diff options
Diffstat (limited to 'lisp/eshell')
-rw-r--r-- | lisp/eshell/em-cmpl.el | 6 | ||||
-rw-r--r-- | lisp/eshell/em-dirs.el | 13 | ||||
-rw-r--r-- | lisp/eshell/em-glob.el | 2 | ||||
-rw-r--r-- | lisp/eshell/em-hist.el | 9 | ||||
-rw-r--r-- | lisp/eshell/em-ls.el | 6 | ||||
-rw-r--r-- | lisp/eshell/em-pred.el | 225 | ||||
-rw-r--r-- | lisp/eshell/em-script.el | 11 | ||||
-rw-r--r-- | lisp/eshell/em-xtra.el | 44 | ||||
-rw-r--r-- | lisp/eshell/esh-mode.el | 2 | ||||
-rw-r--r-- | lisp/eshell/esh-opt.el | 8 | ||||
-rw-r--r-- | lisp/eshell/esh-proc.el | 40 | ||||
-rw-r--r-- | lisp/eshell/esh-util.el | 206 | ||||
-rw-r--r-- | lisp/eshell/esh-var.el | 4 | ||||
-rw-r--r-- | lisp/eshell/eshell.el | 6 |
14 files changed, 263 insertions, 319 deletions
diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el index 638c0ac230a..cbfe0b81545 100644 --- a/lisp/eshell/em-cmpl.el +++ b/lisp/eshell/em-cmpl.el @@ -150,8 +150,8 @@ to writing a completion function." :type (get 'pcomplete-dir-ignore 'custom-type)) (defcustom eshell-cmpl-ignore-case (eshell-under-windows-p) - (eshell-cmpl--custom-variable-docstring 'pcomplete-ignore-case) - :type (get 'pcomplete-ignore-case 'custom-type)) + (eshell-cmpl--custom-variable-docstring 'completion-ignore-case) + :type (get 'completion-ignore-case 'custom-type)) (defcustom eshell-cmpl-autolist nil (eshell-cmpl--custom-variable-docstring 'pcomplete-autolist) @@ -259,7 +259,7 @@ to writing a completion function." eshell-cmpl-file-ignore) (setq-local pcomplete-dir-ignore eshell-cmpl-dir-ignore) - (setq-local pcomplete-ignore-case + (setq-local completion-ignore-case eshell-cmpl-ignore-case) (setq-local pcomplete-autolist eshell-cmpl-autolist) diff --git a/lisp/eshell/em-dirs.el b/lisp/eshell/em-dirs.el index c702ee192a6..ee9057f50e8 100644 --- a/lisp/eshell/em-dirs.el +++ b/lisp/eshell/em-dirs.el @@ -199,10 +199,10 @@ Thus, this does not include the current directory.") (when eshell-cd-on-directory (setq-local eshell-interpreter-alist - (cons (cons #'(lambda (file _args) - (eshell-lone-directory-p file)) - 'eshell-dirs-substitute-cd) - eshell-interpreter-alist))) + (cons (cons (lambda (file _args) + (eshell-lone-directory-p file)) + 'eshell-dirs-substitute-cd) + eshell-interpreter-alist))) (add-hook 'eshell-parse-argument-hook #'eshell-parse-user-reference nil t) @@ -224,7 +224,7 @@ Thus, this does not include the current directory.") (add-hook 'eshell-exit-hook #'eshell-write-last-dir-ring nil t) - (add-hook 'kill-emacs-hook #'eshell-save-some-last-dir)) + (add-hook 'kill-emacs-query-functions #'eshell-save-some-last-dir)) (defun eshell-save-some-last-dir () "Save the list-dir-ring for any open Eshell buffers." @@ -238,7 +238,8 @@ Thus, this does not include the current directory.") (format-message "Save last dir ring for Eshell buffer `%s'? " (buffer-name buf))))) - (eshell-write-last-dir-ring)))))) + (eshell-write-last-dir-ring))))) + t) (defun eshell-lone-directory-p (file) "Test whether FILE is just a directory name, and not a command name." diff --git a/lisp/eshell/em-glob.el b/lisp/eshell/em-glob.el index 316094b17e4..e36f2d0c7fe 100644 --- a/lisp/eshell/em-glob.el +++ b/lisp/eshell/em-glob.el @@ -291,7 +291,7 @@ the form: (let ((index 1)) (setq incl glob) (while (and (eq incl glob) - (setq index (string-match "~" glob index))) + (setq index (string-search "~" glob index))) (if (or (get-text-property index 'escaped glob) (or (= (1+ index) len))) (setq index (1+ index)) diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el index b7b1778ebb1..d82946add00 100644 --- a/lisp/eshell/em-hist.el +++ b/lisp/eshell/em-hist.el @@ -293,7 +293,7 @@ Returns nil if INPUT is prepended by blank space, otherwise non-nil." (add-hook 'eshell-exit-hook #'eshell-write-history nil t) - (add-hook 'kill-emacs-hook #'eshell-save-some-history) + (add-hook 'kill-emacs-query-functions #'eshell-save-some-history) (add-hook 'eshell-input-filter-functions #'eshell-add-to-history nil t)) @@ -310,7 +310,8 @@ Returns nil if INPUT is prepended by blank space, otherwise non-nil." (format-message "Save input history for Eshell buffer `%s'? " (buffer-name buf))))) - (eshell-write-history)))))) + (eshell-write-history))))) + t) (defun eshell/history (&rest args) "List in help buffer the buffer's input history." @@ -379,7 +380,7 @@ input." (if (eq eshell-hist-ignoredups 'erase) ;; Remove any old occurrences of the input, and put ;; the new one at the end. - (progn + (unless (ring-empty-p eshell-history-ring) (ring-remove eshell-history-ring (ring-member eshell-history-ring input)) t) @@ -758,7 +759,7 @@ matched." (setq nth (eshell-hist-word-reference nth))) (unless (numberp mth) (setq mth (eshell-hist-word-reference mth))) - (cons (mapconcat #'identity (eshell-sublist textargs nth mth) " ") + (cons (mapconcat #'identity (seq-subseq textargs nth (1+ mth)) " ") end)))) (defun eshell-hist-parse-modifier (hist reference) diff --git a/lisp/eshell/em-ls.el b/lisp/eshell/em-ls.el index e942ae26928..3d7c43b404b 100644 --- a/lisp/eshell/em-ls.el +++ b/lisp/eshell/em-ls.el @@ -680,12 +680,12 @@ Each member of FILES is either a string or a cons cell of the form (let ((f files) last-f display-files - ignore) + ) ;; ignore (while f (if (cdar f) (setq last-f f f (cdr f)) - (unless ignore + (unless nil ;; ignore (funcall error-func (format "%s: No such file or directory\n" (caar f)))) (if (eq f files) @@ -698,7 +698,7 @@ Each member of FILES is either a string or a cons cell of the form (setcar f (cadr f)) (setcdr f (cddr f)))))) (if (not show-size) - (setq display-files (mapcar 'eshell-ls-annotate files)) + (setq display-files (mapcar #'eshell-ls-annotate files)) (dolist (file files) (let* ((str (eshell-ls-printable-size (file-attribute-size (cdr file)) t)) (len (length str))) diff --git a/lisp/eshell/em-pred.el b/lisp/eshell/em-pred.el index aecc8bb4e0a..def52f42e55 100644 --- a/lisp/eshell/em-pred.el +++ b/lisp/eshell/em-pred.el @@ -63,8 +63,7 @@ ordinary strings." (defcustom eshell-pred-load-hook nil "A list of functions to run when `eshell-pred' is loaded." :version "24.1" ; removed eshell-pred-initialize - :type 'hook - :group 'eshell-pred) + :type 'hook) (defcustom eshell-predicate-alist '((?/ . (eshell-pred-file-type ?d)) ; directories @@ -85,18 +84,18 @@ ordinary strings." (?s . (eshell-pred-file-mode #o4000)) ; setuid (?S . (eshell-pred-file-mode #o2000)) ; setgid (?t . (eshell-pred-file-mode #o1000)) ; sticky bit - (?U . #'(lambda (file) ; owned by effective uid - (if (file-exists-p file) - (= (file-attribute-user-id (file-attributes file)) - (user-uid))))) - ;; (?G . #'(lambda (file) ; owned by effective gid - ;; (if (file-exists-p file) - ;; (= (file-attribute-user-id (file-attributes file)) - ;; (user-uid))))) - (?* . #'(lambda (file) - (and (file-regular-p file) - (not (file-symlink-p file)) - (file-executable-p file)))) + (?U . (lambda (file) ; owned by effective uid + (if (file-exists-p file) + (= (file-attribute-user-id (file-attributes file)) + (user-uid))))) + ;; (?G . (lambda (file) ; owned by effective gid + ;; (if (file-exists-p file) + ;; (= (file-attribute-user-id (file-attributes file)) + ;; (user-uid))))) + (?* . (lambda (file) + (and (file-regular-p file) + (not (file-symlink-p file)) + (file-executable-p file)))) (?l . (eshell-pred-file-links)) (?u . (eshell-pred-user-or-group ?u "user" 2 'eshell-user-id)) (?g . (eshell-pred-user-or-group ?g "group" 3 'eshell-group-id)) @@ -108,31 +107,30 @@ ordinary strings." The format of each entry is (CHAR . PREDICATE-FUNC-SEXP)" - :type '(repeat (cons character sexp)) - :group 'eshell-pred) + :type '(repeat (cons character sexp))) (put 'eshell-predicate-alist 'risky-local-variable t) (defcustom eshell-modifier-alist - '((?E . #'(lambda (lst) - (mapcar - (lambda (str) - (eshell-stringify - (car (eshell-parse-argument str)))) - lst))) - (?L . #'(lambda (lst) (mapcar 'downcase lst))) - (?U . #'(lambda (lst) (mapcar 'upcase lst))) - (?C . #'(lambda (lst) (mapcar 'capitalize lst))) - (?h . #'(lambda (lst) (mapcar 'file-name-directory lst))) + '((?E . (lambda (lst) + (mapcar + (lambda (str) + (eshell-stringify + (car (eshell-parse-argument str)))) + lst))) + (?L . (lambda (lst) (mapcar #'downcase lst))) + (?U . (lambda (lst) (mapcar #'upcase lst))) + (?C . (lambda (lst) (mapcar #'capitalize lst))) + (?h . (lambda (lst) (mapcar #'file-name-directory lst))) (?i . (eshell-include-members)) (?x . (eshell-include-members t)) - (?r . #'(lambda (lst) (mapcar 'file-name-sans-extension lst))) - (?e . #'(lambda (lst) (mapcar 'file-name-extension lst))) - (?t . #'(lambda (lst) (mapcar 'file-name-nondirectory lst))) - (?q . #'(lambda (lst) (mapcar 'eshell-escape-arg lst))) - (?u . #'(lambda (lst) (eshell-uniquify-list lst))) - (?o . #'(lambda (lst) (sort lst 'string-lessp))) - (?O . #'(lambda (lst) (nreverse (sort lst 'string-lessp)))) + (?r . (lambda (lst) (mapcar #'file-name-sans-extension lst))) + (?e . (lambda (lst) (mapcar #'file-name-extension lst))) + (?t . (lambda (lst) (mapcar #'file-name-nondirectory lst))) + (?q . (lambda (lst) (mapcar #'eshell-escape-arg lst))) + (?u . (lambda (lst) (seq-uniq lst))) + (?o . (lambda (lst) (sort lst #'string-lessp))) + (?O . (lambda (lst) (nreverse (sort lst #'string-lessp)))) (?j . (eshell-join-members)) (?S . (eshell-split-members)) (?R . 'reverse) @@ -146,8 +144,7 @@ The format of each entry is The format of each entry is (CHAR ENTRYWISE-P MODIFIER-FUNC-SEXP)" - :type '(repeat (cons character sexp)) - :group 'eshell-pred) + :type '(repeat (cons character sexp))) (put 'eshell-modifier-alist 'risky-local-variable t) @@ -297,9 +294,9 @@ This function is specially for adding onto `eshell-parse-argument-hook'." (append eshell-current-modifiers (list - `(lambda (lst) - (eshell-apply-modifiers - lst (quote ,preds) (quote ,mods))))))))) + (lambda (lst) + (eshell-apply-modifiers + lst preds mods)))))))) (goto-char (1+ end)) (eshell-finish-arg)))))) @@ -324,7 +321,7 @@ resultant list of strings." (if (looking-at "[^|':]") (let ((func (read (current-buffer)))) (if (and func (functionp func)) - (setq preds (eshell-add-pred-func func preds + (setq preds (eshell-add-pred-func (eval func t) preds negate follow)) (error "Invalid function predicate `%s'" (eshell-stringify func)))) @@ -341,8 +338,7 @@ resultant list of strings." (let ((func (read (current-buffer)))) (if (and func (functionp func)) (setq mods - (cons `(lambda (lst) - (mapcar (function ,func) lst)) + (cons (lambda (lst) (mapcar func lst)) mods)) (error "Invalid function modifier `%s'" (eshell-stringify func)))) @@ -353,14 +349,14 @@ resultant list of strings." (if (not mod) (error "Unknown modifier character `%c'" (char-after)) (forward-char) - (setq mods (cons (eval (cdr mod)) mods))))) + (setq mods (cons (eval (cdr mod) t) mods))))) (t (let ((pred (assq char eshell-predicate-alist))) (if (not pred) (error "Unknown predicate character `%c'" char) (forward-char) (setq preds - (eshell-add-pred-func (eval (cdr pred)) preds + (eshell-add-pred-func (eval (cdr pred) t) preds negate follow)))))))) (end-of-buffer (error "Predicate or modifier ended prematurely"))) @@ -369,11 +365,11 @@ resultant list of strings." (defun eshell-add-pred-func (pred funcs negate follow) "Add the predicate function PRED to FUNCS." (if negate - (setq pred `(lambda (file) - (not (funcall ,pred file))))) + (setq pred (lambda (file) + (not (funcall pred file))))) (if follow - (setq pred `(lambda (file) - (funcall ,pred (file-truename file))))) + (setq pred (lambda (file) + (funcall pred (file-truename file))))) (cons pred funcs)) (defun eshell-pred-user-or-group (mod-char mod-type attr-index get-id-func) @@ -399,10 +395,10 @@ resultant list of strings." (unless ugid (error "Unknown %s name specified for modifier `%c'" mod-type mod-char)) - `(lambda (file) - (let ((attrs (file-attributes file))) - (if attrs - (= (nth ,attr-index attrs) ,ugid)))))) + (lambda (file) + (let ((attrs (file-attributes file))) + (if attrs + (= (nth attr-index attrs) ugid)))))) (defun eshell-pred-file-time (mod-char mod-type attr-index) "Return a predicate to test whether a file matches a certain time." @@ -445,13 +441,13 @@ resultant list of strings." (error "Cannot stat file `%s'" file)) (setq when (nth attr-index attrs))) (goto-char (1+ end))) - `(lambda (file) - (let ((attrs (file-attributes file))) - (if attrs - (,(cond ((eq qual ?-) #'time-less-p) + (let ((f (cond ((eq qual ?-) #'time-less-p) ((eq qual ?+) (lambda (a b) (time-less-p b a))) - (#'time-equal-p)) - ,when (nth ,attr-index attrs))))))) + (#'time-equal-p)))) + (lambda (file) + (let ((attrs (file-attributes file))) + (if attrs + (funcall f when (nth attr-index attrs)))))))) (defun eshell-pred-file-type (type) "Return a test which tests that the file is of a certain TYPE. @@ -462,20 +458,20 @@ that `ls -l' will show in the first column of its display." (if (memq type '(?b ?c)) (forward-char) (setq type ?%))) - `(lambda (file) - (let ((attrs (eshell-file-attributes (directory-file-name file)))) - (if attrs - (memq (aref (file-attribute-modes attrs) 0) - ,(if (eq type ?%) - '(?b ?c) - (list 'quote (list type)))))))) + (let ((set (if (eq type ?%) + '(?b ?c) + (list type)))) + (lambda (file) + (let ((attrs (eshell-file-attributes (directory-file-name file)))) + (if attrs + (memq (aref (file-attribute-modes attrs) 0) set)))))) (defsubst eshell-pred-file-mode (mode) "Return a test which tests that MODE pertains to the file." - `(lambda (file) - (let ((modes (file-modes file 'nofollow))) - (if modes - (not (zerop (logand ,mode modes))))))) + (lambda (file) + (let ((modes (file-modes file 'nofollow))) + (if modes + (not (zerop (logand mode modes))))))) (defun eshell-pred-file-links () "Return a predicate to test whether a file has a given number of links." @@ -487,15 +483,15 @@ that `ls -l' will show in the first column of its display." (error "Invalid file link count modifier `l'")) (setq amount (string-to-number (match-string 0))) (goto-char (match-end 0)) - `(lambda (file) - (let ((attrs (eshell-file-attributes file))) - (if attrs - (,(if (eq qual ?-) - '< - (if (eq qual ?+) - '> - '=)) - (file-attribute-link-number attrs) ,amount)))))) + (let ((f (if (eq qual ?-) + #'< + (if (eq qual ?+) + #'> + #'=)))) + (lambda (file) + (let ((attrs (eshell-file-attributes file))) + (if attrs + (funcall f (file-attribute-link-number attrs) amount))))))) (defun eshell-pred-file-size () "Return a predicate to test whether a file is of a given size." @@ -517,15 +513,15 @@ that `ls -l' will show in the first column of its display." (error "Invalid file size modifier `L'")) (setq amount (* (string-to-number (match-string 0)) quantum)) (goto-char (match-end 0)) - `(lambda (file) - (let ((attrs (eshell-file-attributes file))) - (if attrs - (,(if (eq qual ?-) - '< - (if (eq qual ?+) - '> - '=)) - (file-attribute-size attrs) ,amount)))))) + (let ((f (if (eq qual ?-) + #'< + (if (eq qual ?+) + #'> + #'=)))) + (lambda (file) + (let ((attrs (eshell-file-attributes file))) + (if attrs + (funcall f (file-attribute-size attrs) amount))))))) (defun eshell-pred-substitute (&optional repeat) "Return a modifier function that will substitute matches." @@ -539,22 +535,22 @@ that `ls -l' will show in the first column of its display." replace (buffer-substring-no-properties (point) end)) (goto-char (1+ end)) (if repeat - `(lambda (lst) - (mapcar - (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 - (lambda (str) - (if (string-match ,match str) - (setq str (replace-match ,replace t nil str)) - (error (concat str ": substitution failed"))) - str) - lst))))) + (lambda (lst) + (mapcar + (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 + (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." @@ -564,12 +560,12 @@ that `ls -l' will show in the first column of its display." (setq end (eshell-find-delimiter delim delim nil nil t) regexp (buffer-substring-no-properties (point) end)) (goto-char (1+ end)) - `(lambda (lst) - (eshell-winnow-list - lst nil '((lambda (elem) - ,(if invert-p - `(not (string-match ,regexp elem)) - `(string-match ,regexp elem)))))))) + (let ((predicates + (list (if invert-p + (lambda (elem) (not (string-match regexp elem))) + (lambda (elem) (string-match regexp elem)))))) + (lambda (lst) + (eshell-winnow-list lst nil predicates))))) (defun eshell-join-members () "Return a modifier function that join matches." @@ -581,8 +577,8 @@ that `ls -l' will show in the first column of its display." (setq end (eshell-find-delimiter delim delim nil nil t) str (buffer-substring-no-properties (point) end)) (goto-char (1+ end))) - `(lambda (lst) - (mapconcat 'identity lst ,str)))) + (lambda (lst) + (mapconcat #'identity lst str)))) (defun eshell-split-members () "Return a modifier function that splits members." @@ -593,10 +589,11 @@ that `ls -l' will show in the first column of its display." (setq end (eshell-find-delimiter delim delim nil nil t) sep (buffer-substring-no-properties (point) end)) (goto-char (1+ end))) - `(lambda (lst) - (mapcar - (lambda (str) - (split-string str ,sep)) lst)))) + (lambda (lst) + (mapcar + (lambda (str) + (split-string str sep)) + lst)))) (provide 'em-pred) diff --git a/lisp/eshell/em-script.el b/lisp/eshell/em-script.el index aecc48610f7..1f08e891919 100644 --- a/lisp/eshell/em-script.el +++ b/lisp/eshell/em-script.el @@ -59,11 +59,12 @@ This includes when running `eshell-command'." (defun eshell-script-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the script parsing code." (setq-local eshell-interpreter-alist - (cons (cons #'(lambda (file _args) - (string= (file-name-nondirectory file) - "eshell")) - 'eshell/source) - eshell-interpreter-alist)) + (cons (cons (lambda (file _args) + (and (file-regular-p file) + (string= (file-name-nondirectory file) + "eshell"))) + 'eshell/source) + eshell-interpreter-alist)) (setq-local eshell-complex-commands (append '("source" ".") eshell-complex-commands)) ;; these two variables are changed through usage, but we don't want diff --git a/lisp/eshell/em-xtra.el b/lisp/eshell/em-xtra.el index fa3218baf2f..f58e1b85cbd 100644 --- a/lisp/eshell/em-xtra.el +++ b/lisp/eshell/em-xtra.el @@ -23,13 +23,10 @@ ;;; Code: +(require 'cl-lib) (require 'esh-util) (eval-when-compile (require 'eshell)) -;; Strictly speaking, should only be needed at compile time. -;; Require at run-time too to silence compiler. -(require 'pcomplete) -(require 'compile) ;; There are no items in this custom group, but eshell modules (ab)use ;; custom groups. @@ -49,50 +46,45 @@ naturally accessible within Emacs." (defun eshell/expr (&rest args) "Implementation of expr, using the calc package." - (if (not (fboundp 'calc-eval)) - (throw 'eshell-replace-command - (eshell-parse-command "*expr" (flatten-tree args))) - ;; to fool the byte-compiler... - (let ((func 'calc-eval)) - (funcall func (eshell-flatten-and-stringify args))))) + (calc-eval (eshell-flatten-and-stringify args))) (defun eshell/substitute (&rest args) - "Easy front-end to `intersection', for comparing lists of strings." - (apply 'substitute (car args) (cadr args) :test 'equal + "Easy front-end to `cl-substitute', for comparing lists of strings." + (apply #'cl-substitute (car args) (cadr args) :test #'equal (cddr args))) (defun eshell/count (&rest args) - "Easy front-end to `intersection', for comparing lists of strings." - (apply 'count (car args) (cadr args) :test 'equal + "Easy front-end to `cl-count', for comparing lists of strings." + (apply #'cl-count (car args) (cadr args) :test #'equal (cddr args))) (defun eshell/mismatch (&rest args) - "Easy front-end to `intersection', for comparing lists of strings." - (apply 'mismatch (car args) (cadr args) :test 'equal + "Easy front-end to `cl-mismatch', for comparing lists of strings." + (apply #'cl-mismatch (car args) (cadr args) :test #'equal (cddr args))) (defun eshell/union (&rest args) - "Easy front-end to `intersection', for comparing lists of strings." - (apply 'union (car args) (cadr args) :test 'equal + "Easy front-end to `cl-union', for comparing lists of strings." + (apply #'cl-union (car args) (cadr args) :test #'equal (cddr args))) (defun eshell/intersection (&rest args) - "Easy front-end to `intersection', for comparing lists of strings." - (apply 'intersection (car args) (cadr args) :test 'equal + "Easy front-end to `cl-intersection', for comparing lists of strings." + (apply #'cl-intersection (car args) (cadr args) :test #'equal (cddr args))) (defun eshell/set-difference (&rest args) - "Easy front-end to `intersection', for comparing lists of strings." - (apply 'set-difference (car args) (cadr args) :test 'equal + "Easy front-end to `cl-set-difference', for comparing lists of strings." + (apply #'cl-set-difference (car args) (cadr args) :test #'equal (cddr args))) (defun eshell/set-exclusive-or (&rest args) - "Easy front-end to `intersection', for comparing lists of strings." - (apply 'set-exclusive-or (car args) (cadr args) :test 'equal + "Easy front-end to `cl-set-exclusive-or', for comparing lists of strings." + (apply #'cl-set-exclusive-or (car args) (cadr args) :test #'equal (cddr args))) -(defalias 'eshell/ff 'find-name-dired) -(defalias 'eshell/gf 'find-grep-dired) +(defalias 'eshell/ff #'find-name-dired) +(defalias 'eshell/gf #'find-grep-dired) (provide 'em-xtra) diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el index d29b010ea09..f9dbce9770d 100644 --- a/lisp/eshell/esh-mode.el +++ b/lisp/eshell/esh-mode.el @@ -458,7 +458,7 @@ and the hook `eshell-exit-hook'." (let ((inhibit-read-only t) (no-default (eobp)) (find-tag-default-function 'ignore)) - (setq tagname (car (find-tag-interactive "Find tag: " no-default))) + (setq tagname (car (find-tag-interactive "Find tag" no-default))) (with-suppressed-warnings ((obsolete find-tag)) (find-tag tagname next-p regexp-p)))) diff --git a/lisp/eshell/esh-opt.el b/lisp/eshell/esh-opt.el index c1db484be56..7d31845528b 100644 --- a/lisp/eshell/esh-opt.el +++ b/lisp/eshell/esh-opt.el @@ -23,14 +23,6 @@ ;;; Code: - -;; Unused. -;; (defgroup eshell-opt nil -;; "The options processing code handles command argument parsing for -;; Eshell commands implemented in Lisp." -;; :tag "Command options processing" -;; :group 'eshell) - ;;; User Functions: ;; Macro expansion of eshell-eval-using-options refers to eshell-stringify-list diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el index 369382906c8..7a0b26a0658 100644 --- a/lisp/eshell/esh-proc.el +++ b/lisp/eshell/esh-proc.el @@ -37,23 +37,19 @@ finish." (defcustom eshell-proc-load-hook nil "A hook that gets run when `eshell-proc' is loaded." :version "24.1" ; removed eshell-proc-initialize - :type 'hook - :group 'eshell-proc) + :type 'hook) (defcustom eshell-process-wait-seconds 0 "The number of seconds to delay waiting for a synchronous process." - :type 'integer - :group 'eshell-proc) + :type 'integer) (defcustom eshell-process-wait-milliseconds 50 "The number of milliseconds to delay waiting for a synchronous process." - :type 'integer - :group 'eshell-proc) + :type 'integer) (defcustom eshell-done-messages-in-minibuffer t "If non-nil, subjob \"Done\" messages will display in minibuffer." - :type 'boolean - :group 'eshell-proc) + :type 'boolean) (defcustom eshell-delete-exited-processes t "If nil, process entries will stick around until `jobs' is run. @@ -72,14 +68,12 @@ subjob is done is that it will no longer appear in the Note that Eshell will have to be restarted for a change in this variable's value to take effect." - :type 'boolean - :group 'eshell-proc) + :type 'boolean) (defcustom eshell-reset-signals "^\\(interrupt\\|killed\\|quit\\|stopped\\)" "If a termination signal matches this regexp, the terminal will be reset." - :type 'regexp - :group 'eshell-proc) + :type 'regexp) (defcustom eshell-exec-hook nil "Called each time a process is exec'd by `eshell-gather-process-output'. @@ -88,8 +82,7 @@ It is useful for things that must be done each time a process is executed in an eshell mode buffer (e.g., `set-process-query-on-exit-flag'). In contrast, `eshell-mode-hook' is only executed once, when the buffer is created." - :type 'hook - :group 'eshell-proc) + :type 'hook) (defcustom eshell-kill-hook nil "Called when a process run by `eshell-gather-process-output' has ended. @@ -99,8 +92,7 @@ nil, in which case the user attempted to send a signal, but there was no relevant process. This can be used for displaying help information, for example." :version "24.1" ; removed eshell-reset-after-proc - :type 'hook - :group 'eshell-proc) + :type 'hook) ;;; Internal Variables: @@ -126,8 +118,7 @@ information, for example." Runs `eshell-reset-after-proc' and `eshell-kill-hook', passing arguments PROC and STATUS to functions on the latter." ;; Was there till 24.1, but it is not optional. - (if (memq #'eshell-reset-after-proc eshell-kill-hook) - (setq eshell-kill-hook (delq #'eshell-reset-after-proc eshell-kill-hook))) + (remove-hook 'eshell-kill-hook #'eshell-reset-after-proc) (eshell-reset-after-proc status) (run-hook-with-args 'eshell-kill-hook proc status)) @@ -165,7 +156,7 @@ The signals which will cause this to happen are matched by eshell-process-wait-milliseconds)))) (setq procs (cdr procs)))) -(defalias 'eshell/wait 'eshell-wait-for-process) +(defalias 'eshell/wait #'eshell-wait-for-process) (defun eshell/jobs (&rest _args) "List processes, if there are any." @@ -275,7 +266,7 @@ See `eshell-needs-pipe'." ;; neither 'first nor 'last? See bug#1388 discussion. (catch 'found (dolist (exe eshell-needs-pipe) - (if (string-equal exe (if (string-match "/" exe) + (if (string-equal exe (if (string-search "/" exe) command (file-name-nondirectory command))) (throw 'found t)))))) @@ -457,8 +448,7 @@ If QUERY is non-nil, query the user with QUERY before calling FUNC." (defcustom eshell-kill-process-wait-time 5 "Seconds to wait between sending termination signals to a subprocess." - :type 'integer - :group 'eshell-proc) + :type 'integer) (defcustom eshell-kill-process-signals '(SIGINT SIGQUIT SIGKILL) "Signals used to kill processes when an Eshell buffer exits. @@ -466,8 +456,7 @@ Eshell calls each of these signals in order when an Eshell buffer is killed; if the process is still alive afterwards, Eshell waits a number of seconds defined by `eshell-kill-process-wait-time', and tries the next signal in the list." - :type '(repeat symbol) - :group 'eshell-proc) + :type '(repeat symbol)) (defcustom eshell-kill-processes-on-exit nil "If non-nil, kill active processes when exiting an Eshell buffer. @@ -489,8 +478,7 @@ long to delay between signals." :type '(choice (const :tag "Kill all, don't ask" t) (const :tag "Ask before killing" ask) (const :tag "Ask for each process" every) - (const :tag "Don't kill subprocesses" nil)) - :group 'eshell-proc) + (const :tag "Don't kill subprocesses" nil))) (defun eshell-round-robin-kill (&optional query) "Kill current process by trying various signals in sequence. diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el index 8ef1ac9c345..72de6b13e2e 100644 --- a/lisp/eshell/esh-util.el +++ b/lisp/eshell/esh-util.el @@ -23,6 +23,7 @@ ;;; Code: +(require 'seq) (eval-when-compile (require 'cl-lib)) (defgroup eshell-util nil @@ -37,25 +38,21 @@ If nil, t will be represented only in the exit code of the function, and not printed as a string. This causes Lisp functions to behave similarly to external commands, as far as successful result output." - :type 'boolean - :group 'eshell-util) + :type 'boolean) (defcustom eshell-group-file "/etc/group" "If non-nil, the name of the group file on your system." - :type '(choice (const :tag "No group file" nil) file) - :group 'eshell-util) + :type '(choice (const :tag "No group file" nil) file)) (defcustom eshell-passwd-file "/etc/passwd" "If non-nil, the name of the passwd file on your system." - :type '(choice (const :tag "No passwd file" nil) file) - :group 'eshell-util) + :type '(choice (const :tag "No passwd file" nil) file)) (defcustom eshell-hosts-file "/etc/hosts" "The name of the /etc/hosts file. Use `pcomplete-hosts-file' instead; this variable is obsolete and has no effect." - :type '(choice (const :tag "No hosts file" nil) file) - :group 'eshell-util) + :type '(choice (const :tag "No hosts file" nil) file)) ;; Don't make it into an alias, because it doesn't really work with ;; custom and risks creating duplicate entries. Just point users to ;; the other variable, which is less frustrating. @@ -64,25 +61,21 @@ has no effect." (defcustom eshell-handle-errors t "If non-nil, Eshell will handle errors itself. Setting this to nil is offered as an aid to debugging only." - :type 'boolean - :group 'eshell-util) + :type 'boolean) (defcustom eshell-private-file-modes 384 ; umask 177 "The file-modes value to use for creating \"private\" files." - :type 'integer - :group 'eshell-util) + :type 'integer) (defcustom eshell-private-directory-modes 448 ; umask 077 "The file-modes value to use for creating \"private\" directories." - :type 'integer - :group 'eshell-util) + :type 'integer) (defcustom eshell-tar-regexp "\\.t\\(ar\\(\\.\\(gz\\|bz2\\|xz\\|Z\\)\\)?\\|gz\\|a[zZ]\\|z2\\)\\'" "Regular expression used to match tar file names." :version "24.1" ; added xz - :type 'regexp - :group 'eshell-util) + :type 'regexp) (defcustom eshell-convert-numeric-arguments t "If non-nil, converting arguments of numeric form to Lisp numbers. @@ -99,16 +92,14 @@ following in your init file: Any function with the property `eshell-no-numeric-conversions' set to a non-nil value, will be passed strings, not numbers, even when an argument matches `eshell-number-regexp'." - :type 'boolean - :group 'eshell-util) + :type 'boolean) (defcustom eshell-number-regexp "-?\\([0-9]*\\.\\)?[0-9]+\\(e[-0-9.]+\\)?" "Regular expression used to match numeric arguments. If `eshell-convert-numeric-arguments' is non-nil, and an argument matches this regexp, it will be converted to a Lisp number, using the function `string-to-number'." - :type 'regexp - :group 'eshell-util) + :type 'regexp) (defcustom eshell-ange-ls-uids nil "List of user/host/id strings, used to determine remote ownership." @@ -116,8 +107,7 @@ function `string-to-number'." (string :tag "Hostname") (repeat (cons :tag "User/UID List" (string :tag "Username") - (repeat :tag "UIDs" string))))) - :group 'eshell-util) + (repeat :tag "UIDs" string)))))) ;;; Internal Variables: @@ -214,7 +204,7 @@ then quoting is done by a backslash, rather than a doubled delimiter." string (if (eq (aref string (1- len)) ?\n) (setq string (substring string 0 (1- len)))) - (if (string-match "\n" string) + (if (string-search "\n" string) (split-string string "\n") (if (and eshell-convert-numeric-arguments (string-match @@ -223,18 +213,6 @@ then quoting is done by a backslash, rather than a doubled delimiter." (string-to-number string) string)))))) -(defun eshell-sublist (l &optional n m) - "Return from LIST the N to M elements. -If N or M is nil, it means the end of the list." - (let ((a (copy-sequence l))) - (if (and m (consp (nthcdr m a))) - (setcdr (nthcdr m a) nil)) - (if n - (setq a (nthcdr n a)) - (setq n (1- (length a)) - a (last a))) - a)) - (defvar-local eshell-path-env (getenv "PATH") "Content of $PATH. It might be different from \(getenv \"PATH\"), when @@ -303,20 +281,6 @@ Prepend remote identification of `default-directory', if any." (define-obsolete-function-alias 'eshell-flatten-list #'flatten-tree "27.1") -(defun eshell-uniquify-list (l) - "Remove occurring multiples in L. You probably want to sort first." - (let ((m l)) - (while m - (while (and (cdr m) - (string= (car m) - (cadr m))) - (setcdr m (cddr m))) - (setq m (cdr m)))) - l) -(define-obsolete-function-alias - 'eshell-uniqify-list - 'eshell-uniquify-list "27.1") - (defun eshell-stringify (object) "Convert OBJECT into a string value." (cond @@ -334,11 +298,11 @@ Prepend remote identification of `default-directory', if any." (defsubst eshell-stringify-list (args) "Convert each element of ARGS into a string value." - (mapcar 'eshell-stringify args)) + (mapcar #'eshell-stringify args)) (defsubst eshell-flatten-and-stringify (&rest args) "Flatten and stringify all of the ARGS into a single string." - (mapconcat 'eshell-stringify (flatten-tree args) " ")) + (mapconcat #'eshell-stringify (flatten-tree args) " ")) (defsubst eshell-directory-files (regexp &optional directory) "Return a list of files in the given DIRECTORY matching REGEXP." @@ -497,7 +461,7 @@ list." (defsubst eshell-copy-environment () "Return an unrelated copy of `process-environment'." - (mapcar 'concat process-environment)) + (mapcar #'concat process-environment)) (defun eshell-subgroups (groupsym) "Return all of the subgroups of GROUPSYM." @@ -645,74 +609,82 @@ gid format. Valid values are `string' and `integer', defaulting to "If the `processp' function does not exist, PROC is not a process." (and (fboundp 'processp) (processp proc))) -; (defun eshell-copy-file -; (file newname &optional ok-if-already-exists keep-date) -; "Copy FILE to NEWNAME. See docs for `copy-file'." -; (let (copied) -; (if (string-match "\\`\\([^:]+\\):\\(.*\\)" file) -; (let ((front (match-string 1 file)) -; (back (match-string 2 file)) -; buffer) -; (if (and front (string-match eshell-tar-regexp front) -; (setq buffer (find-file-noselect front))) -; (with-current-buffer buffer -; (goto-char (point-min)) -; (if (re-search-forward (concat " " (regexp-quote back) -; "$") nil t) -; (progn -; (tar-copy (if (file-directory-p newname) -; (expand-file-name -; (file-name-nondirectory back) newname) -; newname)) -; (setq copied t)) -; (error "%s not found in tar file %s" back front)))))) -; (unless copied -; (copy-file file newname ok-if-already-exists keep-date)))) - -; (defun eshell-file-attributes (filename) -; "Return a list of attributes of file FILENAME. -; See the documentation for `file-attributes'." -; (let (result) -; (when (string-match "\\`\\([^:]+\\):\\(.*\\)\\'" filename) -; (let ((front (match-string 1 filename)) -; (back (match-string 2 filename)) -; buffer) -; (when (and front (string-match eshell-tar-regexp front) -; (setq buffer (find-file-noselect front))) -; (with-current-buffer buffer -; (goto-char (point-min)) -; (when (re-search-forward (concat " " (regexp-quote back) -; "\\s-*$") nil t) -; (let* ((descrip (tar-current-descriptor)) -; (tokens (tar-desc-tokens descrip))) -; (setq result -; (list -; (cond -; ((eq (tar-header-link-type tokens) 5) -; t) -; ((eq (tar-header-link-type tokens) t) -; (tar-header-link-name tokens))) -; 1 -; (tar-header-uid tokens) -; (tar-header-gid tokens) -; (tar-header-date tokens) -; (tar-header-date tokens) -; (tar-header-date tokens) -; (tar-header-size tokens) -; (concat -; (cond -; ((eq (tar-header-link-type tokens) 5) "d") -; ((eq (tar-header-link-type tokens) t) "l") -; (t "-")) -; (tar-grind-file-mode (tar-header-mode tokens) -; (make-string 9 ? ) 0)) -; nil nil nil)))))))) -; (or result -; (file-attributes filename)))) - +;; (defun eshell-copy-file +;; (file newname &optional ok-if-already-exists keep-date) +;; "Copy FILE to NEWNAME. See docs for `copy-file'." +;; (let (copied) +;; (if (string-match "\\`\\([^:]+\\):\\(.*\\)" file) +;; (let ((front (match-string 1 file)) +;; (back (match-string 2 file)) +;; buffer) +;; (if (and front (string-match eshell-tar-regexp front) +;; (setq buffer (find-file-noselect front))) +;; (with-current-buffer buffer +;; (goto-char (point-min)) +;; (if (re-search-forward (concat " " (regexp-quote back) +;; "$") nil t) +;; (progn +;; (tar-copy (if (file-directory-p newname) +;; (expand-file-name +;; (file-name-nondirectory back) newname) +;; newname)) +;; (setq copied t)) +;; (error "%s not found in tar file %s" back front)))))) +;; (unless copied +;; (copy-file file newname ok-if-already-exists keep-date)))) + +;; (defun eshell-file-attributes (filename) +;; "Return a list of attributes of file FILENAME. +;; See the documentation for `file-attributes'." +;; (let (result) +;; (when (string-match "\\`\\([^:]+\\):\\(.*\\)\\'" filename) +;; (let ((front (match-string 1 filename)) +;; (back (match-string 2 filename)) +;; buffer) +;; (when (and front (string-match eshell-tar-regexp front) +;; (setq buffer (find-file-noselect front))) +;; (with-current-buffer buffer +;; (goto-char (point-min)) +;; (when (re-search-forward (concat " " (regexp-quote back) +;; "\\s-*$") nil t) +;; (let* ((descrip (tar-current-descriptor)) +;; (tokens (tar-desc-tokens descrip))) +;; (setq result +;; (list +;; (cond +;; ((eq (tar-header-link-type tokens) 5) +;; t) +;; ((eq (tar-header-link-type tokens) t) +;; (tar-header-link-name tokens))) +;; 1 +;; (tar-header-uid tokens) +;; (tar-header-gid tokens) +;; (tar-header-date tokens) +;; (tar-header-date tokens) +;; (tar-header-date tokens) +;; (tar-header-size tokens) +;; (file-modes-number-to-symbolic +;; (logior (tar-header-mode tokens) +;; (cond +;; ((eq (tar-header-link-type tokens) 5) 16384) +;; ((eq (tar-header-link-type tokens) t) 32768)))) +;; nil nil nil)))))))) +;; (or result +;; (file-attributes filename)))) + +;; Obsolete. + +(define-obsolete-function-alias 'eshell-uniquify-list #'seq-uniq "28.1") +(define-obsolete-function-alias 'eshell-uniqify-list #'seq-uniq "28.1") (define-obsolete-function-alias 'eshell-copy-tree #'copy-tree "28.1") (define-obsolete-function-alias 'eshell-user-name #'user-login-name "28.1") +(defun eshell-sublist (l &optional n m) + "Return from LIST the N to M elements. +If N or M is nil, it means the end of the list." + (declare (obsolete seq-subseq "28.1")) + (seq-subseq l n (1+ m))) + (provide 'esh-util) ;;; esh-util.el ends here diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el index a09c47ce7c2..5dc6a193050 100644 --- a/lisp/eshell/esh-var.el +++ b/lisp/eshell/esh-var.el @@ -355,7 +355,7 @@ This function is explicit for adding to `eshell-parse-argument-hook'." (defun pcomplete/eshell-mode/setq () "Completion function for Eshell's `setq'." (while (and (pcomplete-here (all-completions pcomplete-stub - obarray 'boundp)) + obarray #'boundp)) (pcomplete-here)))) ;; FIXME the real "env" command does more than this, it runs a program @@ -381,7 +381,7 @@ 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 (lambda (x) - (substring x 0 (string-match "=" x))) + (substring x 0 (string-search "=" x))) (or environment process-environment))) (defun eshell-environment-variables () diff --git a/lisp/eshell/eshell.el b/lisp/eshell/eshell.el index 3aaf2fb78aa..101ac860346 100644 --- a/lisp/eshell/eshell.el +++ b/lisp/eshell/eshell.el @@ -294,9 +294,9 @@ With prefix ARG, insert output into the current buffer at point." (setq arg current-prefix-arg)) (let ((eshell-non-interactive-p t)) ;; Enable `eshell-mode' only in this minibuffer. - (minibuffer-with-setup-hook #'(lambda () - (eshell-mode) - (eshell-command-mode +1)) + (minibuffer-with-setup-hook (lambda () + (eshell-mode) + (eshell-command-mode +1)) (unless command (setq command (read-from-minibuffer "Emacs shell command: ")) (if (eshell-using-module 'eshell-hist) |