all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Code folding in Emacs.
@ 2021-10-10  8:16 Hongyi Zhao
  2021-10-10 11:37 ` tolugboji
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Hongyi Zhao @ 2021-10-10  8:16 UTC (permalink / raw)
  To: help-gnu-emacs

I just found the following code snippet from here [1] for code folding in Emacs:


(global-set-key (kbd "<C-f5>") 'set-selective-display-dlw)

(defun set-selective-display-dlw (&optional level)
  "Fold text indented same of more than the cursor.
If level is set, set the indent level to LEVEL.
If 'selective-display' is already set to LEVEL, clicking
F5 again will unset 'selective-display' by setting it to 0."
  (interactive "P")
  (if (eq selective-display (1+ (current-column)))
      (set-selective-display 0)
    (set-selective-display (or level (1+ (current-column))))))

The above code trick seems very simple, but it works for many
languages. So I recommend it here.

[1] https://discourse.julialang.org/t/code-folding-for-emacs/41421/3

Regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Code folding in Emacs.
  2021-10-10  8:16 Code folding in Emacs Hongyi Zhao
@ 2021-10-10 11:37 ` tolugboji
  2021-10-10 11:54   ` Hongyi Zhao
  2021-10-10 14:29 ` Emanuel Berg via Users list for the GNU Emacs text editor
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 14+ messages in thread
From: tolugboji @ 2021-10-10 11:37 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs

Emacs should develop code folding (opening and closing) to also work with the mouse.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Sunday, October 10th, 2021 at 8:16 AM, Hongyi Zhao <hongyi.zhao@gmail.com> wrote:

