Prefer setq-local in eshell

* lisp/eshell/em-cmpl.el (eshell-cmpl-initialize):
* lisp/eshell/em-dirs.el (eshell-dirs-initialize):
* lisp/eshell/em-glob.el (eshell-glob-initialize, eshell-glob-regexp):
* lisp/eshell/em-hist.el (eshell-hist-initialize):
* lisp/eshell/em-prompt.el (eshell-prompt-initialize):
* lisp/eshell/em-rebind.el (eshell-rebind-initialize)
(eshell-setup-input-keymap):
* lisp/eshell/em-script.el (eshell-script-initialize):
* lisp/eshell/em-smart.el (eshell-smart-initialize):
* lisp/eshell/em-term.el (eshell-term-initialize, eshell-exec-visual):
* lisp/eshell/em-tramp.el (eshell-tramp-initialize):
* lisp/eshell/em-unix.el (eshell-unix-initialize, eshell/diff):
* lisp/eshell/esh-arg.el (eshell-arg-initialize):
* lisp/eshell/esh-cmd.el (eshell-cmd-initialize):
* lisp/eshell/esh-io.el (eshell-get-target):
* lisp/eshell/esh-mode.el (eshell-mode):
* lisp/eshell/esh-var.el (eshell-var-initialize): Prefer setq-local.
This commit is contained in:
Stefan Kangas 2020-12-04 10:55:50 +01:00
parent f365eb2e05
commit 78cdf4c762
16 changed files with 90 additions and 107 deletions

View file

