Subject: bug#35334: 26.2; Changes to position of point are undone during with-current-buffer if window is visible but not current

From: Sean McAfee <[email-masked]>
Date: Fri, 19 Apr 2019 21:00:02 -0700

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