unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 40896@debbugs.gnu.org, tino.calancha@gmail.com
Subject: bug#40896: 27.0.91; Moving point fails sometimes in shell-command
Date: Tue, 28 Apr 2020 16:22:19 +0200	[thread overview]
Message-ID: <87tv13wuzo.fsf@gmx.de> (raw)
In-Reply-To: <837dxz3kww.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 28 Apr 2020 14:32:47 +0300")

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Michael Albinus <michael.albinus@gmx.de>
>> Cc: 40896@debbugs.gnu.org,  tino.calancha@gmail.com
>> Date: Mon, 27 Apr 2020 19:50:57 +0200
>> 
>> Hmm, maybe I have been biased with the Tramp behaviour. But still,
>> there's suspicious behaviour with shell-command:
>
> I think these also behave as intended.  In general, all the non-nil
> values of shell-command-dont-erase-buffer are set up to accumulate
> output of several consecutive commands.  Once again, perhaps the
> documentation needs to be clarified.

Whatever shell-command-dont-erase-buffer says, shell-command output in
non-interactive mode shall be inserted at point, possibly after erasing
the buffer first. The first example I gave shows that this doesn't happen:

--8<---------------cut here---------------start------------->8---
;; Don't erase if the buffer is not the current one and
;; `shell-command-dont-erase-buffer' is set to `save-point'.
;; Check point.
(let ((default-directory temporary-file-directory)
      (shell-command-dont-erase-buffer 'save-point)
      buffer point)
  (with-temp-buffer
    (setq buffer (current-buffer))
    (insert "foobar")
    (goto-char (- (point-max) 3))
    (setq point (point))
    (cl-assert (string-equal "foobar" (buffer-string)))
    (cl-assert (string-equal "foo" (buffer-substring (point-min) (point))))
    (cl-assert (string-equal "bar" (buffer-substring (point) (point-max))))
    (cl-assert (= (point) (- (point-max) 3)))
    (with-temp-buffer
      (shell-command "echo baz" buffer))
    ;; The shell command output should be inserted between "foo" and "bar".
    (cl-assert (string-equal "foobaz\nbar" (buffer-string)) 'show-args)
    (cl-assert (= point (point)) 'show-args)))
--8<---------------cut here---------------end--------------->8---

Note that in case the buffer the output has to be inserted in is the
current one, this test succeeds. You can achieve this be replacing
'(with-temp-buffer (shell-command "echo baz" buffer))' by
'(shell-command "echo baz" buffer)'. This is inconsistent, isn't it? And
I haven't found any indication, that in case the buffer is not the
current one, shell command is inserted at the end of the buffer instead
of being inserted at point.

The second test case I've shown indicates, that a random value of
shell-command-dont-erase-buffer (I use the symbol 'random' here) doesn't
behave as expected. The docstring of that user option is not clear to
me: could it be, that the special symbols 'beg-last-out', 'end-last-out'
and ‘save-point’ indicate only setting the point if the buffer is the
current one? Why that? It's inconsistent in my eyes.

Maybe all of this is irrelevant in real life. But I'm fighting with
Tramp, in order to let its shell-command implementation behave like in
the local case.

Best regards, Michael.





  reply	other threads:[~2020-04-28 14:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-27  8:28 bug#40896: 27.0.91; Moving point fails sometimes in shell-command Michael Albinus
2020-04-27 14:43 ` Eli Zaretskii
2020-04-27 17:50   ` Michael Albinus
2020-04-28 11:32     ` Eli Zaretskii
2020-04-28 14:22       ` Michael Albinus [this message]
2020-04-30 13:45         ` Michael Albinus
2020-05-02  9:40           ` Eli Zaretskii
2020-05-02 13:12             ` Michael Albinus
2022-01-28 15:34               ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tv13wuzo.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=40896@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=tino.calancha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).