Don't quote lambdas in eshell/*.el

* lisp/eshell/em-basic.el (eshell-echo):
* lisp/eshell/em-cmpl.el (eshell-command-completion-function)
(eshell-default-completion-function, eshell-cmpl-initialize)
(eshell-complete-parse-arguments, eshell-complete-commands-list):
* lisp/eshell/em-dirs.el (eshell-complete-user-reference):
* lisp/eshell/em-hist.el (eshell-hist-unload-hook)
(eshell-hist-initialize):
* lisp/eshell/em-ls.el (eshell-ls-sort-entries):
* lisp/eshell/em-pred.el (eshell-modifier-alist)
(eshell-display-predicate-help, eshell-display-modifier-help)
(eshell-pred-substitute, eshell-split-members):
* lisp/eshell/em-prompt.el (eshell-prompt-function):
* lisp/eshell/em-smart.el (eshell-smart-unload-hook)
(eshell-smart-initialize, eshell-refresh-windows):
* lisp/eshell/em-unix.el (eshell-shuffle-files):
* lisp/eshell/esh-arg.el (eshell-parse-argument-hook):
* lisp/eshell/esh-cmd.el (eshell-cmd-initialize)
(eshell-parse-command):
* lisp/eshell/esh-mode.el (eshell-preinput-scroll-to-bottom)
(eshell-postoutput-scroll-to-bottom):
* lisp/eshell/esh-module.el (eshell-modules-list):
* lisp/eshell/esh-proc.el (eshell-read-process-name)
(eshell-round-robin-kill):
* lisp/eshell/esh-var.el (eshell-envvar-names)
(eshell-variables-list): Don't quote lambdas.
This commit is contained in:
Stefan Kangas 2020-11-16 14:43:55 +01:00
parent 81588748bd
commit 238261db95
15 changed files with 212 additions and 246 deletions

View file

@ -90,11 +90,10 @@ or `eshell-printn' for display."
(car args))
(t
(mapcar
(function
(lambda (arg)
(if (stringp arg)
(set-text-properties 0 (length arg) nil arg))
arg))
(lambda (arg)
(if (stringp arg)
(set-text-properties 0 (length arg) nil arg))
arg)
args)))))
(if output-newline
(cond

View file

@ -210,9 +210,8 @@ to writing a completion function."
:group 'eshell-cmpl)
(defcustom eshell-command-completion-function
(function
(lambda ()
(pcomplete-here (eshell-complete-commands-list))))
(lambda ()
(pcomplete-here (eshell-complete-commands-list)))
(eshell-cmpl--custom-variable-docstring 'pcomplete-command-completion-function)
:type (get 'pcomplete-command-completion-function 'custom-type)
:group 'eshell-cmpl)
@ -224,12 +223,11 @@ to writing a completion function."
:group 'eshell-cmpl)
(defcustom eshell-default-completion-function
(function
(lambda ()
(while (pcomplete-here
(pcomplete-dirs-or-entries
(cdr (assoc (funcall eshell-cmpl-command-name-function)
eshell-command-completions-alist)))))))
(lambda ()
(while (pcomplete-here
(pcomplete-dirs-or-entries
(cdr (assoc (funcall eshell-cmpl-command-name-function)
eshell-command-completions-alist))))))
(eshell-cmpl--custom-variable-docstring 'pcomplete-default-completion-function)
:type (get 'pcomplete-default-completion-function 'custom-type)
:group 'eshell-cmpl)
@ -308,10 +306,9 @@ to writing a completion function."
;; 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
(function
(lambda ()
(set (make-local-variable 'comint-file-name-quote-list)
eshell-special-chars-outside-quoting)))
(lambda ()
(set (make-local-variable '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
@ -391,19 +388,18 @@ to writing a completion function."
(nconc args (list ""))
(nconc posns (list (point))))
(cons (mapcar
(function
(lambda (arg)
(let ((val
(if (listp arg)
(let ((result
(eshell-do-eval
(list 'eshell-commands arg) t)))
(cl-assert (eq (car result) 'quote))
(cadr result))
arg)))
(if (numberp val)
(setq val (number-to-string val)))
(or val ""))))
(lambda (arg)
(let ((val
(if (listp arg)
(let ((result
(eshell-do-eval
(list 'eshell-commands arg) t)))
(cl-assert (eq (car result) 'quote))
(cadr result))
arg)))
(if (numberp val)
(setq val (number-to-string val)))
(or val "")))
args)
posns)))
@ -454,9 +450,8 @@ to writing a completion function."
(eshell-alias-completions filename))
(eshell-winnow-list
(mapcar
(function
(lambda (name)
(substring name 7)))
(lambda (name)
(substring name 7))
(all-completions (concat "eshell/" filename)
obarray #'functionp))
nil '(eshell-find-alias-function))

View file

@ -289,9 +289,8 @@ Thus, this does not include the current directory.")
(eshell-read-user-names)
(pcomplete-uniquify-list
(mapcar
(function
(lambda (user)
(file-name-as-directory (cdr user))))
(lambda (user)
(file-name-as-directory (cdr user)))
eshell-user-names)))))))
(defun eshell/pwd (&rest _args)

View file

@ -79,9 +79,8 @@
(defcustom eshell-hist-unload-hook
(list
(function
(lambda ()
(remove-hook 'kill-emacs-hook 'eshell-save-some-history))))
(lambda ()
(remove-hook 'kill-emacs-hook 'eshell-save-some-history)))
"A hook that gets run when `eshell-hist' is unloaded."
:type 'hook)
@ -250,16 +249,14 @@ Returns nil if INPUT is prepended by blank space, otherwise non-nil."
(set (make-local-variable 'search-invisible) t)
(set (make-local-variable 'search-exit-option) t)
(add-hook 'isearch-mode-hook
(function
(lambda ()
(if (>= (point) eshell-last-output-end)
(setq overriding-terminal-local-map
eshell-isearch-map))))
(lambda ()
(if (>= (point) eshell-last-output-end)
(setq overriding-terminal-local-map
eshell-isearch-map)))
nil t)
(add-hook 'isearch-mode-end-hook
(function
(lambda ()
(setq overriding-terminal-local-map nil)))
(lambda ()
(setq overriding-terminal-local-map nil))
nil t))
(eshell-hist-mode))

View file

@ -631,38 +631,37 @@ In Eshell's implementation of ls, ENTRIES is always reversed."
(if (eq sort-method 'unsorted)
(nreverse entries)
(sort entries
(function
(lambda (l r)
(let ((result
(cond
((eq sort-method 'by-atime)
(eshell-ls-compare-entries l r 4 'time-less-p))
((eq sort-method 'by-mtime)
(eshell-ls-compare-entries l r 5 'time-less-p))
((eq sort-method 'by-ctime)
(eshell-ls-compare-entries l r 6 'time-less-p))
((eq sort-method 'by-size)
(eshell-ls-compare-entries l r 7 '<))
((eq sort-method 'by-extension)
(let ((lx (file-name-extension
(directory-file-name (car l))))
(rx (file-name-extension
(directory-file-name (car r)))))
(cond
((or (and (not lx) (not rx))
(equal lx rx))
(string-lessp (directory-file-name (car l))
(directory-file-name (car r))))
((not lx) t)
((not rx) nil)
(t
(string-lessp lx rx)))))
(t
(string-lessp (directory-file-name (car l))
(directory-file-name (car r)))))))
(if reverse-list
(not result)
result)))))))
(lambda (l r)
(let ((result
(cond
((eq sort-method 'by-atime)
(eshell-ls-compare-entries l r 4 'time-less-p))
((eq sort-method 'by-mtime)
(eshell-ls-compare-entries l r 5 'time-less-p))
((eq sort-method 'by-ctime)
(eshell-ls-compare-entries l r 6 'time-less-p))
((eq sort-method 'by-size)
(eshell-ls-compare-entries l r 7 '<))
((eq sort-method 'by-extension)
(let ((lx (file-name-extension
(directory-file-name (car l))))
(rx (file-name-extension
(directory-file-name (car r)))))
(cond
((or (and (not lx) (not rx))
(equal lx rx))
(string-lessp (directory-file-name (car l))
(directory-file-name (car r))))
((not lx) t)
((not rx) nil)
(t
(string-lessp lx rx)))))
(t
(string-lessp (directory-file-name (car l))
(directory-file-name (car r)))))))
(if reverse-list
(not result)
result))))))
(defun eshell-ls-files (files &optional size-width copy-fileinfo)
"Output a list of FILES.
@ -799,9 +798,8 @@ to use, and each member of which is the width of that column
(width 0)
(widths
(mapcar
(function
(lambda (file)
(+ 2 (length (car file)))))
(lambda (file)
(+ 2 (length (car file))))
files))
;; must account for the added space...
(max-width (+ (window-width) 2))
@ -846,9 +844,8 @@ to use, and each member of which is the width of that column
(width 0)
(widths
(mapcar
(function
(lambda (file)
(+ 2 (length (car file)))))
(lambda (file)
(+ 2 (length (car file))))
files))
(max-width (+ (window-width) 2))
col-widths

View file

@ -116,10 +116,9 @@ The format of each entry is
(defcustom eshell-modifier-alist
'((?E . #'(lambda (lst)
(mapcar
(function
(lambda (str)
(eshell-stringify
(car (eshell-parse-argument str)))))
(lambda (str)
(eshell-stringify
(car (eshell-parse-argument str))))
lst)))
(?L . #'(lambda (lst) (mapcar 'downcase lst)))
(?U . #'(lambda (lst) (mapcar 'upcase lst)))
@ -240,16 +239,14 @@ EXAMPLES:
(defun eshell-display-predicate-help ()
(interactive)
(with-electric-help
(function
(lambda ()
(insert eshell-predicate-help-string)))))
(lambda ()
(insert eshell-predicate-help-string))))
(defun eshell-display-modifier-help ()
(interactive)
(with-electric-help
(function
(lambda ()
(insert eshell-modifier-help-string)))))
(lambda ()
(insert eshell-modifier-help-string))))
(define-minor-mode eshell-pred-mode
"Minor mode for the eshell-pred module.
@ -544,20 +541,20 @@ that `ls -l' will show in the first column of its display."
(if repeat
`(lambda (lst)
(mapcar
(function
(lambda (str)
(let ((i 0))
(while (setq i (string-match ,match str i))
(setq str (replace-match ,replace t nil str))))
str)) lst))
(lambda (str)
(let ((i 0))
(while (setq i (string-match ,match str i))
(setq str (replace-match ,replace t nil str))))
str)
lst))
`(lambda (lst)
(mapcar
(function
(lambda (str)
(if (string-match ,match str)
(setq str (replace-match ,replace t nil str))
(error (concat str ": substitution failed")))
str)) lst)))))
(lambda (str)
(if (string-match ,match str)
(setq str (replace-match ,replace t nil str))
(error (concat str ": substitution failed")))
str)
lst)))))
(defun eshell-include-members (&optional invert-p)
"Include only lisp members matching a regexp."
@ -598,9 +595,8 @@ that `ls -l' will show in the first column of its display."
(goto-char (1+ end)))
`(lambda (lst)
(mapcar
(function
(lambda (str)
(split-string str ,sep))) lst))))
(lambda (str)
(split-string str ,sep)) lst))))
(provide 'em-pred)

View file

@ -48,10 +48,9 @@ as is common with most shells."
(autoload 'eshell/pwd "em-dirs")
(defcustom eshell-prompt-function
(function
(lambda ()
(concat (abbreviate-file-name (eshell/pwd))
(if (= (user-uid) 0) " # " " $ "))))
(lambda ()
(concat (abbreviate-file-name (eshell/pwd))
(if (= (user-uid) 0) " # " " $ ")))
"A function that returns the Eshell prompt string.
Make sure to update `eshell-prompt-regexp' so that it will match your
prompt."

View file

@ -94,10 +94,9 @@ it to get a real sense of how it works."
(defcustom eshell-smart-unload-hook
(list
(function
(lambda ()
(remove-hook 'window-configuration-change-hook
'eshell-refresh-windows))))
(lambda ()
(remove-hook 'window-configuration-change-hook
'eshell-refresh-windows)))
"A hook that gets run when `eshell-smart' is unloaded."
:type 'hook
:group 'eshell-smart)
@ -186,9 +185,8 @@ The options are `begin', `after' or `end'."
(make-local-variable 'eshell-smart-command-done)
(add-hook 'eshell-post-command-hook
(function
(lambda ()
(setq eshell-smart-command-done t)))
(lambda ()
(setq eshell-smart-command-done t))
t t)
(unless (eq eshell-review-quick-commands t)
@ -208,13 +206,12 @@ The options are `begin', `after' or `end'."
"Refresh all visible Eshell buffers."
(let (affected)
(walk-windows
(function
(lambda (wind)
(with-current-buffer (window-buffer wind)
(if eshell-mode
(let (window-scroll-functions) ;;FIXME: Why?
(eshell-smart-scroll-window wind (window-start))
(setq affected t))))))
(lambda (wind)
(with-current-buffer (window-buffer wind)
(if eshell-mode
(let (window-scroll-functions) ;;FIXME: Why?
(eshell-smart-scroll-window wind (window-start))
(setq affected t)))))
0 frame)
(if affected
(let (window-scroll-functions) ;;FIXME: Why?

View file

@ -419,9 +419,8 @@ Remove the DIRECTORY(ies), if they are empty.")
(apply 'eshell-shuffle-files
command action
(mapcar
(function
(lambda (file)
(concat source "/" file)))
(lambda (file)
(concat source "/" file))
(directory-files source))
target func t args)
(when (eq func 'rename-file)

View file

@ -85,51 +85,48 @@ If POS is nil, the location of point is checked."
'eshell-parse-special-reference
;; numbers convert to numbers if they stand alone
(function
(lambda ()
(when (and (not eshell-current-argument)
(not eshell-current-quoted)
(looking-at eshell-number-regexp)
(eshell-arg-delimiter (match-end 0)))
(goto-char (match-end 0))
(let ((str (match-string 0)))
(if (> (length str) 0)
(add-text-properties 0 (length str) '(number t) str))
str))))
(lambda ()
(when (and (not eshell-current-argument)
(not eshell-current-quoted)
(looking-at eshell-number-regexp)
(eshell-arg-delimiter (match-end 0)))
(goto-char (match-end 0))
(let ((str (match-string 0)))
(if (> (length str) 0)
(add-text-properties 0 (length str) '(number t) str))
str)))
;; parse any non-special characters, based on the current context
(function
(lambda ()
(unless eshell-inside-quote-regexp
(setq eshell-inside-quote-regexp
(format "[^%s]+"
(apply 'string eshell-special-chars-inside-quoting))))
(unless eshell-outside-quote-regexp
(setq eshell-outside-quote-regexp
(format "[^%s]+"
(apply 'string eshell-special-chars-outside-quoting))))
(when (looking-at (if eshell-current-quoted
eshell-inside-quote-regexp
eshell-outside-quote-regexp))
(goto-char (match-end 0))
(let ((str (match-string 0)))
(if str
(set-text-properties 0 (length str) nil str))
str))))
(lambda ()
(unless eshell-inside-quote-regexp
(setq eshell-inside-quote-regexp
(format "[^%s]+"
(apply 'string eshell-special-chars-inside-quoting))))
(unless eshell-outside-quote-regexp
(setq eshell-outside-quote-regexp
(format "[^%s]+"
(apply 'string eshell-special-chars-outside-quoting))))
(when (looking-at (if eshell-current-quoted
eshell-inside-quote-regexp
eshell-outside-quote-regexp))
(goto-char (match-end 0))
(let ((str (match-string 0)))
(if str
(set-text-properties 0 (length str) nil str))
str)))
;; whitespace or a comment is an argument delimiter
(function
(lambda ()
(let (comment-p)
(when (or (looking-at "[ \t]+")
(and (not eshell-current-argument)
(looking-at "#\\([^<'].*\\|$\\)")
(setq comment-p t)))
(if comment-p
(add-text-properties (match-beginning 0) (match-end 0)
'(comment t)))
(goto-char (match-end 0))
(eshell-finish-arg)))))
(lambda ()
(let (comment-p)
(when (or (looking-at "[ \t]+")
(and (not eshell-current-argument)
(looking-at "#\\([^<'].*\\|$\\)")
(setq comment-p t)))
(if comment-p
(add-text-properties (match-beginning 0) (match-end 0)
'(comment t)))
(goto-char (match-end 0))
(eshell-finish-arg))))
;; parse backslash and the character after
'eshell-parse-backslash

View file

@ -304,10 +304,9 @@ otherwise t.")
;; situation can occur, for example, if a Lisp function results in
;; `debug' being called, and the user then types \\[top-level]
(add-hook 'eshell-post-command-hook
(function
(lambda ()
(setq eshell-current-command nil
eshell-last-async-proc nil)))
(lambda ()
(setq eshell-current-command nil
eshell-last-async-proc nil))
nil t)
(add-hook 'eshell-parse-argument-hook
@ -355,18 +354,17 @@ hooks should be run before and after the command."
args))
(commands
(mapcar
(function
(lambda (cmd)
(setq cmd
(if (or (not (car eshell--sep-terms))
(string= (car eshell--sep-terms) ";"))
(eshell-parse-pipeline cmd)
`(eshell-do-subjob
(list ,(eshell-parse-pipeline cmd)))))
(setq eshell--sep-terms (cdr eshell--sep-terms))
(if eshell-in-pipeline-p
cmd
`(eshell-trap-errors ,cmd))))
(lambda (cmd)
(setq cmd
(if (or (not (car eshell--sep-terms))
(string= (car eshell--sep-terms) ";"))
(eshell-parse-pipeline cmd)
`(eshell-do-subjob
(list ,(eshell-parse-pipeline cmd)))))
(setq eshell--sep-terms (cdr eshell--sep-terms))
(if eshell-in-pipeline-p
cmd
`(eshell-trap-errors ,cmd)))
(eshell-separate-commands terms "[&;]" nil 'eshell--sep-terms))))
(let ((cmd commands))
(while cmd

View file

@ -742,13 +742,12 @@ This function should be a pre-command hook."
(if (eq scroll 'this)
(goto-char (point-max))
(walk-windows
(function
(lambda (window)
(when (and (eq (window-buffer window) current)
(or (eq scroll t) (eq scroll 'all)))
(select-window window)
(goto-char (point-max))
(select-window selected))))
(lambda (window)
(when (and (eq (window-buffer window) current)
(or (eq scroll t) (eq scroll 'all)))
(select-window window)
(goto-char (point-max))
(select-window selected)))
nil t))))))
;;; jww (1999-10-23): this needs testing
@ -764,29 +763,28 @@ This function should be in the list `eshell-output-filter-functions'."
(scroll eshell-scroll-to-bottom-on-output))
(unwind-protect
(walk-windows
(function
(lambda (window)
(if (eq (window-buffer window) current)
(progn
(select-window window)
(if (and (< (point) eshell-last-output-end)
(or (eq scroll t) (eq scroll 'all)
;; Maybe user wants point to jump to end.
(and (eq scroll 'this)
(eq selected window))
(and (eq scroll 'others)
(not (eq selected window)))
;; If point was at the end, keep it at end.
(>= (point) eshell-last-output-start)))
(goto-char eshell-last-output-end))
;; Optionally scroll so that the text
;; ends at the bottom of the window.
(if (and eshell-scroll-show-maximum-output
(>= (point) eshell-last-output-end))
(save-excursion
(goto-char (point-max))
(recenter -1)))
(select-window selected)))))
(lambda (window)
(if (eq (window-buffer window) current)
(progn
(select-window window)
(if (and (< (point) eshell-last-output-end)
(or (eq scroll t) (eq scroll 'all)
;; Maybe user wants point to jump to end.
(and (eq scroll 'this)
(eq selected window))
(and (eq scroll 'others)
(not (eq selected window)))
;; If point was at the end, keep it at end.
(>= (point) eshell-last-output-start)))
(goto-char eshell-last-output-end))
;; Optionally scroll so that the text
;; ends at the bottom of the window.
(if (and eshell-scroll-show-maximum-output
(>= (point) eshell-last-output-end))
(save-excursion
(goto-char (point-max))
(recenter -1)))
(select-window selected))))
nil t)
(set-buffer current))))

View file

@ -65,16 +65,15 @@ Changes will only take effect in future Eshell buffers."
:type (append
(list 'set ':tag "Supported modules")
(mapcar
(function
(lambda (modname)
(let ((modsym (intern modname)))
(list 'const
':tag (format "%s -- %s" modname
(get modsym 'custom-tag))
':link (caar (get modsym 'custom-links))
':doc (concat "\n" (get modsym 'group-documentation)
"\n ")
modsym))))
(lambda (modname)
(let ((modsym (intern modname)))
(list 'const
':tag (format "%s -- %s" modname
(get modsym 'custom-tag))
':link (caar (get modsym 'custom-links))
':doc (concat "\n" (get modsym 'group-documentation)
"\n ")
modsym)))
(sort (mapcar 'symbol-name
(eshell-subgroups 'eshell-module))
'string-lessp))

View file

@ -215,9 +215,8 @@ and signal names."
The prompt will be set to PROMPT."
(completing-read prompt
(mapcar
(function
(lambda (proc)
(cons (process-name proc) t)))
(lambda (proc)
(cons (process-name proc) t))
(process-list))
nil t))
@ -499,9 +498,8 @@ See the variable `eshell-kill-processes-on-exit'."
(let ((sigs eshell-kill-process-signals))
(while sigs
(eshell-process-interact
(function
(lambda (proc)
(signal-process (process-id proc) (car sigs)))) t query)
(lambda (proc)
(signal-process (process-id proc) (car sigs))) t query)
(setq query nil)
(if (not eshell-process-list)
(setq sigs nil)

View file

@ -382,9 +382,8 @@ This function is explicit for adding to `eshell-parse-argument-hook'."
(defun eshell-envvar-names (&optional environment)
"Return a list of currently visible environment variable names."
(mapcar (function
(lambda (x)
(substring x 0 (string-match "=" x))))
(mapcar (lambda (x)
(substring x 0 (string-match "=" x)))
(or environment process-environment)))
(defun eshell-environment-variables ()
@ -618,14 +617,13 @@ For example, to retrieve the second element of a user's record in
(sort
(append
(mapcar
(function
(lambda (varname)
(let ((value (eshell-get-variable varname)))
(if (and value
(stringp value)
(file-directory-p value))
(concat varname "/")
varname))))
(lambda (varname)
(let ((value (eshell-get-variable varname)))
(if (and value
(stringp value)
(file-directory-p value))
(concat varname "/")
varname)))
(eshell-envvar-names (eshell-environment-variables)))
(all-completions argname obarray 'boundp)
completions)