unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Behavior of with-current-buffer
@ 2020-04-15  7:37 Andreas Röhler
  2020-04-15  8:37 ` Andreas Röhler
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Röhler @ 2020-04-15  7:37 UTC (permalink / raw)
  To: Help GNU Emacs

[-- Attachment #1: Type: text/plain, Size: 893 bytes --]

Hi,

have a buffer connected with a Python-process, however not in 
comint-mode - for speed. See upper window in attachment not-point-max.png.

In the case given "import json" was sent to this buffer by a function 
‘py-fast-send-string’ which is shown partially in window below.

This function checks for a newline-char at the end of the string - 
actually an extra "\n" was sent inside this or-clause.

After sending "\n", second-cursor in output-buffer is shown after the 
newly inserted prompt at EOB. However, when or-clause returns, the 
cursor jumps back to the position before the last prompt started, i.e. 
at position before sending.

An extra (goto-char (point-max)) as shown in code would help, but 
shouldn't be necessary.

Any explanation? A bug?

Thanks,
Andreas
GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 2.24.32, 
cairo version 1.16.0) of 2020-04-06





[-- Attachment #2: not-point-max.png --]
[-- Type: image/png, Size: 149475 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Behavior of with-current-buffer
  2020-04-15  7:37 Behavior of with-current-buffer Andreas Röhler
@ 2020-04-15  8:37 ` Andreas Röhler
  0 siblings, 0 replies; 2+ messages in thread
From: Andreas Röhler @ 2020-04-15  8:37 UTC (permalink / raw)
  To: Help GNU Emacs


Am 15.04.20 um 09:37 schrieb Andreas Röhler:
> Hi,
>
> have a buffer connected with a Python-process, however not in 
> comint-mode - for speed. See upper window in attachment 
> not-point-max.png.
>
> In the case given "import json" was sent to this buffer by a function 
> ‘py-fast-send-string’ which is shown partially in window below.
>
> This function checks for a newline-char at the end of the string - 
> actually an extra "\n" was sent inside this or-clause.
>
> After sending "\n", second-cursor in output-buffer is shown after the 
> newly inserted prompt at EOB. However, when or-clause returns, the 
> cursor jumps back to the position before the last prompt started, i.e. 
> at position before sending.
>
> An extra (goto-char (point-max)) as shown in code would help, but 
> shouldn't be necessary.
>
> Any explanation? A bug?
>
> Thanks,
> Andreas
> GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 2.24.32, 
> cairo version 1.16.0) of 2020-04-06
>
>
>
>

Herewith two example to reproduce from Emacs -Q


(defun with-current-buffer-check ()
   (interactive)
   (let ((oldbuf (current-buffer))
     (output-buffer (shell  "With-current-buffer-Test")))
     (set-buffer oldbuf)
       (with-current-buffer output-buffer
     (goto-char (point-max))
     (insert "echo \"asdf\"")
     (comint-send-input))))

(defun with-current-buffer-check-2 ()
   (interactive)
   (let* ((oldbuf (current-buffer))
      (output-buffer (shell  "With-current-buffer-Test-2"))
      (proc (get-buffer-process output-buffer))
      (strg "echo \"asdf\""))
     (set-buffer oldbuf)
     (with-current-buffer output-buffer
       (process-send-string proc strg)
       (or (string-match "\n$" strg)
       (process-send-string proc "\n")))))




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-15  8:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-15  7:37 Behavior of with-current-buffer Andreas Röhler
2020-04-15  8:37 ` Andreas Röhler

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).