Emacs script shell mode box

For some reason, my script mode shells are not executing. An example in my .emacs:

(add-hook 'shell-script-mode-hook (lambda () (rainbow-delimiters-mode 1)))

causes the variables to be set, but the mode does not load for open script files. What is the correct way here?

I use the default shell mode script (modeline says, for example, Shell-script[bash] ). Do I need to connect for each type of shell individually (sh, bash, zsh)? If so, can you tell me how?

Thank you very much!

EDIT3:

This turned out to be due to a text mode conflict with the insertion of a skeleton-pair in sh-mode (I tried to avoid a conflict by disabling textmate in sh-mode, which then left sh-mood-hook aparatus in ruins. I completely deleted text mode and now use the standard skeleton-pair globality.

I agree with the phils answer - without it, I probably would not be able to debug this on my own.

EDIT2:

Thanks to phils, I think his comment brings us closer to a solution. However, this is not a problem with rainbow separators. I removed all sh-mode-hook except your welcome message and restarted Emacs. When I open the .sh file, I get the following:

Indentation settings for the bash shell type indentation settings. Indentation variables are now local. Indenting the bash shell type Invalid file mode specification: (void-function nil)

Pay attention to the message "hello." Sh-mode-hook value: (nil (lambda nil (message "hello")))

I think the problem is that this is the first nil value - although I don’t see it being installed anywhere.

If I do this:

(setq sh-mode-hook t) (add-hook 'sh-mode-hook (lambda () (message "hello")))

I see a welcome message, although after a reboot (I put these lines in .emacs) it disappeared again (zero again on the top of the hook).

Any idea what to do to have an active hook when setting up?

EDIT1: I also tried:

(add-hook 'sh-mode-hook (lambda () (rainbow-delimiters-mode 1)))

with the same negative result - I'm not sure that this is relevant, although ...

+4
source share
2 answers

shell-script-mode is an alias for sh-mode . I did not check, but I would suspect that only the hook variable for the name "real" is evaluated, so I think that sh-mode-hook will be used.

Anyway, nothing is broken in your syntax, so there may be something wrong with (rainbow-delimiters-mode 1) . For example, you should be able to observe that the following works correctly:

(add-hook 'sh-mode-hook (lambda () (message "hello")))

FWIW, for interceptions, I recommend not using anonymous functions at all, simply because it is much easier to update your hook function if it is named (removing the old lambda expression from a variable before adding the updated one is just annoying in my books).

+9
source

Try removing ':

 (add-hook 'shell-script-mode-hook (lambda () (rainbow-delimiters-mode 1))) 
0
source

Source: https://habr.com/ru/post/1391405/


All Articles