Add new capabilities to org-mobile.el

- Allow to set any TODO keyword
- Allow to replace the local tags
This commit is contained in:
Carsten Dominik 2009-09-30 09:22:33 +02:00
parent f99fa74db1
commit ec302d2a7a
3 changed files with 54 additions and 9 deletions

View File

@ -1,5 +1,11 @@
2009-09-30 Carsten Dominik <carsten.dominik@gmail.com> 2009-09-30 Carsten Dominik <carsten.dominik@gmail.com>
* 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 * org-latex.el (org-export-latex-set-initial-vars): Also check in
the plist. the plist.

View File

@ -91,16 +91,21 @@ should point to this file."
(defcustom org-mobile-action-alist (defcustom org-mobile-action-alist
'(("d" . (org-todo 'done)) '(("d" . (org-todo 'done))
("a" . (org-archive-subtree-default)) ("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. "Alist with flags and actions for mobile sync.
When flagging an entry, MobileOrg will create entries that look like 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, 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 i.e. what action should be taken. The :data part in the parenthesis is
is an actions string. The cdr is an Emacs Lisp form that will be evaluated optional. If present, the string after the colon will be passed to the
with the cursor on the headline of that entry." 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 :group 'org-mobile
:type '(repeat :type '(repeat
(cons (string :tag "Action flag") (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))) (setq beg (or beg (point-min)) end (or end (point-max)))
(goto-char beg) (goto-char beg)
(let ((marker (make-marker)) (let ((marker (make-marker))
(org-inhibit-logging 'note)
(end (move-marker (make-marker) end)) (end (move-marker (make-marker) end))
action id id-pos cmd text) action data id id-pos cmd text)
(while (re-search-forward (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)) (goto-char (- (match-beginning 1) 2))
(catch 'next (catch 'next
(setq action (match-string 1) (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 "") cmd (if (equal action "")
'(progn '(progn
(org-toggle-tag "FLAGGED" 'on) (org-toggle-tag "FLAGGED" 'on)

View File

@ -11251,6 +11251,38 @@ If ONOFF is `on' or `off', don't toggle but set to this state."
(org-back-to-heading t) (org-back-to-heading t)
(org-set-tags arg just-align)))) (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) (defun org-set-tags (&optional arg just-align)
"Set the tags for the current headline. "Set the tags for the current headline.
With prefix ARG, realign all tags in headings in the current buffer." With prefix ARG, realign all tags in headings in the current buffer."