emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 338b3718b6c: Fix visiting RPM files


From: Eli Zaretskii
Subject: emacs-29 338b3718b6c: Fix visiting RPM files
Date: Mon, 10 Apr 2023 09:11:29 -0400 (EDT)

branch: emacs-29
commit 338b3718b6cf14ef13b9390928e2b13b5d4f1797
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    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)
---
 lisp/progmodes/sh-script.el | 20 ++++++++++++--------
 1 file 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]