From 84945f9de037949b2be3801acb496540c9365722 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Wed, 12 Jun 2024 15:31:45 +0200 Subject: [PATCH] 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 Link: https://orgmode.org/list/CAJ+Teoehk30LKVCTwMy0uREBHkNVBvrOLDZYboUQ4wBV6Fnwzw@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 37ce91570..4a2623b55 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)