Subject: 29.0.50; pp-use-max-width=t can break bookmark-save

From: Visuwesh <[email-masked]>
Date: Fri, 31 Dec 2021 17:18:25 +0100 (CET)

When the user option `pp-use-max-width' introduced in Emacs 29 is set to
t, `bookmark-save' can fail.  Following the backtrace points out the
problem lies in `pp', specifically `pp-emacs-lisp-code', which fails to printthe following bookmark record produced pdf-tools,

("Last read Peter Sykes"
(filename . "~/doc/uni/refb/A_guidebook_to_Mechanism_in_Organic_Chemistry_Peter_Sykes.pdf")
(position . 1)
(page . 263)
(slice)
(size . 4.367774566473988)
(origin 0.0 . 0.5892997639653816)
(handler . pdf-view-bookmark-jump-handler))

Let-binding `pp-use-max-width' to nil in `bookmark-save' should fix the
problem, I think.

Following is the backtrace produced when trying to save bookmarks (I hope it
doesn't get mangled),

Debugger entered--Lisp error: (error "Invalid search bound (wrong side of point)")
  looking-back(" " 2)
  pp--insert(" " (filename . "~/doc/uni/refb/A_guidebook_to_Mechanism_in_Organic..."))
  pp--format-list(("Last read Peter Sykes" (filename . "~/doc/uni/refb/A_guidebook_to_Mechanism_in_Organic...") (position . 1) (page . 1) (slice) (size . fit-width) (origin 0.0 . 0.0) (handler . pdf-view-bookmark-jump-handler)))
  pp--insert-lisp(("Last read Peter Sykes" (filename . "~/doc/uni/refb/A_guidebook_to_Mechanism_in_Organic...") (position . 1) (page . 1) (slice) (size . fit-width) (origin 0.0 . 0.0) (handler . pdf-view-bookmark-jump-handler)))
  pp-emacs-lisp-code(("Last read Peter Sykes" (filename . "~/doc/uni/refb/A_guidebook_to_Mechanism_in_Organic...") (position . 1) (page . 1) (slice) (size . fit-width) (origin 0.0 . 0.0) (handler . pdf-view-bookmark-jump-handler)))
  pp-to-string(("Last read Peter Sykes" (filename . "~/doc/uni/refb/A_guidebook_to_Mechanism_in_Organic...") (position . 1) (page . 1) (slice) (size . fit-width) (origin 0.0 . 0.0) (handler . pdf-view-bookmark-jump-handler)))
  pp(("Last read Peter Sykes" (filename . "~/doc/uni/refb/A_guidebook_to_Mechanism_in_Organic...") (position . 1) (page . 1) (slice) (size . fit-width) (origin 0.0 . 0.0) (handler . pdf-view-bookmark-jump-handler)) #<buffer  *Bookmarks*>)
  bookmark-write-file("/home/viz/lib/emacs/bookmarks")
  bookmark-save()
  bookmark-store("Last read Peter Sykes" ((filename . "~/doc/uni/refb/A_guidebook_to_Mechanism_in_Organic...") (position . 1) (page . 1) (slice) (size . fit-width) (origin 0.0 . 0.0) (handler . pdf-view-bookmark-jump-handler)) nil)
  bookmark-set-internal("Set bookmark named" nil overwrite)
  bookmark-set(nil nil)
  funcall-interactively(bookmark-set nil nil)
  command-execute(bookmark-set)

In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars)
Repository revision: 4b7e73432cd07612e5225189e18696f755c8f954
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: NixOS 21.11 (Porcupine)

Configured using:
'configure
--prefix=/nix/store/rsgfliii3k06j8i77zn295yp87qbq0yr-emacs-git-20211221.0
--disable-build-details --with-modules --with-x-toolkit=lucid
--with-xft --with-cairo --with-native-compilation'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM LUCID ZLIB

Important settings:
  value of $EMACSLOADPATH:
  value of $EMACSNATIVELOADPATH: /nix/store/x6fjznfj7wks7nvs6xgsk1q4fcd5rjrw-emacs-packages-deps/share/emacs/native-lisp::
  value of $LANG: en_GB.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  paredit-mode: t
  eros-mode: t
  flymake-mode: t
  pdf-occur-global-minor-mode: t
  hl-todo-mode: t
  minibuffer-depth-indicate-mode: t
  repeat-mode: t
  display-time-mode: t
  display-battery-mode: t
  straight-use-package-mode: t
  straight-package-neutering-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-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  transient-mark-mode: t

Load-path shadows:
/home/viz/.nix-profile/share/emacs/site-lisp/site-start hides /nix/store/x6fjznfj7wks7nvs6xgsk1q4fcd5rjrw-emacs-packages-deps/share/emacs/site-lisp/site-start
/home/viz/lib/emacs/straight/build/map/map hides /nix/store/rsgfliii3k06j8i77zn295yp87qbq0yr-emacs-git-20211221.0/share/emacs/29.0.50/lisp/emacs-lisp/map
/home/viz/lib/emacs/straight/build/let-alist/let-alist hides /nix/store/rsgfliii3k06j8i77zn295yp87qbq0yr-emacs-git-20211221.0/share/emacs/29.0.50/lisp/emacs-lisp/let-alist
/nix/store/rsgfliii3k06j8i77zn295yp87qbq0yr-emacs-git-20211221.0/share/emacs/29.0.50/lisp/emacs-lisp/eieio-compat hides /nix/store/rsgfliii3k06j8i77zn295yp87qbq0yr-emacs-git-20211221.0/share/emacs/29.0.50/lisp/obsolete/eieio-compat

Features:
(shadow sort goto-addr mail-extr emacsbug message yank-media rmc puny
rfc822 mml mml-sec epa epg rfc6068 epg-config gnus-util mm-decode
mm-bodies mm-encode mailabbrev gmm-utils mailheader sendmail mail-utils
debug cl-print face-remap help-fns radix-tree paredit edmacro kmacro
eros time-date checkdoc lisp-mnt mail-parse rfc2231 rfc2047 rfc2045
mm-util ietf-drums mail-prsvr flymake-proc flymake project warnings
thingatpt writegood-mode-autoloads sokoban-autoloads ement-autoloads
ts-autoloads s-autoloads map-autoloads plz-autoloads nov-autoloads
esxml-autoloads kv-autoloads transmission-autoloads lua-mode-autoloads
nix-mode-autoloads magit-section-autoloads dash-autoloads
racket-mode-autoloads eros-autoloads flymake-shellcheck-autoloads avy
avy-autoloads siege-mode-autoloads paredit-autoloads
expand-region-autoloads filladapt-autoloads compose quail
scroll-other-window org-pdftools-autoloads org-noter-autoloads
finder-inf math-delimiters-autoloads doct-autoloads ob-async-autoloads
async-autoloads emacs-ob-racket-autoloads valign-autoloads
org-starless-autoloads cdlatex-autoloads auctex-autoloads tex-site
easy-mmode pdf-occur ibuf-ext ibuffer ibuffer-loaddefs tablist
tablist-filter semantic/wisent/comp semantic/wisent
semantic/wisent/wisent semantic/util-modes semantic/util semantic
semantic/tag semantic/lex semantic/fw mode-local cedet pdf-isearch
let-alist pdf-misc imenu pdf-tools package browse-url url url-proxy
url-privacy url-expand url-methods url-history url-cookie url-domsuf
url-util mailcap url-handlers url-parse auth-source eieio eieio-core
eieio-loaddefs json map url-vars compile comint ansi-color ring cus-edit
hl-todo edebug backtrace find-func wid-edit pdf-view password-cache
bookmark text-property-search pp jka-compr pdf-cache pdf-info tq
pdf-util advice pdf-macs image-mode dired-x dired dired-loaddefs exif
pdf-tools-autoloads let-alist-autoloads tablist-autoloads derived
mb-depth cus-load repeat visual-fill-autoloads olivetti-autoloads
hl-todo-autoloads time format-spec battery dbus filenotify xml
disp-table lacarte-autoloads shell-command-plus-autoloads icalendar
diary-lib diary-loaddefs cal-menu calendar cal-loaddefs rx
chemtable-autoloads molar-mass-autoloads pcase straight-autoloads info
cl-seq cl-extra help-mode straight cl-macs cl-loaddefs cl-lib
vz-nh-theme seq gv subr-x byte-opt bytecomp byte-compile cconv
iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode 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 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 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 emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button 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
dbusbind inotify dynamic-setting system-font-setting font-render-setting
cairo x-toolkit x multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 244713 25017) (symbols ?0 18721 0) (strings 32 64808 3640)
(
  string-bytes 1 2424342) (vectors 16 36511) (vector-slots 8 672184 15121)
(
  floats 8 128 ?E) (intervals ?8 423 0) (buffers 992 18))