diff options
Diffstat (limited to 'lisp/eshell')
-rw-r--r-- | lisp/eshell/em-script.el | 5 | ||||
-rw-r--r-- | lisp/eshell/em-xtra.el | 44 | ||||
-rw-r--r-- | lisp/eshell/esh-proc.el | 38 | ||||
-rw-r--r-- | lisp/eshell/esh-util.el | 166 |
4 files changed, 111 insertions, 142 deletions
diff --git a/lisp/eshell/em-script.el b/lisp/eshell/em-script.el index 658ea085c95..1f08e891919 100644 --- a/lisp/eshell/em-script.el +++ b/lisp/eshell/em-script.el @@ -60,8 +60,9 @@ This includes when running `eshell-command'." "Initialize the script parsing code." (setq-local eshell-interpreter-alist (cons (cons (lambda (file _args) - (string= (file-name-nondirectory file) - "eshell")) + (and (file-regular-p file) + (string= (file-name-nondirectory file) + "eshell"))) 'eshell/source) eshell-interpreter-alist)) (setq-local eshell-complex-commands 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-proc.el b/lisp/eshell/esh-proc.el index 369382906c8..96c9a60deab 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." @@ -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 a48f62654d5..30104816f07 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: @@ -308,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." @@ -471,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." @@ -619,70 +609,68 @@ 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. |