Merge Org 7.9.3 (commit 31c1aea)
[bpt/emacs.git] / lisp / org / org-mobile.el
index 3f41d45..d2e7c21 100644 (file)
@@ -304,12 +304,13 @@ Also exclude files matching `org-mobile-files-exclude-regexp'."
 
 ;;;###autoload
 (defun org-mobile-push ()
-  "Push the current state of Org affairs to the WebDAV directory.
+  "Push the current state of Org affairs to the target directory.
 This will create the index file, copy all agenda files there, and also
 create all custom agenda views, for upload to the mobile phone."
   (interactive)
   (let ((a-buffer (get-buffer org-agenda-buffer-name)))
-    (let ((org-agenda-buffer-name "*SUMO*")
+    (let ((org-agenda-curbuf-name org-agenda-buffer-name)
+         (org-agenda-buffer-name "*SUMO*")
          (org-agenda-tag-filter org-agenda-tag-filter)
          (org-agenda-redo-command org-agenda-redo-command))
       (save-excursion
@@ -329,15 +330,17 @@ create all custom agenda views, for upload to the mobile phone."
          (org-mobile-create-index-file)
          (message "Writing checksums...")
          (org-mobile-write-checksums)
-         (run-hooks 'org-mobile-post-push-hook))))
+         (run-hooks 'org-mobile-post-push-hook)))
+      (setq org-agenda-buffer-name org-agenda-curbuf-name
+           org-agenda-this-buffer-name org-agenda-curbuf-name))
     (redraw-display)
-    (when (and a-buffer (buffer-live-p a-buffer))
+    (when (buffer-live-p a-buffer)
       (if (not (get-buffer-window a-buffer))
-         (kill-buffer a-buffer)
-       (let ((cw (selected-window)))
-         (select-window (get-buffer-window a-buffer))
-         (org-agenda-redo)
-         (select-window cw)))))
+         (kill-buffer a-buffer)
+       (let ((cw (selected-window)))
+         (select-window (get-buffer-window a-buffer))
+         (org-agenda-redo)
+         (select-window cw)))))
   (message "Files for mobile viewer staged"))
 
 (defvar org-mobile-before-process-capture-hook nil
@@ -417,7 +420,8 @@ agenda view showing the flagged items."
        (target-file (expand-file-name org-mobile-index-file
                                       org-mobile-directory))
        file link-name todo-kwds done-kwds tags drawers entry kwds dwds twds)
-
+    (when (stringp (car def-todo))
+      (setq def-todo (list (cons 'sequence def-todo))))
     (org-agenda-prepare-buffers (mapcar 'car files-alist))
     (setq done-kwds (org-uniquify org-done-keywords-for-agenda))
     (setq todo-kwds (org-delete-all
@@ -536,7 +540,7 @@ The table of checksums is written to the file mobile-checksums."
                        (t (cons (car x) (cons "" (cdr x))))))
                org-agenda-custom-commands)))
        (default-list '(("a" "Agenda" agenda) ("t" "All TODO" alltodo)))
-       thelist new e key desc type match settings cmds gkey gdesc gsettings cnt)
+       thelist atitle new e key desc type match settings cmds gkey gdesc gsettings cnt)
     (cond
      ((eq org-mobile-agendas 'custom)
       (setq thelist custom-list))
@@ -588,12 +592,13 @@ The table of checksums is written to the file mobile-checksums."
        (setq cnt 0)
        (while (setq e (pop cmds))
          (setq type (car e) match (nth 1 e) settings (nth 2 e))
+         (setq atitle (if (string= "" gdesc) match gdesc))
          (setq settings (append gsettings settings))
          (setq settings
                (cons (list 'org-agenda-title-append
                            (concat "<after>KEYS=" gkey "#" (number-to-string
                                                             (setq cnt (1+ cnt)))
-                                   " TITLE: " gdesc " " match "</after>"))
+                                   " TITLE: " atitle "</after>"))
                      settings))
          (push (list type match settings) new)))))
     (and new (list "X" "SUMO" (reverse new)
@@ -983,7 +988,7 @@ is currently a noop.")
              (goto-char (point-max))
              (newline)
              (goto-char (point-max))
-             (move-marker (make-marker) (point)))))
+             (point-marker))))
       (let ((file (match-string 1 link))
            (path (match-string 2 link)))
        (setq file (org-link-unescape file))