* bug#35334: 26.2; Changes to position of point are undone during with-current-buffer if window is visible but not current
@ 2019-04-20 4:00 Sean McAfee
2019-04-20 4:10 ` Noam Postavsky
0 siblings, 1 reply; 10+ messages in thread
From: Sean McAfee @ 2019-04-20 4:00 UTC (permalink / raw)
To: 35334
[-- Attachment #1: Type: text/plain, Size: 3706 bytes --]
Starting from emacs -Q:
Create a new buffer named "a". Insert ten asterisks and move point to
the beginning of the buffer.
Split the window and select the scratch buffer in one of them, leaving
buffer "a" visible in the other. In the scratch buffer, evaluate this
Lisp expression:
(with-current-buffer "a" (goto-char 5) (insert "foo"))
You can see "foo" inserted at position 5 in buffer "a", but point
remains at the beginning of the buffer.
Go to buffer "a", delete the "foo", and move to the beginning of the
buffer again. Go to the scratch buffer and make it the sole visible
window. Evaluate the above Lisp expression again. Go to buffer "a".
"foo" has been inserted at position 5 as before, but now point is at
position 8, after the "foo".
I would expect point to move to position 8 in both cases, and I don't
see anything in the documentation for with-current-buffer or goto-char
to suggest that it ever wouldn't.
In GNU Emacs 26.2 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll
bars)
of 2019-04-19 built on SeanMc
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description: Ubuntu 18.04.2 LTS
Recent messages:
C-x C-g is undefined
C-. is undefined
Undo!
C-. is undefined
nil
Undo!
Mark activated
nil
Quit
Undo!
Configured features:
XAW3D XPM JPEG TIFF GIF PNG SOUND GPM DBUS GSETTINGS GLIB NOTIFY ACL
LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS LUCID X11 XDBE XIM THREADS LCMS2
Important settings:
value of $LANG: en_US.UTF-8
value of $XMODIFIERS: @im=ibus
locale-coding-system: utf-8-unix
Major mode: Fundamental
Minor modes in effect:
tooltip-mode: t
global-eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
Load-path shadows:
None found.
Features:
(shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv
bytecomp byte-compile cconv cl-loaddefs cl-lib dired dired-loaddefs
format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg
epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils elec-pair time-date
mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page menu-bar
rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
x-toolkit x multi-tty make-network-process emacs)
Memory information:
((conses 16 96878 15032)
(symbols 48 20303 1)
(miscs 40 69 168)
(strings 32 29315 1561)
(string-bytes 1 758564)
(vectors 16 14757)
(vector-slots 8 508710 8162)
(floats 8 51 278)
(intervals 56 278 13)
(buffers 992 12))
[-- Attachment #2: Type: text/html, Size: 4285 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#35334: 26.2; Changes to position of point are undone during with-current-buffer if window is visible but not current
2019-04-20 4:00 bug#35334: 26.2; Changes to position of point are undone during with-current-buffer if window is visible but not current Sean McAfee
@ 2019-04-20 4:10 ` Noam Postavsky
2019-04-21 23:32 ` Sean McAfee
0 siblings, 1 reply; 10+ messages in thread
From: Noam Postavsky @ 2019-04-20 4:10 UTC (permalink / raw)
To: Sean McAfee; +Cc: 35334
Sean McAfee <eefacm@gmail.com> writes:
> I would expect point to move to position 8 in both cases, and I don't
> see anything in the documentation for with-current-buffer or goto-char
> to suggest that it ever wouldn't.
How about in (elisp) Window Point?
* Selecting a window sets the value of point in its buffer from the
window's value of point. Conversely, deselecting a window sets the
window's value of point from that of the buffer.
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#35334: 26.2; Changes to position of point are undone during with-current-buffer if window is visible but not current
2019-04-20 4:10 ` Noam Postavsky
@ 2019-04-21 23:32 ` Sean McAfee
2019-04-22 2:38 ` Noam Postavsky
0 siblings, 1 reply; 10+ messages in thread
From: Sean McAfee @ 2019-04-21 23:32 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 35334
[-- Attachment #1: Type: text/plain, Size: 2061 bytes --]
On Fri, Apr 19, 2019 at 9:10 PM Noam Postavsky <npostavs@gmail.com> wrote:
> Sean McAfee <eefacm@gmail.com> writes:
> > I would expect point to move to position 8 in both cases, and I don't
> > see anything in the documentation for with-current-buffer or goto-char
> > to suggest that it ever wouldn't.
>
> How about in (elisp) Window Point?
>
> * Selecting a window sets the value of point in its buffer from the
> window's value of point. Conversely, deselecting a window sets the
> window's value of point from that of the buffer.
>
Okay, I wasn't fully aware of these window-point semantics. I'll take a
step back and describe my actual problem, of which the bug I thought I was
reporting was the simplest case I could reduce it to.
Starting with two windows visible, the scratch buffer and a window showing
empty buffer "a", I evaluate this expression in the scratch buffer:
(start-process "count" "a" "bash" "-c" "for i in {1..10}; echo $i; sleep 1;
done")
I see the numbers 1-10 inserted into buffer "a", one second apart, as
expected. The position of point in buffer "a" follows the new lines as
they're inserted.
Now I define the function ordinary-insertion-filter, as found on this page:
https://www.gnu.org/software/emacs/manual/html_node/elisp/Filter-Functions.html
That function is described as "mimicking the actions of the default
filter." However, if I erase buffer "a" and evaluate this expression in
the scratch buffer:
(let ((proc (start-process "count" "a" "bash" "-c" "for i in {1..10}; echo
$i; sleep 1; done")))
(set-process-filter proc #'ordinary-insertion-filter))
...then I see the numbers inserted as before, but now the position of point
in buffer "a" doesn't move; it stays at the beginning of the buffer. If I
select the window showing buffer "a" as the numbers are still being
inserted and move point to the end of the buffer, then point starts
following the new numbers. But if I select the scratch buffer again, point
in buffer "a" stops following the new numbers.
Is this the expected behavior?
[-- Attachment #2: Type: text/html, Size: 3005 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#35334: 26.2; Changes to position of point are undone during with-current-buffer if window is visible but not current
2019-04-21 23:32 ` Sean McAfee
@ 2019-04-22 2:38 ` Noam Postavsky
2019-04-22 7:22 ` Eli Zaretskii
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Noam Postavsky @ 2019-04-22 2:38 UTC (permalink / raw)
To: Sean McAfee; +Cc: 35334
Sean McAfee <eefacm@gmail.com> writes:
> Starting with two windows visible, the scratch buffer and a window showing
> empty buffer "a", I evaluate this expression in the scratch buffer:
>
> (start-process "count" "a" "bash" "-c" "for i in {1..10}; echo $i; sleep 1; done")
[missing a "do" before the "echo $i", by the way]
> I see the numbers 1-10 inserted into buffer "a", one second apart, as
> expected. The position of point in buffer "a" follows the new lines as
> they're inserted.
>
> Now I define the function ordinary-insertion-filter, as found on this page:
>
> https://www.gnu.org/software/emacs/manual/html_node/elisp/Filter-Functions.html
>
> That function is described as "mimicking the actions of the default
> filter." However, if I erase buffer "a" and evaluate this expression in
> the scratch buffer:
>
> (let ((proc (start-process "count" "a" "bash" "-c" "for i in {1..10}; echo $i; sleep 1; done")))
> (set-process-filter proc #'ordinary-insertion-filter))
>
> ...then I see the numbers inserted as before, but now the position of point
> in buffer "a" doesn't move
Okay, interesting. The difference seems to be that
`internal-default-process-filter' actually uses `insert-before-markers'
rather than plain `insert'. I guess the window point is implemented as
a marker, so inserting this way happens to move it as well.
(defun ordinary-insertion-filter (proc string)
(when (buffer-live-p (process-buffer proc))
(with-current-buffer (process-buffer proc)
(let ((moving (= (point) (process-mark proc))))
(save-excursion
;; Insert the text, advancing the process marker.
(goto-char (process-mark proc))
(insert-before-markers string) ; <------------ change here
(set-marker (process-mark proc) (point)))
(if moving (goto-char (process-mark proc)))))))
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#35334: 26.2; Changes to position of point are undone during with-current-buffer if window is visible but not current
2019-04-22 2:38 ` Noam Postavsky
@ 2019-04-22 7:22 ` Eli Zaretskii
2019-04-27 21:05 ` Sean McAfee
2019-04-27 21:07 ` Noam Postavsky
2 siblings, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2019-04-22 7:22 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 35334, eefacm
> From: Noam Postavsky <npostavs@gmail.com>
> Date: Sun, 21 Apr 2019 22:38:41 -0400
> Cc: 35334@debbugs.gnu.org
>
> I guess the window point is implemented as a marker
Yes, see the comments in window.h.
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#35334: 26.2; Changes to position of point are undone during with-current-buffer if window is visible but not current
2019-04-22 2:38 ` Noam Postavsky
2019-04-22 7:22 ` Eli Zaretskii
@ 2019-04-27 21:05 ` Sean McAfee
2019-04-28 2:19 ` Noam Postavsky
2019-04-27 21:07 ` Noam Postavsky
2 siblings, 1 reply; 10+ messages in thread
From: Sean McAfee @ 2019-04-27 21:05 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 35334
[-- Attachment #1: Type: text/plain, Size: 382 bytes --]
On Sun, Apr 21, 2019 at 7:38 PM Noam Postavsky <npostavs@gmail.com> wrote:
> (insert-before-markers string) ; <------------ change here
>
OK, since I now have a workaround, or rather the appropriate code to use in
my situation, the bug is resolved from my perspective.
Perhaps the "Process Filter Functions" manual page could stand to be
touched up a bit, though.
[-- Attachment #2: Type: text/html, Size: 703 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#35334: 26.2; Changes to position of point are undone during with-current-buffer if window is visible but not current
2019-04-27 21:05 ` Sean McAfee
@ 2019-04-28 2:19 ` Noam Postavsky
2019-04-30 21:58 ` Sean McAfee
0 siblings, 1 reply; 10+ messages in thread
From: Noam Postavsky @ 2019-04-28 2:19 UTC (permalink / raw)
To: Sean McAfee; +Cc: 35334
Sean McAfee <eefacm@gmail.com> writes:
> On Sun, Apr 21, 2019 at 7:38 PM Noam Postavsky <npostavs@gmail.com> wrote:
>
>> (insert-before-markers string) ; <------------ change here
>>
>
> OK, since I now have a workaround, or rather the appropriate code to use in
> my situation, the bug is resolved from my perspective.
>
> Perhaps the "Process Filter Functions" manual page could stand to be
> touched up a bit, though.
Oh, we sent at the same time. By "touched up a bit" did you have in
mind anything apart from making that change quoted above?
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#35334: 26.2; Changes to position of point are undone during with-current-buffer if window is visible but not current
2019-04-28 2:19 ` Noam Postavsky
@ 2019-04-30 21:58 ` Sean McAfee
2019-05-01 0:55 ` Noam Postavsky
0 siblings, 1 reply; 10+ messages in thread
From: Sean McAfee @ 2019-04-30 21:58 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 35334
[-- Attachment #1: Type: text/plain, Size: 382 bytes --]
On Sat, Apr 27, 2019 at 7:19 PM Noam Postavsky <npostavs@gmail.com> wrote:
> Sean McAfee <eefacm@gmail.com> writes:
> > Perhaps the "Process Filter Functions" manual page could stand to be
> > touched up a bit, though.
>
> Oh, we sent at the same time. By "touched up a bit" did you have in
> mind anything apart from making that change quoted above?
>
>
Nope, that should do it.
[-- Attachment #2: Type: text/html, Size: 765 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#35334: 26.2; Changes to position of point are undone during with-current-buffer if window is visible but not current
2019-04-30 21:58 ` Sean McAfee
@ 2019-05-01 0:55 ` Noam Postavsky
0 siblings, 0 replies; 10+ messages in thread
From: Noam Postavsky @ 2019-05-01 0:55 UTC (permalink / raw)
To: Sean McAfee; +Cc: 35334
close 35334 26.3
quit
Sean McAfee <eefacm@gmail.com> writes:
> On Sat, Apr 27, 2019 at 7:19 PM Noam Postavsky <npostavs@gmail.com> wrote:
>
>> Sean McAfee <eefacm@gmail.com> writes:
>> > Perhaps the "Process Filter Functions" manual page could stand to be
>> > touched up a bit, though.
>>
>> Oh, we sent at the same time. By "touched up a bit" did you have in
>> mind anything apart from making that change quoted above?
>>
>>
> Nope, that should do it.
Okay, pushed to emacs-26 (I accidentally put the wrong bug number in the
commit message though).
ec02c736d6 2019-04-30T20:51:24-04:00 "Update process filter example (Bug#35044)"
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=ec02c736d65f2fd3a8a17e4e8dc143bf15d9600d
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#35334: 26.2; Changes to position of point are undone during with-current-buffer if window is visible but not current
2019-04-22 2:38 ` Noam Postavsky
2019-04-22 7:22 ` Eli Zaretskii
2019-04-27 21:05 ` Sean McAfee
@ 2019-04-27 21:07 ` Noam Postavsky
2 siblings, 0 replies; 10+ messages in thread
From: Noam Postavsky @ 2019-04-27 21:07 UTC (permalink / raw)
To: Sean McAfee; +Cc: 35334
> (defun ordinary-insertion-filter (proc string)
> (when (buffer-live-p (process-buffer proc))
> (with-current-buffer (process-buffer proc)
> (let ((moving (= (point) (process-mark proc))))
> (save-excursion
> ;; Insert the text, advancing the process marker.
> (goto-char (process-mark proc))
> (insert-before-markers string) ; <------------ change here
> (set-marker (process-mark proc) (point)))
> (if moving (goto-char (process-mark proc)))))))
If we make this update in the manual, would that sufficiently clarify
the sitatuation, or do we need anything else?
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2019-05-01 0:55 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-20 4:00 bug#35334: 26.2; Changes to position of point are undone during with-current-buffer if window is visible but not current Sean McAfee
2019-04-20 4:10 ` Noam Postavsky
2019-04-21 23:32 ` Sean McAfee
2019-04-22 2:38 ` Noam Postavsky
2019-04-22 7:22 ` Eli Zaretskii
2019-04-27 21:05 ` Sean McAfee
2019-04-28 2:19 ` Noam Postavsky
2019-04-30 21:58 ` Sean McAfee
2019-05-01 0:55 ` Noam Postavsky
2019-04-27 21:07 ` Noam Postavsky
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.