emacs-diffs
[Top][All Lists]
Advanced

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

emacs-29 e62f8b0239d: Fix visiting XBM/XPM files when 'c-ts-mode' is act


From: Eli Zaretskii
Subject: emacs-29 e62f8b0239d: Fix visiting XBM/XPM files when 'c-ts-mode' is active
Date: Sun, 19 Mar 2023 16:20:42 -0400 (EDT)

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

    Fix visiting XBM/XPM files when 'c-ts-mode' is active
    
    * lisp/progmodes/c-ts-mode.el (treesit-ready-p): Fix association
    for XBM/XPM files in 'auto-mode-alist'.  (Bug#62276)
---
 lisp/progmodes/c-ts-mode.el | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index ff86b9e0544..659db46dc12 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -1061,10 +1061,15 @@ the code is C or C++ and based on that chooses whether 
to enable
                  
'("\\(\\.ii\\|\\.\\(CC?\\|HH?\\)\\|\\.[ch]\\(pp\\|xx\\|\\+\\+\\)\\|\\.\\(cc\\|hh\\)\\)\\'"
                    . c++-ts-mode)))
 
-(if (treesit-ready-p 'c)
-    (add-to-list 'auto-mode-alist
-                 '("\\(\\.[chi]\\|\\.lex\\|\\.y\\(acc\\)?\\|\\.x[bp]m\\)\\'"
-                   . c-ts-mode)))
+(when (treesit-ready-p 'c)
+  (add-to-list 'auto-mode-alist
+               '("\\(\\.[chi]\\|\\.lex\\|\\.y\\(acc\\)?\\)\\'" . c-ts-mode))
+  (add-to-list 'auto-mode-alist '("\\.x[pb]m\\'" . c-ts-mode))
+  ;; image-mode's association must be before the C mode, otherwise XPM
+  ;; images will be initially visited as C files.  Also note that the
+  ;; regexp must be different from what files.el does, or else
+  ;; add-to-list will not add the association where we want it.
+  (add-to-list 'auto-mode-alist '("\\.x[pb]m\\'" . image-mode)))
 
 (if (and (treesit-ready-p 'cpp)
          (treesit-ready-p 'c))



reply via email to

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