mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
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'.
This commit is contained in:
parent
6b297519b5
commit
175c61c18b
4 changed files with 51 additions and 26 deletions
|
|
@ -3437,20 +3437,22 @@ This affects `shell-command' and `async-shell-command'."
|
|||
:version "27.1")
|
||||
|
||||
(defcustom shell-command-dont-erase-buffer nil
|
||||
"Control if the output buffer is erased before the command.
|
||||
"Whether to erase the output buffer before executing shell command.
|
||||
|
||||
A nil value erases the output buffer before execution of the
|
||||
shell command, except when the output buffer is the current one.
|
||||
|
||||
The value `erase' ensures the output buffer is erased before
|
||||
execution of the shell command.
|
||||
execution of the shell command even if it is the current buffer.
|
||||
|
||||
Other non-nil values prevent the output buffer from being erased and
|
||||
set the point after execution of the shell command.
|
||||
Other non-nil values prevent the output buffer from being erased; they
|
||||
also reposition point in the shell output buffer after execution of the
|
||||
shell command, except when the output buffer is the current buffer.
|
||||
|
||||
The value `beg-last-out' sets point at the beginning of the output,
|
||||
`end-last-out' sets point at the end of the buffer, `save-point'
|
||||
restores the buffer position before the command."
|
||||
The value `beg-last-out' sets point at the beginning of the last
|
||||
output, `end-last-out' sets point at the end of the last output,
|
||||
and `save-point' restores the buffer position as it was before the
|
||||
shell command."
|
||||
:type '(choice
|
||||
(const :tag "Erase output buffer if not the current one" nil)
|
||||
(const :tag "Always erase output buffer" erase)
|
||||
|
|
@ -3480,9 +3482,12 @@ See `shell-command-dont-erase-buffer'."
|
|||
;; if some text has a non-nil read-only property,
|
||||
;; which comint sometimes adds for prompts.
|
||||
(setq pos
|
||||
(cond ((eq sym 'save-point) (point))
|
||||
((eq sym 'beg-last-out) (point-max))
|
||||
;;((not sym)
|
||||
(cond ((eq sym 'save-point)
|
||||
(if (not output-to-current-buffer)
|
||||
(point)))
|
||||
((eq sym 'beg-last-out)
|
||||
(if (not output-to-current-buffer)
|
||||
(point-max)))
|
||||
((or (eq sym 'erase)
|
||||
(and (null sym) (not output-to-current-buffer)))
|
||||
(let ((inhibit-read-only t))
|
||||
|
|
@ -3597,10 +3602,15 @@ says to put the output in some other buffer.
|
|||
If OUTPUT-BUFFER is a buffer or buffer name, erase that buffer
|
||||
and insert the output there; a non-nil value of
|
||||
`shell-command-dont-erase-buffer' prevents the buffer from being
|
||||
erased. If OUTPUT-BUFFER is not a buffer and not nil, insert the
|
||||
erased. If OUTPUT-BUFFER is not a buffer and not nil (which happens
|
||||
interactively when the prefix argument is given), insert the
|
||||
output in current buffer after point leaving mark after it. This
|
||||
cannot be done asynchronously.
|
||||
|
||||
The user option `shell-command-dont-erase-buffer', which see, controls
|
||||
whether the output buffer is erased and where to put point after
|
||||
the shell command.
|
||||
|
||||
If the command terminates without error, but generates output,
|
||||
and you did not specify \"insert it in the current buffer\",
|
||||
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)."
|
|||
;; because we inserted text.
|
||||
(goto-char (prog1 (mark t)
|
||||
(set-marker (mark-marker) (point)
|
||||
(current-buffer))))
|
||||
(shell-command-set-point-after-cmd))
|
||||
(current-buffer)))))
|
||||
;; Output goes in a separate buffer.
|
||||
;; Preserve the match data in case called from a program.
|
||||
;; FIXME: It'd be ridiculous for an Elisp function to call
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue