GNU bug report logs -
#48724
Code collapsing and outline headings for elisp
Previous Next
To reply to this bug, email your comments to 48724 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48724
; Package
emacs
.
(Fri, 28 May 2021 21:00:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Christopher Dimech <dimech <at> gmx.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 28 May 2021 21:00:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Currently, outline-minor-mode has the capability to treat "defun" constructs
as heading, allowing one to choose to hide some code from view by collapsing
the region of code. It would be beneficial for the actual major mode itself
(i.e. emacs-lisp-mode) to handle the code collapsing, leaving the code highlighting
intact. Code collapsing could also be extended beyond not only collapsing
functions and variables ((defun, defvar), but also to additional constructs that could
be indented (e.g. lists '(...), let, let*, pcase) and other constructs users could
find useful (e.g. if, when, ).
And for outline-minor-mode, the mode could then be used to further enhance the structuring
of larger chunks of code (e.g. a collection of functions) using outline headings. Outlining
would then be a separate capability different from code collapsing.
Regards
Christopher
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48724
; Package
emacs
.
(Sat, 29 May 2021 22:16:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 48724 <at> debbugs.gnu.org (full text, mbox):
> Currently, outline-minor-mode has the capability to treat "defun" constructs
> as heading, allowing one to choose to hide some code from view by collapsing
> the region of code. It would be beneficial for the actual major mode itself
> (i.e. emacs-lisp-mode) to handle the code collapsing, leaving the code highlighting
> intact. Code collapsing could also be extended beyond not only collapsing
> functions and variables ((defun, defvar), but also to additional constructs that could
> be indented (e.g. lists '(...), let, let*, pcase) and other constructs users could
> find useful (e.g. if, when, ).
>
> And for outline-minor-mode, the mode could then be used to further enhance the structuring
> of larger chunks of code (e.g. a collection of functions) using outline headings. Outlining
> would then be a separate capability different from code collapsing.
Currently everything is customizable in outline-minor-mode by just
two variables: outline-regexp and outline-level. So when necessary,
emacs-lisp-mode could provide an option that will set different values
of these variables, one of which could set outline-regexp to a regexp
that matches: lists, '(...), let, let*, pcase, if, when, etc…
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48724
; Package
emacs
.
(Sat, 29 May 2021 23:56:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 48724 <at> debbugs.gnu.org (full text, mbox):
> Sent: Sunday, May 30, 2021 at 9:57 AM
> From: "Juri Linkov" <juri <at> linkov.net>
> To: "Christopher Dimech" <dimech <at> gmx.com>
> Cc: 48724 <at> debbugs.gnu.org
> Subject: Re: bug#48724: Code collapsing and outline headings for elisp
>
> > Currently, outline-minor-mode has the capability to treat "defun" constructs
> > as heading, allowing one to choose to hide some code from view by collapsing
> > the region of code. It would be beneficial for the actual major mode itself
> > (i.e. emacs-lisp-mode) to handle the code collapsing, leaving the code highlighting
> > intact. Code collapsing could also be extended beyond not only collapsing
> > functions and variables ((defun, defvar), but also to additional constructs that could
> > be indented (e.g. lists '(...), let, let*, pcase) and other constructs users could
> > find useful (e.g. if, when, ).
> >
> > And for outline-minor-mode, the mode could then be used to further enhance the structuring
> > of larger chunks of code (e.g. a collection of functions) using outline headings. Outlining
> > would then be a separate capability different from code collapsing.
>
> Currently everything is customizable in outline-minor-mode by just
> two variables: outline-regexp and outline-level. So when necessary,
> emacs-lisp-mode could provide an option that will set different values
> of these variables, one of which could set outline-regexp to a regexp
> that matches: lists, '(...), let, let*, pcase, if, when, etc…
The general impression is that outline-minor-mode is a general mode
for customisable headings that are then handled by the respective
major mode.
General settings could be better, because some variables are not customizable.
Serious problem is that the two important variables: `outline-regexp' and
`outline-heading-alist' are not customizable by using "M-x customize-group".
Additionally both of them should be customizable per mode. Don't you think so?
There has been a discussion today about outline-minor-mode settings for fortran
(both fixed and free form). Have had a go at using "!" and "!!", but "Hide Body"
did not hide the body.
There could be some default headings for fortran when outline-minor-mode is enabled.
One could follow the current setup for emacs-lisp-mode, for fortran.
!! for heading level 1
!!! for subheading level 2
!!!! for subsubheading level 3
Together with "Hide Body" for lines beginning with "subroutine" and "function".
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48724
; Package
emacs
.
(Sun, 30 May 2021 01:39:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 48724 <at> debbugs.gnu.org (full text, mbox):
> Sent: Sunday, May 30, 2021 at 11:55 AM
> From: "Christopher Dimech" <dimech <at> gmx.com>
> To: "Juri Linkov" <juri <at> linkov.net>
> Cc: 48724 <at> debbugs.gnu.org
> Subject: bug#48724: Code collapsing and outline headings for elisp
>
> > Sent: Sunday, May 30, 2021 at 9:57 AM
> > From: "Juri Linkov" <juri <at> linkov.net>
> > To: "Christopher Dimech" <dimech <at> gmx.com>
> > Cc: 48724 <at> debbugs.gnu.org
> > Subject: Re: bug#48724: Code collapsing and outline headings for elisp
> >
> > > Currently, outline-minor-mode has the capability to treat "defun" constructs
> > > as heading, allowing one to choose to hide some code from view by collapsing
> > > the region of code. It would be beneficial for the actual major mode itself
> > > (i.e. emacs-lisp-mode) to handle the code collapsing, leaving the code highlighting
> > > intact. Code collapsing could also be extended beyond not only collapsing
> > > functions and variables ((defun, defvar), but also to additional constructs that could
> > > be indented (e.g. lists '(...), let, let*, pcase) and other constructs users could
> > > find useful (e.g. if, when, ).
> > >
> > > And for outline-minor-mode, the mode could then be used to further enhance the structuring
> > > of larger chunks of code (e.g. a collection of functions) using outline headings. Outlining
> > > would then be a separate capability different from code collapsing.
> >
> > Currently everything is customizable in outline-minor-mode by just
> > two variables: outline-regexp and outline-level. So when necessary,
> > emacs-lisp-mode could provide an option that will set different values
> > of these variables, one of which could set outline-regexp to a regexp
> > that matches: lists, '(...), let, let*, pcase, if, when, etc…
>
> The general impression is that outline-minor-mode is a general mode
> for customisable headings that are then handled by the respective
> major mode.
>
> General settings could be better, because some variables are not customizable.
>
> Serious problem is that the two important variables: `outline-regexp' and
> `outline-heading-alist' are not customizable by using "M-x customize-group".
>
> Additionally both of them should be customizable per mode. Don't you think so?
>
> There has been a discussion today about outline-minor-mode settings for fortran
> (both fixed and free form). Have had a go at using "!" and "!!", but "Hide Body"
> did not hide the body.
>
> There could be some default headings for fortran when outline-minor-mode is enabled.
> One could follow the current setup for emacs-lisp-mode, for fortran.
>
> !! for heading level 1
> !!! for subheading level 2
> !!!! for subsubheading level 3
>
> Together with "Hide Body" for lines beginning with "subroutine" and "function".
Looking at emacs-lisp again, the levels should be as follows
!!! for heading level 1 (starting as !!! as in emacs-lisp-mode)
!!!! for subheading level 2
!!!!! for subsubheading level 3 etc
I wonder if there exists the capabibily in outline-minor-mode to hide
code structures inside another code structure.
For instance for "do", "if" and "else" statements.
do in1 = 1, nr(1)
do in2 = 1, nr(1)
ind = in1 - in2
if (ind < 0) then
res(in1, in2) = conjg(fc(abs(ind)+1))
else
res(in1, in2) = fc(ind+1)
endif
enddo
enddo
hiding would then give the following
do in1 = 1, nr(1)
do in2 = 1, nr(1)
ind = in1 - in2
if (ind < 0) then ...
else ...
end if
end do
end do
do in1 = 1, nr(1)
do in2 = 1, nr(1) ...
end do
end do
do in1 = 1, nr(1) ...
end do
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48724
; Package
emacs
.
(Sun, 30 May 2021 22:39:03 GMT)
Full text and
rfc822 format available.
Message #17 received at 48724 <at> debbugs.gnu.org (full text, mbox):
> Serious problem is that the two important variables: `outline-regexp' and
> `outline-heading-alist' are not customizable by using "M-x customize-group".
>
> Additionally both of them should be customizable per mode. Don't you think so?
I think that modes should set `outline-regexp' and `outline-heading-alist'
according to the constructs of their programming language. Then users
don't need to customize these variables.
> There has been a discussion today about outline-minor-mode settings for fortran
> (both fixed and free form). Have had a go at using "!" and "!!", but "Hide Body"
> did not hide the body.
>
> There could be some default headings for fortran when outline-minor-mode is enabled.
> One could follow the current setup for emacs-lisp-mode, for fortran.
>
> !! for heading level 1
> !!! for subheading level 2
> !!!! for subsubheading level 3
I agree it would be nice to set an appropriate value of `outline-regexp'
and `outline-heading-alist' for fortran-mode in lisp/progmodes/fortran.el.
But the last time I used Fortran was when Fortran had the "C" character
for comments at the first fixed column on a punched card, and now
your example uses some new syntax "!" for comments, so sorry, can't help here.
This task would be a nice assignment for the group of students.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48724
; Package
emacs
.
(Sun, 30 May 2021 23:59:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 48724 <at> debbugs.gnu.org (full text, mbox):
> Sent: Monday, May 31, 2021 at 10:15 AM
> From: "Juri Linkov" <juri <at> linkov.net>
> To: "Christopher Dimech" <dimech <at> gmx.com>
> Cc: 48724 <at> debbugs.gnu.org
> Subject: Re: bug#48724: Code collapsing and outline headings for elisp
>
> > Serious problem is that the two important variables: `outline-regexp' and
> > `outline-heading-alist' are not customizable by using "M-x customize-group".
> >
> > Additionally both of them should be customizable per mode. Don't you think so?
>
> I think that modes should set `outline-regexp' and `outline-heading-alist'
> according to the constructs of their programming language. Then users
> don't need to customize these variables.
Quite Right.
> > There has been a discussion today about outline-minor-mode settings for fortran
> > (both fixed and free form). Have had a go at using "!" and "!!", but "Hide Body"
> > did not hide the body.
> >
> > There could be some default headings for fortran when outline-minor-mode is enabled.
> > One could follow the current setup for emacs-lisp-mode, for fortran.
> >
> > !! for heading level 1
> > !!! for subheading level 2
> > !!!! for subsubheading level 3
>
> I agree it would be nice to set an appropriate value of `outline-regexp'
> and `outline-heading-alist' for fortran-mode in lisp/progmodes/fortran.el.
>
> But the last time I used Fortran was when Fortran had the "C" character
> for comments at the first fixed column on a punched card, and now
> your example uses some new syntax "!" for comments, so sorry, can't help here.
>
> This task would be a nice assignment for the group of students.
There are currently two modes (1) the fixed format fortran (fortran-made) you
describe with "C" character for comments, and (2) the newer free format fortran
with "!" character for comments (f90-mode).
Could use for fortran-mode starting from three CCC as in elisp
CCC Heading
CCCC Subheading
CCCCC SubSubHeading etc
And for f90-mode use the following, starting from three !!! as in elisp
!!! for heading level 1
!!!! for subheading level 2
!!!!! for subsubheading level 3
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48724
; Package
emacs
.
(Tue, 01 Jun 2021 11:25:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 48724 <at> debbugs.gnu.org (full text, mbox):
> Sent: Monday, May 31, 2021 at 10:15 AM
> From: "Juri Linkov" <juri <at> linkov.net>
> To: "Christopher Dimech" <dimech <at> gmx.com>
> Cc: 48724 <at> debbugs.gnu.org
> Subject: Re: bug#48724: Code collapsing and outline headings for elisp
>
> > Serious problem is that the two important variables: `outline-regexp' and
> > `outline-heading-alist' are not customizable by using "M-x customize-group".
> >
> > Additionally both of them should be customizable per mode. Don't you think so?
>
> I think that modes should set `outline-regexp' and `outline-heading-alist'
> according to the constructs of their programming language. Then users
> don't need to customize these variables.
>
> > There has been a discussion today about outline-minor-mode settings for fortran
> > (both fixed and free form). Have had a go at using "!" and "!!", but "Hide Body"
> > did not hide the body.
> >
> > There could be some default headings for fortran when outline-minor-mode is enabled.
> > One could follow the current setup for emacs-lisp-mode, for fortran.
> >
> > !! for heading level 1
> > !!! for subheading level 2
> > !!!! for subsubheading level 3
>
> I agree it would be nice to set an appropriate value of `outline-regexp'
> and `outline-heading-alist' for fortran-mode in lisp/progmodes/fortran.el.
I suggest that emacs-lisp-mode does code collapse (show/hide) by default.
Then outline-minor-mode does additional headings in the form
;;; Heading 1
;;;; SubHeading
;;;;; SubSubHeading
;;; Heading 2
outline-minor-mode would then be made to collapse sections of code between
headlines.
This means that a headline hide could hide a number of variable and function
definitions that belong together.
> But the last time I used Fortran was when Fortran had the "C" character
> for comments at the first fixed column on a punched card, and now
> your example uses some new syntax "!" for comments, so sorry, can't help here.
>
> This task would be a nice assignment for the group of students.
Which major modes could be done straight away?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48724
; Package
emacs
.
(Tue, 01 Jun 2021 20:59:03 GMT)
Full text and
rfc822 format available.
Message #26 received at 48724 <at> debbugs.gnu.org (full text, mbox):
> I suggest that emacs-lisp-mode does code collapse (show/hide) by default.
> Then outline-minor-mode does additional headings in the form
>
> ;;; Heading 1
> ;;;; SubHeading
> ;;;;; SubSubHeading
>
> ;;; Heading 2
>
> outline-minor-mode would then be made to collapse sections of code between
> headlines.
>
> This means that a headline hide could hide a number of variable and function
> definitions that belong together.
Recently we changed the outlines of emacs-lisp-mode in https://debbugs.gnu.org/46878
So this is already fixed.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48724
; Package
emacs
.
(Wed, 02 Jun 2021 00:08:01 GMT)
Full text and
rfc822 format available.
Message #29 received at 48724 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
> Sent: Wednesday, June 02, 2021 at 8:44 AM
> From: "Juri Linkov" <juri <at> linkov.net>
> To: "Christopher Dimech" <dimech <at> gmx.com>
> Cc: 48724 <at> debbugs.gnu.org
> Subject: Re: bug#48724: Code collapsing and outline headings for elisp
> I suggest that emacs-lisp-mode does code collapse (show/hide) by default.
> Then outline-minor-mode does additional headings in the form
>
> ;;; Heading 1
> ;;;; SubHeading
> ;;;;; SubSubHeading
>
> ;;; Heading 2
>
> outline-minor-mode would then be made to collapse sections of code between
> headlines.
>
> This means that a headline hide could hide a number of variable and function
> definitions that belong together.
Recently we changed the outlines of emacs-lisp-mode in https://debbugs.gnu.org/46878
So this is already fixed.
Have been discussing all this together with Protesilaos Stavrou. Could you have a read
to see if we actually got to something?
> Sent: Wednesday, June 02, 2021 at 1:46 AM
> From: "Protesilaos Stavrou" <info <at> protesilaos.com>
> To: "Christopher Dimech" <dimech <at> gmx.com>
> Subject: Re: modus-themes and headlines
>
> On 2021-06-01, 14:42 +0200, Christopher Dimech <dimech <at> gmx.com> wrote:
>
> > I send you a file to see how doing "Hide Body" looks like after enabling
> > outline-minor-mode.
> >
> > For headings, you seem to change the font. Anyway, I have seen that the colours
> > for headings staring with comments (;;; ;;;; ;;;;; ...) are basically indistinguisable
> > from code headlines ("(defvar", "(defun"), Almost same colour but not the same.
> >
> > Don't you play with contrast ratio between headings starting with ;;; and those starting
> > with code?
>
> Just rebuilt Emacs and checked with the file you sent. Long story
> short: this is the same as we discussed the other day, namely, that the
> problem is with outline.el and how it chooses to fontify forms that are
> not explicitly defined as headings (defvar, defun...).
>
> To the defun, defvar etc. it applies the outline-8 face, whereas the
> real headings (starting with comments that have three delimiters: ;;;)
> are styled with outline-1 and then incremented for each extra comment
> delimiter.
>
> This happens regardless of theme. It just is that the generic theme
> inherits from font-lock, so the problem is not obvious even though it is
> still there: try it with and without outline-minor-mode to see the
> difference.
>
> Here is what I did (screenshots attached):
>
> - emacs -Q and find-file gungadin.el (screenshot 1)
>
> - M-x outline-minor-mode (screenshot 2)
>
> - M-x load-theme RET modus-operandi RET (screenshot 3)
>
> - M-: (setq-default outline-minor-mode-highlight 'override) RET
> and then M-x outline-minor-mode twice to re-enable the mode
> (screenshot 4)
>
> - M-x disable-theme RET modus-operandi RET (screenshot 5)
>
> - M-x outline-minor-mode (screenshot 6)
>
> Just comparing the last two screenshots you can see that the problem is
> there.
>
> As for the style of the headings for the modus-themes (screenshot 4),
> you can use the variable 'modus-themes-headings' as we mentioned before.
>
> I suggest we bring this issue upstream. Ask them whether the
> defvar,defun etc. can retain their styles and only for explicit headings
> to be fontified.
>
> --
> Protesilaos Stavrou
> https://protesilaos.com
>
[gungadin.el (text/plain, attachment)]
[screenshot-1.png (image/png, attachment)]
[screenshot-2.png (image/png, attachment)]
[screenshot-3.png (image/png, attachment)]
[screenshot-4.png (image/png, attachment)]
[screenshot-5.png (image/png, attachment)]
[screenshot-6.png (image/png, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48724
; Package
emacs
.
(Wed, 02 Jun 2021 21:19:02 GMT)
Full text and
rfc822 format available.
Message #32 received at 48724 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
> Have been discussing all this together with Protesilaos Stavrou. Could you have a read
> to see if we actually got to something?
Thank you for sending this mail.
>> I suggest we bring this issue upstream. Ask them whether the
>> defvar,defun etc. can retain their styles and only for explicit headings
>> to be fontified.
Like in bug#48777, the solution is to use
(setq outline-minor-mode-highlight 'append)
But what is important, to make outline headings readable
while retaining major-mode fontification is what I did
in the init file, and what I highly recommend to you is
to customize outline faces, and to turn their foreground
colors into background colors, so it looks nicely like this:
[screenshot-7.png (image/png, inline)]
This bug report was last modified 4 years and 14 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.