]> git.eshelyaron.com Git - emacs.git/commitdiff
(tumme-write-tags): Add.
authorMathias Dahl <mathias.dahl@gmail.com>
Mon, 24 Jul 2006 16:11:01 +0000 (16:11 +0000)
committerMathias Dahl <mathias.dahl@gmail.com>
Mon, 24 Jul 2006 16:11:01 +0000 (16:11 +0000)
(tumme-write-comments): Add.

lisp/ChangeLog
lisp/tumme.el

index 83f286d3704202f131ae4bfe539bc0a99a85da71..5375b041930aaa1d848243a9ca853b75c0744ccc 100644 (file)
@@ -1,6 +1,7 @@
 2006-07-24  mathias  <mathias@mattis>
 
        * tumme.el (tumme-write-tags): Add.
+       (tumme-write-comments): Add.
 
 2006-07-24  mathias  <mathias.dahl@gmail.com>
 
index 134420ddc9114bf4f4f052ff12a5cfb19161d597..7e3d83173a159bd96d7965178fb5d8ff2081d422 100644 (file)
@@ -2074,6 +2074,41 @@ function.  The result is a couple of new files in
       (save-buffer)
       (kill-buffer buf))))
 
+(defun tumme-write-comments (file-comments)
+  "Write file comments to database.
+Write file comments to one or more files.  FILE-COMMENTS is an alist on
+the following form:
+ ((FILE . COMMENT) ... )"
+  (let (end comment-beg file comment)
+    (with-temp-file tumme-db-file
+      (insert-file-contents tumme-db-file)
+      (dolist (elt file-comments)
+       (setq file (car elt)
+             comment (cdr elt))
+       (goto-char (point-min))
+       (if (search-forward-regexp (format "^%s.*$" file) nil t)
+           (progn
+             (setq end (point))
+             (beginning-of-line)
+             ;; Delete old comment, if any
+             (when (search-forward ";comment:" end t)
+               (setq comment-beg (match-beginning 0))
+               ;; Any tags after the comment?
+               (if (search-forward ";" end t)
+                   (setq comment-end (- (point) 1))
+                 (setq comment-end end))
+               ;; Delete comment tag and comment
+               (delete-region comment-beg comment-end))
+             ;; Insert new comment
+             (beginning-of-line)
+             (unless (search-forward ";" end t)
+               (end-of-line)
+               (insert ";"))
+             (insert (format "comment:%s;" comment)))
+         ;; File does not exist in database - add it.
+         (goto-char (point-max))
+         (insert (format "\n%s;comment:%s" file comment)))))))
+
 (defun tumme-update-property (prop value)
   "Update text property PROP with value VALUE at point."
   (let ((inhibit-read-only t))