> I just found the following code snippet from here [1] for code folding in Emacs:
>
> (global-set-key (kbd "<C-f5>") 'set-selective-display-dlw)
>
> (defun set-selective-display-dlw (&optional level)
>
> "Fold text indented same of more than the cursor.
>
> If level is set, set the indent level to LEVEL.
>
> If 'selective-display' is already set to LEVEL, clicking
>
> F5 again will unset 'selective-display' by setting it to 0."
>
> (interactive "P")
>
> (if (eq selective-display (1+ (current-column)))
>
> (set-selective-display 0)
>
> (set-selective-display (or level (1+ (current-column))))))
>
> The above code trick seems very simple, but it works for many
>
> languages. So I recommend it here.
>
> [1] https://discourse.julialang.org/t/code-folding-for-emacs/41421/3
>
> Regards
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Assoc. Prof. Hongyi Zhao hongyi.zhao@gmail.com
>
> Theory and Simulation of Materials
>
> Hebei Vocational University of Technology and Engineering
>
> No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Code folding in Emacs.
  2021-10-10 11:37 ` tolugboji
@ 2021-10-10 11:54   ` Hongyi Zhao
  2021-10-10 12:42     ` tolugboji
  2021-10-10 16:35     ` Daniel Fleischer
  0 siblings, 2 replies; 14+ messages in thread
From: Hongyi Zhao @ 2021-10-10 11:54 UTC (permalink / raw)
  To: tolugboji; +Cc: help-gnu-emacs

On Sun, Oct 10, 2021 at 7:37 PM tolugboji <tolugboji@protonmail.com> wrote:
>
> Emacs should develop code folding (opening and closing) to also work with the mouse.

The code snippet I posted above is based on an idea here [1], as shown below:

--------------

Outlines and Overviews

SelectiveDisplay – a poor-man’s OutlineMode. It hides lines with more
than the provided number of spaces in front. It can help in getting a
quick overview of files as long as paragraph lines are further
indented than headlines. This is great for viewing man pages: ‘C-u 1
M-x set-selective-display’ to show only headings, `M-x <up> RET’ to
disable it again.
More SelectiveDisplay: ‘set-selective-display’ is `C-x$’ by default.
You can make it a lot friendlier with a wrapper: – DaleWiles

            (global-set-key "\C-x$" 'set-selective-display-dlw)
            (defun set-selective-display-dlw (&optional level)
              "Fold text indented more than the cursor.
            If level is set, set the indent level to level.
            0 displays the entire buffer."
              (interactive "P")
              (set-selective-display (or level (current-column))))
--------------

It seems the idea was initiated by DaleWiles, but his/her homepage
given on emacswiki [2] is empty.

Another note, though there are already several code-folding relevant
packages available on melpa [3-5]. In my opinion, this concise and
clear code snippet is suitable for any programming language that uses
indented semantic blocks, and it beats all relevant packages found on
melpa.

[1] https://www.emacswiki.org/emacs/EmacsNiftyTricks#h5o-6
[2] https://www.emacswiki.org/emacs/DaleWiles
[3] https://github.com/gregsexton/origami.el
[4] https://github.com/matsievskiysv/vimish-fold
[5] https://github.com/emacsorphanage/yafolding

HZ

>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>
> On Sunday, October 10th, 2021 at 8:16 AM, Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>
> > I just found the following code snippet from here [1] for code folding in Emacs:
> >
> > (global-set-key (kbd "<C-f5>") 'set-selective-display-dlw)
> >
> > (defun set-selective-display-dlw (&optional level)
> >
> > "Fold text indented same of more than the cursor.
> >
> > If level is set, set the indent level to LEVEL.
> >
> > If 'selective-display' is already set to LEVEL, clicking
> >
> > F5 again will unset 'selective-display' by setting it to 0."
> >
> > (interactive "P")
> >
> > (if (eq selective-display (1+ (current-column)))
> >
> > (set-selective-display 0)
> >
> > (set-selective-display (or level (1+ (current-column))))))
> >
> > The above code trick seems very simple, but it works for many
> >
> > languages. So I recommend it here.
> >
> > [1] https://discourse.julialang.org/t/code-folding-for-emacs/41421/3
> >
> > Regards
> > ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> >
> > Assoc. Prof. Hongyi Zhao hongyi.zhao@gmail.com
> >
> > Theory and Simulation of Materials
> >
> > Hebei Vocational University of Technology and Engineering
> >
> > No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Code folding in Emacs.
  2021-10-10 11:54   ` Hongyi Zhao
@ 2021-10-10 12:42     ` tolugboji
  2021-10-10 13:16       ` Hongyi Zhao
  2021-10-10 16:35     ` Daniel Fleischer
  1 sibling, 1 reply; 14+ messages in thread
From: tolugboji @ 2021-10-10 12:42 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Sunday, October 10th, 2021 at 11:54 AM, Hongyi Zhao <hongyi.zhao@gmail.com> wrote:

> On Sun, Oct 10, 2021 at 7:37 PM tolugboji tolugboji@protonmail.com wrote:
>
> > Emacs should develop code folding (opening and closing) to also work with the mouse.
>
> The code snippet I posted above is based on an idea here [1], as shown below:
>
> --------------------------------------------------------------------------------
>
> Outlines and Overviews
>
> SelectiveDisplay – a poor-man’s OutlineMode. It hides lines with more
>
> than the provided number of spaces in front. It can help in getting a
>
> quick overview of files as long as paragraph lines are further
>
> indented than headlines. This is great for viewing man pages: ‘C-u 1
>
> M-x set-selective-display’ to show only headings, `M-x <up> RET’ to
>
> disable it again.
>
> More SelectiveDisplay: ‘set-selective-display’ is `C-x$’ by default.
>
> You can make it a lot friendlier with a wrapper: – DaleWiles
>
> (global-set-key "\C-x$" 'set-selective-display-dlw)
>
> (defun set-selective-display-dlw (&optional level)
>
> "Fold text indented more than the cursor.
>
> If level is set, set the indent level to level.
>
> 0 displays the entire buffer."
>
> (interactive "P")
>
> (set-selective-display (or level (current-column))))
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> It seems the idea was initiated by DaleWiles, but his/her homepage
>
> given on emacswiki [2] is empty.
>
> Another note, though there are already several code-folding relevant
>
> packages available on melpa [3-5]. In my opinion, this concise and
>
> clear code snippet is suitable for any programming language that uses
>
> indented semantic blocks, and it beats all relevant packages found on
>
> melpa.

Because it is such a basic operation many would like to use, emacs should provide it
from itself.  Currently outline-minor-mode in too complicated and inconsistent to be
used regularly.  Using a long string of *** is difficult to understand, whereas a
hierarchy based on numeric values is better.  An additional problem is that Headings
Folding and Code Folding are dealt as they are the same.  Very bad idea.


> [1] https://www.emacswiki.org/emacs/EmacsNiftyTricks#h5o-6
>
> [2] https://www.emacswiki.org/emacs/DaleWiles
>
> [3] https://github.com/gregsexton/origami.el
>
> [4] https://github.com/matsievskiysv/vimish-fold
>
> [5] https://github.com/emacsorphanage/yafolding
>
> HZ
>
> > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> >
> > On Sunday, October 10th, 2021 at 8:16 AM, Hongyi Zhao hongyi.zhao@gmail.com wrote:
> >
> > > I just found the following code snippet from here [1] for code folding in Emacs:
> > >
> > > (global-set-key (kbd "<C-f5>") 'set-selective-display-dlw)
> > >
> > > (defun set-selective-display-dlw (&optional level)
> > >
> > > "Fold text indented same of more than the cursor.
> > >
> > > If level is set, set the indent level to LEVEL.
> > >
> > > If 'selective-display' is already set to LEVEL, clicking
> > >
> > > F5 again will unset 'selective-display' by setting it to 0."
> > >
> > > (interactive "P")
> > >
> > > (if (eq selective-display (1+ (current-column)))
> > >
> > > (set-selective-display 0)
> > >
> > > (set-selective-display (or level (1+ (current-column))))))
> > >
> > > The above code trick seems very simple, but it works for many
> > >
> > > languages. So I recommend it here.
> > >
> > > [1] https://discourse.julialang.org/t/code-folding-for-emacs/41421/3
> > >
> > > Regards
> > > -------
> > >
> > > Assoc. Prof. Hongyi Zhao hongyi.zhao@gmail.com
> > >
> > > Theory and Simulation of Materials
> > >
> > > Hebei Vocational University of Technology and Engineering
> > >
> > > No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Code folding in Emacs.
  2021-10-10 12:42     ` tolugboji
@ 2021-10-10 13:16       ` Hongyi Zhao
  2021-10-10 13:49         ` tolugboji
  0 siblings, 1 reply; 14+ messages in thread
From: Hongyi Zhao @ 2021-10-10 13:16 UTC (permalink / raw)
  To: tolugboji; +Cc: help-gnu-emacs

On Sun, Oct 10, 2021 at 8:42 PM tolugboji <tolugboji@protonmail.com> wrote:
> Because it is such a basic operation many would like to use, emacs should provide it
> from itself.  Currently outline-minor-mode in too complicated and inconsistent to be
> used regularly.  Using a long string of *** is difficult to understand, whereas a
> hierarchy based on numeric values is better.  An additional problem is that Headings
> Folding and Code Folding are dealt as they are the same.  Very bad idea.

If someone is willing to fix those flaws, that would be a great job.
I'm not sure if these are easy to solve with a small amount of Elsip
code.

HZ



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Code folding in Emacs.
  2021-10-10 13:16       ` Hongyi Zhao
@ 2021-10-10 13:49         ` tolugboji
  0 siblings, 0 replies; 14+ messages in thread
From: tolugboji @ 2021-10-10 13:49 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs

-‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Sunday, October 10th, 2021 at 1:16 PM, Hongyi Zhao <hongyi.zhao@gmail.com> wrote:

> On Sun, Oct 10, 2021 at 8:42 PM tolugboji tolugboji@protonmail.com wrote:
>
> > Because it is such a basic operation many would like to use, emacs should provide it
> >
> > from itself. Currently outline-minor-mode in too complicated and inconsistent to be
> >
> > used regularly. Using a long string of *** is difficult to understand, whereas a
> >
> > hierarchy based on numeric values is better. An additional problem is that Headings
> >
> > Folding and Code Folding are dealt as they are the same. Very bad idea.
>
> If someone is willing to fix those flaws, that would be a great job.
>
> I'm not sure if these are easy to solve with a small amount of Elsip
>
> code.
>
> HZ

The functionality is there but needs cleaning up.  The major thing is to separate
the folding of headings from the folding of code structures.  Headings should be
at a higher hierarchical level than code folding.  People tend to add things but
when everything becomes somewhat convoluted and complicated, tho code is not
looked upon again with a more robust design.  This step is important because it
eases the way far further development.





^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Code folding in Emacs.
  2021-10-10  8:16 Code folding in Emacs Hongyi Zhao
  2021-10-10 11:37 ` tolugboji
@ 2021-10-10 14:29 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-10 20:11 ` Eric S Fraga
  2021-10-14  5:47 ` David Masterson
  3 siblings, 0 replies; 14+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-10 14:29 UTC (permalink / raw)
  To: help-gnu-emacs

Hongyi Zhao wrote:

> (defun set-selective-display-dlw (&optional level)
>   "Fold text indented same of more than the cursor.
> If level is set, set the indent level to LEVEL.
> If 'selective-display' is already set to LEVEL, clicking
> F5 again will unset 'selective-display' by setting it to 0."
>   (interactive "P")
>   (if (eq selective-display (1+ (current-column)))
>       (set-selective-display 0)
>     (set-selective-display (or level (1+ (current-column))))))
>
> The above code trick seems very simple, but it works for
> many languages. So I recommend it here.

Good Lisp to whoever wrote it ...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Code folding in Emacs.
  2021-10-10 11:54   ` Hongyi Zhao
  2021-10-10 12:42     ` tolugboji
@ 2021-10-10 16:35     ` Daniel Fleischer
  2021-10-11  0:39       ` Hongyi Zhao
  2021-10-11 12:09       ` Hongyi Zhao
  1 sibling, 2 replies; 14+ messages in thread
From: Daniel Fleischer @ 2021-10-10 16:35 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs, tolugboji

Hongyi Zhao <hongyi.zhao@gmail.com> writes:

> [1] https://www.emacswiki.org/emacs/EmacsNiftyTricks#h5o-6
> [2] https://www.emacswiki.org/emacs/DaleWiles
> [3] https://github.com/gregsexton/origami.el
> [4] https://github.com/matsievskiysv/vimish-fold
> [5] https://github.com/emacsorphanage/yafolding

There is also https://www.emacswiki.org/emacs/hideshowvis.el which adds
mouse support to the built-in existing hideshow library.

-- 

Daniel Fleischer



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Code folding in Emacs.
  2021-10-10  8:16 Code folding in Emacs Hongyi Zhao
  2021-10-10 11:37 ` tolugboji
  2021-10-10 14:29 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-10 20:11 ` Eric S Fraga
  2021-10-14  5:47 ` David Masterson
  3 siblings, 0 replies; 14+ messages in thread
From: Eric S Fraga @ 2021-10-10 20:11 UTC (permalink / raw)
  To: help-gnu-emacs

Just for the record, out of the box, Emacs binds C-x $ to
set-selective-display and you can, say, hide lines indented to column 2
or more by typing "C-u 2 C-x $".  You can show all lines by simply
typing "C-x $".
-- 
Eric S Fraga via Emacs 28.0.60 & org 9.5 on Debian 11.0




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Code folding in Emacs.
  2021-10-10 16:35     ` Daniel Fleischer
@ 2021-10-11  0:39       ` Hongyi Zhao
  2021-10-11 12:09       ` Hongyi Zhao
  1 sibling, 0 replies; 14+ messages in thread
From: Hongyi Zhao @ 2021-10-11  0:39 UTC (permalink / raw)
  To: Daniel Fleischer; +Cc: help-gnu-emacs, tolugboji

On Mon, Oct 11, 2021 at 12:35 AM Daniel Fleischer <danflscr@gmail.com> wrote:
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> > [1] https://www.emacswiki.org/emacs/EmacsNiftyTricks#h5o-6
> > [2] https://www.emacswiki.org/emacs/DaleWiles
> > [3] https://github.com/gregsexton/origami.el
> > [4] https://github.com/matsievskiysv/vimish-fold
> > [5] https://github.com/emacsorphanage/yafolding
>
> There is also https://www.emacswiki.org/emacs/hideshowvis.el which adds
> mouse support to the built-in existing hideshow library.

Thank you for pointing this out. After further excavation, I find that
the latest source code is resided at here[1]. I figured out the
following configuration with use-package and straight, and it works
like a charm:

(use-package hideshowvis
  :straight (:host github :repo "sheijk/hideshowvis")
  :config
  (autoload 'hideshowvis-enable "hideshowvis" "Highlight foldable regions")

  (autoload 'hideshowvis-minor-mode
    "hideshowvis"
    "Will indicate regions foldable with hideshow in the fringe."
    'interactive)


  (dolist (hook (list 'prog-mode-hook))
    (add-hook hook 'hideshowvis-enable))

  (hideshowvis-symbols)
  )


[1] https://github.com/sheijk/hideshowvis

HZ



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Code folding in Emacs.
  2021-10-10 16:35     ` Daniel Fleischer
  2021-10-11  0:39       ` Hongyi Zhao
@ 2021-10-11 12:09       ` Hongyi Zhao
  2021-10-11 12:56         ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 14+ messages in thread
From: Hongyi Zhao @ 2021-10-11 12:09 UTC (permalink / raw)
  To: Daniel Fleischer; +Cc: help-gnu-emacs, tolugboji

On Mon, Oct 11, 2021 at 12:35 AM Daniel Fleischer <danflscr@gmail.com> wrote:
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> > [1] https://www.emacswiki.org/emacs/EmacsNiftyTricks#h5o-6
> > [2] https://www.emacswiki.org/emacs/DaleWiles
> > [3] https://github.com/gregsexton/origami.el
> > [4] https://github.com/matsievskiysv/vimish-fold
> > [5] https://github.com/emacsorphanage/yafolding
>
> There is also https://www.emacswiki.org/emacs/hideshowvis.el which adds
> mouse support to the built-in existing hideshow library.

Another package which does the similar job:

https://github.com/alphapapa/outshine

HZ



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Code folding in Emacs.
  2021-10-11 12:09       ` Hongyi Zhao
@ 2021-10-11 12:56         ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 14+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-11 12:56 UTC (permalink / raw)
  To: help-gnu-emacs

Hongyi Zhao wrote:

>> There is also
>> https://www.emacswiki.org/emacs/hideshowvis.el which adds
>> mouse support to the built-in existing hideshow library.
>
> Another package which does the similar job:
>
> https://github.com/alphapapa/outshine

Well, I guess for the Emacs world it is only good that you
test all these different packages ...

In general tho and from a one-user perspective one should get
the foundation smooth and rolling first, then add maybe 2-3
packages tops initially and then maybe one here and there in
the course of time for very specific needs.

Or is it me that is old-fashioned? I just strikes me as
a little backward.

But TEHO ... no need to defend or explain your Emacs or
computer style and attitude to anyone.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Code folding in Emacs.
  2021-10-10  8:16 Code folding in Emacs Hongyi Zhao
                   ` (2 preceding siblings ...)
  2021-10-10 20:11 ` Eric S Fraga
@ 2021-10-14  5:47 ` David Masterson
  2021-10-14  8:21   ` Thibaut Verron
  3 siblings, 1 reply; 14+ messages in thread
From: David Masterson @ 2021-10-14  5:47 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs

Hongyi Zhao <hongyi.zhao@gmail.com> writes:

> I just found the following code snippet from here [1] for code folding in Emacs:
>
>
> (global-set-key (kbd "<C-f5>") 'set-selective-display-dlw)
>
> (defun set-selective-display-dlw (&optional level)
>   "Fold text indented same of more than the cursor.
> If level is set, set the indent level to LEVEL.
> If 'selective-display' is already set to LEVEL, clicking
> F5 again will unset 'selective-display' by setting it to 0."
>   (interactive "P")
>   (if (eq selective-display (1+ (current-column)))
>       (set-selective-display 0)
>     (set-selective-display (or level (1+ (current-column))))))
>
> The above code trick seems very simple, but it works for many
> languages. So I recommend it here.
>
> [1] https://discourse.julialang.org/t/code-folding-for-emacs/41421/3

See Origami.

-- 
David Masterson



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Code folding in Emacs.
  2021-10-14  5:47 ` David Masterson
@ 2021-10-14  8:21   ` Thibaut Verron
  0 siblings, 0 replies; 14+ messages in thread
From: Thibaut Verron @ 2021-10-14  8:21 UTC (permalink / raw)
  To: David Masterson, Hongyi Zhao; +Cc: help-gnu-emacs

On 14/10/2021 07:47, David Masterson wrote:
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
>> I just found the following code snippet from here [1] for code folding in Emacs:
>>
>>
>> (global-set-key (kbd "<C-f5>") 'set-selective-display-dlw)
>>
>> (defun set-selective-display-dlw (&optional level)
>>    "Fold text indented same of more than the cursor.
>> If level is set, set the indent level to LEVEL.
>> If 'selective-display' is already set to LEVEL, clicking
>> F5 again will unset 'selective-display' by setting it to 0."
>>    (interactive "P")
>>    (if (eq selective-display (1+ (current-column)))
>>        (set-selective-display 0)
>>      (set-selective-display (or level (1+ (current-column))))))
>>
>> The above code trick seems very simple, but it works for many
>> languages. So I recommend it here.
>>
>> [1] https://discourse.julialang.org/t/code-folding-for-emacs/41421/3
> See Origami.

Which is, sadly, now unmaintained. Most notably, it lacks documentation 
on how to specify a parser, all one can do is guess based on the 
existing ones. There are forks attempting to clear those gaps, but afaik 
it's not there yet -- and they face distribution issues, with package 
repositories refusing to keep several packages with the same name.

It would be great if Emacs had something like origami built-in, aka a 
folding framework with a more flexible way to specify folding points 
than regexps (hideshow) or headers (outline). Essentially something like 
smie, but for folding: define functions to test if we are at an opener, 
at a closer, to find the closer for an opener, to find the subnodes if 
applicable, and let the package merge it all, construct the folding tree 
and take care of the folding.





^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-10-14  8:21 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-10  8:16 Code folding in Emacs Hongyi Zhao
2021-10-10 11:37 ` tolugboji
2021-10-10 11:54   ` Hongyi Zhao
2021-10-10 12:42     ` tolugboji
2021-10-10 13:16       ` Hongyi Zhao
2021-10-10 13:49         ` tolugboji
2021-10-10 16:35     ` Daniel Fleischer
2021-10-11  0:39       ` Hongyi Zhao
2021-10-11 12:09       ` Hongyi Zhao
2021-10-11 12:56         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-10 14:29 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-10 20:11 ` Eric S Fraga
2021-10-14  5:47 ` David Masterson
2021-10-14  8:21   ` Thibaut Verron

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.