GNU bug report logs -
#19812
24.4; suggest `shell-mode' not interactive
Previous Next
Reported by: Kevin Ryde <user42_kevin <at> yahoo.com.au>
Date: Sun, 8 Feb 2015 04:14:02 UTC
Severity: wishlist
Tags: fixed, patch
Found in version 24.4
Fixed in version 27.1
Done: Lars Ingebrigtsen <larsi <at> mouse.gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Kevin Ryde <user42_kevin <at> 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
This bug report was last modified 5 years and 273 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.