* Turning off sh-electric-here-document-mode?
@ 2020-05-13 0:51 Douglas Lewan
2020-05-13 11:22 ` Philipp Stephani
0 siblings, 1 reply; 11+ messages in thread
From: Douglas Lewan @ 2020-05-13 0:51 UTC (permalink / raw)
To: help-gnu-emacs
OK. I'm sure I'm missing something obvious here.
I want to turn off sh-electric-here-document-mode, but all the obvious
things seem to fail. I've put every one of the following in my .emacs,
but I still get here-documents in shell-script-mode.
(sh-electric-here-document-mode nil)
(sh-electric-here-document-mode 0)
(sh-electric-here-document-mode -1)
(sh-electric-here-document-mode)
How do I do this? Thanks in advance.
--
,Doug
d.lewan2000@gmail.com
(908) 720 7908
"Lie and deny." It's very popular these days.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Turning off sh-electric-here-document-mode?
2020-05-13 0:51 Turning off sh-electric-here-document-mode? Douglas Lewan
@ 2020-05-13 11:22 ` Philipp Stephani
2020-05-13 14:00 ` Douglas Lewan
2020-05-13 18:54 ` Douglas Lewan
0 siblings, 2 replies; 11+ messages in thread
From: Philipp Stephani @ 2020-05-13 11:22 UTC (permalink / raw)
To: Douglas Lewan; +Cc: help-gnu-emacs
Am Mi., 13. Mai 2020 um 02:51 Uhr schrieb Douglas Lewan <d.lewan2000@gmail.com>:
>
> OK. I'm sure I'm missing something obvious here.
>
> I want to turn off sh-electric-here-document-mode, but all the obvious
> things seem to fail. I've put every one of the following in my .emacs,
> but I still get here-documents in shell-script-mode.
>
> (sh-electric-here-document-mode nil)
>
> (sh-electric-here-document-mode 0)
>
> (sh-electric-here-document-mode -1)
>
> (sh-electric-here-document-mode)
>
> How do I do this? Thanks in advance.
>
It's a local mode, so all of those will only enable it in whatever
buffer is current while evaluating your ~/.emacs (probably the scratch
buffer). You need to customize sh-mode-hook instead.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Turning off sh-electric-here-document-mode?
2020-05-13 11:22 ` Philipp Stephani
@ 2020-05-13 14:00 ` Douglas Lewan
2020-05-14 1:25 ` Nick Dokos
2020-05-13 18:54 ` Douglas Lewan
1 sibling, 1 reply; 11+ messages in thread
From: Douglas Lewan @ 2020-05-13 14:00 UTC (permalink / raw)
To: Philipp Stephani; +Cc: help-gnu-emacs
On 5/13/20 7:22 AM, Philipp Stephani wrote:
> Am Mi., 13. Mai 2020 um 02:51 Uhr schrieb Douglas Lewan <d.lewan2000@gmail.com>:
>> OK. I'm sure I'm missing something obvious here.
>>
>> I want to turn off sh-electric-here-document-mode, but all the obvious
>> things seem to fail. I've put every one of the following in my .emacs,
>> but I still get here-documents in shell-script-mode.
>>
>> (sh-electric-here-document-mode nil)
>>
>> (sh-electric-here-document-mode 0)
>>
>> (sh-electric-here-document-mode -1)
>>
>> (sh-electric-here-document-mode)
>>
>> How do I do this? Thanks in advance.
>>
>
> It's a local mode, so all of those will only enable it in whatever
> buffer is current while evaluating your ~/.emacs (probably the scratch
> buffer). You need to customize sh-mode-hook instead.
Indeed, that's where I started. My current .emacs contains the following
code:
(add-hook 'sh-mode-hook (lambda ()
(setq sh-electric-here-document-mode nil)))
Here's the documentation for the variable sh-electric-here-document-mode:
sh-electric-here-document-mode is a variable defined in `sh-script.el'.
Its value is nil
Local in buffer aaa.sh; global value is the same.
Automatically becomes buffer-local when set.
Documentation:
Non-nil if Sh-Electric-Here-Document mode is enabled.
Use the command `sh-electric-here-document-mode' to change this
variable.
It's that last line that led me to try the code samples I originally
posted. However, looking at its source, it's just setting sh-mode-hook,
which is essentially what Philipp Stephani suggested.
I should have mentioned this in the original post: emacs version 24.5.
(I know I'm a bit out of date. Has this changed?)
--
,Doug
d.lewan2000@gmail.com
(908) 720 7908
"Lie and deny." It's very popular these days.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Turning off sh-electric-here-document-mode?
2020-05-13 11:22 ` Philipp Stephani
2020-05-13 14:00 ` Douglas Lewan
@ 2020-05-13 18:54 ` Douglas Lewan
2020-05-13 19:00 ` Noam Postavsky
1 sibling, 1 reply; 11+ messages in thread
From: Douglas Lewan @ 2020-05-13 18:54 UTC (permalink / raw)
To: help-gnu-emacs
On 5/13/20 7:22 AM, Philipp Stephani wrote:
> Am Mi., 13. Mai 2020 um 02:51 Uhr schrieb Douglas Lewan <d.lewan2000@gmail.com>:
>> OK. I'm sure I'm missing something obvious here.
>>
>> I want to turn off sh-electric-here-document-mode, but all the obvious
>> things seem to fail. I've put every one of the following in my .emacs,
>> but I still get here-documents in shell-script-mode.
>>
>> (sh-electric-here-document-mode nil)
>>
>> (sh-electric-here-document-mode 0)
>>
>> (sh-electric-here-document-mode -1)
>>
>> (sh-electric-here-document-mode)
>>
>> How do I do this? Thanks in advance.
>>
>
> It's a local mode, so all of those will only enable it in whatever
> buffer is current while evaluating your ~/.emacs (probably the scratch
> buffer). You need to customize sh-mode-hook instead.
Recall that this was emacs version 24.5. Possibly another important
detail: It's Debian. (I know Debian does you some "favors"; this may
have been yet another one.)
I finally found the following solution
;; Don't give me here-documents by default.
(add-hook 'sh-mode-hook (lambda ()
(setq sh-electric-here-document-mode nil)
(sh-electric-here-document-mode 0)))
I don't know if that's a right way of doing it, but it works.
Thanks for the thought. It definitely nudged me in a right direction.
--
,Doug
d.lewan2000@gmail.com
(908) 720 7908
"Lie and deny." It's very popular these days.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Turning off sh-electric-here-document-mode?
2020-05-13 18:54 ` Douglas Lewan
@ 2020-05-13 19:00 ` Noam Postavsky
2020-05-13 23:10 ` Douglas Lewan
0 siblings, 1 reply; 11+ messages in thread
From: Noam Postavsky @ 2020-05-13 19:00 UTC (permalink / raw)
To: Douglas Lewan; +Cc: help-gnu-emacs
On Wed, 13 May 2020 at 14:54, Douglas Lewan <d.lewan2000@gmail.com> wrote:
> ;; Don't give me here-documents by default.
> (add-hook 'sh-mode-hook (lambda ()
> (setq sh-electric-here-document-mode nil)
> (sh-electric-here-document-mode 0)))
>
> I don't know if that's a right way of doing it, but it works.
The setq is redundant. And I usually prefer -1 rather than 0 to
disable modes for style reasons, but it works either way.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Turning off sh-electric-here-document-mode?
2020-05-13 19:00 ` Noam Postavsky
@ 2020-05-13 23:10 ` Douglas Lewan
2020-05-14 1:50 ` Noam Postavsky
0 siblings, 1 reply; 11+ messages in thread
From: Douglas Lewan @ 2020-05-13 23:10 UTC (permalink / raw)
To: Noam Postavsky; +Cc: help-gnu-emacs
On 5/13/20 3:00 PM, Noam Postavsky wrote:
> On Wed, 13 May 2020 at 14:54, Douglas Lewan <d.lewan2000@gmail.com> wrote:
>
>> ;; Don't give me here-documents by default.
>> (add-hook 'sh-mode-hook (lambda ()
>> (setq sh-electric-here-document-mode nil)
>> (sh-electric-here-document-mode 0)))
>>
>> I don't know if that's a right way of doing it, but it works.
> The setq is redundant. And I usually prefer -1 rather than 0 to
> disable modes for style reasons, but it works either way.
Thanks.
You're right, -1 works too. As someone who's really entirely self-taught
in programming, I'm curious about what you mean by "style reasons" here.
--
,Doug
d.lewan2000@gmail.com
(908) 720 7908
"Lie and deny." It's very popular these days.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Turning off sh-electric-here-document-mode?
2020-05-13 14:00 ` Douglas Lewan
@ 2020-05-14 1:25 ` Nick Dokos
2020-05-14 1:47 ` Noam Postavsky
0 siblings, 1 reply; 11+ messages in thread
From: Nick Dokos @ 2020-05-14 1:25 UTC (permalink / raw)
To: help-gnu-emacs
Douglas Lewan <d.lewan2000@gmail.com> writes:
> On 5/13/20 7:22 AM, Philipp Stephani wrote:
>> Am Mi., 13. Mai 2020 um 02:51 Uhr schrieb Douglas Lewan <d.lewan2000@gmail.com>:
>>> OK. I'm sure I'm missing something obvious here.
>>>
>>> I want to turn off sh-electric-here-document-mode, but all the obvious
>>> things seem to fail. I've put every one of the following in my .emacs,
>>> but I still get here-documents in shell-script-mode.
>>>
>>> (sh-electric-here-document-mode nil)
>>>
>>> (sh-electric-here-document-mode 0)
>>>
>>> (sh-electric-here-document-mode -1)
>>>
>>> (sh-electric-here-document-mode)
>>>
>>> How do I do this? Thanks in advance.
>>>
>>
>> It's a local mode, so all of those will only enable it in whatever
>> buffer is current while evaluating your ~/.emacs (probably the scratch
>> buffer). You need to customize sh-mode-hook instead.
>
> Indeed, that's where I started. My current .emacs contains the
> following code:
>
> (add-hook 'sh-mode-hook (lambda ()
> (setq sh-electric-here-document-mode nil)))
>
> Here's the documentation for the variable sh-electric-here-document-mode:
>
> sh-electric-here-document-mode is a variable defined in `sh-script.el'.
> Its value is nil
> Local in buffer aaa.sh; global value is the same.
>
> Automatically becomes buffer-local when set.
>
> Documentation:
> Non-nil if Sh-Electric-Here-Document mode is enabled.
> Use the command `sh-electric-here-document-mode' to change this
> variable.
>
Basically, the variable `sh-electric-here-document-mode' is an
indicator light: you are supposed to look at it, but setting it to nil
is basically smashing it: it no longer tells you the state of the
underlying switch but that does not change the state of the switch.
The switch is the *function* `sh-electric-here-document-mode': you
call it with e.g -1 as its argument to turn the mode off (which as a
side effect turns the indicator light off, i.e. sets the above
variable to nil). See the doc string of the function for details.
The point however is that sh-electric-here-document-mode is on by
default *because* sh-mode-hook already contains the function that
turns it on, so what you really want to do is delete that function
from the hook:
(remove-hook 'sh-mode-hook 'sh-electric-here-document-mode)
should do it.
--
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] 11+ messages in thread
* Re: Turning off sh-electric-here-document-mode?
2020-05-14 1:25 ` Nick Dokos
@ 2020-05-14 1:47 ` Noam Postavsky
2020-05-14 2:25 ` Nick Dokos
0 siblings, 1 reply; 11+ messages in thread
From: Noam Postavsky @ 2020-05-14 1:47 UTC (permalink / raw)
To: Nick Dokos; +Cc: Help Gnu Emacs mailing list
On Wed, 13 May 2020 at 21:26, Nick Dokos <ndokos@gmail.com> wrote:
> (remove-hook 'sh-mode-hook 'sh-electric-here-document-mode)
>
> should do it.
Only in Emacs 25.1 or later.
[1: ac00a92e3d]: 2016-04-16 14:47:49 -0400
Make sh-electric-here-document-mode accessible in sh-mode-hook. (Bug#3226)
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=ac00a92e3df7111c0eb2c6456ae7df5850bfd8fa
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Turning off sh-electric-here-document-mode?
2020-05-13 23:10 ` Douglas Lewan
@ 2020-05-14 1:50 ` Noam Postavsky
2020-05-14 2:28 ` Douglas Lewan
0 siblings, 1 reply; 11+ messages in thread
From: Noam Postavsky @ 2020-05-14 1:50 UTC (permalink / raw)
To: Douglas Lewan; +Cc: help-gnu-emacs
On Wed, 13 May 2020 at 19:10, Douglas Lewan <d.lewan2000@gmail.com> wrote:
> You're right, -1 works too. As someone who's really entirely self-taught
> in programming, I'm curious about what you mean by "style reasons" here.
I just find -1 to mean disable more obvious than 0. I also use +1
rather than 1 to enable, so it matches.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Turning off sh-electric-here-document-mode?
2020-05-14 1:47 ` Noam Postavsky
@ 2020-05-14 2:25 ` Nick Dokos
0 siblings, 0 replies; 11+ messages in thread
From: Nick Dokos @ 2020-05-14 2:25 UTC (permalink / raw)
To: help-gnu-emacs
Noam Postavsky <npostavs@gmail.com> writes:
> On Wed, 13 May 2020 at 21:26, Nick Dokos <ndokos@gmail.com> wrote:
>
>> (remove-hook 'sh-mode-hook 'sh-electric-here-document-mode)
>>
>> should do it.
>
> Only in Emacs 25.1 or later.
>
> [1: ac00a92e3d]: 2016-04-16 14:47:49 -0400
> Make sh-electric-here-document-mode accessible in sh-mode-hook. (Bug#3226)
> https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=ac00a92e3df7111c0eb2c6456ae7df5850bfd8fa
>
>
Thanks for the pointer!
--
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] 11+ messages in thread
* Re: Turning off sh-electric-here-document-mode?
2020-05-14 1:50 ` Noam Postavsky
@ 2020-05-14 2:28 ` Douglas Lewan
0 siblings, 0 replies; 11+ messages in thread
From: Douglas Lewan @ 2020-05-14 2:28 UTC (permalink / raw)
To: Noam Postavsky; +Cc: help-gnu-emacs
On 5/13/20 9:50 PM, Noam Postavsky wrote:
> On Wed, 13 May 2020 at 19:10, Douglas Lewan <d.lewan2000@gmail.com> wrote:
>
>> You're right, -1 works too. As someone who's really entirely self-taught
>> in programming, I'm curious about what you mean by "style reasons" here.
> I just find -1 to mean disable more obvious than 0. I also use +1
> rather than 1 to enable, so it matches.
Got it. Thanks.
--
,Doug
d.lewan2000@gmail.com
(908) 720 7908
"Lie and deny." It's very popular these days.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2020-05-14 2:28 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-13 0:51 Turning off sh-electric-here-document-mode? Douglas Lewan
2020-05-13 11:22 ` Philipp Stephani
2020-05-13 14:00 ` Douglas Lewan
2020-05-14 1:25 ` Nick Dokos
2020-05-14 1:47 ` Noam Postavsky
2020-05-14 2:25 ` Nick Dokos
2020-05-13 18:54 ` Douglas Lewan
2020-05-13 19:00 ` Noam Postavsky
2020-05-13 23:10 ` Douglas Lewan
2020-05-14 1:50 ` Noam Postavsky
2020-05-14 2:28 ` Douglas Lewan
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).