From cf882898244e313f06732005d9d59f552a4f9ae8 Mon Sep 17 00:00:00 2001 From: Mathias Dahl Date: Mon, 24 Jul 2006 16:09:33 +0000 Subject: [PATCH] (tumme-write-tags): Add. --- lisp/ChangeLog | 4 ++++ lisp/tumme.el | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6845edbcb5f..83f286d3704 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2006-07-24 mathias + + * tumme.el (tumme-write-tags): Add. + 2006-07-24 mathias * tumme.el (tumme-line-up): Add an extra check for end of buffer. diff --git a/lisp/tumme.el b/lisp/tumme.el index f2a5613d833..134420ddc91 100644 --- a/lisp/tumme.el +++ b/lisp/tumme.el @@ -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 -- 2.39.2