unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* headings in sh-mode
@ 2021-07-02  1:46 lisa-asket
  2021-07-02  2:07 ` Stefan Monnier via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 18+ messages in thread
From: lisa-asket @ 2021-07-02  1:46 UTC (permalink / raw)
  To: help-gnu-emacs


How can I set headings in `sh-mode` using `outline-minor-mode` ?



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

* Re: headings in sh-mode
  2021-07-02  1:46 headings in sh-mode lisa-asket
@ 2021-07-02  2:07 ` Stefan Monnier via Users list for the GNU Emacs text editor
  2021-07-02  3:13   ` lisa-asket
  0 siblings, 1 reply; 18+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2021-07-02  2:07 UTC (permalink / raw)
  To: help-gnu-emacs

lisa-asket@perso.be [2021-07-02 03:46:06] wrote:
> How can I set headings in `sh-mode` using `outline-minor-mode` ?

What have you tried?


        Stefan




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

* headings in sh-mode
  2021-07-02  2:07 ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2021-07-02  3:13   ` lisa-asket
  2021-07-02 13:52     ` Stefan Monnier
  0 siblings, 1 reply; 18+ messages in thread
From: lisa-asket @ 2021-07-02  3:13 UTC (permalink / raw)
  To: monnier, help-gnu-emacs

Using comments did not work.  But I can use `*`, `**`, `***`.




From: Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: headings in sh-mode
Date: 02/07/2021 04:07:41 Europe/Paris

lisa-asket@perso.be [2021-07-02 03:46:06] wrote:
> How can I set headings in `sh-mode` using `outline-minor-mode` ?

What have you tried?


Stefan





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

* Re: headings in sh-mode
  2021-07-02  3:13   ` lisa-asket
@ 2021-07-02 13:52     ` Stefan Monnier
  2021-07-02 17:54       ` lisa-asket
  0 siblings, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2021-07-02 13:52 UTC (permalink / raw)
  To: lisa-asket; +Cc: help-gnu-emacs

lisa-asket@perso.be [2021-07-02 05:13:00] wrote:
> Using comments did not work.  But I can use `*`, `**`, `***`.

I was expecting answers in the form of some ELisp snippets, or URLs
describing how to do it, which you'd have presumably found by searching
the web.


        Stefan




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

* headings in sh-mode
  2021-07-02 13:52     ` Stefan Monnier
@ 2021-07-02 17:54       ` lisa-asket
  2021-07-02 18:34         ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 18+ messages in thread
From: lisa-asket @ 2021-07-02 17:54 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

>From: Stefan Monnier <monnier@iro.umontreal.ca>
>To: lisa-asket@perso.be
>Subject: Re: headings in sh-mode
>Date: 02/07/2021 15:52:27 Europe/Paris
>Cc: help-gnu-emacs@gnu.org

>>lisa-asket@perso.be [2021-07-02 05:13:00] wrote:
>> Using comments did not work.  But I can use `*`, `**`, `***`.
>
I was expecting answers in the form of some ELisp snippets, or URLs
>describing how to do it, which you'd have presumably found by searching
>the web.


No.  I just typed 



# Heading

## Heading

### Heading

#### Heading



Then I did 



* Heading

** Heading

*** Heading

**** Heading



The last headings took effect, but they srcew up the srcipt because they are not used as comments.








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

* Re: headings in sh-mode
  2021-07-02 17:54       ` lisa-asket
@ 2021-07-02 18:34         ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-02 19:58           ` lisa-asket
                             ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-02 18:34 UTC (permalink / raw)
  To: help-gnu-emacs

lisa-asket wrote:

> Then I did 
>
> * Heading
>
> ** Heading
>
> *** Heading
>
> **** Heading
>
> The last headings took effect, but they srcew up the srcipt
> because they are not used as comments.

Of course, you must obey the shell language rules (syntax in
this case), if you'd like it to work.

But honestly... you don't need a header hierarchy like this
for a shell script, they should be simple and short (well, as
short as possible, and long scripts aren't advanced, really,
they are just long).

If you really want something like that, can't `org-mode' do
little buttons under each of the ranked headings, and the
script will pop up and maybe execute, even?

