diff options
| author | Samer Masterson | 2015-05-15 19:42:00 -0700 |
|---|---|---|
| committer | Samer Masterson | 2015-05-17 14:28:51 -0700 |
| commit | e37da5a4a8055826f0fc1051083495a828509672 (patch) | |
| tree | 0b03dfaf99da7a0e37e079bfa7cd217a4dcde845 | |
| parent | b510a83ef677c3876cfd71d6bebf0e2ecaf2f976 (diff) | |
| download | emacs-e37da5a4a8055826f0fc1051083495a828509672.tar.gz emacs-e37da5a4a8055826f0fc1051083495a828509672.zip | |
eshell: Introduce new buffer syntax
The new buffer syntax '#<buffer-name>' is equivalent to '#<buffer
buffer-name>'. Remove `eshell-buffer-shorthand', as it is no longer
needed (Bug#19319).
* lisp/eshell/esh-io.el (eshell-buffer-shorthand): Remove.
(eshell-get-target): Remove shorthand-specific code.
* lisp/eshell/esh-arg.el (eshell-parse-special-reference): Parse
'#<buffer-name>'.
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/eshell/esh-arg.el | 41 | ||||
| -rw-r--r-- | lisp/eshell/esh-io.el | 48 |
3 files changed, 51 insertions, 44 deletions
| @@ -675,6 +675,12 @@ command line's password prompt. | |||
| 675 | *** The new built-in command `clear' can scroll window contents out of sight. | 675 | *** The new built-in command `clear' can scroll window contents out of sight. |
| 676 | If provided with an optional non-nil argument, the scrollback contents will be cleared. | 676 | If provided with an optional non-nil argument, the scrollback contents will be cleared. |
| 677 | 677 | ||
| 678 | *** New buffer syntax '#<buffer-name>', which is equivalent to | ||
| 679 | '#<buffer buffer-name>'. This shorthand makes interacting with | ||
| 680 | buffers from eshell more convenient. Custom variable | ||
| 681 | `eshell-buffer-shorthand', which has been broken for a while, has been | ||
| 682 | removed. | ||
| 683 | |||
| 678 | ** Browse-url | 684 | ** Browse-url |
| 679 | 685 | ||
| 680 | *** Support for the Conkeror web browser. | 686 | *** Support for the Conkeror web browser. |
diff --git a/lisp/eshell/esh-arg.el b/lisp/eshell/esh-arg.el index a5f697f037a..49ba72735da 100644 --- a/lisp/eshell/esh-arg.el +++ b/lisp/eshell/esh-arg.el | |||
| @@ -357,22 +357,31 @@ after are both returned." | |||
| 357 | (goto-char (1+ end))))))) | 357 | (goto-char (1+ end))))))) |
| 358 | 358 | ||
| 359 | (defun eshell-parse-special-reference () | 359 | (defun eshell-parse-special-reference () |
| 360 | "Parse a special syntax reference, of the form '#<type arg>'." | 360 | "Parse a special syntax reference, of the form '#<args>'. |
| 361 | (if (and (not eshell-current-argument) | 361 | |
| 362 | (not eshell-current-quoted) | 362 | args := `type' `whitespace' `arbitrary-args' | `arbitrary-args' |
| 363 | (looking-at "#<\\(buffer\\|process\\)\\s-")) | 363 | type := \"buffer\" or \"process\" |
| 364 | (let ((here (point))) | 364 | arbitrary-args := any string of characters. |
| 365 | (goto-char (match-end 0)) | 365 | |
| 366 | (let* ((buffer-p (string= (match-string 1) "buffer")) | 366 | If the form has no 'type', the syntax is parsed as if 'type' were |
| 367 | (end (eshell-find-delimiter ?\< ?\>))) | 367 | \"buffer\"." |
| 368 | (if (not end) | 368 | (when (and (not eshell-current-argument) |
| 369 | (throw 'eshell-incomplete ?\<) | 369 | (not eshell-current-quoted) |
| 370 | (if (eshell-arg-delimiter (1+ end)) | 370 | (looking-at "#<\\(\\(buffer\\|process\\)\\s-\\)?")) |
| 371 | (prog1 | 371 | (let ((here (point))) |
| 372 | (list (if buffer-p 'get-buffer-create 'get-process) | 372 | (goto-char (match-end 0)) ;; Go to the end of the match. |
| 373 | (buffer-substring-no-properties (point) end)) | 373 | (let ((buffer-p (if (match-string 1) |
| 374 | (goto-char (1+ end))) | 374 | (string= (match-string 2) "buffer") |
| 375 | (ignore (goto-char here)))))))) | 375 | t)) ;; buffer-p is non-nil by default. |
| 376 | (end (eshell-find-delimiter ?\< ?\>))) | ||
| 377 | (when (not end) | ||
| 378 | (throw 'eshell-incomplete ?\<)) | ||
| 379 | (if (eshell-arg-delimiter (1+ end)) | ||
| 380 | (prog1 | ||
| 381 | (list (if buffer-p 'get-buffer-create 'get-process) | ||
| 382 | (buffer-substring-no-properties (point) end)) | ||
| 383 | (goto-char (1+ end))) | ||
| 384 | (ignore (goto-char here))))))) | ||
| 376 | 385 | ||
| 377 | (defun eshell-parse-delimiter () | 386 | (defun eshell-parse-delimiter () |
| 378 | "Parse an argument delimiter, which is essentially a command operator." | 387 | "Parse an argument delimiter, which is essentially a command operator." |
diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el index 7dfc39f3202..dc731bc928a 100644 --- a/lisp/eshell/esh-io.el +++ b/lisp/eshell/esh-io.el | |||
| @@ -31,6 +31,18 @@ | |||
| 31 | ;; consistent with most shells. Therefore, only unique features are | 31 | ;; consistent with most shells. Therefore, only unique features are |
| 32 | ;; mentioned here. | 32 | ;; mentioned here. |
| 33 | ;; | 33 | ;; |
| 34 | ;;;_* Redirect to a Buffer or Process | ||
| 35 | ;; | ||
| 36 | ;; Buffers and processes can be named with '#<buffer buffer-name>' and | ||
| 37 | ;; '#<process process-name>', respectively. As a shorthand, | ||
| 38 | ;; '#<buffer-name>' without the explicit "buffer" arg is equivalent to | ||
| 39 | ;; '#<buffer buffer-name>'. | ||
| 40 | ;; | ||
| 41 | ;; echo hello > #<buffer *scratch*> # Overwrite '*scratch*' with 'hello'. | ||
| 42 | ;; echo hello > #<*scratch*> # Same as the command above. | ||
| 43 | ;; | ||
| 44 | ;; echo hello > #<process shell> # Pipe "hello" into the shell process. | ||
| 45 | ;; | ||
| 34 | ;;;_* Insertion | 46 | ;;;_* Insertion |
| 35 | ;; | 47 | ;; |
| 36 | ;; To insert at the location of point in a buffer, use '>>>': | 48 | ;; To insert at the location of point in a buffer, use '>>>': |
| @@ -98,19 +110,6 @@ other buffers) ." | |||
| 98 | :type 'integer | 110 | :type 'integer |
| 99 | :group 'eshell-io) | 111 | :group 'eshell-io) |
| 100 | 112 | ||
| 101 | (defcustom eshell-buffer-shorthand nil | ||
| 102 | "If non-nil, a symbol name can be used for a buffer in redirection. | ||
| 103 | If nil, redirecting to a buffer requires buffer name syntax. If this | ||
| 104 | variable is set, redirection directly to Lisp symbols will be | ||
| 105 | impossible. | ||
| 106 | |||
| 107 | Example: | ||
| 108 | |||
| 109 | echo hello > '*scratch* ; works if `eshell-buffer-shorthand' is t | ||
| 110 | echo hello > #<buffer *scratch*> ; always works" | ||
| 111 | :type 'boolean | ||
| 112 | :group 'eshell-io) | ||
| 113 | |||
| 114 | (defcustom eshell-print-queue-size 5 | 113 | (defcustom eshell-print-queue-size 5 |
| 115 | "The size of the print queue, for doing buffered printing. | 114 | "The size of the print queue, for doing buffered printing. |
| 116 | This is basically a speed enhancement, to avoid blocking the Lisp code | 115 | This is basically a speed enhancement, to avoid blocking the Lisp code |
| @@ -355,21 +354,14 @@ it defaults to `insert'." | |||
| 355 | (goto-char (point-max)))) | 354 | (goto-char (point-max)))) |
| 356 | (point-marker)))))) | 355 | (point-marker)))))) |
| 357 | 356 | ||
| 358 | ((or (bufferp target) | 357 | |
| 359 | (and (boundp 'eshell-buffer-shorthand) | 358 | ((bufferp target) |
| 360 | (symbol-value 'eshell-buffer-shorthand) | 359 | (with-current-buffer target |
| 361 | (symbolp target) | 360 | (cond ((eq mode 'overwrite) |
| 362 | (not (memq target '(t nil))))) | 361 | (erase-buffer)) |
| 363 | (let ((buf (if (bufferp target) | 362 | ((eq mode 'append) |
| 364 | target | 363 | (goto-char (point-max)))) |
| 365 | (get-buffer-create | 364 | (point-marker))) |
| 366 | (symbol-name target))))) | ||
| 367 | (with-current-buffer buf | ||
| 368 | (cond ((eq mode 'overwrite) | ||
| 369 | (erase-buffer)) | ||
| 370 | ((eq mode 'append) | ||
| 371 | (goto-char (point-max)))) | ||
| 372 | (point-marker)))) | ||
| 373 | 365 | ||
| 374 | ((functionp target) nil) | 366 | ((functionp target) nil) |
| 375 | 367 | ||