jdtsmith / outli

Simple comment-based outline folding for Emacs
GNU General Public License v3.0
104 stars 6 forks source link

Add option for reversing heading order. #6

Closed gajama closed 1 year ago

gajama commented 1 year ago

Add 2 new local-vars, 'outli-heading-levels' (default 8) and 'outli-headings-reverse' (default nil). 'outli-heading-levels' controls how many levels are added to 'outline-heading-alist' and processed by 'outli-font-lock-keywords'. 'outli-headings-reverse' makes more importnat headings take longer strings, reversing the usual style.

For example, with outli-heading-levels set to 4, and 'outli-headings-reverse' to t you get the following:

level 1 ;;;;;; , level 2 ;;;;; , level 3 ;;;; , level 4 ;;;

Also, set 'outline-heading-alist' to nil before generating it, so multiple versions of heading levels aren't added if outli-mode is toggled.

gajama commented 1 year ago

Hi, another one!

My personal preference in elisp files is for higher level headings to have more semicolons rather than fewer. I know this is maybe odd, and contrary to convention and recommended style, but I think it looks better, and makes a natural progression down to ;; for non-header comments and ; for inline comments. However, I'll understand if you don't want to merge this, or only keep the 'outli-heading-levels' variable.

jdtsmith commented 1 year ago

Interesting. The large body of elisp files, for example, use "golf rules", for the obvious reason: if you ever want to go "one more level" you are out of luck, whereas I could increase from 8 to 10 and everything will just work. But I think we should be able to support this style. Can you share a screenshot?

gajama commented 1 year ago

Contrived example. I wouldn't normally split things up quite this much!

reverse headings outli

It is less flexible, but i've got a function that converts a buffer from one to the other, so I guess I could use that, insert a new level of heading, and convert back. To be honest, 4 levels have been enough in all the elisp files I've used this format in so far. If I was going to write a more complicated, or deeply nested document, I'd probably use Org. I don't mind the stars in Org.

It's only really (e)lisp, where the comment character is also the natural heading marker, that I like it this way round. Otherwise, I think my brain wants to read comments with ";;" as more important than ";;;" .

In languages with c-like block comments I'd go for /**, /***, etc. enclosing the heading

jdtsmith commented 1 year ago

Nice colors. I will consider a reversed variable along with max depth, since even without the former, reducing the latter will yield to some (probably immeasurable) gains in font-locking speed.

i've got a function that converts a buffer from one to the other

The problem isn't really your own files, but when you want to contribute to say one of minad's package, or emacs-core; you have to adapt to their standard, and can't reverse it. I'm not sure the language really matters, e.g. python # *****

gajama commented 1 year ago

If I was contributing, I'd use the conventional way, or my converter function.

You need the reversed variable to make outline mode work correctly, I think.

On Fri, 10 Mar 2023 at 17:31, JD Smith @.***> wrote:

Nice colors. I will consider a reversed variable along with max depth, since even without the former, reducing the latter will yield to some (probably immeasurable) gains in font-locking speed.

i've got a function that converts a buffer from one to the other

The problem isn't really your own files, but when you want to contribute to say one of minad's package, or emacs-core; you have to adapt to their standard, and can't reverse it. I'm not sure the language really matters, e.g. python # *****

— Reply to this email directly, view it on GitHub https://github.com/jdtsmith/outli/pull/6#issuecomment-1464136686, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADG3SHGRGFME6Y2FNYJJ7FLW3NQQXANCNFSM6AAAAAAVVZHVPU . You are receiving this because you authored the thread.Message ID: @.***>

gajama commented 1 year ago

Hi, I've abandoned this. Headline promotion/demotion wasn't working correctly, and I also worked out, if I did want to do this, I could do it easily enough without changing Outli code. But I've found that setting appropriate font sizes on the headings works well enough for me not to have the extra hassles of reversing the headings.

jdtsmith commented 1 year ago

Thanks for letting me know.