Browse Source

org-src: Allow per language block face

* lisp/org-src.el (org-src-font-lock-fontify-block):
* lisp/org.el (org-fontify-meta-lines-and-blocks-1): Allow per-block
  face.

Suggested-by: Karl Voit <devnull <at> Karl-Voit.at>
<http://thread.gmane.org/gmane.emacs.orgmode/103833/focus=107645
Rasmus 8 years ago
parent
commit
b0def38b4b
2 changed files with 12 additions and 4 deletions
  1. 6 3
      lisp/org-src.el
  2. 6 1
      lisp/org.el

+ 6 - 3
lisp/org-src.el

@@ -494,7 +494,10 @@ 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)))
+	    (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)))))
 	(remove-text-properties start end '(face nil))
 	(with-current-buffer
 	    (get-buffer-create
@@ -510,12 +513,12 @@ as `org-src-fontify-natively' is non-nil."
 		(put-text-property
 		 (+ start (1- pos)) (1- (+ start next)) 'face
 		 (list :inherit (append (and new-face (list new-face))
-					(list 'org-block)))
+					block-faces))
 		 org-buffer))
 	      (setq pos next))
 	    ;; Add the face to the remaining part of the text.
 	    (put-text-property (1- (+ start pos)) end 'face
-			       '(:inherit org-block) org-buffer)))
+			       (list :inherit block-faces) org-buffer)))
 	(add-text-properties
 	 start end
 	 '(font-lock-fontified t fontified t font-lock-multiline t))

+ 6 - 1
lisp/org.el

@@ -5976,7 +5976,12 @@ by a #."
 	      (add-text-properties beg1 block-end '(src-block t)))
 	     (quoting
 	      (add-text-properties beg1 (min (point-max) (1+ end1))
-				   '(face org-block))) ; end of source block
+				   (list 'face
+					 (list :inherit
+					       (let ((face-name
+						      (intern (format "org-block-%s" lang))))
+						 (append (and (facep face-name) (list face-name))
+							 '(org-block))))))) ; end of source block
 	     ((not org-fontify-quote-and-verse-blocks))
 	     ((string= block-type "quote")
 	      (add-text-properties beg1 (min (point-max) (1+ end1)) '(face org-quote)))