org-mobile.el 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069
  1. ;;; org-mobile.el --- Code for asymmetric sync with a mobile device
  2. ;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
  3. ;;
  4. ;; Author: Carsten Dominik <carsten at orgmode dot org>
  5. ;; Keywords: outlines, hypermedia, calendar, wp
  6. ;; Homepage: http://orgmode.org
  7. ;; Version: 7.01trans
  8. ;;
  9. ;; This file is part of GNU Emacs.
  10. ;;
  11. ;; GNU Emacs is free software: you can redistribute it and/or modify
  12. ;; it under the terms of the GNU General Public License as published by
  13. ;; the Free Software Foundation, either version 3 of the License, or
  14. ;; (at your option) any later version.
  15. ;;
  16. ;; GNU Emacs is distributed in the hope that it will be useful,
  17. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. ;; GNU General Public License for more details.
  20. ;;
  21. ;; You should have received a copy of the GNU General Public License
  22. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  23. ;;
  24. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  25. ;;
  26. ;;; Commentary:
  27. ;;
  28. ;; This file contains the code to interact with Richard Moreland's iPhone
  29. ;; application MobileOrg. This code is documented in Appendix B of the
  30. ;; Org-mode manual. The code is not specific for the iPhone, however.
  31. ;; Any external viewer/flagging/editing application that uses the same
  32. ;; conventions could be used.
  33. (require 'org)
  34. (require 'org-agenda)
  35. ;;; Code:
  36. (eval-when-compile (require 'cl))
  37. (defgroup org-mobile nil
  38. "Options concerning support for a viewer/editor on a mobile device."
  39. :tag "Org Mobile"
  40. :group 'org)
  41. (defcustom org-mobile-files '(org-agenda-files)
  42. "Files to be staged for MobileOrg.
  43. This is basically a list of files and directories. Files will be staged
  44. directly. Directories will be search for files with the extension `.org'.
  45. In addition to this, the list may also contain the following symbols:
  46. org-agenda-files
  47. This means include the complete, unrestricted list of files given in
  48. the variable `org-agenda-files'.
  49. org-agenda-text-search-extra-files
  50. Include the files given in the variable
  51. `org-agenda-text-search-extra-files'"
  52. :group 'org-mobile
  53. :type '(list :greedy t
  54. (option (const :tag "org-agenda-files" org-agenda-files))
  55. (option (const :tag "org-agenda-text-search-extra-files"
  56. org-agenda-text-search-extra-files))
  57. (repeat :inline t :tag "Additional files"
  58. (file))))
  59. (defcustom org-mobile-directory ""
  60. "The WebDAV directory where the interaction with the mobile takes place."
  61. :group 'org-mobile
  62. :type 'directory)
  63. (defcustom org-mobile-use-encryption nil
  64. "Non-nil means keep only encrypted files on the WebDAV server.
  65. Encryption uses AES-256, with a password given in
  66. `org-mobile-encryption-password'.
  67. When nil, plain files are kept on the server.
  68. Turning on encryption requires to set the same password in the MobileOrg
  69. application. Before turning this on, check of MobileOrg does already
  70. support it - at the time of this writing it did not yet."
  71. :group 'org-mobile
  72. :type 'boolean)
  73. (defcustom org-mobile-encryption-tempfile "~/orgtmpcrypt"
  74. "File that is being used as a temporary file for encryption.
  75. This must be local file on your local machine (not on the WebDAV server).
  76. You might want to put this file into a directory where only you have access."
  77. :group 'org-mobile
  78. :type 'directory)
  79. (defcustom org-mobile-encryption-password ""
  80. "Password for encrypting files uploaded to the server.
  81. This is a single password which is used for AES-256 encryption. The same
  82. password must also be set in the MobileOrg application. All Org files,
  83. including mobileorg.org will be encrypted using this password.
  84. SECURITY CONSIDERATIONS:
  85. Note that, when Org runs the encryption commands, the password could
  86. be visible briefly on your system with the `ps' command. So this method is
  87. only intended to keep the files secure on the server, not on your own machine.
  88. Also, if you set this variable in an init file (.emacs or .emacs.d/init.el
  89. or custom.el...) and if that file is stored in a way so that other can read
  90. it, this also limits the security of this approach. You can also leave
  91. this variable empty - Org will then ask for the password once per Emacs
  92. session."
  93. :group 'org-mobile
  94. :type '(string :tag "Password"))
  95. (defvar org-mobile-encryption-password-session nil)
  96. (defun org-mobile-encryption-password ()
  97. (or (org-string-nw-p org-mobile-encryption-password)
  98. (org-string-nw-p org-mobile-encryption-password-session)
  99. (setq org-mobile-encryption-password-session
  100. (read-passwd "Password for MobileOrg: " t))))
  101. (defcustom org-mobile-inbox-for-pull "~/org/from-mobile.org"
  102. "The file where captured notes and flags will be appended to.
  103. During the execution of `org-mobile-pull', the file
  104. `org-mobile-capture-file' will be emptied it's contents have
  105. been appended to the file given here. This file should be in
  106. `org-directory', and not in the staging area or on the web server."
  107. :group 'org-mobile
  108. :type 'file)
  109. (defconst org-mobile-capture-file "mobileorg.org"
  110. "The capture file where the mobile stores captured notes and flags.
  111. This should not be changed, because MobileOrg assumes this name.")
  112. (defcustom org-mobile-index-file "index.org"
  113. "The index file with inks to all Org files that should be loaded by MobileOrg.
  114. Relative to `org-mobile-directory'. The Address field in the MobileOrg setup
  115. should point to this file."
  116. :group 'org-mobile
  117. :type 'file)
  118. (defcustom org-mobile-agendas 'all
  119. "The agendas that should be pushed to MobileOrg.
  120. Allowed values:
  121. default the weekly agenda and the global TODO list
  122. custom all custom agendas defined by the user
  123. all the custom agendas and the default ones
  124. list a list of selection key(s) as string."
  125. :group 'org-mobile
  126. :type '(choice
  127. (const :tag "Default Agendas" default)
  128. (const :tag "Custom Agendas" custom)
  129. (const :tag "Default and Custom Agendas" all)
  130. (repeat :tag "Selected"
  131. (string :tag "Selection Keys"))))
  132. (defcustom org-mobile-force-id-on-agenda-items t
  133. "Non-nil means make all agenda items carry an ID."
  134. :group 'org-mobile
  135. :type 'boolean)
  136. (defcustom org-mobile-force-mobile-change nil
  137. "Non-nil means force the change made on the mobile device.
  138. So even if there have been changes to the computer version of the entry,
  139. force the new value set on the mobile.
  140. When nil, mark the entry from the mobile with an error message.
  141. Instead of nil or t, this variable can also be a list of symbols, indicating
  142. the editing types for which the mobile version should always dominate."
  143. :group 'org-mobile
  144. :type '(choice
  145. (const :tag "Always" t)
  146. (const :tag "Never" nil)
  147. (set :greedy t :tag "Specify"
  148. (const todo)
  149. (const tags)
  150. (const priority)
  151. (const heading)
  152. (const body))))
  153. (defcustom org-mobile-action-alist
  154. '(("edit" . (org-mobile-edit data old new)))
  155. "Alist with flags and actions for mobile sync.
  156. When flagging an entry, MobileOrg will create entries that look like
  157. * F(action:data) [[id:entry-id][entry title]]
  158. This alist defines that the ACTION in the parentheses of F() should mean,
  159. i.e. what action should be taken. The :data part in the parenthesis is
  160. optional. If present, the string after the colon will be passed to the
  161. action form as the `data' variable.
  162. The car of each elements of the alist is an actions string. The cdr is
  163. an Emacs Lisp form that will be evaluated with the cursor on the headline
  164. of that entry.
  165. For now, it is not recommended to change this variable."
  166. :group 'org-mobile
  167. :type '(repeat
  168. (cons (string :tag "Action flag")
  169. (sexp :tag "Action form"))))
  170. (defcustom org-mobile-checksum-binary (or (executable-find "shasum")
  171. (executable-find "sha1sum")
  172. (executable-find "md5sum")
  173. (executable-find "md5"))
  174. "Executable used for computing checksums of agenda files."
  175. :group 'org-mobile
  176. :type 'string)
  177. (defvar org-mobile-pre-push-hook nil
  178. "Hook run before running `org-mobile-push'.
  179. This could be used to clean up `org-mobile-directory', for example to
  180. remove files that used to be included in the agenda but no longer are.
  181. The presence of such files would not really be a problem, but after time
  182. they may accumulate.")
  183. (defvar org-mobile-post-push-hook nil
  184. "Hook run after running `org-mobile-push'.
  185. If Emacs does not have direct write access to the WebDAV directory used
  186. by the mobile device, this hook should be used to copy all files from the
  187. local staging directory `org-mobile-directory' to the WebDAV directory,
  188. for example using `rsync' or `scp'.")
  189. (defvar org-mobile-pre-pull-hook nil
  190. "Hook run before executing `org-mobile-pull'.
  191. If Emacs does not have direct write access to the WebDAV directory used
  192. by the mobile device, this hook should be used to copy the capture file
  193. `mobileorg.org' from the WebDAV location to the local staging
  194. directory `org-mobile-directory'.")
  195. (defvar org-mobile-post-pull-hook nil
  196. "Hook run after running `org-mobile-pull'.
  197. If Emacs does not have direct write access to the WebDAV directory used
  198. by the mobile device, this hook should be used to copy the emptied
  199. capture file `mobileorg.org' back to the WebDAV directory, for example
  200. using `rsync' or `scp'.")
  201. (defvar org-mobile-last-flagged-files nil
  202. "List of files containing entries flagged in the latest pull.")
  203. (defvar org-mobile-files-alist nil)
  204. (defvar org-mobile-checksum-files nil)
  205. (defun org-mobile-prepare-file-lists ()
  206. (setq org-mobile-files-alist (org-mobile-files-alist))
  207. (setq org-mobile-checksum-files nil))
  208. (defun org-mobile-files-alist ()
  209. "Expand the list in `org-mobile-files' to a list of existing files."
  210. (let* ((include-archives
  211. (and (member 'org-agenda-text-search-extra-files org-mobile-files)
  212. (member 'agenda-archives org-agenda-text-search-extra-files)
  213. t))
  214. (files
  215. (apply 'append
  216. (mapcar
  217. (lambda (f)
  218. (cond
  219. ((eq f 'org-agenda-files)
  220. (org-agenda-files t include-archives))
  221. ((eq f 'org-agenda-text-search-extra-files)
  222. (delq 'agenda-archives
  223. (copy-sequence
  224. org-agenda-text-search-extra-files)))
  225. ((and (stringp f) (file-directory-p f))
  226. (directory-files f 'full "\\.org\\'"))
  227. ((and (stringp f) (file-exists-p f))
  228. (list f))
  229. (t nil)))
  230. org-mobile-files)))
  231. (orgdir-uname (file-name-as-directory (file-truename org-directory)))
  232. (orgdir-re (concat "\\`" (regexp-quote orgdir-uname)))
  233. uname seen rtn file link-name)
  234. ;; Make the files unique, and determine the name under which they will
  235. ;; be listed.
  236. (while (setq file (pop files))
  237. (if (not (file-name-absolute-p file))
  238. (setq file (expand-file-name file org-directory)))
  239. (setq uname (file-truename file))
  240. (unless (member uname seen)
  241. (push uname seen)
  242. (if (string-match orgdir-re uname)
  243. (setq link-name (substring uname (match-end 0)))
  244. (setq link-name (file-name-nondirectory uname)))
  245. (push (cons file link-name) rtn)))
  246. (nreverse rtn)))
  247. ;;;###autoload
  248. (defun org-mobile-push ()
  249. "Push the current state of Org affairs to the WebDAV directory.
  250. This will create the index file, copy all agenda files there, and also
  251. create all custom agenda views, for upload to the mobile phone."
  252. (interactive)
  253. (let ((a-buffer (get-buffer org-agenda-buffer-name)))
  254. (let ((org-agenda-buffer-name "*SUMO*")
  255. (org-agenda-filter org-agenda-filter)
  256. (org-agenda-redo-command org-agenda-redo-command))
  257. (save-excursion
  258. (save-window-excursion
  259. (org-mobile-check-setup)
  260. (org-mobile-prepare-file-lists)
  261. (run-hooks 'org-mobile-pre-push-hook)
  262. (message "Creating agendas...")
  263. (let ((inhibit-redisplay t)) (org-mobile-create-sumo-agenda))
  264. (message "Creating agendas...done")
  265. (org-save-all-org-buffers) ; to save any IDs created by this process
  266. (message "Copying files...")
  267. (org-mobile-copy-agenda-files)
  268. (message "Writing index file...")
  269. (org-mobile-create-index-file)
  270. (message "Writing checksums...")
  271. (org-mobile-write-checksums)
  272. (run-hooks 'org-mobile-post-push-hook))))
  273. (redraw-display)
  274. (when (and a-buffer (buffer-live-p a-buffer))
  275. (if (not (get-buffer-window a-buffer))
  276. (kill-buffer a-buffer)
  277. (let ((cw (selected-window)))
  278. (select-window (get-buffer-window a-buffer))
  279. (org-agenda-redo)
  280. (select-window cw)))))
  281. (message "Files for mobile viewer staged"))
  282. (defvar org-mobile-before-process-capture-hook nil
  283. "Hook that is run after content was moved to `org-mobile-inbox-for-pull'.
  284. The inbox file is visited by the current buffer, and the buffer is
  285. narrowed to the newly captured data.")
  286. ;;;###autoload
  287. (defun org-mobile-pull ()
  288. "Pull the contents of `org-mobile-capture-file' and integrate them.
  289. Apply all flagged actions, flag entries to be flagged and then call an
  290. agenda view showing the flagged items."
  291. (interactive)
  292. (org-mobile-check-setup)
  293. (run-hooks 'org-mobile-pre-pull-hook)
  294. (let ((insertion-marker (org-mobile-move-capture)))
  295. (if (not (markerp insertion-marker))
  296. (message "No new items")
  297. (org-with-point-at insertion-marker
  298. (save-restriction
  299. (narrow-to-region (point) (point-max))
  300. (run-hooks 'org-mobile-before-process-capture-hook)))
  301. (org-with-point-at insertion-marker
  302. (org-mobile-apply (point) (point-max)))
  303. (move-marker insertion-marker nil)
  304. (run-hooks 'org-mobile-post-pull-hook)
  305. (when org-mobile-last-flagged-files
  306. ;; Make an agenda view of flagged entries, but only in the files
  307. ;; where stuff has been added.
  308. (put 'org-agenda-files 'org-restrict org-mobile-last-flagged-files)
  309. (let ((org-agenda-keep-restricted-file-list t))
  310. (org-agenda nil "?"))))))
  311. (defun org-mobile-check-setup ()
  312. "Check if org-mobile-directory has been set up."
  313. (unless (and org-directory
  314. (stringp org-directory)
  315. (string-match "\\S-" org-directory)
  316. (file-exists-p org-directory)
  317. (file-directory-p org-directory))
  318. (error
  319. "Please set `org-directory' to the directory where your org files live"))
  320. (unless (and org-mobile-directory
  321. (stringp org-mobile-directory)
  322. (string-match "\\S-" org-mobile-directory)
  323. (file-exists-p org-mobile-directory)
  324. (file-directory-p org-mobile-directory))
  325. (error
  326. "Variable `org-mobile-directory' must point to an existing directory"))
  327. (unless (and org-mobile-inbox-for-pull
  328. (stringp org-mobile-inbox-for-pull)
  329. (string-match "\\S-" org-mobile-inbox-for-pull)
  330. (file-exists-p
  331. (file-name-directory org-mobile-inbox-for-pull)))
  332. (error
  333. "Variable `org-mobile-inbox-for-pull' must point to a file in an existing directory"))
  334. (unless (and org-mobile-checksum-binary
  335. (string-match "\\S-" org-mobile-checksum-binary))
  336. (error "No executable found to compute checksums"))
  337. (when org-mobile-use-encryption
  338. (unless (string-match "\\S-" (org-mobile-encryption-password))
  339. (error
  340. "To use encryption, you must set `org-mobile-encryption-password'"))
  341. (unless (file-writable-p org-mobile-encryption-tempfile)
  342. (error "Cannot write to encryption tempfile %s"
  343. org-mobile-encryption-tempfile))
  344. (unless (executable-find "openssl")
  345. (error "openssl is needed to encrypt files"))))
  346. (defun org-mobile-create-index-file ()
  347. "Write the index file in the WebDAV directory."
  348. (let ((files-alist (sort (copy-sequence org-mobile-files-alist)
  349. (lambda (a b) (string< (cdr a) (cdr b)))))
  350. (def-todo (default-value 'org-todo-keywords))
  351. (def-tags (default-value 'org-tag-alist))
  352. file link-name todo-kwds done-kwds tags drawers entry kwds dwds twds)
  353. (org-prepare-agenda-buffers (mapcar 'car files-alist))
  354. (setq done-kwds (org-uniquify org-done-keywords-for-agenda))
  355. (setq todo-kwds (org-delete-all
  356. done-kwds
  357. (org-uniquify org-todo-keywords-for-agenda)))
  358. (setq drawers (org-uniquify org-drawers-for-agenda))
  359. (setq tags (org-uniquify
  360. (delq nil
  361. (mapcar
  362. (lambda (e)
  363. (cond ((stringp e) e)
  364. ((listp e)
  365. (if (stringp (car e)) (car e) nil))
  366. (t nil)))
  367. org-tag-alist-for-agenda))))
  368. (with-temp-file
  369. (expand-file-name org-mobile-index-file org-mobile-directory)
  370. (while (setq entry (pop def-todo))
  371. (insert "#+READONLY\n")
  372. (setq kwds (mapcar (lambda (x) (if (string-match "(" x)
  373. (substring x 0 (match-beginning 0))
  374. x))
  375. (cdr entry)))
  376. (insert "#+TODO: " (mapconcat 'identity kwds " ") "\n")
  377. (setq dwds (member "|" kwds)
  378. twds (org-delete-all dwds kwds)
  379. todo-kwds (org-delete-all twds todo-kwds)
  380. done-kwds (org-delete-all dwds done-kwds)))
  381. (when (or todo-kwds done-kwds)
  382. (insert "#+TODO: " (mapconcat 'identity todo-kwds " ") " | "
  383. (mapconcat 'identity done-kwds " ") "\n"))
  384. (setq def-tags (mapcar
  385. (lambda (x)
  386. (cond ((null x) nil)
  387. ((stringp x) x)
  388. ((eq (car x) :startgroup) "{")
  389. ((eq (car x) :endgroup) "}")
  390. ((eq (car x) :newline) nil)
  391. ((listp x) (car x))
  392. (t nil)))
  393. def-tags))
  394. (setq def-tags (delq nil def-tags))
  395. (setq tags (org-delete-all def-tags tags))
  396. (setq tags (sort tags (lambda (a b) (string< (downcase a) (downcase b)))))
  397. (setq tags (append def-tags tags nil))
  398. (insert "#+TAGS: " (mapconcat 'identity tags " ") "\n")
  399. (insert "#+DRAWERS: " (mapconcat 'identity drawers " ") "\n")
  400. (insert "#+ALLPRIORITIES: A B C" "\n")
  401. (when (file-exists-p (expand-file-name
  402. org-mobile-directory "agendas.org"))
  403. (insert "* [[file:agendas.org][Agenda Views]]\n"))
  404. (while (setq entry (pop files-alist))
  405. (setq file (car entry)
  406. link-name (cdr entry))
  407. (insert (format "* [[file:%s][%s]]\n"
  408. link-name link-name)))
  409. (push (cons org-mobile-index-file (md5 (buffer-string)))
  410. org-mobile-checksum-files))))
  411. (defun org-mobile-copy-agenda-files ()
  412. "Copy all agenda files to the stage or WebDAV directory."
  413. (let ((files-alist org-mobile-files-alist)
  414. file buf entry link-name target-path target-dir check)
  415. (while (setq entry (pop files-alist))
  416. (setq file (car entry) link-name (cdr entry))
  417. (when (file-exists-p file)
  418. (setq target-path (expand-file-name link-name org-mobile-directory)
  419. target-dir (file-name-directory target-path))
  420. (unless (file-directory-p target-dir)
  421. (make-directory target-dir 'parents))
  422. (if org-mobile-use-encryption
  423. (org-mobile-encrypt-and-move file target-path)
  424. (copy-file file target-path 'ok-if-exists))
  425. (setq check (shell-command-to-string
  426. (concat org-mobile-checksum-binary " "
  427. (shell-quote-argument (expand-file-name file)))))
  428. (when (string-match "[a-fA-F0-9]\\{30,40\\}" check)
  429. (push (cons link-name (match-string 0 check))
  430. org-mobile-checksum-files))))
  431. (setq file (expand-file-name org-mobile-capture-file
  432. org-mobile-directory))
  433. (save-excursion
  434. (setq buf (find-file file))
  435. (and (= (point-min) (point-max)) (insert "\n"))
  436. (save-buffer)
  437. (push (cons org-mobile-capture-file (md5 (buffer-string)))
  438. org-mobile-checksum-files)
  439. (when org-mobile-use-encryption
  440. (write-file org-mobile-encryption-tempfile)
  441. (org-mobile-encrypt-and-move org-mobile-encryption-tempfile file)))
  442. (kill-buffer buf)))
  443. (defun org-mobile-write-checksums ()
  444. "Create checksums for all files in `org-mobile-directory'.
  445. The table of checksums is written to the file mobile-checksums."
  446. (let ((sumfile (expand-file-name "checksums.dat" org-mobile-directory))
  447. (files org-mobile-checksum-files)
  448. entry file sum)
  449. (with-temp-file sumfile
  450. (set-buffer-file-coding-system 'undecided-unix nil)
  451. (while (setq entry (pop files))
  452. (setq file (car entry) sum (cdr entry))
  453. (insert (format "%s %s\n" sum file))))))
  454. (defun org-mobile-sumo-agenda-command ()
  455. "Return an agenda custom command that comprises all custom commands."
  456. (let ((custom-list
  457. ;; normalize different versions
  458. (delq nil
  459. (mapcar
  460. (lambda (x)
  461. (cond ((stringp (cdr x)) nil)
  462. ((stringp (nth 1 x)) x)
  463. ((not (nth 1 x)) (cons (car x) (cons "" (cddr x))))
  464. (t (cons (car x) (cons "" (cdr x))))))
  465. org-agenda-custom-commands)))
  466. (default-list '(("a" "Agenda" agenda) ("t" "All TODO" alltodo)))
  467. thelist new e key desc type match settings cmds gkey gdesc gsettings cnt)
  468. (cond
  469. ((eq org-mobile-agendas 'custom)
  470. (setq thelist custom-list))
  471. ((eq org-mobile-agendas 'default)
  472. (setq thelist default-list))
  473. ((eq org-mobile-agendas 'all)
  474. (setq thelist custom-list)
  475. (unless (assoc "t" thelist) (push '("t" "ALL TODO" alltodo) thelist))
  476. (unless (assoc "a" thelist) (push '("a" "Agenda" agenda) thelist)))
  477. ((listp org-mobile-agendas)
  478. (setq thelist (append custom-list default-list))
  479. (setq thelist (delq nil (mapcar (lambda (k) (assoc k thelist))
  480. org-mobile-agendas)))))
  481. (while (setq e (pop thelist))
  482. (cond
  483. ((stringp (cdr e))
  484. ;; this is a description entry - skip it
  485. )
  486. ((eq (nth 2 e) 'search)
  487. ;; Search view is interactive, skip
  488. )
  489. ((memq (nth 2 e) '(todo-tree tags-tree occur-tree))
  490. ;; These are trees, not really agenda commands
  491. )
  492. ((and (memq (nth 2 e) '(todo tags tags-todo))
  493. (or (null (nth 3 e))
  494. (not (string-match "\\S-" (nth 3 e)))))
  495. ;; These would be interactive because the match string is empty
  496. )
  497. ((memq (nth 2 e) '(agenda alltodo todo tags tags-todo))
  498. ;; a normal command
  499. (setq key (car e) desc (nth 1 e) type (nth 2 e) match (nth 3 e)
  500. settings (nth 4 e))
  501. (setq settings
  502. (cons (list 'org-agenda-title-append
  503. (concat "<after>KEYS=" key " TITLE: "
  504. (if (and (stringp desc) (> (length desc) 0))
  505. desc (symbol-name type))
  506. " " match "</after>"))
  507. settings))
  508. (push (list type match settings) new))
  509. ((symbolp (nth 2 e))
  510. ;; A user-defined function, not sure how to handle that yet
  511. )
  512. (t
  513. ;; a block agenda
  514. (setq gkey (car e) gdesc (nth 1 e) gsettings (nth 3 e) cmds (nth 2 e))
  515. (setq cnt 0)
  516. (while (setq e (pop cmds))
  517. (setq type (car e) match (nth 1 e) settings (nth 2 e))
  518. (setq settings (append gsettings settings))
  519. (setq settings
  520. (cons (list 'org-agenda-title-append
  521. (concat "<after>KEYS=" gkey "#" (number-to-string
  522. (setq cnt (1+ cnt)))
  523. " TITLE: " gdesc " " match "</after>"))
  524. settings))
  525. (push (list type match settings) new)))))
  526. (and new (list "X" "SUMO" (reverse new)
  527. '((org-agenda-compact-blocks nil))))))
  528. (defvar org-mobile-creating-agendas nil)
  529. (defun org-mobile-write-agenda-for-mobile (file)
  530. (let ((all (buffer-string)) in-date id pl prefix line app short m sexp)
  531. (with-temp-file file
  532. (org-mode)
  533. (insert "#+READONLY\n")
  534. (insert all)
  535. (goto-char (point-min))
  536. (while (not (eobp))
  537. (cond
  538. ((looking-at "[ \t]*$")) ; keep empty lines
  539. ((looking-at "=+$")
  540. ;; remove underlining
  541. (delete-region (point) (point-at-eol)))
  542. ((get-text-property (point) 'org-agenda-structural-header)
  543. (setq in-date nil)
  544. (setq app (get-text-property (point)
  545. 'org-agenda-title-append))
  546. (setq short (get-text-property (point)
  547. 'short-heading))
  548. (when (and short (looking-at ".+"))
  549. (replace-match short)
  550. (beginning-of-line 1))
  551. (when app
  552. (end-of-line 1)
  553. (insert app)
  554. (beginning-of-line 1))
  555. (insert "* "))
  556. ((get-text-property (point) 'org-agenda-date-header)
  557. (setq in-date t)
  558. (insert "** "))
  559. ((setq m (or (get-text-property (point) 'org-hd-marker)
  560. (get-text-property (point) 'org-marker)))
  561. (setq sexp (member (get-text-property (point) 'type)
  562. '("diary" "sexp")))
  563. (if (setq pl (get-text-property (point) 'prefix-length))
  564. (progn
  565. (setq prefix (org-trim (buffer-substring
  566. (point) (+ (point) pl)))
  567. line (org-trim (buffer-substring
  568. (+ (point) pl)
  569. (point-at-eol))))
  570. (delete-region (point-at-bol) (point-at-eol))
  571. (insert line "<before>" prefix "</before>")
  572. (beginning-of-line 1))
  573. (and (looking-at "[ \t]+") (replace-match "")))
  574. (insert (if in-date "*** " "** "))
  575. (end-of-line 1)
  576. (insert "\n")
  577. (unless sexp
  578. (insert (org-agenda-get-some-entry-text
  579. m 10 " " 'planning)
  580. "\n")
  581. (when (setq id
  582. (if (org-bound-and-true-p
  583. org-mobile-force-id-on-agenda-items)
  584. (org-id-get m 'create)
  585. (or (org-entry-get m "ID")
  586. (org-mobile-get-outline-path-link m))))
  587. (insert " :PROPERTIES:\n :ORIGINAL_ID: " id
  588. "\n :END:\n")))))
  589. (beginning-of-line 2))
  590. (push (cons "agendas.org" (md5 (buffer-string)))
  591. org-mobile-checksum-files))
  592. (message "Agenda written to Org file %s" file)))
  593. (defun org-mobile-get-outline-path-link (pom)
  594. (org-with-point-at pom
  595. (concat "olp:"
  596. (org-mobile-escape-olp (file-name-nondirectory buffer-file-name))
  597. "/"
  598. (mapconcat 'org-mobile-escape-olp
  599. (org-get-outline-path)
  600. "/")
  601. "/"
  602. (org-mobile-escape-olp (nth 4 (org-heading-components))))))
  603. (defun org-mobile-escape-olp (s)
  604. (let ((table '((?: . "%3a") (?\[ . "%5b") (?\] . "%5d") (?/ . "%2f"))))
  605. (org-link-escape s table)))
  606. ;;;###autoload
  607. (defun org-mobile-create-sumo-agenda ()
  608. "Create a file that contains all custom agenda views."
  609. (interactive)
  610. (let* ((file (expand-file-name "agendas.org"
  611. org-mobile-directory))
  612. (file1 (if org-mobile-use-encryption
  613. org-mobile-encryption-tempfile
  614. file))
  615. (sumo (org-mobile-sumo-agenda-command))
  616. (org-agenda-custom-commands
  617. (list (append sumo (list (list file1)))))
  618. (org-mobile-creating-agendas t))
  619. (unless (file-writable-p file1)
  620. (error "Cannot write to file %s" file1))
  621. (when sumo
  622. (org-store-agenda-views))
  623. (when org-mobile-use-encryption
  624. (org-mobile-encrypt-file file1 file)
  625. (delete-file file1))))
  626. (defun org-mobile-encrypt-and-move (infile outfile)
  627. "Encrypt INFILE locally to INFILE_enc, then move it to OUTFILE.
  628. We do this in two steps so that remote paths will work, even if the
  629. encryption program does not understand them."
  630. (let ((encfile (concat infile "_enc")))
  631. (org-mobile-encrypt-file infile encfile)
  632. (when outfile
  633. (copy-file encfile outfile 'ok-if-exists)
  634. (delete-file encfile))))
  635. (defun org-mobile-encrypt-file (infile outfile)
  636. "Encrypt INFILE to OUTFILE, using `org-mobile-encryption-password'."
  637. (shell-command
  638. (format "openssl enc -aes-256-cbc -salt -pass %s -in %s -out %s"
  639. (shell-quote-argument (concat "pass:"
  640. (org-mobile-encryption-password)))
  641. (shell-quote-argument (expand-file-name infile))
  642. (shell-quote-argument (expand-file-name outfile)))))
  643. (defun org-mobile-decrypt-file (infile outfile)
  644. "Decrypt INFILE to OUTFILE, using `org-mobile-encryption-password'."
  645. (shell-command
  646. (format "openssl enc -d -aes-256-cbc -salt -pass %s -in %s -out %s"
  647. (shell-quote-argument (concat "pass:"
  648. (org-mobile-encryption-password)))
  649. (shell-quote-argument (expand-file-name infile))
  650. (shell-quote-argument (expand-file-name outfile)))))
  651. (defun org-mobile-move-capture ()
  652. "Move the contents of the capture file to the inbox file.
  653. Return a marker to the location where the new content has been added.
  654. If nothing new has been added, return nil."
  655. (interactive)
  656. (let* ((encfile nil)
  657. (capture-file (expand-file-name org-mobile-capture-file
  658. org-mobile-directory))
  659. (inbox-buffer (find-file-noselect org-mobile-inbox-for-pull))
  660. (capture-buffer
  661. (if (not org-mobile-use-encryption)
  662. (find-file-noselect capture-file)
  663. (if (file-exists-p org-mobile-encryption-tempfile)
  664. (delete-file org-mobile-encryption-tempfile))
  665. (setq encfile (concat org-mobile-encryption-tempfile "_enc"))
  666. (copy-file capture-file encfile)
  667. (org-mobile-decrypt-file encfile org-mobile-encryption-tempfile)
  668. (find-file-noselect org-mobile-encryption-tempfile)))
  669. (insertion-point (make-marker))
  670. not-empty content)
  671. (with-current-buffer capture-buffer
  672. (setq content (buffer-string))
  673. (setq not-empty (string-match "\\S-" content))
  674. (when not-empty
  675. (set-buffer inbox-buffer)
  676. (widen)
  677. (goto-char (point-max))
  678. (or (bolp) (newline))
  679. (move-marker insertion-point
  680. (prog1 (point) (insert content)))
  681. (save-buffer)
  682. (set-buffer capture-buffer)
  683. (erase-buffer)
  684. (save-buffer)
  685. (org-mobile-update-checksum-for-capture-file (buffer-string))))
  686. (kill-buffer capture-buffer)
  687. (when org-mobile-use-encryption
  688. (org-mobile-encrypt-and-move org-mobile-encryption-tempfile
  689. capture-file))
  690. (if not-empty insertion-point)))
  691. (defun org-mobile-update-checksum-for-capture-file (buffer-string)
  692. "Find the checksum line and modify it to match BUFFER-STRING."
  693. (let* ((file (expand-file-name "checksums.dat" org-mobile-directory))
  694. (buffer (find-file-noselect file)))
  695. (when buffer
  696. (with-current-buffer buffer
  697. (when (re-search-forward (concat "\\([0-9a-fA-F]\\{30,\\}\\).*?"
  698. (regexp-quote org-mobile-capture-file)
  699. "[ \t]*$") nil t)
  700. (goto-char (match-beginning 1))
  701. (delete-region (match-beginning 1) (match-end 1))
  702. (insert (md5 buffer-string))
  703. (save-buffer)))
  704. (kill-buffer buffer))))
  705. (defun org-mobile-apply (&optional beg end)
  706. "Apply all change requests in the current buffer.
  707. If BEG and END are given, only do this in that region."
  708. (interactive)
  709. (require 'org-archive)
  710. (setq org-mobile-last-flagged-files nil)
  711. (setq beg (or beg (point-min)) end (or end (point-max)))
  712. ;; Remove all Note IDs
  713. (goto-char beg)
  714. (while (re-search-forward "^\\*\\* Note ID: [-0-9A-F]+[ \t]*\n" end t)
  715. (replace-match ""))
  716. ;; Find all the referenced entries, without making any changes yet
  717. (let ((marker (make-marker))
  718. (bos-marker (make-marker))
  719. (end (move-marker (make-marker) end))
  720. (cnt-new 0)
  721. (cnt-edit 0)
  722. (cnt-flag 0)
  723. (cnt-error 0)
  724. buf-list
  725. id-pos org-mobile-error)
  726. ;; Count the new captures
  727. (goto-char beg)
  728. (while (re-search-forward "^\\* \\(.*\\)" end t)
  729. (and (>= (- (match-end 1) (match-beginning 1)) 2)
  730. (not (equal (downcase (substring (match-string 1) 0 2)) "f("))
  731. (incf cnt-new)))
  732. (goto-char beg)
  733. (while (re-search-forward
  734. "^\\*+[ \t]+F(\\([^():\n]*\\)\\(:\\([^()\n]*\\)\\)?)[ \t]+\\[\\[\\(\\(id\\|olp\\):\\([^]\n]+\\)\\)" end t)
  735. (setq id-pos (condition-case msg
  736. (org-mobile-locate-entry (match-string 4))
  737. (error (nth 1 msg))))
  738. (when (and (markerp id-pos)
  739. (not (member (marker-buffer id-pos) buf-list)))
  740. (org-mobile-timestamp-buffer (marker-buffer id-pos))
  741. (push (marker-buffer id-pos) buf-list))
  742. (if (or (not id-pos) (stringp id-pos))
  743. (progn
  744. (goto-char (+ 2 (point-at-bol)))
  745. (insert id-pos " ")
  746. (incf cnt-error))
  747. (add-text-properties (point-at-bol) (point-at-eol)
  748. (list 'org-mobile-marker
  749. (or id-pos "Linked entry not found")))))
  750. ;; OK, now go back and start applying
  751. (goto-char beg)
  752. (while (re-search-forward "^\\*+[ \t]+F(\\([^():\n]*\\)\\(:\\([^()\n]*\\)\\)?)" end t)
  753. (catch 'next
  754. (setq id-pos (get-text-property (point-at-bol) 'org-mobile-marker))
  755. (if (not (markerp id-pos))
  756. (progn
  757. (incf cnt-error)
  758. (insert "UNKNOWN PROBLEM"))
  759. (let* ((action (match-string 1))
  760. (data (and (match-end 3) (match-string 3)))
  761. (bos (point-at-bol))
  762. (eos (save-excursion (org-end-of-subtree t t)))
  763. (cmd (if (equal action "")
  764. '(progn
  765. (incf cnt-flag)
  766. (org-toggle-tag "FLAGGED" 'on)
  767. (and note
  768. (org-entry-put nil "THEFLAGGINGNOTE" note)))
  769. (incf cnt-edit)
  770. (cdr (assoc action org-mobile-action-alist))))
  771. (note (and (equal action "")
  772. (buffer-substring (1+ (point-at-eol)) eos)))
  773. (org-inhibit-logging 'note) ;; Do not take notes interactively
  774. old new)
  775. (goto-char bos)
  776. (move-marker bos-marker (point))
  777. (if (re-search-forward "^** Old value[ \t]*$" eos t)
  778. (setq old (buffer-substring
  779. (1+ (match-end 0))
  780. (progn (outline-next-heading) (point)))))
  781. (if (re-search-forward "^** New value[ \t]*$" eos t)
  782. (setq new (buffer-substring
  783. (1+ (match-end 0))
  784. (progn (outline-next-heading)
  785. (if (eobp) (org-back-over-empty-lines))
  786. (point)))))
  787. (setq old (and old (if (string-match "\\S-" old) old nil)))
  788. (setq new (and new (if (string-match "\\S-" new) new nil)))
  789. (if (and note (> (length note) 0))
  790. ;; Make Note into a single line, to fit into a property
  791. (setq note (mapconcat 'identity
  792. (org-split-string (org-trim note) "\n")
  793. "\\n")))
  794. (unless (equal data "body")
  795. (setq new (and new (org-trim new))
  796. old (and old (org-trim old))))
  797. (goto-char (+ 2 bos-marker))
  798. (unless (markerp id-pos)
  799. (insert "BAD REFERENCE ")
  800. (incf cnt-error)
  801. (throw 'next t))
  802. (unless cmd
  803. (insert "BAD FLAG ")
  804. (incf cnt-error)
  805. (throw 'next t))
  806. ;; Remember this place so that we can return
  807. (move-marker marker (point))
  808. (setq org-mobile-error nil)
  809. (save-excursion
  810. (condition-case msg
  811. (org-with-point-at id-pos
  812. (progn
  813. (eval cmd)
  814. (if (member "FLAGGED" (org-get-tags))
  815. (add-to-list 'org-mobile-last-flagged-files
  816. (buffer-file-name (current-buffer))))))
  817. (error (setq org-mobile-error msg))))
  818. (when org-mobile-error
  819. (switch-to-buffer (marker-buffer marker))
  820. (goto-char marker)
  821. (incf cnt-error)
  822. (insert (if (stringp (nth 1 org-mobile-error))
  823. (nth 1 org-mobile-error)
  824. "EXECUTION FAILED")
  825. " ")
  826. (throw 'next t))
  827. ;; If we get here, the action has been applied successfully
  828. ;; So remove the entry
  829. (goto-char bos-marker)
  830. (delete-region (point) (org-end-of-subtree t t))))))
  831. (save-buffer)
  832. (move-marker marker nil)
  833. (move-marker end nil)
  834. (message "%d new, %d edits, %d flags, %d errors" cnt-new
  835. cnt-edit cnt-flag cnt-error)
  836. (sit-for 1)))
  837. (defun org-mobile-timestamp-buffer (buf)
  838. "Time stamp buffer BUF, just to make sure its checksum will change."
  839. (with-current-buffer buf
  840. (save-excursion
  841. (save-restriction
  842. (widen)
  843. (goto-char (point-min))
  844. (if (re-search-forward
  845. "^\\([ \t]*\\)#\\+LAST_MOBILE_CHANGE:.*\n?" nil t)
  846. (progn
  847. (goto-char (match-end 1))
  848. (delete-region (point) (match-end 0)))
  849. (if (looking-at ".*?-\\*-.*-\\*-")
  850. (forward-line 1)))
  851. (insert "#+LAST_MOBILE_CHANGE: "
  852. (format-time-string "%Y-%m-%d %T") "\n")))))
  853. (defun org-mobile-smart-read ()
  854. "Parse the entry at point for shortcuts and expand them.
  855. These shortcuts are meant for fast and easy typing on the limited
  856. keyboards of a mobile device. Below we show a list of the shortcuts
  857. currently implemented.
  858. The entry is expected to contain an inactive time stamp indicating when
  859. the entry was created. When setting dates and
  860. times (for example for deadlines), the time strings are interpreted
  861. relative to that creation date.
  862. Abbreviations are expected to take up entire lines, just because it is so
  863. easy to type RET on a mobile device. Abbreviations start with one or two
  864. letters, followed immediately by a dot and then additional information.
  865. Generally the entire shortcut line is removed after action have been taken.
  866. Time stamps will be constructed using `org-read-date'. So for example a
  867. line \"dd. 2tue\" will set a deadline on the second Tuesday after the
  868. creation date.
  869. Here are the shortcuts currently implemented:
  870. dd. string set deadline
  871. ss. string set scheduling
  872. tt. string set time tamp, here.
  873. ti. string set inactive time
  874. tg. tag1 tag2 tag3 set all these tags, change case where necessary
  875. td. kwd set this todo keyword, change case where necessary
  876. FIXME: Hmmm, not sure if we can make his work against the
  877. auto-correction feature. Needs a bit more thinking. So this function
  878. is currently a noop.")
  879. (defun org-mobile-locate-entry (link)
  880. (if (string-match "\\`id:\\(.*\\)$" link)
  881. (org-id-find (match-string 1 link) 'marker)
  882. (if (not (string-match "\\`olp:\\(.*?\\):\\(.*\\)$" link))
  883. nil
  884. (let ((file (match-string 1 link))
  885. (path (match-string 2 link))
  886. (table '((?: . "%3a") (?\[ . "%5b") (?\] . "%5d") (?/ . "%2f"))))
  887. (setq file (org-link-unescape file table))
  888. (setq file (expand-file-name file org-directory))
  889. (setq path (mapcar (lambda (x) (org-link-unescape x table))
  890. (org-split-string path "/")))
  891. (org-find-olp (cons file path))))))
  892. (defun org-mobile-edit (what old new)
  893. "Edit item WHAT in the current entry by replacing OLD with NEW.
  894. WHAT can be \"heading\", \"todo\", \"tags\", \"priority\", or \"body\".
  895. The edit only takes place if the current value is equal (except for
  896. white space) the OLD. If this is so, OLD will be replace by NEW
  897. and the command will return t. If something goes wrong, a string will
  898. be returned that indicates what went wrong."
  899. (let (current old1 new1)
  900. (if (stringp what) (setq what (intern what)))
  901. (cond
  902. ((memq what '(todo todostate))
  903. (setq current (org-get-todo-state))
  904. (cond
  905. ((equal new "DONEARCHIVE")
  906. (org-todo 'done)
  907. (org-archive-subtree-default))
  908. ((equal new current) t) ; nothing needs to be done
  909. ((or (equal current old)
  910. (eq org-mobile-force-mobile-change t)
  911. (memq 'todo org-mobile-force-mobile-change))
  912. (org-todo (or new 'none)) t)
  913. (t (error "State before change was expected as \"%s\", but is \"%s\""
  914. old current))))
  915. ((eq what 'tags)
  916. (setq current (org-get-tags)
  917. new1 (and new (org-split-string new ":+"))
  918. old1 (and old (org-split-string old ":+")))
  919. (cond
  920. ((org-mobile-tags-same-p current new1) t) ; no change needed
  921. ((or (org-mobile-tags-same-p current old1)
  922. (eq org-mobile-force-mobile-change t)
  923. (memq 'tags org-mobile-force-mobile-change))
  924. (org-set-tags-to new1) t)
  925. (t (error "Tags before change were expected as \"%s\", but are \"%s\""
  926. (or old "") (or current "")))))
  927. ((eq what 'priority)
  928. (when (looking-at org-complex-heading-regexp)
  929. (setq current (and (match-end 3) (substring (match-string 3) 2 3)))
  930. (cond
  931. ((equal current new) t) ; no action required
  932. ((or (equal current old)
  933. (eq org-mobile-force-mobile-change t)
  934. (memq 'tags org-mobile-force-mobile-change))
  935. (org-priority (and new (string-to-char new))))
  936. (t (error "Priority was expected to be %s, but is %s"
  937. old current)))))
  938. ((eq what 'heading)
  939. (when (looking-at org-complex-heading-regexp)
  940. (setq current (match-string 4))
  941. (cond
  942. ((equal current new) t) ; no action required
  943. ((or (equal current old)
  944. (eq org-mobile-force-mobile-change t)
  945. (memq 'heading org-mobile-force-mobile-change))
  946. (goto-char (match-beginning 4))
  947. (insert new)
  948. (delete-region (point) (+ (point) (length current)))
  949. (org-set-tags nil 'align))
  950. (t (error "Heading changed in MobileOrg and on the computer")))))
  951. ((eq what 'body)
  952. (setq current (buffer-substring (min (1+ (point-at-eol)) (point-max))
  953. (save-excursion (outline-next-heading)
  954. (point))))
  955. (if (not (string-match "\\S-" current)) (setq current nil))
  956. (cond
  957. ((org-mobile-bodies-same-p current new) t) ; no action necessary
  958. ((or (org-mobile-bodies-same-p current old)
  959. (eq org-mobile-force-mobile-change t)
  960. (memq 'body org-mobile-force-mobile-change))
  961. (save-excursion
  962. (end-of-line 1)
  963. (insert "\n" new)
  964. (or (bolp) (insert "\n"))
  965. (delete-region (point) (progn (org-back-to-heading t)
  966. (outline-next-heading)
  967. (point))))
  968. t)
  969. (t (error "Body was changed in MobileOrg and on the computer")))))))
  970. (defun org-mobile-tags-same-p (list1 list2)
  971. "Are the two tag lists the same?"
  972. (not (or (org-delete-all list1 list2)
  973. (org-delete-all list2 list1))))
  974. (defun org-mobile-bodies-same-p (a b)
  975. "Compare if A and B are visually equal strings.
  976. We first remove leading and trailing white space from the entire strings.
  977. Then we split the strings into lines and remove leading/trailing whitespace
  978. from each line. Then we compare.
  979. A and B must be strings or nil."
  980. (cond
  981. ((and (not a) (not b)) t)
  982. ((or (not a) (not b)) nil)
  983. (t (setq a (org-trim a) b (org-trim b))
  984. (setq a (mapconcat 'identity (org-split-string a "[ \t]*\n[ \t]*") "\n"))
  985. (setq b (mapconcat 'identity (org-split-string b "[ \t]*\n[ \t]*") "\n"))
  986. (equal a b))))
  987. (provide 'org-mobile)
  988. ;; arch-tag: ace0e26c-58f2-4309-8a61-05ec1535f658
  989. ;;; org-mobile.el ends here