初稿: 2018-08-09 Thu 11:07
最終更新日: 2018-12-14 Fri 20:44
ホーム | 文書トップ | 目次

org-with-remote-undo
org-agenda-undo-listにundo情報を記録した上でbodyを実行する

 1: (defmacro org-with-remote-undo (buffer &rest body)
 2:   "Execute BODY while recording undo information in two buffers."
 3:   (declare (debug (form body)) (indent 1))
 4:   (org-with-gensyms (cline cmd buf1 buf2 undo1 undo2 c1 c2)
 5:     `(let ((,cline (org-current-line))
 6:            (,cmd this-command)
 7:            (,buf1 (current-buffer))
 8:            (,buf2 ,buffer)
 9:            (,undo1 buffer-undo-list)
10:            (,undo2 (with-current-buffer ,buffer buffer-undo-list))
11:            ,c1 ,c2)
12:        ,@body
13:        (when org-agenda-allow-remote-undo
14:          (setq ,c1 (org-verify-change-for-undo
15:                     ,undo1 (with-current-buffer ,buf1 buffer-undo-list))
16:                ,c2 (org-verify-change-for-undo
17:                     ,undo2 (with-current-buffer ,buf2 buffer-undo-list)))
18:          (when (or ,c1 ,c2)
19:            ;; make sure there are undo boundaries
20:            (and ,c1 (with-current-buffer ,buf1 (undo-boundary)))
21:            (and ,c2 (with-current-buffer ,buf2 (undo-boundary)))
22:            ;; remember which buffer to undo
23:            (push (list ,cmd ,cline ,buf1 ,c1 ,buf2 ,c2)
24:                  org-agenda-undo-list))))))

日付: 2018-08-09 Thu 11:07

著者: conao

Created: 2018-12-14 Fri 21:04

Validate