Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 629513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:45:16+00:00 2026-05-13T19:45:16+00:00

I want to save data to a file in my elisp program. I have

  • 0

I want to save data to a file in my elisp program. I have a multi-dimensional list that I want to save to a file, so I can restore it the next time my program runs. What’s the easiest / best way to do this?

I realise, of course, that I can simply write my data to a buffer in a custom format and then save the buffer, but then I’d have to write a function to parse that data format when I want to restore it. I’d rather not have to do that.

In Python, there’s the Pickle module that lets you “dump” objects to disk and restore them, very easily. Is there something similar for elisp?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:45:16+00:00Added an answer on May 13, 2026 at 7:45 pm

    This ‘dump-vars-to-file routine will create some expressions that can be read by simply evaluating the expressions later (via a 'load command or 'read):

    (defun dump-vars-to-file (varlist filename)
      "simplistic dumping of variables in VARLIST to a file FILENAME"
      (save-excursion
        (let ((buf (find-file-noselect filename)))
          (set-buffer buf)
          (erase-buffer)
          (dump varlist buf)
          (save-buffer)
          (kill-buffer))))
    
    (defun dump (varlist buffer)
      "insert into buffer the setq statement to recreate the variables in VARLIST"
      (loop for var in varlist do
            (print (list 'setq var (list 'quote (symbol-value var)))
                   buffer)))
    

    I’m sure I’m missing some built-in routine that does a nicer job or is more flexible.

    I tested it with this little routine:

    (defun checkit ()
      (let ((a '(1 2 3 (4 5)))
            (b '(a b c))
            (c (make-vector 3 'a)))
        (dump-vars-to-file '(a b c) "/some/path/to/file.el")))
    

    Which produced the output:

    (setq a (quote (1 2 3 (4 5))))
    (setq b (quote (a b c)))
    (setq c (quote [a a a]))
    

    For more information, see the info page on reading and printing lisp objects

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use a variable-sized multi-dimensional array in my app to save data.
I want to setup a table that can: Save the data on the user's
I have some arbitrary pixel data that I want to save as a PNG.
I want to save space when writing my data to file. That is I
I have a problem with my android-app. I want to save a Data-list in
How can I save data to a file (that I will plot later on)
So I have an air application that I want to save data from into
I want to save some custom data into application configuration file and I need
I want to write data to an output file and save it on a
I want to save data to xml file , which include Create xml file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.