* Making outline-minor-mode's outline-regexp more flexible
@ 2018-12-29 4:15 Mark Edgington
2018-12-29 7:25 ` Eli Zaretskii
2018-12-29 21:28 ` Juri Linkov
0 siblings, 2 replies; 8+ messages in thread
From: Mark Edgington @ 2018-12-29 4:15 UTC (permalink / raw)
To: emacs-devel
Currently when using outline-minor-mode, the outline-regexp variable
defines a regexp used to match headlines. The way that it is
currently treated is that the entirety of the match is considered part
of the headline. The problem with this is that
it prevents specifying headlines in this way:
// * first headline
if (foo) {
// ** second headline
...
}
Instead, in order for org-mode like features (e.g.
promoting/demoting/folding/moving headlines) to work, all headlines
currently are assumed to start at the first column -- there can't be
any preceding whitespace, because such whitespace is treated as part
of the headline, and affects the outline depth of the headline. Having
the headline start at the first column can reduce the readability of
the code that it is placed in.
One way this could be improved is by making it so that if
outline-regexp contains a group to be matched, then only the text
matched by the group determines the outline depth, instead of the text
matched by the full regular expression.
Would there be issues with changing the meaning of outline-regexp in
this way? If so, would it be possible to add an auxiliary variable
that determines how the regexp is to be interpreted?
What do you all think? I don't suspect that the implementation of
this would be too much work, and the benefit of being able to have
indented headlines might be worthwhile. This is especially important
when collaborating on code with others who aren't using emacs.
Regards,
Mark
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Making outline-minor-mode's outline-regexp more flexible
2018-12-29 4:15 Making outline-minor-mode's outline-regexp more flexible Mark Edgington
@ 2018-12-29 7:25 ` Eli Zaretskii
2018-12-29 21:28 ` Juri Linkov
1 sibling, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2018-12-29 7:25 UTC (permalink / raw)
To: Mark Edgington; +Cc: emacs-devel
> From: Mark Edgington <edgimar@gmail.com>
> Date: Fri, 28 Dec 2018 23:15:52 -0500
>
> Would there be issues with changing the meaning of outline-regexp in
> this way? If so, would it be possible to add an auxiliary variable
> that determines how the regexp is to be interpreted?
If we think there might be issues with a change, adding a variable to
control that change is TRT (and should be in NEWS). Whether to make
the new behavior the default is a separate question.
Thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Making outline-minor-mode's outline-regexp more flexible
2018-12-29 4:15 Making outline-minor-mode's outline-regexp more flexible Mark Edgington
2018-12-29 7:25 ` Eli Zaretskii
@ 2018-12-29 21:28 ` Juri Linkov
2018-12-30 2:24 ` Mark Edgington
1 sibling, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2018-12-29 21:28 UTC (permalink / raw)
To: Mark Edgington; +Cc: emacs-devel
> Would there be issues with changing the meaning of outline-regexp in
> this way? If so, would it be possible to add an auxiliary variable
> that determines how the regexp is to be interpreted?
I have been able to use the variable outline-level to do what you want
by adding a group to outline-regexp and subtracting its matched beginning
in outline-level.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Making outline-minor-mode's outline-regexp more flexible
2018-12-29 21:28 ` Juri Linkov
@ 2018-12-30 2:24 ` Mark Edgington
2019-01-02 1:59 ` Stefan Monnier
0 siblings, 1 reply; 8+ messages in thread
From: Mark Edgington @ 2018-12-30 2:24 UTC (permalink / raw)
To: Juri Linkov; +Cc: emacs-devel
> I have been able to use the variable outline-level to do what you want
> by adding a group to outline-regexp and subtracting its matched beginning
> in outline-level.
Ok, that is a valid way to do it (maybe the only way?), but it
requires writing a custom function to perform the regexp matching and
subtract its size. Perhaps it would be nice to provide a predefined
function in outline.el that can be used to generate an outline-level
function -- this higher-order function would take one argument, a
group number, and would return a function that returns the size of the
text matching the specified group in outline-regexp. Thoughts?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Making outline-minor-mode's outline-regexp more flexible
2018-12-30 2:24 ` Mark Edgington
@ 2019-01-02 1:59 ` Stefan Monnier
0 siblings, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2019-01-02 1:59 UTC (permalink / raw)
To: emacs-devel
>> I have been able to use the variable outline-level to do what you want
>> by adding a group to outline-regexp and subtracting its matched beginning
>> in outline-level.
> Ok, that is a valid way to do it (maybe the only way?), but it
> requires writing a custom function to perform the regexp matching and
> subtract its size.
I don't see why outline-level would need to do any matching.
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Making outline-minor-mode's outline-regexp more flexible
@ 2019-01-09 2:52 Mark Edgington
2019-01-09 2:56 ` Mark Edgington
2019-01-09 3:10 ` Stefan Monnier
0 siblings, 2 replies; 8+ messages in thread
From: Mark Edgington @ 2019-01-09 2:52 UTC (permalink / raw)
To: monnier; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 185 bytes --]
> I don't see why outline-level would need to do any matching.
How would you compute the outline level of 2 for " // ***", and level
3 for both " // ****" and ” // ****”?
[-- Attachment #2: Type: text/html, Size: 259 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Making outline-minor-mode's outline-regexp more flexible
2019-01-09 2:52 Mark Edgington
@ 2019-01-09 2:56 ` Mark Edgington
2019-01-09 3:10 ` Stefan Monnier
1 sibling, 0 replies; 8+ messages in thread
From: Mark Edgington @ 2019-01-09 2:56 UTC (permalink / raw)
To: monnier; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 295 bytes --]
>
> > I don't see why outline-level would need to do any matching.
>
> How would you compute the outline level of 2 for " // ***", and level 3 for both " // ****" and ” // ****”?
>
> I guess you can strip off whitespace on the left, but there may cases
where it isn't so simple.
[-- Attachment #2: Type: text/html, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Making outline-minor-mode's outline-regexp more flexible
2019-01-09 2:52 Mark Edgington
2019-01-09 2:56 ` Mark Edgington
@ 2019-01-09 3:10 ` Stefan Monnier
1 sibling, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2019-01-09 3:10 UTC (permalink / raw)
To: emacs-devel
>> I don't see why outline-level would need to do any matching.
> How would you compute the outline level of 2 for " // ***", and level
> 3 for both " // ****" and ” // ****”?
Based on the match-data: when outline-level is called, outline-rege3xp
has just been matched, as described in C-h v outline-level:
Function of no args to compute a header’s nesting level in an outline.
It can assume point is at the beginning of a header line and that the match
data reflects the ‘outline-regexp’.
-- Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-01-09 3:10 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-29 4:15 Making outline-minor-mode's outline-regexp more flexible Mark Edgington
2018-12-29 7:25 ` Eli Zaretskii
2018-12-29 21:28 ` Juri Linkov
2018-12-30 2:24 ` Mark Edgington
2019-01-02 1:59 ` Stefan Monnier
-- strict thread matches above, loose matches on Subject: below --
2019-01-09 2:52 Mark Edgington
2019-01-09 2:56 ` Mark Edgington
2019-01-09 3:10 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).