From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sean Whitton Newsgroups: gmane.emacs.devel Subject: Adding missing C-x 5 C-j and C-x t C-j commands Date: Sun, 22 May 2022 12:53:25 -0700 Message-ID: <87a6b9xs22.fsf@athena.silentflame.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23298"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Notmuch/0.36 Emacs/29.0.50 (x86_64-pc-linux-gnu) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun May 22 21:54:43 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nsrez-0005px-03 for ged-emacs-devel@m.gmane-mx.org; Sun, 22 May 2022 21:54:43 +0200 Original-Received: from localhost ([::1]:33272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nsrex-00016d-JF for ged-emacs-devel@m.gmane-mx.org; Sun, 22 May 2022 15:54:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nsrdq-0000Pb-HB for emacs-devel@gnu.org; Sun, 22 May 2022 15:53:30 -0400 Original-Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:60005) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nsrdo-0001L6-Cp for emacs-devel@gnu.org; Sun, 22 May 2022 15:53:30 -0400 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 0593032004E7 for ; Sun, 22 May 2022 15:53:26 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 22 May 2022 15:53:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=cc:content-type:date:date:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to; s=fm3; t= 1653249206; x=1653335606; bh=cfF2/H08EyAFgOj6GlCU9o3IDo8sSLn0Zy8 GfCMEqoU=; b=c0WksOS3jcij38yhaug1apMgMHtVadT2ogCn9XAwPrDAbiEPRCk 5dnuLAxMJy65X6PQQh1TOhUV9Y3Hf9nzZyvvbd1qPYH1tb1kAJ9BiU1+GGjZZFSE q+z/wl/j1QXrr8lJ8YNb4NhBIyJQIFojcuTa5Sa+ulBirjAM4g5n/kOVJWlmoQEZ P2x6LsSoHo2bYV/1jFhah+XcKDfFweZTsdmLVIxv7HJYmUGqQAuJVFIoOiD8uN09 TNtqagYjdNYwOZWgWXMRmTCFdT+rca5V2GudyxkO5mxvhWqZCXVSnCteRqAV2eBB UAVqFjfhQV7R6N9c5wGp2TnXXUc+t/zfehw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:message-id:mime-version :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1653249206; x= 1653335606; bh=cfF2/H08EyAFgOj6GlCU9o3IDo8sSLn0Zy8GfCMEqoU=; b=Y dZ7w0uxLkpjOo89F/symjTMWpDtsuDyz50a/eBf9lnJcNm3GNvxGpQGftJENTFkN wMrt5P9e2rWpbFt35l5vEJVIL4tqtrEwtWGmjJIjiv9tbfoLo4FdyZRKD0FL8aL1 Rq/CosEj1bplyC6JRm8ncH+p+RClv18DdmMf9N6WYaQ7ORrRBi63Dt6rA34lHIht hJ472XVJnO0A5imJe13zBDn1e4iGMQ9lMfVtKHEdJuLVs748roqqSquP6hW7cDLA ngvSICVmi3H5jxhjGboX/Lz41lAAaLZlqapVK+anLSgPGqoumh1FtRAeGVvauJOR vlZ+plm7QH2dsm8guhqpw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrieekgddugeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufgffkfggtgesmhdttdertd ertdenucfhrhhomhepufgvrghnucghhhhithhtohhnuceoshhpfihhihhtthhonhesshhp fihhihhtthhonhdrnhgrmhgvqeenucggtffrrghtthgvrhhnpeekgeegueejledugeevve evleejfffhlefhgeffhfduhefhhfekvdehfeetvdeuleenucevlhhushhtvghrufhiiigv pedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehsphifhhhithhtohhnsehsphifhhhith htohhnrdhnrghmvg X-ME-Proxy: Feedback-ID: i23c04076:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sun, 22 May 2022 15:53:26 -0400 (EDT) Original-Received: by athena.silentflame.com (Postfix, from userid 1000) id 495451B5974; Sun, 22 May 2022 19:53:25 +0000 (UTC) Received-SPF: pass client-ip=64.147.123.19; envelope-from=spwhitton@spwhitton.name; helo=wout3-smtp.messagingengine.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, GAPPY_SUBJECT=0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:290106 Archived-At: --=-=-= Content-Type: text/plain We have C-x d, C-x 4 d, C-x 5 d and C-x t d, but only C-x C-j and C-x 4 C-j. My fingers try to use C-x 5 C-j, and find it isn't there, at least biweekly. Here is a draft patch to fill the gap. C-x t C-j temporarily doesn't work due to #55582. -- Sean Whitton --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-dired-jump-other-frame-and-dired-jump-other-tab.patch >From 2b5ced057a959ab51387ac5d45d2a7b10a414591 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 22 May 2022 12:08:54 -0700 Subject: [PATCH] Add dired-jump-other-frame and dired-jump-other-tab * lisp/bindings.el: Drop binding C-x C-j and C-x 4 C-j. * lisp/dired.el: Bind C-x C-j, C-x 4 C-j, C-x 5 C-j and C-x t C-j using autoload cookies. (This parallels the way in which C-x d, C-x 4 d, C-x 5 d and C-x t d are bound.) (dired-up-directory): When optional argument is a function, switch to the buffer using that function. (dired-jump): Refactor to call dired-jump--internal. (dired-jump-other-window): Refactor to call dired-jump--internal and add "... in other window" to read-file-name prompt. (dired-jump-other-frame, dired-jump-other-tab): New commands. (dired-jump--internal): New function factored out of dired-jump. * etc/NEWS: * doc/emacs/dired.texi (Entering Dired): Document the change. --- doc/emacs/dired.texi | 9 +++++- etc/NEWS | 4 +++ lisp/bindings.el | 3 -- lisp/dired.el | 66 ++++++++++++++++++++++++++++++++------------ 4 files changed, 60 insertions(+), 22 deletions(-) diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi index ed4ff5213f..5a95d6e8e1 100644 --- a/doc/emacs/dired.texi +++ b/doc/emacs/dired.texi @@ -111,8 +111,12 @@ Dired Enter @findex dired-jump @findex dired-jump-other-window +@findex dired-jump-other-frame +@findex dired-jump-other-tab @kindex C-x C-j @kindex C-x 4 C-j +@kindex C-x 5 C-j +@kindex C-x t C-j You can ask Emacs to invoke Dired on the default-directory (@pxref{File Names, default-directory}) of any buffer, by typing @kbd{C-x C-j} (@code{dired-jump}). If the buffer visits a file, this @@ -123,7 +127,10 @@ Dired Enter and places point on the line that corresponds to the directory where you invoked @code{dired-jump}. Typing @kbd{C-x 4 C-j} (@code{dired-jump-other-window}) has the same effect, but displays the -Dired buffer in a new window. +Dired buffer in a new window; similarly @kbd{C-x 5 C-j} +(@code{dired-jump-other-frame}) to display the Dired buffer in a new +frame and @kbd{C-x t C-j} (@code{dired-jump-other-tab}) to display the +Dired buffer in a new tab. The variable @code{dired-listing-switches} specifies the options to give to @command{ls} for listing the directory; this string diff --git a/etc/NEWS b/etc/NEWS index 190620619f..31105bfbec 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1493,6 +1493,10 @@ If non-nil (which is the default), hitting 'RET' or 'mouse-1' on the directory components at the directory displayed at the start of the buffer will take you to that directory. ++++ +*** New commands 'dired-jump-other-frame' and 'dired-jump-other-tab'. +These are bound to 'C-x 5 C-j' and 'C-x t C-j' respectively. + ** Exif --- diff --git a/lisp/bindings.el b/lisp/bindings.el index ed1325e326..4ed197f1d4 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el @@ -1501,9 +1501,6 @@ esc-map (define-key ctl-x-map "'" 'expand-abbrev) (define-key ctl-x-map "\C-b" 'list-buffers) -(define-key ctl-x-map "\C-j" 'dired-jump) -(define-key ctl-x-4-map "\C-j" 'dired-jump-other-window) - (define-key ctl-x-map "z" 'repeat) (defvar ctl-x-x-map diff --git a/lisp/dired.el b/lisp/dired.el index 89fbd52aa6..d8fa726c6f 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -2583,8 +2583,13 @@ dired-up-directory "Run Dired on parent directory of current directory. Find the parent directory either in this buffer or another buffer. Creates a buffer if necessary. -If OTHER-WINDOW (the optional prefix arg), display the parent -directory in another window." + +When called interactively with a prefix argument, display the +parent directory in another window. + +When called from Lisp, if OTHER-WINDOW is a function, switch to +the buffer by calling that function. When OTHER-WINDOW is +otherwise non-nil, use `switch-to-buffer-other-window'." (interactive "P") (let* ((dir (dired-current-directory)) (up (file-name-directory (directory-file-name dir)))) @@ -2592,11 +2597,12 @@ dired-up-directory ;; Only try dired-goto-subdir if buffer has more than one dir. (and (cdr dired-subdir-alist) (dired-goto-subdir up)) - (progn - (if other-window - (dired-other-window up) - (dired--find-possibly-alternative-file up)) - (dired-goto-file dir))))) + (progn (pcase other-window + ('nil (dired--find-possibly-alternative-file up)) + ((or (pred functionp) (pred symbolp)) + (funcall other-window (dired-noselect up))) + (_ (dired-other-window up))) + (dired-goto-file dir))))) (defun dired-get-file-for-visit () "Get the current line's file name, with an error if file does not exist." @@ -4704,6 +4710,7 @@ archive-superior-buffer (defvar tar-superior-buffer) (declare-function dired-omit-mode "dired-x" (&optional arg)) +;;;###autoload (define-key ctl-x-map "\C-j" #'dired-jump) ;;;###autoload (defun dired-jump (&optional other-window file-name) "Jump to Dired buffer corresponding to current buffer. @@ -4723,6 +4730,39 @@ dired-jump (interactive (list nil (and current-prefix-arg (read-file-name "Jump to Dired file: ")))) + (dired-jump--internal (if other-window + #'switch-to-buffer-other-window + #'pop-to-buffer-same-window) + file-name)) + +;;;###autoload (define-key ctl-x-4-map "\C-j" #'dired-jump-other-window) +;;;###autoload +(defun dired-jump-other-window (&optional file-name) + "Like \\[dired-jump] (`dired-jump') but in other window." + (interactive + (list (and current-prefix-arg + (read-file-name "Jump to Dired file in other window: ")))) + (dired-jump--internal #'switch-to-buffer-other-window file-name)) + +;;;###autoload (define-key ctl-x-5-map "\C-j" #'dired-jump-other-frame) +;;;###autoload +(defun dired-jump-other-frame (&optional file-name) + "Like \\[dired-jump] (`dired-jump') but in other frame." + (interactive + (list (and current-prefix-arg + (read-file-name "Jump to Dired file in other frame: ")))) + (dired-jump--internal #'switch-to-buffer-other-frame file-name)) + +;;;###autoload (define-key tab-prefix-map "\C-j" #'dired-jump-other-tab) +;;;###autoload +(defun dired-jump-other-tab (&optional file-name) + "Like \\[dired-jump] (`dired-jump') but make new tab." + (interactive + (list (and current-prefix-arg + (read-file-name "Jump to Dired file in other tab: ")))) + (dired-jump--internal #'switch-to-buffer-other-tab file-name)) + +(defun dired-jump--internal (other-window file-name) (cond ((and (bound-and-true-p archive-subfile-mode) (buffer-live-p archive-superior-buffer)) @@ -4746,9 +4786,7 @@ dired-jump ;; refresh and try again (dired-insert-subdir (file-name-directory dir)) (dired-goto-file dir))) - (if other-window - (dired-other-window dir) - (dired dir)) + (funcall other-window (dired-noselect dir)) (if file (or (dired-goto-file file) ;; refresh and try again @@ -4760,14 +4798,6 @@ dired-jump (dired-omit-mode) (dired-goto-file file))))))))) -;;;###autoload -(defun dired-jump-other-window (&optional file-name) - "Like \\[dired-jump] (`dired-jump') but in other window." - (interactive - (list (and current-prefix-arg - (read-file-name "Jump to Dired file: ")))) - (dired-jump t file-name)) - (provide 'dired) (run-hooks 'dired-load-hook) ; for your customizations -- 2.30.2 --=-=-=--