Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow preceding whitespace #14

Open
JohnLunzer opened this issue Apr 5, 2018 · 6 comments
Open

allow preceding whitespace #14

JohnLunzer opened this issue Apr 5, 2018 · 6 comments

Comments

@JohnLunzer
Copy link

Is there any way to allow preceding whitespace before headlines?

I'm having some issues getting my outlines working properly in Python because in Python there is a lot of indentation.

Any advice?

@alphapapa
Copy link
Owner

IIRC this is a matter of outline-minor-mode and the associated regexp-containing variables that match commented outline headings. You can experiment with them in your config, try adding optional whitespace matchers, etc. Of course, you'll have to avoid matching newlines. ISTR that it gets pretty messy. Anyway, AFAIK it's not related to Outshine itself.

@kepi
Copy link

kepi commented Oct 15, 2018

I tried to play around it for some time but without any success. I'm not sure if I want same thing as @JohnLunzer but I think so :)

If you see screenshot bellow, what I want is TAB do outline-cycle on both headings, Layers and Enter layers bellow one. It is working as supposed on Layers as it is starting at the beginning of line, but only runs indent-relative when not.

outshine_heading_space

I belive that this behaviour is intentional as documented in outline-cycle. But it would be great if it would work when I have cursor placed after comments or maybe just cycle outline after indent-relative is called (would be probably best).

You can see in screenshot, that faces are working and it is displayed as it should, but cycle is not working.

If this is related to regexp, can you help me with pointing out which one? I was trying to play with outline-regexp but its buffer local variable and different for every mode.

@alphapapa
Copy link
Owner

alphapapa commented Oct 15, 2018

If this is related to regexp, can you help me with pointing out which one? I was trying to play with outline-regexp but its buffer local variable and different for every mode.

It's complicated. IIRC there are two regexps, one for matching outline headings and one for determining heading levels. You'll have to dig into the outline-mode code. Anyway, AFAIK it's not related to Outshine.

It might be better to look into alternative outline packages, like Origami.

@johnbcoughlin
Copy link

Based on my reading of the code, it seems that outshine is building the outline-regexp and outline-level string and function for each major mode:

;;;;; Calculate outline-regexp and outline-level

It then chomps off the leading whitespace from the computed regexp:

(defun outshine-normalize-regexps ()
  "Chomp leading and trailing whitespace from outline regexps."
  (and comment-start
       (setq outshine-normalized-comment-start
             (if outshine-preserve-delimiter-whitespace
                 comment-start
               (outshine-chomp comment-start))))
  (and comment-end
       (setq outshine-normalized-comment-end
             (outshine-chomp comment-end)))
  (and outshine-regexp-base
       (setq outshine-normalized-outline-regexp-base
             (outshine-chomp outshine-regexp-base))))

So it seems like this is within outshine. It would be great if it were possible to use preceding whitespace, because in a language like Rust, the rustfmt utility will indent comments to the current indentation level, which makes them invalid as outline headings.

@henrymazza
Copy link

henrymazza commented Apr 25, 2020

Looks like a outline-mode problem. Outshine recognizes indented headings, it even highlights it. But outline-hide-subtree that don't behaves well.

I tried to change outline-regexp but not luck at all. But i'm no expert...

@alphapapa
Copy link
Owner

Based on my reading of the code, it seems that outshine is building the outline-regexp and outline-level string and function for each major mode:

It then chomps off the leading whitespace from the computed regexp:

So it seems like this is within outshine. It would be great if it were possible to use preceding whitespace, because in a language like Rust, the rustfmt utility will indent comments to the current indentation level, which makes them invalid as outline headings.

[...one year later...]

Thanks. The interaction and overlap between outshine-mode and outline-minor-mode is a source of confusion. Ideally Outshine should reuse as much functionality that's built-in to Emacs as possible.

For that reason, I'd still recommend trying to fix this in outline-minor-mode. If it's not possible to use regexps with leading whitespace with outline-minor-mode, I'd suggest raising that on the emacs-devel mailing list, or just filing an Emacs bug report.

Then we should try to make Outshine reuse that functionality rather than redefining its own regexps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants