emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dired-jump keybinding and autoload


From: Juri Linkov
Subject: Re: dired-jump keybinding and autoload
Date: Wed, 19 May 2010 01:59:54 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu)

[On 2008-05-10 I wrote:]
> `C-x C-j' is a global key binding, unlike other dired keys.  But I agree
> that dired-jump is useful enough to deserve its global key binding,
> and I know no other package that would conflict with it.
>
> The only drawback of this command is that it doesn't allow reading
> an arbitrary file name.  I propose to change its argument so that
> `C-u C-x C-j' will read the file name from the minibuffer (with the
> default to the current file name), and keep the existing key binding
> `C-x 4 C-j' to use the other window.

This is implemented by the following patch:

=== modified file 'lisp/dired-x.el'
--- lisp/dired-x.el     2010-03-30 16:10:14 +0000
+++ lisp/dired-x.el     2010-05-18 22:50:16 +0000
@@ -506,16 +506,21 @@ (defun dired-very-clean-tex ()
 ;;; JUMP.
 
 ;;;###autoload
-(defun dired-jump (&optional other-window)
+(defun dired-jump (&optional other-window file-name)
   "Jump to dired buffer corresponding to current buffer.
 If in a file, dired the current directory and move to file's line.
 If in Dired already, pop up a level and goto old directory's line.
 In case the proper dired file line cannot be found, refresh the dired
-buffer and try again."
-  (interactive "P")
-  (let* ((file buffer-file-name)
+buffer and try again.
+When OTHER-WINDOW is non-nil, jump to dired buffer in other window.
+Interactively with prefix argument, read FILE-NAME and
+move to its line in dired."
+  (interactive
+   (list nil (and current-prefix-arg
+                 (read-file-name "Jump to dired file: "))))
+  (let* ((file (or file-name buffer-file-name))
          (dir (if file (file-name-directory file) default-directory)))
-    (if (eq major-mode 'dired-mode)
+    (if (and (eq major-mode 'dired-mode) (null file-name))
         (progn
           (setq dir (dired-current-directory))
           (dired-up-directory other-window)
@@ -539,10 +544,12 @@ (defun dired-jump (&optional other-windo
                    (dired-omit-mode)
                    (dired-goto-file file))))))))
 
-(defun dired-jump-other-window ()
+(defun dired-jump-other-window (&optional file-name)
   "Like \\[dired-jump] (`dired-jump') but in other window."
-  (interactive)
-  (dired-jump t))
+  (interactive
+   (list (and current-prefix-arg
+             (read-file-name "Jump to dired file: "))))
+  (dired-jump t file-name))
 
 ;;; OMITTING.

-- 
Juri Linkov
http://www.jurta.org/emacs/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]