unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#50765: 27.2; [PATCH] Fix problems with 'C-c C-n' in sh-script-mode
@ 2021-09-23 16:28 miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-09-23 21:18 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-09-23 16:28 UTC (permalink / raw)
  To: 50765


[-- Attachment #1.1: Type: text/plain, Size: 445 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Fix-problems-with-C-c-C-n-in-sh-script-mode.patch --]
[-- Type: text/x-patch, Size: 1709 bytes --]

From 84cdc5fd707baa2537cc57a77cec4ea537c4f308 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miha=20Rihtar=C5=A1i=C4=8D?= <miha@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


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#50765: 27.2; [PATCH] Fix problems with 'C-c C-n' in sh-script-mode
  2021-09-23 16:28 bug#50765: 27.2; [PATCH] Fix problems with 'C-c C-n' in sh-script-mode miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-09-23 21:18 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2021-09-23 21:18 UTC (permalink / raw)
  To: miha; +Cc: 50765

miha@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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-23 21:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-23 16:28 bug#50765: 27.2; [PATCH] Fix problems with 'C-c C-n' in sh-script-mode miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-23 21:18 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).