bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#33492: 27.0.50; desktop-locals-to-save won't consider buffer-undo-li


From: Terje Larsen
Subject: bug#33492: 27.0.50; desktop-locals-to-save won't consider buffer-undo-list as local
Date: Sat, 24 Nov 2018 21:54:12 +0100

Add buffer-undo-list to be saved by desktop-save:
(cl-pushnew 'buffer-undo-list desktop-locals-to-save :test #'equal)

Open a file:
C-x C-f ~/sample.txt

Input text such as:
Lorem ipsum dolor sit amet

Remove the two last words:
M-2 M-DEL

Save the desktop:
M-x desktop-save

... Restart Emacs ...

Load the desktop:
M-x desktop-read

Execute undo operation:
C-/

At this point I expect the undo operations from the previous session
to be successful.

It seems like this has been mentioned at StackExchange amongst other
places before:
https://emacs.stackexchange.com/questions/3725/why-is-the-buffer-undo-list-excluded-from-buffer-local-variables

I can verify that the issue stems from desktop-save relying on the C-function
buffer-local-variables and this function does not include the variable
buffer-undo-list.
Due to this it will be ignored from being saved by the desktop-save command.

Proposed in the StackExchange post is to append the buffer-undo-list
in the desktop-save
function. But perhaps it should be included in the C-function? Or does
that perhaps cause
other issues?

Personally I have solved it by using an advice:

(defun +append-buffer-undo-list-to-buffer-local-variables-advice
(orig-fn &rest args)
       "Override `buffer-local-variables' and call ORIG-FN with ARGS.
     There is a bug in Emacs where the `buffer-undo-list' data is
     missing from the output of `buffer-local-variables'. This
     advice temporarily overrides the function and appends the
     missing data."
       (let ((orig-buffer-local-variables-fn (symbol-function
'buffer-local-variables)))
         (cl-letf (((symbol-function 'buffer-local-variables)
                    #'(lambda () (append (funcall
orig-buffer-local-variables-fn)
                                    `(,(cons 'buffer-undo-list
buffer-undo-list))))))
           (apply orig-fn args))))
(advice-add #'desktop-buffer-info :around
#'+append-buffer-undo-list-to-buffer-local-variables-advice)

I hope this "long-standing" bug would allow more people to utilize a
persistent undo without
jumping through hoops.

Thanks!


In GNU Emacs 27.0.50 (build 2, x86_64-apple-darwin18.0.0, NS
appkit-1671.00 Version 10.14 (Build 18A391))
of 2018-11-07 built on C02V91MHHV2Q.local
Repository revision: 811d9291fcfb12d87bad277d4e8b25152129d73d
Windowing system distributor 'Apple', version 10.3.1671
System Description:  Mac OS X 10.14.1

Recent messages:
Desktop: 1 frame, 1 buffer restored.
You can run the command ‘desktop-read’ with M-x d-rea RET
Desktop: 1 frame, 1 buffer restored.
user-error: No further undo information [2 times]
user-error: Beginning of history; no preceding item
user-error: End of history; no default available

Configured using:
'configure --disable-dependency-tracking --disable-silent-rules
--enable-locallisppath=/usr/local/share/emacs/site-lisp
--infodir=/usr/local/Cellar/emacs/HEAD-811d929_1/share/info/emacs
--prefix=/usr/local/Cellar/emacs/HEAD-811d929_1 --with-gnutls
--without-x --with-xml2 --without-dbus --with-imagemagick --with-rsvg
--with-ns --disable-ns-self-contained'

Configured features:
RSVG IMAGEMAGICK GLIB NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS NS THREADS LCMS2 GMP

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

Major mode: Text

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 dired dired-loaddefs format-spec rfc822 mml
mml-sec password-cache epa derived epg epg-config gnus-util rmail
rmail-loaddefs time-date 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 cl-seq cl-extra
help-mode easymenu desktop frameset cl-loaddefs cl-lib elec-pair tooltip
eldoc electric uniquify ediff-hook vc-hooks lisp-float-type 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 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 kqueue cocoa ns
lcms2 multi-tty make-network-process emacs)

Memory information:
((conses 16 208523 10884)
(symbols 48 20326 1)
(strings 32 30075 1669)
(string-bytes 1 808523)
(vectors 16 35932)
(vector-slots 8 729980 19992)
(floats 8 51 198)
(intervals 56 240 0)
(buffers 992 13))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]