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

    orgtbl-gather-send-defs: Fix infinite loop when table is at bob
    
    * lisp/org-table.el (orgtbl-gather-send-defs): Avoid infinite loop
    when table is at the beginning of buffer.
    
    Reported-by: Rustom Mody <rustompm...@gmail.com>
    Link: 
https://orgmode.org/list/caj+teoehk30lkvctwmy0urebhknvbvroldzybouq4wbv6fn...@mail.gmail.com
---
 lisp/org-table.el | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/lisp/org-table.el b/lisp/org-table.el
index 37ce91570d..4a2623b553 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -5477,14 +5477,16 @@ a radio table."
     (goto-char (org-table-begin))
     (let (rtn)
       (forward-line -1)
-      (while (looking-at "[ \t]*#\\+ORGTBL[: \t][ \t]*SEND[ \t]+\\([^ 
\t\r\n]+\\)[ \t]+\\([^ \t\r\n]+\\)\\([ \t]+.*\\)?")
-       (let ((name (org-no-properties (match-string 1)))
-             (transform (intern (match-string 2)))
-             (params (if (match-end 3)
-                         (read (concat "(" (match-string 3) ")")))))
-         (push (list :name name :transform transform :params params)
-               rtn)
-         (forward-line -1)))
+      (catch :bob
+        (while (looking-at "[ \t]*#\\+ORGTBL[: \t][ \t]*SEND[ \t]+\\([^ 
\t\r\n]+\\)[ \t]+\\([^ \t\r\n]+\\)\\([ \t]+.*\\)?")
+         (let ((name (org-no-properties (match-string 1)))
+               (transform (intern (match-string 2)))
+               (params (if (match-end 3)
+                           (read (concat "(" (match-string 3) ")")))))
+           (push (list :name name :transform transform :params params)
+                 rtn)
+            (when (bobp) (throw :bob nil))
+           (forward-line -1))))
       rtn)))
 
 (defun orgtbl-send-replace-tbl (name text)

Reply via email to