unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Is it possible to save undo state in file and reload again?
@ 2023-01-06 15:24 Jean Louis
  0 siblings, 0 replies; only message in thread
From: Jean Louis @ 2023-01-06 15:24 UTC (permalink / raw)
  To: Help GNU Emacs

There must exist some "undo" state in Emacs for {C-x u} to work,
right?

Is it maybe the contents of variable `pending-undo-list'?

I have tried saving it this way:

(defun data-to-file (data file)
  "PRIN1 Emacs Lisp DATA to FILE"
  (string-to-file-force (prin1-to-string data) file))

(defun data-from-file (file)
  "Reads and returns Emacs Lisp data from FILE"
  (condition-case nil
      (car (read-from-string
	    (file-to-string file)))
    (error nil)))

(data-to-file pending-undo-list "pul") ➜ "pul"

(file-to-string "pul") works and I can see what is inside.

But then my function `data-from-file' can't handle it:

(data-from-file "pul")

because I get this error

(read-from-string (file-to-string "pul")) 
eval: Invalid read syntax: "#"

How can I save it in file and read from file with that read syntax
"#"? It should be somehow possible.

When editing database objects I would try to capture the undo state
and at any new editing to reload the undo state.


--
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-06 15:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-06 15:24 Is it possible to save undo state in file and reload again? Jean Louis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).