Kaynağa Gözat

Use font-lock-append-text-property to apply org-src faces

* lisp/org-src.el (org-src-font-lock-fontify-block): Replace anonymous
  faces with inheritance by lists of faces constructed by
  `font-lock-add-text-property`.  This properly deals with cases when
  the source buffer's `face' property is already a list.
Clément Pit--Claudel 8 yıl önce
ebeveyn
işleme
b7dd0e8511
1 değiştirilmiş dosya ile 8 ekleme ve 11 silme
  1. 8 11
      lisp/org-src.el

+ 8 - 11
lisp/org-src.el

@@ -492,10 +492,7 @@ as `org-src-fontify-natively' is non-nil."
     (when (fboundp lang-mode)
       (let ((string (buffer-substring-no-properties start end))
 	    (modified (buffer-modified-p))
-	    (org-buffer (current-buffer))
-	    (block-faces (let ((face-name (intern (format "org-block-%s" lang))))
-			   (append (and (facep face-name) (list face-name))
-				   '(org-block)))))
+	    (org-buffer (current-buffer)))
 	(remove-text-properties start end '(face nil))
 	(with-current-buffer
 	    (get-buffer-create
@@ -509,14 +506,14 @@ as `org-src-fontify-natively' is non-nil."
 	    (while (setq next (next-single-property-change pos 'face))
 	      (let ((new-face (get-text-property pos 'face)))
 		(put-text-property
-		 (+ start (1- pos)) (1- (+ start next)) 'face
-		 (list :inherit (append (and new-face (list new-face))
-					block-faces))
+		 (+ start (1- pos)) (1- (+ start next)) 'face new-face
 		 org-buffer))
-	      (setq pos next))
-	    ;; Add the face to the remaining part of the text.
-	    (put-text-property (1- (+ start pos)) end 'face
-			       (list :inherit block-faces) org-buffer)))
+	      (setq pos next))))
+	;; Add Org faces.
+	(let ((face-name (intern (format "org-block-%s" lang))))
+	  (when (facep face-name)
+	    (font-lock-append-text-property start end 'face face-name))
+	  (font-lock-append-text-property start end 'face 'org-block))
 	(add-text-properties
 	 start end
 	 '(font-lock-fontified t fontified t font-lock-multiline t))