From 0c90cdc7793a21e5cf4e8ef5b4043a95d988489b Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Fri, 8 Oct 2010 09:29:42 +0200 Subject: [PATCH] MobileOrg: Use outline path if we cannot make an ID * lisp/org-mobile.el (org-mobile-force-id-on-agenda-items): Fix docstring. (org-mobile-write-agenda-for-mobile): Use outline path if we do not have an ID and are not allowed to make one. (org-mobile-get-outline-path-link): New function. --- lisp/org-mobile.el | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lisp/org-mobile.el b/lisp/org-mobile.el index 5b91ed41e..af3493d16 100644 --- a/lisp/org-mobile.el +++ b/lisp/org-mobile.el @@ -150,7 +150,7 @@ list a list of selection key(s) as string." (string :tag "Selection Keys")))) (defcustom org-mobile-force-id-on-agenda-items t - "Non-nil means make all agenda items carry and ID." + "Non-nil means make all agenda items carry an ID." :group 'org-mobile :type 'boolean) @@ -626,7 +626,8 @@ The table of checksums is written to the file mobile-checksums." (if (org-bound-and-true-p org-mobile-force-id-on-agenda-items) (org-id-get m 'create) - (org-entry-get m "ID"))) + (or (org-entry-get m "ID") + (org-mobile-get-outline-path-link m)))) (insert " :PROPERTIES:\n :ORIGINAL_ID: " id "\n :END:\n"))))) (beginning-of-line 2)) @@ -634,6 +635,21 @@ The table of checksums is written to the file mobile-checksums." org-mobile-checksum-files)) (message "Agenda written to Org file %s" file))) +(defun org-mobile-get-outline-path-link (pom) + (org-with-point-at pom + (concat "olp:" + (org-mobile-escape-olp (file-name-nondirectory buffer-file-name)) + "/" + (mapconcat 'org-mobile-escape-olp + (org-get-outline-path) + "/") + "/" + (org-mobile-escape-olp (nth 4 (org-heading-components)))))) + +(defun org-mobile-escape-olp (s) + (let ((table '((?: . "%3a") (?\[ . "%5b") (?\] . "%5d") (?/ . "%2f")))) + (org-link-escape s table))) + ;;;###autoload (defun org-mobile-create-sumo-agenda () "Create a file that contains all custom agenda views."