(require 'pcomplete)
(eval-when-compile (require 'files-x)) ;with-connection-local-variables
(require 'subr-x)
+(eval-when-compile (require 'cl-lib))
;;; Customization and Buffer Variables
(const :tag "on" t))
:group 'shell)
+(defcustom shell-comint-fl-enable t
+ "Enable highlighting of input in shell buffers.
+This variable only has effect when the shell is started. Use the
+command `comint-fl-mode' to toggle highlighting of input."
+ :type 'boolean
+ :group 'shell
+ :safe 'booleanp
+ :version "29.1")
+
+(defcustom shell-indirect-setup-hook nil
+ "Hook run after setting up an indirect shell fontification buffer."
+ :type 'boolean
+ :group 'shell
+ :safe 'booleanp
+ :version "29.1")
+
(defvar shell-dirstack nil
"List of directories saved by pushd in this buffer's shell.
Thus, this does not include the shell's current directory.")
(put 'shell-mode 'mode-class 'special)
+(defvar sh-shell-file)
+
(define-derived-mode shell-mode comint-mode "Shell"
"Major mode for interacting with an inferior shell.
\\<shell-mode-map>
whenever it receives the bell character in output from a
command."
:interactive nil
+ :after-hook
+ (and (null comint-use-prompt-regexp)
+ shell-comint-fl-enable
+ (comint-fl-mode))
+
(setq comint-prompt-regexp shell-prompt-pattern)
(shell-completion-vars)
(setq-local paragraph-separate "\\'")
(setq-local ansi-color-apply-face-function #'shell-apply-ansi-color)
(shell-reapply-ansi-color)
+ (add-hook 'comint-indirect-setup-hook
+ #'shell-indirect-setup-hook 'append t)
+ (setq comint-indirect-setup-function
+ (let ((shell shell--start-prog))
+ (lambda ()
+ (require 'sh-script)
+ (cl-letf
+ (((default-value 'sh-shell-file)
+ (or shell sh-shell-file))
+ (inhibit-message t)
+ (message-log-max nil))
+ (sh-mode)))))
+
;; This is not really correct, since the shell buffer does not really
;; edit this directory. But it is useful in the buffer list and menus.
(setq list-buffers-directory (expand-file-name default-directory))
": [[:digit:]]+:[[:digit:]]+;")))
(comint-read-input-ring t)))
+(defun shell-indirect-setup-hook ()
+ "Run `shell-indirect-setup-hook'."
+ (run-hooks 'shell-indirect-setup-hook))
+
(defun shell-apply-ansi-color (beg end face)
"Apply FACE as the ansi-color face for the text between BEG and END."
(when face