Mercurial > emacs
annotate lisp/tumme.el @ 72124:46e335881cbf
(tumme-track-original-file): Add `buffer-live-p' check.
(tumme-format-properties-string): Handle empty `buf'.
(tumme-get-comment): Change variable names inside `let'. Add
missing `let' variable that cause font-lock problems.
(tumme-write-comments): Change variable names inside `let'. Add
missing `let' variable that cause font-lock problems.
(tumme-forward-image): Rename from `tumme-forward-char'.
(tumme-backward-image): Rename from `tumme-backward-char'.
author | Mathias Dahl <mathias.dahl@gmail.com> |
---|---|
date | Tue, 25 Jul 2006 16:20:53 +0000 |
parents | 2df19ee49e28 |
children | b5439b7a1ef1 |
rev | line source |
---|---|
67302 | 1 ;;; tumme.el --- use dired to browse and manipulate your images |
2 ;; | |
68651
3bd95f4f2941
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
68404
diff
changeset
|
3 ;; Copyright (C) 2005, 2006 Free Software Foundation, Inc. |
67302 | 4 ;; |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
5 ;; Version: 0.4.11 |
68404 | 6 ;; Keywords: multimedia |
67302 | 7 ;; Author: Mathias Dahl <mathias.rem0veth1s.dahl@gmail.com> |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
24 ;; Boston, MA 02110-1301, USA. | |
25 | |
26 ;;; Commentary: | |
27 ;; | |
28 ;; BACKGROUND | |
29 ;; ========== | |
30 ;; | |
31 ;; I needed a program to browse, organize and tag my pictures. I got | |
32 ;; tired of the old gallery program I used as it did not allow | |
33 ;; multi-file operations easily. Also, it put things out of my | |
34 ;; control. Image viewing programs I tested did not allow multi-file | |
35 ;; operations or did not do what I wanted it to. | |
36 ;; | |
37 ;; So, I got the idea to use the wonderful functionality of Emacs and | |
38 ;; `dired' to do it. It would allow me to do almost anything I wanted, | |
39 ;; which is basically just to browse all my pictures in an easy way, | |
40 ;; letting me manipulate and tag them in various ways. `dired' already | |
41 ;; provide all the file handling and navigation facilities; I only | |
42 ;; needed to add some functions to display the images. | |
43 ;; | |
44 ;; I briefly tried out thumbs.el, and although it seemed more | |
45 ;; powerful than this package, it did not work the way I wanted to. It | |
46 ;; was too slow to created thumbnails of all files in a directory (I | |
47 ;; currently keep all my 2000+ images in the same directory) and | |
48 ;; browsing the thumbnail buffer was slow too. tumme.el will not | |
49 ;; create thumbnails until they are needed and the browsing is done | |
50 ;; quickly and easily in dired. I copied a great deal of ideas and | |
51 ;; code from there though... :) | |
52 ;; | |
53 ;; About the name: tumme means thumb in Swedish and it is used for | |
54 ;; working with thumbnails, so... :) If you want to know how to | |
55 ;; pronounce it, go to the page on EmacsWiki and download the .ogg | |
56 ;; file from there. | |
57 ;; | |
58 ;; `tumme' stores the thumbnail files in `tumme-dir' using the file | |
59 ;; name format ORIGNAME.thumb.ORIGEXT. For example | |
68783
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
60 ;; ~/.emacs.d/tumme/myimage01.thumb.jpg. The "database" is for now |
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
61 ;; just a plain text file with the following format: |
67302 | 62 ;; |
63 ;; file-name-non-directory;comment:comment-text;tag1;tag2;tag3;...;tagN | |
64 ;; | |
65 ;; | |
66 ;; PREREQUISITES | |
67 ;; ============= | |
68 ;; | |
69 ;; * The ImageMagick package. Currently, `convert' and `mogrify' are | |
70 ;; used. Find it here: http://www.imagemagick.org. | |
71 ;; | |
72 ;; * For non-lossy rotation of JPEG images, the JpegTRAN program is | |
73 ;; needed. | |
74 ;; | |
75 ;; * For `tumme-get-exif-data' and `tumme-write-exif-data' to work, | |
76 ;; the command line tool `exiftool' is needed. It can be found here: | |
77 ;; http://www.sno.phy.queensu.ca/~phil/exiftool/. These two functions | |
78 ;; are, among other things, used for writing comments to image files | |
79 ;; using `tumme-thumbnail-set-image-description' and to create | |
80 ;; "unique" file names using `tumme-get-exif-file-name' (used by | |
81 ;; `tumme-copy-with-exif-file-name'). | |
82 ;; | |
83 ;; | |
84 ;; USAGE | |
85 ;; ===== | |
86 ;; | |
72093
e75e38c3a62f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72091
diff
changeset
|
87 ;; This information has been moved to the manual. Type `C-h r' to open |
70890
6bb61012beed
Removed most of the information in the USAGE section. The manual does a better job.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70888
diff
changeset
|
88 ;; the Emacs manual and go to the node Thumbnails by typing `g |
6bb61012beed
Removed most of the information in the USAGE section. The manual does a better job.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70888
diff
changeset
|
89 ;; Thumbnails RET'. |
67302 | 90 ;; |
70890
6bb61012beed
Removed most of the information in the USAGE section. The manual does a better job.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70888
diff
changeset
|
91 ;; Quickstart: M-x tumme RET DIRNAME RET |
67302 | 92 ;; |
70890
6bb61012beed
Removed most of the information in the USAGE section. The manual does a better job.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70888
diff
changeset
|
93 ;; where DIRNAME is a directory containing image files. |
67302 | 94 ;; |
95 ;; LIMITATIONS | |
96 ;; =========== | |
97 ;; | |
98 ;; * Supports all image formats that Emacs and convert supports, but | |
99 ;; the thumbnails are hard-coded to JPEG format. | |
100 ;; | |
101 ;; * WARNING: The "database" format used might be changed so keep a | |
102 ;; backup of `tumme-db-file' when testing new versions. | |
103 ;; | |
104 ;; | |
105 ;; TODO | |
106 ;; ==== | |
107 ;; | |
108 ;; * Support gallery creation when using per-directory thumbnail | |
109 ;; storage. | |
110 ;; | |
111 ;; * Some sort of auto-rotate function based on rotate info in the | |
112 ;; EXIF data. | |
113 ;; | |
114 ;; * Check if exiftool exist before trying to call it to give a better | |
115 ;; error message. | |
116 ;; | |
117 ;; * Investigate if it is possible to also write the tags to the image | |
118 ;; files. | |
119 ;; | |
120 ;; * From thumbs.el: Add an option for clean-up/max-size functionality | |
68754
9c1ca2e3695c
Added a few todo items.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68682
diff
changeset
|
121 ;; for thumbnail directory. |
67302 | 122 ;; |
123 ;; * From thumbs.el: Add setroot function. | |
124 ;; | |
68754
9c1ca2e3695c
Added a few todo items.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68682
diff
changeset
|
125 ;; * From thumbs.el: Add image resizing, if useful (tumme's automatic |
9c1ca2e3695c
Added a few todo items.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68682
diff
changeset
|
126 ;; "image fit" might be enough) |
9c1ca2e3695c
Added a few todo items.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68682
diff
changeset
|
127 ;; |
9c1ca2e3695c
Added a few todo items.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68682
diff
changeset
|
128 ;; * From thumbs.el: Add the "modify" commands (emboss, negate, |
9c1ca2e3695c
Added a few todo items.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68682
diff
changeset
|
129 ;; monochrome etc). |
9c1ca2e3695c
Added a few todo items.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68682
diff
changeset
|
130 ;; |
67302 | 131 ;; * Asynchronous creation of thumbnails. |
132 ;; | |
133 ;; * Add `tumme-display-thumbs-ring' and functions to cycle that. Find | |
134 ;; out which is best, saving old batch just before inserting new, or | |
135 ;; saving the current batch in the ring when inserting it. Adding it | |
136 ;; probably needs rewriting `tumme-display-thumbs' to be more general. | |
137 ;; | |
138 ;; * Find some way of toggling on and off really nice keybindings in | |
69284
692ff61f94dc
Changes in whitespace.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68851
diff
changeset
|
139 ;; dired (for example, using C-n or <down> instead of C-S-n). Richard |
67302 | 140 ;; suggested that we could keep C-t as prefix for tumme commands as it |
69284
692ff61f94dc
Changes in whitespace.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68851
diff
changeset
|
141 ;; is currently not used in dired. He also suggested that |
67302 | 142 ;; `dired-next-line' and `dired-previous-line' figure out if tumme is |
143 ;; enabled in the current buffer and, if it is, call | |
144 ;; `tumme-dired-next-line' and `tumme-dired-previous-line', | |
69284
692ff61f94dc
Changes in whitespace.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68851
diff
changeset
|
145 ;; respectively. Update: This is partly done; some bindings have now |
68806
3e96b0954fa1
Enhanced some docstrings. Added todo item about the Thumbnail
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68783
diff
changeset
|
146 ;; been added to dired. |
67302 | 147 ;; |
148 ;; * Enhanced gallery creation with basic CSS-support and pagination | |
149 ;; of tag pages with many pictures. | |
150 ;; | |
151 ;; * Rewrite `tumme-modify-mark-on-thumb-original-file' to be less | |
152 ;; ugly. | |
153 ;; | |
154 ;; * In some way keep track of buffers and windows and stuff so that | |
155 ;; it works as the user expects. | |
156 ;; | |
157 ;; * More/better documentation | |
158 ;; | |
159 ;; | |
160 ;;; Code: | |
161 | |
162 (require 'dired) | |
163 (require 'format-spec) | |
72019
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
164 (require 'widget) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
165 |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
166 (eval-when-compile |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
167 (require 'wid-edit)) |
67302 | 168 |
169 (defgroup tumme nil | |
170 "Use dired to browse your images as thumbnails, and more." | |
171 :prefix "tumme-" | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
172 :group 'multimedia) |
67302 | 173 |
68783
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
174 (defcustom tumme-dir "~/.emacs.d/tumme/" |
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
175 "*Directory where thumbnail images are stored." |
67302 | 176 :type 'string |
177 :group 'tumme) | |
178 | |
179 (defcustom tumme-thumbnail-storage 'use-tumme-dir | |
180 "*How to store tumme's thumbnail files. | |
181 Tumme can store thumbnail files in one of two ways and this is | |
182 controlled by this variable. \"Use tumme dir\" means that the | |
183 thumbnails are stored in a central directory. \"Per directory\" | |
184 means that each thumbnail is stored in a subdirectory called | |
68833
207844891bb3
(tumme-thumbnail-storage): Updated docstring. Added
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68815
diff
changeset
|
185 \".tumme\" in the same directory where the image file is. |
207844891bb3
(tumme-thumbnail-storage): Updated docstring. Added
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68815
diff
changeset
|
186 \"Thumbnail Managing Standard\" means that the thumbnails are |
68851
ef6240377b78
(tumme-thumbnail-storage): Fix docstring.
Juri Linkov <juri@jurta.org>
parents:
68835
diff
changeset
|
187 stored and generated according to the Thumbnail Managing Standard |
ef6240377b78
(tumme-thumbnail-storage): Fix docstring.
Juri Linkov <juri@jurta.org>
parents:
68835
diff
changeset
|
188 that allows sharing of thumbnails across different programs." |
67302 | 189 :type '(choice :tag "How to store thumbnail files" |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
190 (const :tag "Thumbnail Managing Standard" standard) |
67302 | 191 (const :tag "Use tumme-dir" use-tumme-dir) |
192 (const :tag "Per-directory" per-directory)) | |
193 :group 'tumme) | |
194 | |
68783
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
195 (defcustom tumme-db-file "~/.emacs.d/tumme/.tumme_db" |
67302 | 196 "*Database file where file names and their associated tags are stored." |
197 :type 'string | |
198 :group 'tumme) | |
199 | |
68783
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
200 (defcustom tumme-temp-image-file "~/.emacs.d/tumme/.tumme_temp" |
67302 | 201 "*Name of temporary image file used by various commands." |
202 :type 'string | |
203 :group 'tumme) | |
204 | |
68783
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
205 (defcustom tumme-gallery-dir "~/.emacs.d/tumme/.tumme_gallery" |
67302 | 206 "*Directory to store generated gallery html pages. |
207 This path needs to be \"shared\" to the public so that it can access | |
208 the index.html page that tumme creates." | |
209 :type 'string | |
210 :group 'tumme) | |
211 | |
212 (defcustom tumme-gallery-image-root-url | |
213 "http://your.own.server/tummepics" | |
214 "*URL where the full size images are to be found. | |
215 Note that this path has to be configured in your web server. Tumme | |
216 expects to find pictures in this directory." | |
217 :type 'string | |
218 :group 'tumme) | |
219 | |
220 (defcustom tumme-gallery-thumb-image-root-url | |
221 "http://your.own.server/tummethumbs" | |
222 "*URL where the thumbnail images are to be found. | |
223 Note that this path has to be configured in your web server. Tumme | |
224 expects to find pictures in this directory." | |
225 :type 'string | |
226 :group 'tumme) | |
227 | |
228 (defcustom tumme-cmd-create-thumbnail-program | |
229 "convert" | |
230 "*Executable used to create thumbnail. | |
231 Used together with `tumme-cmd-create-thumbnail-options'." | |
232 :type 'string | |
233 :group 'tumme) | |
234 | |
235 (defcustom tumme-cmd-create-thumbnail-options | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
236 "%p -size %wx%h \"%f\" -resize %wx%h +profile \"*\" jpeg:\"%t\"" |
67302 | 237 "*Format of command used to create thumbnail image. |
238 Available options are %p which is replaced by | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
239 `tumme-cmd-create-thumbnail-program', %w which is replaced by |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
240 `tumme-thumb-width', %h which is replaced by `tumme-thumb-height', |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
241 %f which is replaced by the file name of the original image and %t |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
242 which is replaced by the file name of the thumbnail file." |
67302 | 243 :type 'string |
244 :group 'tumme) | |
245 | |
246 (defcustom tumme-cmd-create-temp-image-program | |
247 "convert" | |
248 "*Executable used to create temporary image. | |
249 Used together with `tumme-cmd-create-temp-image-options'." | |
250 :type 'string | |
251 :group 'tumme) | |
252 | |
253 (defcustom tumme-cmd-create-temp-image-options | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
254 "%p -size %wx%h \"%f\" -resize %wx%h +profile \"*\" jpeg:\"%t\"" |
67302 | 255 "*Format of command used to create temporary image for display window. |
256 Available options are %p which is replaced by | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
257 `tumme-cmd-create-temp-image-program', %w and %h which is replaced by |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
258 the calculated max size for width and height in the image display window, |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
259 %f which is replaced by the file name of the original image and %t which |
67302 | 260 is replaced by the file name of the temporary file." |
261 :type 'string | |
262 :group 'tumme) | |
263 | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
264 (defcustom tumme-cmd-pngnq-program (executable-find "pngnq") |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
265 "*The file name of the `pngnq' program. |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
266 It quantizes colors of PNG images down to 256 colors." |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
267 :type '(choice (const :tag "Not Set" nil) string) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
268 :group 'tumme) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
269 |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
270 (defcustom tumme-cmd-pngcrush-program (executable-find "pngcrush") |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
271 "*The file name of the `pngcrush' program. |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
272 It optimizes the compression of PNG images. Also it adds PNG textual chunks |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
273 with the information required by the Thumbnail Managing Standard." |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
274 :type '(choice (const :tag "Not Set" nil) string) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
275 :group 'tumme) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
276 |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
277 (defcustom tumme-cmd-create-standard-thumbnail-command |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
278 (concat |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
279 tumme-cmd-create-thumbnail-program " " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
280 "-size %wx%h \"%f\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
281 (unless (or tumme-cmd-pngcrush-program tumme-cmd-pngnq-program) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
282 (concat |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
283 "-set \"Thumb::MTime\" \"%m\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
284 "-set \"Thumb::URI\" \"file://%f\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
285 "-set \"Description\" \"Thumbnail of file://%f\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
286 "-set \"Software\" \"" (emacs-version) "\" ")) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
287 "-thumbnail %wx%h png:\"%t\"" |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
288 (if tumme-cmd-pngnq-program |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
289 (concat |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
290 " ; " tumme-cmd-pngnq-program " -f \"%t\"" |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
291 (unless tumme-cmd-pngcrush-program |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
292 " ; mv %q %t"))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
293 (if tumme-cmd-pngcrush-program |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
294 (concat |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
295 (unless tumme-cmd-pngcrush-program |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
296 " ; cp %t %q") |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
297 " ; " tumme-cmd-pngcrush-program " -q " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
298 "-text b \"Description\" \"Thumbnail of file://%f\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
299 "-text b \"Software\" \"" (emacs-version) "\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
300 ;; "-text b \"Thumb::Image::Height\" \"%oh\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
301 ;; "-text b \"Thumb::Image::Mimetype\" \"%mime\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
302 ;; "-text b \"Thumb::Image::Width\" \"%ow\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
303 "-text b \"Thumb::MTime\" \"%m\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
304 ;; "-text b \"Thumb::Size\" \"%b\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
305 "-text b \"Thumb::URI\" \"file://%f\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
306 "%q %t" |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
307 " ; rm %q"))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
308 "*Command to create thumbnails according to the Thumbnail Managing Standard." |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
309 :type 'string |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
310 :group 'tumme) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
311 |
67302 | 312 (defcustom tumme-cmd-rotate-thumbnail-program |
313 "mogrify" | |
314 "*Executable used to rotate thumbnail. | |
315 Used together with `tumme-cmd-rotate-thumbnail-options'." | |
316 :type 'string | |
317 :group 'tumme) | |
318 | |
319 (defcustom tumme-cmd-rotate-thumbnail-options | |
320 "%p -rotate %d \"%t\"" | |
321 "*Format of command used to rotate thumbnail image. | |
322 Available options are %p which is replaced by | |
323 `tumme-cmd-rotate-thumbnail-program', %d which is replaced by the | |
324 number of (positive) degrees to rotate the image, normally 90 or 270 | |
325 \(for 90 degrees right and left), %t which is replaced by the file name | |
326 of the thumbnail file." | |
327 :type 'string | |
328 :group 'tumme) | |
329 | |
330 (defcustom tumme-cmd-rotate-original-program | |
331 "jpegtran" | |
332 "*Executable used to rotate original image. | |
333 Used together with `tumme-cmd-rotate-original-options'." | |
334 :type 'string | |
335 :group 'tumme) | |
336 | |
337 (defcustom tumme-cmd-rotate-original-options | |
338 "%p -rotate %d -copy all \"%o\" > %t" | |
339 "*Format of command used to rotate original image. | |
340 Available options are %p which is replaced by | |
341 `tumme-cmd-rotate-original-program', %d which is replaced by the | |
342 number of (positive) degrees to rotate the image, normally 90 or | |
343 270 \(for 90 degrees right and left), %o which is replaced by the | |
344 original image file name and %t which is replaced by | |
68673
5a7d4aa73d2d
(tumme-get-thumbnail-image): Add missing arg to `error'.
Juanma Barranquero <lekktu@gmail.com>
parents:
68658
diff
changeset
|
345 `tumme-temp-image-file'." |
67302 | 346 :type 'string |
347 :group 'tumme) | |
348 | |
349 (defcustom tumme-temp-rotate-image-file | |
68783
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
350 "~/.emacs.d/tumme/.tumme_rotate_temp" |
67302 | 351 "*Temporary file for rotate operations." |
352 :type 'string | |
353 :group 'tumme) | |
354 | |
355 (defcustom tumme-rotate-original-ask-before-overwrite t | |
356 "Confirm overwrite of original file after rotate operation. | |
357 If non-nil, ask user for confirmation before overwriting the | |
358 original file with `tumme-temp-rotate-image-file'." | |
359 :type 'boolean | |
360 :group 'tumme) | |
361 | |
362 (defcustom tumme-cmd-write-exif-data-program | |
363 "exiftool" | |
364 "*Program used to write EXIF data to image. | |
365 Used together with `tumme-cmd-write-exif-data-options'." | |
366 :type 'string | |
367 :group 'tumme) | |
368 | |
369 (defcustom tumme-cmd-write-exif-data-options | |
370 "%p -%t=\"%v\" \"%f\"" | |
371 "*Format of command used to write EXIF data. | |
372 Available options are %p which is replaced by | |
373 `tumme-cmd-write-exif-data-program', %f which is replaced by the | |
374 image file name, %t which is replaced by the tag name and %v | |
375 which is replaced by the tag value." | |
376 :type 'string | |
377 :group 'tumme) | |
378 | |
379 (defcustom tumme-cmd-read-exif-data-program | |
380 "exiftool" | |
381 "*Program used to read EXIF data to image. | |
382 Used together with `tumme-cmd-read-exif-data-program-options'." | |
383 :type 'string | |
384 :group 'tumme) | |
385 | |
386 (defcustom tumme-cmd-read-exif-data-options | |
387 "%p -s -s -s -%t \"%f\"" | |
388 "*Format of command used to read EXIF data. | |
389 Available options are %p which is replaced by | |
390 `tumme-cmd-write-exif-data-options', %f which is replaced | |
391 by the image file name and %t which is replaced by the tag name." | |
392 :type 'string | |
393 :group 'tumme) | |
394 | |
395 (defcustom tumme-gallery-hidden-tags | |
396 (list "private" "hidden" "pending") | |
397 "*List of \"hidden\" tags. | |
398 Used by `tumme-gallery-generate' to leave out \"hidden\" images." | |
399 :type '(repeat string) | |
400 :group 'tumme) | |
401 | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
402 (defcustom tumme-thumb-size (if (eq 'standard tumme-thumbnail-storage) 128 100) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
403 "Size of thumbnails, in pixels. |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
404 This is the default size for both `tumme-thumb-width' and `tumme-thumb-height'." |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
405 :type 'integer |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
406 :group 'tumme) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
407 |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
408 (defcustom tumme-thumb-width tumme-thumb-size |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
409 "Width of thumbnails, in pixels." |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
410 :type 'integer |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
411 :group 'tumme) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
412 |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
413 (defcustom tumme-thumb-height tumme-thumb-size |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
414 "Height of thumbnails, in pixels." |
67302 | 415 :type 'integer |
416 :group 'tumme) | |
417 | |
418 (defcustom tumme-thumb-relief 2 | |
419 "*Size of button-like border around thumbnails." | |
420 :type 'integer | |
421 :group 'tumme) | |
422 | |
423 (defcustom tumme-thumb-margin 2 | |
424 "*Size of the margin around thumbnails. | |
425 This is where you see the cursor." | |
426 :type 'integer | |
427 :group 'tumme) | |
428 | |
429 (defcustom tumme-line-up-method 'dynamic | |
430 "*Default method for line-up of thumbnails in thumbnail buffer. | |
431 Used by `tumme-display-thumbs' and other functions that needs to | |
432 line-up thumbnails. Dynamic means to use the available width of the | |
433 window containing the thumbnail buffer, Fixed means to use | |
434 `tumme-thumbs-per-row', Interactive is for asking the user, and No | |
435 line-up means that no automatic line-up will be done." | |
436 :type '(choice :tag "Default line-up method" | |
437 (const :tag "Dynamic" dynamic) | |
438 (const :tag "Fixed" fixed) | |
439 (const :tag "Interactive" interactive) | |
440 (const :tag "No line-up" none)) | |
441 :group 'tumme) | |
442 | |
443 (defcustom tumme-thumbs-per-row 3 | |
444 "*Number of thumbnails to display per row in thumb buffer." | |
445 :type 'integer | |
446 :group 'tumme) | |
447 | |
448 (defcustom tumme-display-window-width-correction 1 | |
68673
5a7d4aa73d2d
(tumme-get-thumbnail-image): Add missing arg to `error'.
Juanma Barranquero <lekktu@gmail.com>
parents:
68658
diff
changeset
|
449 "*Number to be used to correct image display window width. |
67302 | 450 Change if the default (1) does not work (i.e. if the image does not |
451 completely fit)." | |
452 :type 'integer | |
453 :group 'tumme) | |
454 | |
455 (defcustom tumme-display-window-height-correction 0 | |
456 "*Number to be used to correct image display window height. | |
68673
5a7d4aa73d2d
(tumme-get-thumbnail-image): Add missing arg to `error'.
Juanma Barranquero <lekktu@gmail.com>
parents:
68658
diff
changeset
|
457 Change if the default (0) does not work (i.e. if the image does not |
67302 | 458 completely fit)." |
459 :type 'integer | |
460 :group 'tumme) | |
461 | |
70893
c6ca6d20fb3d
Movement tracking on by default. I have tested this for over a year now and it seems to be stable and fast enough for everyday use.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70891
diff
changeset
|
462 (defcustom tumme-track-movement t |
67302 | 463 "The current state of the tracking and mirroring. |
464 For more information, see the documentation for | |
465 `tumme-toggle-movement-tracking'." | |
466 :type 'boolean | |
467 :group 'tumme) | |
468 | |
469 (defcustom tumme-append-when-browsing nil | |
470 "Append thumbnails in thumbnail buffer when browsing. | |
471 If non-nil, using `tumme-next-line-and-display' and | |
472 `tumme-previous-line-and-display' will leave a trail of thumbnail | |
473 images in the thumbnail buffer. If you enable this and want to clean | |
474 the thumbnail buffer because it is filled with too many thumbmnails, | |
475 just call `tumme-display-thumb' to display only the image at point. | |
476 This value can be toggled using `tumme-toggle-append-browsing'." | |
477 :type 'boolean | |
478 :group 'tumme) | |
479 | |
480 (defcustom tumme-dired-disp-props t | |
481 "If non-nil, display properties for dired file when browsing. | |
482 Used by `tumme-next-line-and-display', | |
483 `tumme-previous-line-and-display' and `tumme-mark-and-display-next'. | |
484 If the database file is large, this can slow down image browsing in | |
485 dired and you might want to turn it off." | |
486 :type 'boolean | |
487 :group 'tumme) | |
488 | |
489 (defcustom tumme-display-properties-format "%b: %f (%t): %c" | |
68673
5a7d4aa73d2d
(tumme-get-thumbnail-image): Add missing arg to `error'.
Juanma Barranquero <lekktu@gmail.com>
parents:
68658
diff
changeset
|
490 "*Display format for thumbnail properties. |
67302 | 491 %b is replaced with associated dired buffer name, %f with file name |
492 \(without path) of original image file, %t with the list of tags and %c | |
493 with the comment." | |
494 :type 'string | |
495 :group 'tumme) | |
496 | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
497 (defcustom tumme-external-viewer |
71780 | 498 ;; TODO: Use mailcap, dired-guess-shell-alist-default, |
499 ;; dired-view-command-alist. | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
500 (cond ((executable-find "display")) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
501 ((executable-find "xli")) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
502 ((executable-find "qiv") "qiv -t")) |
67302 | 503 "*Name of external viewer. |
504 Including parameters. Used when displaying original image from | |
505 `tumme-thumbnail-mode'." | |
506 :type 'string | |
507 :group 'tumme) | |
508 | |
509 (defcustom tumme-main-image-directory "~/pics/" | |
510 "*Name of main image directory, if any. | |
511 Used by `tumme-copy-with-exif-file-name'." | |
512 :type 'string | |
513 :group 'tumme) | |
514 | |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
515 (defcustom tumme-show-all-from-dir-max-files 50 |
71023
613d5f4255bd
(tumme-show-all-from-dir-max-files): Fix typo.
Nick Roberts <nickrob@snap.net.nz>
parents:
71001
diff
changeset
|
516 "*Maximum number of files to show using `tumme-show-all-from-dir'. |
68757
3c76b1d6eff0
Tried to make docstring less `colloquial'...
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68754
diff
changeset
|
517 before warning the user." |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
518 :type 'integer |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
519 :group 'tumme) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
520 |
68783
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
521 (defun tumme-dir () |
70888
b84970723553
Added new parameter to `tumme-display-thumbs' to be used from `tumme-next-line-and-display' and similar commands.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70807
diff
changeset
|
522 "Return the current thumbnails directory (from variable `tumme-dir'). |
68783
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
523 Create the thumbnails directory if it does not exist." |
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
524 (let ((tumme-dir (file-name-as-directory |
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
525 (expand-file-name tumme-dir)))) |
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
526 (unless (file-directory-p tumme-dir) |
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
527 (make-directory tumme-dir t) |
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
528 (message "Creating thumbnails directory")) |
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
529 tumme-dir)) |
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
530 |
67302 | 531 (defun tumme-insert-image (file type relief margin) |
532 "Insert image FILE of image TYPE, using RELIEF and MARGIN, at point." | |
533 | |
534 (let ((i `(image :type ,type | |
535 :file ,file | |
536 :relief ,relief | |
537 :margin ,margin))) | |
538 (insert-image i))) | |
539 | |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
540 (defun tumme-get-thumbnail-image (file) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
541 "Return the image descriptor for a thumbnail of image file FILE." |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
542 (unless (string-match (image-file-name-regexp) file) |
68673
5a7d4aa73d2d
(tumme-get-thumbnail-image): Add missing arg to `error'.
Juanma Barranquero <lekktu@gmail.com>
parents:
68658
diff
changeset
|
543 (error "%s is not a valid image file" file)) |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
544 (let ((thumb-file (tumme-thumb-name file))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
545 (unless (and (file-exists-p thumb-file) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
546 (<= (float-time (nth 5 (file-attributes file))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
547 (float-time (nth 5 (file-attributes thumb-file))))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
548 (tumme-create-thumb file thumb-file)) |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
549 (create-image thumb-file) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
550 ;; (list 'image :type 'jpeg |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
551 ;; :file thumb-file |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
552 ;; :relief tumme-thumb-relief :margin tumme-thumb-margin) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
553 )) |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
554 |
67302 | 555 (defun tumme-insert-thumbnail (file original-file-name |
556 associated-dired-buffer) | |
557 "Insert thumbnail image FILE. | |
558 Add text properties ORIGINAL-FILE-NAME and ASSOCIATED-DIRED-BUFFER." | |
559 (let (beg end) | |
560 (setq beg (point)) | |
561 (tumme-insert-image file | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
562 ;; TODO: this should depend on the real file type |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
563 (if (eq 'standard tumme-thumbnail-storage) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
564 'png 'jpeg) |
67302 | 565 tumme-thumb-relief |
566 tumme-thumb-margin) | |
567 (setq end (point)) | |
568 (add-text-properties | |
569 beg end | |
570 (list 'tumme-thumbnail t | |
571 'original-file-name original-file-name | |
572 'associated-dired-buffer associated-dired-buffer | |
573 'tags (tumme-list-tags original-file-name) | |
574 'mouse-face 'highlight | |
575 'comment (tumme-get-comment original-file-name))))) | |
576 | |
577 (defun tumme-thumb-name (file) | |
578 "Return thumbnail file name for FILE. | |
579 Depending on the value of `tumme-thumbnail-storage', the file | |
580 name will vary. For central thumbnail file storage, make a | |
581 MD5-hash of the image file's directory name and add that to make | |
582 the thumbnail file name unique. For per-directory storage, just | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
583 add a subdirectory. For standard storage, produce the file name |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
584 according to the Thumbnail Managing Standard." |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
585 (cond ((eq 'standard tumme-thumbnail-storage) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
586 (expand-file-name |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
587 (concat "~/.thumbnails/normal/" |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
588 (md5 (concat "file://" (expand-file-name file))) ".png"))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
589 ((eq 'use-tumme-dir tumme-thumbnail-storage) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
590 (let* ((f (expand-file-name file)) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
591 (md5-hash |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
592 ;; Is MD5 hashes fast enough? The checksum of a |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
593 ;; thumbnail file name need not be that |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
594 ;; "cryptographically" good so a faster one could |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
595 ;; be used here. |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
596 (md5 (file-name-as-directory (file-name-directory f))))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
597 (format "%s%s%s.thumb.%s" |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
598 (file-name-as-directory (expand-file-name (tumme-dir))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
599 (file-name-sans-extension (file-name-nondirectory f)) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
600 (if md5-hash (concat "_" md5-hash) "") |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
601 (file-name-extension f)))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
602 ((eq 'per-directory tumme-thumbnail-storage) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
603 (let ((f (expand-file-name file))) |
68851
ef6240377b78
(tumme-thumbnail-storage): Fix docstring.
Juri Linkov <juri@jurta.org>
parents:
68835
diff
changeset
|
604 (format "%s.tumme/%s.thumb.%s" |
ef6240377b78
(tumme-thumbnail-storage): Fix docstring.
Juri Linkov <juri@jurta.org>
parents:
68835
diff
changeset
|
605 (file-name-directory f) |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
606 (file-name-sans-extension (file-name-nondirectory f)) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
607 (file-name-extension f)))))) |
67302 | 608 |
609 (defun tumme-create-thumb (original-file thumbnail-file) | |
610 "For ORIGINAL-FILE, create thumbnail image named THUMBNAIL-FILE." | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
611 (let* ((width (int-to-string tumme-thumb-width)) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
612 (height (int-to-string tumme-thumb-height)) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
613 (modif-time (format "%.0f" (float-time (nth 5 (file-attributes |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
614 original-file))))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
615 (thumbnail-nq8-file (replace-regexp-in-string ".png\\'" "-nq8.png" |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
616 thumbnail-file)) |
67302 | 617 (command |
618 (format-spec | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
619 (if (eq 'standard tumme-thumbnail-storage) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
620 tumme-cmd-create-standard-thumbnail-command |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
621 tumme-cmd-create-thumbnail-options) |
67302 | 622 (list |
623 (cons ?p tumme-cmd-create-thumbnail-program) | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
624 (cons ?w width) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
625 (cons ?h height) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
626 (cons ?m modif-time) |
67302 | 627 (cons ?f original-file) |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
628 (cons ?q thumbnail-nq8-file) |
67302 | 629 (cons ?t thumbnail-file)))) |
630 thumbnail-dir) | |
631 (when (not (file-exists-p | |
632 (setq thumbnail-dir (file-name-directory thumbnail-file)))) | |
633 (message "Creating thumbnail directory.") | |
634 (make-directory thumbnail-dir)) | |
71808 | 635 (call-process shell-file-name nil nil nil shell-command-switch command))) |
67302 | 636 |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
637 ;;;###autoload |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
638 (defun tumme-dired-insert-marked-thumbs () |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
639 "Insert thumbnails before file names of marked files in the dired buffer." |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
640 (interactive) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
641 (dired-map-over-marks |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
642 (let* ((image-pos (dired-move-to-filename)) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
643 (image-file (dired-get-filename)) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
644 (thumb-file (tumme-get-thumbnail-image image-file)) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
645 overlay) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
646 ;; If image is not already added, then add it. |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
647 (unless (delq nil (mapcar (lambda (o) (overlay-get o 'put-image)) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
648 ;; Can't use (overlays-at (point)), BUG? |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
649 (overlays-in (point) (1+ (point))))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
650 (put-image thumb-file image-pos) |
72093
e75e38c3a62f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72091
diff
changeset
|
651 (setq |
71780 | 652 overlay |
653 (car (delq nil (mapcar (lambda (o) (and (overlay-get o 'put-image) o)) | |
654 (overlays-in (point) (1+ (point))))))) | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
655 (overlay-put overlay 'image-file image-file) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
656 (overlay-put overlay 'thumb-file thumb-file))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
657 nil) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
658 (add-hook 'dired-after-readin-hook 'tumme-dired-after-readin-hook nil t)) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
659 |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
660 (defun tumme-dired-after-readin-hook () |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
661 "Relocate existing thumbnail overlays in dired buffer after reverting. |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
662 Move them to their corresponding files if they are still exist. |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
663 Otherwise, delete overlays." |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
664 (mapc (lambda (overlay) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
665 (when (overlay-get overlay 'put-image) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
666 (let* ((image-file (overlay-get overlay 'image-file)) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
667 (image-pos (dired-goto-file image-file))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
668 (if image-pos |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
669 (move-overlay overlay image-pos image-pos) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
670 (delete-overlay overlay))))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
671 (overlays-in (point-min) (point-max)))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
672 |
67302 | 673 (defun tumme-next-line-and-display () |
674 "Move to next dired line and display thumbnail image." | |
675 (interactive) | |
676 (dired-next-line 1) | |
677 (tumme-display-thumbs | |
70888
b84970723553
Added new parameter to `tumme-display-thumbs' to be used from `tumme-next-line-and-display' and similar commands.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70807
diff
changeset
|
678 t (or tumme-append-when-browsing nil) t) |
67302 | 679 (if tumme-dired-disp-props |
680 (tumme-dired-display-properties))) | |
681 | |
682 (defun tumme-previous-line-and-display () | |
683 "Move to previous dired line and display thumbnail image." | |
684 (interactive) | |
685 (dired-previous-line 1) | |
686 (tumme-display-thumbs | |
70888
b84970723553
Added new parameter to `tumme-display-thumbs' to be used from `tumme-next-line-and-display' and similar commands.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70807
diff
changeset
|
687 t (or tumme-append-when-browsing nil) t) |
67302 | 688 (if tumme-dired-disp-props |
689 (tumme-dired-display-properties))) | |
690 | |
691 (defun tumme-toggle-append-browsing () | |
692 "Toggle `tumme-append-when-browsing'." | |
693 (interactive) | |
694 (setq tumme-append-when-browsing | |
695 (not tumme-append-when-browsing)) | |
696 (message "Append browsing %s." | |
697 (if tumme-append-when-browsing | |
698 "on" | |
699 "off"))) | |
700 | |
701 (defun tumme-mark-and-display-next () | |
702 "Mark current file in dired and display next thumbnail image." | |
703 (interactive) | |
704 (dired-mark 1) | |
705 (tumme-display-thumbs | |
70888
b84970723553
Added new parameter to `tumme-display-thumbs' to be used from `tumme-next-line-and-display' and similar commands.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70807
diff
changeset
|
706 t (or tumme-append-when-browsing nil) t) |
67302 | 707 (if tumme-dired-disp-props |
708 (tumme-dired-display-properties))) | |
709 | |
710 (defun tumme-toggle-dired-display-properties () | |
711 "Toggle `tumme-dired-disp-props'." | |
712 (interactive) | |
713 (setq tumme-dired-disp-props | |
714 (not tumme-dired-disp-props)) | |
715 (message "Dired display properties %s." | |
716 (if tumme-dired-disp-props | |
717 "on" | |
718 "off"))) | |
719 | |
720 (defvar tumme-thumbnail-buffer "*tumme*" | |
721 "Tumme's thumbnail buffer.") | |
722 | |
723 (defun tumme-create-thumbnail-buffer () | |
724 "Create thumb buffer and set `tumme-thumbnail-mode'." | |
725 (let ((buf (get-buffer-create tumme-thumbnail-buffer))) | |
71780 | 726 (with-current-buffer buf |
67302 | 727 (setq buffer-read-only t) |
728 (if (not (eq major-mode 'tumme-thumbnail-mode)) | |
729 (tumme-thumbnail-mode))) | |
730 buf)) | |
731 | |
732 (defvar tumme-display-image-buffer "*tumme-display-image*" | |
733 "Where larger versions of the images are display.") | |
734 | |
735 (defun tumme-create-display-image-buffer () | |
736 "Create image display buffer and set `tumme-display-image-mode'." | |
737 (let ((buf (get-buffer-create tumme-display-image-buffer))) | |
71780 | 738 (with-current-buffer buf |
67302 | 739 (setq buffer-read-only t) |
740 (if (not (eq major-mode 'tumme-display-image-mode)) | |
741 (tumme-display-image-mode))) | |
742 buf)) | |
743 | |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
744 (defvar tumme-saved-window-configuration nil |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
745 "Saved window configuration.") |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
746 |
68404 | 747 ;;;###autoload |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
748 (defun tumme-dired-with-window-configuration (dir &optional arg) |
67302 | 749 "Open directory DIR and create a default window configuration. |
750 | |
751 Convenience command that: | |
752 | |
753 - Opens dired in folder DIR | |
754 - Splits windows in most useful (?) way | |
755 - Set `truncate-lines' to t | |
756 | |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
757 After the command has finished, you would typically mark some |
68757
3c76b1d6eff0
Tried to make docstring less `colloquial'...
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68754
diff
changeset
|
758 image files in dired and type |
3c76b1d6eff0
Tried to make docstring less `colloquial'...
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68754
diff
changeset
|
759 \\[tumme-display-thumbs] (`tumme-display-thumbs'). |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
760 |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
761 If called with prefix argument ARG, skip splitting of windows. |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
762 |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
763 The current window configuration is saved and can be restored by |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
764 calling `tumme-restore-window-configuration'." |
67302 | 765 (interactive "DDirectory: \nP") |
766 (let ((buf (tumme-create-thumbnail-buffer)) | |
767 (buf2 (tumme-create-display-image-buffer))) | |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
768 (setq tumme-saved-window-configuration |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
769 (current-window-configuration)) |
67302 | 770 (dired dir) |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
771 (delete-other-windows) |
67302 | 772 (when (not arg) |
773 (split-window-horizontally) | |
774 (setq truncate-lines t) | |
775 (save-excursion | |
776 (other-window 1) | |
777 (switch-to-buffer buf) | |
778 (split-window-vertically) | |
779 (other-window 1) | |
780 (switch-to-buffer buf2) | |
781 (other-window -2))))) | |
782 | |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
783 (defun tumme-restore-window-configuration () |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
784 "Restore window configuration. |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
785 Restore any changes to the window configuration made by calling |
68673
5a7d4aa73d2d
(tumme-get-thumbnail-image): Add missing arg to `error'.
Juanma Barranquero <lekktu@gmail.com>
parents:
68658
diff
changeset
|
786 `tumme-dired-with-window-configuration'." |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
787 (interactive) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
788 (if tumme-saved-window-configuration |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
789 (set-window-configuration tumme-saved-window-configuration) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
790 (message "No saved window configuration"))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
791 |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
792 ;;;###autoload |
70888
b84970723553
Added new parameter to `tumme-display-thumbs' to be used from `tumme-next-line-and-display' and similar commands.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70807
diff
changeset
|
793 (defun tumme-display-thumbs (&optional arg append do-not-pop) |
67302 | 794 "Display thumbnails of all marked files, in `tumme-thumbnail-buffer'. |
795 If a thumbnail image does not exist for a file, it is created on the | |
796 fly. With prefix argument ARG, display only thumbnail for file at | |
797 point (this is useful if you have marked some files but want to show | |
798 another one). | |
799 | |
800 Recommended usage is to split the current frame horizontally so that | |
801 you have the dired buffer in the left window and the | |
802 `tumme-thumbnail-buffer' buffer in the right window. | |
803 | |
804 With optional argument APPEND, append thumbnail to thumbnail buffer | |
70888
b84970723553
Added new parameter to `tumme-display-thumbs' to be used from `tumme-next-line-and-display' and similar commands.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70807
diff
changeset
|
805 instead of erasing it first. |
b84970723553
Added new parameter to `tumme-display-thumbs' to be used from `tumme-next-line-and-display' and similar commands.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70807
diff
changeset
|
806 |
b84970723553
Added new parameter to `tumme-display-thumbs' to be used from `tumme-next-line-and-display' and similar commands.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70807
diff
changeset
|
807 Option argument DO-NOT-POP controls if `pop-to-buffer' should be |
b84970723553
Added new parameter to `tumme-display-thumbs' to be used from `tumme-next-line-and-display' and similar commands.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70807
diff
changeset
|
808 used or not. If non-nil, use `display-buffer' instead of |
b84970723553
Added new parameter to `tumme-display-thumbs' to be used from `tumme-next-line-and-display' and similar commands.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70807
diff
changeset
|
809 `pop-to-buffer'. This is used from functions like |
b84970723553
Added new parameter to `tumme-display-thumbs' to be used from `tumme-next-line-and-display' and similar commands.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70807
diff
changeset
|
810 `tumme-next-line-and-display' and |
b84970723553
Added new parameter to `tumme-display-thumbs' to be used from `tumme-next-line-and-display' and similar commands.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70807
diff
changeset
|
811 `tumme-previous-line-and-display' where we do not want the |
b84970723553
Added new parameter to `tumme-display-thumbs' to be used from `tumme-next-line-and-display' and similar commands.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70807
diff
changeset
|
812 thumbnail buffer to be selected." |
67302 | 813 (interactive "P") |
814 (let ((buf (tumme-create-thumbnail-buffer)) | |
815 curr-file thumb-name files count dired-buf beg) | |
816 (if arg | |
817 (setq files (list (dired-get-filename))) | |
818 (setq files (dired-get-marked-files))) | |
819 (setq dired-buf (current-buffer)) | |
71780 | 820 (with-current-buffer buf |
67302 | 821 (let ((inhibit-read-only t)) |
822 (if (not append) | |
823 (erase-buffer) | |
824 (goto-char (point-max))) | |
825 (mapcar | |
826 (lambda (curr-file) | |
827 (setq thumb-name (tumme-thumb-name curr-file)) | |
828 (if (and (not (file-exists-p thumb-name)) | |
829 (not (= 0 (tumme-create-thumb curr-file thumb-name)))) | |
830 (message "Thumb could not be created for file %s" curr-file) | |
831 (tumme-insert-thumbnail thumb-name curr-file dired-buf))) | |
832 files)) | |
833 (cond ((eq 'dynamic tumme-line-up-method) | |
834 (tumme-line-up-dynamic)) | |
835 ((eq 'fixed tumme-line-up-method) | |
836 (tumme-line-up)) | |
837 ((eq 'interactive tumme-line-up-method) | |
838 (tumme-line-up-interactive)) | |
839 ((eq 'none tumme-line-up-method) | |
840 nil) | |
841 (t | |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
842 (tumme-line-up-dynamic)))) |
70888
b84970723553
Added new parameter to `tumme-display-thumbs' to be used from `tumme-next-line-and-display' and similar commands.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70807
diff
changeset
|
843 (if do-not-pop |
b84970723553
Added new parameter to `tumme-display-thumbs' to be used from `tumme-next-line-and-display' and similar commands.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70807
diff
changeset
|
844 (display-buffer tumme-thumbnail-buffer) |
b84970723553
Added new parameter to `tumme-display-thumbs' to be used from `tumme-next-line-and-display' and similar commands.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70807
diff
changeset
|
845 (pop-to-buffer tumme-thumbnail-buffer)))) |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
846 |
71023
613d5f4255bd
(tumme-show-all-from-dir-max-files): Fix typo.
Nick Roberts <nickrob@snap.net.nz>
parents:
71001
diff
changeset
|
847 ;;;###autoload |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
848 (defun tumme-show-all-from-dir (dir) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
849 "Make a preview buffer for all images in DIR and display it. |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
850 If the number of files in DIR matching `image-file-name-regexp' |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
851 exceeds `tumme-show-all-from-dir-max-files', a warning will be |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
852 displayed." |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
853 (interactive "DDir: ") |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
854 (dired dir) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
855 (dired-mark-files-regexp (image-file-name-regexp)) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
856 (let ((files (dired-get-marked-files))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
857 (if (or (<= (length files) tumme-show-all-from-dir-max-files) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
858 (and (> (length files) tumme-show-all-from-dir-max-files) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
859 (y-or-n-p |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
860 (format |
68757
3c76b1d6eff0
Tried to make docstring less `colloquial'...
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68754
diff
changeset
|
861 "Directory contains more than %d image files. Proceed? " |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
862 tumme-show-all-from-dir-max-files)))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
863 (progn |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
864 (tumme-display-thumbs) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
865 (pop-to-buffer tumme-thumbnail-buffer)) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
866 (message "Cancelled.")))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
867 |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
868 ;;;###autoload |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
869 (defalias 'tumme 'tumme-show-all-from-dir) |
67302 | 870 |
72085
eeafd2670b7f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72083
diff
changeset
|
871 (defun tumme-write-tags (file-tags) |
eeafd2670b7f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72083
diff
changeset
|
872 "Write file tags to database. |
eeafd2670b7f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72083
diff
changeset
|
873 Write each file and tag in FILE-TAGS to the database. FILE-TAGS |
eeafd2670b7f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72083
diff
changeset
|
874 is an alist in the following form: |
eeafd2670b7f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72083
diff
changeset
|
875 ((FILE . TAG) ... )" |
eeafd2670b7f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72083
diff
changeset
|
876 (let (end file tag) |
eeafd2670b7f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72083
diff
changeset
|
877 (with-temp-file tumme-db-file |
eeafd2670b7f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72083
diff
changeset
|
878 (insert-file-contents tumme-db-file) |
eeafd2670b7f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72083
diff
changeset
|
879 (dolist (elt file-tags) |
eeafd2670b7f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72083
diff
changeset
|
880 (setq file (car elt) |
eeafd2670b7f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72083
diff
changeset
|
881 tag (cdr elt)) |
eeafd2670b7f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72083
diff
changeset
|
882 (goto-char (point-min)) |
eeafd2670b7f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72083
diff
changeset
|
883 (if (search-forward-regexp (format "^%s.*$" file) nil t) |
eeafd2670b7f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72083
diff
changeset
|
884 (progn |
eeafd2670b7f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72083
diff
changeset
|
885 (setq end (point)) |
eeafd2670b7f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72083
diff
changeset
|
886 (beginning-of-line) |
eeafd2670b7f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72083
diff
changeset
|
887 (when (not (search-forward (format ";%s" tag) end t)) |
eeafd2670b7f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72083
diff
changeset
|
888 (end-of-line) |
eeafd2670b7f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72083
diff
changeset
|
889 (insert (format ";%s" tag)))) |
eeafd2670b7f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72083
diff
changeset
|
890 (goto-char (point-max)) |
eeafd2670b7f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72083
diff
changeset
|
891 (insert (format "\n%s;%s" file tag))))))) |
eeafd2670b7f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72083
diff
changeset
|
892 |
67302 | 893 (defun tumme-remove-tag (files tag) |
894 "For all FILES, remove TAG from the image database." | |
895 (save-excursion | |
896 (let (end buf start) | |
897 (setq buf (find-file tumme-db-file)) | |
898 (if (not (listp files)) | |
899 (if (stringp files) | |
900 (setq files (list files)) | |
901 (error "Files must be a string or a list of strings!"))) | |
902 (mapcar | |
903 (lambda (file) | |
904 (goto-char (point-min)) | |
70996
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
905 (when (search-forward-regexp |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
906 (format "^%s" file) nil t) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
907 (end-of-line) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
908 (setq end (point)) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
909 (beginning-of-line) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
910 (when (search-forward-regexp (format "\\(;%s\\)" tag) end t) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
911 (delete-region (match-beginning 1) (match-end 1)) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
912 ;; Check if file should still be in the database. If |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
913 ;; it has no tags or comments, it will be removed. |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
914 (end-of-line) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
915 (setq end (point)) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
916 (beginning-of-line) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
917 (when (not (search-forward ";" end t)) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
918 (kill-line 1) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
919 ;; If on empty line at end of buffer |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
920 (when (and (eobp) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
921 (looking-at "^$")) |
71001
95bd5a8f89a3
Change a lot of `(if .. (progn ..)' to `(when ..)'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70996
diff
changeset
|
922 (delete-backward-char 1)))))) |
95bd5a8f89a3
Change a lot of `(if .. (progn ..)' to `(when ..)'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70996
diff
changeset
|
923 files) |
95bd5a8f89a3
Change a lot of `(if .. (progn ..)' to `(when ..)'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70996
diff
changeset
|
924 (save-buffer) |
95bd5a8f89a3
Change a lot of `(if .. (progn ..)' to `(when ..)'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70996
diff
changeset
|
925 (kill-buffer buf)))) |
67302 | 926 |
927 (defun tumme-list-tags (file) | |
928 "Read all tags for image FILE from the image database." | |
929 (save-excursion | |
930 (let (end buf (tags "")) | |
931 (setq buf (find-file tumme-db-file)) | |
932 (goto-char (point-min)) | |
70996
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
933 (when (search-forward-regexp |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
934 (format "^%s" file) nil t) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
935 (end-of-line) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
936 (setq end (point)) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
937 (beginning-of-line) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
938 (if (search-forward ";" end t) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
939 (if (search-forward "comment:" end t) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
940 (if (search-forward ";" end t) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
941 (setq tags (buffer-substring (point) end))) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
942 (setq tags (buffer-substring (point) end))))) |
67302 | 943 (kill-buffer buf) |
944 (split-string tags ";")))) | |
945 | |
68682
23eaa0d773ea
Added more autoload cookies.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68675
diff
changeset
|
946 ;;;###autoload |
67302 | 947 (defun tumme-tag-files (arg) |
948 "Tag marked file(s) in dired. With prefix ARG, tag file at point." | |
949 (interactive "P") | |
70807
ce0e66acbc05
Added information to the add-tags prompt.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
69284
diff
changeset
|
950 (let ((tag (read-string "Tags to add (separate tags with a semicolon): ")) |
67302 | 951 curr-file files) |
952 (if arg | |
72089
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
953 (setq files (list (dired-get-filename))) |
67302 | 954 (setq files (dired-get-marked-files))) |
72089
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
955 (tumme-write-tags |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
956 (mapcar |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
957 (lambda (x) |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
958 (cons x tag)) |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
959 files)))) |
67302 | 960 |
961 (defun tumme-tag-thumbnail () | |
962 "Tag current thumbnail." | |
963 (interactive) | |
70807
ce0e66acbc05
Added information to the add-tags prompt.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
69284
diff
changeset
|
964 (let ((tag (read-string "Tags to add (separate tags with a semicolon): "))) |
72089
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
965 (tumme-write-tags (list (cons (tumme-original-file-name) tag)))) |
67302 | 966 (tumme-update-property |
967 'tags (tumme-list-tags (tumme-original-file-name)))) | |
968 | |
68682
23eaa0d773ea
Added more autoload cookies.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68675
diff
changeset
|
969 ;;;###autoload |
70982
9200b8713856
(tumme-delete-tag): Rename from `tumme-tag-remove'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70916
diff
changeset
|
970 (defun tumme-delete-tag (arg) |
67302 | 971 "Remove tag for selected file(s). |
972 With prefix argument ARG, remove tag from file at point." | |
973 (interactive "P") | |
974 (let ((tag (read-string "Tag to remove: ")) | |
975 files) | |
976 (if arg | |
977 (setq files (list (dired-get-filename))) | |
978 (setq files (dired-get-marked-files))) | |
979 (tumme-remove-tag files tag))) | |
980 | |
981 (defun tumme-tag-thumbnail-remove () | |
982 "Remove tag from thumbnail." | |
983 (interactive) | |
984 (let ((tag (read-string "Tag to remove: "))) | |
985 (tumme-remove-tag (tumme-original-file-name) tag)) | |
986 (tumme-update-property | |
987 'tags (tumme-list-tags (tumme-original-file-name)))) | |
988 | |
989 (defun tumme-original-file-name () | |
990 "Get original file name for thumbnail or display image at point." | |
991 (get-text-property (point) 'original-file-name)) | |
992 | |
993 (defun tumme-associated-dired-buffer () | |
994 "Get associated dired buffer at point." | |
995 (get-text-property (point) 'associated-dired-buffer)) | |
996 | |
997 (defun tumme-get-buffer-window (buf) | |
998 "Return window where buffer BUF is." | |
999 (get-window-with-predicate | |
1000 (lambda (window) | |
1001 (equal (window-buffer window) buf)) | |
1002 nil t)) | |
1003 | |
1004 (defun tumme-track-original-file () | |
1005 "Track the original file in the associated dired buffer. | |
1006 See documentation for `tumme-toggle-movement-tracking'. Interactive | |
1007 use only useful if `tumme-track-movement' is nil." | |
1008 (interactive) | |
1009 (let ((old-buf (current-buffer)) | |
1010 (dired-buf (tumme-associated-dired-buffer)) | |
1011 (file-name (tumme-original-file-name))) | |
72119
c57307165d5e
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72093
diff
changeset
|
1012 (when (and (buffer-live-p dired-buf) file-name) |
70996
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1013 (setq file-name (file-name-nondirectory file-name)) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1014 (set-buffer dired-buf) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1015 (goto-char (point-min)) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1016 (if (not (search-forward file-name nil t)) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1017 (message "Could not track file") |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1018 (dired-move-to-filename) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1019 (set-window-point |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1020 (tumme-get-buffer-window dired-buf) (point))) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1021 (set-buffer old-buf)))) |
67302 | 1022 |
1023 (defun tumme-toggle-movement-tracking () | |
1024 "Turn on and off `tumme-track-movement'. | |
1025 Tracking of the movements between thumbnail and dired buffer so that | |
1026 they are \"mirrored\" in the dired buffer. When this is on, moving | |
1027 around in the thumbnail or dired buffer will find the matching | |
1028 position in the other buffer." | |
1029 (interactive) | |
1030 (setq tumme-track-movement (not tumme-track-movement)) | |
1031 (message "Tracking %s" (if tumme-track-movement "on" "off"))) | |
1032 | |
1033 (defun tumme-track-thumbnail () | |
1034 "Track current dired file's thumb in `tumme-thumbnail-buffer'. | |
1035 This is almost the same as what `tumme-track-original-file' does, but | |
1036 the other way around." | |
1037 (let ((file (dired-get-filename)) | |
1038 (old-buf (current-buffer)) | |
1039 prop-val found) | |
70996
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1040 (when (get-buffer tumme-thumbnail-buffer) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1041 (set-buffer tumme-thumbnail-buffer) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1042 (goto-char (point-min)) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1043 (while (and (not (eobp)) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1044 (not found)) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1045 (if (and (setq prop-val |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1046 (get-text-property (point) 'original-file-name)) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1047 (string= prop-val file)) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1048 (setq found t)) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1049 (if (not found) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1050 (forward-char 1))) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1051 (when found |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1052 (set-window-point |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1053 (tumme-thumbnail-window) (point)) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1054 (tumme-display-thumb-properties)) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1055 (set-buffer old-buf)))) |
67302 | 1056 |
1057 (defun tumme-dired-next-line (&optional arg) | |
1058 "Call `dired-next-line', then track thumbnail. | |
1059 This can safely replace `dired-next-line'. With prefix argument, move | |
1060 ARG lines." | |
1061 (interactive "P") | |
1062 (dired-next-line (or arg 1)) | |
1063 (if tumme-track-movement | |
1064 (tumme-track-thumbnail))) | |
1065 | |
1066 (defun tumme-dired-previous-line (&optional arg) | |
1067 "Call `dired-previous-line', then track thumbnail. | |
1068 This can safely replace `dired-previous-line'. With prefix argument, | |
1069 move ARG lines." | |
1070 (interactive "P") | |
1071 (dired-previous-line (or arg 1)) | |
1072 (if tumme-track-movement | |
1073 (tumme-track-thumbnail))) | |
1074 | |
72124
46e335881cbf
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72121
diff
changeset
|
1075 (defun tumme-forward-image () |
67302 | 1076 "Move to next image and display properties." |
1077 (interactive) | |
1078 ;; Before we move, make sure that there is an image two positions | |
1079 ;; forward. | |
70996
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1080 (when (save-excursion |
67302 | 1081 (forward-char 2) |
1082 (tumme-image-at-point-p)) | |
70996
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1083 (forward-char) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1084 (while (and (not (eobp)) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1085 (not (tumme-image-at-point-p))) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1086 (forward-char)) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1087 (if tumme-track-movement |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1088 (tumme-track-original-file))) |
67302 | 1089 (tumme-display-thumb-properties)) |
1090 | |
72124
46e335881cbf
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72121
diff
changeset
|
1091 (defun tumme-backward-image () |
67302 | 1092 "Move to previous image and display properties." |
1093 (interactive) | |
70996
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1094 (when (not (bobp)) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1095 (backward-char) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1096 (while (and (not (bobp)) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1097 (not (tumme-image-at-point-p))) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1098 (backward-char)) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1099 (if tumme-track-movement |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1100 (tumme-track-original-file))) |
67302 | 1101 (tumme-display-thumb-properties)) |
1102 | |
1103 (defun tumme-next-line () | |
1104 "Move to next line and display properties." | |
1105 (interactive) | |
1106 (next-line 1) | |
1107 ;; If we end up in an empty spot, back up to the next thumbnail. | |
1108 (if (not (tumme-image-at-point-p)) | |
72124
46e335881cbf
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72121
diff
changeset
|
1109 (tumme-backward-image)) |
67302 | 1110 (if tumme-track-movement |
1111 (tumme-track-original-file)) | |
1112 (tumme-display-thumb-properties)) | |
1113 | |
1114 | |
1115 (defun tumme-previous-line () | |
1116 "Move to previous line and display properties." | |
1117 (interactive) | |
1118 (previous-line 1) | |
1119 ;; If we end up in an empty spot, back up to the next | |
1120 ;; thumbnail. This should only happen if the user deleted a | |
1121 ;; thumbnail and did not refresh, so it is not very common. But we | |
1122 ;; can handle it in a good manner, so why not? | |
1123 (if (not (tumme-image-at-point-p)) | |
72124
46e335881cbf
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72121
diff
changeset
|
1124 (tumme-backward-image)) |
67302 | 1125 (if tumme-track-movement |
1126 (tumme-track-original-file)) | |
1127 (tumme-display-thumb-properties)) | |
1128 | |
1129 (defun tumme-format-properties-string (buf file props comment) | |
1130 "Format display properties. | |
1131 BUF is the associated dired buffer, FILE is the original image file | |
68673
5a7d4aa73d2d
(tumme-get-thumbnail-image): Add missing arg to `error'.
Juanma Barranquero <lekktu@gmail.com>
parents:
68658
diff
changeset
|
1132 name, PROPS is a list of tags and COMMENT is the image files's |
67302 | 1133 comment." |
1134 (format-spec | |
1135 tumme-display-properties-format | |
1136 (list | |
72119
c57307165d5e
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72093
diff
changeset
|
1137 (cons ?b (or buf "")) |
67302 | 1138 (cons ?f file) |
1139 (cons ?t (or (princ props) "")) | |
1140 (cons ?c (or comment ""))))) | |
1141 | |
1142 (defun tumme-display-thumb-properties () | |
1143 "Display thumbnail properties in the echo area." | |
1144 (if (not (eobp)) | |
1145 (let ((file-name (file-name-nondirectory (tumme-original-file-name))) | |
1146 (dired-buf (buffer-name (tumme-associated-dired-buffer))) | |
1147 (props (mapconcat | |
1148 'princ | |
1149 (get-text-property (point) 'tags) | |
1150 ", ")) | |
1151 (comment (get-text-property (point) 'comment))) | |
1152 (if file-name | |
1153 (message | |
1154 (tumme-format-properties-string | |
1155 dired-buf | |
1156 file-name | |
1157 props | |
1158 comment)))))) | |
1159 | |
1160 (defun tumme-dired-file-marked-p () | |
1161 "Check whether file on current line is marked or not." | |
1162 (save-excursion | |
1163 (beginning-of-line) | |
1164 (not (looking-at "^ .*$")))) | |
1165 | |
1166 (defun tumme-modify-mark-on-thumb-original-file (command) | |
1167 "Modify mark in dired buffer. | |
1168 This is quite ugly but I don't know how to implemented in a better | |
1169 way. COMMAND is one of 'mark for marking file in dired, 'unmark for | |
1170 unmarking file in dired or 'flag for flagging file for delete in | |
1171 dired." | |
1172 (let ((file-name (tumme-original-file-name)) | |
1173 (dired-buf (tumme-associated-dired-buffer))) | |
1174 (if (not (and dired-buf file-name)) | |
1175 (message "No image, or image with correct properties, at point.") | |
71780 | 1176 (with-current-buffer dired-buf |
67302 | 1177 (message file-name) |
1178 (setq file-name (file-name-nondirectory file-name)) | |
1179 (goto-char (point-min)) | |
1180 (if (search-forward file-name nil t) | |
1181 (cond ((eq command 'mark) (dired-mark 1)) | |
1182 ((eq command 'unmark) (dired-unmark 1)) | |
1183 ((eq command 'toggle) | |
1184 (if (tumme-dired-file-marked-p) | |
1185 (dired-unmark 1) | |
1186 (dired-mark 1))) | |
1187 ((eq command 'flag) (dired-flag-file-deletion 1)))))))) | |
1188 | |
1189 (defun tumme-mark-thumb-original-file () | |
1190 "Mark original image file in associated dired buffer." | |
1191 (interactive) | |
1192 (tumme-modify-mark-on-thumb-original-file 'mark) | |
72124
46e335881cbf
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72121
diff
changeset
|
1193 (tumme-forward-image)) |
67302 | 1194 |
1195 (defun tumme-unmark-thumb-original-file () | |
1196 "Unmark original image file in associated dired buffer." | |
1197 (interactive) | |
1198 (tumme-modify-mark-on-thumb-original-file 'unmark) | |
72124
46e335881cbf
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72121
diff
changeset
|
1199 (tumme-forward-image)) |
67302 | 1200 |
1201 (defun tumme-flag-thumb-original-file () | |
1202 "Flag original image file for deletion in associated dired buffer." | |
1203 (interactive) | |
1204 (tumme-modify-mark-on-thumb-original-file 'flag) | |
72124
46e335881cbf
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72121
diff
changeset
|
1205 (tumme-forward-image)) |
67302 | 1206 |
1207 (defun tumme-toggle-mark-thumb-original-file () | |
1208 "Toggle mark on original image file in associated dired buffer." | |
1209 (interactive) | |
1210 (tumme-modify-mark-on-thumb-original-file 'toggle)) | |
1211 | |
1212 (defun tumme-jump-original-dired-buffer () | |
1213 "Jump to the dired buffer associated with the current image file. | |
1214 You probably want to use this together with | |
1215 `tumme-track-original-file'." | |
1216 (interactive) | |
1217 (let ((buf (tumme-associated-dired-buffer)) | |
1218 window frame) | |
1219 (setq window (tumme-get-buffer-window buf)) | |
1220 (if window | |
1221 (progn | |
1222 (if (not (equal (selected-frame) (setq frame (window-frame window)))) | |
1223 (select-frame-set-input-focus frame)) | |
1224 (select-window window)) | |
1225 (message "Associated dired buffer not visible")))) | |
1226 | |
68682
23eaa0d773ea
Added more autoload cookies.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68675
diff
changeset
|
1227 ;;;###autoload |
67302 | 1228 (defun tumme-jump-thumbnail-buffer () |
1229 "Jump to thumbnail buffer." | |
1230 (interactive) | |
1231 (let ((window (tumme-thumbnail-window)) | |
1232 frame) | |
1233 (if window | |
1234 (progn | |
1235 (if (not (equal (selected-frame) (setq frame (window-frame window)))) | |
1236 (select-frame-set-input-focus frame)) | |
1237 (select-window window)) | |
1238 (message "Thumbnail buffer not visible")))) | |
1239 | |
1240 (defvar tumme-thumbnail-mode-map (make-sparse-keymap) | |
1241 "Keymap for `tumme-thumbnail-mode'.") | |
1242 | |
1243 (defvar tumme-thumbnail-mode-line-up-map (make-sparse-keymap) | |
1244 "Keymap for line-up commands in `tumme-thumbnail-mode'.") | |
1245 | |
1246 (defvar tumme-thumbnail-mode-tag-map (make-sparse-keymap) | |
1247 "Keymap for tag commands in `tumme-thumbnail-mode'.") | |
1248 | |
1249 (defun tumme-define-thumbnail-mode-keymap () | |
1250 "Define keymap for `tumme-thumbnail-mode'." | |
1251 | |
1252 ;; Keys | |
72124
46e335881cbf
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72121
diff
changeset
|
1253 (define-key tumme-thumbnail-mode-map [right] 'tumme-forward-image) |
46e335881cbf
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72121
diff
changeset
|
1254 (define-key tumme-thumbnail-mode-map [left] 'tumme-backward-image) |
67302 | 1255 (define-key tumme-thumbnail-mode-map [up] 'tumme-previous-line) |
1256 (define-key tumme-thumbnail-mode-map [down] 'tumme-next-line) | |
72124
46e335881cbf
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72121
diff
changeset
|
1257 (define-key tumme-thumbnail-mode-map "\C-f" 'tumme-forward-image) |
46e335881cbf
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72121
diff
changeset
|
1258 (define-key tumme-thumbnail-mode-map "\C-b" 'tumme-backward-image) |
67302 | 1259 (define-key tumme-thumbnail-mode-map "\C-p" 'tumme-previous-line) |
1260 (define-key tumme-thumbnail-mode-map "\C-n" 'tumme-next-line) | |
1261 | |
1262 (define-key tumme-thumbnail-mode-map "d" 'tumme-flag-thumb-original-file) | |
1263 (define-key tumme-thumbnail-mode-map [delete] | |
1264 'tumme-flag-thumb-original-file) | |
1265 (define-key tumme-thumbnail-mode-map "m" 'tumme-mark-thumb-original-file) | |
1266 (define-key tumme-thumbnail-mode-map "u" 'tumme-unmark-thumb-original-file) | |
1267 (define-key tumme-thumbnail-mode-map "." 'tumme-track-original-file) | |
1268 (define-key tumme-thumbnail-mode-map [tab] 'tumme-jump-original-dired-buffer) | |
1269 | |
1270 ;; add line-up map | |
1271 (define-key tumme-thumbnail-mode-map "g" tumme-thumbnail-mode-line-up-map) | |
1272 | |
1273 ;; map it to "g" so that the user can press it more quickly | |
1274 (define-key tumme-thumbnail-mode-line-up-map "g" 'tumme-line-up-dynamic) | |
1275 ;; "f" for "fixed" number of thumbs per row | |
1276 (define-key tumme-thumbnail-mode-line-up-map "f" 'tumme-line-up) | |
1277 ;; "i" for "interactive" | |
1278 (define-key tumme-thumbnail-mode-line-up-map "i" 'tumme-line-up-interactive) | |
1279 | |
1280 ;; add tag map | |
1281 (define-key tumme-thumbnail-mode-map "t" tumme-thumbnail-mode-tag-map) | |
1282 | |
1283 ;; map it to "t" so that the user can press it more quickly | |
1284 (define-key tumme-thumbnail-mode-tag-map "t" 'tumme-tag-thumbnail) | |
1285 ;; "r" for "remove" | |
1286 (define-key tumme-thumbnail-mode-tag-map "r" 'tumme-tag-thumbnail-remove) | |
1287 | |
1288 (define-key tumme-thumbnail-mode-map "\C-m" | |
1289 'tumme-display-thumbnail-original-image) | |
1290 (define-key tumme-thumbnail-mode-map [C-return] | |
1291 'tumme-thumbnail-display-external) | |
1292 | |
1293 (define-key tumme-thumbnail-mode-map "l" 'tumme-rotate-thumbnail-left) | |
1294 (define-key tumme-thumbnail-mode-map "r" 'tumme-rotate-thumbnail-right) | |
1295 | |
1296 (define-key tumme-thumbnail-mode-map "L" 'tumme-rotate-original-left) | |
1297 (define-key tumme-thumbnail-mode-map "R" 'tumme-rotate-original-right) | |
1298 | |
71780 | 1299 (define-key tumme-thumbnail-mode-map "D" |
1300 'tumme-thumbnail-set-image-description) | |
67302 | 1301 |
1302 (define-key tumme-thumbnail-mode-map "\C-d" 'tumme-delete-char) | |
1303 (define-key tumme-thumbnail-mode-map " " | |
1304 'tumme-display-next-thumbnail-original) | |
1305 (define-key tumme-thumbnail-mode-map | |
1306 (kbd "DEL") 'tumme-display-previous-thumbnail-original) | |
1307 (define-key tumme-thumbnail-mode-map "c" 'tumme-comment-thumbnail) | |
1308 (define-key tumme-thumbnail-mode-map "q" 'tumme-kill-buffer-and-window) | |
1309 | |
1310 ;; Mouse | |
1311 (define-key tumme-thumbnail-mode-map [mouse-2] 'tumme-mouse-display-image) | |
1312 (define-key tumme-thumbnail-mode-map [mouse-1] 'tumme-mouse-select-thumbnail) | |
1313 | |
1314 ;; Seems I must first set C-down-mouse-1 to undefined, or else it | |
1315 ;; will trigger the buffer menu. If I try to instead bind | |
1316 ;; C-down-mouse-1 to `tumme-mouse-toggle-mark', I get a message | |
1317 ;; about C-mouse-1 not being defined afterwards. Annoying, but I | |
1318 ;; probably do not completely understand mouse events. | |
1319 | |
1320 (define-key tumme-thumbnail-mode-map [C-down-mouse-1] 'undefined) | |
1321 (define-key tumme-thumbnail-mode-map [C-mouse-1] 'tumme-mouse-toggle-mark) | |
1322 | |
1323 ;; Menu | |
1324 (define-key tumme-thumbnail-mode-map [menu-bar tumme] | |
1325 (cons "Tumme" (make-sparse-keymap "Tumme"))) | |
1326 | |
1327 (define-key tumme-thumbnail-mode-map | |
1328 [menu-bar tumme tumme-kill-buffer-and-window] | |
1329 '("Quit" . tumme-kill-buffer-and-window)) | |
1330 | |
1331 (define-key tumme-thumbnail-mode-map | |
1332 [menu-bar tumme tumme-delete-char] | |
1333 '("Delete thumbnail from buffer" . tumme-delete-char)) | |
1334 | |
1335 (define-key tumme-thumbnail-mode-map | |
1336 [menu-bar tumme tumme-tag-thumbnail-remove] | |
1337 '("Remove tag from thumbnail" . tumme-tag-thumbnail-remove)) | |
1338 | |
1339 (define-key tumme-thumbnail-mode-map | |
1340 [menu-bar tumme tumme-tag-thumbnail] | |
1341 '("Tag thumbnail" . tumme-tag-thumbnail)) | |
1342 | |
1343 (define-key tumme-thumbnail-mode-map | |
1344 [menu-bar tumme tumme-comment-thumbnail] | |
1345 '("Comment thumbnail" . tumme-comment-thumbnail)) | |
1346 | |
1347 (define-key tumme-thumbnail-mode-map | |
1348 [menu-bar tumme tumme-refresh-thumb] | |
1349 '("Refresh thumb" . tumme-refresh-thumb)) | |
1350 (define-key tumme-thumbnail-mode-map | |
1351 [menu-bar tumme tumme-line-up-dynamic] | |
1352 '("Dynamic line up" . tumme-line-up-dynamic)) | |
1353 (define-key tumme-thumbnail-mode-map | |
1354 [menu-bar tumme tumme-line-up] | |
1355 '("Line up thumbnails" . tumme-line-up)) | |
1356 | |
1357 (define-key tumme-thumbnail-mode-map | |
1358 [menu-bar tumme tumme-rotate-thumbnail-left] | |
1359 '("Rotate thumbnail left" . tumme-rotate-thumbnail-left)) | |
1360 (define-key tumme-thumbnail-mode-map | |
1361 [menu-bar tumme tumme-rotate-thumbnail-right] | |
1362 '("Rotate thumbnail right" . tumme-rotate-thumbnail-right)) | |
1363 | |
1364 (define-key tumme-thumbnail-mode-map | |
1365 [menu-bar tumme tumme-rotate-original-left] | |
1366 '("Rotate original left" . tumme-rotate-original-left)) | |
1367 (define-key tumme-thumbnail-mode-map | |
1368 [menu-bar tumme tumme-rotate-original-right] | |
1369 '("Rotate original right" . tumme-rotate-original-right)) | |
1370 | |
1371 (define-key tumme-thumbnail-mode-map | |
1372 [menu-bar tumme tumme-toggle-movement-tracking] | |
1373 '("Toggle movement tracking on/off" . tumme-toggle-movement-tracking)) | |
1374 | |
1375 (define-key tumme-thumbnail-mode-map | |
1376 [menu-bar tumme tumme-jump-original-dired-buffer] | |
1377 '("Jump to dired buffer" . tumme-jump-original-dired-buffer)) | |
1378 (define-key tumme-thumbnail-mode-map | |
1379 [menu-bar tumme tumme-track-original-file] | |
1380 '("Track original" . tumme-track-original-file)) | |
1381 | |
1382 (define-key tumme-thumbnail-mode-map | |
1383 [menu-bar tumme tumme-flag-thumb-original-file] | |
1384 '("Flag original for deletion" . tumme-flag-thumb-original-file)) | |
1385 (define-key tumme-thumbnail-mode-map | |
1386 [menu-bar tumme tumme-unmark-thumb-original-file] | |
1387 '("Unmark original" . tumme-unmark-thumb-original-file)) | |
1388 (define-key tumme-thumbnail-mode-map | |
1389 [menu-bar tumme tumme-mark-thumb-original-file] | |
1390 '("Mark original" . tumme-mark-thumb-original-file)) | |
1391 | |
1392 (define-key tumme-thumbnail-mode-map | |
1393 [menu-bar tumme tumme-thumbnail-display-external] | |
1394 '("Display in external viewer" . tumme-thumbnail-display-external)) | |
1395 (define-key tumme-thumbnail-mode-map | |
1396 [menu-bar tumme tumme-display-thumbnail-original-image] | |
1397 '("Display image" . tumme-display-thumbnail-original-image))) | |
1398 | |
1399 (defvar tumme-display-image-mode-map (make-sparse-keymap) | |
1400 "Keymap for `tumme-display-image-mode'.") | |
1401 | |
1402 (defun tumme-define-display-image-mode-keymap () | |
1403 "Define keymap for `tumme-display-image-mode'." | |
1404 | |
1405 ;; Keys | |
1406 (define-key tumme-display-image-mode-map "q" 'tumme-kill-buffer-and-window) | |
1407 | |
1408 (define-key tumme-display-image-mode-map "f" | |
1409 'tumme-display-current-image-full) | |
1410 | |
1411 (define-key tumme-display-image-mode-map "s" | |
1412 'tumme-display-current-image-sized) | |
1413 | |
1414 ;; Menu | |
1415 (define-key tumme-display-image-mode-map [menu-bar tumme] | |
1416 (cons "Tumme" (make-sparse-keymap "Tumme"))) | |
1417 | |
1418 (define-key tumme-display-image-mode-map | |
1419 [menu-bar tumme tumme-kill-buffer-and-window] | |
1420 '("Quit" . tumme-kill-buffer-and-window)) | |
1421 | |
1422 (define-key tumme-display-image-mode-map | |
1423 [menu-bar tumme tumme-display-current-image-sized] | |
1424 '("Display original, sized to fit" . tumme-display-current-image-sized)) | |
1425 | |
1426 (define-key tumme-display-image-mode-map | |
1427 [menu-bar tumme tumme-display-current-image-full] | |
1428 '("Display original, full size" . tumme-display-current-image-full)) | |
1429 | |
1430 ) | |
1431 | |
1432 (defun tumme-display-current-image-full () | |
1433 "Display current image in full size." | |
1434 (interactive) | |
1435 (let ((file (tumme-original-file-name))) | |
1436 (if file | |
1437 (progn | |
1438 (tumme-display-image file t) | |
1439 (message "Full size image displayed")) | |
1440 (error "No original file name at point")))) | |
1441 | |
1442 (defun tumme-display-current-image-sized () | |
1443 "Display current image in sized to fit window dimensions." | |
1444 (interactive) | |
1445 (let ((file (tumme-original-file-name))) | |
1446 (if file | |
1447 (progn | |
1448 (tumme-display-image file) | |
1449 (message "Full size image displayed")) | |
1450 (error "No original file name at point")))) | |
1451 | |
1452 (define-derived-mode tumme-thumbnail-mode | |
1453 fundamental-mode "tumme-thumbnail" | |
1454 "Browse and manipulate thumbnail images using dired. | |
1455 Use `tumme-dired' and `tumme-setup-dired-keybindings' to get a | |
1456 nice setup to start with." | |
1457 (tumme-define-thumbnail-mode-keymap) | |
1458 (message "tumme-thumbnail-mode enabled")) | |
1459 | |
1460 (define-derived-mode tumme-display-image-mode | |
1461 fundamental-mode "tumme-image-display" | |
1462 "Mode for displaying and manipulating original image. | |
1463 Resized or in full-size." | |
1464 (tumme-define-display-image-mode-keymap) | |
1465 (message "tumme-display-image-mode enabled")) | |
1466 | |
68404 | 1467 ;;;###autoload |
67302 | 1468 (defun tumme-setup-dired-keybindings () |
1469 "Setup easy-to-use keybindings for the commands to be used in dired mode. | |
1470 Note that n, p and <down> and <up> will be hijacked and bound to | |
1471 `tumme-dired-x-line'." | |
1472 (interactive) | |
1473 | |
1474 ;; Hijack previous and next line movement. Let C-p and C-b be | |
1475 ;; though... | |
1476 | |
1477 (define-key dired-mode-map "p" 'tumme-dired-previous-line) | |
1478 (define-key dired-mode-map "n" 'tumme-dired-next-line) | |
1479 (define-key dired-mode-map [up] 'tumme-dired-previous-line) | |
1480 (define-key dired-mode-map [down] 'tumme-dired-next-line) | |
1481 | |
1482 (define-key dired-mode-map (kbd "C-S-n") 'tumme-next-line-and-display) | |
1483 (define-key dired-mode-map (kbd "C-S-p") 'tumme-previous-line-and-display) | |
1484 (define-key dired-mode-map (kbd "C-S-m") 'tumme-mark-and-display-next) | |
1485 | |
1486 (define-key dired-mode-map "\C-td" 'tumme-display-thumbs) | |
1487 (define-key dired-mode-map "\C-tt" 'tumme-tag-files) | |
70982
9200b8713856
(tumme-delete-tag): Rename from `tumme-tag-remove'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70916
diff
changeset
|
1488 (define-key dired-mode-map "\C-tr" 'tumme-delete-tag) |
67302 | 1489 (define-key dired-mode-map [tab] 'tumme-jump-thumbnail-buffer) |
70891
96a49e1507ec
Renamed `tumme-display-dired-image' to `tumme-dired-display-image'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70890
diff
changeset
|
1490 (define-key dired-mode-map "\C-ti" 'tumme-dired-display-image) |
67302 | 1491 (define-key dired-mode-map "\C-tx" 'tumme-dired-display-external) |
1492 (define-key dired-mode-map "\C-ta" 'tumme-display-thumbs-append) | |
1493 (define-key dired-mode-map "\C-t." 'tumme-display-thumb) | |
1494 (define-key dired-mode-map "\C-tc" 'tumme-dired-comment-files) | |
1495 (define-key dired-mode-map "\C-tf" 'tumme-mark-tagged-files) | |
1496 | |
1497 ;; Menu for dired | |
1498 (define-key dired-mode-map [menu-bar tumme] | |
1499 (cons "Tumme" (make-sparse-keymap "Tumme"))) | |
1500 | |
1501 (define-key dired-mode-map [menu-bar tumme tumme-copy-with-exif-file-name] | |
1502 '("Copy with EXIF file name" . tumme-copy-with-exif-file-name)) | |
1503 | |
1504 (define-key dired-mode-map [menu-bar tumme tumme-dired-comment-files] | |
1505 '("Comment files" . tumme-dired-comment-files)) | |
1506 | |
1507 (define-key dired-mode-map [menu-bar tumme tumme-mark-tagged-files] | |
1508 '("Mark tagged files" . tumme-mark-tagged-files)) | |
1509 | |
70982
9200b8713856
(tumme-delete-tag): Rename from `tumme-tag-remove'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70916
diff
changeset
|
1510 (define-key dired-mode-map [menu-bar tumme tumme-delete-tag] |
9200b8713856
(tumme-delete-tag): Rename from `tumme-tag-remove'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70916
diff
changeset
|
1511 '("Remove tag from files" . tumme-delete-tag)) |
67302 | 1512 |
1513 (define-key dired-mode-map [menu-bar tumme tumme-tag-files] | |
1514 '("Tag files" . tumme-tag-files)) | |
1515 | |
1516 (define-key dired-mode-map [menu-bar tumme tumme-jump-thumbnail-buffer] | |
1517 '("Jump to thumbnail buffer" . tumme-jump-thumbnail-buffer)) | |
1518 | |
1519 (define-key dired-mode-map [menu-bar tumme tumme-toggle-movement-tracking] | |
1520 '("Toggle movement tracking" . tumme-toggle-movement-tracking)) | |
1521 | |
1522 (define-key dired-mode-map | |
1523 [menu-bar tumme tumme-toggle-append-browsing] | |
1524 '("Toggle append browsing" . tumme-toggle-append-browsing)) | |
1525 | |
1526 (define-key dired-mode-map | |
1527 [menu-bar tumme tumme-toggle-disp-props] | |
1528 '("Toggle display properties" . tumme-toggle-dired-display-properties)) | |
1529 | |
1530 (define-key dired-mode-map | |
1531 [menu-bar tumme tumme-dired-display-external] | |
1532 '("Display in external viewer" . tumme-dired-display-external)) | |
1533 (define-key dired-mode-map | |
70891
96a49e1507ec
Renamed `tumme-display-dired-image' to `tumme-dired-display-image'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70890
diff
changeset
|
1534 [menu-bar tumme tumme-dired-display-image] |
96a49e1507ec
Renamed `tumme-display-dired-image' to `tumme-dired-display-image'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70890
diff
changeset
|
1535 '("Display image" . tumme-dired-display-image)) |
67302 | 1536 (define-key dired-mode-map |
1537 [menu-bar tumme tumme-display-thumb] | |
1538 '("Display this thumbnail" . tumme-display-thumb)) | |
1539 (define-key dired-mode-map | |
1540 [menu-bar tumme tumme-display-thumbs-append] | |
1541 '("Display thumbnails append" . tumme-display-thumbs-append)) | |
1542 (define-key dired-mode-map | |
1543 [menu-bar tumme tumme-display-thumbs] | |
1544 '("Display thumbnails" . tumme-display-thumbs)) | |
1545 | |
1546 (define-key dired-mode-map | |
1547 [menu-bar tumme tumme-create-thumbs] | |
1548 '("Create thumbnails for marked files" . tumme-create-thumbs)) | |
1549 | |
1550 (define-key dired-mode-map | |
1551 [menu-bar tumme tumme-mark-and-display-next] | |
1552 '("Mark and display next" . tumme-mark-and-display-next)) | |
1553 (define-key dired-mode-map | |
1554 [menu-bar tumme tumme-previous-line-and-display] | |
1555 '("Display thumb for previous file" . tumme-previous-line-and-display)) | |
1556 (define-key dired-mode-map | |
1557 [menu-bar tumme tumme-next-line-and-display] | |
1558 '("Display thumb for next file" . tumme-next-line-and-display))) | |
1559 | |
1560 (defun tumme-create-thumbs (&optional arg) | |
1561 "Create thumbnail images for all marked files in dired. | |
1562 With prefix argument ARG, create thumbnails even if they already exist | |
68757
3c76b1d6eff0
Tried to make docstring less `colloquial'...
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68754
diff
changeset
|
1563 \(i.e. use this to refresh your thumbnails)." |
67302 | 1564 (interactive "P") |
1565 (let (curr-file thumb-name files count) | |
1566 (setq files (dired-get-marked-files)) | |
1567 (mapcar | |
1568 (lambda (curr-file) | |
1569 (setq thumb-name (tumme-thumb-name curr-file)) | |
1570 ;; If the user overrides the exist check, we must clear the | |
1571 ;; image cache so that if the user wants to display the | |
1572 ;; thumnail, it is not fetched from cache. | |
1573 (if arg | |
1574 (clear-image-cache)) | |
1575 (if (or (not (file-exists-p thumb-name)) | |
1576 arg) | |
1577 (if (not (= 0 (tumme-create-thumb curr-file | |
1578 (tumme-thumb-name curr-file)))) | |
1579 (error "Thumb could not be created")))) | |
1580 files))) | |
1581 | |
1582 (defvar tumme-slideshow-timer nil | |
1583 "Slideshow timer.") | |
1584 | |
1585 (defvar tumme-slideshow-count 0 | |
1586 "Keeping track on number of images in slideshow.") | |
1587 | |
1588 (defvar tumme-slideshow-times 0 | |
1589 "Number of pictures to display in slideshow.") | |
1590 | |
1591 (defun tumme-slideshow-step () | |
1592 "Step to next file, if `tumme-slideshow-times' has not been reached." | |
1593 (if (< tumme-slideshow-count tumme-slideshow-times) | |
1594 (progn | |
1595 (message "%s" (1+ tumme-slideshow-count)) | |
1596 (setq tumme-slideshow-count (1+ tumme-slideshow-count)) | |
1597 (tumme-next-line-and-display)) | |
1598 (tumme-slideshow-stop))) | |
1599 | |
1600 (defun tumme-slideshow-start () | |
1601 "Start slideshow. | |
1602 Ask user for number of images to show and the delay in between." | |
1603 (interactive) | |
1604 (setq tumme-slideshow-count 0) | |
1605 (setq tumme-slideshow-times (string-to-number (read-string "How many: "))) | |
1606 (let ((repeat (string-to-number | |
1607 (read-string | |
1608 "Delay, in seconds. Decimals are accepted : " "1")))) | |
1609 (setq tumme-slideshow-timer | |
1610 (run-with-timer | |
1611 0 repeat | |
1612 'tumme-slideshow-step)))) | |
1613 | |
1614 (defun tumme-slideshow-stop () | |
1615 "Cancel slideshow." | |
1616 (interactive) | |
1617 (cancel-timer tumme-slideshow-timer)) | |
1618 | |
1619 (defun tumme-delete-char () | |
1620 "Remove current thumbnail from thumbnail buffer and line up." | |
1621 (interactive) | |
1622 (let ((inhibit-read-only t)) | |
1623 (delete-char 1) | |
1624 (if (looking-at " ") | |
1625 (delete-char 1)))) | |
1626 | |
68682
23eaa0d773ea
Added more autoload cookies.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68675
diff
changeset
|
1627 ;;;###autoload |
67302 | 1628 (defun tumme-display-thumbs-append () |
1629 "Append thumbnails to `tumme-thumbnail-buffer'." | |
1630 (interactive) | |
70888
b84970723553
Added new parameter to `tumme-display-thumbs' to be used from `tumme-next-line-and-display' and similar commands.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70807
diff
changeset
|
1631 (tumme-display-thumbs nil t t)) |
67302 | 1632 |
68682
23eaa0d773ea
Added more autoload cookies.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68675
diff
changeset
|
1633 ;;;###autoload |
67302 | 1634 (defun tumme-display-thumb () |
1635 "Shorthard for `tumme-display-thumbs' with prefix argument." | |
1636 (interactive) | |
70888
b84970723553
Added new parameter to `tumme-display-thumbs' to be used from `tumme-next-line-and-display' and similar commands.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70807
diff
changeset
|
1637 (tumme-display-thumbs t nil t)) |
67302 | 1638 |
1639 (defun tumme-line-up () | |
1640 "Line up thumbnails according to `tumme-thumbs-per-row'. | |
1641 See also `tumme-line-up-dynamic'." | |
1642 (interactive) | |
1643 (let ((inhibit-read-only t)) | |
1644 (goto-char (point-min)) | |
1645 (while (and (not (tumme-image-at-point-p)) | |
1646 (not (eobp))) | |
1647 (delete-char 1)) | |
1648 (while (not (eobp)) | |
1649 (forward-char) | |
1650 (while (and (not (tumme-image-at-point-p)) | |
1651 (not (eobp))) | |
1652 (delete-char 1))) | |
1653 (goto-char (point-min)) | |
1654 (let ((count 0)) | |
1655 (while (not (eobp)) | |
1656 (forward-char) | |
1657 (if (= tumme-thumbs-per-row 1) | |
1658 (insert "\n") | |
1659 (insert " ") | |
1660 (setq count (1+ count)) | |
72083
bb51418c995c
Add extra check for end of buffer.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72019
diff
changeset
|
1661 (when (and (= count (- tumme-thumbs-per-row 1)) |
bb51418c995c
Add extra check for end of buffer.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72019
diff
changeset
|
1662 (not (eobp))) |
70996
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1663 (forward-char) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1664 (insert "\n") |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
1665 (setq count 0))))) |
67302 | 1666 (goto-char (point-min)))) |
1667 | |
1668 (defun tumme-line-up-dynamic () | |
1669 "Line up thumbnails images dynamically. | |
68673
5a7d4aa73d2d
(tumme-get-thumbnail-image): Add missing arg to `error'.
Juanma Barranquero <lekktu@gmail.com>
parents:
68658
diff
changeset
|
1670 Calculate how many thumbnails fit." |
67302 | 1671 (interactive) |
1672 (let* ((char-width (frame-char-width)) | |
1673 (width (tumme-window-width-pixels (tumme-thumbnail-window))) | |
1674 (tumme-thumbs-per-row | |
1675 (/ width | |
1676 (+ (* 2 tumme-thumb-relief) | |
1677 (* 2 tumme-thumb-margin) | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1678 tumme-thumb-width char-width)))) |
67302 | 1679 (tumme-line-up))) |
1680 | |
1681 (defun tumme-line-up-interactive () | |
1682 "Line up thumbnails interactively. | |
68673
5a7d4aa73d2d
(tumme-get-thumbnail-image): Add missing arg to `error'.
Juanma Barranquero <lekktu@gmail.com>
parents:
68658
diff
changeset
|
1683 Ask user how many thumbnails should be displayed per row." |
67302 | 1684 (interactive) |
1685 (let ((tumme-thumbs-per-row | |
1686 (string-to-number (read-string "How many thumbs per row: ")))) | |
1687 (if (not (> tumme-thumbs-per-row 0)) | |
1688 (message "Number must be greater than 0") | |
1689 (tumme-line-up)))) | |
1690 | |
1691 (defun tumme-thumbnail-display-external () | |
1692 "Display original image for thumbnail at point using external viewer." | |
1693 (interactive) | |
1694 (let ((file (tumme-original-file-name))) | |
1695 (if (not (tumme-image-at-point-p)) | |
1696 (message "No thumbnail at point") | |
1697 (if (not file) | |
1698 (message "No original file name found") | |
71808 | 1699 (call-process shell-file-name nil nil nil shell-command-switch |
71780 | 1700 (format "%s \"%s\"" tumme-external-viewer file)))))) |
67302 | 1701 |
68682
23eaa0d773ea
Added more autoload cookies.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68675
diff
changeset
|
1702 ;;;###autoload |
67302 | 1703 (defun tumme-dired-display-external () |
1704 "Display file at point using an external viewer." | |
1705 (interactive) | |
1706 (let ((file (dired-get-filename))) | |
71808 | 1707 (call-process shell-file-name nil nil nil shell-command-switch |
71780 | 1708 (format "%s \"%s\"" tumme-external-viewer file)))) |
67302 | 1709 |
1710 (defun tumme-window-width-pixels (window) | |
1711 "Calculate WINDOW width in pixels." | |
1712 (* (window-width window) (frame-char-width))) | |
1713 | |
1714 (defun tumme-window-height-pixels (window) | |
1715 "Calculate WINDOW height in pixels." | |
1716 ;; Note: The mode-line consumes one line | |
1717 (* (- (window-height window) 1) (frame-char-height))) | |
1718 | |
1719 (defun tumme-display-window () | |
1720 "Return window where `tumme-display-image-buffer' is visible." | |
1721 (get-window-with-predicate | |
1722 (lambda (window) | |
1723 (equal (buffer-name (window-buffer window)) tumme-display-image-buffer)) | |
1724 nil t)) | |
1725 | |
1726 (defun tumme-thumbnail-window () | |
1727 "Return window where `tumme-thumbnail-buffer' is visible." | |
1728 (get-window-with-predicate | |
1729 (lambda (window) | |
1730 (equal (buffer-name (window-buffer window)) tumme-thumbnail-buffer)) | |
1731 nil t)) | |
1732 | |
1733 (defun tumme-associated-dired-buffer-window () | |
1734 "Return window where associated dired buffer is visible." | |
1735 (let (buf) | |
1736 (if (tumme-image-at-point-p) | |
1737 (progn | |
1738 (setq buf (tumme-associated-dired-buffer)) | |
1739 (get-window-with-predicate | |
1740 (lambda (window) | |
1741 (equal (window-buffer window) buf)))) | |
1742 (error "No thumbnail image at point")))) | |
1743 | |
1744 (defun tumme-display-window-width () | |
1745 "Return width, in pixels, of tumme's image display window." | |
1746 (- (tumme-window-width-pixels (tumme-display-window)) | |
1747 tumme-display-window-width-correction)) | |
1748 | |
1749 (defun tumme-display-window-height () | |
1750 "Return height, in pixels, of tumme's image display window." | |
1751 (- (tumme-window-height-pixels (tumme-display-window)) | |
1752 tumme-display-window-height-correction)) | |
1753 | |
1754 (defun tumme-display-image (file &optional original-size) | |
1755 "Display image FILE in image buffer. | |
70916
dfbe62ceddcf
* tumme.el (tumme-display-image): Changed documentation string
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70893
diff
changeset
|
1756 Use this when you want to display the image, semi sized, in a new |
dfbe62ceddcf
* tumme.el (tumme-display-image): Changed documentation string
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70893
diff
changeset
|
1757 window. The image is sized to fit the display window (using a |
dfbe62ceddcf
* tumme.el (tumme-display-image): Changed documentation string
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70893
diff
changeset
|
1758 temporary file, don't worry). Because of this, it will not be as |
dfbe62ceddcf
* tumme.el (tumme-display-image): Changed documentation string
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70893
diff
changeset
|
1759 quick as opening it directly, but on most modern systems it |
dfbe62ceddcf
* tumme.el (tumme-display-image): Changed documentation string
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70893
diff
changeset
|
1760 should feel snappy enough. |
67302 | 1761 |
1762 If optional argument ORIGINAL-SIZE is non-nil, display image in its | |
1763 original size." | |
1764 (let ((new-file (expand-file-name tumme-temp-image-file)) | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1765 width height command ret) |
67302 | 1766 (setq file (expand-file-name file)) |
1767 (if (not original-size) | |
1768 (progn | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1769 (setq width (tumme-display-window-width)) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1770 (setq height (tumme-display-window-height)) |
67302 | 1771 (setq command |
1772 (format-spec | |
1773 tumme-cmd-create-temp-image-options | |
1774 (list | |
1775 (cons ?p tumme-cmd-create-temp-image-program) | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1776 (cons ?w width) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1777 (cons ?h height) |
67302 | 1778 (cons ?f file) |
1779 (cons ?t new-file)))) | |
71808 | 1780 (setq ret (call-process shell-file-name nil nil nil |
1781 shell-command-switch command)) | |
67302 | 1782 (if (not (= 0 ret)) |
1783 (error "Could not resize image"))) | |
1784 (copy-file file new-file t)) | |
71780 | 1785 (with-current-buffer (tumme-create-display-image-buffer) |
67302 | 1786 (let ((inhibit-read-only t)) |
1787 (erase-buffer) | |
1788 (clear-image-cache) | |
1789 (tumme-insert-image tumme-temp-image-file 'jpeg 0 0) | |
1790 (goto-char (point-min)) | |
1791 (tumme-update-property 'original-file-name file))))) | |
1792 | |
1793 (defun tumme-display-thumbnail-original-image (&optional arg) | |
1794 "Display current thumbnail's original image in display buffer. | |
1795 See documentation for `tumme-display-image' for more information. | |
1796 With prefix argument ARG, display image in its original size." | |
1797 (interactive "P") | |
1798 (let ((file (tumme-original-file-name))) | |
1799 (if (not (string-equal major-mode "tumme-thumbnail-mode")) | |
1800 (message "Not in tumme-thumbnail-mode") | |
1801 (if (not (tumme-image-at-point-p)) | |
1802 (message "No thumbnail at point") | |
1803 (if (not file) | |
1804 (message "No original file name found") | |
72017
0ec82e7ecc2f
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
71919
diff
changeset
|
1805 (tumme-create-display-image-buffer) |
0ec82e7ecc2f
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
71919
diff
changeset
|
1806 (display-buffer tumme-display-image-buffer) |
0ec82e7ecc2f
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
71919
diff
changeset
|
1807 (tumme-display-image file arg)))))) |
0ec82e7ecc2f
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
71919
diff
changeset
|
1808 |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1809 |
68682
23eaa0d773ea
Added more autoload cookies.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68675
diff
changeset
|
1810 ;;;###autoload |
70891
96a49e1507ec
Renamed `tumme-display-dired-image' to `tumme-dired-display-image'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70890
diff
changeset
|
1811 (defun tumme-dired-display-image (&optional arg) |
67302 | 1812 "Display current image file. |
1813 See documentation for `tumme-display-image' for more information. | |
1814 With prefix argument ARG, display image in its original size." | |
1815 (interactive "P") | |
72017
0ec82e7ecc2f
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
71919
diff
changeset
|
1816 (tumme-create-display-image-buffer) |
0ec82e7ecc2f
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
71919
diff
changeset
|
1817 (display-buffer tumme-display-image-buffer) |
0ec82e7ecc2f
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
71919
diff
changeset
|
1818 (tumme-display-image (dired-get-filename) arg)) |
67302 | 1819 |
1820 (defun tumme-image-at-point-p () | |
1821 "Return true if there is a tumme thumbnail at point." | |
1822 (get-text-property (point) 'tumme-thumbnail)) | |
1823 | |
1824 (defun tumme-rotate-thumbnail (degrees) | |
1825 "Rotate thumbnail DEGREES degrees." | |
1826 (if (not (tumme-image-at-point-p)) | |
1827 (message "No thumbnail at point") | |
1828 (let ((file (tumme-thumb-name (tumme-original-file-name))) | |
1829 command) | |
1830 (setq command (format-spec | |
1831 tumme-cmd-rotate-thumbnail-options | |
1832 (list | |
1833 (cons ?p tumme-cmd-rotate-thumbnail-program) | |
1834 (cons ?d degrees) | |
1835 (cons ?t (expand-file-name file))))) | |
71808 | 1836 (call-process shell-file-name nil nil nil shell-command-switch command) |
67302 | 1837 ;; Clear the cache to refresh image. I wish I could just refresh |
1838 ;; the current file but I do not know how to do that. Yet... | |
1839 (clear-image-cache)))) | |
1840 | |
1841 (defun tumme-rotate-thumbnail-left () | |
1842 "Rotate thumbnail left (counter clockwise) 90 degrees. | |
1843 The result of the rotation is displayed in the image display area | |
1844 and a confirmation is needed before the original image files is | |
1845 overwritten. This confirmation can be turned off using | |
1846 `tumme-rotate-original-ask-before-overwrite'." | |
1847 (interactive) | |
1848 (tumme-rotate-thumbnail "270")) | |
1849 | |
1850 (defun tumme-rotate-thumbnail-right () | |
1851 "Rotate thumbnail counter right (clockwise) 90 degrees. | |
1852 The result of the rotation is displayed in the image display area | |
1853 and a confirmation is needed before the original image files is | |
1854 overwritten. This confirmation can be turned off using | |
1855 `tumme-rotate-original-ask-before-overwrite'." | |
1856 (interactive) | |
1857 (tumme-rotate-thumbnail "90")) | |
1858 | |
1859 (defun tumme-refresh-thumb () | |
1860 "Force creation of new image for current thumbnail." | |
1861 (interactive) | |
1862 (let ((file (tumme-original-file-name))) | |
1863 (clear-image-cache) | |
1864 (tumme-create-thumb file (tumme-thumb-name file)))) | |
1865 | |
1866 (defun tumme-rotate-original (degrees) | |
1867 "Rotate original image DEGREES degrees." | |
1868 (if (not (tumme-image-at-point-p)) | |
1869 (message "No image at point") | |
1870 (let ((file (tumme-original-file-name)) | |
1871 command temp-file) | |
1872 (if (not (string-match "\.[jJ][pP[eE]?[gG]$" file)) | |
1873 (error "Only JPEG images can be rotated!")) | |
1874 (setq command (format-spec | |
1875 tumme-cmd-rotate-original-options | |
1876 (list | |
1877 (cons ?p tumme-cmd-rotate-original-program) | |
1878 (cons ?d degrees) | |
1879 (cons ?o (expand-file-name file)) | |
1880 (cons ?t tumme-temp-rotate-image-file)))) | |
71808 | 1881 (if (not (= 0 (call-process shell-file-name nil nil nil |
1882 shell-command-switch command))) | |
67302 | 1883 (error "Could not rotate image") |
1884 (tumme-display-image tumme-temp-rotate-image-file) | |
1885 (if (or (and tumme-rotate-original-ask-before-overwrite | |
71780 | 1886 (y-or-n-p |
1887 "Rotate to temp file OK. Overwrite original image? ")) | |
67302 | 1888 (not tumme-rotate-original-ask-before-overwrite)) |
1889 (progn | |
1890 (copy-file tumme-temp-rotate-image-file file t) | |
1891 (tumme-refresh-thumb)) | |
1892 (tumme-display-image file)))))) | |
1893 | |
1894 (defun tumme-rotate-original-left () | |
1895 "Rotate original image left (counter clockwise) 90 degrees." | |
1896 (interactive) | |
1897 (tumme-rotate-original "270")) | |
1898 | |
1899 (defun tumme-rotate-original-right () | |
1900 "Rotate original image right (clockwise) 90 degrees." | |
1901 (interactive) | |
1902 (tumme-rotate-original "90")) | |
1903 | |
1904 (defun tumme-get-exif-file-name (file) | |
1905 "Use the image's EXIF information to return a unique file name. | |
1906 The file name should be unique as long as you do not take more than | |
1907 one picture per second. The original file name is suffixed at the end | |
1908 for traceability. The format of the returned file name is | |
1909 YYYY_MM_DD_HH_MM_DD_ORIG_FILE_NAME.jpg. Used from | |
1910 `tumme-copy-with-exif-file-name'." | |
1911 (let (data no-exif-data-found) | |
1912 (if (not (string-match "\.[Jj][Pp][Ee]?[Gg]$" (expand-file-name file))) | |
1913 (progn | |
1914 (setq no-exif-data-found t) | |
1915 (setq data | |
1916 (format-time-string | |
1917 "%Y:%m:%d %H:%M:%S" | |
1918 (nth 5 (file-attributes (expand-file-name file)))))) | |
71780 | 1919 (setq data (tumme-get-exif-data (expand-file-name file) |
1920 "DateTimeOriginal"))) | |
67302 | 1921 (while (string-match "[ :]" data) |
1922 (setq data (replace-match "_" nil nil data))) | |
1923 (format "%s%s%s" data | |
1924 (if no-exif-data-found | |
1925 "_noexif_" | |
1926 "_") | |
1927 (file-name-nondirectory file)))) | |
1928 | |
1929 (defun tumme-thumbnail-set-image-description () | |
1930 "Set the ImageDescription EXIF tag for the original image. | |
1931 If the image already has a value for this tag, it is used as the | |
1932 default value at the prompt." | |
1933 (interactive) | |
1934 (if (not (tumme-image-at-point-p)) | |
1935 (message "No thumbnail at point") | |
1936 (let* ((file (tumme-original-file-name)) | |
1937 (old-value (tumme-get-exif-data file "ImageDescription"))) | |
1938 (if (eq 0 | |
1939 (tumme-set-exif-data file "ImageDescription" | |
71780 | 1940 (read-string "Value of ImageDescription: " |
1941 old-value))) | |
67302 | 1942 (message "Successfully wrote ImageDescription tag.") |
1943 (error "Could not write ImageDescription tag"))))) | |
1944 | |
1945 (defun tumme-set-exif-data (file tag-name tag-value) | |
1946 "In FILE, set EXIF tag TAG-NAME to value TAG-VALUE." | |
1947 (let (command) | |
1948 (setq command (format-spec | |
1949 tumme-cmd-write-exif-data-options | |
1950 (list | |
1951 (cons ?p tumme-cmd-write-exif-data-program) | |
1952 (cons ?f (expand-file-name file)) | |
1953 (cons ?t tag-name) | |
1954 (cons ?v tag-value)))) | |
71808 | 1955 (call-process shell-file-name nil nil nil shell-command-switch command))) |
67302 | 1956 |
1957 (defun tumme-get-exif-data (file tag-name) | |
1958 "From FILE, return EXIF tag TAG-NAME." | |
1959 (let ((buf (get-buffer-create "*tumme-get-exif-data*")) | |
1960 command tag-value) | |
1961 (setq command (format-spec | |
1962 tumme-cmd-read-exif-data-options | |
1963 (list | |
1964 (cons ?p tumme-cmd-read-exif-data-program) | |
1965 (cons ?f file) | |
1966 (cons ?t tag-name)))) | |
71780 | 1967 (with-current-buffer buf |
67302 | 1968 (delete-region (point-min) (point-max)) |
71808 | 1969 (if (not (eq (call-process shell-file-name nil t nil |
1970 shell-command-switch command) 0)) | |
67302 | 1971 (error "Could not get EXIF tag") |
1972 (goto-char (point-min)) | |
1973 ;; Clean buffer from newlines and carriage returns before | |
1974 ;; getting final info | |
1975 (while (search-forward-regexp "[\n\r]" nil t) | |
1976 (replace-match "" nil t)) | |
1977 (setq tag-value (buffer-substring (point-min) (point-max))))) | |
1978 tag-value)) | |
1979 | |
1980 (defun tumme-copy-with-exif-file-name () | |
1981 "Copy file with unique name to main image directory. | |
68757
3c76b1d6eff0
Tried to make docstring less `colloquial'...
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68754
diff
changeset
|
1982 Copy current or all marked files in dired to a new file in your |
3c76b1d6eff0
Tried to make docstring less `colloquial'...
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68754
diff
changeset
|
1983 main image directory, using a file name generated by |
3c76b1d6eff0
Tried to make docstring less `colloquial'...
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68754
diff
changeset
|
1984 `tumme-get-exif-file-name'. A typical usage for this if when |
3c76b1d6eff0
Tried to make docstring less `colloquial'...
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68754
diff
changeset
|
1985 copying images from a digital camera into the image directory. |
67302 | 1986 |
68757
3c76b1d6eff0
Tried to make docstring less `colloquial'...
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68754
diff
changeset
|
1987 Typically, you would open up the folder with the incoming |
3c76b1d6eff0
Tried to make docstring less `colloquial'...
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68754
diff
changeset
|
1988 digital images, mark the files to be copied, and execute this |
67302 | 1989 function. The result is a couple of new files in |
68757
3c76b1d6eff0
Tried to make docstring less `colloquial'...
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68754
diff
changeset
|
1990 `tumme-main-image-directory' called |
3c76b1d6eff0
Tried to make docstring less `colloquial'...
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68754
diff
changeset
|
1991 2005_05_08_12_52_00_dscn0319.jpg, |
3c76b1d6eff0
Tried to make docstring less `colloquial'...
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68754
diff
changeset
|
1992 2005_05_08_14_27_45_dscn0320.jpg etc." |
67302 | 1993 (interactive) |
1994 (let (new-name | |
1995 (files (dired-get-marked-files))) | |
1996 (mapcar | |
1997 (lambda (curr-file) | |
1998 (setq new-name | |
1999 (format "%s/%s" | |
2000 (file-name-as-directory | |
2001 (expand-file-name tumme-main-image-directory)) | |
2002 (tumme-get-exif-file-name curr-file))) | |
2003 (message "Copying %s to %s" curr-file new-name) | |
2004 (copy-file curr-file new-name)) | |
2005 files))) | |
2006 | |
2007 (defun tumme-display-next-thumbnail-original () | |
2008 "In thubnail buffer, move to next thumbnail and display the image." | |
2009 (interactive) | |
72124
46e335881cbf
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72121
diff
changeset
|
2010 (tumme-forward-image) |
67302 | 2011 (tumme-display-thumbnail-original-image)) |
2012 | |
2013 (defun tumme-display-previous-thumbnail-original () | |
68673
5a7d4aa73d2d
(tumme-get-thumbnail-image): Add missing arg to `error'.
Juanma Barranquero <lekktu@gmail.com>
parents:
68658
diff
changeset
|
2014 "Move to previous thumbnail and display image." |
67302 | 2015 (interactive) |
72124
46e335881cbf
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72121
diff
changeset
|
2016 (tumme-backward-image) |
67302 | 2017 (tumme-display-thumbnail-original-image)) |
2018 | |
72087
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2019 (defun tumme-write-comments (file-comments) |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2020 "Write file comments to database. |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2021 Write file comments to one or more files. FILE-COMMENTS is an alist on |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2022 the following form: |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2023 ((FILE . COMMENT) ... )" |
72121
2df19ee49e28
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72119
diff
changeset
|
2024 (let (end comment-beg-pos comment-end-pos file comment) |
72087
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2025 (with-temp-file tumme-db-file |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2026 (insert-file-contents tumme-db-file) |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2027 (dolist (elt file-comments) |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2028 (setq file (car elt) |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2029 comment (cdr elt)) |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2030 (goto-char (point-min)) |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2031 (if (search-forward-regexp (format "^%s.*$" file) nil t) |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2032 (progn |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2033 (setq end (point)) |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2034 (beginning-of-line) |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2035 ;; Delete old comment, if any |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2036 (when (search-forward ";comment:" end t) |
72121
2df19ee49e28
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72119
diff
changeset
|
2037 (setq comment-beg-pos (match-beginning 0)) |
72087
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2038 ;; Any tags after the comment? |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2039 (if (search-forward ";" end t) |
72121
2df19ee49e28
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72119
diff
changeset
|
2040 (setq comment-end-pos (- (point) 1)) |
2df19ee49e28
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72119
diff
changeset
|
2041 (setq comment-end-pos end)) |
72087
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2042 ;; Delete comment tag and comment |
72121
2df19ee49e28
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72119
diff
changeset
|
2043 (delete-region comment-beg-pos comment-end-pos)) |
72087
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2044 ;; Insert new comment |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2045 (beginning-of-line) |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2046 (unless (search-forward ";" end t) |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2047 (end-of-line) |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2048 (insert ";")) |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2049 (insert (format "comment:%s;" comment))) |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2050 ;; File does not exist in database - add it. |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2051 (goto-char (point-max)) |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2052 (insert (format "\n%s;comment:%s" file comment))))))) |
585ed6ff296a
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72085
diff
changeset
|
2053 |
67302 | 2054 (defun tumme-update-property (prop value) |
2055 "Update text property PROP with value VALUE at point." | |
2056 (let ((inhibit-read-only t)) | |
2057 (put-text-property | |
2058 (point) (1+ (point)) | |
2059 prop | |
2060 value))) | |
2061 | |
68682
23eaa0d773ea
Added more autoload cookies.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68675
diff
changeset
|
2062 ;;;###autoload |
67302 | 2063 (defun tumme-dired-comment-files () |
2064 "Add comment to current or marked files in dired." | |
2065 (interactive) | |
72089
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
2066 (let ((comment (tumme-read-comment))) |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
2067 (tumme-write-comments |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
2068 (mapcar |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
2069 (lambda (curr-file) |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
2070 (cons curr-file comment)) |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
2071 (dired-get-marked-files))))) |
67302 | 2072 |
2073 (defun tumme-comment-thumbnail () | |
2074 "Add comment to current thumbnail in thumbnail buffer." | |
2075 (interactive) | |
2076 (let* ((file (tumme-original-file-name)) | |
2077 (comment (tumme-read-comment file))) | |
72089
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
2078 (tumme-write-comments (list (cons file comment))) |
67302 | 2079 (tumme-update-property 'comment comment)) |
2080 (tumme-display-thumb-properties)) | |
2081 | |
2082 (defun tumme-read-comment (&optional file) | |
68806
3e96b0954fa1
Enhanced some docstrings. Added todo item about the Thumbnail
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68783
diff
changeset
|
2083 "Read comment for an image. |
3e96b0954fa1
Enhanced some docstrings. Added todo item about the Thumbnail
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68783
diff
changeset
|
2084 Read comment for an image, optionally using old comment from FILE |
3e96b0954fa1
Enhanced some docstrings. Added todo item about the Thumbnail
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68783
diff
changeset
|
2085 as initial value." |
67302 | 2086 (let ((comment |
2087 (read-string | |
2088 "Comment: " | |
2089 (if file (tumme-get-comment file))))) | |
2090 comment)) | |
2091 | |
2092 (defun tumme-get-comment (file) | |
2093 "Get comment for file FILE." | |
2094 (save-excursion | |
72121
2df19ee49e28
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72119
diff
changeset
|
2095 (let (end buf comment-beg-pos comment-end-pos comment) |
67302 | 2096 (setq buf (find-file tumme-db-file)) |
2097 (goto-char (point-min)) | |
70996
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
2098 (when (search-forward-regexp |
71919
9bf2fbfa2516
Fix bug in `tumme-get-comment'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
71808
diff
changeset
|
2099 (format "^%s" file) nil t) |
70996
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
2100 (end-of-line) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
2101 (setq end (point)) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
2102 (beginning-of-line) |
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
2103 (cond ((search-forward ";comment:" end t) |
72121
2df19ee49e28
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72119
diff
changeset
|
2104 (setq comment-beg-pos (point)) |
70996
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
2105 (if (search-forward ";" end t) |
72121
2df19ee49e28
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72119
diff
changeset
|
2106 (setq comment-end-pos (- (point) 1)) |
2df19ee49e28
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72119
diff
changeset
|
2107 (setq comment-end-pos end)) |
70996
0074ea910aa8
* tumme.el: Replace a lot of `if ... progn' with `when'.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
70982
diff
changeset
|
2108 (setq comment (buffer-substring |
72121
2df19ee49e28
(tumme-track-original-file): Add `buffer-live-p' check.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72119
diff
changeset
|
2109 comment-beg-pos comment-end-pos))))) |
67302 | 2110 (kill-buffer buf) |
2111 comment))) | |
2112 | |
68682
23eaa0d773ea
Added more autoload cookies.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68675
diff
changeset
|
2113 ;;;###autoload |
67302 | 2114 (defun tumme-mark-tagged-files () |
68806
3e96b0954fa1
Enhanced some docstrings. Added todo item about the Thumbnail
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68783
diff
changeset
|
2115 "Use regexp to mark files with matching tag. |
3e96b0954fa1
Enhanced some docstrings. Added todo item about the Thumbnail
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68783
diff
changeset
|
2116 A `tag' is a keyword, a piece of meta data, associated with an |
3e96b0954fa1
Enhanced some docstrings. Added todo item about the Thumbnail
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68783
diff
changeset
|
2117 image file and stored in tumme's database file. This command |
3e96b0954fa1
Enhanced some docstrings. Added todo item about the Thumbnail
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68783
diff
changeset
|
2118 lets you input a regexp and this will be matched against all tags |
3e96b0954fa1
Enhanced some docstrings. Added todo item about the Thumbnail
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68783
diff
changeset
|
2119 on all image files in the database file. The files that have a |
3e96b0954fa1
Enhanced some docstrings. Added todo item about the Thumbnail
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68783
diff
changeset
|
2120 matching tags will be marked in the dired buffer." |
67302 | 2121 (interactive) |
2122 (let ((tag (read-string "Mark tagged files (regexp): ")) | |
2123 (hits 0) | |
2124 files buf) | |
2125 (save-excursion | |
2126 (setq buf (find-file tumme-db-file)) | |
2127 (goto-char (point-min)) | |
2128 ;; Collect matches | |
2129 (while (search-forward-regexp | |
68811 | 2130 (concat "\\(^[^;\n]+\\);.*" tag ".*$") nil t) |
67302 | 2131 (setq files (append (list (match-string 1)) files))) |
2132 (kill-buffer buf) | |
2133 ;; Mark files | |
2134 (mapcar | |
2135 ;; I tried using `dired-mark-files-regexp' but it was | |
2136 ;; waaaay to slow. | |
2137 (lambda (curr-file) | |
2138 ;; Don't bother about hits found in other directories than | |
2139 ;; the current one. | |
2140 (when (string= (file-name-as-directory | |
2141 (expand-file-name default-directory)) | |
2142 (file-name-as-directory | |
2143 (file-name-directory curr-file))) | |
2144 (setq curr-file (file-name-nondirectory curr-file)) | |
2145 (goto-char (point-min)) | |
2146 (when (search-forward-regexp (format "\\s %s$" curr-file) nil t) | |
2147 (setq hits (+ hits 1)) | |
2148 (dired-mark 1)))) | |
2149 files)) | |
2150 (message "%d files with matching tag marked." hits))) | |
2151 | |
2152 (defun tumme-mouse-display-image (event) | |
2153 "Use mouse EVENT, call `tumme-display-image' to display image. | |
2154 Track this in associated dired buffer if `tumme-track-movement' is | |
2155 non-nil." | |
2156 (interactive "e") | |
2157 (let (file) | |
2158 (mouse-set-point event) | |
2159 (goto-char (posn-point (event-end event))) | |
2160 (setq file (tumme-original-file-name)) | |
2161 (if tumme-track-movement | |
2162 (tumme-track-original-file)) | |
72017
0ec82e7ecc2f
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
71919
diff
changeset
|
2163 (tumme-create-display-image-buffer) |
0ec82e7ecc2f
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
71919
diff
changeset
|
2164 (display-buffer tumme-display-image-buffer) |
67302 | 2165 (tumme-display-image file))) |
2166 | |
2167 (defun tumme-mouse-select-thumbnail (event) | |
2168 "Use mouse EVENT to select thumbnail image. | |
2169 Track this in associated dired buffer if `tumme-track-movement' is | |
2170 non-nil." | |
2171 (interactive "e") | |
2172 (let (file) | |
2173 (mouse-set-point event) | |
2174 (goto-char (posn-point (event-end event))) | |
2175 (if tumme-track-movement | |
2176 (tumme-track-original-file))) | |
2177 (tumme-display-thumb-properties)) | |
2178 | |
2179 (defun tumme-mouse-toggle-mark (event) | |
2180 "Use mouse EVENT to toggle dired mark for thumbnail. | |
2181 Track this in associated dired buffer if `tumme-track-movement' is | |
2182 non-nil." | |
2183 (interactive "e") | |
2184 (let (file) | |
2185 (mouse-set-point event) | |
2186 (goto-char (posn-point (event-end event))) | |
2187 (if tumme-track-movement | |
2188 (tumme-track-original-file))) | |
2189 (tumme-toggle-mark-thumb-original-file)) | |
2190 | |
2191 (defun tumme-dired-display-properties () | |
2192 "Display properties for dired file in the echo area." | |
2193 (interactive) | |
2194 (let* ((file (dired-get-filename)) | |
2195 (file-name (file-name-nondirectory file)) | |
2196 (dired-buf (buffer-name (current-buffer))) | |
2197 (props (mapconcat | |
2198 'princ | |
2199 (tumme-list-tags file) | |
2200 ", ")) | |
2201 (comment (tumme-get-comment file))) | |
2202 (if file-name | |
2203 (message | |
2204 (tumme-format-properties-string | |
2205 dired-buf | |
2206 file-name | |
2207 props | |
2208 comment))))) | |
2209 | |
2210 (defvar tumme-tag-file-list nil | |
2211 "List to store tag-file structure.") | |
2212 | |
2213 (defvar tumme-file-tag-list nil | |
2214 "List to store file-tag structure.") | |
2215 | |
2216 (defvar tumme-file-comment-list nil | |
2217 "List to store file comments.") | |
2218 | |
2219 (defun tumme-add-to-tag-file-list (tag file) | |
2220 "Add relation between TAG and FILE." | |
2221 (let (curr) | |
2222 (if tumme-tag-file-list | |
2223 (if (setq curr (assoc tag tumme-tag-file-list)) | |
2224 (if (not (member file curr)) | |
2225 (setcdr curr (cons file (cdr curr)))) | |
2226 (setcdr tumme-tag-file-list | |
2227 (cons (list tag file) (cdr tumme-tag-file-list)))) | |
2228 (setq tumme-tag-file-list (list (list tag file)))))) | |
2229 | |
2230 (defun tumme-add-to-tag-file-lists (tag file) | |
2231 "Helper function used from `tumme-create-gallery-lists'. | |
2232 | |
2233 Add TAG to FILE in one list and FILE to TAG in the other. | |
2234 | |
2235 Lisp structures look like the following: | |
2236 | |
2237 tumme-file-tag-list: | |
2238 | |
2239 ((\"filename1\" \"tag1\" \"tag2\" \"tag3\" ...) | |
2240 (\"filename2\" \"tag1\" \"tag2\" \"tag3\" ...) | |
2241 ...) | |
2242 | |
2243 tumme-tag-file-list: | |
2244 | |
2245 ((\"tag1\" \"filename1\" \"filename2\" \"filename3\" ...) | |
2246 (\"tag2\" \"filename1\" \"filename2\" \"filename3\" ...) | |
2247 ...)" | |
2248 ;; Add tag to file list | |
2249 (let (curr) | |
2250 (if tumme-file-tag-list | |
2251 (if (setq curr (assoc file tumme-file-tag-list)) | |
2252 (setcdr curr (cons tag (cdr curr))) | |
2253 (setcdr tumme-file-tag-list | |
2254 (cons (list file tag) (cdr tumme-file-tag-list)))) | |
2255 (setq tumme-file-tag-list (list (list file tag)))) | |
2256 ;; Add file to tag list | |
2257 (if tumme-tag-file-list | |
2258 (if (setq curr (assoc tag tumme-tag-file-list)) | |
2259 (if (not (member file curr)) | |
2260 (setcdr curr (cons file (cdr curr)))) | |
2261 (setcdr tumme-tag-file-list | |
2262 (cons (list tag file) (cdr tumme-tag-file-list)))) | |
2263 (setq tumme-tag-file-list (list (list tag file)))))) | |
2264 | |
2265 (defun tumme-add-to-file-comment-list (file comment) | |
2266 "Helper function used from `tumme-create-gallery-lists'. | |
2267 | |
2268 For FILE, add COMMENT to list. | |
2269 | |
2270 Lisp structure looks like the following: | |
2271 | |
2272 tumme-file-comment-list: | |
2273 | |
2274 ((\"filename1\" . \"comment1\") | |
2275 (\"filename2\" . \"comment2\") | |
2276 ...)" | |
2277 (if tumme-file-comment-list | |
2278 (if (not (assoc file tumme-file-comment-list)) | |
2279 (setcdr tumme-file-comment-list | |
2280 (cons (cons file comment) | |
2281 (cdr tumme-file-comment-list)))) | |
2282 (setq tumme-file-comment-list (list (cons file comment))))) | |
2283 | |
2284 (defun tumme-create-gallery-lists () | |
2285 "Create temporary lists used by `tumme-gallery-generate'." | |
2286 (let ((buf (find-file tumme-db-file)) | |
2287 end beg file row-tags) | |
2288 (setq tumme-tag-file-list nil) | |
2289 (setq tumme-file-tag-list nil) | |
2290 (setq tumme-file-comment-list nil) | |
2291 (goto-char (point-min)) | |
2292 (while (search-forward-regexp "^." nil t) | |
2293 (end-of-line) | |
2294 (setq end (point)) | |
2295 (beginning-of-line) | |
2296 (setq beg (point)) | |
2297 (if (not (search-forward ";" end nil)) | |
2298 (error "Something is really wrong, check format of database")) | |
2299 (setq row-tags (split-string | |
2300 (buffer-substring beg end) ";")) | |
2301 (setq file (car row-tags)) | |
2302 (mapc | |
2303 (lambda (x) | |
2304 (if (not (string-match "^comment:\\(.*\\)" x)) | |
2305 (tumme-add-to-tag-file-lists x file) | |
2306 (tumme-add-to-file-comment-list file (match-string 1 x)))) | |
2307 (cdr row-tags))) | |
2308 (kill-buffer buf)) | |
2309 ;; Sort tag-file list | |
2310 (setq tumme-tag-file-list | |
2311 (sort tumme-tag-file-list | |
2312 (lambda (x y) | |
2313 (string< (car x) (car y)))))) | |
2314 | |
2315 (defun tumme-hidden-p (file) | |
2316 "Return t if image FILE has a \"hidden\" tag." | |
2317 (let (hidden) | |
2318 (mapc | |
2319 (lambda (tag) | |
2320 (if (member tag tumme-gallery-hidden-tags) | |
2321 (setq hidden t))) | |
2322 (cdr (assoc file tumme-file-tag-list))) | |
2323 hidden)) | |
2324 | |
2325 (defun tumme-gallery-generate () | |
2326 "Generate gallery pages. | |
2327 First we create a couple of Lisp structures from the database to make | |
2328 it easier to generate, then HTML-files are created in | |
2329 `tumme-gallery-dir'" | |
2330 (interactive) | |
2331 (if (eq 'per-directory tumme-thumbnail-storage) | |
2332 (error "Currently, gallery generation is not supported \ | |
2333 when using per-directory thumbnail file storage")) | |
2334 (tumme-create-gallery-lists) | |
2335 (let ((tags tumme-tag-file-list) | |
2336 count curr tag index-buf tag-buf | |
2337 comment file-tags tag-link tag-link-list) | |
2338 ;; Make sure gallery root exist | |
2339 (if (file-exists-p tumme-gallery-dir) | |
2340 (if (not (file-directory-p tumme-gallery-dir)) | |
68757
3c76b1d6eff0
Tried to make docstring less `colloquial'...
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68754
diff
changeset
|
2341 (error "Variable tumme-gallery-dir is not a directory")) |
67302 | 2342 (make-directory tumme-gallery-dir)) |
2343 ;; Open index file | |
2344 (setq index-buf (find-file | |
2345 (format "%s/index.html" tumme-gallery-dir))) | |
2346 (erase-buffer) | |
2347 (insert "<html>\n") | |
2348 (insert " <body>\n") | |
2349 (insert " <h2>Tumme Gallery</h2>\n") | |
2350 (insert (format "<p>\n Gallery generated %s\n <p>\n" | |
2351 (current-time-string))) | |
2352 (insert " <h3>Tag index</h3>\n") | |
2353 (setq count 1) | |
2354 ;; Pre-generate list of all tag links | |
2355 (mapc | |
2356 (lambda (curr) | |
2357 (setq tag (car curr)) | |
2358 (when (not (member tag tumme-gallery-hidden-tags)) | |
2359 (setq tag-link (format "<a href=\"%d.html\">%s</a>" count tag)) | |
2360 (if tag-link-list | |
2361 (setq tag-link-list | |
2362 (append tag-link-list (list (cons tag tag-link)))) | |
2363 (setq tag-link-list (list (cons tag tag-link)))) | |
2364 (setq count (1+ count)))) | |
2365 tags) | |
2366 (setq count 1) | |
2367 ;; Main loop where we generated thumbnail pages per tag | |
2368 (mapc | |
2369 (lambda (curr) | |
2370 (setq tag (car curr)) | |
2371 ;; Don't display hidden tags | |
2372 (when (not (member tag tumme-gallery-hidden-tags)) | |
2373 ;; Insert link to tag page in index | |
2374 (insert (format " %s<br>\n" (cdr (assoc tag tag-link-list)))) | |
2375 ;; Open per-tag file | |
2376 (setq tag-buf (find-file | |
2377 (format "%s/%s.html" tumme-gallery-dir count))) | |
2378 (erase-buffer) | |
2379 (insert "<html>\n") | |
2380 (insert " <body>\n") | |
2381 (insert " <p><a href=\"index.html\">Index</a></p>\n") | |
2382 (insert (format " <h2>Images with tag "%s"</h2>" tag)) | |
2383 ;; Main loop for files per tag page | |
2384 (mapc | |
2385 (lambda (file) | |
2386 (when (not (tumme-hidden-p file)) | |
2387 ;; Insert thumbnail with link to full image | |
2388 (insert | |
2389 (format "<a href=\"%s/%s\"><img src=\"%s/%s\"%s></a>\n" | |
71780 | 2390 tumme-gallery-image-root-url |
2391 (file-name-nondirectory file) | |
67302 | 2392 tumme-gallery-thumb-image-root-url |
2393 (file-name-nondirectory (tumme-thumb-name file)) file)) | |
2394 ;; Insert comment, if any | |
2395 (if (setq comment (cdr (assoc file tumme-file-comment-list))) | |
2396 (insert (format "<br>\n%s<br>\n" comment)) | |
2397 (insert "<br>\n")) | |
2398 ;; Insert links to other tags, if any | |
2399 (when (> (length | |
2400 (setq file-tags (assoc file tumme-file-tag-list))) 2) | |
2401 (insert "[ ") | |
2402 (mapc | |
2403 (lambda (extra-tag) | |
2404 ;; Only insert if not file name or the main tag | |
2405 (if (and (not (equal extra-tag tag)) | |
2406 (not (equal extra-tag file))) | |
2407 (insert | |
2408 (format "%s " (cdr (assoc extra-tag tag-link-list)))))) | |
2409 file-tags) | |
2410 (insert "]<br>\n")))) | |
2411 (cdr curr)) | |
2412 (insert " <p><a href=\"index.html\">Index</a></p>\n") | |
2413 (insert " </body>\n") | |
2414 (insert "</html>\n") | |
2415 (save-buffer) | |
2416 (kill-buffer tag-buf) | |
2417 (setq count (1+ count)))) | |
2418 tags) | |
2419 (insert " </body>\n") | |
2420 (insert "</html>") | |
2421 (save-buffer) | |
2422 (kill-buffer index-buf))) | |
2423 | |
2424 (defun tumme-kill-buffer-and-window () | |
2425 "Kill the current buffer and, if possible, also the window." | |
2426 (interactive) | |
2427 (let ((buffer (current-buffer))) | |
2428 (condition-case nil | |
2429 (delete-window (selected-window)) | |
2430 (error nil)) | |
2431 (kill-buffer buffer))) | |
2432 | |
72019
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2433 (defvar tumme-widget-list nil |
72093
e75e38c3a62f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72091
diff
changeset
|
2434 "List to keep track of meta data in edit buffer.") |
72019
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2435 |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2436 ;;;###autoload |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2437 (defun tumme-dired-edit-comment-and-tags () |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2438 "Edit comment and tags of current or marked image files. |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2439 Edit comment and tags for all marked image files in an |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2440 easy-to-use form." |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2441 (interactive) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2442 (setq tumme-widget-list nil) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2443 ;; Setup buffer. |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2444 (let ((files (dired-get-marked-files))) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2445 (switch-to-buffer "*Tumme Edit Meta Data*") |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2446 (kill-all-local-variables) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2447 (make-local-variable 'widget-example-repeat) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2448 (let ((inhibit-read-only t)) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2449 (erase-buffer)) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2450 (remove-overlays) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2451 ;; Some help for the user. |
72093
e75e38c3a62f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72091
diff
changeset
|
2452 (widget-insert |
72019
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2453 "\nEdit comments and tags for each image. Separate multiple tags |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2454 with a comma. Move forward between fields using TAB or RET. |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2455 Move to the previous field using backtab (S-TAB). Save by |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2456 activating the Save button at the bottom of the form or cancel |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2457 the operation by activating the Cancel button.\n\n") |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2458 ;; Here comes all images and a comment and tag field for each |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2459 ;; image. |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2460 (let (thumb-file img comment-widget tag-widget) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2461 |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2462 (dolist (file files) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2463 |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2464 (setq thumb-file (tumme-thumb-name file) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2465 img (create-image thumb-file)) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2466 |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2467 (insert-image img) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2468 (widget-insert "\n\nComment: ") |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2469 (setq comment-widget |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2470 (widget-create 'editable-field |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2471 :size 60 |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2472 :format "%v " |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2473 :value (or (tumme-get-comment file) ""))) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2474 (widget-insert "\nTags: ") |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2475 (setq tag-widget |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2476 (widget-create 'editable-field |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2477 :size 60 |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2478 :format "%v " |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2479 :value (or (mapconcat |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2480 (lambda (tag) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2481 tag) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2482 (tumme-list-tags file) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2483 ",") ""))) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2484 ;; Save information in all widgets so that we can use it when |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2485 ;; the user saves the form. |
72093
e75e38c3a62f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72091
diff
changeset
|
2486 (setq tumme-widget-list |
e75e38c3a62f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72091
diff
changeset
|
2487 (append tumme-widget-list |
72019
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2488 (list (list file comment-widget tag-widget)))) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2489 (widget-insert "\n\n"))) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2490 |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2491 ;; Footer with Save and Cancel button. |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2492 (widget-insert "\n") |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2493 (widget-create 'push-button |
72093
e75e38c3a62f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72091
diff
changeset
|
2494 :notify |
72019
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2495 (lambda (&rest ignore) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2496 (tumme-save-information-from-widgets) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2497 (bury-buffer) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2498 (message "Done.")) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2499 "Save") |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2500 (widget-insert " ") |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2501 (widget-create 'push-button |
72093
e75e38c3a62f
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72091
diff
changeset
|
2502 :notify |
72019
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2503 (lambda (&rest ignore) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2504 (bury-buffer) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2505 (message "Operation canceled.")) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2506 "Cancel") |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2507 (widget-insert "\n") |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2508 (use-local-map widget-keymap) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2509 (widget-setup) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2510 ;; Jump to the first widget. |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2511 (widget-forward 1))) |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2512 |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2513 (defun tumme-save-information-from-widgets () |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2514 "Save information found in `tumme-widget-list'. |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2515 Use the information in `tumme-widget-list' to save comments and |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2516 tags to their respective image file. Internal function used by |
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2517 `tumme-dired-edit-comment-and-tags'." |
72089
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
2518 (let (file comment tag-string tag-list lst) |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
2519 (tumme-write-comments |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
2520 (mapcar |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
2521 (lambda (widget) |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
2522 (setq file (car widget) |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
2523 comment (widget-value (cadr widget))) |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
2524 (cons file comment)) |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
2525 tumme-widget-list)) |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
2526 (tumme-write-tags |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
2527 (dolist (widget tumme-widget-list lst) |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
2528 (setq file (car widget) |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
2529 tag-string (widget-value (car (cddr widget))) |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
2530 tag-list (split-string tag-string ",")) |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
2531 (dolist (tag tag-list) |
d2f7e6fe7dbf
(tumme-write-tags): Add.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72087
diff
changeset
|
2532 (push (cons file tag) lst)))))) |
72019
43d3a49f9bd4
(tumme-display-thumbnail-original-image): Make sure
Mathias Dahl <mathias.dahl@gmail.com>
parents:
72017
diff
changeset
|
2533 |
67302 | 2534 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2535 ;;;;;;;;; TEST-SECTION ;;;;;;;;;;; | |
2536 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
2537 | |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2538 ;; (defvar tumme-dir-max-size 12300000) |
67302 | 2539 |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2540 ;; (defun tumme-test-clean-old-files () |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2541 ;; "Clean `tumme-dir' from old thumbnail files. |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2542 ;; \"Oldness\" measured using last access time. If the total size of all |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2543 ;; thumbnail files in `tumme-dir' is larger than 'tumme-dir-max-size', |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2544 ;; old files are deleted until the max size is reached." |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2545 ;; (let* ((files |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2546 ;; (sort |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2547 ;; (mapcar |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2548 ;; (lambda (f) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2549 ;; (let ((fattribs (file-attributes f))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2550 ;; ;; Get last access time and file size |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2551 ;; `(,(nth 4 fattribs) ,(nth 7 fattribs) ,f))) |
68783
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
2552 ;; (directory-files (tumme-dir) t ".+\.thumb\..+$")) |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2553 ;; ;; Sort function. Compare time between two files. |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2554 ;; '(lambda (l1 l2) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2555 ;; (time-less-p (car l1) (car l2))))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2556 ;; (dirsize (apply '+ (mapcar (lambda (x) (cadr x)) files)))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2557 ;; (while (> dirsize tumme-dir-max-size) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2558 ;; (y-or-n-p |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2559 ;; (format "Size of thumbnail directory: %d, delete old file %s? " |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2560 ;; dirsize (cadr (cdar files)))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2561 ;; (delete-file (cadr (cdar files))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2562 ;; (setq dirsize (- dirsize (car (cdar files)))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2563 ;; (setq files (cdr files))))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2564 |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2565 ;;;;;;;;;;;;;;;;;;;;;;, |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2566 |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2567 ;; (defun dired-speedbar-buttons (dired-buffer) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2568 ;; (when (and (boundp 'tumme-use-speedbar) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2569 ;; tumme-use-speedbar) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2570 ;; (let ((filename (with-current-buffer dired-buffer |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2571 ;; (dired-get-filename)))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2572 ;; (when (and (not (string-equal filename (buffer-string))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2573 ;; (string-match (image-file-name-regexp) filename)) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2574 ;; (erase-buffer) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2575 ;; (insert (propertize |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2576 ;; filename |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2577 ;; 'display |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2578 ;; (tumme-get-thumbnail-image filename))))))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2579 |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2580 ;; (setq tumme-use-speedbar t) |
67302 | 2581 |
2582 (provide 'tumme) | |
2583 | |
67318 | 2584 ;; arch-tag: 9d11411d-331f-4380-8b44-8adfe3a0343e |
67302 | 2585 ;;; tumme.el ends here |