alphapapa / burly.el

Save and restore frames and windows with their buffers in Emacs
GNU General Public License v3.0
301 stars 14 forks source link

[Feature Request] burly-open-last-bookmark can cross session. #48

Open zw963 opened 2 years ago

zw963 commented 2 years ago

That is, it can restore the last bookmark which i saved in current emacs session.

e.g.

before restart emacs, i save to bookmark1, then reboot emacs

when i restart emacs, then run bury-open-list-bookmark, i expected i can restore previous bookmark1 immedately.

For how to use this feature .e.g. i can add a hook like this:

(if (and (fboundp 'daemonp) (daemonp))
    (add-hook 'after-make-frame-functions 'burly-open-last-bookmark t)
  )

When my emacs restart, will open previous bookmark automatically.

Thank you.

ssl19 commented 2 years ago

You can use savehist-mode 😃

(savehist-mode)
(bookmark-maybe-load-default-file)
(defun my/burly-savehist-integration ()
  (when (bound-and-true-p burly-opened-bookmark-name)
    (setq burly-opened-bookmark-name
          (substring-no-properties burly-opened-bookmark-name))))
(add-hook 'savehist-save-hook #'my/burly-savehist-integration)
(add-to-list 'savehist-additional-variables 'burly-opened-bookmark-name)
gsingh93 commented 1 year ago

@ssl19 thanks for that snippet! Can you explain what the purpose of my/burly-savehist-integration is? Shouldn't saving and restoring burly-opened-bookmark-name work fine without it?

ssl19 commented 1 year ago

According to savehist-additional-variables The contents of variables should be printable with the Lisp printer.

You could try yourself to see the difference :)

alphapapa commented 1 year ago

This seems like a good idea. It would probably be sufficient to make the variable a defcustom and save its value when necessary. (Probably, an idle timer should be used, because saving all of the customize options can cause a noticeable delay.)