GNU bug report logs - #50765
27.2; [PATCH] Fix problems with 'C-c C-n' in sh-script-mode

Previous Next

Package: emacs;

Reported by: miha <at> kamnitnik.top

Date: Thu, 23 Sep 2021 16:26:01 UTC

Severity: normal

Tags: patch

Found in version 27.2

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 50765 in the body.
You can then email your comments to 50765 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#50765; Package emacs. (Thu, 23 Sep 2021 16:26:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to miha <at> kamnitnik.top:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 23 Sep 2021 16:26:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: miha <at> kamnitnik.top
To: bug-gnu-emacs <at> gnu.org
Subject: 27.2; [PATCH] Fix problems with 'C-c C-n' in sh-script-mode
Date: Thu, 23 Sep 2021 18:28:21 +0200
[Message part 1 (text/plain, inline)]
Scenario: we are editing a buffer in 'shell-script-mode' and a *shell*
buffer doesn't exist yet.

In Emacs 27, pressing 'C-c C-n' creates a shell buffer and displays it
in a separate window by default.  This is less annoying than displaying
it in the selected window, which is what Emacs 28 currently does by
default, so this patch reverts that.

It also fixes a subtle bug, where a local variable is set in an
incorrect buffer.

Best regards.

[0001-Fix-problems-with-C-c-C-n-in-sh-script-mode.patch (text/x-patch, inline)]
From 84cdc5fd707baa2537cc57a77cec4ea537c4f308 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miha=20Rihtar=C5=A1i=C4=8D?= <miha <at> kamnitnik.top>
Date: Thu, 23 Sep 2021 18:03:24 +0200
Subject: [PATCH] Fix problems with 'C-c C-n' in sh-script-mode

* lisp/progmodes/sh-script.el (sh-shell-process): If a *shell* buffer
doesn't exist, 'C-c C-n' creates one and displays it.  This patch
prevents it from being displayed in the selected window.
Additionally, it ensures that the local `sh-shell-process' variable is
set in the correct buffer.
---
 lisp/progmodes/sh-script.el | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index cccd70f06c..3b6774aa14 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -1396,8 +1396,15 @@ sh-shell-process
             (or found
                 (and force
                      (get-buffer-process
-                      (let ((explicit-shell-file-name sh-shell-file))
-                        (shell)))))))))
+                      (let ((explicit-shell-file-name sh-shell-file)
+                            (display-buffer-overriding-action
+                             '(nil . ((inhibit-same-window . t)))))
+                        ;; We must prevent this `(shell)' call from
+                        ;; switching buffers, so that the variable
+                        ;; `sh-shell-process' is set locally in the
+                        ;; correct buffer.
+                        (save-current-buffer
+                          (shell))))))))))
 
 (defun sh-show-shell ()
   "Pop the shell interaction buffer."
-- 
2.33.0

[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50765; Package emacs. (Thu, 23 Sep 2021 21:20:01 GMT) Full text and rfc822 format available.

Message #8 received at 50765 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: miha <at> kamnitnik.top
Cc: 50765 <at> debbugs.gnu.org
Subject: Re: bug#50765: 27.2; [PATCH] Fix problems with 'C-c C-n' in
 sh-script-mode
Date: Thu, 23 Sep 2021 23:18:56 +0200
miha <at> kamnitnik.top writes:

> In Emacs 27, pressing 'C-c C-n' creates a shell buffer and displays it
> in a separate window by default.  This is less annoying than displaying
> it in the selected window, which is what Emacs 28 currently does by
> default, so this patch reverts that.

Makes sense to me, so I've pushed it to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 28.1, send any further explanations to 50765 <at> debbugs.gnu.org and miha <at> kamnitnik.top Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 23 Sep 2021 21:20:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 22 Oct 2021 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 185 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.