From ec302d2a7ad3092b813184a3ce808adc65455943 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Wed, 30 Sep 2009 09:22:33 +0200 Subject: [PATCH] Add new capabilities to org-mobile.el - Allow to set any TODO keyword - Allow to replace the local tags --- lisp/ChangeLog | 6 ++++++ lisp/org-mobile.el | 25 ++++++++++++++++--------- lisp/org.el | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 9 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7809272a4..2eff23f7a 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,11 @@ 2009-09-30 Carsten Dominik + * org.el (org-set-tags-to): New command. + + * org-mobile.el (org-mobile-action-alist): Add more options and + update the docstring. + (org-mobile-apply-flags): Parse for and use the data. + * org-latex.el (org-export-latex-set-initial-vars): Also check in the plist. diff --git a/lisp/org-mobile.el b/lisp/org-mobile.el index a61dac3cf..6fd6ff99f 100644 --- a/lisp/org-mobile.el +++ b/lisp/org-mobile.el @@ -91,16 +91,21 @@ should point to this file." (defcustom org-mobile-action-alist '(("d" . (org-todo 'done)) ("a" . (org-archive-subtree-default)) - ("d-a" . (progn (org-todo 'done) (org-archive-subtree-default)))) + ("d-a" . (progn (org-todo 'done) (org-archive-subtree-default))) + ("todo" . (org-todo data)) + ("tags" . (org-set-tags-to data))) "Alist with flags and actions for mobile sync. When flagging an entry, MobileOrg will create entries that look like - * F(action) [[id:entry-id][entry title]] + * F(action:data) [[id:entry-id][entry title]] -This alist defines that the action in the parentheses of F() should mean, -i.e. what action should be taken. The car of each elements of the alist -is an actions string. The cdr is an Emacs Lisp form that will be evaluated -with the cursor on the headline of that entry." +This alist defines that the ACTION in the parentheses of F() should mean, +i.e. what action should be taken. The :data part in the parenthesis is +optional. If present, the string after the colon will be passed to the +action form as the `data' variable. +The car of each elements of the alist is an actions string. The cdr is +an Emacs Lisp form that will be evaluated with the cursor on the headline +of that entry." :group 'org-mobile :type '(repeat (cons (string :tag "Action flag") @@ -413,14 +418,16 @@ If BEG and END are given, only do this in that region." (setq beg (or beg (point-min)) end (or end (point-max))) (goto-char beg) (let ((marker (make-marker)) + (org-inhibit-logging 'note) (end (move-marker (make-marker) end)) - action id id-pos cmd text) + action data id id-pos cmd text) (while (re-search-forward - "^\\*+[ \t]+F(\\([^()\n]*\\))[ \t]+\\[\\[id:\\([^]\n ]+\\)" end t) + "^\\*+[ \t]+F(\\([^():\n]*\\)\\(:\\([^()\n]*\\)\\)?)[ \t]+\\[\\[id:\\([^]\n ]+\\)" end t) (goto-char (- (match-beginning 1) 2)) (catch 'next (setq action (match-string 1) - id (match-string 2) + data (and (match-end 3) (match-string 3)) + id (match-string 4) cmd (if (equal action "") '(progn (org-toggle-tag "FLAGGED" 'on) diff --git a/lisp/org.el b/lisp/org.el index ec2d450c4..70ec30874 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -11251,6 +11251,38 @@ If ONOFF is `on' or `off', don't toggle but set to this state." (org-back-to-heading t) (org-set-tags arg just-align)))) +(defun org-set-tags-to (data) + "Set the tags of the current entry to DATA, replacing the current tags. +DATA may be a tags string like :aa:bb:cc:, or a list of tags. +If DATA is nil or the empty string, any tags will be removed." + (interactive "sTags: ") + (setq data + (cond + ((eq data nil) "") + ((equal data "") "") + ((stringp data) + (concat ":" (mapconcat 'identity (org-split-string data ":+") ":") + ":")) + ((listp data) + (concat ":" (mapconcat 'identity data ":") ":")) + t nil)) + (when data + (save-excursion + (org-back-to-heading t) + (when (looking-at org-complex-heading-regexp) + (if (match-end 5) + (progn + (goto-char (match-beginning 5)) + (insert data) + (delete-region (point) (point-at-eol)) + (org-set-tags nil 'align)) + (goto-char (point-at-eol)) + (insert " " data) + (org-set-tags nil 'align))) + (beginning-of-line 1) + (if (looking-at ".*?\\([ \t]+\\)$") + (delete-region (match-beginning 1) (match-end 1)))))) + (defun org-set-tags (&optional arg just-align) "Set the tags for the current headline. With prefix ARG, realign all tags in headings in the current buffer."