reddit / emacs

outli – simple outliner mode with org-like interaction for code, documents, etc.

JDRiverRun · 2022-09-16 22:07
[outli](https://github.com/jdtsmith/outli) is a simple outliner mode based on the built-in outline-minor-mode which makes it easy to outline, fold, navigate, and restructure your code, documents, or other buffers. It offers nice headline styling, org-like speed-keys, imenu support, and more. If you've used outshine, it's inspired by and similar to that, but *much* simpler: * More focused: 1/30th the LOC * Better default headline styling (IMO) * Automatic and easy to configure headline prefix patterns, which can be different per mode * Adds only one buffer-wide binding (`Shift-Tab`, for headline cycling) * Close adherence to org speed-key bindings Note that [outshine](https://github.com/alphapapa/outshine) also supports editing of comment-blocks-as-org-syntax (via outorg) and many other legacy features.
lebensterben · 2022-09-16 22:24
I use outshine so I'm wandering what's the main differences?
JDRiverRun · 2022-09-16 22:33
I was an outshine user too, but I didn't use most of its functionality, wanted better headline styling, found that its key bindings got in my way sometimes, wanted my org-speed-key muscle memory to transfer over, and wanted to configure different heading styles in different modes. I did submit a PR along these lines but I believe outshine isn't maintained by its original author anymore. If you are happy with outshine or use any of its more advanced features, you should likely stick with it.
lebensterben · 2022-09-16 22:44
Honestly I don't know what are the advanced features. Most of time I only need navigation across headings, promote/demote heading level, and moving "subtree".
_viz_ · 2022-09-17 02:30
Which are already provided by outline-mode.
lebensterben · 2022-09-17 02:37
I don't think these are available in outline-mode: https://github.com/alphapapa/outshine/blob/bf1eed10dd7a89b63d0fc014944033db397c1e23/outshine.el#L2425-L2436
_viz_ · 2022-09-17 02:46
They are.
lebensterben · 2022-09-17 02:51
what are they?
JDRiverRun · 2022-09-17 15:41
Yes outline-mode has grown some capabilities over time, notably simple visibility cycling. So some of what outshine does, the built-in outline can do by itself now. outli is so simple because it works as a front-end to outline-minor-mode, calling functions (from the speed-key help): Speed commands ============== Outline Navigation ------------------ n outline-next-visible-heading p outline-previous-visible-heading f outline-forward-same-level b outline-backward-same-level u outline-up-heading Outline Visibility ------------------ c outline-cycle C outline-cycle-buffer s outli-toggle-narrow-to-subtree h outline-hide-sublevels 1 (outline-hide-sublevels 1) 2 (outline-hide-sublevels 2) 3 (outline-hide-sublevels 3) 4 (outline-hide-sublevels 4) 5 (outline-hide-sublevels 5) Outline Structure Editing ------------------------- U outline-move-subtree-up D outline-move-subtree-down r outline-demote l outline-promote i outli-insert-heading-respect-content @ outline-mark-subtree ? outli-speed-command-help You can see outline-promote/demote there, so those can be used as-is without any extra mode (though the default key bindings are atrocious). outli adds a few things like `narrow-to-subtree` and `insert-heading-respect-content` (ala org). And of course the speed-key bindings, automatic *comments-as-header* patterns, and styling.
lebensterben · 2022-09-17 16:59
🙏 thx
myme · 2022-09-17 21:14
Nice, I like the look and the ergonomics of the speed keys. One question, it doesn't seem to work well with `markdown-mode` – I tried adding this `outli-heading-config`: `(markdown-mode "#" ?# t)`. Probably not surprising, because `markdown-mode` comes with its own visibility cycling functionality which interferes here. Any tips how to get it to work editing markdown files? Is there a simpler markdown mode maybe?
JDRiverRun · 2022-09-17 22:15
Yeah modes that also try to control headings themselves can be an issue. You could of course use it with separate markdown *comments* as an additional organizational level to markdown headings... but that might be repetitive and... not what you want. If you want outli to control the headings you could disable markdown's Tab key and header styling, like (before enabling the mode, e.g. in a use-package *:config*): (define-key markdown-mode-map (kbd "TAB") nil) Note you will also want the stem to be the blank string "", or else your top level heading will be `##`. For styling, markdown-mode is styling the header itself, which will lead to some oddities. You can tell outli not to do *any* styling with the new `'none` flag in the config, and leave it to markdown. Or, alternatively, you can tell markdown not to do any header styling with: (cl-delete '(markdown-fontify-headings) markdown-mode-font-lock-keywords :test 'equal)
c256 · 2022-09-17 22:20
As soon as you feel comfortable, consider submitting/reworking it as an enhancement to outline-mode. (“as soon as…” meaning anything from “right now” to “after you’ve had it in the wild for a while”, etc.) Emacs-devel is happy to enhance the built-in functionality, especially if it’s simpler (and also “simpler than Org”, which is a great benefit but also a pretty hefty package). You’d need to be able and willing to assign copyright, but beyond that, the process is **much** easier now than it has been in the past.
TiMueller · 2022-09-18 06:39
I'd love to try out Outli. But I do not understand how to give information to your variable outli-heading-config. Is it a string? Do I use setq like: (setq outli-heading-config "t \* \*") If I try `(setq outli-heading-config '(t "*" "*")` I get the error: Wrong type argument, listp t. An example would help a non-programmer like me a lot. Thank you in advance!
myme · 2022-09-18 10:58
Thanks - it turns out outline-mode works good enough even without deleting the Tab keybinding, at least when point is at the beginning of the headline. Maybe I just didn't try that before. But deleting the keybinding is even better of course, because then Tab cycling also works from anywhere on the headline. The tip to configure blank string for stem might have contributed too. Currently still experimenting with your suggestions for styling. The `'none` flag seems to be the most appropriate for markdown-mode at first, since it comes with its own styling preferences. However, then the colors of the overbars do not match the colors of the headline. I think I'll therefore prefer outli-mode's styling.
JDRiverRun · 2022-09-18 14:24
I added a new [FAQ](https://github.com/jdtsmith/outli#faq) mentioning the structure. But easiest is just `M-x customize-group outli`! Also, try with the defaults: it may already work how you expect.
JDRiverRun · 2022-09-18 14:31
You can also disable the overline if you want; see the [FAQ](https://github.com/jdtsmith/outli#faq). One other point on the `Tab` binding: if you can arrange to have `outli-mode` loaded *before* `markdown-mode`, it's keymap will "win" on headlines, and markdown's will work everywhere else. That's probably a better solution.
Lucaskek · 2022-09-19 05:28
I was having problems with my config very recently, I took me a stupid long time to realize that outshine was loading an older version of orgmode before straight I needed this man
TiMueller · 2022-09-20 06:56
Thank you for adding the new FAQ! That helped. Now I tried both, getting it to work with the defaults, and setting my own outli-heading-config. While I am not getting errors anymore for the customizing, still it doesn't seem to find what is a heading and what isn't. So sorry! I seem to be too much of a noob to get it running. As I am using Doom, I cannot use the configuration example with :hook, but I set the hook like this: (add-hook 'text-mode-hook (lambda () (outli-mode 1))) Now, this seems to get my org-mode into difficulties (I would neet outli to work in one buffer, while working with org-mode in another buffer). There are errors like: Error running timer ‘org-reveal’: (user-error "Before first headline at position 15921 in buffer Aufgaben.org") org-back-to-heading: Before first headline at position 24072 in buffer Emacs.org If I take out the hook command in my config.el and start outli-mode by hand, it doesn't work either. `outline-hide-sublevels` doesn't work any longer, and `outli-insert-heading-respect-sublevels` says "Before first heading", regardless of where I am. To me it seems like it doesn't know what is a heading. All this with default settings. If I try my own, it's all the same. This is how I try the settings in the second run: (setq outli-heading-config '((MAJOR-MODE . 'text-mode) (STEM . "*") (REPEAT-CHAR . ?*) (STYLE . nil) (NO-BAR . T))) I don't want to steal your time. But if you have another idea what I am doing wrong, I would like to give it a try.
JDRiverRun · 2022-09-20 13:26
Did you try the customize interface? I think you'll find that much easier. A valid alist will look like `'((text-mode "##" ?* nil t))`. Even though it doesn't look like it, that inner thing is an element of an alist. A surprising fact for new elispers: a list is *also* a cons cell (try `M-: (consp '(foo bar baz))`. Also, you definitely don't want *outli* to be active with org.
TiMueller · 2022-09-21 14:07
Thank you for the alist example! I took it for setting `outli-heading-config`. Doom doesn't support `customize`, but I enabled it to check wether outli-heading-config got the right values from the config.el, and it did. Still, `outline-cycle` and other commands do not work, also `outli-insert-heading-respect-sublevels` says "Before first heading". It seems to me it doesn't recognize my headings. By the way, I have to use M-x to try out the commands, because I do not use evil. Your commands in outli depend on evil, right? I would have to define new keybinds to use them. Which I would gladly do. But my Doom-without-evil doesn't seem to work well with outli, regrettably.
JDRiverRun · 2022-09-21 14:52
\> Your commands in outli depend on evil, right? No. Just like org-mode's speed keys, the outli speed keys work *only* at the beginning of a headline. You can check `C-h v outline-regex` to see how outli has configured it and whether it should match your headings.