emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/tumme.el,v


From: Mathias Dahl
Subject: [Emacs-diffs] Changes to emacs/lisp/tumme.el,v
Date: Mon, 24 Jul 2006 16:10:46 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Mathias Dahl <mathiasdahl>      06/07/24 16:10:46

Index: tumme.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/tumme.el,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- tumme.el    24 Jul 2006 16:09:17 -0000      1.35
+++ tumme.el    24 Jul 2006 16:10:46 -0000      1.36
@@ -2074,6 +2074,41 @@
       (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))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]