jdtsmith / outli

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

make fontification optional #4

Closed tpeacock19 closed 1 year ago

tpeacock19 commented 1 year ago

I think it would be useful to allow for the fontification settings to be optional. I currently use modus-themes and the modus-themes-headings variable is already applied to the outline-minor-mode faces outline-{1-8}, thus, I don't need the fontification options of outli.

In fact, I think the style options can be applied to these faces and you would not need to use your regexp-based function outli-fontify-headlines

jdtsmith commented 1 year ago

Did you try STYLE?

- optional STYLE: If the symbol 'none, no styling of any kind is
  applied to headings.  If otherwise non-nil, the stem and repeat
  character parts of the heading both get identical stem-styling.

Can you provide a screen shot with modus (only) styling?

tpeacock19 commented 1 year ago

I did eventually use style. Though it only worked when I set it to (emacs-lisp-mode ";;" ?\; none). Though, I cannot tell you why it would not work when quoted.

I guess my request is more simply that outli-mode has optional features (the fontification and/or speed keys) that are opt-in rather than opt-out. However, I understand that it's your package so you can be as opinionated as you want.

Additionally, it may be much simpler to leverage the faces included in outline-minor-mode with (setq outline-minor-mode-highlight t).

2023-03-08T20:17:48,771885176-07:00 2023-03-08T20:18:37,973129966-07:00 2023-03-08T20:19:59,873665511-07:00

jdtsmith commented 1 year ago

How did you set it? If you set via customize an outer single quote is implicit.

I personally want style to match org headers so I don't have to think. And I like to have comments 'char face shine through in stem. Is the real issue that style='none was too hard to find in the docs?

tpeacock19 commented 1 year ago

If you set via customize an outer single quote is implicit.

I evaluated the form in the screenshots. The two examples are above. Whether I set with lisp directly or through customize, it does not seem to work. Does setting it to (emacs-lisp-mode ";;" ?\; none) with setq work for you?

I personally want style to match org headers so I don't have to think.

You could accomplish this with (custom-set-faces '(outline-1 ((t (:inherit org-level-1))))).

Is the real issue that style='none was too hard to find in the docs?

No, I just expected a global variable to control the styling, and when it did not work with setting the value to 'none, I grew impatient and simply incorporated the outli-heading-config/outline-heading-alist logic to my personal config.

jdtsmith commented 1 year ago

I evaluated the form in the screenshots.

It does not live update; perhaps you were evaluating in an open buffer, and didn't toggle outline-mode? I have added a note mentioning this.

I just expected a global variable to control the styling

I see. I will consider adding a global style disable for people in your situation.

tpeacock19 commented 1 year ago

It does not live update; perhaps you were evaluating in an open buffer, and didn't toggle outline-mode? I have added a note mentioning this.

No, I know how to toggle modes. I would like if you at least attempted to try setting it with lisp instead of customize. It happens with emacs -Q as well. Thanks anyway.

jdtsmith commented 1 year ago

@tpeacock19 you have two quotes on 'none, an outer and inner. As a result, the symbol you are setting STYLE to is 'none, not (as expected) none. Quoting rules in emacs can be confusing, but this is likely your problem. Also, screenshots are not very useful for evaluating snippets; consider wrapping them in ```elisp...``` for easier evaluation.

tpeacock19 commented 1 year ago

You asked for the screenshot. And the docstring says the symbol 'none. But I don't use this package so no help is necessary.

jdtsmith commented 1 year ago

OK, I have implemented two default custom variables which, if non-nil, globally override the settings in outli-heading-config . See outli-default-style and outli-default-nobar. Give a try.

brongulus commented 1 year ago

Thanks for the quick fix, can confirm outli-default-nobar is working.

jdtsmith commented 1 year ago

@brongulus great! @tpeacock19 My only point is that screenshots are useful to see style, but not for evaluating code. There is definitely ambiguity in how to specify quoted symbols in emacs; I've changed the docs for now (but have seen people get confused in the past because of the missing ', so we'll see). In general, I always assume symbols do not start with punctuation and haven't run into counter-examples.

tpeacock19 commented 1 year ago

The main issue is that quoting none in your outli-heading-config defcustom is incorrect.

(choice :tag "Style"
        (const :tag "No Styling" 'none)
        (const :tag "Uniform Style" t)
        (const :tag "Default Style" nil))

At least when testing it now, if I use customize to set the emacs-lisp-mode style to 'No Styling' it shows up as:

`((emacs-lisp-mode ";;" 59 'none nil)
 (tex-mode "%%" 37 t nil)
 (org-mode)
 (t
  (let*
      ((c
        (or comment-start "#"))
       (space
        (unless
            (eq
             (aref c
                   (1-
                    (length c)))
             32)
          " ")))
    (concat c space))
  42 nil nil))

Which, will not result in disabling the styling, since you are comparing it to a standard 'none symbol in outli-fontify-headlines with (eq style 'none). You don't do in the newer outli-default-style so I imagine it was just a typo. Fixing that would help anyone using customize to try to disable styling.

‘(const VALUE)’ The value must be VALUE—nothing else is allowed.

 The main use of ‘const’ is inside of ‘choice’.  For example,
 ‘(choice integer (const nil))’ allows either an integer or ‘nil’.

 ‘:tag’ is often used with ‘const’, inside of ‘choice’.  For
 example,

      (choice (const :tag "Yes" t)
              (const :tag "No" nil)
              (const :tag "Ask" foo))

 describes a variable for which ‘t’ means yes, ‘nil’ means no, and
 ‘foo’ means “ask”.

Info (elisp) Composite Types

jdtsmith commented 1 year ago

The main issue is that quoting none in your outli-heading-config defcustom is incorrect

Aha, so defcustom was promoting 'none afterall! Thanks very much, fixed.