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

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

How to save invisible (lisp) data in a text file


From: sokobania
Subject: How to save invisible (lisp) data in a text file
Date: Thu, 21 Aug 2014 07:04:22 -0700 (PDT)
User-agent: G2/1.0

I would like to do the following:
- display some normal text in a buffer with some major
  mode named "my-special-mode"
- let the user interact with the buffer contents
- store in ram some lisp data generated by the user interaction
  (like marks and extra text not displayed in the buffer)
- store the normal text AND this extra data in a file

Then, when reopening the file, emacs would:
- display the normal text in a buffer with "my-special-mode"
- reinstall in ram the lisp data associated to the file

Is this possible with emacs?

Oops... As the answer to "Is this possible with emacs?"
is always "yes", I would rather ask:

Is there a simple way (functions, mode, package...) to do that?
Are there any (simple) emacs-lisp examples of such a thing?

At the moment, the solution I was thinking of
would be to use file variables.
The major mode "my-special-mode" would:
- delete the last lines of the buffer when invoked
- add a hook to save-file to write the extra data at the end
of the file in a few lines like:

<my-special-mode-delimiter>
Local Variables:
mode: my-special-mode
my-special-mode-data: '(all I need to save to rebuild the data)
End:

It seems rather simple. Is it correct/standard?
Is there any mode which does something similar?
(write data into the "Local Variables:" section)

)jack(


reply via email to

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