I'm not an org-mode user myself, what you describe I recognize
from HTML and LaTeX but those are about organizing
_information_, not bunching together shell tools executing on
top of each other, and to the side...

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




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

* headings in sh-mode
  2021-07-02 18:34         ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-02 19:58           ` lisa-asket
  2021-07-02 20:44             ` Stefan Monnier via Users list for the GNU Emacs text editor
  2021-07-02 20:02           ` Yuri Khan
  2021-07-02 20:43           ` Stefan Monnier via Users list for the GNU Emacs text editor
  2 siblings, 1 reply; 18+ messages in thread
From: lisa-asket @ 2021-07-02 19:58 UTC (permalink / raw)
  To: moasenwood, help-gnu-emacs

From: Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: headings in sh-mode
Date: 02/07/2021 20:34:04 Europe/Paris

lisa-asket wrote:

> Then I did 
>
> * Heading
>
> ** Heading
>
> *** Heading
>
> **** Heading
>
> The last headings took effect, but they srcew up the srcipt
> because they are not used as comments.

>Of course, you must obey the shell language rules (syntax in
>this case), if you'd like it to work.



It was by default, I did not set them up.  Simply loaded a bash file,

called `M-x outline-minor-mode` and lines starting with `*` were

considered as headings.  This screws up shell scripts.  This problem

should be fixed so headings must start with `#` first.



>But honestly... you don't need a header hierarchy like this
>for a shell script, they should be simple and short (well, as
>short as possible, and long scripts aren't advanced, really,
>they are just long).



The header hierarchy functionality is available, so I do not see 

how one can disregard a such a problem, advising people not to

use it. 



I went to the doctor because my thumb hurts.  He told me not to use it !



>If you really want something like that, can't `org-mode' do
>little buttons under each of the ranked headings, and the
>script will pop up and maybe execute, even?

>I'm not an org-mode user myself, what you describe I recognize
>from HTML and LaTeX but those are about organizing
>_information_, not bunching together shell tools executing on
>top of each other, and to the side...

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





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

* Re: headings in sh-mode
  2021-07-02 18:34         ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-02 19:58           ` lisa-asket
@ 2021-07-02 20:02           ` Yuri Khan
  2021-07-02 20:32             ` lisa-asket
  2021-07-02 23:11             ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-02 20:43           ` Stefan Monnier via Users list for the GNU Emacs text editor
  2 siblings, 2 replies; 18+ messages in thread
From: Yuri Khan @ 2021-07-02 20:02 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Sat, 3 Jul 2021 at 01:34, Emanuel Berg via Users list for the GNU
Emacs text editor <help-gnu-emacs@gnu.org> wrote:

> But honestly... you don't need a header hierarchy like this
> for a shell script, they should be simple and short (well, as
> short as possible, and long scripts aren't advanced, really,
> they are just long).

This. If your shell script is so long and/or nested that you want
folding, then you’re much better served by rewriting in a proper
programming language. My personal rule of thumb is, rewrite if you
want to do any arithmetics, or arrays, or the script no longer fits in
a single screenful.

A similar point goes for other programming languages: If you want to
fold parts of a function, the part you want to fold is a candidate for
extraction. If you want to hide some functions while looking at
others, maybe split your module.

A working folding facility can be a painkiller when working with
existing code. But don’t become addicted to painkillers.



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

* headings in sh-mode
  2021-07-02 20:02           ` Yuri Khan
@ 2021-07-02 20:32             ` lisa-asket
  2021-07-02 23:11             ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 0 replies; 18+ messages in thread
From: lisa-asket @ 2021-07-02 20:32 UTC (permalink / raw)
  To: Yuri Khan, Emanuel Berg, help-gnu-emacs

>From: Yuri Khan <yuri.v.khan@gmail.com>
>To: Emanuel Berg <moasenwood@zoho.eu>;
>   help-gnu-emacs <help-gnu-emacs@gnu.org>
>Subject: Re: headings in sh-mode
>Date: 02/07/2021 22:02:57 Europe/Paris

>On Sat, 3 Jul 2021 at 01:34, Emanuel Berg via Users list for the GNU
>Emacs text editor <help-gnu-emacs@gnu.org> wrote:

