all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: emacs-devel@gnu.org
Subject: Re: dired-jump keybinding and autoload
Date: Wed, 19 May 2010 01:59:54 +0300	[thread overview]
Message-ID: <87iq6kzuhh.fsf@mail.jurta.org> (raw)
In-Reply-To: <87lk2j83m1.fsf@jurta.org> (Juri Linkov's message of "Sat, 10 May 2008 02:52:30 +0300")

[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))
 \f
 ;;; OMITTING.

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



  reply	other threads:[~2010-05-18 22:59 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-08 12:59 dired-jump keybinding and autoload Stephen Berman
2008-05-08 14:12 ` Stefan Monnier
2008-05-08 14:36   ` David Kastrup
2008-05-08 16:08     ` Stephen Berman
2008-05-09 23:52       ` Juri Linkov
2010-05-18 22:59         ` Juri Linkov [this message]
2010-05-23 15:48           ` Wojciech Meyer
2010-05-23 16:04             ` Juri Linkov
2010-05-23 16:45               ` Drew Adams
2010-05-23 16:50                 ` Lennart Borgman
2010-05-23 17:11                   ` Drew Adams
2010-05-23 17:24                     ` Lennart Borgman
2010-05-23 18:14                       ` Drew Adams
2010-05-23 18:47                         ` Lennart Borgman
2010-05-23 20:56                           ` Drew Adams
2010-05-23 21:08                             ` Lennart Borgman
2010-05-24  1:01                   ` Stephen J. Turnbull
2010-05-24  1:30                     ` Lennart Borgman
2010-05-24  5:03                       ` Stephen J. Turnbull
2010-05-23 16:59               ` Leo
2010-05-24 16:00                 ` Juri Linkov
2010-05-24 16:17                   ` Lennart Borgman
2010-05-24 16:46                     ` Drew Adams
2010-05-24 16:53                       ` Lennart Borgman
2010-05-24 16:35                   ` Drew Adams
2010-05-24  5:05             ` Miles Bader
2010-05-24  7:19               ` Wojciech Meyer
2010-05-24 17:39                 ` Lennart Borgman
2010-05-25  6:35                 ` Miles Bader

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87iq6kzuhh.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.