diff options
authorBastien Guerry <>2014-07-28 16:54:00 (GMT)
committer Bastien Guerry <>2014-07-28 16:54:00 (GMT)
commitf8b42e8ebeeecdef59a8a7cbc4324264a5162197 (patch)
parent98295a8a25a0eac70ad365ec2c20051fa2964e0a (diff)
Don't use an overlay for src blocks backgrounds
* org-faces.el (org-block-background): Delete. * org.el (org-fontify-meta-lines-and-blocks-1): Don't use an overlay for the block background. (org-in-src-block-p): Check against the `src-block' text property, not against an overlay. The overlay was introduced here: and fixed here But (1) it makes fontification slowler, (2) it makes `org-in-src-block-p' slower and it prevents correct ps-printing of Org buffers. If we want to use a different background color, we need another solution than using overlays.
2 files changed, 2 insertions, 15 deletions
diff --git a/lisp/org-faces.el b/lisp/org-faces.el
index e693dab..83453e8 100644
--- a/lisp/org-faces.el
+++ b/lisp/org-faces.el
@@ -537,9 +537,6 @@ follows a #+DATE:, #+AUTHOR: or #+EMAIL: keyword."
:group 'org-faces
:version "22.1")
-(defface org-block-background '((t ()))
- "Face used for the source block background.")
(org-copy-face 'org-meta-line 'org-block-begin-line
"Face used for the line delimiting the begin of source blocks.")
diff --git a/lisp/org.el b/lisp/org.el
index a153151..7e30061 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5930,15 +5930,7 @@ by a #."
((and lang (not (string= lang "")) org-src-fontify-natively)
(org-src-font-lock-fontify-block lang block-start block-end)
- ;; remove old background overlays
- (mapc (lambda (ov)
- (if (eq (overlay-get ov 'face) 'org-block-background)
- (delete-overlay ov)))
- (overlays-at (/ (+ beg1 block-end) 2)))
- ;; add a background overlay
- (setq ovl (make-overlay beg1 block-end))
- (overlay-put ovl 'face 'org-block-background)
- (overlay-put ovl 'evaporate t)) ; make it go away when empty
+ (add-text-properties beg1 block-end '(src-block t)))
(add-text-properties beg1 (min (point-max) (1+ end1))
'(face org-block))) ; end of source block
@@ -21828,9 +21820,7 @@ and end of string."
When INSIDE is non-nil, don't consider we are within a src block
when point is at #+BEGIN_SRC or #+END_SRC."
(let ((case-fold-search t) ov)
- (or (and (setq ov (overlays-at (point)))
- (memq 'org-block-background
- (overlay-properties (car ov))))
+ (or (and (eq (get-char-property (point) 'src-block) t))
(and (not inside)