diff options
Diffstat (limited to 'eshell-conf.el')
-rw-r--r-- | eshell-conf.el | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/eshell-conf.el b/eshell-conf.el index 9ca592a..a1bdf68 100644 --- a/eshell-conf.el +++ b/eshell-conf.el @@ -60,6 +60,40 @@ See `eshell-j' for the actual functionality." (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. If the keyword argument TEST is non-nil, it should be a function @@ -105,6 +139,10 @@ supposed to leave the global state alone as well. (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. Where this jumps to is determined by the symbolic links in the @@ -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 |