From d1b756f381f83f2f659ea4f87ced382b1044e4eb Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Mon, 19 Oct 2009 13:20:51 +0200 Subject: [PATCH] Fix checksum of mobileorg.org after moving content --- lisp/org-mobile.el | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lisp/org-mobile.el b/lisp/org-mobile.el index 46a6cfba5..e0a2644e7 100644 --- a/lisp/org-mobile.el +++ b/lisp/org-mobile.el @@ -132,7 +132,7 @@ For now, it is not recommended to change this variable." (executable-find "sha1sum") (executable-find "md5sum") (executable-find "md5")) - "Executable used for computing checksums of aenda files." + "Executable used for computing checksums of agenda files." :group 'org-mobile :type 'string) @@ -534,10 +534,25 @@ If nothing new has beed added, return nil." (save-buffer) (set-buffer capture-buffer) (erase-buffer) - (save-buffer))) + (save-buffer) + (org-mobile-update-checksum-for-capture-file (buffer-string)))) (kill-buffer capture-buffer) (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) "Apply all change requests in the current buffer. If BEG and END are given, only do this in that region."