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

index 6845edbcb5f3c43c4acea43b15123d79f81c2dc6..83f286d3704202f131ae4bfe539bc0a99a85da71 100644 (file)
@@ -1,3 +1,7 @@
+2006-07-24  mathias  <mathias@mattis>
+
+       * tumme.el (tumme-write-tags): Add.
+
 2006-07-24  mathias  <mathias.dahl@gmail.com>
 
        * tumme.el (tumme-line-up): Add an extra check for end of buffer.
index f2a5613d8337727356d15c73aa56b73978accd6c..134420ddc9114bf4f4f052ff12a5cfb19161d597 100644 (file)
@@ -895,6 +895,28 @@ displayed."
       (save-buffer)
       (kill-buffer buf))))
 
+(defun tumme-write-tags (file-tags)
+  "Write file tags to database.
+Write each file and tag in FILE-TAGS to the database.  FILE-TAGS
+is an alist in the following form:
+ ((FILE . TAG) ... )"
+  (let (end file tag)
+    (with-temp-file tumme-db-file
+      (insert-file-contents tumme-db-file)
+      (dolist (elt file-tags)
+       (setq file (car elt)
+             tag (cdr elt))
+       (goto-char (point-min))
+       (if (search-forward-regexp (format "^%s.*$" file) nil t)
+           (progn
+             (setq end (point))
+             (beginning-of-line)
+             (when (not (search-forward (format ";%s" tag) end t))
+               (end-of-line)
+               (insert (format ";%s" tag))))
+         (goto-char (point-max))
+         (insert (format "\n%s;%s" file tag)))))))
+
 (defun tumme-remove-tag (files tag)
   "For all FILES, remove TAG from the image database."
   (save-excursion