Browse Source

Fix checksum of mobileorg.org after moving content

Carsten Dominik 16 years ago
parent
commit
d1b756f381
1 changed files with 17 additions and 2 deletions
  1. 17 2
      lisp/org-mobile.el

+ 17 - 2
lisp/org-mobile.el

@@ -132,7 +132,7 @@ For now, it is not recommended to change this variable."
 					  (executable-find "sha1sum")
 					  (executable-find "sha1sum")
 					  (executable-find "md5sum")
 					  (executable-find "md5sum")
 					  (executable-find "md5"))
 					  (executable-find "md5"))
-  "Executable used for computing checksums of aenda files."
+  "Executable used for computing checksums of agenda files."
   :group 'org-mobile
   :group 'org-mobile
   :type 'string)
   :type 'string)
 
 
@@ -534,10 +534,25 @@ If nothing new has beed added, return nil."
 	(save-buffer)
 	(save-buffer)
 	(set-buffer capture-buffer)
 	(set-buffer capture-buffer)
 	(erase-buffer)
 	(erase-buffer)
-	(save-buffer)))
+	(save-buffer)
+	(org-mobile-update-checksum-for-capture-file (buffer-string))))
     (kill-buffer capture-buffer)
     (kill-buffer capture-buffer)
     (if not-empty insertion-point)))
     (if not-empty insertion-point)))
 
 
+(defun org-mobile-update-checksum-for-capture-file (buffer-string)
+  (let* ((file (expand-file-name "checksums.dat" org-mobile-directory))
+	 (buffer (find-file-noselect file)))
+    (when buffer
+      (with-current-buffer buffer
+	(when (re-search-forward (concat "\\([0-9a-fA-F]\\{30,\\}\\).*?"
+					 (regexp-quote org-mobile-capture-file)
+					 "[ \t]*$"))
+	  (goto-char (match-beginning 1))
+	  (delete-region (match-beginning 1) (match-end 1))
+	  (insert (md5 buffer-string))
+	  (save-buffer)))
+      (kill-buffer buffer))))
+
 (defun org-mobile-apply (&optional beg end)
 (defun org-mobile-apply (&optional beg end)
   "Apply all change requests in the current buffer.
   "Apply all change requests in the current buffer.
 If BEG and END are given, only do this in that region."
 If BEG and END are given, only do this in that region."