Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7083261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:09:23+00:00 2026-05-28T07:09:23+00:00

For some reason my shell script mode hooks do not get executed. Example in

  • 0

For some reason my shell script mode hooks do not get executed. Example in my .emacs:

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

causes the variables to be set, but the mode is not loaded for the opened script files. What is the proper way to hook here?

I use the default shell script mode (modeline says e.g. Shell-script[bash]). Do I have to hook for each shell type individually (sh, bash, zsh)? If yes can you please tell me how?

Thank you very much!

EDIT3:

It turned out to be due a conflict of textmate-mode with the skeleton-pair-insert in sh-mode (I tried to avoid the conflict by disabling textmate in sh-mode, which then left the sh-mood-hook aparatus in ruins. I’ve removed textmate-mode completely and use now the standard skeleton-pair approch globaly.

I’ll accept phils answer – without him I’d probably not be able to debug this on my own.

EDIT2:

Thanks to phils, I think his comment takes us closer to solution. It’s not a problem with rainbow-delimiters though. I removed all sh-mode-hook except your hello message one and restart Emacs. When I open a .sh file I get this:

Setting up indent for shell type bash
setting up indent stuff
Indentation variables are now local.
Indentation setup for shell type bash
File mode specification error: (void-function nil)

Note no “hello” message. The value of sh-mode-hook is:
(nil
(lambda nil
(message "hello")))

I think the problem is this first nil value – though I don’t see that it would be set anywhere.

If I eval this:

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

I see the hello message, though after restart (I’ve put those lines in .emacs) it is gone again (the nil is again on top of the hook).

Any idea what to do to have active hook at setup?

EDIT1:
I’ve tried also:

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

with same negative result – not sure if this is relevant though…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:09:24+00:00Added an answer on May 28, 2026 at 7:09 am

    shell-script-mode is an alias for sh-mode. I haven’t checked, but I would suspect that only the hook variable for the ‘real’ function name is evaluated, so I think sh-mode-hook would be the one to use.

    Anyhow, there’s nothing broken about your syntax, so there may be something amiss with the use of (rainbow-delimiters-mode 1). For instance, you should be able to observe that the following works correctly:

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

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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following shell script. For some reason the java program's standard error
For some reason I never see this done. Is there a reason why not?
For some reason, Section 1 works but Section 2 does not. When run in
For some reason, no matter how I go about it, I cannot get TortoiseSVN
I need some example Jython, or Java, code to exec an interactive OS shell
I am new to Shell script. Just have a small question about some script
For some reason when I attempt to make a request to an Ajax.net web
For some reason when I create a new namespace in Visual Studio 2008 its
For some reason, when I try to install SQL Server 2008 Express , I
For some reason, lately the *.UDL files on many of my client systems are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.