diff options
author | Eli Zaretskii <eliz@gnu.org> | 2023-04-10 16:09:58 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2023-04-10 16:09:58 +0300 |
commit | 338b3718b6cf14ef13b9390928e2b13b5d4f1797 (patch) | |
tree | 5885eeaf681d201a57f95b14984eb04b2824e3fd | |
parent | b4afee03193575c3812c6f9704cd08d0dc852e5a (diff) | |
download | emacs-338b3718b6cf14ef13b9390928e2b13b5d4f1797.tar.gz |
Fix visiting RPM files
We cannot call 'sh-set-shell' inside 'sh-base-mode', since various
settings of 'sh-mode', in particular the syntax table, is not yet
set. Likewise with various hooks: since 'sh-base-mode' is not a
mode any file should be visited with, it makes no sense to set up
stuff like 'hack-local-variables-hook' in 'sh-base-mode'; it
should be set in the descendant modes instead.
* lisp/progmodes/sh-script.el (sh-base-mode): Move the call to
'sh-set-shell' from here...
(sh-mode): ...to here...
(bash-ts-mode): ...with a copy here. (Bug#62748)
-rw-r--r-- | lisp/progmodes/sh-script.el | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 5493e68d5bd..54da1e0468e 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1537,13 +1537,7 @@ implementations. Currently there are two: `sh-mode' and (lambda (terminator) (if (eq terminator ?') "'\\'" - "\\"))) - ;; Parse or insert magic number for exec, and set all variables depending - ;; on the shell thus determined. - (sh-set-shell (sh--guess-shell) nil nil) - (add-hook 'flymake-diagnostic-functions #'sh-shellcheck-flymake nil t) - (add-hook 'hack-local-variables-hook - #'sh-after-hack-local-variables nil t)) + "\\")))) ;;;###autoload (define-derived-mode sh-mode sh-base-mode "Shell-script" @@ -1603,7 +1597,13 @@ with your script for an edit-interpret-debug cycle." nil nil ((?/ . "w") (?~ . "w") (?. . "w") (?- . "w") (?_ . "w")) nil (font-lock-syntactic-face-function - . ,#'sh-font-lock-syntactic-face-function)))) + . ,#'sh-font-lock-syntactic-face-function))) + ;; Parse or insert magic number for exec, and set all variables depending + ;; on the shell thus determined. + (sh-set-shell (sh--guess-shell) nil nil) + (add-hook 'flymake-diagnostic-functions #'sh-shellcheck-flymake nil t) + (add-hook 'hack-local-variables-hook + #'sh-after-hack-local-variables nil t)) ;;;###autoload (defalias 'shell-script-mode 'sh-mode) @@ -1615,6 +1615,10 @@ This mode automatically falls back to `sh-mode' if the buffer is not written in Bash or sh." :syntax-table sh-mode-syntax-table (when (treesit-ready-p 'bash) + (sh-set-shell "bash" nil nil) + (add-hook 'flymake-diagnostic-functions #'sh-shellcheck-flymake nil t) + (add-hook 'hack-local-variables-hook + #'sh-after-hack-local-variables nil t) (treesit-parser-create 'bash) (setq-local treesit-font-lock-feature-list '(( comment function) |