From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: dired-jump keybinding and autoload Date: Wed, 19 May 2010 01:59:54 +0300 Organization: JURTA Message-ID: <87iq6kzuhh.fsf@mail.jurta.org> References: <874p9954u9.fsf@escher.local.home> <86r6ccooam.fsf@lola.quinscape.zz> <87skws4w3l.fsf@escher.local.home> <87lk2j83m1.fsf@jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1274223863 7014 80.91.229.12 (18 May 2010 23:04:23 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 18 May 2010 23:04:23 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 19 01:04:13 2010 connect(): No such file or directory Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OEVpY-0004qt-7P for ged-emacs-devel@m.gmane.org; Wed, 19 May 2010 01:04:11 +0200 Original-Received: from localhost ([127.0.0.1]:38820 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OEVpK-0002RC-M7 for ged-emacs-devel@m.gmane.org; Tue, 18 May 2010 19:03:54 -0400 Original-Received: from [140.186.70.92] (port=47621 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OEVpE-0002R6-Gw for emacs-devel@gnu.org; Tue, 18 May 2010 19:03:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OEVp5-0006z9-HO for emacs-devel@gnu.org; Tue, 18 May 2010 19:03:41 -0400 Original-Received: from smtp-out2.starman.ee ([85.253.0.4]:37024 helo=mx2.starman.ee) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OEVp5-0006z1-69 for emacs-devel@gnu.org; Tue, 18 May 2010 19:03:39 -0400 X-Virus-Scanned: by Amavisd-New at mx2.starman.ee Original-Received: from mail.starman.ee (82.131.33.174.cable.starman.ee [82.131.33.174]) by mx2.starman.ee (Postfix) with ESMTP id 343573F40FF for ; Wed, 19 May 2010 02:03:35 +0300 (EEST) In-Reply-To: <87lk2j83m1.fsf@jurta.org> (Juri Linkov's message of "Sat, 10 May 2008 02:52:30 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:124917 Archived-At: [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/