How to restore Emacs' windows and buffers from the last session?












4















How to restore Emacs' windows and buffers from the last session?



The behavior I want is like in web browser that you can restore all the tabs from last session.










share|improve this question


















  • 1





    See the answer to this question.

    – Tom
    Jan 29 '12 at 6:51
















4















How to restore Emacs' windows and buffers from the last session?



The behavior I want is like in web browser that you can restore all the tabs from last session.










share|improve this question


















  • 1





    See the answer to this question.

    – Tom
    Jan 29 '12 at 6:51














4












4








4


1






How to restore Emacs' windows and buffers from the last session?



The behavior I want is like in web browser that you can restore all the tabs from last session.










share|improve this question














How to restore Emacs' windows and buffers from the last session?



The behavior I want is like in web browser that you can restore all the tabs from last session.







windows emacs






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 29 '12 at 5:12









qazwsxqazwsx

3,085154771




3,085154771








  • 1





    See the answer to this question.

    – Tom
    Jan 29 '12 at 6:51














  • 1





    See the answer to this question.

    – Tom
    Jan 29 '12 at 6:51








1




1





See the answer to this question.

– Tom
Jan 29 '12 at 6:51





See the answer to this question.

– Tom
Jan 29 '12 at 6:51










3 Answers
3






active

oldest

votes


















1














In addition to automatically restoring your last Emacs session state, you can also save any number of session states and restore them on demand in any other session, any number of times. IOW, you can easily switch among different desktops.



The easiest way to do this is to load library Bookmark+ and use key C-x r K to save the current session state as a desktop bookmark. You can then restore any desktop bookmark in any session using key C-x j K.






