diff options
| author | Mathias Dahl | 2006-07-24 16:09:33 +0000 |
|---|---|---|
| committer | Mathias Dahl | 2006-07-24 16:09:33 +0000 |
| commit | cf882898244e313f06732005d9d59f552a4f9ae8 (patch) | |
| tree | d91f4fb797f87e2c35c77ff5e930243c75fe6c4f | |
| parent | bd876f90953400122f0bee0beae3c2166c1f0117 (diff) | |
| download | emacs-cf882898244e313f06732005d9d59f552a4f9ae8.tar.gz emacs-cf882898244e313f06732005d9d59f552a4f9ae8.zip | |
(tumme-write-tags): Add.
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/tumme.el | 22 |
2 files changed, 26 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6845edbcb5f..83f286d3704 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2006-07-24 mathias <mathias@mattis> | ||
| 2 | |||
| 3 | * tumme.el (tumme-write-tags): Add. | ||
| 4 | |||
| 1 | 2006-07-24 mathias <mathias.dahl@gmail.com> | 5 | 2006-07-24 mathias <mathias.dahl@gmail.com> |
| 2 | 6 | ||
| 3 | * tumme.el (tumme-line-up): Add an extra check for end of buffer. | 7 | * 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." | |||
| 895 | (save-buffer) | 895 | (save-buffer) |
| 896 | (kill-buffer buf)))) | 896 | (kill-buffer buf)))) |
| 897 | 897 | ||
| 898 | (defun tumme-write-tags (file-tags) | ||
| 899 | "Write file tags to database. | ||
| 900 | Write each file and tag in FILE-TAGS to the database. FILE-TAGS | ||
| 901 | is an alist in the following form: | ||
| 902 | ((FILE . TAG) ... )" | ||
| 903 | (let (end file tag) | ||
| 904 | (with-temp-file tumme-db-file | ||
| 905 | (insert-file-contents tumme-db-file) | ||
| 906 | (dolist (elt file-tags) | ||
| 907 | (setq file (car elt) | ||
| 908 | tag (cdr elt)) | ||
| 909 | (goto-char (point-min)) | ||
| 910 | (if (search-forward-regexp (format "^%s.*$" file) nil t) | ||
| 911 | (progn | ||
| 912 | (setq end (point)) | ||
| 913 | (beginning-of-line) | ||
| 914 | (when (not (search-forward (format ";%s" tag) end t)) | ||
| 915 | (end-of-line) | ||
| 916 | (insert (format ";%s" tag)))) | ||
| 917 | (goto-char (point-max)) | ||
| 918 | (insert (format "\n%s;%s" file tag))))))) | ||
| 919 | |||
| 898 | (defun tumme-remove-tag (files tag) | 920 | (defun tumme-remove-tag (files tag) |
| 899 | "For all FILES, remove TAG from the image database." | 921 | "For all FILES, remove TAG from the image database." |
| 900 | (save-excursion | 922 | (save-excursion |