diff options
Diffstat (limited to '.emacs.d/init.el')
-rw-r--r-- | .emacs.d/init.el | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 89c982ca..fb31801b 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -1690,7 +1690,8 @@ The ideas behind these behaviours are as follows. C-x p e." (interactive "P") (require 'eshell) - (let* ((default-directory (or (and (eq major-mode 'dired-mode) + (let* ((default-directory (or (and (not (eq chdir 'strict)) + (eq major-mode 'dired-mode) (dired-current-directory)) default-directory)) (current-project (and (not (file-remote-p default-directory)) @@ -2734,6 +2735,36 @@ mutt's review view, after exiting EDITOR." ;; go ahead and advise `read-only-mode' (require 'git-annex)) +(defun spw/dired-copy-filename-as-kill (&optional arg) + (interactive "P") + ;; Invoking with '!', and no prefix argument, is a shortcut for copying + ;; absolute paths, and behaving like 'M-!' rather than like 'M-&'. + ;; + ;; As we pass the prefix argument on to `dired-copy-filename-as-kill', there + ;; isn't a way to pass a prefix argument to 'M-&' (it wouldn't make sense to + ;; pass a prefix argument to 'M-!'). One can use, e.g., C-u M-& C-x o &. + (if (and (not arg) (char-equal last-command-event ?!)) + (dired-copy-filename-as-kill 0) + (call-interactively #'dired-copy-filename-as-kill)) + ;; Here we try to do something sensible based on what the prefix argument + ;; means to `dired-copy-filename-as-kill'. + (cond ((if arg + (zerop (prefix-numeric-value arg)) + (char-equal last-command-event ?!)) + (spw/eshell-jump)) + ((consp arg) + (spw/eshell-jump nil 'strict)) + (t + (spw/eshell-jump nil t))) + (if (= (point) eshell-last-output-end) + (save-excursion (insert ?\s) (yank) (insert ?\s)) + (just-one-space) + (yank) + (just-one-space))) +(spw/feature-define-keys dired + "!" #'spw/dired-copy-filename-as-kill + "&" #'spw/dired-copy-filename-as-kill) + ;;;; EWW |