aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2011-08-08 14:21:32 -0400
committerChong Yidong2011-08-08 14:21:32 -0400
commit839dde57161c56f03ec4fbcba9e1b26d0924b8fd (patch)
treeb7d2be56a8cd17c0904f456e70f7be4f85ab1c87
parent757664a4549c35d3cf5f2f4305ba1f09ce97a6da (diff)
downloademacs-839dde57161c56f03ec4fbcba9e1b26d0924b8fd.tar.gz
emacs-839dde57161c56f03ec4fbcba9e1b26d0924b8fd.zip
* image-dired.el: Don't use find-file for temporary work.
(image-dired--with-db-file): New macro. (image-dired-write-tags, image-dired-remove-tag) (image-dired-create-gallery-lists, image-dired-write-comments) (image-dired-get-comment, image-dired-mark-tagged-files) (image-dired-list-tags, image-dired-gallery-generate): Use it. (image-dired-gallery-generate): Use insert-file-contents. Fixes: debbugs:7895
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/image-dired.el454
2 files changed, 225 insertions, 237 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index bd344dad35a..d81f39aa64c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,13 @@
12011-08-08 Chong Yidong <cyd@stupidchicken.com> 12011-08-08 Chong Yidong <cyd@stupidchicken.com>
2 2
3 * image-dired.el: Don't use find-file for temporary work (Bug#7895).
4 (image-dired--with-db-file): New macro.
5 (image-dired-write-tags, image-dired-remove-tag)
6 (image-dired-create-gallery-lists, image-dired-write-comments)
7 (image-dired-get-comment, image-dired-mark-tagged-files)
8 (image-dired-list-tags, image-dired-gallery-generate): Use it.
9 (image-dired-gallery-generate): Use insert-file-contents.
10
3 * time.el (display-time-world-list, display-time-world-display): 11 * time.el (display-time-world-list, display-time-world-display):
4 * time-stamp.el (time-stamp-string): 12 * time-stamp.el (time-stamp-string):
5 * vc/add-log.el (add-change-log-entry): Use setenv instead of 13 * vc/add-log.el (add-change-log-entry): Use setenv instead of
diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index ce351f13a19..5477d01379d 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -516,6 +516,14 @@ before warning the user."
516 :type 'integer 516 :type 'integer
517 :group 'image-dired) 517 :group 'image-dired)
518 518
519(defmacro image-dired--with-db-file (&rest body)
520 "Run BODY in a temp buffer containing `image-dired-db-file'.
521Return the last form in BODY."
522 `(with-temp-buffer
523 (if (file-exists-p image-dired-db-file)
524 (insert-file-contents image-dired-db-file))
525 ,@body))
526
519(defun image-dired-dir () 527(defun image-dired-dir ()
520 "Return the current thumbnails directory (from variable `image-dired-dir'). 528 "Return the current thumbnails directory (from variable `image-dired-dir').
521Create the thumbnails directory if it does not exist." 529Create the thumbnails directory if it does not exist."
@@ -898,76 +906,69 @@ FILE-TAGS is an alist in the following form:
898 ((FILE . TAG) ... )" 906 ((FILE . TAG) ... )"
899 (image-dired-sane-db-file) 907 (image-dired-sane-db-file)
900 (let (end file tag) 908 (let (end file tag)
901 (with-temp-file image-dired-db-file 909 (image-dired--with-db-file
902 (insert-file-contents image-dired-db-file) 910 (setq buffer-file-name image-dired-db-file)
903 (dolist (elt file-tags) 911 (dolist (elt file-tags)
904 (setq file (car elt) 912 (setq file (car elt)
905 tag (cdr elt)) 913 tag (cdr elt))
906 (goto-char (point-min)) 914 (goto-char (point-min))
907 (if (search-forward-regexp (format "^%s.*$" file) nil t) 915 (if (search-forward-regexp (format "^%s.*$" file) nil t)
908 (progn 916 (progn
909 (setq end (point)) 917 (setq end (point))
910 (beginning-of-line) 918 (beginning-of-line)
911 (when (not (search-forward (format ";%s" tag) end t)) 919 (when (not (search-forward (format ";%s" tag) end t))
912 (end-of-line) 920 (end-of-line)
913 (insert (format ";%s" tag)))) 921 (insert (format ";%s" tag))))
914 (goto-char (point-max)) 922 (goto-char (point-max))
915 (insert (format "\n%s;%s" file tag))))))) 923 (insert (format "\n%s;%s" file tag))))
924 (save-buffer))))
916 925
917(defun image-dired-remove-tag (files tag) 926(defun image-dired-remove-tag (files tag)
918 "For all FILES, remove TAG from the image database." 927 "For all FILES, remove TAG from the image database."
919 (image-dired-sane-db-file) 928 (image-dired-sane-db-file)
920 (save-excursion 929 (image-dired--with-db-file
921 (let (end buf) 930 (setq buffer-file-name image-dired-db-file)
922 (setq buf (find-file image-dired-db-file)) 931 (let (end)
923 (if (not (listp files)) 932 (unless (listp files)
924 (if (stringp files) 933 (if (stringp files)
925 (setq files (list files)) 934 (setq files (list files))
926 (error "Files must be a string or a list of strings!"))) 935 (error "Files must be a string or a list of strings!")))
927 (mapc 936 (dolist (file files)
928 (lambda (file) 937 (goto-char (point-min))
929 (goto-char (point-min)) 938 (when (search-forward-regexp (format "^%s" file) nil t)
930 (when (search-forward-regexp 939 (end-of-line)
931 (format "^%s" file) nil t) 940 (setq end (point))
932 (end-of-line) 941 (beginning-of-line)
933 (setq end (point)) 942 (when (search-forward-regexp (format "\\(;%s\\)" tag) end t)
934 (beginning-of-line) 943 (delete-region (match-beginning 1) (match-end 1))
935 (when (search-forward-regexp (format "\\(;%s\\)" tag) end t) 944 ;; Check if file should still be in the database. If
936 (delete-region (match-beginning 1) (match-end 1)) 945 ;; it has no tags or comments, it will be removed.
937 ;; Check if file should still be in the database. If 946 (end-of-line)
938 ;; it has no tags or comments, it will be removed. 947 (setq end (point))
939 (end-of-line) 948 (beginning-of-line)
940 (setq end (point)) 949 (when (not (search-forward ";" end t))
941 (beginning-of-line) 950 (kill-line 1)
942 (when (not (search-forward ";" end t)) 951 ;; If on empty line at end of buffer
943 (kill-line 1) 952 (and (eobp)
944 ;; If on empty line at end of buffer 953 (looking-at "^$")
945 (when (and (eobp) 954 (delete-char -1)))))))
946 (looking-at "^$")) 955 (save-buffer)))
947 (delete-char -1))))))
948 files)
949 (save-buffer)
950 (kill-buffer buf))))
951 956
952(defun image-dired-list-tags (file) 957(defun image-dired-list-tags (file)
953 "Read all tags for image FILE from the image database." 958 "Read all tags for image FILE from the image database."
954 (image-dired-sane-db-file) 959 (image-dired-sane-db-file)
955 (save-excursion 960 (image-dired--with-db-file
956 (let (end buf (tags "")) 961 (let (end (tags ""))
957 (setq buf (find-file image-dired-db-file)) 962 (when (search-forward-regexp (format "^%s" file) nil t)
958 (goto-char (point-min)) 963 (end-of-line)
959 (when (search-forward-regexp 964 (setq end (point))
960 (format "^%s" file) nil t) 965 (beginning-of-line)
961 (end-of-line) 966 (if (search-forward ";" end t)
962 (setq end (point)) 967 (if (search-forward "comment:" end t)
963 (beginning-of-line) 968 (if (search-forward ";" end t)
964 (if (search-forward ";" end t) 969 (setq tags (buffer-substring (point) end)))
965 (if (search-forward "comment:" end t) 970 (setq tags (buffer-substring (point) end)))))
966 (if (search-forward ";" end t) 971 (split-string tags ";"))))
967 (setq tags (buffer-substring (point) end)))
968 (setq tags (buffer-substring (point) end)))))
969 (kill-buffer buf)
970 (split-string tags ";"))))
971 972
972;;;###autoload 973;;;###autoload
973(defun image-dired-tag-files (arg) 974(defun image-dired-tag-files (arg)
@@ -2061,34 +2062,35 @@ FILE-COMMENTS is an alist on the following form:
2061 ((FILE . COMMENT) ... )" 2062 ((FILE . COMMENT) ... )"
2062 (image-dired-sane-db-file) 2063 (image-dired-sane-db-file)
2063 (let (end comment-beg-pos comment-end-pos file comment) 2064 (let (end comment-beg-pos comment-end-pos file comment)
2064 (with-temp-file image-dired-db-file 2065 (image-dired--with-db-file
2065 (insert-file-contents image-dired-db-file) 2066 (setq buffer-file-name image-dired-db-file)
2066 (dolist (elt file-comments) 2067 (dolist (elt file-comments)
2067 (setq file (car elt) 2068 (setq file (car elt)
2068 comment (cdr elt)) 2069 comment (cdr elt))
2069 (goto-char (point-min)) 2070 (goto-char (point-min))
2070 (if (search-forward-regexp (format "^%s.*$" file) nil t) 2071 (if (search-forward-regexp (format "^%s.*$" file) nil t)
2071 (progn 2072 (progn
2072 (setq end (point)) 2073 (setq end (point))
2073 (beginning-of-line) 2074 (beginning-of-line)
2074 ;; Delete old comment, if any 2075 ;; Delete old comment, if any
2075 (when (search-forward ";comment:" end t) 2076 (when (search-forward ";comment:" end t)
2076 (setq comment-beg-pos (match-beginning 0)) 2077 (setq comment-beg-pos (match-beginning 0))
2077 ;; Any tags after the comment? 2078 ;; Any tags after the comment?
2078 (if (search-forward ";" end t) 2079 (if (search-forward ";" end t)
2079 (setq comment-end-pos (- (point) 1)) 2080 (setq comment-end-pos (- (point) 1))
2080 (setq comment-end-pos end)) 2081 (setq comment-end-pos end))
2081 ;; Delete comment tag and comment 2082 ;; Delete comment tag and comment
2082 (delete-region comment-beg-pos comment-end-pos)) 2083 (delete-region comment-beg-pos comment-end-pos))
2083 ;; Insert new comment 2084 ;; Insert new comment
2084 (beginning-of-line) 2085 (beginning-of-line)
2085 (unless (search-forward ";" end t) 2086 (unless (search-forward ";" end t)
2086 (end-of-line) 2087 (end-of-line)
2087 (insert ";")) 2088 (insert ";"))
2088 (insert (format "comment:%s;" comment))) 2089 (insert (format "comment:%s;" comment)))
2089 ;; File does not exist in database - add it. 2090 ;; File does not exist in database - add it.
2090 (goto-char (point-max)) 2091 (goto-char (point-max))
2091 (insert (format "\n%s;comment:%s" file comment))))))) 2092 (insert (format "\n%s;comment:%s" file comment))))
2093 (save-buffer))))
2092 2094
2093(defun image-dired-update-property (prop value) 2095(defun image-dired-update-property (prop value)
2094 "Update text property PROP with value VALUE at point." 2096 "Update text property PROP with value VALUE at point."
@@ -2130,24 +2132,20 @@ Optionally use old comment from FILE as initial value."
2130(defun image-dired-get-comment (file) 2132(defun image-dired-get-comment (file)
2131 "Get comment for file FILE." 2133 "Get comment for file FILE."
2132 (image-dired-sane-db-file) 2134 (image-dired-sane-db-file)
2133 (save-excursion 2135 (image-dired--with-db-file
2134 (let (end buf comment-beg-pos comment-end-pos comment) 2136 (let (end comment-beg-pos comment-end-pos comment)
2135 (setq buf (find-file image-dired-db-file)) 2137 (when (search-forward-regexp (format "^%s" file) nil t)
2136 (goto-char (point-min)) 2138 (end-of-line)
2137 (when (search-forward-regexp 2139 (setq end (point))
2138 (format "^%s" file) nil t) 2140 (beginning-of-line)
2139 (end-of-line) 2141 (when (search-forward ";comment:" end t)
2140 (setq end (point)) 2142 (setq comment-beg-pos (point))
2141 (beginning-of-line) 2143 (if (search-forward ";" end t)
2142 (cond ((search-forward ";comment:" end t) 2144 (setq comment-end-pos (- (point) 1))
2143 (setq comment-beg-pos (point)) 2145 (setq comment-end-pos end))
2144 (if (search-forward ";" end t) 2146 (setq comment (buffer-substring
2145 (setq comment-end-pos (- (point) 1)) 2147 comment-beg-pos comment-end-pos))))
2146 (setq comment-end-pos end)) 2148 comment)))
2147 (setq comment (buffer-substring
2148 comment-beg-pos comment-end-pos)))))
2149 (kill-buffer buf)
2150 comment)))
2151 2149
2152;;;###autoload 2150;;;###autoload
2153(defun image-dired-mark-tagged-files () 2151(defun image-dired-mark-tagged-files ()
@@ -2161,32 +2159,26 @@ matching tag will be marked in the dired buffer."
2161 (image-dired-sane-db-file) 2159 (image-dired-sane-db-file)
2162 (let ((tag (read-string "Mark tagged files (regexp): ")) 2160 (let ((tag (read-string "Mark tagged files (regexp): "))
2163 (hits 0) 2161 (hits 0)
2164 files buf) 2162 files)
2165 (save-excursion 2163 (image-dired--with-db-file
2166 (setq buf (find-file image-dired-db-file)) 2164 ;; Collect matches
2167 (goto-char (point-min)) 2165 (while (search-forward-regexp
2168 ;; Collect matches 2166 (concat "\\(^[^;\n]+\\);.*" tag ".*$") nil t)
2169 (while (search-forward-regexp 2167 (push (match-string 1) files)))
2170 (concat "\\(^[^;\n]+\\);.*" tag ".*$") nil t) 2168 ;; Mark files
2171 (setq files (append (list (match-string 1)) files))) 2169 (dolist (curr-file files)
2172 (kill-buffer buf) 2170 ;; I tried using `dired-mark-files-regexp' but it was waaaay to
2173 ;; Mark files 2171 ;; slow. Don't bother about hits found in other directories
2174 (mapc 2172 ;; than the current one.
2175 ;; I tried using `dired-mark-files-regexp' but it was 2173 (when (string= (file-name-as-directory
2176 ;; waaaay to slow. 2174 (expand-file-name default-directory))
2177 (lambda (curr-file) 2175 (file-name-as-directory
2178 ;; Don't bother about hits found in other directories than 2176 (file-name-directory curr-file)))
2179 ;; the current one. 2177 (setq curr-file (file-name-nondirectory curr-file))
2180 (when (string= (file-name-as-directory 2178 (goto-char (point-min))
2181 (expand-file-name default-directory)) 2179 (when (search-forward-regexp (format "\\s %s$" curr-file) nil t)
2182 (file-name-as-directory 2180 (setq hits (+ hits 1))
2183 (file-name-directory curr-file))) 2181 (dired-mark 1))))
2184 (setq curr-file (file-name-nondirectory curr-file))
2185 (goto-char (point-min))
2186 (when (search-forward-regexp (format "\\s %s$" curr-file) nil t)
2187 (setq hits (+ hits 1))
2188 (dired-mark 1))))
2189 files))
2190 (message "%d files with matching tag marked." hits))) 2182 (message "%d files with matching tag marked." hits)))
2191 2183
2192(defun image-dired-mouse-display-image (event) 2184(defun image-dired-mouse-display-image (event)
@@ -2322,29 +2314,26 @@ image-dired-file-comment-list:
2322(defun image-dired-create-gallery-lists () 2314(defun image-dired-create-gallery-lists ()
2323 "Create temporary lists used by `image-dired-gallery-generate'." 2315 "Create temporary lists used by `image-dired-gallery-generate'."
2324 (image-dired-sane-db-file) 2316 (image-dired-sane-db-file)
2325 (let ((buf (find-file image-dired-db-file)) 2317 (image-dired--with-db-file
2326 end beg file row-tags) 2318 (let (end beg file row-tags)
2327 (setq image-dired-tag-file-list nil) 2319 (setq image-dired-tag-file-list nil)
2328 (setq image-dired-file-tag-list nil) 2320 (setq image-dired-file-tag-list nil)
2329 (setq image-dired-file-comment-list nil) 2321 (setq image-dired-file-comment-list nil)
2330 (goto-char (point-min)) 2322 (goto-char (point-min))
2331 (while (search-forward-regexp "^." nil t) 2323 (while (search-forward-regexp "^." nil t)
2332 (end-of-line) 2324 (end-of-line)
2333 (setq end (point)) 2325 (setq end (point))
2334 (beginning-of-line) 2326 (beginning-of-line)
2335 (setq beg (point)) 2327 (setq beg (point))
2336 (if (not (search-forward ";" end nil)) 2328 (unless (search-forward ";" end nil)
2337 (error "Something is really wrong, check format of database")) 2329 (error "Something is really wrong, check format of database"))
2338 (setq row-tags (split-string 2330 (setq row-tags (split-string
2339 (buffer-substring beg end) ";")) 2331 (buffer-substring beg end) ";"))
2340 (setq file (car row-tags)) 2332 (setq file (car row-tags))
2341 (mapc 2333 (dolist (x (cdr row-tags))
2342 (lambda (x) 2334 (if (not (string-match "^comment:\\(.*\\)" x))
2343 (if (not (string-match "^comment:\\(.*\\)" x)) 2335 (image-dired-add-to-tag-file-lists x file)
2344 (image-dired-add-to-tag-file-lists x file) 2336 (image-dired-add-to-file-comment-list file (match-string 1 x)))))))
2345 (image-dired-add-to-file-comment-list file (match-string 1 x))))
2346 (cdr row-tags)))
2347 (kill-buffer buf))
2348 ;; Sort tag-file list 2337 ;; Sort tag-file list
2349 (setq image-dired-tag-file-list 2338 (setq image-dired-tag-file-list
2350 (sort image-dired-tag-file-list 2339 (sort image-dired-tag-file-list
@@ -2372,7 +2361,8 @@ it easier to generate, then HTML-files are created in
2372when using per-directory thumbnail file storage")) 2361when using per-directory thumbnail file storage"))
2373 (image-dired-create-gallery-lists) 2362 (image-dired-create-gallery-lists)
2374 (let ((tags image-dired-tag-file-list) 2363 (let ((tags image-dired-tag-file-list)
2375 count tag index-buf tag-buf 2364 (index-file (format "%s/index.html" image-dired-gallery-dir))
2365 count tag tag-file
2376 comment file-tags tag-link tag-link-list) 2366 comment file-tags tag-link tag-link-list)
2377 ;; Make sure gallery root exist 2367 ;; Make sure gallery root exist
2378 (if (file-exists-p image-dired-gallery-dir) 2368 (if (file-exists-p image-dired-gallery-dir)
@@ -2380,85 +2370,75 @@ when using per-directory thumbnail file storage"))
2380 (error "Variable image-dired-gallery-dir is not a directory")) 2370 (error "Variable image-dired-gallery-dir is not a directory"))
2381 (make-directory image-dired-gallery-dir)) 2371 (make-directory image-dired-gallery-dir))
2382 ;; Open index file 2372 ;; Open index file
2383 (setq index-buf (find-file 2373 (with-temp-file index-file
2384 (format "%s/index.html" image-dired-gallery-dir))) 2374 (if (file-exists-p index-file)
2385 (erase-buffer) 2375 (insert-file-contents index-file))
2386 (insert "<html>\n") 2376 (insert "<html>\n")
2387 (insert " <body>\n") 2377 (insert " <body>\n")
2388 (insert " <h2>Image-Dired Gallery</h2>\n") 2378 (insert " <h2>Image-Dired Gallery</h2>\n")
2389 (insert (format "<p>\n Gallery generated %s\n <p>\n" 2379 (insert (format "<p>\n Gallery generated %s\n <p>\n"
2390 (current-time-string))) 2380 (current-time-string)))
2391 (insert " <h3>Tag index</h3>\n") 2381 (insert " <h3>Tag index</h3>\n")
2392 (setq count 1) 2382 (setq count 1)
2393 ;; Pre-generate list of all tag links 2383 ;; Pre-generate list of all tag links
2394 (mapc 2384 (dolist (curr tags)
2395 (lambda (curr) 2385 (setq tag (car curr))
2396 (setq tag (car curr)) 2386 (when (not (member tag image-dired-gallery-hidden-tags))
2397 (when (not (member tag image-dired-gallery-hidden-tags)) 2387 (setq tag-link (format "<a href=\"%d.html\">%s</a>" count tag))
2398 (setq tag-link (format "<a href=\"%d.html\">%s</a>" count tag)) 2388 (if tag-link-list
2399 (if tag-link-list 2389 (setq tag-link-list
2400 (setq tag-link-list 2390 (append tag-link-list (list (cons tag tag-link))))
2401 (append tag-link-list (list (cons tag tag-link)))) 2391 (setq tag-link-list (list (cons tag tag-link))))
2402 (setq tag-link-list (list (cons tag tag-link)))) 2392 (setq count (1+ count))))
2403 (setq count (1+ count)))) 2393 (setq count 1)
2404 tags) 2394 ;; Main loop where we generated thumbnail pages per tag
2405 (setq count 1) 2395 (dolist (curr tags)
2406 ;; Main loop where we generated thumbnail pages per tag 2396 (setq tag (car curr))
2407 (mapc 2397 ;; Don't display hidden tags
2408 (lambda (curr) 2398 (when (not (member tag image-dired-gallery-hidden-tags))
2409 (setq tag (car curr)) 2399 ;; Insert link to tag page in index
2410 ;; Don't display hidden tags 2400 (insert (format " %s<br>\n" (cdr (assoc tag tag-link-list))))
2411 (when (not (member tag image-dired-gallery-hidden-tags)) 2401 ;; Open per-tag file
2412 ;; Insert link to tag page in index 2402 (setq tag-file (format "%s/%s.html" image-dired-gallery-dir count))
2413 (insert (format " %s<br>\n" (cdr (assoc tag tag-link-list)))) 2403 (with-temp-file tag-file
2414 ;; Open per-tag file 2404 (if (file-exists-p tag-file)
2415 (setq tag-buf (find-file 2405 (insert-file-contents tag-file))
2416 (format "%s/%s.html" image-dired-gallery-dir count))) 2406 (erase-buffer)
2417 (erase-buffer) 2407 (insert "<html>\n")
2418 (insert "<html>\n") 2408 (insert " <body>\n")
2419 (insert " <body>\n") 2409 (insert " <p><a href=\"index.html\">Index</a></p>\n")
2420 (insert " <p><a href=\"index.html\">Index</a></p>\n") 2410 (insert (format " <h2>Images with tag &quot;%s&quot;</h2>" tag))
2421 (insert (format " <h2>Images with tag &quot;%s&quot;</h2>" tag)) 2411 ;; Main loop for files per tag page
2422 ;; Main loop for files per tag page 2412 (dolist (file (cdr curr))
2423 (mapc 2413 (unless (image-dired-hidden-p file)
2424 (lambda (file) 2414 ;; Insert thumbnail with link to full image
2425 (when (not (image-dired-hidden-p file)) 2415 (insert
2426 ;; Insert thumbnail with link to full image 2416 (format "<a href=\"%s/%s\"><img src=\"%s/%s\"%s></a>\n"
2427 (insert 2417 image-dired-gallery-image-root-url
2428 (format "<a href=\"%s/%s\"><img src=\"%s/%s\"%s></a>\n" 2418 (file-name-nondirectory file)
2429 image-dired-gallery-image-root-url 2419 image-dired-gallery-thumb-image-root-url
2430 (file-name-nondirectory file) 2420 (file-name-nondirectory (image-dired-thumb-name file)) file))
2431 image-dired-gallery-thumb-image-root-url 2421 ;; Insert comment, if any
2432 (file-name-nondirectory (image-dired-thumb-name file)) file)) 2422 (if (setq comment (cdr (assoc file image-dired-file-comment-list)))
2433 ;; Insert comment, if any 2423 (insert (format "<br>\n%s<br>\n" comment))
2434 (if (setq comment (cdr (assoc file image-dired-file-comment-list))) 2424 (insert "<br>\n"))
2435 (insert (format "<br>\n%s<br>\n" comment)) 2425 ;; Insert links to other tags, if any
2436 (insert "<br>\n")) 2426 (when (> (length
2437 ;; Insert links to other tags, if any 2427 (setq file-tags (assoc file image-dired-file-tag-list))) 2)
2438 (when (> (length 2428 (insert "[ ")
2439 (setq file-tags (assoc file image-dired-file-tag-list))) 2) 2429 (dolist (extra-tag file-tags)
2440 (insert "[ ") 2430 ;; Only insert if not file name or the main tag
2441 (mapc 2431 (if (and (not (equal extra-tag tag))
2442 (lambda (extra-tag) 2432 (not (equal extra-tag file)))
2443 ;; Only insert if not file name or the main tag 2433 (insert
2444 (if (and (not (equal extra-tag tag)) 2434 (format "%s " (cdr (assoc extra-tag tag-link-list))))))
2445 (not (equal extra-tag file))) 2435 (insert "]<br>\n"))))
2446 (insert 2436 (insert " <p><a href=\"index.html\">Index</a></p>\n")
2447 (format "%s " (cdr (assoc extra-tag tag-link-list)))))) 2437 (insert " </body>\n")
2448 file-tags) 2438 (insert "</html>\n"))
2449 (insert "]<br>\n")))) 2439 (setq count (1+ count))))
2450 (cdr curr)) 2440 (insert " </body>\n")
2451 (insert " <p><a href=\"index.html\">Index</a></p>\n") 2441 (insert "</html>"))))
2452 (insert " </body>\n")
2453 (insert "</html>\n")
2454 (save-buffer)
2455 (kill-buffer tag-buf)
2456 (setq count (1+ count))))
2457 tags)
2458 (insert " </body>\n")
2459 (insert "</html>")
2460 (save-buffer)
2461 (kill-buffer index-buf)))
2462 2442
2463(defun image-dired-kill-buffer-and-window () 2443(defun image-dired-kill-buffer-and-window ()
2464 "Kill the current buffer and, if possible, also the window." 2444 "Kill the current buffer and, if possible, also the window."