1

I'm just trying my hands on emacs lisp. So far I've had some luck, but I'm stuck trying to load my frames configuration into a list.

Here's what I'm trying to do... I am saving frames configuration (all currently open frames) like so

(defun save-all-frames ()
  (interactive)
  (let ((config (current-frame-configuration)))
    (with-temp-buffer
      (insert
       (format "%s" config))
      (if (file-exists-p framegeometry-file)
          (when (file-writable-p framegeometry-file)
            (write-file framegeometry-file)))
      ))
  )

where framegeometry-file points to "~/.emacs.d/frameconfig.el"

Now this works fine...but I do not know how to read it back into a list so that I can traverse through it and create frames with the configuration. I'm thinking of using set-frame-configuration to restore the configuration read from the file.

Any help or pointers in the right direction will be really appreciated.

  • 2
    Considering that (current-frame-configuration) returns unreadable objects, this approach has no chance of working. You might want to look at code in desktop.el, which comes with Emacs, which does plenty of things including saving of the frame configuration. – DoMiNeLa10 Jun 8 at 8:51
  • Thank you. Right now I've progressed to a point where I can restore the layout and buffers, but the buffer which was in focus when I exited emacs is not put back in focus. But if I call load-file on my desktop file, it works. So I will look into doing that instead of calling desktop-read. – Wilson Almeida Jun 8 at 9:46
  • What @DoMiNeLa10 said. See library frameset.el, which is what desktop.el uses for saving and restoring frames. – Drew Jun 8 at 15:55
  • Following up on my question.. I've managed to do what I set out to, using frameset-save and frameset-restore functions. With these, I'm able to restore all frame and buffer configuration including restoring buffers to their frames/windows and restoring all state before Emacs was killed. And this works irrespective of how Emacs is launched i.e. daemon or standalone process. – Wilson Almeida Jun 30 at 6:14
  • @WilsonAlmeida can you post an answer to your question if you managed to figure it out? – DoMiNeLa10 Jun 30 at 10:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.