我在下面的代码中遇到无限循环问题。它在点处插入项目列表,用逗号分隔它们,然后将列表转换为组织表。
这在一次执行一个时有效,但如果你多次从emacs lisp函数调用,如下所示,那么它会进入无限循环插入,直到它锁定或显示下面的消息。
现在更新它会在我执行(test1)时锁定,如下所示
可以从pastebin here
下载完整代码示例我无法弄清楚造成这种行为的原因。注释行反映了导致相同错误的同一事物的不同方式。
(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)
; (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))
错误:
Warning (undo): Buffer `test3.txt' undo info was 12711518 bytes long.
The undo info was discarded because it exceeded `undo-outer-limit'.