>> But honestly... you don't need a header hierarchy like this
>> for a shell script, they should be simple and short (well, as
>> short as possible, and long scripts aren't advanced, really,
>> they are just long).

>This. If your shell script is so long and/or nested that you want
>folding, then you’re much better served by rewriting in a proper
>programming language. My personal rule of thumb is, rewrite if you
>want to do any arithmetics, or arrays, or the script no longer fits in
>a single screenful.



I am not arguing on the merits or otherwise of header folding.



Only pointing out that headings using outline-minor-mode should be

made to work correctly as expected by the minor mode, irrespective

of whether a user ultimately uses the functionality or not.



Such rational does make sense actually.  



>A similar point goes for other programming languages: If you want to
>fold parts of a function, the part you want to fold is a candidate for
>extraction. If you want to hide some functions while looking at
>others, maybe split your module.

>A working folding facility can be a painkiller when working with
>existing code. But don’t become addicted to painkillers.




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

* Re: headings in sh-mode
  2021-07-02 18:34         ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-02 19:58           ` lisa-asket
  2021-07-02 20:02           ` Yuri Khan
@ 2021-07-02 20:43           ` Stefan Monnier via Users list for the GNU Emacs text editor
  2021-07-02 20:53             ` lisa-asket
  2021-07-02 23:13             ` Emanuel Berg via Users list for the GNU Emacs text editor
  2 siblings, 2 replies; 18+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2021-07-02 20:43 UTC (permalink / raw)
  To: help-gnu-emacs

> But honestly... you don't need a header hierarchy like this
> for a shell script, they should be simple and short (well, as
> short as possible, and long scripts aren't advanced, really,
> they are just long).

While I tend to agree, I plead guilty to not following this advice:

https://gitlab.com/monnier/bugit/-/raw/main/bugit


        Stefan




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

* Re: headings in sh-mode
  2021-07-02 19:58           ` lisa-asket
@ 2021-07-02 20:44             ` Stefan Monnier via Users list for the GNU Emacs text editor
  2021-07-02 20:56               ` lisa-asket
  0 siblings, 1 reply; 18+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2021-07-02 20:44 UTC (permalink / raw)
  To: help-gnu-emacs

> This problem should be fixed so ...

This sounds like you want to report a bug: `M-x report-emacs-bug`.


        Stefan




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

* headings in sh-mode
  2021-07-02 20:43           ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2021-07-02 20:53             ` lisa-asket
  2021-07-02 23:14               ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-08 20:56               ` Nick Dokos
  2021-07-02 23:13             ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 2 replies; 18+ messages in thread
From: lisa-asket @ 2021-07-02 20:53 UTC (permalink / raw)
  To: monnier, help-gnu-emacs

>From: Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
>To: help-gnu-emacs@gnu.org
>Subject: Re: headings in sh-mode
>Date: 02/07/2021 22:43:01 Europe/Paris

>> But honestly... you don't need a header hierarchy like this
>> for a shell script, they should be simple and short (well, as
>> short as possible, and long scripts aren't advanced, really,
>> they are just long).

>While I tend to agree, I plead guilty to not following this advice:

>https://gitlab.com/monnier/bugit/-/raw/main/bugit

Could the difficulties using outline-minor-mode be fixed nevertheless?



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

* headings in sh-mode
  2021-07-02 20:44             ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2021-07-02 20:56               ` lisa-asket
  2021-07-03  1:08                 ` Stefan Monnier
  0 siblings, 1 reply; 18+ messages in thread
From: lisa-asket @ 2021-07-02 20:56 UTC (permalink / raw)
  To: monnier, help-gnu-emacs

> From: Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
> To: help-gnu-emacs@gnu.org
> Subject: Re: headings in sh-mode
> Date: 02/07/2021 22:44:58 Europe/Paris

> > This problem should be fixed so ...

> This sounds like you want to report a bug: `M-x report-emacs-bug`.

> Stefan



Hello Stefan, would you also consider it a bug and sending a bug report worthwhile?






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

* Re: headings in sh-mode
  2021-07-02 20:02           ` Yuri Khan
  2021-07-02 20:32             ` lisa-asket
