branch: externals-release/org
commit a1a9d408a423d1bf7e07392eef00ce296b3604fb
Author: Ihor Radchenko <yanta...@posteo.net>
Commit: Ihor Radchenko <yanta...@posteo.net>

    org-src-font-lock-fontify-block: Fix blocks without lang
    
    * lisp/org-src.el (org-src-font-lock-fontify-block):
    Fix error fontifying blocks without language containing tabs.
    
    Reported-by: Aitenate <aiten...@outlook.com>
    Link: 
https://orgmode.org/list/du2p250mb020615b1fc610cc3f56340fbdb...@du2p250mb0206.eurp250.prod.outlook.com
---
 lisp/org-src.el | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index 302c27ac86..6570b1b2ab 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -740,20 +740,21 @@ as `org-src-fontify-natively' is non-nil."
         (font-lock-append-text-property start end 'face src-face))
       (font-lock-append-text-property start end 'face 'org-block))
     ;; Display native tab indentation characters as spaces
-    (save-excursion
-      (goto-char start)
-      (let ((indent-offset
-            (if (org-src-preserve-indentation-p) 0
-              (+ (progn (backward-char)
-                         (org-current-text-indentation))
-                 org-edit-src-content-indentation))))
-        (while (re-search-forward "^[ ]*\t" end t)
-          (let* ((b (and (eq indent-offset (move-to-column indent-offset))
-                         (point)))
-                 (e (progn (skip-chars-forward "\t") (point)))
-                 (s (and b (make-string (* (- e b) native-tab-width) ? ))))
-            (when (and b (< b e)) (add-text-properties b e `(display ,s)))
-            (forward-char)))))
+    (when native-tab-width
+      (save-excursion
+        (goto-char start)
+        (let ((indent-offset
+              (if (org-src-preserve-indentation-p) 0
+                (+ (progn (backward-char)
+                           (org-current-text-indentation))
+                   org-edit-src-content-indentation))))
+          (while (re-search-forward "^[ ]*\t" end t)
+            (let* ((b (and (eq indent-offset (move-to-column indent-offset))
+                           (point)))
+                   (e (progn (skip-chars-forward "\t") (point)))
+                   (s (and b (make-string (* (- e b) native-tab-width) ? ))))
+              (when (and b (< b e)) (add-text-properties b e `(display ,s)))
+              (forward-char))))))
     (add-text-properties
      start end
      '(font-lock-fontified t fontified t font-lock-multiline t))

Reply via email to