@ -267,48 +267,48 @@ to writing a completion function."
(defun eshell-cmpl-initialize () ;Called from `eshell-mode' via intern-soft!
"Initialize the completions module."
(set (make-local-variable 'pcomplete-command-completion-function)
eshell-command-completion-function)
(set (make-local-variable 'pcomplete-command-name-function)
eshell-cmpl-command-name-function)
(set (make-local-variable 'pcomplete-default-completion-function)
eshell-default-completion-function)
(set (make-local-variable 'pcomplete-parse-arguments-function)
'eshell-complete-parse-arguments)
(set (make-local-variable 'pcomplete-file-ignore)
eshell-cmpl-file-ignore)
(set (make-local-variable 'pcomplete-dir-ignore)
eshell-cmpl-dir-ignore)
(set (make-local-variable 'pcomplete-ignore-case)
eshell-cmpl-ignore-case)
(set (make-local-variable 'pcomplete-autolist)
eshell-cmpl-autolist)
(setq-local pcomplete-command-completion-function
eshell-command-completion-function)
(setq-local pcomplete-command-name-function
eshell-cmpl-command-name-function)
(setq-local pcomplete-default-completion-function
eshell-default-completion-function)
(setq-local pcomplete-parse-arguments-function
'eshell-complete-parse-arguments)
(setq-local pcomplete-file-ignore
eshell-cmpl-file-ignore)
(setq-local pcomplete-dir-ignore
eshell-cmpl-dir-ignore)
(setq-local pcomplete-ignore-case
eshell-cmpl-ignore-case)
(setq-local pcomplete-autolist
eshell-cmpl-autolist)
(if (boundp 'pcomplete-suffix-list)
(set (make-local-variable 'pcomplete-suffix-list)
eshell-cmpl-suffix-list))
(set (make-local-variable 'pcomplete-recexact)
eshell-cmpl-recexact)
(set (make-local-variable 'pcomplete-man-function)
eshell-cmpl-man-function)
(set (make-local-variable 'pcomplete-compare-entry-function)
eshell-cmpl-compare-entry-function)
(set (make-local-variable 'pcomplete-expand-before-complete)
eshell-cmpl-expand-before-complete)
(set (make-local-variable 'pcomplete-cycle-completions)
eshell-cmpl-cycle-completions)
(set (make-local-variable 'pcomplete-cycle-cutoff-length)
eshell-cmpl-cycle-cutoff-length)
(set (make-local-variable 'pcomplete-restore-window-delay)
eshell-cmpl-restore-window-delay)
(set (make-local-variable 'pcomplete-use-paring)
eshell-cmpl-use-paring)
(setq-local pcomplete-suffix-list
eshell-cmpl-suffix-list))
(setq-local pcomplete-recexact
eshell-cmpl-recexact)
(setq-local pcomplete-man-function
eshell-cmpl-man-function)
(setq-local pcomplete-compare-entry-function
eshell-cmpl-compare-entry-function)
(setq-local pcomplete-expand-before-complete
eshell-cmpl-expand-before-complete)
(setq-local pcomplete-cycle-completions
eshell-cmpl-cycle-completions)
(setq-local pcomplete-cycle-cutoff-length
eshell-cmpl-cycle-cutoff-length)
(setq-local pcomplete-restore-window-delay
eshell-cmpl-restore-window-delay)
(setq-local pcomplete-use-paring
eshell-cmpl-use-paring)
;; `comint-file-name-quote-list' should only be set after all the
;; load-hooks for any other extension modules have been run, which
;; is true at the time `eshell-mode-hook' is run
(add-hook 'eshell-mode-hook
(lambda ()
(set (make-local-variable 'comint-file-name-quote-list)
eshell-special-chars-outside-quoting))
(setq-local comint-file-name-quote-list
eshell-special-chars-outside-quoting))
nil t)
(add-hook 'pcomplete-quote-arg-hook #'eshell-quote-backslash nil t)
(add-hook 'completion-at-point-functions

View file

@ -175,8 +175,7 @@ Thus, this does not include the current directory.")
(defun eshell-dirs-initialize () ;Called from `eshell-mode' via intern-soft!
"Initialize the builtin functions for Eshell."
(make-local-variable 'eshell-variable-aliases-list)
(setq eshell-variable-aliases-list
(setq-local eshell-variable-aliases-list
(append
eshell-variable-aliases-list
`(("-" ,(lambda (indices)
@ -199,8 +198,7 @@ Thus, this does not include the current directory.")
t))))
(when eshell-cd-on-directory
(make-local-variable 'eshell-interpreter-alist)
(setq eshell-interpreter-alist
(setq-local eshell-interpreter-alist
(cons (cons #'(lambda (file _args)
(eshell-lone-directory-p file))
'eshell-dirs-substitute-cd)

View file

@ -129,7 +129,7 @@ This option slows down recursive glob processing by quite a bit."
"Initialize the extended globbing code."
;; it's important that `eshell-glob-chars-list' come first
(when (boundp 'eshell-special-chars-outside-quoting)
(set (make-local-variable 'eshell-special-chars-outside-quoting)
(setq-local eshell-special-chars-outside-quoting
(append eshell-glob-chars-list eshell-special-chars-outside-quoting)))
(add-hook 'eshell-parse-argument-hook 'eshell-parse-glob-chars t t)
(add-hook 'eshell-pre-rewrite-command-hook
@ -205,7 +205,7 @@ resulting regular expression."
regexp)
(while (string-match
(or eshell-glob-chars-regexp
(set (make-local-variable 'eshell-glob-chars-regexp)
(setq-local eshell-glob-chars-regexp
(format "[%s]+" (apply 'string eshell-glob-chars-list))))
pattern matched-in-pattern)
(let* ((op-begin (match-beginning 0))

View file

@ -243,11 +243,10 @@ Returns nil if INPUT is prepended by blank space, otherwise non-nil."
(if (and (eshell-using-module 'eshell-rebind)
(not eshell-non-interactive-p))
(let ((rebind-alist eshell-rebind-keys-alist))
(make-local-variable 'eshell-rebind-keys-alist)
(setq eshell-rebind-keys-alist
(setq-local eshell-rebind-keys-alist
(append rebind-alist eshell-hist-rebind-keys-alist))
(set (make-local-variable 'search-invisible) t)
(set (make-local-variable 'search-exit-option) t)
(setq-local search-invisible t)
(setq-local search-exit-option t)
(add-hook 'isearch-mode-hook
(lambda ()
(if (>= (point) eshell-last-output-end)
@ -278,8 +277,8 @@ Returns nil if INPUT is prepended by blank space, otherwise non-nil."
(make-local-variable 'eshell-save-history-index)
(if (minibuffer-window-active-p (selected-window))
(set (make-local-variable 'eshell-save-history-on-exit) nil)
(set (make-local-variable 'eshell-history-ring) nil)
(setq-local eshell-save-history-on-exit nil)
(setq-local eshell-history-ring nil)
(if eshell-history-file-name
(eshell-read-history nil t))

View file

@ -117,10 +117,9 @@ arriving, or after."
(make-local-variable 'eshell-prompt-regexp)
(if eshell-prompt-regexp
(set (make-local-variable 'paragraph-start) eshell-prompt-regexp))
(setq-local paragraph-start eshell-prompt-regexp))
(set (make-local-variable 'eshell-skip-prompt-function)
'eshell-skip-prompt)
(setq-local eshell-skip-prompt-function #'eshell-skip-prompt)
(eshell-prompt-mode)))
(defun eshell-emit-prompt ()

View file

@ -163,7 +163,7 @@ This is default behavior of shells like bash."
(add-hook 'pre-command-hook 'eshell-save-previous-point nil t)
(make-local-variable 'overriding-local-map)
(add-hook 'post-command-hook 'eshell-rebind-input-map nil t)
(set (make-local-variable 'eshell-lock-keymap) nil)
(setq-local eshell-lock-keymap nil)
(eshell-rebind-mode)))
(defun eshell-lock-local-map (&optional arg)
@ -219,8 +219,7 @@ lock it at that."
(defun eshell-setup-input-keymap ()
"Setup the input keymap to be used during input editing."
(make-local-variable 'eshell-input-keymap)
(setq eshell-input-keymap (make-sparse-keymap))
(setq-local eshell-input-keymap (make-sparse-keymap))
(set-keymap-parent eshell-input-keymap eshell-mode-map)
(let ((bindings eshell-rebind-keys-alist))
(while bindings

View file

@ -58,15 +58,13 @@ This includes when running `eshell-command'."
(defun eshell-script-initialize () ;Called from `eshell-mode' via intern-soft!
"Initialize the script parsing code."
(make-local-variable 'eshell-interpreter-alist)
(setq eshell-interpreter-alist
(setq-local eshell-interpreter-alist
(cons (cons #'(lambda (file _args)
(string= (file-name-nondirectory file)
"eshell"))
'eshell/source)
eshell-interpreter-alist))
(make-local-variable 'eshell-complex-commands)
(setq eshell-complex-commands
(setq-local eshell-complex-commands
(append '("source" ".") eshell-complex-commands))
;; these two variables are changed through usage, but we don't want
;; to ruin it for other modules

View file

@ -170,9 +170,9 @@ The options are `begin', `after' or `end'."
(unless eshell-non-interactive-p
;; override a few variables, since they would interfere with the
;; smart display functionality.
(set (make-local-variable 'eshell-scroll-to-bottom-on-output) nil)
(set (make-local-variable 'eshell-scroll-to-bottom-on-input) nil)
(set (make-local-variable 'eshell-scroll-show-maximum-output) t)
(setq-local eshell-scroll-to-bottom-on-output nil)
(setq-local eshell-scroll-to-bottom-on-input nil)
(setq-local eshell-scroll-show-maximum-output t)
(add-hook 'window-scroll-functions 'eshell-smart-scroll-window nil t)
(add-hook 'window-configuration-change-hook 'eshell-refresh-windows)

View file

@ -143,8 +143,7 @@ behavior for short-lived processes, see bug#18108."
(defun eshell-term-initialize () ;Called from `eshell-mode' via intern-soft!
"Initialize the `term' interface code."
(make-local-variable 'eshell-interpreter-alist)
(setq eshell-interpreter-alist
(setq-local eshell-interpreter-alist
(cons (cons #'eshell-visual-command-p
'eshell-exec-visual)
eshell-interpreter-alist)))
@ -179,9 +178,8 @@ allowed."
(save-current-buffer
(switch-to-buffer term-buf)
(term-mode)
(set (make-local-variable 'term-term-name) eshell-term-name)
(make-local-variable 'eshell-parent-buffer)
(setq eshell-parent-buffer eshell-buf)
(setq-local term-term-name eshell-term-name)
(setq-local eshell-parent-buffer eshell-buf)
(term-exec term-buf program program nil args)
(let ((proc (get-buffer-process term-buf)))
(if (and proc (eq 'run (process-status proc)))

View file

@ -51,10 +51,9 @@
(when (eshell-using-module 'eshell-cmpl)
(add-hook 'pcomplete-try-first-hook
'eshell-complete-host-reference nil t))
(make-local-variable 'eshell-complex-commands)
(setq eshell-complex-commands
(append '("su" "sudo")
eshell-complex-commands)))
(setq-local eshell-complex-commands
(append '("su" "sudo")
eshell-complex-commands)))
(autoload 'eshell-parse-command "esh-cmd")

View file

@ -144,8 +144,7 @@ Otherwise, Emacs will attempt to use rsh to invoke du on the remote machine."
(when (eshell-using-module 'eshell-cmpl)
(add-hook 'pcomplete-try-first-hook
'eshell-complete-host-reference nil t))
(make-local-variable 'eshell-complex-commands)
(setq eshell-complex-commands
(setq-local eshell-complex-commands
(append '("grep" "egrep" "fgrep" "agrep" "glimpse" "locate"
"cat" "time" "cp" "mv" "make" "du" "diff")
eshell-complex-commands)))
@ -1008,7 +1007,7 @@ Show wall-clock time elapsed during execution of COMMAND.")
(lambda (buff _msg)
(with-current-buffer buff
(diff-mode)
(set (make-local-variable 'eshell-diff-window-config) config)
(setq-local eshell-diff-window-config config)
(local-set-key [?q] #'eshell-diff-quit)
(if (fboundp 'turn-on-font-lock-if-enabled)
(turn-on-font-lock-if-enabled))

View file

@ -168,8 +168,8 @@ treated as a literal character."
(defun eshell-arg-initialize () ;Called from `eshell-mode' via intern-soft!
"Initialize the argument parsing code."
(eshell-arg-mode)
(set (make-local-variable 'eshell-inside-quote-regexp) nil)
(set (make-local-variable 'eshell-outside-quote-regexp) nil))
(setq-local eshell-inside-quote-regexp nil)
(setq-local eshell-outside-quote-regexp nil))
(defun eshell-insert-buffer-name (buffer-name)
"Insert BUFFER-NAME into the current buffer at point."

View file

@ -290,12 +290,12 @@ otherwise t.")
(defun eshell-cmd-initialize () ;Called from `eshell-mode' via intern-soft!
"Initialize the Eshell command processing module."
(set (make-local-variable 'eshell-current-command) nil)
(set (make-local-variable 'eshell-command-name) nil)
(set (make-local-variable 'eshell-command-arguments) nil)
(set (make-local-variable 'eshell-last-arguments) nil)
(set (make-local-variable 'eshell-last-command-name) nil)
(set (make-local-variable 'eshell-last-async-proc) nil)
(setq-local eshell-current-command nil)
(setq-local eshell-command-name nil)
(setq-local eshell-command-arguments nil)
(setq-local eshell-last-arguments nil)
(setq-local eshell-last-command-name nil)
(setq-local eshell-last-async-proc nil)
(add-hook 'eshell-kill-hook #'eshell-resume-command nil t)

View file

@ -344,8 +344,8 @@ it defaults to `insert'."
(if buffer-file-read-only
(error "Cannot write to read-only file `%s'" target))
(setq buffer-read-only nil)
(set (make-local-variable 'eshell-output-file-buffer)
(if (eq exists buf) 0 t))
(setq-local eshell-output-file-buffer
(if (eq exists buf) 0 t))
(cond ((eq mode 'overwrite)
(erase-buffer))
((eq mode 'append)

View file

@ -312,45 +312,40 @@ and the hook `eshell-exit-hook'."
(if mode-line-elt
(setcar mode-line-elt 'eshell-command-running-string))))
(set (make-local-variable 'bookmark-make-record-function)
'eshell-bookmark-make-record)
(setq-local bookmark-make-record-function #'eshell-bookmark-make-record)
(setq local-abbrev-table eshell-mode-abbrev-table)
(set (make-local-variable 'list-buffers-directory)
(expand-file-name default-directory))
(setq-local list-buffers-directory (expand-file-name default-directory))
;; always set the tab width to 8 in Eshell buffers, since external
;; commands which do their own formatting almost always expect this
(set (make-local-variable 'tab-width) 8)
(setq-local tab-width 8)
;; don't ever use auto-fill in Eshell buffers
(setq auto-fill-function nil)
;; always display everything from a return value
(if (boundp 'print-length)
(set (make-local-variable 'print-length) nil))
(setq-local print-length nil))
(if (boundp 'print-level)
(set (make-local-variable 'print-level) nil))
(setq-local print-level nil))
;; set require-final-newline to nil; otherwise, all redirected
;; output will end with a newline, whether or not the source
;; indicated it!
(set (make-local-variable 'require-final-newline) nil)
(setq-local require-final-newline nil)
(set (make-local-variable 'max-lisp-eval-depth)
(max 3000 max-lisp-eval-depth))
(set (make-local-variable 'max-specpdl-size)
(max 6000 max-lisp-eval-depth))
(setq-local max-lisp-eval-depth (max 3000 max-lisp-eval-depth))
(setq-local max-specpdl-size (max 6000 max-lisp-eval-depth))
(set (make-local-variable 'eshell-last-input-start) (point-marker))
(set (make-local-variable 'eshell-last-input-end) (point-marker))
(set (make-local-variable 'eshell-last-output-start) (point-marker))
(set (make-local-variable 'eshell-last-output-end) (point-marker))
(set (make-local-variable 'eshell-last-output-block-begin) (point))
(setq-local eshell-last-input-start (point-marker))
(setq-local eshell-last-input-end (point-marker))
(setq-local eshell-last-output-start (point-marker))
(setq-local eshell-last-output-end (point-marker))
(setq-local eshell-last-output-block-begin (point))
(let ((modules-list (copy-sequence eshell-modules-list)))
(make-local-variable 'eshell-modules-list)
(setq eshell-modules-list modules-list))
(setq-local eshell-modules-list modules-list))
;; This is to avoid making the paragraph base direction
;; right-to-left if the first word just happens to start with a
@ -391,7 +386,7 @@ and the hook `eshell-exit-hook'."
(add-hook 'pre-command-hook #'eshell-preinput-scroll-to-bottom t t))
(when eshell-scroll-show-maximum-output
(set (make-local-variable 'scroll-conservatively) 1000))
(setq-local scroll-conservatively 1000))
(when eshell-status-in-mode-line
(add-hook 'eshell-pre-command-hook #'eshell-command-started nil t)

View file

@ -227,12 +227,11 @@ environment of created subprocesses."
;; Break the association with our parent's environment. Otherwise,
;; changing a variable will affect all of Emacs.
(unless eshell-modify-global-environment
(set (make-local-variable 'process-environment)
(eshell-copy-environment)))
(setq-local process-environment (eshell-copy-environment)))
(set (make-local-variable 'eshell-special-chars-inside-quoting)
(setq-local eshell-special-chars-inside-quoting
(append eshell-special-chars-inside-quoting '(?$)))
(set (make-local-variable 'eshell-special-chars-outside-quoting)
(setq-local eshell-special-chars-outside-quoting
(append eshell-special-chars-outside-quoting '(?$)))
(add-hook 'eshell-parse-argument-hook #'eshell-interpolate-variable t t)