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

$ export EDITOR="emacsclient"
$ C-x C-e
(add-hook 'server-visit-hook
          (lambda ()
            (sh-mode)))

用不着加个空 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)
    

GitHub - bbatsov/emacs-lisp-style-guide: A community-driven Emacs Lisp style guide

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