开发者

Infinite loop in emacs lisp when using org-table-convert-region

I've been having trouble with an infinite loop in the code below. It inserts a list of items at point, comma separating them, and then converts the list to an org table.

This works when executing one at a time, but if you call from an emacs lisp function more than once, as below, then it goes into an infinite loop inserting |'s until it locks up or shows the message below.

Update it now locks up when I do (test1) as below

Can dowload a full example of the code from pastebin here

I can't quite figure out what's causing this behaviour. The commented lines reflect different ways to do the same thing that cause the same bug.

(defun org-table-from-list(l)
  "Create an org-table from a list"
  (if (listp l)
      (let ((beg (point)))
    (insert-list l)
;   (message (format "beg end %d %d\n" beg (point)))
    (org-table-convert-region beg (point) '(4))
;   (set-mark beg)
开发者_Python百科;   (end-of-line)
;   (org-table-create-or-convert-from-region '(4))
    (forward-line))))


(defun insert-list(l)
  "insert a list L into the current buffer"
  (let ((str ""))
    (dolist (i l)
      (setf str (concat str i ",")))
    (let ((len (length str)))
      (insert (subseq str 0 (1- len))))))

(defun test1 () (interactive) (org-table-from-list '("apple" "carrot" "coke" "smile")))

(progn 
       (test1)
       (test1))    

The error:

Warning (undo): Buffer `test3.txt' undo info was 12711518 bytes long.
The undo info was discarded because it exceeded `undo-outer-limit'.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