# HG changeset patch # User Mathias Dahl # Date 1153757357 0 # Node ID eeafd2670b7f99ff76aad4a52d85c4706641738a # Parent 002ee31c5102ac778fa8d67370ba94e388a275fd (tumme-write-tags): Add. diff -r 002ee31c5102 -r eeafd2670b7f lisp/tumme.el --- a/lisp/tumme.el Mon Jul 24 10:53:10 2006 +0000 +++ b/lisp/tumme.el Mon Jul 24 16:09:17 2006 +0000 @@ -895,6 +895,28 @@ (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