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: Thu, 03 Aug 2023 17:41:27 +0300 Message-ID: <877cqcw5m0.fsf@protesilaos.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="9759"; mail-complaints-to="usenet@ciao.gmane.io" To: 65039@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 03 16:42:29 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 1qRZX2-0002Hs-OC for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 03 Aug 2023 16:42:28 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qRZWe-0008Uo-Us; Thu, 03 Aug 2023 10:42: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 1qRZWc-0008Uf-TQ for bug-gnu-emacs@gnu.org; Thu, 03 Aug 2023 10:42:02 -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 1qRZWc-0005wJ-Hx for bug-gnu-emacs@gnu.org; Thu, 03 Aug 2023 10:42:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qRZWc-0007g5-4h for bug-gnu-emacs@gnu.org; Thu, 03 Aug 2023 10:42: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: Thu, 03 Aug 2023 14:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 65039 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.169107370529487 (code B ref -1); Thu, 03 Aug 2023 14:42:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 3 Aug 2023 14:41:45 +0000 Original-Received: from localhost ([127.0.0.1]:52670 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qRZWK-0007fW-VI for submit@debbugs.gnu.org; Thu, 03 Aug 2023 10:41:45 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:36666) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qRZWI-0007fI-My for submit@debbugs.gnu.org; Thu, 03 Aug 2023 10:41:43 -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 1qRZWC-0008PP-Kc for bug-gnu-emacs@gnu.org; Thu, 03 Aug 2023 10:41:36 -0400 Original-Received: from relay5-d.mail.gandi.net ([2001:4b98:dc4:8::225]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qRZWA-0005og-Ba for bug-gnu-emacs@gnu.org; Thu, 03 Aug 2023 10:41:36 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 0C1E71C000D for ; Thu, 3 Aug 2023 14:41:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protesilaos.com; s=gm1; t=1691073689; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=bzf3bYPTNtfWbdHXf+nlYHCNylY2kz5jLtU7DaGJy2Y=; b=UGui3mChfzmZ8t+mE1iiEwDnFVTtDr96jw3au3zf6NBy85YFNToS8QiHZ8zlQiSf+4R4e2 Phc1+R8M9Dw0O4MEFJ5Se30PvW8cm1qklxuIoNGcppmgxOpIO79s5GKAv5upu0Wg/XcQYY KqcNiSTnZNW889HJB04TGI46X9MOB/MvBaRQHArpdgdiQBbClQWWX7HDn8MabqXl49QEJf I1h5J9CaxUxoToNyvsMVReLniesdNcx29tyfNdZ7BGbmNeuNNWcZGNRiYJsLJzGLaqXFJv Pa+EmgWGqErdJb3k4d+rWREeMTRcMMhfpESbwf93DGP0IvUuS4kU1ZY+y4tzzQ== X-GND-Sasl: public@protesilaos.com Received-SPF: none client-ip=2001:4b98:dc4:8::225; envelope-from=info@protesilaos.com; helo=relay5-d.mail.gandi.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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:266589 Archived-At: --=-=-= Content-Type: text/plain Dear maintainers, I noticed that M-x shell does not have a bookmark handler like M-x eshell does. What do you think about the attached patch? All the best, Protesilaos (or simply "Prot") -- Protesilaos Stavrou https://protesilaos.com --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-bookmark-handler-for-M-x-shell.patch >From 69744f953b95dc2f3c9c3039324e121a6d664570 Mon Sep 17 00:00:00 2001 Message-ID: <69744f953b95dc2f3c9c3039324e121a6d664570.1691073443.git.info@protesilaos.com> From: Protesilaos Stavrou Date: Thu, 3 Aug 2023 17:35:10 +0300 Subject: [PATCH] Add bookmark handler for M-x shell * etc/NEWS: Anounce the new feature. * lisp/shell.el (shell-mode): Add buffer-local 'bookmark-make-record-function'. (bookmark-prop-get, shell-bookmark-name, shell-bookmark-make-record) (shell-bookmark-jump): Add bookmark handler. --- etc/NEWS | 6 ++++++ lisp/shell.el | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index 7b521f3e6fe..da5d9b96002 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 --=-=-=--