123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- (defcustom org-fastup-action-alist
- '((?A org-archive t)
- (?T (org-todo 1) nil)
- (?D (org-todo (length org-todo-keywords)) nil)
- (?N org-todo nil)
- (?< org-promote-subtree t)
- (?> org-demote-subtree t)
- (?M org-set-tags nil)
- (?S org-schedule t))
- "List of fastupdate actions.
- Each entry in this list is a list of 3 items:
- - A character representing the fastupdate action
- - A function or form to be executed, with cursor at beginning of headline
- - A flag indicating if execution of this action should normally be confirmed."
- :group 'org-fastup
- :type '(repeat
- (list :value (?a nil t)
- (character :tag "Prefix char")
- (choice
- (const :tag "Archive this subtree" org-archive)
- (const :tag "Make TODO" (org-todo 1))
- (const :tag "Mark DONE" (org-todo (length org-todo-keywords)))
- (const :tag "Cycle TODO" org-todo)
- (const :tag "Promote subtree" org-promote-subtree)
- (const :tag "Demote subtree" org-demote-subtree)
- (const :tag "Set Tags" org-set-tags)
- (const :tag "Schedule" org-schedule)
- (const :tag "Set Deadline" org-schedule)
- (sexp))
- (boolean :tag "Confirm"))))
- (defun org-fastup-check-buffer ()
- "Check for and execute fastupdate actions.
- This first checks if there are any fastupdate actions in the buffer.
- If yes, the user is asked for a processing mode, with three possibilities
- with respect to confirming actions:
- Always confirm each action before executing it
- Never execute all actions without prior confirmation
- Maybe get only confirmation for actions that have been configured
- as requiring confirmation in `org-fastup-action-alist'.
- The command will then walk through the buffer, stop at each eaction
- and do the right thing there."
- (interactive)
- (show-all)
- (let ((start (point-min))
-
-
- (re "^\\([-a-zA-Z0-9!@#$%^&+?<>]\\)\\*+")
- s action confirm)
- (if (not (save-excursion
- (goto-char (point-min))
- (re-search-forward re nil t)))
- (if (interactive-p) (message "No fastupdate actions in this buffer"))
- (goto-char start)
- (message "Fastupdate: Confirm actions [A]lways [Maybe] [N]ever, or [Q]uit?")
- (setq reaction (read-char-exclusive))
- (cond
- ((memq reaction '(?q ?Q)) (error "Abort"))
- ((memq reaction '(?a ?A)) (setq cf 'always))
- ((memq reaction '(?m ?M)) (setq cf 'maybe))
- ((memq reaction '(?n ?N)) (setq cf 'never)))
- (while (re-search-forward re nil t)
- (goto-char (setq start (match-beginning 0)))
- (setq s (match-string 1)
- entry (assoc (string-to-char s) org-fastup-action-alist)
- action (nth 1 entry)
- confirm (nth 2 entry))
- (cond
- ((null action)
- (if (y-or-n-p "Unknown action. Remove fastupdate character? ")
- (delete-region start (1+ start))
- (goto-char (1+ start))))
- ((or (equal cf 'never)
- (and (eq cf 'maybe) (not confirm))
- (y-or-n-p (format "execute action [%s] " s)))
- (delete-region start (1+ start))
-
-
- (if (symbolp action) (funcall action) (eval action))
-
- (sit-for 2))
- (t
- (if (y-or-n-p "Action denied. Remove fastupdate character? ")
-
- (delete-region start (1+ start))
-
- (goto-char (1+ start)))))))))
|