diff options
| author | Grégoire Jadi | 2013-06-12 17:06:09 +0200 |
|---|---|---|
| committer | Grégoire Jadi | 2013-06-12 17:06:09 +0200 |
| commit | 32a590b04a10f6bbe92bc1519b9e5ba2d32cfabc (patch) | |
| tree | 578be4eb2757a0716f252a269adc49fa9406556d /lisp/eshell | |
| parent | 5c77269b59c8d8d88fa91ec2c949294db1bb2131 (diff) | |
| parent | e6fa6da6899bf1b4877b96c450eae3934085d560 (diff) | |
| download | emacs-32a590b04a10f6bbe92bc1519b9e5ba2d32cfabc.tar.gz emacs-32a590b04a10f6bbe92bc1519b9e5ba2d32cfabc.zip | |
Merge branch 'jave-xwidget' into xwidget
Diffstat (limited to 'lisp/eshell')
| -rw-r--r-- | lisp/eshell/em-cmpl.el | 16 | ||||
| -rw-r--r-- | lisp/eshell/em-dirs.el | 3 | ||||
| -rw-r--r-- | lisp/eshell/em-script.el | 7 | ||||
| -rw-r--r-- | lisp/eshell/em-term.el | 76 | ||||
| -rw-r--r-- | lisp/eshell/esh-ext.el | 17 | ||||
| -rw-r--r-- | lisp/eshell/esh-mode.el | 7 |
6 files changed, 97 insertions, 29 deletions
diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el index 426db3232ed..7120f639a70 100644 --- a/lisp/eshell/em-cmpl.el +++ b/lisp/eshell/em-cmpl.el | |||
| @@ -243,6 +243,12 @@ to writing a completion function." | |||
| 243 | 243 | ||
| 244 | ;;; Functions: | 244 | ;;; Functions: |
| 245 | 245 | ||
| 246 | (defun eshell-complete-lisp-symbol () | ||
| 247 | "Try to complete the text around point as a Lisp symbol." | ||
| 248 | (interactive) | ||
| 249 | (let ((completion-at-point-functions '(lisp-completion-at-point))) | ||
| 250 | (completion-at-point))) | ||
| 251 | |||
| 246 | (defun eshell-cmpl-initialize () | 252 | (defun eshell-cmpl-initialize () |
| 247 | "Initialize the completions module." | 253 | "Initialize the completions module." |
| 248 | (set (make-local-variable 'pcomplete-command-completion-function) | 254 | (set (make-local-variable 'pcomplete-command-completion-function) |
| @@ -279,17 +285,17 @@ to writing a completion function." | |||
| 279 | eshell-cmpl-restore-window-delay) | 285 | eshell-cmpl-restore-window-delay) |
| 280 | (set (make-local-variable 'pcomplete-use-paring) | 286 | (set (make-local-variable 'pcomplete-use-paring) |
| 281 | eshell-cmpl-use-paring) | 287 | eshell-cmpl-use-paring) |
| 282 | ;; `pcomplete-arg-quote-list' should only be set after all the | 288 | ;; `comint-file-name-quote-list' should only be set after all the |
| 283 | ;; load-hooks for any other extension modules have been run, which | 289 | ;; load-hooks for any other extension modules have been run, which |
| 284 | ;; is true at the time `eshell-mode-hook' is run | 290 | ;; is true at the time `eshell-mode-hook' is run |
| 285 | (add-hook 'eshell-mode-hook | 291 | (add-hook 'eshell-mode-hook |
| 286 | (function | 292 | (function |
| 287 | (lambda () | 293 | (lambda () |
| 288 | (set (make-local-variable 'pcomplete-arg-quote-list) | 294 | (set (make-local-variable 'comint-file-name-quote-list) |
| 289 | eshell-special-chars-outside-quoting))) nil t) | 295 | eshell-special-chars-outside-quoting))) nil t) |
| 290 | (add-hook 'pcomplete-quote-arg-hook 'eshell-quote-backslash nil t) | 296 | (add-hook 'pcomplete-quote-arg-hook 'eshell-quote-backslash nil t) |
| 291 | (define-key eshell-mode-map [(meta tab)] 'lisp-complete-symbol) | 297 | (define-key eshell-mode-map [(meta tab)] 'eshell-complete-lisp-symbol) |
| 292 | (define-key eshell-mode-map [(meta control ?i)] 'lisp-complete-symbol) | 298 | (define-key eshell-mode-map [(meta control ?i)] 'eshell-complete-lisp-symbol) |
| 293 | (define-key eshell-command-map [(meta ?h)] 'eshell-completion-help) | 299 | (define-key eshell-command-map [(meta ?h)] 'eshell-completion-help) |
| 294 | (define-key eshell-command-map [tab] 'pcomplete-expand-and-complete) | 300 | (define-key eshell-command-map [tab] 'pcomplete-expand-and-complete) |
| 295 | (define-key eshell-command-map [(control ?i)] | 301 | (define-key eshell-command-map [(control ?i)] |
| @@ -347,7 +353,7 @@ to writing a completion function." | |||
| 347 | (setq begin (1+ (cadr delim)) | 353 | (setq begin (1+ (cadr delim)) |
| 348 | args (eshell-parse-arguments begin end))) | 354 | args (eshell-parse-arguments begin end))) |
| 349 | ((eq (car delim) ?\() | 355 | ((eq (car delim) ?\() |
| 350 | (lisp-complete-symbol) | 356 | (eshell-complete-lisp-symbol) |
| 351 | (throw 'pcompleted t)) | 357 | (throw 'pcompleted t)) |
| 352 | (t | 358 | (t |
| 353 | (insert-and-inherit "\t") | 359 | (insert-and-inherit "\t") |
diff --git a/lisp/eshell/em-dirs.el b/lisp/eshell/em-dirs.el index c93bbe9ecb1..e8fbe0518ac 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..b073928738f 100644 --- a/lisp/eshell/em-script.el +++ b/lisp/eshell/em-script.el | |||
| @@ -61,9 +61,10 @@ 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 (cons #'(lambda (file args) |
| 65 | (string= (file-name-nondirectory file) | 65 | (string= (file-name-nondirectory file) |
| 66 | "eshell")) . eshell/source) | 66 | "eshell")) |
| 67 | 'eshell/source) | ||
| 67 | eshell-interpreter-alist)) | 68 | eshell-interpreter-alist)) |
| 68 | (make-local-variable 'eshell-complex-commands) | 69 | (make-local-variable 'eshell-complex-commands) |
| 69 | (setq eshell-complex-commands | 70 | (setq eshell-complex-commands |
diff --git a/lisp/eshell/em-term.el b/lisp/eshell/em-term.el index e5360f2deb4..2932f443e4f 100644 --- a/lisp/eshell/em-term.el +++ b/lisp/eshell/em-term.el | |||
| @@ -31,6 +31,7 @@ | |||
| 31 | 31 | ||
| 32 | ;;; Code: | 32 | ;;; Code: |
| 33 | 33 | ||
| 34 | (require 'cl-lib) | ||
| 34 | (require 'esh-util) | 35 | (require 'esh-util) |
| 35 | (require 'esh-ext) | 36 | (require 'esh-ext) |
| 36 | (eval-when-compile (require 'eshell)) | 37 | (eval-when-compile (require 'eshell)) |
| @@ -61,10 +62,57 @@ which commands are considered visual in nature." | |||
| 61 | "less" "more" ; M-x view-file | 62 | "less" "more" ; M-x view-file |
| 62 | "lynx" "ncftp" ; w3.el, ange-ftp | 63 | "lynx" "ncftp" ; w3.el, ange-ftp |
| 63 | "pine" "tin" "trn" "elm") ; GNUS!! | 64 | "pine" "tin" "trn" "elm") ; GNUS!! |
| 64 | "A list of commands that present their output in a visual fashion." | 65 | "A list of commands that present their output in a visual fashion. |
| 66 | |||
| 67 | Commands listed here are run in a term buffer. | ||
| 68 | |||
| 69 | See also `eshell-visual-subcommands' and `eshell-visual-options'." | ||
| 65 | :type '(repeat string) | 70 | :type '(repeat string) |
| 66 | :group 'eshell-term) | 71 | :group 'eshell-term) |
| 67 | 72 | ||
| 73 | (defcustom eshell-visual-subcommands | ||
| 74 | nil | ||
| 75 | "An alist of subcommands that present their output in a visual fashion. | ||
| 76 | |||
| 77 | An alist of the form | ||
| 78 | |||
| 79 | ((COMMAND1 SUBCOMMAND1 SUBCOMMAND2...) | ||
| 80 | (COMMAND2 SUBCOMMAND1 ...)) | ||
| 81 | |||
| 82 | of commands with subcommands that present their output in a | ||
| 83 | visual fashion. A likely entry is | ||
| 84 | |||
| 85 | (\"git\" \"log\" \"diff\" \"show\") | ||
| 86 | |||
| 87 | because git shows logs and diffs using a pager by default. | ||
| 88 | |||
| 89 | See also `eshell-visual-commands' and `eshell-visual-options'." | ||
| 90 | :type '(repeat (cons (string :tag "Command") | ||
| 91 | (repeat (string :tag "Subcommand")))) | ||
| 92 | :version "24.4" | ||
| 93 | :group 'eshell-term) | ||
| 94 | |||
| 95 | (defcustom eshell-visual-options | ||
| 96 | nil | ||
| 97 | "An alist of the form | ||
| 98 | |||
| 99 | ((COMMAND1 OPTION1 OPTION2...) | ||
| 100 | (COMMAND2 OPTION1 ...)) | ||
| 101 | |||
| 102 | of commands with options that present their output in a visual | ||
| 103 | fashion. For example, a sensible entry would be | ||
| 104 | |||
| 105 | (\"git\" \"--help\") | ||
| 106 | |||
| 107 | because \"git <command> --help\" shows the command's | ||
| 108 | documentation with a pager. | ||
| 109 | |||
| 110 | See also `eshell-visual-commands' and `eshell-visual-subcommands'." | ||
| 111 | :type '(repeat (cons (string :tag "Command") | ||
| 112 | (repeat (string :tag "Option")))) | ||
| 113 | :version "24.4" | ||
| 114 | :group 'eshell-term) | ||
| 115 | |||
| 68 | ;; If you change this from term-term-name, you need to ensure that the | 116 | ;; 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) | 117 | ;; value you choose exists in the system's terminfo database. (Bug#12485) |
| 70 | (defcustom eshell-term-name term-term-name | 118 | (defcustom eshell-term-name term-term-name |
| @@ -77,8 +125,10 @@ used." | |||
| 77 | 125 | ||
| 78 | (defcustom eshell-escape-control-x t | 126 | (defcustom eshell-escape-control-x t |
| 79 | "If non-nil, allow <C-x> to be handled by Emacs key in visual buffers. | 127 | "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 | 128 | See the variables `eshell-visual-commands', |
| 81 | nil, <C-x> will send that control character to the invoked process." | 129 | `eshell-visual-subcommands', and `eshell-visual-options'. If |
| 130 | this variable is set to nil, <C-x> will send that control | ||
| 131 | character to the invoked process." | ||
| 82 | :type 'boolean | 132 | :type 'boolean |
| 83 | :group 'eshell-term) | 133 | :group 'eshell-term) |
| 84 | 134 | ||
| @@ -92,19 +142,29 @@ nil, <C-x> will send that control character to the invoked process." | |||
| 92 | "Initialize the `term' interface code." | 142 | "Initialize the `term' interface code." |
| 93 | (make-local-variable 'eshell-interpreter-alist) | 143 | (make-local-variable 'eshell-interpreter-alist) |
| 94 | (setq eshell-interpreter-alist | 144 | (setq eshell-interpreter-alist |
| 95 | (cons (cons (function | 145 | (cons (cons #'eshell-visual-command-p |
| 96 | (lambda (command) | ||
| 97 | (member (file-name-nondirectory command) | ||
| 98 | eshell-visual-commands))) | ||
| 99 | 'eshell-exec-visual) | 146 | 'eshell-exec-visual) |
| 100 | eshell-interpreter-alist))) | 147 | eshell-interpreter-alist))) |
| 101 | 148 | ||
| 149 | (defun eshell-visual-command-p (command args) | ||
| 150 | "Returns non-nil when given a visual command. | ||
| 151 | If either COMMAND or a subcommand in ARGS (e.g. git log) is a | ||
| 152 | visual command, returns non-nil." | ||
| 153 | (let ((command (file-name-nondirectory command))) | ||
| 154 | (and (eshell-interactive-output-p) | ||
| 155 | (or (member command eshell-visual-commands) | ||
| 156 | (member (car args) | ||
| 157 | (cdr (assoc command eshell-visual-subcommands))) | ||
| 158 | (cl-intersection args | ||
| 159 | (cdr (assoc command eshell-visual-options)) | ||
| 160 | :test 'string=))))) | ||
| 161 | |||
| 102 | (defun eshell-exec-visual (&rest args) | 162 | (defun eshell-exec-visual (&rest args) |
| 103 | "Run the specified PROGRAM in a terminal emulation buffer. | 163 | "Run the specified PROGRAM in a terminal emulation buffer. |
| 104 | ARGS are passed to the program. At the moment, no piping of input is | 164 | ARGS are passed to the program. At the moment, no piping of input is |
| 105 | allowed." | 165 | allowed." |
| 106 | (let* (eshell-interpreter-alist | 166 | (let* (eshell-interpreter-alist |
| 107 | (interp (eshell-find-interpreter (car args))) | 167 | (interp (eshell-find-interpreter (car args) (cdr args))) |
| 108 | (program (car interp)) | 168 | (program (car interp)) |
| 109 | (args (eshell-flatten-list | 169 | (args (eshell-flatten-list |
| 110 | (eshell-stringify-list (append (cdr interp) | 170 | (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 | ||
diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el index ee857cf20f3..5346bd16fd2 100644 --- a/lisp/eshell/esh-mode.el +++ b/lisp/eshell/esh-mode.el | |||
| @@ -326,11 +326,8 @@ and the hook `eshell-exit-hook'." | |||
| 326 | (if mode-line-elt | 326 | (if mode-line-elt |
| 327 | (setcar mode-line-elt 'eshell-command-running-string)))) | 327 | (setcar mode-line-elt 'eshell-command-running-string)))) |
| 328 | 328 | ||
| 329 | (define-key eshell-mode-map [return] 'eshell-send-input) | 329 | (define-key eshell-mode-map "\r" 'eshell-send-input) |
| 330 | (define-key eshell-mode-map [(control ?m)] 'eshell-send-input) | 330 | (define-key eshell-mode-map "\M-\r" 'eshell-queue-input) |
| 331 | (define-key eshell-mode-map [(control ?j)] 'eshell-send-input) | ||
| 332 | (define-key eshell-mode-map [(meta return)] 'eshell-queue-input) | ||
| 333 | (define-key eshell-mode-map [(meta control ?m)] 'eshell-queue-input) | ||
| 334 | (define-key eshell-mode-map [(meta control ?l)] 'eshell-show-output) | 331 | (define-key eshell-mode-map [(meta control ?l)] 'eshell-show-output) |
| 335 | (define-key eshell-mode-map [(control ?a)] 'eshell-bol) | 332 | (define-key eshell-mode-map [(control ?a)] 'eshell-bol) |
| 336 | 333 | ||