diff options
| author | Tassilo Horn | 2013-06-02 11:19:09 +0200 |
|---|---|---|
| committer | Tassilo Horn | 2013-06-02 11:19:09 +0200 |
| commit | d105b0e26f965b41452153ad405efe98ff142de6 (patch) | |
| tree | bf98e74bdf26d4be65559abee240ced7b8633b86 | |
| parent | 8a621d5317e94977bb3e5e5ab2800b810d0297ee (diff) | |
| download | emacs-d105b0e26f965b41452153ad405efe98ff142de6.tar.gz emacs-d105b0e26f965b41452153ad405efe98ff142de6.zip | |
* eshell/esh-ext.el (eshell-external-command): Pass args to
`eshell-find-interpreter'.
(eshell-find-interpreter): Add new second parameter ARGS.
* eshell/em-script.el (eshell-script-initialize): Add second arg
to the function added as MATCH to `eshell-interpreter-alist'
* eshell/em-dirs.el (eshell-dirs-initialize): Add second arg to
the function added as MATCH to `eshell-interpreter-alist'
* eshell/em-term.el (eshell-visual-subcommands): New defcustom.
(eshell-visual-options): New defcustom.
(eshell-escape-control-x): Adapt docstring.
(eshell-term-initialize): Test `eshell-visual-subcommands' and
`eshell-visual-options' in addition to `eshell-visual-commands'.
(eshell-exec-visual): Pass args to `eshell-find-interpreter'.
| -rw-r--r-- | lisp/ChangeLog | 19 | ||||
| -rw-r--r-- | lisp/eshell/em-dirs.el | 3 | ||||
| -rw-r--r-- | lisp/eshell/em-script.el | 2 | ||||
| -rw-r--r-- | lisp/eshell/em-term.el | 52 | ||||
| -rw-r--r-- | lisp/eshell/esh-ext.el | 17 |
5 files changed, 78 insertions, 15 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4a2fb7cc1cf..f05378a2cd4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,22 @@ | |||
| 1 | 2013-06-02 Tassilo Horn <tsdh@gnu.org> | ||
| 2 | |||
| 3 | * eshell/esh-ext.el (eshell-external-command): Pass args to | ||
| 4 | `eshell-find-interpreter'. | ||
| 5 | (eshell-find-interpreter): Add new second parameter ARGS. | ||
| 6 | |||
| 7 | * eshell/em-script.el (eshell-script-initialize): Add second arg | ||
| 8 | to the function added as MATCH to `eshell-interpreter-alist' | ||
| 9 | |||
| 10 | * eshell/em-dirs.el (eshell-dirs-initialize): Add second arg to | ||
| 11 | the function added as MATCH to `eshell-interpreter-alist' | ||
| 12 | |||
| 13 | * eshell/em-term.el (eshell-visual-subcommands): New defcustom. | ||
| 14 | (eshell-visual-options): New defcustom. | ||
| 15 | (eshell-escape-control-x): Adapt docstring. | ||
| 16 | (eshell-term-initialize): Test `eshell-visual-subcommands' and | ||
| 17 | `eshell-visual-options' in addition to `eshell-visual-commands'. | ||
| 18 | (eshell-exec-visual): Pass args to `eshell-find-interpreter'. | ||
| 19 | |||
| 1 | 2013-06-01 Fabián Ezequiel Gallina <fgallina@gnu.org> | 20 | 2013-06-01 Fabián Ezequiel Gallina <fgallina@gnu.org> |
| 2 | 21 | ||
| 3 | * progmodes/python.el (python-indent-block-enders): Add break, | 22 | * progmodes/python.el (python-indent-block-enders): Add break, |
diff --git a/lisp/eshell/em-dirs.el b/lisp/eshell/em-dirs.el index c93bbe9ecb1..106ca152c90 100644 --- a/lisp/eshell/em-dirs.el +++ b/lisp/eshell/em-dirs.el | |||
| @@ -207,7 +207,8 @@ Thus, this does not include the current directory.") | |||
| 207 | (when eshell-cd-on-directory | 207 | (when eshell-cd-on-directory |
| 208 | (make-local-variable 'eshell-interpreter-alist) | 208 | (make-local-variable 'eshell-interpreter-alist) |
| 209 | (setq eshell-interpreter-alist | 209 | (setq eshell-interpreter-alist |
| 210 | (cons (cons 'eshell-lone-directory-p | 210 | (cons (cons (lambda (file args) |
| 211 | (eshell-lone-directory-p file)) | ||
| 211 | 'eshell-dirs-substitute-cd) | 212 | 'eshell-dirs-substitute-cd) |
| 212 | eshell-interpreter-alist))) | 213 | eshell-interpreter-alist))) |
| 213 | 214 | ||
diff --git a/lisp/eshell/em-script.el b/lisp/eshell/em-script.el index 711b2e21468..13ae6941dde 100644 --- a/lisp/eshell/em-script.el +++ b/lisp/eshell/em-script.el | |||
| @@ -61,7 +61,7 @@ This includes when running `eshell-command'." | |||
| 61 | "Initialize the script parsing code." | 61 | "Initialize the script parsing code." |
| 62 | (make-local-variable 'eshell-interpreter-alist) | 62 | (make-local-variable 'eshell-interpreter-alist) |
| 63 | (setq eshell-interpreter-alist | 63 | (setq eshell-interpreter-alist |
| 64 | (cons '((lambda (file) | 64 | (cons '((lambda (file args) |
| 65 | (string= (file-name-nondirectory file) | 65 | (string= (file-name-nondirectory file) |
| 66 | "eshell")) . eshell/source) | 66 | "eshell")) . eshell/source) |
| 67 | eshell-interpreter-alist)) | 67 | eshell-interpreter-alist)) |
diff --git a/lisp/eshell/em-term.el b/lisp/eshell/em-term.el index e5360f2deb4..7875fbc9c80 100644 --- a/lisp/eshell/em-term.el +++ b/lisp/eshell/em-term.el | |||
| @@ -65,6 +65,39 @@ which commands are considered visual in nature." | |||
| 65 | :type '(repeat string) | 65 | :type '(repeat string) |
| 66 | :group 'eshell-term) | 66 | :group 'eshell-term) |
| 67 | 67 | ||
| 68 | (defcustom eshell-visual-subcommands | ||
| 69 | nil | ||
| 70 | "An alist of the form | ||
| 71 | |||
| 72 | ((COMMAND1 SUBCOMMAND1 SUBCOMMAND2...) | ||
| 73 | (COMMAND2 SUBCOMMAND1 ...)) | ||
| 74 | |||
| 75 | of commands with subcommands that present their output in a | ||
| 76 | visual fashion. A likely entry is | ||
| 77 | |||
| 78 | (\"git\" \"log\" \"diff\" \"show\") | ||
| 79 | |||
| 80 | because git shows logs and diffs using a pager by default." | ||
| 81 | :type '(repeat (cons (string :tag "Command") | ||
| 82 | (repeat (string :tag "Subcommand"))))) | ||
| 83 | |||
| 84 | (defcustom eshell-visual-options | ||
| 85 | nil | ||
| 86 | "An alist of the form | ||
| 87 | |||
| 88 | ((COMMAND1 OPTION1 OPTION2...) | ||
| 89 | (COMMAND2 OPTION1 ...)) | ||
| 90 | |||
| 91 | of commands with options that present their output in a visual | ||
| 92 | fashion. For example, a sensible entry would be | ||
| 93 | |||
| 94 | (\"git\" \"--help\") | ||
| 95 | |||
| 96 | because \"git <command> --help\" shows the command's | ||
| 97 | documentation with a pager." | ||
| 98 | :type '(repeat (cons (string :tag "Command") | ||
| 99 | (repeat (string :tag "Option"))))) | ||
| 100 | |||
| 68 | ;; If you change this from term-term-name, you need to ensure that the | 101 | ;; If you change this from term-term-name, you need to ensure that the |
| 69 | ;; value you choose exists in the system's terminfo database. (Bug#12485) | 102 | ;; value you choose exists in the system's terminfo database. (Bug#12485) |
| 70 | (defcustom eshell-term-name term-term-name | 103 | (defcustom eshell-term-name term-term-name |
| @@ -77,8 +110,10 @@ used." | |||
| 77 | 110 | ||
| 78 | (defcustom eshell-escape-control-x t | 111 | (defcustom eshell-escape-control-x t |
| 79 | "If non-nil, allow <C-x> to be handled by Emacs key in visual buffers. | 112 | "If non-nil, allow <C-x> to be handled by Emacs key in visual buffers. |
| 80 | See the variable `eshell-visual-commands'. If this variable is set to | 113 | See the variables `eshell-visual-commands', |
| 81 | nil, <C-x> will send that control character to the invoked process." | 114 | `eshell-visual-subcommands', and `eshell-visual-options'. If |
| 115 | this variable is set to nil, <C-x> will send that control | ||
| 116 | character to the invoked process." | ||
| 82 | :type 'boolean | 117 | :type 'boolean |
| 83 | :group 'eshell-term) | 118 | :group 'eshell-term) |
| 84 | 119 | ||
| @@ -93,9 +128,14 @@ nil, <C-x> will send that control character to the invoked process." | |||
| 93 | (make-local-variable 'eshell-interpreter-alist) | 128 | (make-local-variable 'eshell-interpreter-alist) |
| 94 | (setq eshell-interpreter-alist | 129 | (setq eshell-interpreter-alist |
| 95 | (cons (cons (function | 130 | (cons (cons (function |
| 96 | (lambda (command) | 131 | (lambda (command args) |
| 97 | (member (file-name-nondirectory command) | 132 | (let ((command (file-name-nondirectory command))) |
| 98 | eshell-visual-commands))) | 133 | (or (member command eshell-visual-commands) |
| 134 | (member (car args) | ||
| 135 | (cdr (assoc command eshell-visual-subcommands))) | ||
| 136 | (intersection args | ||
| 137 | (cdr (assoc command eshell-visual-options)) | ||
| 138 | :test 'string=))))) | ||
| 99 | 'eshell-exec-visual) | 139 | 'eshell-exec-visual) |
| 100 | eshell-interpreter-alist))) | 140 | eshell-interpreter-alist))) |
| 101 | 141 | ||
| @@ -104,7 +144,7 @@ nil, <C-x> will send that control character to the invoked process." | |||
| 104 | ARGS are passed to the program. At the moment, no piping of input is | 144 | ARGS are passed to the program. At the moment, no piping of input is |
| 105 | allowed." | 145 | allowed." |
| 106 | (let* (eshell-interpreter-alist | 146 | (let* (eshell-interpreter-alist |
| 107 | (interp (eshell-find-interpreter (car args))) | 147 | (interp (eshell-find-interpreter (car args) (cdr args))) |
| 108 | (program (car interp)) | 148 | (program (car interp)) |
| 109 | (args (eshell-flatten-list | 149 | (args (eshell-flatten-list |
| 110 | (eshell-stringify-list (append (cdr interp) | 150 | (eshell-stringify-list (append (cdr interp) |
diff --git a/lisp/eshell/esh-ext.el b/lisp/eshell/esh-ext.el index c4e4c000bda..474e536de2e 100644 --- a/lisp/eshell/esh-ext.el +++ b/lisp/eshell/esh-ext.el | |||
| @@ -125,9 +125,10 @@ Each member is a cons cell of the form: | |||
| 125 | 125 | ||
| 126 | (MATCH . INTERPRETER) | 126 | (MATCH . INTERPRETER) |
| 127 | 127 | ||
| 128 | MATCH should be a regexp, which is matched against the command name, | 128 | MATCH should be a regexp, which is matched against the command |
| 129 | or a function. If either returns a non-nil value, then INTERPRETER | 129 | name, or a function of arity 2 receiving the COMMAND and its |
| 130 | will be used for that command. | 130 | ARGS (a list). If either returns a non-nil value, then |
| 131 | INTERPRETER will be used for that command. | ||
| 131 | 132 | ||
| 132 | If INTERPRETER is a string, it will be called as the command name, | 133 | If INTERPRETER is a string, it will be called as the command name, |
| 133 | with the original command name passed as the first argument, with all | 134 | with the original command name passed as the first argument, with all |
| @@ -215,6 +216,7 @@ causing the user to wonder if anything's really going on..." | |||
| 215 | (setq args (eshell-stringify-list (eshell-flatten-list args))) | 216 | (setq args (eshell-stringify-list (eshell-flatten-list args))) |
| 216 | (let ((interp (eshell-find-interpreter | 217 | (let ((interp (eshell-find-interpreter |
| 217 | command | 218 | command |
| 219 | args | ||
| 218 | ;; `eshell-find-interpreter' does not work correctly | 220 | ;; `eshell-find-interpreter' does not work correctly |
| 219 | ;; for Tramp file name syntax. But we don't need to | 221 | ;; for Tramp file name syntax. But we don't need to |
| 220 | ;; know the interpreter in that case, therefore the | 222 | ;; know the interpreter in that case, therefore the |
| @@ -267,7 +269,7 @@ Return nil, or a list of the form: | |||
| 267 | (list (match-string 1) | 269 | (list (match-string 1) |
| 268 | file))))))) | 270 | file))))))) |
| 269 | 271 | ||
| 270 | (defun eshell-find-interpreter (file &optional no-examine-p) | 272 | (defun eshell-find-interpreter (file args &optional no-examine-p) |
| 271 | "Find the command interpreter with which to execute FILE. | 273 | "Find the command interpreter with which to execute FILE. |
| 272 | If NO-EXAMINE-P is non-nil, FILE will not be inspected for a script | 274 | If NO-EXAMINE-P is non-nil, FILE will not be inspected for a script |
| 273 | line of the form #!<interp>." | 275 | line of the form #!<interp>." |
| @@ -277,8 +279,9 @@ line of the form #!<interp>." | |||
| 277 | (dolist (possible eshell-interpreter-alist) | 279 | (dolist (possible eshell-interpreter-alist) |
| 278 | (cond | 280 | (cond |
| 279 | ((functionp (car possible)) | 281 | ((functionp (car possible)) |
| 280 | (and (funcall (car possible) file) | 282 | (let ((fn (car possible))) |
| 281 | (throw 'found (cdr possible)))) | 283 | (and (funcall fn file args) |
| 284 | (throw 'found (cdr possible))))) | ||
| 282 | ((stringp (car possible)) | 285 | ((stringp (car possible)) |
| 283 | (and (string-match (car possible) file) | 286 | (and (string-match (car possible) file) |
| 284 | (throw 'found (cdr possible)))) | 287 | (throw 'found (cdr possible)))) |
| @@ -312,7 +315,7 @@ line of the form #!<interp>." | |||
| 312 | (setq interp (eshell-script-interpreter fullname)) | 315 | (setq interp (eshell-script-interpreter fullname)) |
| 313 | (if interp | 316 | (if interp |
| 314 | (setq interp | 317 | (setq interp |
| 315 | (cons (car (eshell-find-interpreter (car interp) t)) | 318 | (cons (car (eshell-find-interpreter (car interp) args t)) |
| 316 | (cdr interp))))) | 319 | (cdr interp))))) |
| 317 | (or interp (list fullname))))))) | 320 | (or interp (list fullname))))))) |
| 318 | 321 | ||