diff options
| author | Eli Zaretskii | 2020-04-18 12:01:26 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2020-04-18 12:01:26 +0300 |
| commit | 175c61c18bfaa1d75aa087ba4bd4de3ebfe1a1d6 (patch) | |
| tree | dfbb644b07477429f7958c7a8c01998aa6e68cf6 /lisp | |
| parent | 6b297519b580df27d8721943f55629689b4c83e0 (diff) | |
| download | emacs-175c61c18bfaa1d75aa087ba4bd4de3ebfe1a1d6.tar.gz emacs-175c61c18bfaa1d75aa087ba4bd4de3ebfe1a1d6.zip | |
Fix "C-u M-!" when 'shell-command-dont-erase-buffer' is non-nil
* lisp/simple.el (shell-command-dont-erase-buffer): Clarify the
effect of the various values in the doc string.
(shell-command-save-pos-or-erase, shell-command): Don't move or
push point if the output will go to the current buffer.
(Bug#40690)
(shell-command): Mention 'shell-command-dont-erase-buffer' in the
doc string.
* test/lisp/simple-tests.el
(with-shell-command-dont-erase-buffer): Don't is shell quoting
'like this', as it doesn't work on MS-Windows; quote "like this"
instead.
(simple-tests-shell-command-dont-erase-buffer): Adapt the test to
the new modus operandi.
* doc/emacs/misc.texi (Single Shell): Document the effect of the
various values of 'shell-command-dont-erase-buffer'.
* etc/NEWS: Expand and reword the entry regarding changes in
'shell-command-dont-erase-buffer'.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/simple.el | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index ea16d1400cc..e3169e523b9 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -3437,20 +3437,22 @@ This affects `shell-command' and `async-shell-command'." | |||
| 3437 | :version "27.1") | 3437 | :version "27.1") |
| 3438 | 3438 | ||
| 3439 | (defcustom shell-command-dont-erase-buffer nil | 3439 | (defcustom shell-command-dont-erase-buffer nil |
| 3440 | "Control if the output buffer is erased before the command. | 3440 | "Whether to erase the output buffer before executing shell command. |
| 3441 | 3441 | ||
| 3442 | A nil value erases the output buffer before execution of the | 3442 | A nil value erases the output buffer before execution of the |
| 3443 | shell command, except when the output buffer is the current one. | 3443 | shell command, except when the output buffer is the current one. |
| 3444 | 3444 | ||
| 3445 | The value `erase' ensures the output buffer is erased before | 3445 | The value `erase' ensures the output buffer is erased before |
| 3446 | execution of the shell command. | 3446 | execution of the shell command even if it is the current buffer. |
| 3447 | 3447 | ||
| 3448 | Other non-nil values prevent the output buffer from being erased and | 3448 | Other non-nil values prevent the output buffer from being erased; they |
| 3449 | set the point after execution of the shell command. | 3449 | also reposition point in the shell output buffer after execution of the |
| 3450 | shell command, except when the output buffer is the current buffer. | ||
| 3450 | 3451 | ||
| 3451 | The value `beg-last-out' sets point at the beginning of the output, | 3452 | The value `beg-last-out' sets point at the beginning of the last |
| 3452 | `end-last-out' sets point at the end of the buffer, `save-point' | 3453 | output, `end-last-out' sets point at the end of the last output, |
| 3453 | restores the buffer position before the command." | 3454 | and `save-point' restores the buffer position as it was before the |
| 3455 | shell command." | ||
| 3454 | :type '(choice | 3456 | :type '(choice |
| 3455 | (const :tag "Erase output buffer if not the current one" nil) | 3457 | (const :tag "Erase output buffer if not the current one" nil) |
| 3456 | (const :tag "Always erase output buffer" erase) | 3458 | (const :tag "Always erase output buffer" erase) |
| @@ -3480,9 +3482,12 @@ See `shell-command-dont-erase-buffer'." | |||
| 3480 | ;; if some text has a non-nil read-only property, | 3482 | ;; if some text has a non-nil read-only property, |
| 3481 | ;; which comint sometimes adds for prompts. | 3483 | ;; which comint sometimes adds for prompts. |
| 3482 | (setq pos | 3484 | (setq pos |
| 3483 | (cond ((eq sym 'save-point) (point)) | 3485 | (cond ((eq sym 'save-point) |
| 3484 | ((eq sym 'beg-last-out) (point-max)) | 3486 | (if (not output-to-current-buffer) |
| 3485 | ;;((not sym) | 3487 | (point))) |
| 3488 | ((eq sym 'beg-last-out) | ||
| 3489 | (if (not output-to-current-buffer) | ||
| 3490 | (point-max))) | ||
| 3486 | ((or (eq sym 'erase) | 3491 | ((or (eq sym 'erase) |
| 3487 | (and (null sym) (not output-to-current-buffer))) | 3492 | (and (null sym) (not output-to-current-buffer))) |
| 3488 | (let ((inhibit-read-only t)) | 3493 | (let ((inhibit-read-only t)) |
| @@ -3597,10 +3602,15 @@ says to put the output in some other buffer. | |||
| 3597 | If OUTPUT-BUFFER is a buffer or buffer name, erase that buffer | 3602 | If OUTPUT-BUFFER is a buffer or buffer name, erase that buffer |
| 3598 | and insert the output there; a non-nil value of | 3603 | and insert the output there; a non-nil value of |
| 3599 | `shell-command-dont-erase-buffer' prevents the buffer from being | 3604 | `shell-command-dont-erase-buffer' prevents the buffer from being |
| 3600 | erased. If OUTPUT-BUFFER is not a buffer and not nil, insert the | 3605 | erased. If OUTPUT-BUFFER is not a buffer and not nil (which happens |
| 3606 | interactively when the prefix argument is given), insert the | ||
| 3601 | output in current buffer after point leaving mark after it. This | 3607 | output in current buffer after point leaving mark after it. This |
| 3602 | cannot be done asynchronously. | 3608 | cannot be done asynchronously. |
| 3603 | 3609 | ||
| 3610 | The user option `shell-command-dont-erase-buffer', which see, controls | ||
| 3611 | whether the output buffer is erased and where to put point after | ||
| 3612 | the shell command. | ||
| 3613 | |||
| 3604 | If the command terminates without error, but generates output, | 3614 | If the command terminates without error, but generates output, |
| 3605 | and you did not specify \"insert it in the current buffer\", | 3615 | and you did not specify \"insert it in the current buffer\", |
| 3606 | the output can be displayed in the echo area or in its buffer. | 3616 | the output can be displayed in the echo area or in its buffer. |
| @@ -3688,8 +3698,7 @@ impose the use of a shell (with its need to quote arguments)." | |||
| 3688 | ;; because we inserted text. | 3698 | ;; because we inserted text. |
| 3689 | (goto-char (prog1 (mark t) | 3699 | (goto-char (prog1 (mark t) |
| 3690 | (set-marker (mark-marker) (point) | 3700 | (set-marker (mark-marker) (point) |
| 3691 | (current-buffer)))) | 3701 | (current-buffer))))) |
| 3692 | (shell-command-set-point-after-cmd)) | ||
| 3693 | ;; Output goes in a separate buffer. | 3702 | ;; Output goes in a separate buffer. |
| 3694 | ;; Preserve the match data in case called from a program. | 3703 | ;; Preserve the match data in case called from a program. |
| 3695 | ;; FIXME: It'd be ridiculous for an Elisp function to call | 3704 | ;; FIXME: It'd be ridiculous for an Elisp function to call |