;; capmove.el org-mode capture moving the point in a buffer ;; $ emacs -Q -l capfail.el (unless window-system (insert "This test needs window-system, exiting...") (sleep-for 3) (kill-emacs)) (setq inhibit-splash-screen t) (add-to-list 'load-path "~/.emacs.d/org/lisp") (require 'org) (setq org-capture-templates '(("t" "Todo" entry (file "todo.org") "* TODO %^{Title}\n %?"))) (define-key global-map (kbd "C-c c") 'org-capture) (switch-to-buffer "test.org") (insert "we start here and do some editing\n") (goto-char 0) (select-frame (make-frame)) (goto-char (point-max)) (dotimes (n 5) (insert (format "%d\n" n)) (sit-for 1)) (insert "now we invoke capture here") (sit-for 1) (setq last-kbd-macro [?\C-c ?c ?t ?t ?e ?s ?t return return]) (sleep-for 3) (kmacro-call-macro nil) (insert "note that capture had already moved the point\n") (insert "to the top of the file in this buffer\n\n") (sit-for 3) (insert "so we end up in a different place when we finish\n") (insert "even if we abort it with C-c C-k") (sit-for 3) (setq last-kbd-macro [?\C-c ?\C-k]) (sleep-for 3) (kmacro-call-macro nil) (provide 'capmove)