org-src.el: Apply common faces even when src block language mode is absent

* lisp/org-src.el (org-src-font-lock-fontify-block): Apply
`org-src-block-faces'/`org-block' faces even when no major mode is
available for the src block language.

Reported-by: duskhorn <duskhorn@proton.me>
Link: https://orgmode.org/list/zCjC9UjXEgJk8kuyi8t2K2XzO3fL7pYWynHhoYWAes9eCA1FkomCY9bss4uKZfBg60M4xUisyDqFWKVMOn1r_XzUVE7gr3ci82MEOLjGIMk=@proton.me
This commit is contained in:
Ihor Radchenko 2022-12-26 11:55:26 +03:00
parent de83f548d9
commit ecfb55af0a
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 77 additions and 77 deletions

View File

@ -629,12 +629,12 @@ Leave point in edit buffer."
"Fontify code block between START and END using LANG's syntax. "Fontify code block between START and END using LANG's syntax.
This function is called by Emacs' automatic fontification, as long This function is called by Emacs' automatic fontification, as long
as `org-src-fontify-natively' is non-nil." as `org-src-fontify-natively' is non-nil."
(let ((modified (buffer-modified-p)))
(remove-text-properties start end '(face nil))
(let ((lang-mode (org-src-get-lang-mode lang))) (let ((lang-mode (org-src-get-lang-mode lang)))
(when (fboundp lang-mode) (when (fboundp lang-mode)
(let ((string (buffer-substring-no-properties start end)) (let ((string (buffer-substring-no-properties start end))
(modified (buffer-modified-p))
(org-buffer (current-buffer))) (org-buffer (current-buffer)))
(remove-text-properties start end '(face nil))
(with-current-buffer (with-current-buffer
(get-buffer-create (get-buffer-create
(format " *org-src-fontification:%s*" lang-mode)) (format " *org-src-fontification:%s*" lang-mode))
@ -694,7 +694,7 @@ as `org-src-fontify-natively' is non-nil."
'org-src-invisible new-prop 'org-src-invisible new-prop
org-buffer))))))) org-buffer)))))))
(setq pos next))) (setq pos next)))
(set-buffer-modified-p nil)) (set-buffer-modified-p nil)))))
;; Add Org faces. ;; Add Org faces.
(let ((src-face (nth 1 (assoc-string lang org-src-block-faces t)))) (let ((src-face (nth 1 (assoc-string lang org-src-block-faces t))))
(when (or (facep src-face) (listp src-face)) (when (or (facep src-face) (listp src-face))
@ -705,7 +705,7 @@ as `org-src-fontify-natively' is non-nil."
(add-text-properties (add-text-properties
start end start end
'(font-lock-fontified t fontified t font-lock-multiline t)) '(font-lock-fontified t fontified t font-lock-multiline t))
(set-buffer-modified-p modified))))) (set-buffer-modified-p modified)))
(defun org-fontify-inline-src-blocks (limit) (defun org-fontify-inline-src-blocks (limit)
"Try to apply `org-fontify-inline-src-blocks-1'." "Try to apply `org-fontify-inline-src-blocks-1'."