[elpa] externals/disk-usage c44cc97 01/26: Set default for directory-size-function dynamically
branch: externals/disk-usage commit c44cc97815b426bc840a166c6eb18f1adf32aa67 Author: Pierre Neidhardt Commit: Pierre Neidhardt Set default for directory-size-function dynamically --- disk-usage.el | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index e3085ff..d5c8629 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -65,7 +65,13 @@ "Whether to kill the current `disk-usage' buffer before moving directory." :type 'boolean) -(defcustom disk-usage--directory-size-function #'disk-usage--directory-size-with-du +(defvar disk-usage--du-command "du") +(defvar disk-usage--du-args "-sb") +(defvar disk-usage--find-command "find") + +(defcustom disk-usage--directory-size-function (if (executable-find disk-usage--du-command) + #'disk-usage--directory-size-with-du + #'disk-usage--directory-size-with-emacs) "Function that returns the total disk usage of the directory passed as argument." :type '(choice (function :tag "Native (slow)" disk-usage--directory-size-with-emacs) (function :tag "System \"du\"" disk-usage--directory-size-with-du))) @@ -141,10 +147,6 @@ :children (- (length (directory-files path)) 2))) (list (disk-usage--file-info-make :size 0 :name directory) -(defvar disk-usage--du-command "du") -(defvar disk-usage--du-args "-sb") -(defvar disk-usage--find-command "find") - (defun disk-usage--list-recursively (directory) "This is the equivalent of running the shell command $ find . -type f -exec du -sb {} +"
[elpa] externals/disk-usage 2874158 03/26: Add TODOs about file-notify, date filtering, formatting and process-file
branch: externals/disk-usage commit 2874158d7ef7cd9340fa7de4d414c8e76080570b Author: Pierre Neidhardt Commit: Pierre Neidhardt Add TODOs about file-notify, date filtering, formatting and process-file --- disk-usage.el | 10 ++ 1 file changed, 10 insertions(+) diff --git a/disk-usage.el b/disk-usage.el index 52d36d2..2822127 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -53,6 +53,16 @@ (require 'tabulated-list) (eval-when-compile (require 'cl-lib)) +;; TODO: Work out the docstrings and align to 80 columns. + +;; TODO: Use process-file instead of call-process. + +;; TODO: Filter out files by date. Make generic filter function? Could factor +;; disk-usage-files into this. + +;; TODO: Use file-notify library to watch file system changes and auto-update. +;; Also see https://github.com/Alexander-Miller/treemacs#filewatch-mode. + ;; TODO: Apparent size? Not obvious, because Emacs file-attributes does not support it. ;; TODO: Helm-FF does not work when file-name-nondirectory is on. ;; TODO: Add support for charts?
[elpa] externals/disk-usage 349719b 11/26: Display symlink targets
branch: externals/disk-usage commit 349719b4370e0361e3ae480d07e1012a68a43f6d Author: Pierre Neidhardt Commit: Pierre Neidhardt Display symlink targets --- disk-usage.el | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index d80fda6..b035aeb 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -53,8 +53,6 @@ (require 'tabulated-list) (eval-when-compile (require 'cl-lib)) -;; TODO: Retest symlinks arrows. - ;; TODO: Filter out files by date. Make generic filter function? Could factor ;; disk-usage-files into this. @@ -314,15 +312,19 @@ FILE-ENTRY may be a string or a button." file-entry)) (formatted-filename (cond + ;; Symlinks ((stringp (file-attribute-type (file-attributes filename))) -(propertize (funcall disk-usage--format-files filename) -'face (if (file-directory-p filename) - 'disk-usage-symlink-directory -'disk-usage-symlink))) +(concat (propertize (funcall disk-usage--format-files filename) +'face (if (file-directory-p filename) + 'disk-usage-symlink-directory +'disk-usage-symlink)) +" -> " (file-attribute-type (file-attributes filename + ;; Directories ((and (not (null (file-attribute-type (file-attributes filename (not (file-accessible-directory-p filename))) (propertize (funcall disk-usage--format-files filename) 'face 'disk-usage-inaccessible)) + ;; Regular files (t (funcall disk-usage--format-files filename) (if (listp file-entry) (let ((copy (cl-copy-list file-entry)))
[elpa] externals/disk-usage 7fd6e43 19/26: Add filters to recursive listings
branch: externals/disk-usage commit 7fd6e43b3c81688b34fe2a0039936c1b356ea59a Author: Pierre Neidhardt Commit: Pierre Neidhardt Add filters to recursive listings --- disk-usage.el | 35 --- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index 12b92e1..e30b245 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -256,21 +256,26 @@ See `disk-usage-add-filters' and `disk-usage-remove-filters'.") "This is the equivalent of running the shell command $ find . -type f -exec du -sb {} +" (setq directory (or directory default-directory)) - ;; TODO: Add filters here. - (mapcar (lambda (s) -(let ((pair (split-string s "\t"))) - (disk-usage--file-info-make - :name (cadr pair) - :size (string-to-number (cl-first pair) - (split-string (with-temp-buffer - (process-file disk-usage--find-command nil '(t nil) nil -directory -"-type" "f" -"-exec" -disk-usage--du-command -disk-usage--du-args "{}" "+") -(buffer-string)) - "\n" 'omit-nulls))) + (delq + nil + (mapcar (lambda (s) + (let* ((pair (split-string s "\t")) +(name (cadr pair)) +(attributes (file-attributes name))) + (when (cl-loop for filter in disk-usage-filters + always (funcall filter name attributes)) + (disk-usage--file-info-make + :name name + :size (string-to-number (cl-first pair)) + (split-string (with-temp-buffer + (process-file disk-usage--find-command nil '(t nil) nil + directory + "-type" "f" + "-exec" + disk-usage--du-command + disk-usage--du-args "{}" "+") + (buffer-string)) + "\n" 'omit-nulls (defcustom disk-usage-list-function #'disk-usage--list "Function that returns a list of `disk-usage--file-info'.
[elpa] externals/disk-usage 2d36a87 04/26: Fix disk-usage--path-at-point to return directory
branch: externals/disk-usage commit 2d36a87eca2bb2015a37298ca497f1fa995d70fc Author: Pierre Neidhardt Commit: Pierre Neidhardt Fix disk-usage--path-at-point to return directory It's now resilient to column change. --- disk-usage.el | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index 2822127..cc69541 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -402,11 +402,8 @@ Also see `disk-usage-by-types-mode'." ;; FIXME: The GNU convention is to use "path" only for lists of directories ;; as in `load-path' and $PATH and to use "file name" for what you here call ;; "path". --Stef - (let* ((entry (tabulated-list-get-entry (point))) - (path (aref entry 1))) -(if (listp path) -(setq path (cl-first path)) - path))) + (let ((file-info (tabulated-list-get-id (point +(disk-usage--file-info-name file-info))) (defun disk-usage--directory-at-point () (let ((path (disk-usage--path-at-point)))
[elpa] externals/disk-usage 6a01954 05/26: Rename disk-usage--path-at-point -> disk-usage--file-name-at-point
branch: externals/disk-usage commit 6a019549f2d1eb30d79d4e4b7e68a7f1bf844aab Author: Pierre Neidhardt Commit: Pierre Neidhardt Rename disk-usage--path-at-point -> disk-usage--file-name-at-point --- disk-usage.el | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index cc69541..04ebd26 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -398,15 +398,12 @@ Also see `disk-usage-by-types-mode'." (kill-this-buffer)) (disk-usage (expand-file-name ".." directory -(defun disk-usage--path-at-point () - ;; FIXME: The GNU convention is to use "path" only for lists of directories - ;; as in `load-path' and $PATH and to use "file name" for what you here call - ;; "path". --Stef +(defun disk-usage--file-name-at-point () (let ((file-info (tabulated-list-get-id (point (disk-usage--file-info-name file-info))) (defun disk-usage--directory-at-point () - (let ((path (disk-usage--path-at-point))) + (let ((path (disk-usage--file-name-at-point))) (if (file-directory-p path) path (setq path (file-name-directory path) @@ -452,7 +449,7 @@ non-nil or with prefix argument." (defun disk-usage-find-file-at-point () (interactive) - (find-file (disk-usage--path-at-point))) + (find-file (disk-usage--file-name-at-point))) (defun disk-usage-dired-at-point () (interactive)
[elpa] externals/disk-usage 1d85ea5 10/26: Fix missing total-size in header
branch: externals/disk-usage commit 1d85ea5155f22257b6ba52c6b10541e7f5fbc906 Author: Pierre Neidhardt Commit: Pierre Neidhardt Fix missing total-size in header --- disk-usage.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index de662ad..d80fda6 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -53,7 +53,7 @@ (require 'tabulated-list) (eval-when-compile (require 'cl-lib)) -;; TODO: Retest total-size and symlinks arrows. +;; TODO: Retest symlinks arrows. ;; TODO: Filter out files by date. Make generic filter function? Could factor ;; disk-usage-files into this. @@ -261,7 +261,7 @@ Takes a number and returns a string." (setq directory (or directory default-directory)) (let* ((listing (funcall disk-usage-list-function directory)) (total-size (disk-usage--total listing))) -(disk-usage--set-tabulated-list-format ) +(disk-usage--set-tabulated-list-format total-size) (tabulated-list-init-header) (setq tabulated-list-entries (mapcar
[elpa] externals/disk-usage 20ed51e 13/26: Fix mark not being set
branch: externals/disk-usage commit 20ed51ef903bc38b492ec7cdf16de7195359e766 Author: Pierre Neidhardt Commit: Pierre Neidhardt Fix mark not being set --- disk-usage.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disk-usage.el b/disk-usage.el index 39d5a25..c8dfb83 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -441,7 +441,7 @@ See `disk-usage-mark' and `disk-usage-unmark'." mark (or mark "*")) (dotimes (_ count) (let ((file-info (tabulated-list-get-id (point -(setf (disk-usage--file-info-marked file-info) (string= mark ""))) +(setf (disk-usage--file-info-marked file-info) (not (string= mark "" (tabulated-list-put-tag mark) (forward-line step
[elpa] externals/disk-usage c7f4597 16/26: Customize default filters
branch: externals/disk-usage commit c7f4597817f899dae51c033281bf82595a337b7e Author: Pierre Neidhardt Commit: Pierre Neidhardt Customize default filters --- disk-usage.el | 6 ++ 1 file changed, 6 insertions(+) diff --git a/disk-usage.el b/disk-usage.el index 22ed325..585ecf5 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -182,6 +182,10 @@ See `disk-usage-add-filters' and `disk-usage-remove-filters'. You can add custom filters to this list." :type '(repeat 'symbol)) +(defcustom disk-usage-default-filters '() + "Filters to enable in new `disk-usage' buffers." + :type '(repeat 'symbol)) + (defvar-local disk-usage-filters nil "List of `disk-usage' filters in current buffer. See `disk-usage-add-filters' and `disk-usage-remove-filters'.") @@ -486,6 +490,7 @@ If DIRECTORY is nil, use current directory." (get-buffer-create (format "*%s<%s>*" disk-usage-buffer-name (directory-file-name directory (disk-usage-mode) + (setq disk-usage-filters disk-usage-default-filters) (setq default-directory directory) (tabulated-list-revert)) @@ -725,6 +730,7 @@ If nil, LISTING is taken from the entry in the (switch-to-buffer (get-buffer-create (format "*%s*" disk-usage-files-buffer-name))) (disk-usage-mode) +(setq disk-usage-filters disk-usage-default-filters) (set (make-local-variable 'disk-usage-list-function) (lambda (_) (disk-usage--list nil listing-with-attributes))) (tabulated-list-revert)))
[elpa] externals/disk-usage 54d4aee 25/26: Propertize size, percent and children columns
branch: externals/disk-usage commit 54d4aee73dfeb5589a712b62905eb65926ac Author: Pierre Neidhardt Commit: Pierre Neidhardt Propertize size, percent and children columns --- disk-usage.el | 24 +++- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index dd28afe..fa25931 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -110,7 +110,19 @@ (defface disk-usage-symlink-directory '((t :inherit disk-usage-symlink :underline t)) - "Face for symlinks.") + "Face for symlinked directories.") + +(defface disk-usage-size + '((t :inherit default)) + "Face for sizes.") + +(defface disk-usage-percent + '((t :inherit default)) + "Face for the percent column.") + +(defface disk-usage-children + '((t :inherit default)) + "Face for the children column.") (defvar disk-usage-mode-map (let ((map (make-sparse-keymap))) @@ -470,11 +482,13 @@ FILE-ENTRY may be a string or a button." cols) cols (setq x (tabulated-list-print-col 0 -(funcall disk-usage-size-format-function - (string-to-number (aref cols 0))) +(propertize + (funcall disk-usage-size-format-function + (string-to-number (aref cols 0))) + 'face 'disk-usage-size) x)) - (setq x (tabulated-list-print-col 1 (aref cols 1) x)) - (setq x (tabulated-list-print-col 2 (aref cols 2) x)) + (setq x (tabulated-list-print-col 1 (propertize (aref cols 1) 'face 'disk-usage-percent) x)) + (setq x (tabulated-list-print-col 2 (propertize (aref cols 2) 'face 'disk-usage-children) x)) (setq x (tabulated-list-print-col 3 (disk-usage--print-file-col (aref cols 3)) x)) (cl-loop for i from 4 below ncols do (setq x (tabulated-list-print-col i (aref cols i) x
[elpa] externals/disk-usage 6a214bc 09/26: Add many docstrings
branch: externals/disk-usage commit 6a214bc6066e108fbdd53b86ce39a3ecca05e21e Author: Pierre Neidhardt Commit: Pierre Neidhardt Add many docstrings --- disk-usage.el | 29 +++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index 2e4aec9..de662ad 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -53,7 +53,7 @@ (require 'tabulated-list) (eval-when-compile (require 'cl-lib)) -;; TODO: Work out the docstrings and align to 80 columns. +;; TODO: Retest total-size and symlinks arrows. ;; TODO: Filter out files by date. Make generic filter function? Could factor ;; disk-usage-files into this. @@ -289,6 +289,7 @@ Takes a string and returns a string. `identity' and `file-name-nondirectory' are good candidates.") (defun disk-usage-toggle-human-readable () + "Toggle between printing size in bytes or in more readable units." (interactive) (setq disk-usage-size-format-function (if (eq disk-usage-size-format-function #'file-size-human-readable) @@ -297,6 +298,7 @@ Takes a string and returns a string. (tabulated-list-revert)) (defun disk-usage-toggle-full-path () + "Toggle between displaying the full paths or the base names." (interactive) (setq disk-usage--format-files (if (eq disk-usage--format-files #'identity) @@ -382,6 +384,8 @@ Also see `disk-usage-by-types-mode'." ;;;###autoload (defun disk-usage (&optional directory) + "Display listing of files in DIRECTORY with their size. +If DIRECTORY is nil, use current directory." (interactive "D") (unless (file-accessible-directory-p directory) (error "Directory cannot be opened: %S" directory)) @@ -399,11 +403,15 @@ Also see `disk-usage-by-types-mode'." ;;;###autoload (defun disk-usage-here () + "Run `disk-usage' in current directory." (interactive) (disk-usage default-directory)) (defun disk-usage-up (&optional discard-previous-buffer) - (interactive) + "Run `disk-usage' in the parent directory. +With DISCARD-PREVIOUS-BUFFER or prefix argument, current buffer +is deleted before switching." + (interactive "p") (let ((directory default-directory)) (when (and (or discard-previous-buffer disk-usage-discard-previous-buffer) (eq major-mode 'disk-usage-mode)) @@ -421,6 +429,8 @@ Also see `disk-usage-by-types-mode'." (setq path (file-name-directory path) (defun disk-usage-mark-at-point (&optional count mark) + "Mark entry at point. +See `disk-usage-mark' and `disk-usage-unmark'." (interactive "p") (let ((step (if (> count 0) 1 -1))) (setq count (abs count) @@ -432,6 +442,10 @@ Also see `disk-usage-by-types-mode'." (forward-line step (defun disk-usage-mark (&optional count mark) + "Mark files for deletion with `disk-usage-delete-marked-files'. +With numeric argument, mark that many times. +With negative numeric argument, move upward. +When region is active, mark all entries in region." (interactive "p") (if (region-active-p) (let ((count (count-lines @@ -443,6 +457,10 @@ Also see `disk-usage-by-types-mode'." (disk-usage-mark-at-point count mark))) (defun disk-usage-unmark (&optional count) + "Unmark files marked with `disk-usage-mark'. +With numeric argument, unmark that many times. +With negative numeric argument, move upward. +When region is active, unmark all entries in region." (interactive "p") (disk-usage-mark count "")) @@ -460,6 +478,7 @@ non-nil or with prefix argument." (tabulated-list-revert))) (defun disk-usage-find-file-at-point () + "Find file at point in Emacs." (interactive) (find-file (disk-usage--file-name-at-point))) @@ -468,11 +487,13 @@ non-nil or with prefix argument." (dired (disk-usage--directory-at-point))) (defun disk-usage-eshell-at-point () + "Run a new `eshell' from the folder at point." (interactive) (let ((default-directory (disk-usage--directory-at-point))) (eshell 'new-session))) (defun disk-usage-shell-at-point () + "Run a new `shell' from the folder at point." (interactive) (let ((default-directory (disk-usage--directory-at-point))) (shell (get-buffer-create (generate-new-buffer-name "*shell*") @@ -596,12 +617,16 @@ Also see `disk-usage-mode'." ;;;###autoload (defun disk-usage-by-types-here () + "Run `disk-usage-by-types' in current directory." (interactive) (disk-usage-by-types default-directory)) (defvar disk-usage-files-buffer-name "disk-usage-files") (defun disk-usage-files (&optional listing) + "Run `disk-usage' over LISTING. +If nil, LISTING is taken from the entry in the +`disk-usage-by-types' buffer." (interactive) (unless (eq major-mode 'disk-usage-by-types-mode) (error "Must be in a disk-usage-by-types buffer"))
[elpa] externals/disk-usage 284c142 24/26: Inherit from error/warning faces instead of defining foreground colors
branch: externals/disk-usage commit 284c1424104c96f4dc190abb6c0c67446b259135 Author: Pierre Neidhardt Commit: Pierre Neidhardt Inherit from error/warning faces instead of defining foreground colors --- disk-usage.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index 1888a67..dd28afe 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -99,12 +99,12 @@ (function :tag "System \"du\"" disk-usage--directory-size-with-du))) (defface disk-usage-inaccessible - '((t :foreground "red" + '((t :inherit error :underline t)) "Face for inaccessible folders.") (defface disk-usage-symlink - '((t :foreground "orange")) + '((t :inherit warning)) "Face for symlinks.") (defface disk-usage-symlink-directory
[elpa] externals/disk-usage updated (0bbb9a6 -> a53be8d)
ambrevar pushed a change to branch externals/disk-usage. from 0bbb9a6 * disk-usage.el: Fix copyright and minor tweaks new c44cc97 Set default for directory-size-function dynamically new cec7fc6 Require Emacs 26 for file-attribute-* functions new 2874158 Add TODOs about file-notify, date filtering, formatting and process-file new 2d36a87 Fix disk-usage--path-at-point to return directory new 6a01954 Rename disk-usage--path-at-point -> disk-usage--file-name-at-point new 936b73d Actually use disk-usage--find-command new 7708379 Use process-file instead of call-process new 8bf5d5c Break some long lines new 6a214bc Add many docstrings new 1d85ea5 Fix missing total-size in header new 349719b Display symlink targets new 0fff6a8 Fix 'nil' children issue on inaccessible directories new 20ed51e Fix mark not being set new 488ddc8 Add support for filters new 6846590 Add 1-hour filter new c7f4597 Customize default filters new aa7d267 Document filters new 0feb208 Message instead of warning when no filters new 7fd6e43 Add filters to recursive listings new 364c62b Bind "a" and "A" to filter commands in disk-usage-by-types new bcae407 Replace (delq (mapcar ...)) with cl-loop new 7b14829 Normalize filter names new ea2bcd2 Set du-command dynamically for BSD/macOS and make command settings customizable new 284c142 Inherit from error/warning faces instead of defining foreground colors new 54d4aee Propertize size, percent and children columns new a53be8d Version 1.2.0 Summary of changes: disk-usage.el | 374 -- readme.org| 6 + 2 files changed, 289 insertions(+), 91 deletions(-)
[elpa] externals/disk-usage bcae407 21/26: Replace (delq (mapcar ...)) with cl-loop
branch: externals/disk-usage commit bcae4074f63527844b8d24c714da1f0caedccb28 Author: Pierre Neidhardt Commit: Pierre Neidhardt Replace (delq (mapcar ...)) with cl-loop --- disk-usage.el | 24 +++- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index 94c9da7..01667f2 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -256,18 +256,7 @@ See `disk-usage-add-filters' and `disk-usage-remove-filters'.") "This is the equivalent of running the shell command $ find . -type f -exec du -sb {} +" (setq directory (or directory default-directory)) - (delq - nil - (mapcar (lambda (s) - (let* ((pair (split-string s "\t")) -(name (cadr pair)) -(attributes (file-attributes name))) - (when (cl-loop for filter in disk-usage-filters - always (funcall filter name attributes)) - (disk-usage--file-info-make - :name name - :size (string-to-number (cl-first pair)) - (split-string (with-temp-buffer + (let ((pair-strings (split-string (with-temp-buffer (process-file disk-usage--find-command nil '(t nil) nil directory "-type" "f" @@ -275,7 +264,16 @@ $ find . -type f -exec du -sb {} +" disk-usage--du-command disk-usage--du-args "{}" "+") (buffer-string)) - "\n" 'omit-nulls +"\n" 'omit-nulls))) +(cl-loop for pair-string in pair-strings + for pair = (split-string pair-string "\t") + for name = (cadr pair) + for attributes = (file-attributes name) + when (cl-loop for filter in disk-usage-filters + always (funcall filter name attributes)) + collect (disk-usage--file-info-make + :name name + :size (string-to-number (cl-first pair)) (defcustom disk-usage-list-function #'disk-usage--list "Function that returns a list of `disk-usage--file-info'.
[elpa] externals/disk-usage 936b73d 06/26: Actually use disk-usage--find-command
branch: externals/disk-usage commit 936b73d6800470a1c0b4b0e363ffac6fa61960e5 Author: Pierre Neidhardt Commit: Pierre Neidhardt Actually use disk-usage--find-command --- disk-usage.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disk-usage.el b/disk-usage.el index 04ebd26..3b26368 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -167,7 +167,7 @@ $ find . -type f -exec du -sb {} +" :name (cadr pair) :size (string-to-number (cl-first pair) (split-string (with-temp-buffer - (call-process "find" nil '(t nil) nil + (call-process disk-usage--find-command nil '(t nil) nil directory "-type" "f" "-exec" disk-usage--du-command disk-usage--du-args "{}" "+")
[elpa] externals/disk-usage 6846590 15/26: Add 1-hour filter
branch: externals/disk-usage commit 684659078d16cfcc47e311dc53cd99a01f57ebd6 Author: Pierre Neidhardt Commit: Pierre Neidhardt Add 1-hour filter --- disk-usage.el | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/disk-usage.el b/disk-usage.el index 1900148..22ed325 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -130,6 +130,16 @@ (interactive) (clrhash disk-usage--cache)) +(defun disk-usage-filter-1-hour (_path attributes &optional seconds) + (if (null (file-attribute-type attributes)) + ;; Regular files + (time-less-p + (time-since +(file-attribute-modification-time attributes)) + (seconds-to-time (or seconds (* 60 60 +;; Always keep directories and symlinks. +t)) + (defun disk-usage-filter-1-day (_path attributes &optional days) (if (null (file-attribute-type attributes)) ;; Regular files @@ -156,7 +166,8 @@ (defun disk-usage-filter-10M-size (path attributes) (disk-usage-filter-1M-size path attributes (* 10 1024 1024))) -(defcustom disk-usage-available-filters '(disk-usage-filter-1-day +(defcustom disk-usage-available-filters '(disk-usage-filter-1-hour + disk-usage-filter-1-day disk-usage-filter-1-week disk-usage-filter-4-week disk-usage-filter-1M-size
[elpa] externals/disk-usage 7708379 07/26: Use process-file instead of call-process
branch: externals/disk-usage commit 7708379cc923abce1efcc6dc04733bb7e91dc246 Author: Pierre Neidhardt Commit: Pierre Neidhardt Use process-file instead of call-process --- disk-usage.el | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index 3b26368..39963fa 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -55,8 +55,6 @@ ;; TODO: Work out the docstrings and align to 80 columns. -;; TODO: Use process-file instead of call-process. - ;; TODO: Filter out files by date. Make generic filter function? Could factor ;; disk-usage-files into this. @@ -167,7 +165,7 @@ $ find . -type f -exec du -sb {} +" :name (cadr pair) :size (string-to-number (cl-first pair) (split-string (with-temp-buffer - (call-process disk-usage--find-command nil '(t nil) nil + (process-file disk-usage--find-command nil '(t nil) nil directory "-type" "f" "-exec" disk-usage--du-command disk-usage--du-args "{}" "+") @@ -214,7 +212,7 @@ This is slow but does not require any external process." (split-string (with-temp-buffer (with-output-to-string - (call-process disk-usage--du-command + (process-file disk-usage--du-command nil '(t nil) nil disk-usage--du-args path)) (buffer-string))
[elpa] externals/disk-usage cec7fc6 02/26: Require Emacs 26 for file-attribute-* functions
branch: externals/disk-usage commit cec7fc6adf0aa6926e60983041e9534b0833c5a5 Author: Pierre Neidhardt Commit: Pierre Neidhardt Require Emacs 26 for file-attribute-* functions --- disk-usage.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disk-usage.el b/disk-usage.el index d5c8629..52d36d2 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -6,7 +6,7 @@ ;; Maintainer: Pierre Neidhardt ;; URL: https://gitlab.com/Ambrevar/emacs-disk-usage ;; Version: 1.1.0 -;; Package-Requires: ((emacs "25.1")) +;; Package-Requires: ((emacs "26.1")) ;; Keywords: files, convenience, tools ;; This file is not part of GNU Emacs.
[elpa] externals/disk-usage 0feb208 18/26: Message instead of warning when no filters
branch: externals/disk-usage commit 0feb208fa8630d8934b53978b25ef50d3fc2456c Author: Pierre Neidhardt Commit: Pierre Neidhardt Message instead of warning when no filters --- disk-usage.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disk-usage.el b/disk-usage.el index 0f4d5d9..12b92e1 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -207,7 +207,7 @@ See `disk-usage-add-filters' and `disk-usage-remove-filters'.") (defun disk-usage-remove-filters () (interactive) (if (null disk-usage-filters) - (warn "No filters in this buffer.") + (message "No filters in this buffer.") (let ((filters (completing-read-multiple "Filters: " disk-usage-filters nil
[elpa] externals/disk-usage aa7d267 17/26: Document filters
branch: externals/disk-usage commit aa7d267da5337234922315d2a90120f44520b57c Author: Pierre Neidhardt Commit: Pierre Neidhardt Document filters --- disk-usage.el | 4 readme.org| 4 2 files changed, 8 insertions(+) diff --git a/disk-usage.el b/disk-usage.el index 585ecf5..0f4d5d9 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -46,6 +46,10 @@ ;; ;; With a prefix argument, cache is updated when reverting the buffer. ;; +;; With `disk-usage-add-filters' you can filter out files with arbitrary +;; predicates, e.g. files bigger than some size or older than a certain number +;; of days. +;; ;; You can customize options in the 'disk-usage group. diff --git a/readme.org b/readme.org index 9d3ee32..596cb11 100644 --- a/readme.org +++ b/readme.org @@ -39,6 +39,10 @@ extensions. With a prefix argument, cache is updated when reverting the buffer. +With ~disk-usage-add-filters~ you can filter out files with arbitrary +predicates, e.g. files bigger than some size or older than a certain number of +days. + You can customize options in the =disk-usage= group. * Screenshots
[elpa] externals/disk-usage 488ddc8 14/26: Add support for filters
branch: externals/disk-usage commit 488ddc8e4b4836029bdd31b1e6b2a9a715c09b44 Author: Pierre Neidhardt Commit: Pierre Neidhardt Add support for filters --- disk-usage.el | 79 --- 1 file changed, 76 insertions(+), 3 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index c8dfb83..1900148 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -51,10 +51,10 @@ ;;; Code: (require 'tabulated-list) +(require 'seq) (eval-when-compile (require 'cl-lib)) -;; TODO: Filter out files by date. Make generic filter function? Could factor -;; disk-usage-files into this. +;; TODO: Can we factor `disk-usage-files' into filters? ;; TODO: Use file-notify library to watch file system changes and auto-update. ;; Also see https://github.com/Alexander-Miller/treemacs#filewatch-mode. @@ -103,6 +103,8 @@ (define-key map (kbd "S-") #'disk-usage-find-file-at-point) (define-key map (kbd "") #'disk-usage-up) (define-key map "^" #'disk-usage-up) +(define-key map "a" #'disk-usage-add-filters) +(define-key map "A" #'disk-usage-remove-filters) (define-key map "d" #'disk-usage-dired-at-point) (define-key map "e" #'disk-usage-eshell-at-point) (define-key map "h" #'disk-usage-toggle-human-readable) @@ -128,6 +130,74 @@ (interactive) (clrhash disk-usage--cache)) +(defun disk-usage-filter-1-day (_path attributes &optional days) + (if (null (file-attribute-type attributes)) + ;; Regular files + (time-less-p + (time-since +(file-attribute-modification-time attributes)) + (days-to-time (or days 1))) +;; Always keep directories and symlinks. +t)) + +(defun disk-usage-filter-1-week (path attributes) + (disk-usage-filter-1-day path attributes 7)) + +(defun disk-usage-filter-4-weeks (path attributes) + (disk-usage-filter-1-day path attributes 28)) + +(defun disk-usage-filter-1M-size (_path attributes &optional size) + (if (null (file-attribute-type attributes)) + ;; Regular files + (> (file-attribute-size attributes) (or size (* 1024 1024))) +;; Always keep directories and symlinks. +t)) + +(defun disk-usage-filter-10M-size (path attributes) + (disk-usage-filter-1M-size path attributes (* 10 1024 1024))) + +(defcustom disk-usage-available-filters '(disk-usage-filter-1-day + disk-usage-filter-1-week + disk-usage-filter-4-week + disk-usage-filter-1M-size + disk-usage-filter-10M-size) + "Filters can be used to leave out files from the listing. + +A filter is a function that takes a path and file attributes and +return nil to exclude a file or non-nil to include it. +A file must pass all the filters to be included. +See `disk-usage-add-filters' and `disk-usage-remove-filters'. + +You can add custom filters to this list." + :type '(repeat 'symbol)) + +(defvar-local disk-usage-filters nil + "List of `disk-usage' filters in current buffer. +See `disk-usage-add-filters' and `disk-usage-remove-filters'.") + +(defun disk-usage-add-filters () + (interactive) + (let ((filters (completing-read-multiple "Filters: " + disk-usage-available-filters + nil + t))) +(dolist (filter filters) + (add-to-list 'disk-usage-filters (intern filter))) +(tabulated-list-revert))) + +(defun disk-usage-remove-filters () + (interactive) + (if (null disk-usage-filters) + (warn "No filters in this buffer.") +(let ((filters (completing-read-multiple "Filters: " + disk-usage-filters + nil + t))) + (setq disk-usage-filters +(seq-difference disk-usage-filters +(mapcar #'intern filters))) + (tabulated-list-revert + (defun disk-usage--list (directory &optional listing) (setq directory (or directory default-directory)) (let ((listing (or listing @@ -138,13 +208,15 @@ (or (cl-loop for l in listing for attributes = (cl-rest l) for path = (cl-first l) + if (cl-loop for filter in disk-usage-filters + always (funcall filter path attributes)) ;; Files if (null (file-attribute-type attributes)) collect (disk-usage--file-info-make :name path :size (file-attribute-size attribu
[elpa] externals/disk-usage 364c62b 20/26: Bind "a" and "A" to filter commands in disk-usage-by-types
branch: externals/disk-usage commit 364c62b9ca9b578ef3f020747757d52b6e86e189 Author: Pierre Neidhardt Commit: Pierre Neidhardt Bind "a" and "A" to filter commands in disk-usage-by-types --- disk-usage.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/disk-usage.el b/disk-usage.el index e30b245..94c9da7 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -691,6 +691,8 @@ TYPE is the file extension (lower case)." (let ((map (make-sparse-keymap))) (set-keymap-parent map tabulated-list-mode-map) (define-key map "h" #'disk-usage-toggle-human-readable) +(define-key map "a" #'disk-usage-add-filters) +(define-key map "A" #'disk-usage-remove-filters) ;; Don't use "" since that doesn't work in a tty. (define-key map (kbd "RET") #'disk-usage-files) map)
[elpa] externals/disk-usage 7b14829 22/26: Normalize filter names
branch: externals/disk-usage commit 7b148294a2807ce770b37bb6a7c54080be459990 Author: Pierre Neidhardt Commit: Pierre Neidhardt Normalize filter names --- disk-usage.el | 43 +++ 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index 01667f2..63b7fd9 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -134,7 +134,8 @@ (interactive) (clrhash disk-usage--cache)) -(defun disk-usage-filter-1-hour (_path attributes &optional seconds) +(defun disk-usage-filter-1-hour> (_path attributes &optional seconds) + "Discard regular files older than 1 hour." (if (null (file-attribute-type attributes)) ;; Regular files (time-less-p @@ -144,7 +145,8 @@ ;; Always keep directories and symlinks. t)) -(defun disk-usage-filter-1-day (_path attributes &optional days) +(defun disk-usage-filter-1-day> (_path attributes &optional days) + "Discard regular files older than 1 day." (if (null (file-attribute-type attributes)) ;; Regular files (time-less-p @@ -154,28 +156,37 @@ ;; Always keep directories and symlinks. t)) -(defun disk-usage-filter-1-week (path attributes) - (disk-usage-filter-1-day path attributes 7)) +(defun disk-usage-filter-1-week> (path attributes) + (disk-usage-filter-1-day> path attributes 7)) -(defun disk-usage-filter-4-weeks (path attributes) - (disk-usage-filter-1-day path attributes 28)) +(defun disk-usage-filter-4-weeks> (path attributes) + (disk-usage-filter-1-day> path attributes 28)) -(defun disk-usage-filter-1M-size (_path attributes &optional size) +(defun disk-usage-filter-1-MiB> (_path attributes &optional size) + "Discard regular files bigger than 1 MiB." (if (null (file-attribute-type attributes)) ;; Regular files - (> (file-attribute-size attributes) (or size (* 1024 1024))) + (< (file-attribute-size attributes) (or size (* 1024 1024))) ;; Always keep directories and symlinks. t)) -(defun disk-usage-filter-10M-size (path attributes) - (disk-usage-filter-1M-size path attributes (* 10 1024 1024))) +(defun disk-usage-filter-10-MiB> (path attributes) + (disk-usage-filter-1-MiB> path attributes (* 10 1024 1024))) -(defcustom disk-usage-available-filters '(disk-usage-filter-1-hour - disk-usage-filter-1-day - disk-usage-filter-1-week - disk-usage-filter-4-week - disk-usage-filter-1M-size - disk-usage-filter-10M-size) +(defun disk-usage-filter-100-MiB> (path attributes) + (disk-usage-filter-1-MiB> path attributes (* 100 1024 1024))) + +(defun disk-usage-filter-1-GiB> (path attributes) + (disk-usage-filter-1-MiB> path attributes (* 1024 1024 1024))) + +(defcustom disk-usage-available-filters '(disk-usage-filter-1-hour> + disk-usage-filter-1-day> + disk-usage-filter-1-week> + disk-usage-filter-4-weeks> + disk-usage-filter-1-MiB> + disk-usage-filter-10-MiB> + disk-usage-filter-100-MiB> + disk-usage-filter-1-GiB>) "Filters can be used to leave out files from the listing. A filter is a function that takes a path and file attributes and
[elpa] externals/disk-usage 0fff6a8 12/26: Fix 'nil' children issue on inaccessible directories
branch: externals/disk-usage commit 0fff6a89c6e90d9526ace4aad4e815b863b7315c Author: Pierre Neidhardt Commit: Pierre Neidhardt Fix 'nil' children issue on inaccessible directories --- disk-usage.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/disk-usage.el b/disk-usage.el index b035aeb..39d5a25 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -156,7 +156,9 @@ (disk-usage--file-info-make :name path :size (disk-usage--directory-size path) - :children (- (length (directory-files path)) 2))) + :children (if (file-accessible-directory-p path) +(- (length (directory-files path)) 2) + 0))) (list (disk-usage--file-info-make :size 0 :name directory) (defun disk-usage--list-recursively (directory)
[elpa] externals/disk-usage 8bf5d5c 08/26: Break some long lines
branch: externals/disk-usage commit 8bf5d5c4949e87c2fb38bb91d7c55eba25f42286 Author: Pierre Neidhardt Commit: Pierre Neidhardt Break some long lines --- disk-usage.el | 124 +++--- 1 file changed, 74 insertions(+), 50 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index 39963fa..2e4aec9 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -77,9 +77,10 @@ (defvar disk-usage--du-args "-sb") (defvar disk-usage--find-command "find") -(defcustom disk-usage--directory-size-function (if (executable-find disk-usage--du-command) - #'disk-usage--directory-size-with-du - #'disk-usage--directory-size-with-emacs) +(defcustom disk-usage--directory-size-function + (if (executable-find disk-usage--du-command) + #'disk-usage--directory-size-with-du +#'disk-usage--directory-size-with-emacs) "Function that returns the total disk usage of the directory passed as argument." :type '(choice (function :tag "Native (slow)" disk-usage--directory-size-with-emacs) (function :tag "System \"du\"" disk-usage--directory-size-with-du))) @@ -133,26 +134,31 @@ (setq directory (or directory default-directory)) (let ((listing (or listing (and (file-accessible-directory-p directory) - (directory-files-and-attributes directory 'full nil 'nosort) + (directory-files-and-attributes + directory + 'full nil 'nosort) (or (cl-loop for l in listing for attributes = (cl-rest l) for path = (cl-first l) ;; Files if (null (file-attribute-type attributes)) - collect (disk-usage--file-info-make :name path - :size (file-attribute-size attributes)) + collect (disk-usage--file-info-make + :name path + :size (file-attribute-size attributes)) ;; Symlinks if (stringp (file-attribute-type attributes)) - collect (disk-usage--file-info-make :name path - :size (file-attribute-size attributes)) + collect (disk-usage--file-info-make + :name path + :size (file-attribute-size attributes)) ;; Folders else if (and (eq t (file-attribute-type attributes)) (not (string= "." (file-name-base path))) (not (string= ".." (file-name-base path collect - (disk-usage--file-info-make :name path - :size (disk-usage--directory-size path) - :children (- (length (directory-files path)) 2))) + (disk-usage--file-info-make + :name path + :size (disk-usage--directory-size path) + :children (- (length (directory-files path)) 2))) (list (disk-usage--file-info-make :size 0 :name directory) (defun disk-usage--list-recursively (directory) @@ -168,7 +174,9 @@ $ find . -type f -exec du -sb {} +" (process-file disk-usage--find-command nil '(t nil) nil directory "-type" "f" -"-exec" disk-usage--du-command disk-usage--du-args "{}" "+") +"-exec" +disk-usage--du-command +disk-usage--du-args "{}" "+") (buffer-string)) "\n" 'omit-nulls))) @@ -256,21 +264,24 @@ Takes a number and returns a string." (disk-usage--set-tabulated-list-format ) (tabulated-list-init-header) (setq tabulated-list-entries - (mapcar (lambda (file-info) -(list file-info (vector (number-to-string (disk-usage--file-info-size file-info)) -(format "%.1f%%" -(* 100 (/ (float (disk-usage--file-info-size file-info)) - total-size))) -(number-to-string (disk-usage--file-info-children file-i
[elpa] externals/disk-usage ea2bcd2 23/26: Set du-command dynamically for BSD/macOS and make command settings customizable
branch: externals/disk-usage commit ea2bcd27fd3f4e9eef7028e0ddb6093dde370903 Author: Pierre Neidhardt Commit: Pierre Neidhardt Set du-command dynamically for BSD/macOS and make command settings customizable --- disk-usage.el | 19 +++ readme.org| 2 ++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index 63b7fd9..1888a67 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -26,6 +26,9 @@ ;;; Commentary: ;; +;; Warning: BSD and macOS users need `gdu`, the "GNU du" from the "GNU +;; coreutils". +;; ;; Disk Usage is a file system analyzer: it offers a tabulated view of file ;; listings sorted by size. Directory sizes are computed recursively. The results ;; are cached for speed. @@ -35,7 +38,7 @@ ;; `disk-usage-dired-at-point' to open a `dired' buffer for the current ;; directory. ;; -;; Instead of displaying only the current folder, ~disk-usage~ can also display +;; Instead of displaying only the current folder, `disk-usage' can also display ;; files in all subfolders recursively with `disk-usage-toggle-recursive'. ;; ;; Marked files can be trashed with `disk-usage-delete-marked-files'. When @@ -75,9 +78,17 @@ "Whether to kill the current `disk-usage' buffer before moving directory." :type 'boolean) -(defvar disk-usage--du-command "du") -(defvar disk-usage--du-args "-sb") -(defvar disk-usage--find-command "find") +(defcustom disk-usage--du-command (if (member system-type '(gnu gnu/linux gnu/kfreebsd)) + "du" +"gdu") + "Non-GNU users need GNU's `du' for the `-b' flag. See `disk-usage--du-args'." + :type 'string) +(defcustom disk-usage--du-args "-sb" + "Non-GNU users need GNU's `du' for the `-b' flag. See `disk-usage--du-command'." + :type 'string) +(defcustom disk-usage--find-command "find" + "The `find' executable. This is required for recursive listings." + :type 'string) (defcustom disk-usage--directory-size-function (if (executable-find disk-usage--du-command) diff --git a/readme.org b/readme.org index 596cb11..e1ad843 100644 --- a/readme.org +++ b/readme.org @@ -22,6 +22,8 @@ Load the package with : (require 'disk-usage) +Warning: BSD and macOS users need `gdu`, the "GNU du" from the "GNU coreutils". + * Features Run ~disk-usage~ or ~disk-usage-here~ to display a listing. See ~describe-mode~
[elpa] externals/disk-usage a53be8d 26/26: Version 1.2.0
branch: externals/disk-usage commit a53be8d94a1b1af1e6e92471a54f02b36c62ae92 Author: Pierre Neidhardt Commit: Pierre Neidhardt Version 1.2.0 --- disk-usage.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disk-usage.el b/disk-usage.el index fa25931..b2d79f1 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -5,7 +5,7 @@ ;; Author: Pierre Neidhardt ;; Maintainer: Pierre Neidhardt ;; URL: https://gitlab.com/Ambrevar/emacs-disk-usage -;; Version: 1.1.0 +;; Version: 1.2.0 ;; Package-Requires: ((emacs "26.1")) ;; Keywords: files, convenience, tools
[elpa] externals/disk-usage cea4662 4/4: Maybe-optimize disk-usage--list-recursively
branch: externals/disk-usage commit cea46628bcc0681281d78cdd0f5da34f81752d90 Author: Pierre Neidhardt Commit: Pierre Neidhardt Maybe-optimize disk-usage--list-recursively It does not seem to make a difference locally. Maybe remotely. --- disk-usage.el | 27 +-- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index 8312ba0..622ab05 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -298,25 +298,24 @@ $ find . -type f -exec du -sb {} +" (setq directory (or directory default-directory)) (let* ((default-directory directory) ;; Note: Cannot use `process-lines' if we want to work on remote hosts. - (pair-strings (split-string + (subdirs (split-string (with-temp-buffer (process-file disk-usage-find-command nil '(t nil) nil (file-local-name directory) -"-type" "f" -"-exec" -disk-usage-du-command -disk-usage-du-args "{}" "+") +"-type" "d") (buffer-string)) "\n" 'omit-nulls))) -(cl-loop for pair-string in pair-strings - for pair = (split-string pair-string "\t") - for name = (concat (file-remote-p directory) (cadr pair)) - for attributes = (file-attributes name) - when (cl-loop for filter in disk-usage-filters - always (funcall filter name attributes)) - collect (disk-usage--file-info-make - :name name - :size (string-to-number (cl-first pair)) +(cl-loop for dir in subdirs + append (cl-loop for file in (directory-files-and-attributes dir 'full nil 'nosort) + for name = (concat (file-remote-p directory) (car file)) + for attributes = (cdr file) + when (and attributes + (not (file-attribute-type attributes)) + (cl-loop for filter in disk-usage-filters +always (funcall filter name attributes))) + collect (disk-usage--file-info-make + :name name + :size (file-attribute-size attributes)) (defcustom disk-usage-list-function #'disk-usage--list "Function that returns a list of `disk-usage--file-info'.
[elpa] externals/disk-usage 64750a9 3/4: Catch nil DIRECTORY in DISK-USAGE
branch: externals/disk-usage commit 64750a9de114332ff04a97114522e40873d19e3b Author: Pierre Neidhardt Commit: Pierre Neidhardt Catch nil DIRECTORY in DISK-USAGE --- disk-usage.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/disk-usage.el b/disk-usage.el index 6b8590f..8312ba0 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -341,6 +341,8 @@ It takes the directory to scan as argument." (let ((size (unless current-prefix-arg (gethash path disk-usage--cache (unless size + ;; TODO: Add progress "bar"? But can we get progress for "du"? + ;; Maybe just print progress when using `disk-usage-directory-size-with-emacs'. (message "Computing disk usage for %S..." path) (setq size (funcall disk-usage-directory-size-function path)) (puthash path size disk-usage--cache)) @@ -533,7 +535,7 @@ Also see `disk-usage-by-types-mode'." "Display listing of files in DIRECTORY with their size. If DIRECTORY is nil, use current directory." (interactive "D") - (unless (file-accessible-directory-p directory) + (unless (and (stringp directory) (file-accessible-directory-p directory)) (error "Directory cannot be opened: %S" directory)) (unless disk-usage--cache (setq disk-usage--cache (make-hash-table :test #'equal)))
[elpa] externals/disk-usage 21d1d0e 1/4: Rename "--" -> "-" in user-facing symbols
branch: externals/disk-usage commit 21d1d0ea307a52f382414bf741446948f743a3bb Author: Pierre Neidhardt Commit: Pierre Neidhardt Rename "--" -> "-" in user-facing symbols --- disk-usage.el | 52 ++-- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index b2d79f1..1252f4c 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -78,25 +78,31 @@ "Whether to kill the current `disk-usage' buffer before moving directory." :type 'boolean) -(defcustom disk-usage--du-command (if (member system-type '(gnu gnu/linux gnu/kfreebsd)) - "du" -"gdu") - "Non-GNU users need GNU's `du' for the `-b' flag. See `disk-usage--du-args'." +(defcustom disk-usage-du-command (if (member system-type '(gnu gnu/linux gnu/kfreebsd)) + "du" + "gdu") + "Non-GNU users need GNU's `du' for the `-b' flag. See `disk-usage-du-args'." :type 'string) -(defcustom disk-usage--du-args "-sb" - "Non-GNU users need GNU's `du' for the `-b' flag. See `disk-usage--du-command'." +(defvaralias 'disk-usage--du-command 'disk-usage-du-command) + +(defcustom disk-usage-du-args "-sb" + "Non-GNU users need GNU's `du' for the `-b' flag. See `disk-usage-du-command'." :type 'string) -(defcustom disk-usage--find-command "find" +(defvaralias 'disk-usage--du-args 'disk-usage-du-args) + +(defcustom disk-usage-find-command "find" "The `find' executable. This is required for recursive listings." :type 'string) +(defvaralias 'disk-usage--find-command 'disk-usage-find-command) -(defcustom disk-usage--directory-size-function - (if (executable-find disk-usage--du-command) - #'disk-usage--directory-size-with-du -#'disk-usage--directory-size-with-emacs) +(defcustom disk-usage-directory-size-function + (if (executable-find disk-usage-du-command) + #'disk-usage-directory-size-with-du +#'disk-usage-directory-size-with-emacs) "Function that returns the total disk usage of the directory passed as argument." - :type '(choice (function :tag "Native (slow)" disk-usage--directory-size-with-emacs) - (function :tag "System \"du\"" disk-usage--directory-size-with-du))) + :type '(choice (function :tag "Native (slow)" disk-usage-directory-size-with-emacs) + (function :tag "System \"du\"" disk-usage-directory-size-with-du))) +(defvaralias 'disk-usage--directory-size-function 'disk-usage-directory-size-function) (defface disk-usage-inaccessible '((t :inherit error @@ -291,12 +297,12 @@ See `disk-usage-add-filters' and `disk-usage-remove-filters'.") $ find . -type f -exec du -sb {} +" (setq directory (or directory default-directory)) (let ((pair-strings (split-string (with-temp-buffer - (process-file disk-usage--find-command nil '(t nil) nil + (process-file disk-usage-find-command nil '(t nil) nil directory "-type" "f" "-exec" - disk-usage--du-command - disk-usage--du-args "{}" "+") + disk-usage-du-command + disk-usage-du-args "{}" "+") (buffer-string)) "\n" 'omit-nulls))) (cl-loop for pair-string in pair-strings @@ -333,26 +339,28 @@ It takes the directory to scan as argument." (gethash path disk-usage--cache (unless size (message "Computing disk usage for %S..." path) - (setq size (funcall disk-usage--directory-size-function path)) + (setq size (funcall disk-usage-directory-size-function path)) (puthash path size disk-usage--cache)) size)) -(defun disk-usage--directory-size-with-emacs (path) +(defun disk-usage-directory-size-with-emacs (path) "Return the total disk usage of directory PATH as a number. This is slow but does not require any external process." (disk-usage--total (disk-usage--list path))) +(defalias 'disk-usage--directory-size-with-emacs 'disk-usage-directory-size-with-emacs) -(defun disk-usage--directo
[elpa] externals/disk-usage updated (a53be8d -> cea4662)
ambrevar pushed a change to branch externals/disk-usage. from a53be8d Version 1.2.0 new 21d1d0e Rename "--" -> "-" in user-facing symbols new c6e06b2 Fix support for remote locations new 64750a9 Catch nil DIRECTORY in DISK-USAGE new cea4662 Maybe-optimize disk-usage--list-recursively Summary of changes: disk-usage.el | 88 +-- 1 file changed, 50 insertions(+), 38 deletions(-)
[elpa] externals/disk-usage c6e06b2 2/4: Fix support for remote locations
branch: externals/disk-usage commit c6e06b2446c5750e6c3da63ce0e88999e63b3fea Author: Pierre Neidhardt Commit: Pierre Neidhardt Fix support for remote locations --- disk-usage.el | 25 ++--- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index 1252f4c..6b8590f 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -296,18 +296,21 @@ See `disk-usage-add-filters' and `disk-usage-remove-filters'.") "This is the equivalent of running the shell command $ find . -type f -exec du -sb {} +" (setq directory (or directory default-directory)) - (let ((pair-strings (split-string (with-temp-buffer - (process-file disk-usage-find-command nil '(t nil) nil - directory - "-type" "f" - "-exec" - disk-usage-du-command - disk-usage-du-args "{}" "+") - (buffer-string)) -"\n" 'omit-nulls))) + (let* ((default-directory directory) + ;; Note: Cannot use `process-lines' if we want to work on remote hosts. + (pair-strings (split-string +(with-temp-buffer + (process-file disk-usage-find-command nil '(t nil) nil +(file-local-name directory) +"-type" "f" +"-exec" +disk-usage-du-command +disk-usage-du-args "{}" "+") + (buffer-string)) +"\n" 'omit-nulls))) (cl-loop for pair-string in pair-strings for pair = (split-string pair-string "\t") - for name = (cadr pair) + for name = (concat (file-remote-p directory) (cadr pair)) for attributes = (file-attributes name) when (cl-loop for filter in disk-usage-filters always (funcall filter name attributes)) @@ -358,7 +361,7 @@ This is slow but does not require any external process." (with-output-to-string (process-file disk-usage-du-command nil '(t nil) nil - disk-usage-du-args path)) + disk-usage-du-args (file-local-name path))) (buffer-string)) (defalias 'disk-usage--directory-size-with-du 'disk-usage-directory-size-with-du)
[elpa] externals/disk-usage 9281e3a 2/3: Make disk-usage-list-function buffer local
branch: externals/disk-usage commit 9281e3a814f265416e7d28f42ca3ade44ca4436d Author: Pierre Neidhardt Commit: Pierre Neidhardt Make disk-usage-list-function buffer local --- disk-usage.el | 1 + 1 file changed, 1 insertion(+) diff --git a/disk-usage.el b/disk-usage.el index 2114ec7..cfcf9d4 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -326,6 +326,7 @@ $ find . -type f -exec du -sb {} +" It takes the directory to scan as argument." :type '(choice (function :tag "Hierarchical" disk-usage--list) (function :tag "Flat (recursive)" disk-usage--list-recursively))) +(make-variable-buffer-local 'disk-usage-list-function) (defun disk-usage-toggle-recursive () "Toggle between hierarchical and flat view."
[elpa] externals/disk-usage updated (cea4662 -> 8bdf331)
ambrevar pushed a change to branch externals/disk-usage. from cea4662 Maybe-optimize disk-usage--list-recursively new 6ab1504 Fix TRAMP support further new 9281e3a Make disk-usage-list-function buffer local new 8bdf331 Toggle the behaviour of disk-usage-discard-previous-buffer Summary of changes: disk-usage.el | 44 +++- readme.org| 3 +++ 2 files changed, 30 insertions(+), 17 deletions(-)
[elpa] externals/disk-usage 6ab1504 1/3: Fix TRAMP support further
branch: externals/disk-usage commit 6ab1504bfb8105130393b7746b54abbc478338d8 Author: Pierre Neidhardt Commit: Pierre Neidhardt Fix TRAMP support further It works with /sudo:: now. --- disk-usage.el | 30 +- readme.org| 3 +++ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index 622ab05..2114ec7 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -263,7 +263,7 @@ See `disk-usage-add-filters' and `disk-usage-remove-filters'.") (and (file-accessible-directory-p directory) (directory-files-and-attributes directory - 'full nil 'nosort) + 'full directory-files-no-dot-files-regexp 'nosort) (or (cl-loop for l in listing for attributes = (cl-rest l) for path = (cl-first l) @@ -280,9 +280,7 @@ See `disk-usage-add-filters' and `disk-usage-remove-filters'.") :name path :size (file-attribute-size attributes)) ;; Folders - else if (and (eq t (file-attribute-type attributes)) - (not (string= "." (file-name-base path))) - (not (string= ".." (file-name-base path + else if (eq t (file-attribute-type attributes)) collect (disk-usage--file-info-make :name path @@ -299,15 +297,21 @@ $ find . -type f -exec du -sb {} +" (let* ((default-directory directory) ;; Note: Cannot use `process-lines' if we want to work on remote hosts. (subdirs (split-string -(with-temp-buffer - (process-file disk-usage-find-command nil '(t nil) nil -(file-local-name directory) -"-type" "d") - (buffer-string)) -"\n" 'omit-nulls))) -(cl-loop for dir in subdirs - append (cl-loop for file in (directory-files-and-attributes dir 'full nil 'nosort) - for name = (concat (file-remote-p directory) (car file)) + (with-temp-buffer + (process-file disk-usage-find-command nil '(t nil) nil + (file-local-name directory) + "-type" "d") + (buffer-string)) + "\n" 'omit-nulls)) + (remote-subdirs (mapcar (lambda (item) + (concat (file-remote-p directory) item)) + subdirs))) +(cl-loop for dir in remote-subdirs + append (cl-loop for file in (directory-files-and-attributes dir + 'full + directory-files-no-dot-files-regexp + 'nosort) + for name = (car file) for attributes = (cdr file) when (and attributes (not (file-attribute-type attributes)) diff --git a/readme.org b/readme.org index e1ad843..a45fea5 100644 --- a/readme.org +++ b/readme.org @@ -45,6 +45,9 @@ With ~disk-usage-add-filters~ you can filter out files with arbitrary predicates, e.g. files bigger than some size or older than a certain number of days. +~disk-usage~ also works with TRAMP, i.e. in folders with restricted-acess like +=/sudo::/root= or on remote machines. + You can customize options in the =disk-usage= group. * Screenshots
[elpa] externals/disk-usage 8bdf331 3/3: Toggle the behaviour of disk-usage-discard-previous-buffer
branch: externals/disk-usage commit 8bdf3312855f39ae92ce918b385123133bf2b5e3 Author: Pierre Neidhardt Commit: Pierre Neidhardt Toggle the behaviour of disk-usage-discard-previous-buffer --- disk-usage.el | 13 + 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index cfcf9d4..741cbe9 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -560,13 +560,18 @@ If DIRECTORY is nil, use current directory." (interactive) (disk-usage default-directory)) -(defun disk-usage-up (&optional discard-previous-buffer) +(defun disk-usage-up (&optional toggle-discard-previous-buffer) "Run `disk-usage' in the parent directory. -With DISCARD-PREVIOUS-BUFFER or prefix argument, current buffer -is deleted before switching." +If `disk-usage-discard-previous-buffer' is non-nil, +the current buffer is discarded before switched. +With TOGGLE-DISCARD-PREVIOUS-BUFFER or prefix argument, this behaviour is +reversed." (interactive "p") (let ((directory default-directory)) -(when (and (or discard-previous-buffer disk-usage-discard-previous-buffer) +(when (and (or (and (not toggle-discard-previous-buffer) +disk-usage-discard-previous-buffer) + (and toggle-discard-previous-buffer +(not disk-usage-discard-previous-buffer))) (eq major-mode 'disk-usage-mode)) (kill-this-buffer)) (disk-usage (expand-file-name ".." directory
[elpa] externals/disk-usage 7b1f74e 1/2: Ask for directory in prompt
branch: externals/disk-usage commit 7b1f74e91d70ce36b9dda6791311cc06115c4f89 Author: Pierre Neidhardt Commit: Pierre Neidhardt Ask for directory in prompt --- disk-usage.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index 741cbe9..9a31781 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -538,7 +538,7 @@ Also see `disk-usage-by-types-mode'." (defun disk-usage (&optional directory) "Display listing of files in DIRECTORY with their size. If DIRECTORY is nil, use current directory." - (interactive "D") + (interactive "DDirectory name: ") (unless (and (stringp directory) (file-accessible-directory-p directory)) (error "Directory cannot be opened: %S" directory)) (unless disk-usage--cache @@ -764,7 +764,7 @@ Also see `disk-usage-mode'." ;;;###autoload (defun disk-usage-by-types (&optional directory) - (interactive "D") + (interactive "DDirectory name: ") (setq directory (file-truename (or (and (file-directory-p directory) directory) default-directory)))
[elpa] externals/disk-usage updated (8bdf331 -> 828f0b0)
ambrevar pushed a change to branch externals/disk-usage. from 8bdf331 Toggle the behaviour of disk-usage-discard-previous-buffer new 7b1f74e Ask for directory in prompt new 828f0b0 Version 1.3.0 Summary of changes: disk-usage.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
[elpa] externals/disk-usage 828f0b0 2/2: Version 1.3.0
branch: externals/disk-usage commit 828f0b0194d481672ed32b8dc8959a93bd068a5a Author: Pierre Neidhardt Commit: Pierre Neidhardt Version 1.3.0 --- disk-usage.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disk-usage.el b/disk-usage.el index 9a31781..ae60280 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -5,7 +5,7 @@ ;; Author: Pierre Neidhardt ;; Maintainer: Pierre Neidhardt ;; URL: https://gitlab.com/Ambrevar/emacs-disk-usage -;; Version: 1.2.0 +;; Version: 1.3.0 ;; Package-Requires: ((emacs "26.1")) ;; Keywords: files, convenience, tools
[elpa] tag 1.2.0 created (now a53be8d)
ambrevar pushed a change to tag 1.2.0. at a53be8d (commit) No new revisions were added by this update.
[elpa] tag 1.0.0 created (now 5998d42)
ambrevar pushed a change to tag 1.0.0. at 5998d42 (commit) No new revisions were added by this update.
[elpa] tag 1.3.0 created (now 828f0b0)
ambrevar pushed a change to tag 1.3.0. at 828f0b0 (commit) No new revisions were added by this update.
[elpa] tag 1.1.0 created (now e44979a)
ambrevar pushed a change to tag 1.1.0. at e44979a (commit) No new revisions were added by this update.
[elpa] externals/disk-usage updated (828f0b0 -> 57c4c69)
ambrevar pushed a change to branch externals/disk-usage. from 828f0b0 Version 1.3.0 new 63a3ca8 Fall back on 0 in -directory-size-with-du new 57c4c69 Version 1.3.1 Summary of changes: disk-usage.el | 21 +++-- 1 file changed, 11 insertions(+), 10 deletions(-)
[elpa] externals/disk-usage 57c4c69 2/2: Version 1.3.1
branch: externals/disk-usage commit 57c4c69777f524c8b6e337ecc3a6302e57e5db81 Author: Pierre Neidhardt Commit: Pierre Neidhardt Version 1.3.1 --- disk-usage.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disk-usage.el b/disk-usage.el index bc49287..7dbd574 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -5,7 +5,7 @@ ;; Author: Pierre Neidhardt ;; Maintainer: Pierre Neidhardt ;; URL: https://gitlab.com/Ambrevar/emacs-disk-usage -;; Version: 1.3.0 +;; Version: 1.3.1 ;; Package-Requires: ((emacs "26.1")) ;; Keywords: files, convenience, tools
[elpa] externals/webfeeder b5148b4 22/22: Version 1.0.0
branch: externals/webfeeder commit b5148b42914f10e56c51bcd149b13b5bf94a1415 Author: Pierre Neidhardt Commit: Pierre Neidhardt Version 1.0.0 --- webfeeder.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webfeeder.el b/webfeeder.el index 0fdd5cb..eeb47a6 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -5,7 +5,7 @@ ;; Author: Pierre Neidhardt ;; Maintainer: Pierre Neidhardt ;; URL: https://gitlab.com/Ambrevar/emacs-webfeeder -;; Version: 0.0.1 +;; Version: 1.0.0 ;; Package-Requires: ((emacs "25.1")) ;; Keywords: news, hypermedia, blog, feed, rss, atom
[elpa] externals/webfeeder 73b905e 14/22: Atom: Specify type for content
branch: externals/webfeeder commit 73b905e54ba8cddd5b1c818b70003da42c9e1bb2 Author: Pierre Neidhardt Commit: Pierre Neidhardt Atom: Specify type for content --- webfeeder.el | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/webfeeder.el b/webfeeder.el index e325ec8..f5ae1d8 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -324,10 +324,9 @@ The date is set to epoch if the item date is nil." "\n") (when (webfeeder-item-subtitle item) (concat " " (webfeeder-item-subtitle item) "\n")) - ;; TODO: Pros and cons if we could pass a "type" item to specify HTML or - ;; XHTML and remove CDATA? - ;; " \n" (when (webfeeder-item-categories item)
[elpa] externals/webfeeder f6032b2 03/22: readme.org: Remove spurious (delete...) from base examples
branch: externals/webfeeder commit f6032b229ab7437c01db7701586ced4f01e94306 Author: Pierre Neidhardt Commit: Pierre Neidhardt readme.org: Remove spurious (delete...) from base examples --- readme.org | 10 ++ 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/readme.org b/readme.org index 8483b52..6ace234 100644 --- a/readme.org +++ b/readme.org @@ -44,11 +44,8 @@ Load the package with "./public" "https://example.org/"; '("post1.html" "post2.html" "post3.html") - (delete "index.html" - (mapcar (lambda (f) (replace-regexp-in-string ".*/public/" "" f)) - (directory-files-recursively "public" "index.html"))) :title "My homepage" - :description "A collection of articles") + :description "A collection of articles in Atom") #+end_src - To build an RSS feed, use the RSS builder: @@ -59,11 +56,8 @@ Load the package with "./public" "https://example.org/"; '("post1.html" "post2.html" "post3.html") - (delete "index.html" - (mapcar (lambda (f) (replace-regexp-in-string ".*/public/" "" f)) - (directory-files-recursively "public" "index.html"))) :title "My homepage" - :description "A collection of articles" + :description "A collection of articles in RSS" :builder 'feed-builder-make-rss) #+end_src
[elpa] externals/webfeeder b1986c3 15/22: Atom: Don't test top-level descriptions
branch: externals/webfeeder commit b1986c3af4072d5b9f1e7d79ed3d42c61e602c73 Author: Pierre Neidhardt Commit: Pierre Neidhardt Atom: Don't test top-level descriptions --- webfeeder-test.el | 19 +++ 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/webfeeder-test.el b/webfeeder-test.el index b96f84a..bf063f4 100644 --- a/webfeeder-test.el +++ b/webfeeder-test.el @@ -68,14 +68,17 @@ :description "Example description" :build-date 0 :max-entries max-entries))) -(should-not - (string= - feed-buffer - (funcall builder feed "https://example.org/"; feed-items - :title "Example feed" - :description "Example description TYPO" - :build-date 0 - :max-entries max-entries) +(when (eq builder 'webfeeder-make-rss) + ;; This test is irrelevant to Atom since it does not have a top-level + ;; "description". + (should-not + (string= +feed-buffer +(funcall builder feed "https://example.org/"; feed-items + :title "Example feed" + :description "Example description TYPO" + :build-date 0 + :max-entries max-entries)) (ert-deftest webfeeder-single-rss-libxml () "Simple test using libxml backend.
[elpa] externals/disk-usage 63a3ca8 1/2: Fall back on 0 in -directory-size-with-du
branch: externals/disk-usage commit 63a3ca8707c330589f8f66bf758c56e1e18cfdca Author: Pierre Neidhardt Commit: Pierre Neidhardt Fall back on 0 in -directory-size-with-du --- disk-usage.el | 19 ++- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index ae60280..bc49287 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -360,15 +360,16 @@ This is slow but does not require any external process." (defun disk-usage-directory-size-with-du (path) "See `disk-usage-directory-size-function'." - (string-to-number - (cl-first -(split-string - (with-temp-buffer - (with-output-to-string - (process-file disk-usage-du-command - nil '(t nil) nil - disk-usage-du-args (file-local-name path))) - (buffer-string)) + (or (ignore-errors (string-to-number + (cl-first + (split-string +(with-temp-buffer + (with-output-to-string +(process-file disk-usage-du-command + nil '(t nil) nil + disk-usage-du-args (file-local-name path))) + (buffer-string)) + 0)) (defalias 'disk-usage--directory-size-with-du 'disk-usage-directory-size-with-du) (defun disk-usage--sort-by-size (a b)
[elpa] externals/webfeeder 1355a7b 08/22: webfeeder.el: Copy the readme into the commentary
branch: externals/webfeeder commit 1355a7bf8a9469a7b2179f159cbd3d6b02f8555c Author: Pierre Neidhardt Commit: Pierre Neidhardt webfeeder.el: Copy the readme into the commentary --- webfeeder.el | 35 --- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/webfeeder.el b/webfeeder.el index 0b526df..312b04a 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -26,10 +26,39 @@ ;;; Commentary: ;; -;; The entry point is `webfeeder-build': run it over a set of HTML files to -;; produce the corresponding webfeed. +;; Webfeeder is an Emacs library to generate RSS +;; (https://en.wikipedia.org/wiki/RSS) and Atom +;; (https://en.wikipedia.org/wiki/Atom_(Web_standard)) feeds from HTML files. ;; -;; See https://validator.w3.org/feed/ for an online validation service. +;; Other webfeed generators have been written for Emacs, but either they are +;; tied to other projects like blog generators, or they only work on Org files +;; like `ox-rss'. Since Webfeeder generates webfeeds from HTML files, it is +;; more general. +;; +;; The various elements of the HTML input are parsed with customizable +;; functions. For instance, Webfeeder offers two functions to parse the title: +;; `webfeeder-title-libxml' (using libxml if your Emacs is linked against it) +;; and the less reliable `webfeeder-title-default'. Feel free to write you own +;; function and bind `webfeeder-title-function' before generating the feeds. +;; +;; The generated feeds should be valid on https://validator.w3.org/feed/. If not, +;; it's a bug, please report. +;; +;; The full list of customizable functions is documented in +;; `feed-builder-html-files-to-items'. +;; +;; The entry point is `webfeeder-build': consult its documentation for more +;; information. +;; +;; Example: +;; +;; (feed-builder-build +;; "atom.xml" +;; "./public" +;; "https://example.org/"; +;; '("post1.html" "post2.html" "post3.html") +;; :title "My homepage" +;; :description "A collection of articles in Atom") ;;; Code:
[elpa] externals/webfeeder 4e980b2 17/22: RSS: Only include author if an email address is found in the string
branch: externals/webfeeder commit 4e980b262db619a5ea5f776be6bddeede8c5d7db Author: Pierre Neidhardt Commit: Pierre Neidhardt RSS: Only include author if an email address is found in the string --- webfeeder.el | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/webfeeder.el b/webfeeder.el index 853be21..b05332d 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -297,7 +297,18 @@ The date is set to epoch if the item date is nil." (concat "\n" (when (webfeeder-item-author item) - (concat " " (webfeeder-item-author item) "\n")) + ;; RSS tag must start with the email. If no e-mail is found, we + ;; skip the tag altogether. Since it's hard to parse email addresses, we + ;; use `mail-extract-address-components' which expects the "NAME " + ;; format. + (let ((name+addr (mail-extract-address-components (webfeeder-item-author item + (when (cadr name+addr) + (concat " " + (cadr name+addr) + (if (car name+addr) + (format " (%s)" (car name+addr)) + "") + "\n" " " (webfeeder-item-title item) "\n" " \n" (when (webfeeder-item-categories item)
[elpa] externals/webfeeder 640b214 05/22: readme.org: Recommend libxml
branch: externals/webfeeder commit 640b214a7d5e6058aa1cb6566cbc343606452454 Author: Pierre Neidhardt Commit: Pierre Neidhardt readme.org: Recommend libxml --- readme.org | 3 +++ 1 file changed, 3 insertions(+) diff --git a/readme.org b/readme.org index 6ace234..2bd99e9 100644 --- a/readme.org +++ b/readme.org @@ -34,6 +34,9 @@ Load the package with : (require 'webfeeder) +It's recommended to have an Emacs built against libxml, although basic support +without libxml is also provided. + * Usage - Build an Atom feed:
[elpa] branch externals/webfeeder created (now b5148b4)
ambrevar pushed a change to branch externals/webfeeder. at b5148b4 Version 1.0.0 This branch includes the following new commits: new 7000480 Init new 272bad4 webfeeder-test.el: Privatize -test-pages new f6032b2 readme.org: Remove spurious (delete...) from base examples new 06fab2c webfeeder-test.el: Rename "page" to "rss" in test names new 640b214 readme.org: Recommend libxml new be073b5 webfeeder.el: Edit most docstrings new f34e3d6 readme.org: Fix rename feed-builder -> webfeeder new 1355a7b webfeeder.el: Copy the readme into the commentary new 0f0ca1d Atom: Fix missing closing tag in new 989c576 Atom: Remove from parent node new a7cfbf1 Atom: Separate time with ":" in rfc3339 new 6e0a8d5 Fall back on default author set in webfeeder-default-author new 567fbe3 Atom: Always href attribute for links new 73b905e Atom: Specify type for content new b1986c3 Atom: Don't test top-level descriptions new bfeb09c RSS: Remove subtitle from items since they are not supported by the standard new 4e980b2 RSS: Only include author if an email address is found in the string new 2b10906 Atom: Add support for email address in author field new e462414 testdata/post0.org: Add email address new 26f5200 Update test feeds new 9083513 Assign copyright to the Free Software Foundation new b5148b4 Version 1.0.0
[elpa] externals/webfeeder 567fbe3 13/22: Atom: Always href attribute for links
branch: externals/webfeeder commit 567fbe368019b1165ecbd369e21d37ec52d3fda6 Author: Pierre Neidhardt Commit: Pierre Neidhardt Atom: Always href attribute for links --- webfeeder.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webfeeder.el b/webfeeder.el index e16e55b..e325ec8 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -334,7 +334,7 @@ The date is set to epoch if the item date is nil." (mapconcat (lambda (cat) (concat " " cat "")) (webfeeder-item-categories item) "\n")) - " " (webfeeder-item-url item) "\n" + " \n" " " (webfeeder-item-url item) "\n" " " (webfeeder--date-to-rfc3339 (or (webfeeder-item-date item) 0))
[elpa] externals/webfeeder 6e0a8d5 12/22: Fall back on default author set in webfeeder-default-author
branch: externals/webfeeder commit 6e0a8d5b47095a6d2116511f2d7cc976b49730ed Author: Pierre Neidhardt Commit: Pierre Neidhardt Fall back on default author set in webfeeder-default-author --- webfeeder.el | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/webfeeder.el b/webfeeder.el index 640493c..e16e55b 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -71,6 +71,14 @@ (defun webfeeder-has-libxml-p () (fboundp 'libxml-parse-html-region)) +(defgroup webfeeder nil + "Predefined configurations for `webfeeder'." + :group 'nxml) + +(defcustom webfeeder-default-author "Unknown author" + "When input files don't provide an author and it is required, use this value." + :type 'string) + (defvar webfeeder-author-function (if (webfeeder-has-libxml-p) 'webfeeder-author-libxml 'webfeeder-author-default) @@ -311,8 +319,9 @@ The date is set to epoch if the item date is nil." (concat "\n" " " (webfeeder-item-title item) "\n" - (when (webfeeder-item-author item) - (concat " " (webfeeder-item-author item) "\n")) + (concat " " (or (webfeeder-item-author item) + webfeeder-default-author) + "\n") (when (webfeeder-item-subtitle item) (concat " " (webfeeder-item-subtitle item) "\n")) ;; TODO: Pros and cons if we could pass a "type" item to specify HTML or
[elpa] externals/webfeeder 26f5200 20/22: Update test feeds
branch: externals/webfeeder commit 26f5200e04d6dc8a58fccf2327cab4fd1b5ce2f9 Author: Pierre Neidhardt Commit: Pierre Neidhardt Update test feeds --- testdata/default-post0.atom | 17 - testdata/default-post0.rss | 9 - testdata/libxml-post0+post1.atom| 32 testdata/libxml-post0+post1.rss | 17 - testdata/libxml-post0-no-fancy.atom | 17 - testdata/libxml-post0-no-fancy.rss | 7 +++ testdata/libxml-post0-no-html.atom | 17 - testdata/libxml-post0-no-html.rss | 7 +++ testdata/libxml-post0.atom | 17 - testdata/libxml-post0.rss | 7 +++ testdata/libxml-post1.atom | 20 ++-- testdata/libxml-post1.rss | 10 +- testdata/post0-html5-fancy.html | 14 +++--- testdata/post0-html5.html | 14 +++--- testdata/post0.html | 14 +++--- testdata/post1-html5-fancy.html | 16 testdata/post1-html5.html | 16 testdata/post1.html | 16 18 files changed, 129 insertions(+), 138 deletions(-) diff --git a/testdata/default-post0.atom b/testdata/default-post0.atom index 67c1831..b3a23b3 100644 --- a/testdata/default-post0.atom +++ b/testdata/default-post0.atom @@ -1,16 +1,15 @@ http://www.w3.org/2005/Atom";>Example feed -Example description Emacs webfeeder.el -https://example.org/";> +https://example.org/"/> https://example.org/default-post0.atom"; rel="self"/> https://example.org/default-post0.atom -1970-01-01T01:00:00+0100 +1970-01-01T01:00:00+01:00 First post - John Doe + John Doej...@doe.org First post's subtitle - - https://example.org/post0-html5-fancy.html + https://example.org/post0-html5-fancy.html"/> https://example.org/post0-html5-fancy.html - 2019-03-13T17:46:00+0100 + 2019-03-26T10:22:00+01:00 diff --git a/testdata/default-post0.rss b/testdata/default-post0.rss index 4d17520..f12847e 100644 --- a/testdata/default-post0.rss +++ b/testdata/default-post0.rss @@ -8,9 +8,8 @@ https://example.org/default-post0.rss"; rel="self" type="application/rss+xml"/> Thu, 01 Jan 1970 01:00:00 +0100 - John Doe + j...@doe.org (John Doe) First post - First post's subtitle https://example.org/post0-html5-fancy.html https://example.org/post0-html5-fancy.html - Wed, 13 Mar 2019 17:46:00 +0100 + Tue, 26 Mar 2019 10:22:00 +0100 diff --git a/testdata/libxml-post0+post1.atom b/testdata/libxml-post0+post1.atom index 1cd34e2..72be1f8 100644 --- a/testdata/libxml-post0+post1.atom +++ b/testdata/libxml-post0+post1.atom @@ -1,14 +1,14 @@ http://www.w3.org/2005/Atom";>Example feed -Example description Emacs webfeeder.el -https://example.org/";> +https://example.org/"/> https://example.org/libxml-post0+post1.atom"; rel="self"/> https://example.org/libxml-post0+post1.atom -1970-01-01T01:00:00+0100 +1970-01-01T01:00:00+01:00 Second post - - https://example.org/post1-html5-fancy.html + https://example.org/post1-html5-fancy.html"/> https://example.org/post1-html5-fancy.html - 2019-03-13T01:00:00+0100 + 2019-03-26T01:00:00+01:00 First post - John Doe + John Doej...@doe.org First post's subtitle - - https://example.org/post0-html5-fancy.html + https://example.org/post0-html5-fancy.html"/> https://example.org/post0-html5-fancy.html - 2019-01-27T01:00:00+0100 + 2019-01-27T01:00:00+01:00 diff --git a/testdata/libxml-post0+post1.rss b/testdata/libxml-post0+post1.rss index c1d043f..ad433a1 100644 --- a/testdata/libxml-post0+post1.rss +++ b/testdata/libxml-post0+post1.rss @@ -23,8 +23,8 @@ id ligula quis est convallis tempor. Curabitur lacinia pulvinar nibh. Nam a sapien. - - 1 Section 1 + + 1 Section 1 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec hendrerit @@ -37,8 +37,8 @@ Nam vestibulum accumsan nisl. - - 2 Section 2 + + 2 Section 2 Pellentesque dapibus suscipit ligula. Donec posuere augue in quam. Etiam vel @@ -57,12 +57,11 @@ tellus lacinia purus, et dictum nunc justo sit amet elit. ]]> https://example.org/post1-html5-fancy.html https://example.org/post1-html5-fancy.html - Wed, 13 Mar 2019 01:00:00 +0100 + Tue, 26 Mar 2019 01:00:00 +0100 - John Doe + j...@doe.org (John Doe) First post - First post's subtitle - https://example.org/post0-html5.html + https://example.org/post0-html5.html"/> https://example.org/post0-html5.html - 2019-01-27T01:00:00+0100 + 2019-01-27T01:00:00+01:00 diff --git a/testdata/libxml-post0-no-fancy.rss b/testdata/libxml-post0-no-fancy.rss index 25e643b..a9300a2 100644 --- a/testdata/libxml-post0-no-fancy.rss +++ b/
[elpa] externals/webfeeder 2b10906 18/22: Atom: Add support for email address in author field
branch: externals/webfeeder commit 2b10906181f9b18c86cb2703e98b00771174beee Author: Pierre Neidhardt Commit: Pierre Neidhardt Atom: Add support for email address in author field --- webfeeder.el | 33 +++-- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/webfeeder.el b/webfeeder.el index b05332d..e6ec2df 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -301,12 +301,12 @@ The date is set to epoch if the item date is nil." ;; skip the tag altogether. Since it's hard to parse email addresses, we ;; use `mail-extract-address-components' which expects the "NAME " ;; format. - (let ((name+addr (mail-extract-address-components (webfeeder-item-author item + (let ((name+addr (webfeeder--extract-name+email (webfeeder-item-author item (when (cadr name+addr) (concat " " (cadr name+addr) (if (car name+addr) - (format " (%s)" (car name+addr)) + (format " (%s)" (xml-escape-string (car name+addr))) "") "\n" " " (webfeeder-item-title item) "\n" @@ -322,15 +322,36 @@ The date is set to epoch if the item date is nil." "\n" "\n")) +(defun webfeeder--extract-name+email (address) + "Like `mail-extract-address-components' but does not set the +address part if email is missing. +For instance, calling this function on \"foo\" returns (\"foo\" nil)." + (let ((name+addr (mail-extract-address-components address))) +(when (string= (car name+addr) + (cadr name+addr)) + (setcdr name+addr nil)) +name+addr)) + +(defun webfeeder--format-atom-author (author) + (concat "" + (let ((name+addr (webfeeder--extract-name+email author))) +(if (cadr name+addr) +(format "%s%s" +(xml-escape-string (car name+addr)) +(cadr name+addr)) + (format "%s" (xml-escape-string author + "\n")) + (defun webfeeder-item-to-atom (item) "Return an atom ITEM as a string. The date is set to epoch if the item date is nil." (concat "\n" " " (webfeeder-item-title item) "\n" - (concat " " (or (webfeeder-item-author item) - webfeeder-default-author) - "\n") + (concat " " + (webfeeder--format-atom-author +(or (webfeeder-item-author item) +webfeeder-default-author))) (when (webfeeder-item-subtitle item) (concat " " (webfeeder-item-subtitle item) "\n")) ;; TODO: What's the impact of chosing between HTML or XHTML as a type? Can @@ -479,7 +500,7 @@ FEED-ITEMS can be generated with `webfeeder-html-files-to-items'." (insert "\n" "http://www.w3.org/2005/Atom\";>" (if author - (concat "" author "\n") + (webfeeder--format-atom-author author) "") "" title "\n" (if subtitle
[elpa] externals/webfeeder 06fab2c 04/22: webfeeder-test.el: Rename "page" to "rss" in test names
branch: externals/webfeeder commit 06fab2cf853986d149714733c2d8a72b1b44ecc6 Author: Pierre Neidhardt Commit: Pierre Neidhardt webfeeder-test.el: Rename "page" to "rss" in test names --- webfeeder-test.el | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/webfeeder-test.el b/webfeeder-test.el index 2fe1159..b96f84a 100644 --- a/webfeeder-test.el +++ b/webfeeder-test.el @@ -77,8 +77,7 @@ :build-date 0 :max-entries max-entries) -;; TODO: Rename "page" to "rss". -(ert-deftest webfeeder-single-page-libxml () +(ert-deftest webfeeder-single-rss-libxml () "Simple test using libxml backend. This requires an Emacs compiled against libxml." (cl-assert (file-directory-p webfeeder-test-dir)) @@ -89,7 +88,7 @@ This requires an Emacs compiled against libxml." (webfeeder--test-pages "libxml-post0.rss" '("post0-html5-fancy.html") 'webfeeder-make-rss -(ert-deftest webfeeder-single-page-default () +(ert-deftest webfeeder-single-rss-default () "Simple test using regular expressions to parse XML." (cl-assert (file-directory-p webfeeder-test-dir)) (let ((default-directory (expand-file-name webfeeder-test-dir default-directory))) @@ -99,7 +98,7 @@ This requires an Emacs compiled against libxml." (webfeeder--test-pages "default-post0.rss" '("post0-html5-fancy.html") 'webfeeder-make-rss -(ert-deftest webfeeder-multi-page-libxml () +(ert-deftest webfeeder-multi-rss-libxml () (cl-assert (file-directory-p webfeeder-test-dir)) (let ((default-directory (expand-file-name webfeeder-test-dir default-directory))) (let ((webfeeder-date-function 'webfeeder-date-libxml) @@ -119,7 +118,7 @@ This requires an Emacs compiled against libxml." "post1-html5-fancy.html") 'webfeeder-make-rss 1 -(ert-deftest webfeeder-single-page-no-html5 () +(ert-deftest webfeeder-single-rss-no-html5 () (cl-assert (file-directory-p webfeeder-test-dir)) (let ((default-directory (expand-file-name webfeeder-test-dir default-directory))) (let ((webfeeder-date-function 'webfeeder-date-libxml) @@ -128,7 +127,7 @@ This requires an Emacs compiled against libxml." (webfeeder--test-pages "libxml-post0-no-html.rss" '("post0.html") 'webfeeder-make-rss -(ert-deftest webfeeder-single-page-no-fancy () +(ert-deftest webfeeder-single-rss-no-fancy () (cl-assert (file-directory-p webfeeder-test-dir)) (let ((default-directory (expand-file-name webfeeder-test-dir default-directory))) (let ((webfeeder-date-function 'webfeeder-date-libxml)
[elpa] externals/webfeeder f34e3d6 07/22: readme.org: Fix rename feed-builder -> webfeeder
branch: externals/webfeeder commit f34e3d67e530aa58f95ff5a8ee0333ea0a75ef5a Author: Pierre Neidhardt Commit: Pierre Neidhardt readme.org: Fix rename feed-builder -> webfeeder --- readme.org | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/readme.org b/readme.org index 2bd99e9..6c4c6a3 100644 --- a/readme.org +++ b/readme.org @@ -9,16 +9,16 @@ general. The various elements of the HTML input are parsed with customizable functions. For instance, Webfeeder offers two functions to parse the title: -~feed-builder-title-libxml~ (using libxml if your Emacs is linked against it) -and the less reliable ~feed-builder-title-default~. -Feel free to write you own function and bind ~feed-builder-title-function~ +~webfeeder-title-libxml~ (using libxml if your Emacs is linked against it) +and the less reliable ~webfeeder-title-default~. +Feel free to write you own function and bind ~webfeeder-title-function~ before generating the feeds. The generated feeds should be valid on https://validator.w3.org/feed/. If not, it's a bug, please report. The full list of customizable functions is documented in -~feed-builder-html-files-to-items~. +~webfeeder-html-files-to-items~. * Installation @@ -42,7 +42,7 @@ without libxml is also provided. - Build an Atom feed: #+begin_src elisp -(feed-builder-build +(webfeeder-build "atom.xml" "./public" "https://example.org/"; @@ -54,14 +54,14 @@ without libxml is also provided. - To build an RSS feed, use the RSS builder: #+begin_src elisp -(feed-builder-build +(webfeeder-build "rss.xml" "./public" "https://example.org/"; '("post1.html" "post2.html" "post3.html") :title "My homepage" :description "A collection of articles in RSS" - :builder 'feed-builder-make-rss) + :builder 'webfeeder-make-rss) #+end_src - Use a custom title query function: @@ -77,15 +77,15 @@ without libxml is also provided. nil title -(let ((feed-builder-title-function 'my-title-query)) - (feed-builder-build +(let ((webfeeder-title-function 'my-title-query)) + (webfeeder-build ; ...)) #+end_src - Limit the feed to 20 articles: #+begin_src elisp -(feed-builder-build +(webfeeder-build ; ... :max-entries 20) #+end_src @@ -94,11 +94,11 @@ without libxml is also provided. #+begin_src elisp (defun item-author-is-Alice-p (item) - (string= (feed-builder-item-author item) "Alice") + (string= (webfeeder-item-author item) "Alice") -(feed-builder-build +(webfeeder-build ; ... :predicate 'item-author-is-Alice-p) #+end_src -See the documentation of ~feed-builder-build~ for more options. +See the documentation of ~webfeeder-build~ for more options.
[elpa] externals/webfeeder 272bad4 02/22: webfeeder-test.el: Privatize -test-pages
branch: externals/webfeeder commit 272bad44e8cac63e244e99aad8d52309c384f61b Author: Pierre Neidhardt Commit: Pierre Neidhardt webfeeder-test.el: Privatize -test-pages --- webfeeder-test.el | 27 +-- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/webfeeder-test.el b/webfeeder-test.el index 1966b91..2fe1159 100644 --- a/webfeeder-test.el +++ b/webfeeder-test.el @@ -38,8 +38,7 @@ (put 'string= 'ert-explainer 'webfeeder--string=-explainer) -;; TODO: Make private. -(defun webfeeder-test-pages (feed html-files +(defun webfeeder--test-pages (feed html-files &optional builder max-entries) (setq builder (or builder 'webfeeder-make-atom)) (let* ((feed-buffer (webfeeder--file-to-string feed)) @@ -87,7 +86,7 @@ This requires an Emacs compiled against libxml." (let ((webfeeder-date-function 'webfeeder-date-libxml) (webfeeder-title-function 'webfeeder-title-libxml) (webfeeder-body-function 'webfeeder-body-libxml)) - (webfeeder-test-pages "libxml-post0.rss" '("post0-html5-fancy.html") + (webfeeder--test-pages "libxml-post0.rss" '("post0-html5-fancy.html") 'webfeeder-make-rss (ert-deftest webfeeder-single-page-default () @@ -97,7 +96,7 @@ This requires an Emacs compiled against libxml." (let ((webfeeder-date-function 'webfeeder-date-default) (webfeeder-title-function 'webfeeder-title-default) (webfeeder-body-function 'webfeeder-body-default)) - (webfeeder-test-pages "default-post0.rss" '("post0-html5-fancy.html") + (webfeeder--test-pages "default-post0.rss" '("post0-html5-fancy.html") 'webfeeder-make-rss (ert-deftest webfeeder-multi-page-libxml () @@ -106,7 +105,7 @@ This requires an Emacs compiled against libxml." (let ((webfeeder-date-function 'webfeeder-date-libxml) (webfeeder-title-function 'webfeeder-title-libxml) (webfeeder-body-function 'webfeeder-body-libxml)) - (webfeeder-test-pages "libxml-post0+post1.rss" '("post0-html5-fancy.html" + (webfeeder--test-pages "libxml-post0+post1.rss" '("post0-html5-fancy.html" "post1-html5-fancy.html") 'webfeeder-make-rss @@ -116,7 +115,7 @@ This requires an Emacs compiled against libxml." (let ((webfeeder-date-function 'webfeeder-date-libxml) (webfeeder-title-function 'webfeeder-title-libxml) (webfeeder-body-function 'webfeeder-body-libxml)) - (webfeeder-test-pages "libxml-post1.rss" '("post0-html5-fancy.html" + (webfeeder--test-pages "libxml-post1.rss" '("post0-html5-fancy.html" "post1-html5-fancy.html") 'webfeeder-make-rss 1 @@ -126,7 +125,7 @@ This requires an Emacs compiled against libxml." (let ((webfeeder-date-function 'webfeeder-date-libxml) (webfeeder-title-function 'webfeeder-title-libxml) (webfeeder-body-function 'webfeeder-body-libxml)) - (webfeeder-test-pages "libxml-post0-no-html.rss" '("post0.html") + (webfeeder--test-pages "libxml-post0-no-html.rss" '("post0.html") 'webfeeder-make-rss (ert-deftest webfeeder-single-page-no-fancy () @@ -135,7 +134,7 @@ This requires an Emacs compiled against libxml." (let ((webfeeder-date-function 'webfeeder-date-libxml) (webfeeder-title-function 'webfeeder-title-libxml) (webfeeder-body-function 'webfeeder-body-libxml)) - (webfeeder-test-pages "libxml-post0-no-fancy.rss" '("post0-html5.html") + (webfeeder--test-pages "libxml-post0-no-fancy.rss" '("post0-html5.html") 'webfeeder-make-rss ;; Atom tests. @@ -145,7 +144,7 @@ This requires an Emacs compiled against libxml." (let ((webfeeder-date-function 'webfeeder-date-libxml) (webfeeder-title-function 'webfeeder-title-libxml) (webfeeder-body-function 'webfeeder-body-libxml)) - (webfeeder-test-pages "libxml-post0.atom" '("post0-html5-fancy.html") + (webfeeder--test-pages "libxml-post0.atom" '("post0-html5-fancy.html") 'webfeeder-make-atom (ert-deftest webfeeder-single-atom-default () @@ -154,7 +1
[elpa] externals/webfeeder be073b5 06/22: webfeeder.el: Edit most docstrings
branch: externals/webfeeder commit be073b59b439b510313eafcd812befc655bbf7c8 Author: Pierre Neidhardt Commit: Pierre Neidhardt webfeeder.el: Edit most docstrings --- webfeeder.el | 58 -- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/webfeeder.el b/webfeeder.el index 0dcefd2..0b526df 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -77,17 +77,19 @@ This can be customized to choose which part to include.") "Function to fetch the generator from an HTML file.") (defun webfeeder-author-default (html-file) - "Return the author from the HTML file." + "Return the author from the HTML-FILE, or nil if not found. +This is less reliable than `webfeeder-author-libxml'." (let ((case-fold-search t)) (with-temp-buffer (insert-file-contents html-file) (goto-char (point-min)) - (search-forward-regexp (rx line-start "\n" (when (webfeeder-item-author item) @@ -268,7 +274,7 @@ The item date is set to epoch if the item date is nil." (defun webfeeder-item-to-atom (item) "Return an atom ITEM as a string. -The item date is set to epoch if the item date is nil." +The date is set to epoch if the item date is nil." (concat "\n" " " (webfeeder-item-title item) "\n" @@ -306,7 +312,7 @@ The item date is set to epoch if the item date is nil." ;;;###autoload (defun webfeeder-html-files-to-items (project-dir url html-files) - "Parse the source HTML-FILES located in PROJECT-DIR and set to be hosted at URL. + "Parse the source HTML-FILES and return a list of webfeeder-items. PROJECT-DIR is where HTML files are also assumed to reside. PROJECT-DIR is the local root of the website hosted at URL. HTML parsing details can be customized through the following
[elpa] externals/webfeeder 9083513 21/22: Assign copyright to the Free Software Foundation
branch: externals/webfeeder commit 908351323119acdb24e5b966e249b76d5a10c440 Author: Pierre Neidhardt Commit: Pierre Neidhardt Assign copyright to the Free Software Foundation --- webfeeder.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webfeeder.el b/webfeeder.el index e6ec2df..0fdd5cb 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -1,6 +1,6 @@ ;;; webfeeder.el --- Build RSS and Atom webfeeds from HTML files -*- lexical-binding: t -*- -;; Copyright (C) 2018, 2019 Pierre Neidhardt +;; Copyright (C) 2019 Free Software Foundation, Inc. ;; Author: Pierre Neidhardt ;; Maintainer: Pierre Neidhardt
[elpa] externals/webfeeder 0f0ca1d 09/22: Atom: Fix missing closing tag in
branch: externals/webfeeder commit 0f0ca1d4d2f9eb8b19246338ecd479aa18ce0a65 Author: Pierre Neidhardt Commit: Pierre Neidhardt Atom: Fix missing closing tag in --- webfeeder.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webfeeder.el b/webfeeder.el index 312b04a..688d4d6 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -467,7 +467,7 @@ FEED-ITEMS can be generated with `webfeeder-html-files-to-items'." "" (or description title) "\n" ;; TODO: Change generator name? (concat "" (or generator "Emacs webfeeder.el") "\n") - "\n" + "\n" (format "\n" path) ;; REVIEW: Use UUID?
[elpa] externals/webfeeder 989c576 10/22: Atom: Remove from parent node
branch: externals/webfeeder commit 989c576ae045fe190ced562f5ca87062e7240940 Author: Pierre Neidhardt Commit: Pierre Neidhardt Atom: Remove from parent node --- webfeeder.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webfeeder.el b/webfeeder.el index 688d4d6..6fe6652 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -464,7 +464,8 @@ FEED-ITEMS can be generated with `webfeeder-html-files-to-items'." (if subtitle (concat "" subtitle "\n") "") - "" (or description title) "\n" + ;; TODO: is not supported at the top-level. Where do we put description? + ;; "" (or description title) "\n" ;; TODO: Change generator name? (concat "" (or generator "Emacs webfeeder.el") "\n") "\n"
[elpa] externals/webfeeder 7000480 01/22: Init
branch: externals/webfeeder commit 70004800cc1265032b5ac8b79e514cc7fe0656d7 Author: Pierre Neidhardt Commit: Pierre Neidhardt Init --- COPYING | 674 Makefile| 11 + readme.org | 107 ++ testdata/default-post0.atom | 38 ++ testdata/default-post0.rss | 40 +++ testdata/libxml-post0+post1.atom| 87 + testdata/libxml-post0+post1.rss | 89 + testdata/libxml-post0-no-fancy.atom | 37 ++ testdata/libxml-post0-no-fancy.rss | 39 +++ testdata/libxml-post0-no-html.atom | 37 ++ testdata/libxml-post0-no-html.rss | 39 +++ testdata/libxml-post0.atom | 35 ++ testdata/libxml-post0.rss | 37 ++ testdata/libxml-post1.atom | 61 testdata/libxml-post1.rss | 63 testdata/post0-html5-fancy.html | 50 +++ testdata/post0-html5.html | 51 +++ testdata/post0.html | 53 +++ testdata/post0.org | 16 + testdata/post1-html5-fancy.html | 73 testdata/post1-html5.html | 72 testdata/post1.html | 74 testdata/post1.org | 34 ++ webfeeder-test-gen.el | 121 +++ webfeeder-test.el | 198 +++ webfeeder.el| 484 ++ 26 files changed, 2620 insertions(+) diff --git a/COPYING b/COPYING new file mode 100644 index 000..94a9ed0 --- /dev/null +++ b/COPYING @@ -0,0 +1,674 @@ +GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, b
[elpa] externals/webfeeder bfeb09c 16/22: RSS: Remove subtitle from items since they are not supported by the standard
branch: externals/webfeeder commit bfeb09c4b5792eb2db19586296d8103bbf6fe27c Author: Pierre Neidhardt Commit: Pierre Neidhardt RSS: Remove subtitle from items since they are not supported by the standard --- webfeeder.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/webfeeder.el b/webfeeder.el index f5ae1d8..853be21 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -299,8 +299,6 @@ The date is set to epoch if the item date is nil." (when (webfeeder-item-author item) (concat " " (webfeeder-item-author item) "\n")) " " (webfeeder-item-title item) "\n" - (when (webfeeder-item-subtitle item) - (concat " " (webfeeder-item-subtitle item) "\n")) " \n" (when (webfeeder-item-categories item) (mapconcat (lambda (cat) (concat " " cat ""))
[elpa] externals/webfeeder e462414 19/22: testdata/post0.org: Add email address
branch: externals/webfeeder commit e4624149788f06be7045a334d184996a7ac36d70 Author: Pierre Neidhardt Commit: Pierre Neidhardt testdata/post0.org: Add email address --- testdata/post0.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdata/post0.org b/testdata/post0.org index a28d300..a876384 100644 --- a/testdata/post0.org +++ b/testdata/post0.org @@ -1,6 +1,6 @@ #+TITLE: First post #+SUBTITLE: First post's subtitle -#+AUTHOR: John Doe +#+AUTHOR: John Doe #+DATE: <2019-01-27 Sun> Aliquam erat volutpat. Nunc eleifend leo vitae magna. In id erat non orci
[elpa] externals/webfeeder a7cfbf1 11/22: Atom: Separate time with ":" in rfc3339
branch: externals/webfeeder commit a7cfbf1db31393195c7b98203c29d74371dc2d13 Author: Pierre Neidhardt Commit: Pierre Neidhardt Atom: Separate time with ":" in rfc3339 --- webfeeder.el | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/webfeeder.el b/webfeeder.el index 6fe6652..640493c 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -277,7 +277,11 @@ This requires Emacs to be linked against libxml." (format-time-string "%a, %d %b %Y %H:%M:%S %z" date)) (defun webfeeder--date-to-rfc3339 (date) - (format-time-string "%FT%T%z" date)) + (concat (format-time-string "%FT%T" date) + (let ((zone (format-time-string "%z" date))) +(concat (substring zone 0 3) +":" +(substring zone 3) (defun webfeeder-item-to-rss (item) "Return an RSS ITEM as a string.
[elpa] master 5ea4575: * externals-list: Add webfeeder
branch: master commit 5ea4575b8f446bb5d5564fe341b5e5ce9e51b405 Author: Pierre Neidhardt Commit: Pierre Neidhardt * externals-list: Add webfeeder --- externals-list | 1 + 1 file changed, 1 insertion(+) diff --git a/externals-list b/externals-list index cedce15..f5e5a83 100644 --- a/externals-list +++ b/externals-list @@ -161,6 +161,7 @@ ("w3" :external nil) ("wcheck-mode":subtree "https://github.com/tlikonen/wcheck-mode.git";) ("web-server" :subtree "https://github.com/eschulte/emacs-web-server.git";) + ("webfeeder" :external "https://gitlab.com/ambrevar/emacs-webfeeder.git";) ("websocket" :subtree "https://github.com/ahyatt/emacs-websocket.git";) ("which-key" :subtree "https://github.com/justbur/emacs-which-key";) ("xelb" :external "https://github.com/ch11ng/xelb.git";)
[elpa] externals/webfeeder 0377ecf 3/3: -make-atom: Don't use DESCRIPTION
branch: externals/webfeeder commit 0377ecf493f0c1db0a5b8f0d5d2eb6dd96b9221e Author: Pierre Neidhardt Commit: Pierre Neidhardt -make-atom: Don't use DESCRIPTION --- webfeeder.el | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/webfeeder.el b/webfeeder.el index cf9bd51..bbefe16 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -472,7 +472,7 @@ FEED-ITEMS can be generated with `webfeeder-html-files-to-items'." ;;;###autoload (cl-defun webfeeder-make-atom (webfeed url feed-items - &key title subtitle ;; description + &key title subtitle ;; description ; Unused? See below. author generator build-date predicate max-entries &allow-other-keys) @@ -481,8 +481,7 @@ FEED-ITEMS can be generated with `webfeeder-html-files-to-items'." WEBFEED is the path where the feed is intended to be stored, relative to URL. -A feed can have a TITLE and DESCRIPTION: if not, the URL will be -used. +A feed can have a TITLE: if not, the URL will be used. When BUILD-DATE is nil, use `current-time'. Otherwise it can be a time expression as in `current-time'. 0 means EPOCH.
[elpa] externals/webfeeder updated (e364ffa -> 0377ecf)
ambrevar pushed a change to branch externals/webfeeder. from e364ffa * webfeeder-test.el, webfeeder-test-gen.el: Add licence blurb new 72f93c4 Don't modify load-path in tests new c70ff93 Send email to Emacs debbugs regarding the string= ERT explainer new 0377ecf -make-atom: Don't use DESCRIPTION Summary of changes: Makefile | 2 +- webfeeder-test.el | 3 +-- webfeeder.el | 5 ++--- 3 files changed, 4 insertions(+), 6 deletions(-)
[elpa] externals/webfeeder c70ff93 2/3: Send email to Emacs debbugs regarding the string= ERT explainer
branch: externals/webfeeder commit c70ff93195341e2ee89f05287a53f65e77e7de84 Author: Pierre Neidhardt Commit: Pierre Neidhardt Send email to Emacs debbugs regarding the string= ERT explainer --- webfeeder-test.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webfeeder-test.el b/webfeeder-test.el index 16b2272..3a8b9f8 100644 --- a/webfeeder-test.el +++ b/webfeeder-test.el @@ -54,7 +54,7 @@ (delete-file file-a) (delete-file file-b) -;; FIXME: Add this to ERT! +;; FIXME: Add this to ERT! (Mail sent to Emacs debbug.) (put 'string= 'ert-explainer #'webfeeder--string=-explainer) (defun webfeeder--test-pages (feed html-files
[elpa] externals/webfeeder 72f93c4 1/3: Don't modify load-path in tests
branch: externals/webfeeder commit 72f93c425104ce929398198a2dd6828de95cd84e Author: Pierre Neidhardt Commit: Pierre Neidhardt Don't modify load-path in tests --- Makefile | 2 +- webfeeder-test.el | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c1d9f47..22705ed 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ EMACS = emacs EMACS_FLAGS = -q check: - $(EMACS) $(EMACS_FLAGS) -batch -l ert -l webfeeder-test.el -f ert-run-tests-batch-and-exit + $(EMACS) $(EMACS_FLAGS) -batch -l webfeeder.el -l ert -l webfeeder-test.el -f ert-run-tests-batch-and-exit html: $(EMACS) $(EMACS_FLAGS) -batch -l webfeeder.el -l webfeeder-test.el -l webfeeder-test-gen.el -f webfeeder-test-gen diff --git a/webfeeder-test.el b/webfeeder-test.el index a5c3ff3..16b2272 100644 --- a/webfeeder-test.el +++ b/webfeeder-test.el @@ -19,7 +19,6 @@ (require 'ert) -(add-to-list 'load-path ".");FIXME: Really? (require 'webfeeder) (require 'diff) (require 'cl-lib)
[elpa] externals/webfeeder 2a46428: Rename spurious "feed-builder-" to "webfeeder-"
branch: externals/webfeeder commit 2a4642814ac1d5ae2a0a8a8314ae67825146b69b Author: Pierre Neidhardt Commit: Pierre Neidhardt Rename spurious "feed-builder-" to "webfeeder-" --- webfeeder.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webfeeder.el b/webfeeder.el index bbefe16..6a36fd0 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -45,14 +45,14 @@ ;; it's a bug, please report. ;; ;; The full list of customizable functions is documented in -;; `feed-builder-html-files-to-items'. +;; `webfeeder-html-files-to-items'. ;; ;; The entry point is `webfeeder-build': consult its documentation for more ;; information. ;; ;; Example: ;; -;; (feed-builder-build +;; (webfeeder-build ;; "atom.xml" ;; "./public" ;; "https://example.org/";
[elpa] externals/disk-usage b0fb8af: Version 1.3.3
branch: externals/disk-usage commit b0fb8af34291a49b041eab8b5570e7bc8433a8d8 Author: Pierre Neidhardt Commit: Pierre Neidhardt Version 1.3.3 --- disk-usage.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disk-usage.el b/disk-usage.el index 7e76ed5..5651148 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -5,7 +5,7 @@ ;; Author: Pierre Neidhardt ;; Maintainer: Pierre Neidhardt ;; URL: https://gitlab.com/Ambrevar/emacs-disk-usage -;; Version: 1.3.2 +;; Version: 1.3.3 ;; Package-Requires: ((emacs "26.1")) ;; Keywords: files, convenience, tools
[elpa] externals/disk-usage 2c02d94 1/3: Fix file and directory deletion
branch: externals/disk-usage commit 2c02d9427e01a3d82312d2da7d580ffc85a8fcb6 Author: Pierre Neidhardt Commit: Pierre Neidhardt Fix file and directory deletion --- disk-usage.el | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index 7dbd574..cc47038 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -632,8 +632,13 @@ non-nil or with prefix argument." "Delete" "Trash"))) (cl-loop for entry in tabulated-list-entries if (disk-usage--file-info-marked (car entry)) - do (let ((delete-by-moving-to-trash (not permanently))) - (delete-file (disk-usage--file-info-name (car entry) + do (let ((delete-by-moving-to-trash (not permanently)) + (file (disk-usage--file-info-name (car entry + (if (file-directory-p file) + (delete-directory file +'recursive +delete-by-moving-to-trash) +(delete-file file delete-by-moving-to-trash (tabulated-list-revert))) (defun disk-usage-find-file-at-point ()
[elpa] externals/disk-usage b138397 2/3: Version 1.3.2
branch: externals/disk-usage commit b138397c0f3bacdcf79927fc697c6704dc988948 Author: Pierre Neidhardt Commit: Pierre Neidhardt Version 1.3.2 --- disk-usage.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disk-usage.el b/disk-usage.el index cc47038..994b4da 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -5,7 +5,7 @@ ;; Author: Pierre Neidhardt ;; Maintainer: Pierre Neidhardt ;; URL: https://gitlab.com/Ambrevar/emacs-disk-usage -;; Version: 1.3.1 +;; Version: 1.3.2 ;; Package-Requires: ((emacs "26.1")) ;; Keywords: files, convenience, tools
[elpa] externals/disk-usage updated (f4f6bfa -> 5ebdc00)
ambrevar pushed a change to branch externals/disk-usage. from f4f6bfa * disk-usage.el: Place defvaralias before the variable declaration new 2c02d94 Fix file and directory deletion new b138397 Version 1.3.2 new 5ebdc00 Merge remote-tracking branch 'elpa/externals/disk-usage' Summary of changes: disk-usage.el | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-)
[elpa] externals/disk-usage 5ebdc00 3/3: Merge remote-tracking branch 'elpa/externals/disk-usage'
branch: externals/disk-usage commit 5ebdc00fb69b6f3e807e25cfea667ddcc5377f54 Merge: b138397 f4f6bfa Author: Pierre Neidhardt Commit: Pierre Neidhardt Merge remote-tracking branch 'elpa/externals/disk-usage' --- disk-usage.el | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/disk-usage.el b/disk-usage.el index 994b4da..7e76ed5 100644 --- a/disk-usage.el +++ b/disk-usage.el @@ -78,23 +78,24 @@ "Whether to kill the current `disk-usage' buffer before moving directory." :type 'boolean) +(defvaralias 'disk-usage--du-command 'disk-usage-du-command) (defcustom disk-usage-du-command (if (member system-type '(gnu gnu/linux gnu/kfreebsd)) "du" "gdu") "Non-GNU users need GNU's `du' for the `-b' flag. See `disk-usage-du-args'." :type 'string) -(defvaralias 'disk-usage--du-command 'disk-usage-du-command) +(defvaralias 'disk-usage--du-args 'disk-usage-du-args) (defcustom disk-usage-du-args "-sb" "Non-GNU users need GNU's `du' for the `-b' flag. See `disk-usage-du-command'." :type 'string) -(defvaralias 'disk-usage--du-args 'disk-usage-du-args) +(defvaralias 'disk-usage--find-command 'disk-usage-find-command) (defcustom disk-usage-find-command "find" "The `find' executable. This is required for recursive listings." :type 'string) -(defvaralias 'disk-usage--find-command 'disk-usage-find-command) +(defvaralias 'disk-usage--directory-size-function 'disk-usage-directory-size-function) (defcustom disk-usage-directory-size-function (if (executable-find disk-usage-du-command) #'disk-usage-directory-size-with-du @@ -102,7 +103,6 @@ "Function that returns the total disk usage of the directory passed as argument." :type '(choice (function :tag "Native (slow)" disk-usage-directory-size-with-emacs) (function :tag "System \"du\"" disk-usage-directory-size-with-du))) -(defvaralias 'disk-usage--directory-size-function 'disk-usage-directory-size-function) (defface disk-usage-inaccessible '((t :inherit error
[elpa] externals/webfeeder 1ce3e02 5/5: Version 1.1.0.
branch: externals/webfeeder commit 1ce3e02ab77f50f8cefa9dd6820f0094ce717b42 Author: Pierre Neidhardt Commit: Pierre Neidhardt Version 1.1.0. --- webfeeder.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webfeeder.el b/webfeeder.el index 39d3146..cfc2192 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -5,7 +5,7 @@ ;; Author: Pierre Neidhardt ;; Maintainer: Pierre Neidhardt ;; URL: https://gitlab.com/Ambrevar/emacs-webfeeder -;; Version: 1.0.0 +;; Version: 1.1.0 ;; Package-Requires: ((emacs "25.1")) ;; Keywords: news, hypermedia, blog, feed, rss, atom
[elpa] externals/webfeeder db24521 3/5: Fix xml-escape-string error on nil.
branch: externals/webfeeder commit db24521e863c2ad45bf167786a2412bf1c8374fb Author: Pierre Neidhardt Commit: Pierre Neidhardt Fix xml-escape-string error on nil. --- webfeeder.el | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/webfeeder.el b/webfeeder.el index 1832455..31e788a 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -389,6 +389,12 @@ The date is set to epoch if the item date is nil." categories generator) +(defun webfeeder---xml-escape-string (string) + "Like `xml-escape-string' but return nil on nil." + (if string + (xml-escape-string string) +nil)) + ;;;###autoload (defun webfeeder-html-files-to-items (project-dir url html-files) "Parse the source HTML-FILES and return a list of webfeeder-items. @@ -406,12 +412,12 @@ variables: (cl-loop for html-file in html-files for dest = (expand-file-name html-file project-dir) for feed-url = (concat (replace-regexp-in-string "/*$" "" url) "/" html-file) - for feed-author = (xml-escape-string (funcall webfeeder-author-function dest)) + for feed-author = (web-feeder--xml-escape-string (funcall webfeeder-author-function dest)) for feed-date = (or (funcall webfeeder-date-function (expand-file-name html-file project-dir)) 0) - for feed-title = (or (xml-escape-string (funcall webfeeder-title-function dest)) feed-url) - for feed-subtitle = (xml-escape-string (funcall webfeeder-subtitle-function dest)) + for feed-title = (or (webfeeder--xml-escape-string (funcall webfeeder-title-function dest)) feed-url) + for feed-subtitle = (webfeeder--xml-escape-string (funcall webfeeder-subtitle-function dest)) for feed-body = (funcall webfeeder-body-function dest feed-url 'exclude-toc) for feed-categories = (funcall webfeeder-categories-function dest) for feed-generator = (funcall webfeeder-generator-function dest)
[elpa] externals/webfeeder d6d33a7 4/5: Fix typos in webfeeder--xml-escape-string.
branch: externals/webfeeder commit d6d33a74ef5e54c0a88e65b9bc69537ce626b61f Author: Pierre Neidhardt Commit: Pierre Neidhardt Fix typos in webfeeder--xml-escape-string. --- webfeeder.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webfeeder.el b/webfeeder.el index 31e788a..39d3146 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -389,7 +389,7 @@ The date is set to epoch if the item date is nil." categories generator) -(defun webfeeder---xml-escape-string (string) +(defun webfeeder--xml-escape-string (string) "Like `xml-escape-string' but return nil on nil." (if string (xml-escape-string string) @@ -412,7 +412,7 @@ variables: (cl-loop for html-file in html-files for dest = (expand-file-name html-file project-dir) for feed-url = (concat (replace-regexp-in-string "/*$" "" url) "/" html-file) - for feed-author = (web-feeder--xml-escape-string (funcall webfeeder-author-function dest)) + for feed-author = (webfeeder--xml-escape-string (funcall webfeeder-author-function dest)) for feed-date = (or (funcall webfeeder-date-function (expand-file-name html-file project-dir)) 0)
[elpa] externals/webfeeder 5784dd1 1/5: Fix atom generation when "author" field has no email.
branch: externals/webfeeder commit 5784dd1d5ffe01d633c6c567aa2bef02d70948b7 Author: Pierre Neidhardt Commit: Pierre Neidhardt Fix atom generation when "author" field has no email. --- webfeeder.el | 20 ++-- 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/webfeeder.el b/webfeeder.el index 6a36fd0..07f0ed0 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -325,8 +325,12 @@ The date is set to epoch if the item date is nil." (defun webfeeder--extract-name+email (address) "Like `mail-extract-address-components' but does not set the address part if email is missing. -For instance, calling this function on \"foo\" returns (\"foo\" nil)." +For instance, calling this function on \"foo\" returns (\"foo\" nil). +Calling it on f...@bar.abc returns (nil \"f...@bar.abc\")." (let ((name+addr (mail-extract-address-components address))) +(unless (string-match "@" (cadr name+addr)) + (setcar name+addr (cadr name+addr)) + (setcdr name+addr nil)) (when (string= (car name+addr) (cadr name+addr)) (setcdr name+addr nil)) @@ -335,11 +339,15 @@ For instance, calling this function on \"foo\" returns (\"foo\" nil)." (defun webfeeder--format-atom-author (author) (concat "" (let ((name+addr (webfeeder--extract-name+email author))) -(if (cadr name+addr) -(format "%s%s" -(xml-escape-string (car name+addr)) -(cadr name+addr)) - (format "%s" (xml-escape-string author +(cond + ((and (car name+addr) (cadr name+addr)) + (format "%s%s" + (xml-escape-string (car name+addr)) + (cadr name+addr))) + ((car name+addr) + (format "%s" (xml-escape-string author))) + (t + (format "%s" (xml-escape-string author) "\n")) (defun webfeeder-item-to-atom (item)
[elpa] externals/webfeeder 3a30b31 2/5: Escape author, title and subtitle for XML special characters.
branch: externals/webfeeder commit 3a30b31e2268341d885d02ea007d8ef7f86d61cb Author: Pierre Neidhardt Commit: Pierre Neidhardt Escape author, title and subtitle for XML special characters. --- webfeeder.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webfeeder.el b/webfeeder.el index 07f0ed0..1832455 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -406,12 +406,12 @@ variables: (cl-loop for html-file in html-files for dest = (expand-file-name html-file project-dir) for feed-url = (concat (replace-regexp-in-string "/*$" "" url) "/" html-file) - for feed-author = (funcall webfeeder-author-function dest) + for feed-author = (xml-escape-string (funcall webfeeder-author-function dest)) for feed-date = (or (funcall webfeeder-date-function (expand-file-name html-file project-dir)) 0) - for feed-title = (or (funcall webfeeder-title-function dest) feed-url) - for feed-subtitle = (funcall webfeeder-subtitle-function dest) + for feed-title = (or (xml-escape-string (funcall webfeeder-title-function dest)) feed-url) + for feed-subtitle = (xml-escape-string (funcall webfeeder-subtitle-function dest)) for feed-body = (funcall webfeeder-body-function dest feed-url 'exclude-toc) for feed-categories = (funcall webfeeder-categories-function dest) for feed-generator = (funcall webfeeder-generator-function dest)
[elpa] externals/webfeeder updated (2a46428 -> 1ce3e02)
ambrevar pushed a change to branch externals/webfeeder. from 2a46428 Rename spurious "feed-builder-" to "webfeeder-" new 5784dd1 Fix atom generation when "author" field has no email. new 3a30b31 Escape author, title and subtitle for XML special characters. new db24521 Fix xml-escape-string error on nil. new d6d33a7 Fix typos in webfeeder--xml-escape-string. new 1ce3e02 Version 1.1.0. Summary of changes: webfeeder.el | 34 -- 1 file changed, 24 insertions(+), 10 deletions(-)
[elpa] externals/webfeeder d12b352 1/2: Revert "Escape author, title and subtitle for XML special characters.".
branch: externals/webfeeder commit d12b35221349c08190de87bdd0617f2dcfc0a235 Author: Pierre Neidhardt Commit: Pierre Neidhardt Revert "Escape author, title and subtitle for XML special characters.". It should not be needed and indeed breaks emails in the form "" or special characters in titles or subtitles. --- webfeeder.el | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/webfeeder.el b/webfeeder.el index cfc2192..c23cac6 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -412,12 +412,14 @@ variables: (cl-loop for html-file in html-files for dest = (expand-file-name html-file project-dir) for feed-url = (concat (replace-regexp-in-string "/*$" "" url) "/" html-file) - for feed-author = (webfeeder--xml-escape-string (funcall webfeeder-author-function dest)) + ;; TODO: Shall we escape author, title and subtitle? HTML files + ;; should already be escaped, so there should be no need. + for feed-author = (funcall webfeeder-author-function dest) for feed-date = (or (funcall webfeeder-date-function (expand-file-name html-file project-dir)) 0) - for feed-title = (or (webfeeder--xml-escape-string (funcall webfeeder-title-function dest)) feed-url) - for feed-subtitle = (webfeeder--xml-escape-string (funcall webfeeder-subtitle-function dest)) + for feed-title = (or (funcall webfeeder-title-function dest) feed-url) + for feed-subtitle = (funcall webfeeder-subtitle-function dest) for feed-body = (funcall webfeeder-body-function dest feed-url 'exclude-toc) for feed-categories = (funcall webfeeder-categories-function dest) for feed-generator = (funcall webfeeder-generator-function dest)
[elpa] externals/webfeeder 914a1d0 2/2: Version 1.1.1.
branch: externals/webfeeder commit 914a1d092055f244e027d8857d3c81ff91cff300 Author: Pierre Neidhardt Commit: Pierre Neidhardt Version 1.1.1. --- webfeeder.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webfeeder.el b/webfeeder.el index c23cac6..3ab651c 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -5,7 +5,7 @@ ;; Author: Pierre Neidhardt ;; Maintainer: Pierre Neidhardt ;; URL: https://gitlab.com/Ambrevar/emacs-webfeeder -;; Version: 1.1.0 +;; Version: 1.1.1 ;; Package-Requires: ((emacs "25.1")) ;; Keywords: news, hypermedia, blog, feed, rss, atom
[elpa] externals/webfeeder updated (1ce3e02 -> 914a1d0)
ambrevar pushed a change to branch externals/webfeeder. from 1ce3e02 Version 1.1.0. new d12b352 Revert "Escape author, title and subtitle for XML special characters.". new 914a1d0 Version 1.1.1. Summary of changes: webfeeder.el | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-)
[elpa] externals/webfeeder 6037848: Version 1.1.2.
branch: externals/webfeeder commit 6037848ee495a67510d8b43f1fbe319b76dbd859 Author: Pierre Neidhardt Commit: Pierre Neidhardt Version 1.1.2. --- webfeeder.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webfeeder.el b/webfeeder.el index 3ff4f8c..7a4d5b6 100644 --- a/webfeeder.el +++ b/webfeeder.el @@ -5,7 +5,7 @@ ;; Author: Pierre Neidhardt ;; Maintainer: Pierre Neidhardt ;; URL: https://gitlab.com/Ambrevar/emacs-webfeeder -;; Version: 1.1.1 +;; Version: 1.1.2 ;; Package-Requires: ((emacs "25.1")) ;; Keywords: news, hypermedia, blog, feed, rss, atom