Fix Org ChangeLog entries and remove arch-tag.
[bpt/emacs.git] / lisp / org / org-mobile.el
index 833b672..f3c515a 100644 (file)
@@ -1,10 +1,10 @@
 ;;; org-mobile.el --- Code for asymmetric sync with a mobile device
-;; Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.4
+;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -38,6 +38,9 @@
 
 (eval-when-compile (require 'cl))
 
+(declare-function org-pop-to-buffer-same-window 
+                 "org-compat" (&optional buffer-or-name norecord label))
+
 (defgroup org-mobile nil
   "Options concerning support for a viewer/editor on a mobile device."
   :tag "Org Mobile"
@@ -63,6 +66,11 @@ org-agenda-text-search-extra-files
               (repeat :inline t :tag "Additional files"
                       (file))))
 
+(defcustom org-mobile-files-exclude-regexp ""
+  "A regexp to exclude files from `org-mobile-files'."
+  :group 'org-mobile
+  :type 'regexp)
+
 (defcustom org-mobile-directory ""
   "The WebDAV directory where the interaction with the mobile takes place."
   :group 'org-mobile
@@ -128,7 +136,7 @@ been appended to the file given here.  This file should be in
 This should not be changed, because MobileOrg assumes this name.")
 
 (defcustom org-mobile-index-file "index.org"
-  "The index file with inks to all Org files that should be loaded by MobileOrg.
+  "The index file with links to all Org files that should be loaded by MobileOrg.
 Relative to `org-mobile-directory'.  The Address field in the MobileOrg setup
 should point to this file."
   :group 'org-mobile
@@ -241,7 +249,8 @@ using `rsync' or `scp'.")
   (setq org-mobile-checksum-files nil))
 
 (defun org-mobile-files-alist ()
-  "Expand the list in `org-mobile-files' to a list of existing files."
+  "Expand the list in `org-mobile-files' to a list of existing files.
+Also exclude files matching `org-mobile-files-exclude-regexp'."
   (let* ((include-archives
          (and (member 'org-agenda-text-search-extra-files org-mobile-files)
               (member 'agenda-archives org-agenda-text-search-extra-files)
@@ -263,6 +272,13 @@ using `rsync' or `scp'.")
                      (list f))
                     (t nil)))
                  org-mobile-files)))
+        (files (delete
+                nil 
+                (mapcar (lambda (f)
+                          (unless (and (not (string= org-mobile-files-exclude-regexp ""))
+                                       (string-match org-mobile-files-exclude-regexp f))
+                            (identity f)))
+                        files)))
         (orgdir-uname (file-name-as-directory (file-truename org-directory)))
         (orgdir-re (concat "\\`" (regexp-quote orgdir-uname)))
         uname seen rtn file link-name)
@@ -292,9 +308,9 @@ create all custom agenda views, for upload to the mobile phone."
          (org-agenda-redo-command org-agenda-redo-command))
       (save-excursion
        (save-window-excursion
+         (run-hooks 'org-mobile-pre-push-hook)
          (org-mobile-check-setup)
          (org-mobile-prepare-file-lists)
-         (run-hooks 'org-mobile-pre-push-hook)
          (message "Creating agendas...")
          (let ((inhibit-redisplay t)) (org-mobile-create-sumo-agenda))
          (message "Creating agendas...done")
@@ -562,8 +578,9 @@ The table of checksums is written to the file mobile-checksums."
                                  " " match "</after>"))
                    settings))
        (push (list type match settings) new))
-       ((symbolp (nth 2 e))
-       ;; A user-defined function, not sure how to handle that yet
+       ((or (functionp (nth 2 e)) (symbolp (nth 2 e)))
+       ;; A user-defined function, which can do anything, so simply
+       ;; ignore it.
        )
        (t
        ;; a block agenda
@@ -617,12 +634,12 @@ The table of checksums is written to the file mobile-checksums."
                      (get-text-property (point) 'org-marker)))
          (setq sexp (member (get-text-property (point) 'type)
                             '("diary" "sexp")))
-         (if (setq pl (get-text-property (point) 'prefix-length))
+         (if (setq pl (text-property-any (point) (point-at-eol) 'org-heading t))
              (progn
                (setq prefix (org-trim (buffer-substring
-                                       (point) (+ (point) pl)))
+                                       (point) pl))
                      line (org-trim (buffer-substring
-                                     (+ (point) pl)
+                                     pl
                                      (point-at-eol))))
                (delete-region (point-at-bol) (point-at-eol))
                (insert line "<before>" prefix "</before>")
@@ -660,7 +677,7 @@ The table of checksums is written to the file mobile-checksums."
            (org-mobile-escape-olp (nth 4 (org-heading-components))))))
 
 (defun org-mobile-escape-olp (s)
-  (let  ((table '((?: . "%3a") (?\[ . "%5b") (?\] . "%5d") (?/ . "%2f"))))
+  (let  ((table '(?: ?/)))
     (org-link-escape s table)))
 
 ;;;###autoload
@@ -895,7 +912,7 @@ If BEG and END are given, only do this in that region."
                                   (buffer-file-name (current-buffer))))))
                (error (setq org-mobile-error msg))))
            (when org-mobile-error
-             (switch-to-buffer (marker-buffer marker))
+             (org-pop-to-buffer-same-window (marker-buffer marker))
              (goto-char marker)
              (incf cnt-error)
              (insert (if (stringp (nth 1 org-mobile-error))
@@ -969,11 +986,10 @@ is currently a noop.")
     (if (not (string-match "\\`olp:\\(.*?\\):\\(.*\\)$" link))
        nil
       (let ((file (match-string 1 link))
-           (path (match-string 2 link))
-           (table '((?: . "%3a") (?\[ . "%5b") (?\] . "%5d") (?/ . "%2f"))))
-       (setq file (org-link-unescape file table))
+           (path (match-string 2 link)))
+       (setq file (org-link-unescape file))
        (setq file (expand-file-name file org-directory))
-       (setq path (mapcar (lambda (x) (org-link-unescape x table))
+       (setq path (mapcar 'org-link-unescape
                           (org-split-string path "/")))
        (org-find-olp (cons file path))))))
 
@@ -1084,5 +1100,6 @@ A and B must be strings or nil."
 (provide 'org-mobile)
 
 
+
 ;;; org-mobile.el ends here