help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Turning off sh-electric-here-document-mode?


From: Nick Dokos
Subject: Re: Turning off sh-electric-here-document-mode?
Date: Wed, 13 May 2020 21:25:41 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]