share|improve this answer

































    2














    go to your .emacs file and type (desktop-save-mode 1) this will save all current buffers to a "desktop" file, it wont save the actual layout of your frames but you can look into "registers" for that.






    share|improve this answer































      1














      Here's some code to do it. For the code to work, you need the "tapestry" Lisp library installed. If you use the VM mailer, you have the library installed already. Otherwise you can download it from here.



      Put the following code in your .emacs file. When you want to restore your window and frame setup from your last Emacs session, type M-x load-my-tapestry RET.



      (require 'tapestry)

      (defvar my-tapestry-file "~/.tapestry")

      (defun load-my-tapestry ()
      (interactive)
      (let ((b (find-file-noselect my-tapestry-file)))
      (sit-for 0)
      (set-tapestry (read b))
      (kill-buffer b)))

      (defun save-my-tapestry ()
      (interactive)
      (let ((tap (tapestry)))
      (with-temp-buffer
      (let ((standard-output (current-buffer)))
      (setcar tap (make-list (length (car tap)) nil))
      (print tap)
      (write-region (point-min) (point-max) my-tapestry-file)))))

      (add-hook 'kill-emacs-hook 'save-my-tapestry)





      share|improve this answer
























      • When I do M-x load-my-tapestry RET, I only got (New file) set-tapestry: End of file during parsing in mini-buffer and nothing loaded in the Emacs window.

        – qazwsx
        Jan 29 '12 at 18:03











      • Run M-x save-my-tapestry once and the process should be bootstrapped.

        – Kyle Jones
        Jan 29 '12 at 21:00











      • Did; then it gaves let: Wrong type argument: listp, config error in mini-buffer now.

        – qazwsx
        Jan 29 '12 at 21:44











      • Hmmm, there's no config variable in my answer code or in tapestry.el. (setq debug-on-error t) and get a stacktrace. That should indicate where the error is happening.

        – Kyle Jones
        Jan 29 '12 at 21:59











      • Actually when I rerun it, I get set-tapestry: End of file during parsing error again. I opened a Emacs session, opened two frames, and loaded two different files in each of them, then M-x save-my-tapestry, then close it. Reopen Emacs, then do M-x load-my-tapestry RET, it gave set-tapestry: End of file during parsing.

        – qazwsx
        Jan 29 '12 at 22:05











      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "3"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f383560%2fhow-to-restore-emacs-windows-and-buffers-from-the-last-session%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      In addition to automatically restoring your last Emacs session state, you can also save any number of session states and restore them on demand in any other session, any number of times. IOW, you can easily switch among different desktops.



      The easiest way to do this is to load library Bookmark+ and use key C-x r K to save the current session state as a desktop bookmark. You can then restore any desktop bookmark in any session using key C-x j K.






      share|improve this answer






























        1














        In addition to automatically restoring your last Emacs session state, you can also save any number of session states and restore them on demand in any other session, any number of times. IOW, you can easily switch among different desktops.



        The easiest way to do this is to load library Bookmark+ and use key C-x r K to save the current session state as a desktop bookmark. You can then restore any desktop bookmark in any session using key C-x j K.






        share|improve this answer




























          1












          1








          1







          In addition to automatically restoring your last Emacs session state, you can also save any number of session states and restore them on demand in any other session, any number of times. IOW, you can easily switch among different desktops.



          The easiest way to do this is to load library Bookmark+ and use key C-x r K to save the current session state as a desktop bookmark. You can then restore any desktop bookmark in any session using key C-x j K.






          share|improve this answer















          In addition to automatically restoring your last Emacs session state, you can also save any number of session states and restore them on demand in any other session, any number of times. IOW, you can easily switch among different desktops.



          The easiest way to do this is to load library Bookmark+ and use key C-x r K to save the current session state as a desktop bookmark. You can then restore any desktop bookmark in any session using key C-x j K.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Feb 12 at 10:57









          Qohelet

          1034




          1034










          answered Sep 1 '13 at 21:04









          DrewDrew

          1,850616




          1,850616

























              2














              go to your .emacs file and type (desktop-save-mode 1) this will save all current buffers to a "desktop" file, it wont save the actual layout of your frames but you can look into "registers" for that.






              share|improve this answer




























                2














                go to your .emacs file and type (desktop-save-mode 1) this will save all current buffers to a "desktop" file, it wont save the actual layout of your frames but you can look into "registers" for that.






                share|improve this answer


























                  2












                  2








                  2







                  go to your .emacs file and type (desktop-save-mode 1) this will save all current buffers to a "desktop" file, it wont save the actual layout of your frames but you can look into "registers" for that.






                  share|improve this answer













                  go to your .emacs file and type (desktop-save-mode 1) this will save all current buffers to a "desktop" file, it wont save the actual layout of your frames but you can look into "registers" for that.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 1 '12 at 13:31









                  ShantanuShantanu

                  5821611




                  5821611























                      1














                      Here's some code to do it. For the code to work, you need the "tapestry" Lisp library installed. If you use the VM mailer, you have the library installed already. Otherwise you can download it from here.



                      Put the following code in your .emacs file. When you want to restore your window and frame setup from your last Emacs session, type M-x load-my-tapestry RET.



                      (require 'tapestry)

                      (defvar my-tapestry-file "~/.tapestry")

                      (defun load-my-tapestry ()
                      (interactive)
                      (let ((b (find-file-noselect my-tapestry-file)))
                      (sit-for 0)
                      (set-tapestry (read b))
                      (kill-buffer b)))

                      (defun save-my-tapestry ()
                      (interactive)
                      (let ((tap (tapestry)))
                      (with-temp-buffer
                      (let ((standard-output (current-buffer)))
                      (setcar tap (make-list (length (car tap)) nil))
                      (print tap)
                      (write-region (point-min) (point-max) my-tapestry-file)))))

                      (add-hook 'kill-emacs-hook 'save-my-tapestry)





                      share|improve this answer
























                      • When I do M-x load-my-tapestry RET, I only got (New file) set-tapestry: End of file during parsing in mini-buffer and nothing loaded in the Emacs window.

                        – qazwsx
                        Jan 29 '12 at 18:03











                      • Run M-x save-my-tapestry once and the process should be bootstrapped.

                        – Kyle Jones
                        Jan 29 '12 at 21:00











                      • Did; then it gaves let: Wrong type argument: listp, config error in mini-buffer now.

                        – qazwsx
                        Jan 29 '12 at 21:44











                      • Hmmm, there's no config variable in my answer code or in tapestry.el. (setq debug-on-error t) and get a stacktrace. That should indicate where the error is happening.

                        – Kyle Jones
                        Jan 29 '12 at 21:59











                      • Actually when I rerun it, I get set-tapestry: End of file during parsing error again. I opened a Emacs session, opened two frames, and loaded two different files in each of them, then M-x save-my-tapestry, then close it. Reopen Emacs, then do M-x load-my-tapestry RET, it gave set-tapestry: End of file during parsing.

                        – qazwsx
                        Jan 29 '12 at 22:05
















                      1














                      Here's some code to do it. For the code to work, you need the "tapestry" Lisp library installed. If you use the VM mailer, you have the library installed already. Otherwise you can download it from here.



                      Put the following code in your .emacs file. When you want to restore your window and frame setup from your last Emacs session, type M-x load-my-tapestry RET.



                      (require 'tapestry)

                      (defvar my-tapestry-file "~/.tapestry")

                      (defun load-my-tapestry ()
                      (interactive)
                      (let ((b (find-file-noselect my-tapestry-file)))
                      (sit-for 0)
                      (set-tapestry (read b))
                      (kill-buffer b)))

                      (defun save-my-tapestry ()
                      (interactive)
                      (let ((tap (tapestry)))
                      (with-temp-buffer
                      (let ((standard-output (current-buffer)))
                      (setcar tap (make-list (length (car tap)) nil))
                      (print tap)
                      (write-region (point-min) (point-max) my-tapestry-file)))))

                      (add-hook 'kill-emacs-hook 'save-my-tapestry)





                      share|improve this answer
























                      • When I do M-x load-my-tapestry RET, I only got (New file) set-tapestry: End of file during parsing in mini-buffer and nothing loaded in the Emacs window.

                        – qazwsx
                        Jan 29 '12 at 18:03











                      • Run M-x save-my-tapestry once and the process should be bootstrapped.

                        – Kyle Jones
                        Jan 29 '12 at 21:00











                      • Did; then it gaves let: Wrong type argument: listp, config error in mini-buffer now.

                        – qazwsx
                        Jan 29 '12 at 21:44











                      • Hmmm, there's no config variable in my answer code or in tapestry.el. (setq debug-on-error t) and get a stacktrace. That should indicate where the error is happening.

                        – Kyle Jones
                        Jan 29 '12 at 21:59











                      • Actually when I rerun it, I get set-tapestry: End of file during parsing error again. I opened a Emacs session, opened two frames, and loaded two different files in each of them, then M-x save-my-tapestry, then close it. Reopen Emacs, then do M-x load-my-tapestry RET, it gave set-tapestry: End of file during parsing.

                        – qazwsx
                        Jan 29 '12 at 22:05














                      1












                      1








                      1







                      Here's some code to do it. For the code to work, you need the "tapestry" Lisp library installed. If you use the VM mailer, you have the library installed already. Otherwise you can download it from here.



                      Put the following code in your .emacs file. When you want to restore your window and frame setup from your last Emacs session, type M-x load-my-tapestry RET.



                      (require 'tapestry)

                      (defvar my-tapestry-file "~/.tapestry")

                      (defun load-my-tapestry ()
                      (interactive)
                      (let ((b (find-file-noselect my-tapestry-file)))
                      (sit-for 0)
                      (set-tapestry (read b))
                      (kill-buffer b)))

                      (defun save-my-tapestry ()
                      (interactive)
                      (let ((tap (tapestry)))
                      (with-temp-buffer
                      (let ((standard-output (current-buffer)))
                      (setcar tap (make-list (length (car tap)) nil))
                      (print tap)
                      (write-region (point-min) (point-max) my-tapestry-file)))))

                      (add-hook 'kill-emacs-hook 'save-my-tapestry)





                      share|improve this answer













                      Here's some code to do it. For the code to work, you need the "tapestry" Lisp library installed. If you use the VM mailer, you have the library installed already. Otherwise you can download it from here.



                      Put the following code in your .emacs file. When you want to restore your window and frame setup from your last Emacs session, type M-x load-my-tapestry RET.



                      (require 'tapestry)

                      (defvar my-tapestry-file "~/.tapestry")

                      (defun load-my-tapestry ()
                      (interactive)
                      (let ((b (find-file-noselect my-tapestry-file)))
                      (sit-for 0)
                      (set-tapestry (read b))
                      (kill-buffer b)))

                      (defun save-my-tapestry ()
                      (interactive)
                      (let ((tap (tapestry)))
                      (with-temp-buffer
                      (let ((standard-output (current-buffer)))
                      (setcar tap (make-list (length (car tap)) nil))
                      (print tap)
                      (write-region (point-min) (point-max) my-tapestry-file)))))

                      (add-hook 'kill-emacs-hook 'save-my-tapestry)






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Jan 29 '12 at 8:57









                      Kyle JonesKyle Jones

                      5,58621729




                      5,58621729













                      • When I do M-x load-my-tapestry RET, I only got (New file) set-tapestry: End of file during parsing in mini-buffer and nothing loaded in the Emacs window.

                        – qazwsx
                        Jan 29 '12 at 18:03











                      • Run M-x save-my-tapestry once and the process should be bootstrapped.

                        – Kyle Jones
                        Jan 29 '12 at 21:00











                      • Did; then it gaves let: Wrong type argument: listp, config error in mini-buffer now.

                        – qazwsx
                        Jan 29 '12 at 21:44











                      • Hmmm, there's no config variable in my answer code or in tapestry.el. (setq debug-on-error t) and get a stacktrace. That should indicate where the error is happening.

                        – Kyle Jones
                        Jan 29 '12 at 21:59











                      • Actually when I rerun it, I get set-tapestry: End of file during parsing error again. I opened a Emacs session, opened two frames, and loaded two different files in each of them, then M-x save-my-tapestry, then close it. Reopen Emacs, then do M-x load-my-tapestry RET, it gave set-tapestry: End of file during parsing.

                        – qazwsx
                        Jan 29 '12 at 22:05



















                      • When I do M-x load-my-tapestry RET, I only got (New file) set-tapestry: End of file during parsing in mini-buffer and nothing loaded in the Emacs window.

                        – qazwsx
                        Jan 29 '12 at 18:03











                      • Run M-x save-my-tapestry once and the process should be bootstrapped.

                        – Kyle Jones
                        Jan 29 '12 at 21:00











                      • Did; then it gaves let: Wrong type argument: listp, config error in mini-buffer now.

                        – qazwsx
                        Jan 29 '12 at 21:44











                      • Hmmm, there's no config variable in my answer code or in tapestry.el. (setq debug-on-error t) and get a stacktrace. That should indicate where the error is happening.

                        – Kyle Jones
                        Jan 29 '12 at 21:59











                      • Actually when I rerun it, I get set-tapestry: End of file during parsing error again. I opened a Emacs session, opened two frames, and loaded two different files in each of them, then M-x save-my-tapestry, then close it. Reopen Emacs, then do M-x load-my-tapestry RET, it gave set-tapestry: End of file during parsing.

                        – qazwsx
                        Jan 29 '12 at 22:05

















                      When I do M-x load-my-tapestry RET, I only got (New file) set-tapestry: End of file during parsing in mini-buffer and nothing loaded in the Emacs window.

                      – qazwsx
                      Jan 29 '12 at 18:03





                      When I do M-x load-my-tapestry RET, I only got (New file) set-tapestry: End of file during parsing in mini-buffer and nothing loaded in the Emacs window.

                      – qazwsx
                      Jan 29 '12 at 18:03













                      Run M-x save-my-tapestry once and the process should be bootstrapped.

                      – Kyle Jones
                      Jan 29 '12 at 21:00





                      Run M-x save-my-tapestry once and the process should be bootstrapped.

                      – Kyle Jones
                      Jan 29 '12 at 21:00













                      Did; then it gaves let: Wrong type argument: listp, config error in mini-buffer now.

                      – qazwsx
                      Jan 29 '12 at 21:44





                      Did; then it gaves let: Wrong type argument: listp, config error in mini-buffer now.

                      – qazwsx
                      Jan 29 '12 at 21:44













                      Hmmm, there's no config variable in my answer code or in tapestry.el. (setq debug-on-error t) and get a stacktrace. That should indicate where the error is happening.

                      – Kyle Jones
                      Jan 29 '12 at 21:59





                      Hmmm, there's no config variable in my answer code or in tapestry.el. (setq debug-on-error t) and get a stacktrace. That should indicate where the error is happening.

                      – Kyle Jones
                      Jan 29 '12 at 21:59













                      Actually when I rerun it, I get set-tapestry: End of file during parsing error again. I opened a Emacs session, opened two frames, and loaded two different files in each of them, then M-x save-my-tapestry, then close it. Reopen Emacs, then do M-x load-my-tapestry RET, it gave set-tapestry: End of file during parsing.

                      – qazwsx
                      Jan 29 '12 at 22:05





                      Actually when I rerun it, I get set-tapestry: End of file during parsing error again. I opened a Emacs session, opened two frames, and loaded two different files in each of them, then M-x save-my-tapestry, then close it. Reopen Emacs, then do M-x load-my-tapestry RET, it gave set-tapestry: End of file during parsing.

                      – qazwsx
                      Jan 29 '12 at 22:05


















                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Super User!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f383560%2fhow-to-restore-emacs-windows-and-buffers-from-the-last-session%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                      Mangá

                       ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