unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Help GNU Emacs <help-gnu-emacs@gnu.org>
Subject: Is it possible to save undo state in file and reload again?
Date: Fri, 06 Jan 2023 18:24:41 +0300	[thread overview]
Message-ID: <0357584ce5b79f1e9f0c303f22901b06.support1@rcdrun.com> (raw)

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/



                 reply	other threads:[~2023-01-06 15:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0357584ce5b79f1e9f0c303f22901b06.support1@rcdrun.com \
    --to=bugs@gnu.support \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).