I am using web-mode
to fold/unfold code. When I fold code, kill buffer and re open it, code folding disappears.
How to preserve code folding even after killing and reopening buffer?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityI am using web-mode
to fold/unfold code. When I fold code, kill buffer and re open it, code folding disappears.
How to preserve code folding even after killing and reopening buffer?
I've tried Vimish fold, and it seems to do what you ask. Below is my setup for the keybindings:
(require 'vimish-fold)
(vimish-fold-global-mode 1)
;; this registers a region for future folding/unfolding
(global-set-key (kbd "C-c v") #'vimish-fold)
;; this unregisters the region under point from folding/unfolding
(global-set-key (kbd "C-c d") #'vimish-fold-delete)
;; this is the actual fold/unfold command
(global-set-key (kbd "C-c t") #'vimish-fold-toggle)
I think Mark is the author of this mode, so, maybe he'll chime in and write something about it too.
M-: (vimish-fold--kill-emacs-hook)
. But there are few other things about saving folds that I personally don't like: 1. huge file names for the files where folds info is recorded. 2. foldining info isn't recorded for killed buffers. I'll put an fr in the bug tracker for this.
– wvxvw
Oct 8 '15 at 14:42
org-struct
mode (allows you to use comments in other modes to embed Org-like headings which you can then collapse and expand) and hide-show
minor mode, which is the basic folding, except it doesn't have the option to save the folding either.
– wvxvw
Oct 8 '15 at 14:51