From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Protesilaos Stavrou Newsgroups: gmane.emacs.bugs Subject: bug#65039: 30.0.50; [PATCH] Add bookmark handler for M-x shell Date: Fri, 04 Aug 2023 17:06:59 +0300 Message-ID: <871qgisxz0.fsf@protesilaos.com> References: <877cqcw5m0.fsf@protesilaos.com> <83zg38w25c.fsf@gnu.org> <87y1ir2mko.fsf@protesilaos.com> <834jlfw116.fsf@gnu.org> 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="8280"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 65039@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Aug 04 16:08:27 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1qRvTe-0001ti-TG for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 04 Aug 2023 16:08:27 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qRvTI-0004x7-Ho; Fri, 04 Aug 2023 10:08:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qRvTG-0004wl-W2 for bug-gnu-emacs@gnu.org; Fri, 04 Aug 2023 10:08:03 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qRvTG-0003dW-Nr for bug-gnu-emacs@gnu.org; Fri, 04 Aug 2023 10:08:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qRvTG-0000EG-JT for bug-gnu-emacs@gnu.org; Fri, 04 Aug 2023 10:08:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Protesilaos Stavrou Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 04 Aug 2023 14:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65039 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 65039-submit@debbugs.gnu.org id=B65039.1691158028794 (code B ref 65039); Fri, 04 Aug 2023 14:08:02 +0000 Original-Received: (at 65039) by debbugs.gnu.org; 4 Aug 2023 14:07:08 +0000 Original-Received: from localhost ([127.0.0.1]:54475 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qRvSN-0000Cj-Q8 for submit@debbugs.gnu.org; Fri, 04 Aug 2023 10:07:08 -0400 Original-Received: from relay3-d.mail.gandi.net ([217.70.183.195]:33329) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qRvSM-0000C5-EW for 65039@debbugs.gnu.org; Fri, 04 Aug 2023 10:07:07 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 59DDC60003; Fri, 4 Aug 2023 14:07:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protesilaos.com; s=gm1; t=1691158020; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=3R9JLKJrv6dJ8dbzCM3dbvDMXD/6mpiFodQm8xcVdec=; b=eo8ApEmJKLs7vZsP5P2+Jn9nWlF7h75u4E8AiwB7s6HIQ0Ecstl/CQKYr1IcPNNb0TMEqW EQ95KsC7viQA7q1O6Iyzsvt0qrsBU8ZB0Yfw/tCcL9vEzDGEudBSFTYTOEevpxJD1Njs45 J1Vn9TBxFr3TvggI3sMJ0flEvto+hwfUzQRmrcPfTLwEdsI7yKdRoyoqQpAjnHp9WEVHHR YJRFhHQTxFw8V2xOnyMIKUQ4gYjIUnfTablZcJ5y/x9k2DXRZ7B4XsjcF1FNDYgfsWzew9 qj2jQSdP9NunFHhSPKw9m2rPMxnclzleZWKsBKO6OkWbYz/1G6Dh2Ke2IOM+jg== In-Reply-To: <834jlfw116.fsf@gnu.org> X-GND-Sasl: public@protesilaos.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:266677 Archived-At: --=-=-= Content-Type: text/plain > From: Eli Zaretskii > Date: Fri, 4 Aug 2023 13:32:37 +0300 > >> From: Protesilaos Stavrou >> Cc: 65039@debbugs.gnu.org >> Date: Fri, 04 Aug 2023 12:17:43 +0300 >> >> > I'll let users of bookmarks comment, but in any case, please also >> > check that the section "Bookmarks" in the Emacs user manual doesn't >> > need some update due to this feature. (You marked the NEWS entry with >> > "---", which might mean you already checked that, but I'm not sure.) >> >> I thought a change was not necessary. Though I am happy to do it, if >> needed. > > It sounds like the notion of "jumping" to a bookmark has evolved, and > nowadays jumping to a bookmark might do much more than just jump to a > buffer position. Perhaps that node in the manual should say something > about that, and show a couple of examples? The revised patch includes a possible update to the manual. Are those examples sufficient? -- Protesilaos Stavrou https://protesilaos.com --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-bookmark-handler-for-M-x-shell.patch >From 4c903061803f7e41cc4f87f80b1b089c2174cc21 Mon Sep 17 00:00:00 2001 Message-ID: <4c903061803f7e41cc4f87f80b1b089c2174cc21.1691157813.git.info@protesilaos.com> From: Protesilaos Stavrou Date: Fri, 4 Aug 2023 17:03:08 +0300 Subject: [PATCH] Add bookmark handler for M-x shell * doc/emacs/regs.texi (Bookmarks): Explain that 'bookmark-jump' establishes a remote connection. * etc/NEWS: Announce the new feature. * lisp/shell.el (shell-mode): Add buffer-local value for 'bookmark-make-record-function'. (bookmark-prop-get, shell-bookmark-name, shell-bookmark-make-record) (shell-bookmark-jump): Add section about the bookmark handler. --- doc/emacs/regs.texi | 6 ++++++ etc/NEWS | 6 ++++++ lisp/shell.el | 26 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/doc/emacs/regs.texi b/doc/emacs/regs.texi index e52f68dd18e..2debf9988c2 100644 --- a/doc/emacs/regs.texi +++ b/doc/emacs/regs.texi @@ -391,6 +391,12 @@ many characters of context to record on each side of the bookmark's position. (In buffers that are visiting encrypted files, no context is saved in the bookmarks file no matter the value of this variable.) + If the bookmark is stored in a remote location, @code{bookmark-jump} +will establish the connection and then create the buffer. This works +with regular files, as well as the buffers of @kbd{M-x dired} and +@kbd{M-x shell}. @xref{Top, The Tramp Manual,, tramp, The Tramp +Manual}. + Here are some additional commands for working with bookmarks: @table @kbd diff --git a/etc/NEWS b/etc/NEWS index 7b521f3e6fe..6329165cda2 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -286,6 +286,12 @@ When this user option is non-nil, 'shell-get-old-input' ('C-RET') includes multiple shell "\" continuation lines from command output. Default is nil. ++++ +*** Bookmark handler for 'shell' buffers +Now the 'bookmark-set' command will record 'shell' buffers. This +means that 'bookmark-jump' will create the 'shell' buffer in the +directory it was in. + ** Prog Mode +++ diff --git a/lisp/shell.el b/lisp/shell.el index 0a24b4ea4c2..bdf8eb17fbd 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -676,6 +676,7 @@ (define-derived-mode shell-mode comint-mode "Shell" (setq comint-prompt-regexp shell-prompt-pattern) (shell-completion-vars) + (setq-local bookmark-make-record-function #'shell-bookmark-make-record) (setq-local paragraph-separate "\\'") (setq-local paragraph-start comint-prompt-regexp) (setq-local font-lock-defaults '(shell-font-lock-keywords t)) @@ -1812,6 +1813,31 @@ (defun shell-highlight-undef-mode-restart () (when shell-highlight-undef-mode (shell-highlight-undef-mode 1))) +;;; Bookmark support + +;; Adapted from esh-mode.el +(declare-function bookmark-prop-get "bookmark" (bookmark prop)) + +(defun shell-bookmark-name () + (format "shell-%s" + (file-name-nondirectory + (directory-file-name + (file-name-directory default-directory))))) + +(defun shell-bookmark-make-record () + "Create a bookmark for the current Shell buffer." + `(,(shell-bookmark-name) + (location . ,default-directory) + (handler . shell-bookmark-jump))) + +;;;###autoload +(defun shell-bookmark-jump (bookmark) + "Default bookmark handler for Shell buffers." + (let ((default-directory (bookmark-prop-get bookmark 'location))) + (shell))) + +(put 'shell-bookmark-jump 'bookmark-handler-type "Shell") + (provide 'shell) ;;; shell.el ends here -- 2.41.0 --=-=-=--