Fix some minor quibble with mobile support

This commit is contained in:
Carsten Dominik 2009-10-19 12:50:47 +02:00
parent f0a3343533
commit 4300198902
3 changed files with 40 additions and 11 deletions

View File

@ -1,3 +1,9 @@
2009-10-19 Carsten Dominik <carsten.dominik@gmail.com>
* org-mobile.el (org-mobile-apply): Count success and failure.
* org.el (org-indent-line-function): Fix regexp replace problem.
2009-10-19 John Wiegley <johnw@newartisans.com> 2009-10-19 John Wiegley <johnw@newartisans.com>
* org-agenda.el (org-agenda-auto-exclude-function): New * org-agenda.el (org-agenda-auto-exclude-function): New

View File

@ -547,16 +547,28 @@ If BEG and END are given, only do this in that region."
;; Remove all Note IDs ;; Remove all Note IDs
(goto-char beg) (goto-char beg)
(while (re-search-forward "^\\*\\* Note ID: [-0-9A-F]+[ \t]*\n" nil t) (while (re-search-forward "^\\*\\* Note ID: [-0-9A-F]+[ \t]*\n" end t)
(replace-match "")) (replace-match ""))
;; Find all the referenced entries, without making any changes yet ;; Find all the referenced entries, without making any changes yet
(goto-char beg)
(let ((marker (make-marker)) (let ((marker (make-marker))
(bos-marker (make-marker)) (bos-marker (make-marker))
(end (move-marker (make-marker) end)) (end (move-marker (make-marker) end))
(cnt-new 0)
(cnt-edit 0)
(cnt-flag 0)
(cnt-error 0)
buf-list buf-list
id-pos org-mobile-error) id-pos org-mobile-error)
;; Count the new captures
(goto-char beg)
(while (re-search-forward "^\\* \\(.*\\)" end t)
(and (>= (- (match-end 1) (match-beginning 1)) 2)
(not (equal (downcase (substring (match-string 1) 0 2)) "f("))
(incf cnt-new)))
(goto-char beg)
(while (re-search-forward (while (re-search-forward
"^\\*+[ \t]+F(\\([^():\n]*\\)\\(:\\([^()\n]*\\)\\)?)[ \t]+\\[\\[\\(\\(id\\|olp\\):\\([^]\n]+\\)\\)" end t) "^\\*+[ \t]+F(\\([^():\n]*\\)\\(:\\([^()\n]*\\)\\)?)[ \t]+\\[\\[\\(\\(id\\|olp\\):\\([^]\n]+\\)\\)" end t)
(setq id-pos (condition-case msg (setq id-pos (condition-case msg
@ -570,7 +582,8 @@ If BEG and END are given, only do this in that region."
(if (or (not id-pos) (stringp id-pos)) (if (or (not id-pos) (stringp id-pos))
(progn (progn
(goto-char (+ 2 (point-at-bol))) (goto-char (+ 2 (point-at-bol)))
(insert id-pos " ")) (insert id-pos " ")
(incf cnt-error))
(add-text-properties (point-at-bol) (point-at-eol) (add-text-properties (point-at-bol) (point-at-eol)
(list 'org-mobile-marker (list 'org-mobile-marker
(or id-pos "Linked entry not found"))))) (or id-pos "Linked entry not found")))))
@ -582,16 +595,19 @@ If BEG and END are given, only do this in that region."
(setq id-pos (get-text-property (point-at-bol) 'org-mobile-marker)) (setq id-pos (get-text-property (point-at-bol) 'org-mobile-marker))
(if (not (markerp id-pos)) (if (not (markerp id-pos))
(progn (progn
(incf cnt-error)
(insert "UNKNOWN PROBLEM")) (insert "UNKNOWN PROBLEM"))
(let* ((action (match-string 1)) (let* ((action (match-string 1))
(data (and (match-end 3) (match-string 3))) (data (and (match-end 3) (match-string 3)))
(bos (point-at-bol)) (bos (point-at-bol))
(eos (org-end-of-subtree t t)) (eos (save-excursion (org-end-of-subtree t t)))
(cmd (if (equal action "") (cmd (if (equal action "")
'(progn '(progn
(incf cnt-flag)
(org-toggle-tag "FLAGGED" 'on) (org-toggle-tag "FLAGGED" 'on)
(and note (and note
(org-entry-put nil "THEFLAGGINGNOTE" note))) (org-entry-put nil "THEFLAGGINGNOTE" note)))
(incf cnt-edit)
(cdr (assoc action org-mobile-action-alist)))) (cdr (assoc action org-mobile-action-alist))))
(note (and (equal action "") (note (and (equal action "")
(buffer-substring (1+ (point-at-eol)) eos))) (buffer-substring (1+ (point-at-eol)) eos)))
@ -609,8 +625,8 @@ If BEG and END are given, only do this in that region."
(progn (outline-next-heading) (progn (outline-next-heading)
(if (eobp) (org-back-over-empty-lines)) (if (eobp) (org-back-over-empty-lines))
(point))))) (point)))))
(setq old (if (string-match "\\S-" old) old nil)) (setq old (and old (if (string-match "\\S-" old) old nil)))
(setq new (if (string-match "\\S-" new) new nil)) (setq new (and new (if (string-match "\\S-" new) new nil)))
(if (and note (> (length note) 0)) (if (and note (> (length note) 0))
;; Make Note into a single line, to fit into a property ;; Make Note into a single line, to fit into a property
(setq note (mapconcat 'identity (setq note (mapconcat 'identity
@ -622,9 +638,11 @@ If BEG and END are given, only do this in that region."
(goto-char (+ 2 bos-marker)) (goto-char (+ 2 bos-marker))
(unless (markerp id-pos) (unless (markerp id-pos)
(insert "BAD REFERENCE ") (insert "BAD REFERENCE ")
(incf cnd-error)
(throw 'next t)) (throw 'next t))
(unless cmd (unless cmd
(insert "BAD FLAG ") (insert "BAD FLAG ")
(incf cnt-error)
(throw 'next t)) (throw 'next t))
;; Remember this place so tha we can return ;; Remember this place so tha we can return
(move-marker marker (point)) (move-marker marker (point))
@ -641,6 +659,7 @@ If BEG and END are given, only do this in that region."
(when org-mobile-error (when org-mobile-error
(switch-to-buffer (marker-buffer marker)) (switch-to-buffer (marker-buffer marker))
(goto-char marker) (goto-char marker)
(incf cnt-error)
(insert (if (stringp (nth 1 org-mobile-error)) (insert (if (stringp (nth 1 org-mobile-error))
(nth 1 org-mobile-error) (nth 1 org-mobile-error)
"EXECUTION FAILED") "EXECUTION FAILED")
@ -651,7 +670,10 @@ If BEG and END are given, only do this in that region."
(goto-char bos-marker) (goto-char bos-marker)
(delete-region (point) (org-end-of-subtree t t)))))) (delete-region (point) (org-end-of-subtree t t))))))
(move-marker marker nil) (move-marker marker nil)
(move-marker end nil))) (move-marker end nil)
(message "%d new, %d edits, %d flags, %d errors" cnt-new
cnt-edit cnt-flag cnt-error)
(sit-for 1)))
(defun org-mobile-timestamp-buffer (buf) (defun org-mobile-timestamp-buffer (buf)
"Time stamp buffer BUF, just to make sure its checksum will change." "Time stamp buffer BUF, just to make sure its checksum will change."
@ -771,7 +793,7 @@ be returned that indicates what went wrong."
((or (equal current old) ((or (equal current old)
(eq org-mobile-force-mobile-change t) (eq org-mobile-force-mobile-change t)
(memq 'todo org-mobile-force-mobile-change)) (memq 'todo org-mobile-force-mobile-change))
(org-todo new) t) (org-todo (or new 'none)) t)
(t (error "State before change was expected as \"%s\", but is \"%s\"" (t (error "State before change was expected as \"%s\", but is \"%s\""
old current)))) old current))))

View File

@ -16500,9 +16500,10 @@ which make use of the date at the cursor."
(beginning-of-line 1) (beginning-of-line 1)
(if (looking-at (if (looking-at
"\\([ \t]+\\)\\(:[-_0-9a-zA-Z]+:\\)[ \t]*\\(\\S-.*\\(\\S-\\|$\\)\\)") "\\([ \t]+\\)\\(:[-_0-9a-zA-Z]+:\\)[ \t]*\\(\\S-.*\\(\\S-\\|$\\)\\)")
(replace-match (concat "\\1" (format org-property-format (replace-match (concat (match-string 1)
(match-string 2) (match-string 3))) (format org-property-format
t nil)) (match-string 2) (match-string 3)))
t t))
(org-move-to-column column))) (org-move-to-column column)))
(defun org-set-autofill-regexps () (defun org-set-autofill-regexps ()