@ 2021-07-02 23:11             ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 0 replies; 18+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-02 23:11 UTC (permalink / raw)
  To: help-gnu-emacs

Yuri Khan wrote:

>> But honestly... you don't need a header hierarchy like this
>> for a shell script, they should be simple and short (well,
>> as short as possible, and long scripts aren't advanced,
>> really, they are just long).
>
> This. If your shell script is so long and/or nested that you
> want folding, then you’re much better served by rewriting in
> a proper programming language. My personal rule of thumb is,
> rewrite if you want to do any arithmetics, or arrays, or the
> script no longer fits in a single screenful.
>
> A similar point goes for other programming languages: If you
> want to fold parts of a function, the part you want to fold
> is a candidate for extraction. If you want to hide some
> functions while looking at others, maybe split your module.
>
> A working folding facility can be a painkiller when working
> with existing code. But don’t become addicted
> to painkillers.

In so many words, agreed.

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




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

* Re: headings in sh-mode
  2021-07-02 20:43           ` Stefan Monnier via Users list for the GNU Emacs text editor
  2021-07-02 20:53             ` lisa-asket
@ 2021-07-02 23:13             ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 0 replies; 18+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-02 23:13 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier via Users list for the GNU Emacs text editor wrote:

>> But honestly... you don't need a header hierarchy like this
>> for a shell script, they should be simple and short (well,
>> as short as possible, and long scripts aren't advanced,
>> really, they are just long).
>
> While I tend to agree, I plead guilty to not following this
> advice:
>
> https://gitlab.com/monnier/bugit/-/raw/main/bugit

2640 lines :)

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




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

* Re: headings in sh-mode
  2021-07-02 20:53             ` lisa-asket
@ 2021-07-02 23:14               ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-07-08 20:56               ` Nick Dokos
  1 sibling, 0 replies; 18+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-02 23:14 UTC (permalink / raw)
  To: help-gnu-emacs

lisa-asket wrote:

> Could the difficulties using outline-minor-mode be
> fixed nevertheless?

Report the bug!

It is great that you found it, now just report it!

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




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

* Re: headings in sh-mode
  2021-07-02 20:56               ` lisa-asket
@ 2021-07-03  1:08                 ` Stefan Monnier
  0 siblings, 0 replies; 18+ messages in thread
From: Stefan Monnier @ 2021-07-03  1:08 UTC (permalink / raw)
  To: lisa-asket; +Cc: help-gnu-emacs

>> > This problem should be fixed so ...
>> This sounds like you want to report a bug: `M-x report-emacs-bug`.
> Hello Stefan, would you also consider it a bug and sending a bug
> report worthwhile?

What I think is not relevant to this decision,


        Stefan




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

* Re: headings in sh-mode
  2021-07-02 20:53             ` lisa-asket
  2021-07-02 23:14               ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-07-08 20:56               ` Nick Dokos
  1 sibling, 0 replies; 18+ messages in thread
From: Nick Dokos @ 2021-07-08 20:56 UTC (permalink / raw)
  To: help-gnu-emacs

lisa-asket@perso.be writes:


> Could the difficulties using outline-minor-mode be fixed nevertheless?
>

Yes - `C-h v outline-regexp` will give you the doc string of the variable.

-- 
Nick

"There are only two hard problems in computer science: cache
invalidation, naming things, and off-by-one errors." -Martin Fowler




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

end of thread, other threads:[~2021-07-08 20:56 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-02  1:46 headings in sh-mode lisa-asket
2021-07-02  2:07 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-07-02  3:13   ` lisa-asket
2021-07-02 13:52     ` Stefan Monnier
2021-07-02 17:54       ` lisa-asket
2021-07-02 18:34         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-02 19:58           ` lisa-asket
2021-07-02 20:44             ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-07-02 20:56               ` lisa-asket
2021-07-03  1:08                 ` Stefan Monnier
2021-07-02 20:02           ` Yuri Khan
2021-07-02 20:32             ` lisa-asket
2021-07-02 23:11             ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-02 20:43           ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-07-02 20:53             ` lisa-asket
2021-07-02 23:14               ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-08 20:56               ` Nick Dokos
2021-07-02 23:13             ` Emanuel Berg via Users list for the GNU Emacs text editor

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).