When using emacs as command line editor, how to auto set sh-mode as major-mode


#1
$ export EDITOR="emacsclient"
$ C-x C-e

#2
(add-hook 'server-visit-hook
          (lambda ()
            (sh-mode)))

#3

用不着加个空 lambda

  • Don’t wrap functions in anonymous functions when you don’t need to.

    ;; good 
    (cl-remove-if-not #'evenp numbers) 
    
    ;; bad
    (cl-remove-if-not (lambda (x) (evenp x)) numbers)
    

https://github.com/bbatsov/emacs-lisp-style-guide#functions


#4

use #'sh-mode instead of (lambda () (sh-mode))