Subject: 31.0.50; replace-region-contents moves point

From: "Paul D. Nelson" <[email-masked]>
Date: Mon, 07 Apr 2025 14:09:12 +0200

The info docs for replace-region-contents say that it attempts to
preserve point.  With the latest update, it fails to preserve point in
cases where it did before.  I fixed my use case with save-excursion, and
the docs are vague enough that this issue might not qualify as a bug,
but I figured I'd report it just in case it was unintentional, or in
case others come across it.

For example:

(with-temp-buffer
  (insert "abc")
  (replace-region-contents (- (point) 3) (- (point) 2) (lambda () "A"))
  (char-to-string (char-before)))

now returns "A", but I believe that it previously returned "c".

In GNU Emacs 31.0.50 (build 1, aarch64-apple-darwin24.1.0, NS
 appkit-2575.20 Version 15.1.1 (Build 24B91)) of 2025-04-06 built on
 d51735
Repository revision: 8ae7224b8fae59229b186853b300822bd70a8ec4
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2575
System Description:  macOS 15.1.1

Configured using:
 'configure --with-ns --with-native-compilation --with-tree-sitter
 --with-gif --with-png --with-jpeg --with-rsvg --with-tiff
 --with-imagemagick --with-x-toolkit=gtk3 --with-xwidgets'

Configured features:
ACL DBUS GLIB GNUTLS IMAGEMAGICK LCMS2 LIBXML2 MODULES NATIVE_COMP
NOTIFY KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TOOLKIT_SCROLL_BARS
TREE_SITTER WEBP XIM XWIDGETS ZLIB

Important settings:
  value of $LC_CTYPE: UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  savehist-mode: t
  recentf-mode: t
  repeat-mode: t
  display-time-mode: t
  save-place-mode: t
  global-auto-revert-mode: t
  minibuffer-depth-indicate-mode: t
  electric-pair-mode: t
  override-global-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tab-bar-history-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug lisp-mnt message mailcap yank-media puny
rfc822 mml mml-sec password-cache epa derived epg rfc6068 epg-config
gnus-util text-property-search mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils thingatpt llm vc-git diff-mode
track-changes files-x vc-dispatcher foldout noutline outline imenu
dired-aux hl-line dired dired-loaddefs time-date pcase savehist recentf
tree-widget repeat time saveplace autorevert filenotify mb-depth
elec-pair comp comp-cstr warnings subr-x comp-run comp-common rx edmacro
kmacro byte-opt cl-macs gv cl-extra help-mode use-package-bind-key
bind-key easy-mmode use-package-ensure cl-seq use-package-core bytecomp
byte-compile cus-edit pp cus-start cus-load icons wid-edit cl-loaddefs
cl-lib rmc iso-transl tooltip cconv eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/ns-win ns-win
ucs-normalize mule-util term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine 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 emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads xwidget-internal dbusbind
kqueue cocoa ns lcms2 multi-tty make-network-process tty-child-frames
native-compile emacs)

Memory information:
((conses 16 201000 24284) (symbols 48 23072 1) (strings 32 56478 4127)
 (string-bytes 1 1440313) (vectors 16 25713)
 (vector-slots 8 1044292 203938) (floats 8 70 20)
 (intervals 56 1876 41) (buffers 992 17))