branch: externals/org-modern
commit cc8710762656a0175061d4a86a5b58e3be74daba
Author: JD Smith <93749+jdtsm...@users.noreply.github.com>
Commit: JD Smith <93749+jdtsm...@users.noreply.github.com>

    block-bracket-prefix: guard against empty prefix
    
    This occurs for blocks before the first headline.  At present they
    have no bracket styling (org-modern's fringe could be used as a
    fallback).
---
 org-modern-indent.el | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/org-modern-indent.el b/org-modern-indent.el
index 8e525fc23d..73579cebe2 100644
--- a/org-modern-indent.el
+++ b/org-modern-indent.el
@@ -71,16 +71,17 @@ the block is flush left in the buffer."
 The three returned prefixes include begin, end, and guide bracket
 indicators, and are cached by prefix length, for speed.
 Additionally, the original prefix string is included at the end
-of the returned vector."
-  (let* ((l (length prefix)))
-    (or (gethash l org-modern-indent--block-prefixes)
-       (puthash l (cl-loop for type in '("begin" "guide" "end")
-                           for tstr = (symbol-value
-                                       (intern (concat "org-modern-indent-" 
type)))
-                           with pstr = (substring prefix 0 -1)
-                           collect (concat pstr tstr) into prefix-brackets
-                           finally return (vconcat prefix-brackets (list 
prefix)))
-                org-modern-indent--block-prefixes))))
+of the returned vector.  If PREFIX is nil or empty, nil is returned."
+  (unless (or (not prefix) (string-empty-p prefix))
+    (let* ((l (length prefix)))
+      (or (gethash l org-modern-indent--block-prefixes)
+         (puthash l (cl-loop for type in '("begin" "guide" "end")
+                             for tstr = (symbol-value
+                                         (intern (concat "org-modern-indent-" 
type)))
+                             with pstr = (substring prefix 0 -1)
+                             collect (concat pstr tstr) into prefix-brackets
+                             finally return (vconcat prefix-brackets (list 
prefix)))
+                  org-modern-indent--block-prefixes)))))
 
 (defun org-modern-indent--block-bracket-flush ()
   "Insert brackets for org blocks flush with the line prefix."

Reply via email to