From: Basil L. Contovounesios Date: Fri, 17 Apr 2020 09:27:36 +0000 (+0100) Subject: Define explicit-shell-file-name only in shell.el X-Git-Tag: emacs-28.0.90~4941 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6ecec6096697729491ba141e7650ad69de5f034e;p=emacs.git Define explicit-shell-file-name only in shell.el For discussion, see the following thread: https://lists.gnu.org/r/emacs-devel/2020-04/msg00880.html * doc/emacs/cmdargs.texi (General Variables): Mention shell-file-name in relation to SHELL. * doc/emacs/misc.texi (Interactive Shell): Move index entry for SHELL environment variable from here, where it is not mentioned... (Single Shell): ...to here, where it is discussed along with shell-file-name. * lisp/dired.el (dired-insert-directory): Use shell-file-name instead of explicit-shell-file-name when a shell is implicitly requested. * lisp/obsolete/terminal.el (explicit-shell-file-name): * lisp/term.el (explicit-shell-file-name): Remove duplicate defcustoms and load lisp/shell.el instead. (Bug#40679) * lisp/shell.el (explicit-shell-file-name): Clarify docstring. (shell): Simplify. --- diff --git a/doc/emacs/cmdargs.texi b/doc/emacs/cmdargs.texi index 3dd1fe9a308..a828eee076f 100644 --- a/doc/emacs/cmdargs.texi +++ b/doc/emacs/cmdargs.texi @@ -654,7 +654,8 @@ Used by the Gnus package. @item SHELL @vindex SHELL@r{, environment variable} The name of an interpreter used to parse and execute programs run from -inside Emacs. +inside Emacs. This is used to initialize the variable +@code{shell-file-name} (@pxref{Single Shell}). @item SMTPSERVER @vindex SMTPSERVER@r{, environment variable} The name of the outgoing mail server. This is used to initialize the diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi index 4865ee17518..5b5134b7c3f 100644 --- a/doc/emacs/misc.texi +++ b/doc/emacs/misc.texi @@ -810,6 +810,7 @@ to @command{gpg}. This will output the list of keys to the buffer whose name is the value of @code{shell-command-buffer-name}. @vindex shell-file-name +@cindex @env{SHELL} environment variable The above commands use the shell specified by the variable @code{shell-file-name}. Its default value is determined by the @env{SHELL} environment variable when Emacs is started. If the file @@ -889,7 +890,6 @@ Subshells in different buffers run independently and in parallel. @vindex explicit-shell-file-name @cindex environment variables for subshells @cindex @env{ESHELL} environment variable -@cindex @env{SHELL} environment variable To specify the shell file name used by @kbd{M-x shell}, customize the variable @code{explicit-shell-file-name}. If this is @code{nil} (the default), Emacs uses the environment variable @env{ESHELL} if it diff --git a/lisp/dired.el b/lisp/dired.el index 08b19a02250..30b9f5b8fa1 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -1509,8 +1509,7 @@ see `dired-use-ls-dired' for more details.") (script (format "ls %s %s" switches (cdr dir-wildcard))) (remotep (file-remote-p dir)) (sh (or (and remotep "/bin/sh") - (and (bound-and-true-p explicit-shell-file-name) - (executable-find explicit-shell-file-name)) + (executable-find shell-file-name) (executable-find "sh"))) (switch (if remotep "-c" shell-command-switch))) ;; Enable globstar diff --git a/lisp/obsolete/terminal.el b/lisp/obsolete/terminal.el index 6ee53af6483..3d73c030c36 100644 --- a/lisp/obsolete/terminal.el +++ b/lisp/obsolete/terminal.el @@ -44,6 +44,7 @@ ;;>> more-processing enabled. (require 'ehelp) +(require 'shell) (defgroup terminal nil "Terminal emulator for Emacs." @@ -1056,12 +1057,6 @@ move to start of new line, clear to end of line." ;; This used to have `new' in it, but that loses outside BSD ;; and it's apparently not needed in BSD. -(defcustom explicit-shell-file-name nil - "If non-nil, is file name to use for explicitly requested inferior shell." - :type '(choice (const :tag "None" nil) - file) - :group 'terminal) - ;;;###autoload (defun terminal-emulator (buffer program args &optional width height) "Under a display-terminal emulator in BUFFER, run PROGRAM on arguments ARGS. diff --git a/lisp/shell.el b/lisp/shell.el index 51937cdeef3..5fed6513b96 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -265,10 +265,11 @@ see the function `dirtrack-mode'." :group 'shell-directories) (defcustom explicit-shell-file-name nil - "If non-nil, is file name to use for explicitly requested inferior shell. -When nil, such interactive shell sessions fallback to using either -the shell specified in $ESHELL or in `shell-file-name'." - :type '(choice (const :tag "None" nil) file) + "If non-nil, the file name to use for explicitly requested inferior shells. +When nil, such interactive shell sessions fall back to using the +shell specified in either the environment variable \"ESHELL\" or +`shell-file-name'." + :type '(choice (const :tag "Default" nil) file) :group 'shell) ;; Note: There are no explicit references to the variable `explicit-csh-args'. @@ -748,16 +749,15 @@ Make the shell buffer the current buffer, and return it. (with-connection-local-variables ;; On remote hosts, the local `shell-file-name' might be useless. - (when (file-remote-p default-directory) - (if (and (called-interactively-p 'any) + (when (and (file-remote-p default-directory) + (called-interactively-p 'any) (null explicit-shell-file-name) (null (getenv "ESHELL"))) - (set (make-local-variable 'explicit-shell-file-name) - (file-local-name - (expand-file-name - (read-file-name - "Remote shell path: " default-directory shell-file-name - t shell-file-name)))))) + (setq-local explicit-shell-file-name + (file-local-name + (expand-file-name + (read-file-name "Remote shell path: " default-directory + shell-file-name t shell-file-name))))) ;; Rain or shine, BUFFER must be current by now. (unless (comint-check-proc buffer) diff --git a/lisp/term.el b/lisp/term.el index 148d7a7c286..34dc2870f21 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -299,17 +299,13 @@ ;; so it is important to increase it if there are protocol-relevant changes. (defconst term-protocol-version "0.96") -(eval-when-compile (require 'ange-ftp)) -(eval-when-compile (require 'cl-lib)) -(require 'ring) -(require 'ehelp) +(eval-when-compile + (require 'ange-ftp) + (require 'cl-lib)) (require 'comint) ; Password regexp. - -(declare-function ring-empty-p "ring" (ring)) -(declare-function ring-ref "ring" (ring index)) -(declare-function ring-insert-at-beginning "ring" (ring item)) -(declare-function ring-length "ring" (ring)) -(declare-function ring-insert "ring" (ring item)) +(require 'ehelp) +(require 'ring) +(require 'shell) (defgroup term nil "General command interpreter in a window." @@ -393,11 +389,6 @@ by moving term-home-marker. It is set to t if there is a (defvar-local term-line-mode-buffer-read-only nil "The `buffer-read-only' state to set in `term-line-mode'.") -(defcustom explicit-shell-file-name nil - "If non-nil, is file name to use for explicitly requested inferior shell." - :type '(choice (const nil) file) - :group 'term) - (defvar term-prompt-regexp "^" "Regexp to recognize prompts in the inferior process. Defaults to \"^\", the null string at BOL.