From 400d4ec56f3bcbcf2a184061d5ece214fe54126b Mon Sep 17 00:00:00 2001 From: JSDurand Date: Fri, 26 Feb 2021 20:36:42 +0800 Subject: Eshell and elfeed improvements * elfeed-conf.el (elfeed-feeds): Add some more feeds. * eshell-conf.el (eshell-j): (eshell-mark-directory): Use a dedicated variable for better maintainability. (eshell/mark): Conveniently add marks. (eshell/marks): List the marks. --- eshell-conf.el | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'eshell-conf.el') diff --git a/eshell-conf.el b/eshell-conf.el index 9ca592a..a1bdf68 100644 --- a/eshell-conf.el +++ b/eshell-conf.el @@ -59,6 +59,40 @@ See `eshell-j' for the actual functionality." :usage "[-hra] [short-cut]") (eshell-j args use-recent-p))) +;;;###autoload +(defun eshell/mark (&rest args) + "Add symbolic links to `eshell-mark-directory'. +The argument ARGS should be list of one string which names the +link name. If no argument is given, the base name of the current +directory is used." + ;; (setq args (cons default-directory args)) + ;; (setq args (durand-eshell-delete-dups args :test #'string=)) + (setq args (cond + ((consp args) (car (flatten-tree args))) + ((file-name-nondirectory + (directory-file-name + (file-name-directory default-directory)))))) + (eshell-command-result + (format "ln -sf %s %s" + default-directory (expand-file-name args eshell-mark-directory)))) + +;;;###autoload +(defun eshell/marks () + "List all symbolic links. +Just for the completeness." + (let* ((dirs (directory-files eshell-mark-directory nil + (rx-to-string '(seq bos (or (not ".") + (seq "." (not "."))))))) + (max-length (apply #'max (mapcar #'length dirs)))) + (mapconcat + (function + (lambda (mark) + (concat mark + (make-string (- max-length (length mark)) #x20) + " -> " + (file-truename (expand-file-name mark eshell-mark-directory))))) + dirs "\n"))) + ;;;###autoload (defun durand-eshell-delete-dups (sequence &rest args) "Delete duplicate elements in SEQUENCE. @@ -104,6 +138,10 @@ supposed to leave the global state alone as well. sequence) (nreverse result))) +;;;###autoload +(defvar eshell-mark-directory (expand-file-name "~/.marks") + "The directory that stores links to other directories.") + ;;;###autoload (defun eshell-j (&optional short-cut use-recent-p) "Jump to SHORT-CUT. @@ -114,7 +152,7 @@ if USE-RECENT-P is 'exclusive, then only list the recent directories as candidates, unless there are no recent directories, in which case it falls back to use the marks as the candidates." - (let* ((mark-directory (expand-file-name "~/.marks")) + (let* ((mark-directory eshell-mark-directory) (short-cut (eshell-flatten-and-stringify short-cut)) (links (delq nil (mapcar -- cgit v1.2.3-18-g5258