Function: org-agenda-undo

org-agenda-undo is an interactive and byte-compiled function defined in org-agenda.el.gz.

Signature

(org-agenda-undo)

Documentation

Undo a remote editing step in the agenda.

This undoes changes both in the agenda buffer and in the remote buffer that have been changed along.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-agenda.el.gz
(defun org-agenda-undo ()
  "Undo a remote editing step in the agenda.
This undoes changes both in the agenda buffer and in the remote buffer
that have been changed along."
  (interactive)
  (or org-agenda-allow-remote-undo
      (user-error "Check the variable `org-agenda-allow-remote-undo' to activate remote undo"))
  (when (not (eq this-command last-command))
    (setq org-agenda-undo-has-started-in nil
	  org-agenda-pending-undo-list org-agenda-undo-list))
  (when (not org-agenda-pending-undo-list)
    (user-error "No further undo information"))
  (let* ((entry (pop org-agenda-pending-undo-list))
	 buf line cmd rembuf)
    (setq cmd (pop entry) line (pop entry))
    (setq rembuf (nth 2 entry))
    (org-with-remote-undo rembuf
      (while (bufferp (setq buf (pop entry)))
	(when (pop entry)
	  (with-current-buffer buf
	    (let (;; (last-undo-buffer buf)
                  (inhibit-read-only t))
	      (unless (memq buf org-agenda-undo-has-started-in)
		(push buf org-agenda-undo-has-started-in)
		(make-local-variable 'pending-undo-list)
		(undo-start))
	      (while (and pending-undo-list
			  (listp pending-undo-list)
			  (not (car pending-undo-list)))
		(pop pending-undo-list))
	      (undo-more 1))))))
    (org-goto-line line)
    (message "`%s' undone (buffer %s)" cmd (buffer-name rembuf))))