unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Kevin Ryde <user42_kevin@yahoo.com.au>
Cc: 19812@debbugs.gnu.org
Subject: bug#19812: 24.4; suggest `shell-mode' not interactive
Date: Fri, 02 Aug 2019 21:52:17 +0200	[thread overview]
Message-ID: <87v9vfmjke.fsf@mouse.gnus.org> (raw)
In-Reply-To: <87bnl5qc50.fsf@blah.blah> (Kevin Ryde's message of "Sun, 08 Feb 2015 15:07:39 +1100")

Kevin Ryde <user42_kevin@yahoo.com.au> writes:

> The `shell-mode' function is interactive, but I think perhaps it should
> not be since it is not designed for use as M-x shell-mode in an
> arbitrary buffer, but only after the `shell' function makes various
> setups.
>
> I struck this when a brain fade confused me between shell-command,
> shell-mode and shell and I did M-x shell-mode in a file buffer and
> nearly made a big mess.  The problem is only seen when shell.el has been
> loaded (for any reason) since shell-mode is not autoloaded.
>
> Similar could apply to other special modes, maybe even to most modes
> derived from `special-mode'.

As you point out, there's a lot of modes that only make sense in certain
limited contexts, and having them be interactive isn't very helpful.
I'm not sure it's that much of a problem in general, but it is a
particular an issue with `shell-mode', since I'd guess that a lot of
people type that instead of `M-x shell-script-mode' when starting to
write new shell scripts.

The following fixes this particular issue.  Would something like this be
welcome?

A different fix would be to extend defined-derived-mode to take a
:noninteractive flag to just not include the `(interactive)' in the
defun.  It looks fairly straightforward to implement -- is that a better
idea, perhaps?

(That is, if we want to fix this at all.)

diff --git a/lisp/shell.el b/lisp/shell.el
index 2914d1d2c8..ba7515e7ba 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -553,6 +553,8 @@ shell-mode
 `comint-scroll-to-bottom-on-input' and `comint-scroll-to-bottom-on-output'
 control whether input and output cause the window to scroll to the end of the
 buffer."
+  (when (called-interactively-p 'any)
+    (error "Can't be called interactively; did you mean `shell-script-mode' instead?"))
   (setq comint-prompt-regexp shell-prompt-pattern)
   (shell-completion-vars)
   (setq-local paragraph-separate "\\'")


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





  reply	other threads:[~2019-08-02 19:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-08  4:07 bug#19812: 24.4; suggest `shell-mode' not interactive Kevin Ryde
2019-08-02 19:52 ` Lars Ingebrigtsen [this message]
2019-08-02 23:54   ` Kevin Ryde
2019-08-03 11:11     ` Lars Ingebrigtsen
2019-08-03  7:22   ` Eli Zaretskii
2019-08-03 11:08     ` Lars Ingebrigtsen
2019-08-04 19:11       ` Juri Linkov
2019-08-05  8:54         ` Kevin Ryde
2019-08-05 21:59           ` Juri Linkov
2019-08-07  6:46             ` Kevin Ryde
2019-08-23  0:59     ` Lars Ingebrigtsen
2019-08-27 22:13       ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v9vfmjke.fsf@mouse.gnus.org \
    --to=larsi@gnus.org \
    --cc=19812@debbugs.gnu.org \
    --cc=user42_kevin@yahoo.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).