Tohiko · 2022-06-18 10:23
I use `use-package` extensively with all the different "sections". This has becomes cumbersome quite quickly and I find it hard to navigate to the different sections (`:config, :custom, :init`.. etc).
Is there an easy way to highlight the lines where these keywords appear? Even better, is there an easy way to implement collapsing/expanding these sections?
Horrih · 2022-06-18 11:12
Built in Outline mode helps you define a regexp for sections with increasing indentation. It then applies faces to the sections heading, similar to org mode. It was actually an inspiration for org mode
Those sections are collapsible with tab like in org mode
So here you should define a regexp that matches use-package as section heading and the various keywords as sub headings
Try to configure it and change the face as you want to highlight those.
I use the melpa package outline-minor-faces for nice looking faces for outline mode.
See my config [here](https://github.com/Horrih/config/blob/main/.emacs) line 400ish
Other interesting packages : highlight mode for highlighting regexps, hide show mode to fold balanced expressions. Both are built in, and you could probably achieve a similar result
vifon · 2022-06-18 11:19
If you have these sections indented, you can use the built-in `C-x $` (`set-selective-display`) for that. That's one of the reasons I still keep all my sections as a single sexp (with `progn`) even though `use-package` started supporting more sexps between keywords.
WallyMetropolis · 2022-06-18 12:50
Another option is [origami](https://github.com/gregsexton/origami.el) mode which folds text or code in various languages, or just by indentation level. So if wrap each section in a sexp, you can use elisp folding. Or if you indent each section below the use-package keywords, you can fold each of those keywords.
​
It'll also give you folding elsewhere, so that's neat.
diamondnbond · 2022-06-18 13:37
org-narrow-to-subtree might be what you're looking for (C-x n s), to widen view use C-x n w.
Edit
Forgot to mention this only works if you're following the literate approach to configuration.
Tohiko · 2022-06-18 13:50
This looks promising. I will give it a shot
_viz_ · 2022-06-18 15:30
C-x n d might work regardless. C-x n p is also nice but you would have to spam the file with ^L for OP.