Commit d105b0e2 authored by Tassilo Horn's avatar Tassilo Horn

* 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'.
parent 8a621d53
2013-06-02 Tassilo Horn <tsdh@gnu.org>
* 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'.
2013-06-01 Fabián Ezequiel Gallina <fgallina@gnu.org> 2013-06-01 Fabián Ezequiel Gallina <fgallina@gnu.org>
* progmodes/python.el (python-indent-block-enders): Add break, * progmodes/python.el (python-indent-block-enders): Add break,
......
...@@ -207,7 +207,8 @@ Thus, this does not include the current directory.") ...@@ -207,7 +207,8 @@ Thus, this does not include the current directory.")
(when eshell-cd-on-directory (when eshell-cd-on-directory
(make-local-variable 'eshell-interpreter-alist) (make-local-variable 'eshell-interpreter-alist)
(setq eshell-interpreter-alist (setq eshell-interpreter-alist
(cons (cons 'eshell-lone-directory-p (cons (cons (lambda (file args)
(eshell-lone-directory-p file))
'eshell-dirs-substitute-cd) 'eshell-dirs-substitute-cd)
eshell-interpreter-alist))) eshell-interpreter-alist)))
......
...@@ -61,7 +61,7 @@ This includes when running `eshell-command'." ...@@ -61,7 +61,7 @@ This includes when running `eshell-command'."
"Initialize the script parsing code." "Initialize the script parsing code."
(make-local-variable 'eshell-interpreter-alist) (make-local-variable 'eshell-interpreter-alist)
(setq eshell-interpreter-alist (setq eshell-interpreter-alist
(cons '((lambda (file) (cons '((lambda (file args)
(string= (file-name-nondirectory file) (string= (file-name-nondirectory file)
"eshell")) . eshell/source) "eshell")) . eshell/source)
eshell-interpreter-alist)) eshell-interpreter-alist))
......
...@@ -65,6 +65,39 @@ which commands are considered visual in nature." ...@@ -65,6 +65,39 @@ which commands are considered visual in nature."
:type '(repeat string) :type '(repeat string)
:group 'eshell-term) :group 'eshell-term)
(defcustom eshell-visual-subcommands
nil
"An alist of the form
((COMMAND1 SUBCOMMAND1 SUBCOMMAND2...)
(COMMAND2 SUBCOMMAND1 ...))
of commands with subcommands that present their output in a
visual fashion. A likely entry is
(\"git\" \"log\" \"diff\" \"show\")
because git shows logs and diffs using a pager by default."
:type '(repeat (cons (string :tag "Command")
(repeat (string :tag "Subcommand")))))
(defcustom eshell-visual-options
nil
"An alist of the form
((COMMAND1 OPTION1 OPTION2...)
(COMMAND2 OPTION1 ...))
of commands with options that present their output in a visual
fashion. For example, a sensible entry would be
(\"git\" \"--help\")
because \"git <command> --help\" shows the command's
documentation with a pager."
:type '(repeat (cons (string :tag "Command")
(repeat (string :tag "Option")))))
;; If you change this from term-term-name, you need to ensure that the ;; If you change this from term-term-name, you need to ensure that the
;; value you choose exists in the system's terminfo database. (Bug#12485) ;; value you choose exists in the system's terminfo database. (Bug#12485)
(defcustom eshell-term-name term-term-name (defcustom eshell-term-name term-term-name
...@@ -77,8 +110,10 @@ used." ...@@ -77,8 +110,10 @@ used."
(defcustom eshell-escape-control-x t (defcustom eshell-escape-control-x t
"If non-nil, allow <C-x> to be handled by Emacs key in visual buffers. "If non-nil, allow <C-x> to be handled by Emacs key in visual buffers.
See the variable `eshell-visual-commands'. If this variable is set to See the variables `eshell-visual-commands',
nil, <C-x> will send that control character to the invoked process." `eshell-visual-subcommands', and `eshell-visual-options'. If
this variable is set to nil, <C-x> will send that control
character to the invoked process."
:type 'boolean :type 'boolean
:group 'eshell-term) :group 'eshell-term)
...@@ -93,9 +128,14 @@ nil, <C-x> will send that control character to the invoked process." ...@@ -93,9 +128,14 @@ nil, <C-x> will send that control character to the invoked process."
(make-local-variable 'eshell-interpreter-alist) (make-local-variable 'eshell-interpreter-alist)
(setq eshell-interpreter-alist (setq eshell-interpreter-alist
(cons (cons (function (cons (cons (function
(lambda (command) (lambda (command args)
(member (file-name-nondirectory command) (let ((command (file-name-nondirectory command)))
eshell-visual-commands))) (or (member command eshell-visual-commands)
(member (car args)
(cdr (assoc command eshell-visual-subcommands)))
(intersection args
(cdr (assoc command eshell-visual-options))
:test 'string=)))))
'eshell-exec-visual) 'eshell-exec-visual)
eshell-interpreter-alist))) eshell-interpreter-alist)))
...@@ -104,7 +144,7 @@ nil, <C-x> will send that control character to the invoked process." ...@@ -104,7 +144,7 @@ nil, <C-x> will send that control character to the invoked process."
ARGS are passed to the program. At the moment, no piping of input is ARGS are passed to the program. At the moment, no piping of input is
allowed." allowed."
(let* (eshell-interpreter-alist (let* (eshell-interpreter-alist
(interp (eshell-find-interpreter (car args))) (interp (eshell-find-interpreter (car args) (cdr args)))
(program (car interp)) (program (car interp))
(args (eshell-flatten-list (args (eshell-flatten-list
(eshell-stringify-list (append (cdr interp) (eshell-stringify-list (append (cdr interp)
......
...@@ -125,9 +125,10 @@ Each member is a cons cell of the form: ...@@ -125,9 +125,10 @@ Each member is a cons cell of the form:
(MATCH . INTERPRETER) (MATCH . INTERPRETER)
MATCH should be a regexp, which is matched against the command name, MATCH should be a regexp, which is matched against the command
or a function. If either returns a non-nil value, then INTERPRETER name, or a function of arity 2 receiving the COMMAND and its
will be used for that command. ARGS (a list). If either returns a non-nil value, then
INTERPRETER will be used for that command.
If INTERPRETER is a string, it will be called as the command name, If INTERPRETER is a string, it will be called as the command name,
with the original command name passed as the first argument, with all 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,6 +216,7 @@ causing the user to wonder if anything's really going on..."
(setq args (eshell-stringify-list (eshell-flatten-list args))) (setq args (eshell-stringify-list (eshell-flatten-list args)))
(let ((interp (eshell-find-interpreter (let ((interp (eshell-find-interpreter
command command
args
;; `eshell-find-interpreter' does not work correctly ;; `eshell-find-interpreter' does not work correctly
;; for Tramp file name syntax. But we don't need to ;; for Tramp file name syntax. But we don't need to
;; know the interpreter in that case, therefore the ;; know the interpreter in that case, therefore the
...@@ -267,7 +269,7 @@ Return nil, or a list of the form: ...@@ -267,7 +269,7 @@ Return nil, or a list of the form:
(list (match-string 1) (list (match-string 1)
file))))))) file)))))))
(defun eshell-find-interpreter (file &optional no-examine-p) (defun eshell-find-interpreter (file args &optional no-examine-p)
"Find the command interpreter with which to execute FILE. "Find the command interpreter with which to execute FILE.
If NO-EXAMINE-P is non-nil, FILE will not be inspected for a script If NO-EXAMINE-P is non-nil, FILE will not be inspected for a script
line of the form #!<interp>." line of the form #!<interp>."
...@@ -277,8 +279,9 @@ line of the form #!<interp>." ...@@ -277,8 +279,9 @@ line of the form #!<interp>."
(dolist (possible eshell-interpreter-alist) (dolist (possible eshell-interpreter-alist)
(cond (cond
((functionp (car possible)) ((functionp (car possible))
(and (funcall (car possible) file) (let ((fn (car possible)))
(throw 'found (cdr possible)))) (and (funcall fn file args)
(throw 'found (cdr possible)))))
((stringp (car possible)) ((stringp (car possible))
(and (string-match (car possible) file) (and (string-match (car possible) file)
(throw 'found (cdr possible)))) (throw 'found (cdr possible))))
...@@ -312,7 +315,7 @@ line of the form #!<interp>." ...@@ -312,7 +315,7 @@ line of the form #!<interp>."
(setq interp (eshell-script-interpreter fullname)) (setq interp (eshell-script-interpreter fullname))
(if interp (if interp
(setq interp (setq interp
(cons (car (eshell-find-interpreter (car interp) t)) (cons (car (eshell-find-interpreter (car interp) args t))
(cdr interp))))) (cdr interp)))))
(or interp (list fullname))))))) (or interp (list fullname)))))))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment