Mercurial > emacs
annotate lisp/tumme.el @ 68833:207844891bb3
(tumme-thumbnail-storage): Updated docstring. Added
info about the Thumbnail Managing Standard option.
author | Mathias Dahl <mathias.dahl@gmail.com> |
---|---|
date | Sun, 12 Feb 2006 22:15:05 +0000 |
parents | 3e8cc27a9bcf |
children | cc7307c60e45 |
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 ;; | |
87 ;; If you plan to use tumme much, setting up key bindings for it in | |
88 ;; dired is a good idea: | |
89 ;; | |
90 ;; (tumme-setup-dired-keybindings) | |
91 ;; | |
92 ;; Next, do M-x tumme-dired RET. This will ask you for a directory | |
93 ;; where image files are stored, setup a useful window configuration | |
94 ;; and enable the two special modes that tumme provides. NOTE: If you | |
95 ;; do not want tumme to split your windows, call it with a prefix | |
96 ;; argument. | |
97 ;; | |
98 ;; Start viewing thumbnails by doing C-S-n and C-S-p to go up and down | |
99 ;; in the dired buffer while at the same time displaying a thumbnail | |
100 ;; image. The thumbnail images will be created on the fly, and | |
101 ;; cached. This means that the first time you browse your images, it | |
102 ;; will be a bit slow because the thumbnails are created. If you want | |
103 ;; to avoid this, you can pre-create the thumbnail images by marking | |
104 ;; all images in dired (% m \.jpg$ RET) and then do M-x | |
105 ;; tumme-create-thumbs. | |
106 ;; | |
107 ;; Next, try `tumme-display-thumbs' (C-t d). If no file is marked, a | |
108 ;; thumbnail for the file at point will show up in | |
109 ;; `tumme-thumbnail-buffer'. If one or more files are marked, | |
110 ;; thumbnails for those files will be displayed. | |
111 ;; | |
112 ;; Pressing TAB will switch to the window containing the | |
113 ;; `tumme-thumbnail-buffer' buffer. In there you can move between | |
114 ;; thumbnail images and display a semi-sized version in an Emacs | |
115 ;; buffer (RET), or the original image in an external viewer | |
116 ;; (C-RET). By pressing SPC or DEL you will navigate back and fort | |
117 ;; while at the same time displaying each image in Emacs. You can also | |
118 ;; navigate using arrow keys. Comment a file by pressing "c". Press | |
119 ;; TAB to get back to dired. | |
120 ;; | |
121 ;; While in dired mode, you can tag and comment files, you can tell | |
122 ;; `tumme' to mark files with a certain tag (using a regexp) etc. | |
123 ;; | |
124 ;; The easiest way to see the available commands is to use the Tumme | |
125 ;; menus added in tumme-thumbnail-mode and dired-mode. | |
126 ;; | |
127 ;; | |
128 ;; LIMITATIONS | |
129 ;; =========== | |
130 ;; | |
131 ;; * Supports all image formats that Emacs and convert supports, but | |
132 ;; the thumbnails are hard-coded to JPEG format. | |
133 ;; | |
134 ;; * WARNING: The "database" format used might be changed so keep a | |
135 ;; backup of `tumme-db-file' when testing new versions. | |
136 ;; | |
137 ;; | |
138 ;;; History: | |
139 ;; ======== | |
140 ;; | |
141 ;; Version 0.1, 2005-04-16 | |
142 ;; | |
143 ;; * First release, only browsing support for now. | |
144 ;; | |
145 ;; Version 0.2, 2005-04-21 | |
146 ;; | |
147 ;; * Changed calls to dired-filename-at-point to dired-get-filename | |
148 ;; | |
149 ;; Version 0.3, 2005-04-25 | |
150 ;; | |
151 ;; Quite a lot of changes: | |
152 ;; | |
153 ;; * Added basic image tagging support. No commands that make use of | |
154 ;; it yet. | |
155 ;; | |
156 ;; * Added text properties for the thumbnail images to be able to | |
157 ;; track where they came from originally. Used in `tumme-mode'. | |
158 ;; | |
159 ;; * Added `tumme-mode' to be used when navigating the thumbnail | |
160 ;; buffer. Currently, there are commands to mark, unmark, flag and | |
161 ;; jump to the original file in associated dired buffer. | |
162 ;; | |
163 ;; * When moving around in the thumbnail buffer (in `tumme-mode'), the | |
164 ;; user can turn on tracking of the movements and let them be | |
165 ;; mirrored in the associated dired buffer. | |
166 ;; | |
167 ;; * In this version I have been looking at some ideas in thumbs.el, | |
168 ;; for example the image margin and relief and the `thumbs-mode' | |
169 ;; which I copied and made the `tumme-mode' from. | |
170 ;; | |
171 ;; Version 0.4, 2005-05-02 | |
172 ;; | |
173 ;; * Renamed the functions that are to be used in `tumme-mode' in the | |
174 ;; thumbnail buffer. | |
175 ;; | |
176 ;; * The mark, unmark and flag commands in `tumme-mode' now also moves | |
177 ;; to next thumbnail, like how dired normally works. | |
178 ;; | |
179 ;; * Added `tumme-mode-line-up', `tumme-display-thumbs-append' and | |
180 ;; `tumme-mode-delete-char'. | |
181 ;; | |
182 ;; * Each thumbnail's tags is now displayed when navigating among the | |
183 ;; thumbnails in the thumbnail buffer. | |
184 ;; | |
185 ;; * Added simple slideshow functionality. | |
186 ;; | |
187 ;; Version 0.4.1, 2005-05-05 | |
188 ;; | |
189 ;; * Fixed bug in `tumme-flag-thumb-original-file' | |
190 ;; | |
191 ;; * Added commands to display original image in external viewer | |
192 ;; (`tumme-display-external') and in a Emacs buffer | |
193 ;; (`tumme-display-image'). | |
194 ;; | |
195 ;; * Minor code clean-up | |
196 ;; | |
197 ;; * Renamed some functions back again... | |
198 ;; | |
199 ;; * Added rotation of thumbnail images (90 degrees left and right) | |
200 ;; | |
201 ;; Version 0.4.2, 2005-05-06 | |
202 ;; | |
203 ;; * Removed need for `tumme-display-image-size' in | |
204 ;; `tumme-display-image'. Now, the maximum image size that fits in | |
205 ;; `tumme-display-buffer' is calculated automatically. Introduced | |
206 ;; two correction variables, `tumme-display-window-width-correction' | |
207 ;; and `tumme-display-window-height-correction' to be used to | |
208 ;; correct width and height depending on width and height of window | |
209 ;; decorations, fringes etc. This works really well! | |
210 ;; | |
211 ;; Version 0.4.3, 2005-05-07 | |
212 ;; | |
213 ;; * Added menus to `dired-mode' and `tumme-mode' | |
214 ;; | |
215 ;; * Added `tumme-mark-and-display-next' | |
216 ;; | |
217 ;; * Added `tumme-jump-thumbnail-buffer' | |
218 ;; | |
219 ;; * Bound TAB in `dired-mode-map' and `tumme-mode-map' to | |
220 ;; `tumme-jump-thumbnail-buffer' and | |
221 ;; `tumme-jump-original-dired-buffer', respectively. | |
222 ;; | |
223 ;; * Changed `tumme-display-image' to be more general. Now, it can be | |
224 ;; used from both thumbnail buffer and dired buffer by calling | |
225 ;; `tumme-display-thumbnail-original-image' and | |
226 ;; `tumme-display-dired-image', respectively. | |
227 ;; | |
228 ;; Version 0.4.4, 2005-05-10 | |
229 ;; | |
230 ;; * Added `tumme-get-exif-file-name' and | |
231 ;; `tumme-copy-with-exif-file-name'. These commands might not be | |
232 ;; useful for all people because they are very specific. See the | |
233 ;; documentation for each function for more information. | |
234 ;; | |
235 ;; * Added `tumme-display-next-thumbnail-original' and | |
236 ;; `tumme-display-previous-thumbnail-original' to be used for easy | |
237 ;; image browsing in thumbnail buffer. | |
238 ;; | |
239 ;; * Added support for comments. New function | |
240 ;; `tumme-comment-thumbnail' added, to be used in thumbnail buffer. | |
241 ;; | |
242 ;; * Added `tumme-mark-tagged-files'. Use it in dired buffer to mark | |
243 ;; tagged files. | |
244 ;; | |
245 ;; * Added `mouse-face' property `highlight' for mouse highlighting | |
246 ;; and had to add a space between each thumbnail to avoid whole rows | |
247 ;; to be highlighted. Doing this meant that I had to update | |
248 ;; `tumme-line-up' too... | |
249 ;; | |
250 ;; * Added `tumme-mouse-display-image'. Use mouse-2 to display image | |
251 ;; thumbnail when is highlighted. | |
252 ;; | |
253 ;; * As suggested by Ehud Karni on gnu.emacs.help, changed | |
254 ;; `tumme-window-DIMENSION-pixels' to use `frame-char-DIMENSION' | |
255 ;; instead of `frame-pixel-DIMENSION'. Feels better | |
256 ;; | |
257 ;; * Corrected a bug in `tumme-window-height-pixels'. I did not know | |
258 ;; that the mode-line consumed one line. Also, after experimenting, it | |
259 ;; seems that the only correction needed for the image display width | |
260 ;; is one single pixel. I left the corection variables in there, just | |
261 ;; in case someone has a system that differs. | |
262 ;; | |
263 ;; Version 0.4.5, 2005-05-19 | |
264 ;; | |
265 ;; * Added `tumme-line-up-dynamic' that calculates the number of | |
266 ;; thumbnails that will fit in the thumbnail buffer's window and | |
267 ;; `tumme-line-up-interactive' that asks the user. | |
268 ;; | |
269 ;; * Changed `tumme-display-thumbs' to call one of the `tumme-line-up' | |
270 ;; functions instead of doing the line-up itself. | |
271 ;; | |
272 ;; * Finally! Added experimental gallery creation. See customizable | |
273 ;; variables `tumme-gallery-dir', `tumme-gallery-image-root-url' and | |
274 ;; `tumme-gallery-thumb-image-root-url' and new command | |
275 ;; `tumme-gallery-generate'. Not beatiful, but it works quite | |
276 ;; well. Probably needs some CSS-stuff in it eventually. Also, I'm not | |
277 ;; sure this is the way I want to generate my image galleries in the | |
278 ;; future. After all, static pages cannot do what dynamic pages using | |
279 ;; PHP et al can do. Serves like a proof-of-concept of the tagging | |
280 ;; though. | |
281 ;; | |
282 ;; * Added option to hide images with certain tags. See | |
283 ;; `tumme-gallery-hidden-tags'. | |
284 ;; | |
285 ;; * Added `tumme-tag-thumbnail' for tagging files from thumbnail | |
286 ;; buffer. | |
287 ;; | |
288 ;; * Added `tumme-tag-remove' and `tumme-tag-thumbnail-remove' so that | |
289 ;; you can remove tags. Sorry if I have kept you waiting for | |
290 ;; this... :) | |
291 ;; | |
292 ;; * Added option `tumme-append-when-browsing' and new command | |
293 ;; `tumme-toggle-append-browsing'. | |
294 ;; | |
295 ;; Version 0.4.6, 2005-05-21 | |
296 ;; | |
297 ;; * Changed `tumme-thumb-name' to always use ".jpg" as file extension | |
298 ;; for thumbnail files, instead of using the extension from the | |
299 ;; original file's name. This was a very easy way to open up for | |
300 ;; allowing browsing of all image file types that Emacs support, | |
301 ;; assuming ImageMagick supports it too. | |
302 ;; | |
303 ;; * Fixed bug in `tumme-create-thumb' `tumme-rotate-thumbnail' and | |
304 ;; `tumme-display-image' by adding quotes around the file names. The | |
305 ;; conversion failed if the file name, or path, contained a | |
306 ;; space. Also expanded the file name, as convert (or is it bash?) | |
307 ;; does not work as expected for paths like "~/.tumme...". | |
308 ;; | |
309 ;; * Fixed another "space bug" :) in `tumme-display-external'. | |
310 ;; | |
311 ;; * In call to convert, added "jpeg:" in front of the output file | |
312 ;; name, so that all generated files becomes JPEG files. For now, only | |
313 ;; useful if `tumme-temp-image-file' does not end in .jpg. | |
314 ;; | |
315 ;; Version 0.4.7, 2005-05-26 | |
316 ;; | |
317 ;; * Change header line of tumme.el so that it does not wrap and cause | |
318 ;; evaluation problems for people getting the source from Usenet. | |
319 ;; | |
320 ;; * Changed `tumme-write-tag' slightly to get better performance when | |
321 ;; tagging many files. | |
322 ;; | |
323 ;; * Fixed bug in `tumme-create-gallery-lists' that made it puke if | |
324 ;; there was empty lines in the database. Changed the code so that it | |
325 ;; does not car about that. Also, fixed `tumme-remove-tag' so that it | |
326 ;; tries not to add empty lines at the end of the database. | |
327 ;; | |
328 ;; * Changed all commands that execute shell commands to be | |
329 ;; configurable using the `tumme-cmd-x' custom variables. This makes | |
330 ;; it easier to switch among different image conversion tools which | |
331 ;; might use different syntax and options. | |
332 ;; | |
333 ;; * Added `tumme-toggle-dired-display-properties'. | |
334 ;; | |
335 ;; * Added `tumme-thumb-file-name-format' and changed | |
336 ;; `tumme-thumb-name' to make it possible to configure the format of | |
337 ;; thumbnail files. Did not make it customizable yet though. It might | |
338 ;; be a bad idea to be able to switch between formats... | |
339 ;; | |
340 ;; * Changed `tumme-display-window' so that it looks for tumme's | |
341 ;; display window in all frames. Useful if you want to create an own | |
342 ;; frame for displaying the temporary image. | |
343 ;; | |
344 ;; * After changing the call to `get-window-with-predicate' to scan | |
345 ;; all frames for tumme's special buffers in visible windows, and also | |
346 ;; changing the way tumme tracks thumbnail movement in the dired | |
347 ;; buffer (now using `set-buffer' together with `set-window-point'), | |
348 ;; tumme now works quite happily with all three buffers in different | |
349 ;; frames. This empowers the user to setup the special buffers the way | |
350 ;; that best fits his need at the time. Jumping between dired and | |
351 ;; `tumme-thumbnail-buffer' work independent on in which frames they | |
352 ;; are. | |
353 ;; | |
354 ;; * Renamed `tumme-track-movement-in-dired' to | |
355 ;; `tumme-toggle-movement-tracking'. | |
356 ;; | |
357 ;; * Added `tumme-track-thumbnail' for movement tracking from dired | |
358 ;; buffer, analoguous to the tracking done in thumbnail buffer. Both | |
359 ;; uses the same custom variable `tumme-track-movement' which can be | |
360 ;; toggled on and off with `tumme-toggle-movement-tracking'. This is | |
361 ;; neat. :) Changed `tumme-setup-dired-keybindings' to make use of | |
362 ;; this in the best way. Read more about this there. | |
363 ;; | |
364 ;; Version 0.4.8, 2005-06-05 | |
365 ;; | |
366 ;; * Changed `tumme-display-dired-image' and | |
367 ;; `tumme-display-thumbnail-original-image' so that when called with a | |
368 ;; prefix argument, the image is not resized in the display | |
369 ;; buffer. This will be useful for later additions of image | |
370 ;; manipulation commands. | |
371 ;; | |
372 ;; * Added `tumme-kill-buffer-and-window' to make it easy to kill the | |
373 ;; tumme buffers. | |
374 ;; | |
375 ;; * Renamed `tumme-mode' to `tumme-thumbnail-mode'. | |
376 ;; | |
377 ;; * `tumme-tag-thumbnail' and `tumme-tag-thumbnail-remove' now | |
378 ;; updates the tags property for the thumbnail. | |
379 ;; | |
380 ;; * Added `tumme-dired-display-external' to display images in | |
381 ;; external viewer from dired buffer. | |
382 ;; | |
383 ;; * Added support for multiple files in `tumme-remove-tag' to | |
384 ;; increase performance. | |
385 ;; | |
386 ;; * Added `tumme-display-image-mode' so that we can add image | |
387 ;; manipulation commands there. | |
388 ;; | |
389 ;; * Added call to `tumme-display-thumb-properties' in | |
390 ;; `tumme-track-thumbnail'. | |
391 ;; | |
392 ;; * Added command `tumme-display-current-image-in-full-size' to be | |
393 ;; used in `tumme-display-image-mode'. | |
394 ;; | |
395 ;; * Changed `tumme-display-image' to call | |
396 ;; `tumme-create-display-image-buffer' so that we are sure that | |
397 ;; `tumme-display-image-buffer' is always available. | |
398 ;; | |
399 ;; * Added optional prefix argument to `tumme-dired-folder' that tells | |
400 ;; it to skip the window splitting and just creates the needed | |
401 ;; buffers. | |
402 ;; | |
403 ;; * Fixed bug somewhere that relied on `tumme-dired-folder' having | |
404 ;; created the `tumme-display-image-buffer'. Now `tumme-dired-folder' | |
405 ;; *should* not be necessary to call at all, just convenient. | |
406 ;; | |
407 ;; * Added tracking to `tumme-mouse-display-image'. | |
408 ;; | |
409 ;; * Added `tumme-mouse-select-thumbnail' and bound mouse-1 to it, so | |
410 ;; that selecting a thumbnail will track the original file. | |
411 ;; | |
412 ;; * Added three new custom variables, `tumme-cmd-ACTION-program' to | |
413 ;; make the command options cleaner and easier to read. | |
414 ;; | |
415 ;; * Added `tumme-display-properties-format' and | |
416 ;; `tumme-format-properties-string' to make it possible to configure | |
417 ;; the display format of the image file's properties. | |
418 ;; | |
419 ;; * Added missing (require 'format-spec) | |
420 ;; | |
421 ;; Version 0.4.9, 2005-09-25 | |
422 ;; | |
423 ;; * Fixed bug in `tumme-display-thumbs'. If a thumbnail file could | |
424 ;; not be created for some reason (bad file for example), even if | |
425 ;; several other thumbnails was created sucessfully, the code | |
426 ;; generated an error and never continued doing the line-up. | |
427 ;; | |
428 ;; * Made tumme.el pass the M-x checkdoc test, phew! | |
429 ;; | |
430 ;; * Added `tumme-rotate-original', `tumme-rotate-original-left' and | |
431 ;; `tumme-rotate-original-right' to rotate the original image from | |
432 ;; thumbnail view. By default it uses JpegTRAN to rotate the images | |
433 ;; non-lossy. Only works on JPEG images. The two new commands were | |
434 ;; added to thumbnail mode. Thanks to Colin Marquardt who told me | |
435 ;; about the "-copy all" option to jpegtran. | |
436 ;; | |
437 ;; * Added the functions `tumme-get-exif-data' and | |
438 ;; `tumme-set-exif-data' for reading and writing EXIF data to image files. | |
439 ;; | |
440 ;; * Rewrote `tumme-get-exif-file-name': now uses | |
441 ;; `tumme-get-exif-data'. Slight change to replace spaces with | |
442 ;; underscores (tt seems not all cameras use the exact same format for | |
443 ;; DateTimeOriginal). Added code for handling files that has no | |
444 ;; EXIF-data (use file's timestamp instead). | |
445 ;; | |
446 ;; * Changed from using the exif program to exiftool because exiftool | |
447 ;; also handles writing of EXIF data, which is very useful. | |
448 ;; | |
449 ;; * Added the command `tumme-thumbnail-set-image-description' that | |
450 ;; can be used to set the EXIF tag ImageDescription. Thanks to Colin | |
451 ;; Marquardt for the suggestion. | |
452 ;; | |
453 ;; * Added `tumme-toggle-mark-thumb-original-file' and | |
454 ;; `tumme-mouse-toggle-mark' and changed | |
455 ;; `tumme-modify-mark-on-thumb-original-file' to support toggling of | |
456 ;; mark of original image file in dired, from | |
457 ;; `tumme-thumbnail-mode'. Bound C-down-mouse-1 | |
458 ;; `tumme-mouse-toggle-mark' to in `tumme-thumbnail-mode'. | |
459 ;; | |
460 ;; * Changed `tumme-mouse-select-thumbnail' to also display properties | |
461 ;; after the file is selected. | |
462 ;; | |
463 ;; Version 0.4.10, 2005-11-07 | |
464 ;; | |
465 ;; * Renamed `tumme-dired-folder' to `tumme-dired'. | |
466 ;; | |
467 ;; * Changed format of the database file slightly, now the full path | |
468 ;; and file name is used. Had to change most of the tag functions | |
469 ;; (writing, reading, searching) slightly to cope with the change. If | |
470 ;; you are an old tumme user, you have to update your database | |
471 ;; manually, probably you only need to prefix all rows with a | |
472 ;; directory name to get the full path and file name. | |
473 ;; | |
474 ;; * Removed `tumme-thumb-file-name-format'. Added | |
475 ;; `tumme-thumbnail-storage' and changed `tumme-thumb-name' to provide | |
476 ;; two different thumbnail storage schemes. It is no longer necessary | |
477 ;; to have unique image file names to use tumme fully. | |
478 ;; | |
479 ;; * As a consequence of the above, gallery generation is currently | |
480 ;; not supported if per-directory thumbnail file storage is used. | |
481 ;; | |
482 ;; * Changed parameters to `tumme-create-thumb'. | |
483 ;; | |
484 ;; * To be included in Emacs 22. | |
485 ;; | |
486 ;; | |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
487 ;; Version 0.4.11, 2006-MM-DD |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
488 ;; |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
489 ;; * Changed `tumme-display-thumbs' so that it calls `display-buffer' |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
490 ;; after generating the thumbnails and changed |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
491 ;; `tumme-display-thumbnail-original-image' to display the image |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
492 ;; buffer. These small changes should make it easier for a user to |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
493 ;; start using tumme. |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
494 ;; |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
495 ;; * Added `tumme-show-all-from-dir' to mimic thumbs.el's easy-to-use |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
496 ;; `thumbs' command. A new customize option, |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
497 ;; `tumme-show-all-from-dir-max-files' was added too. |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
498 ;; |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
499 ;; * Renamed `tumme-dired' to `tumme-dired-with-window-configuration' |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
500 ;; and added code to save the window configuration before messing it |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
501 ;; up. The saved window configuration can be restored using the new |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
502 ;; command `tumme-restore-window-configuration'. |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
503 ;; |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
504 ;; * Added `tumme-get-thumbnail-image', created by Chong Yidong. His |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
505 ;; own comments: ..., that just takes the original filename and |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
506 ;; returns a thumbnail image descriptor. Then third-party libraries |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
507 ;; won't have to muck around with tumme.el's internal functions like |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
508 ;; `thumme-thumb-name', `tumme-create-thumb', etc. His code to get |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
509 ;; speedbar display tumme thumbnails, might be integrated soon. |
67302 | 510 ;; |
68783
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
511 ;; * Changed the default value of `tumme-dir' to "~/.emacs.d/tumme" |
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
512 ;; and added a new function, `tumme-dir' to handle the creating of |
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
513 ;; it. Code copied from thumbs.el. |
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
514 ;; |
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
515 ;; |
67302 | 516 ;; TODO |
517 ;; ==== | |
518 ;; | |
519 ;; * Support gallery creation when using per-directory thumbnail | |
520 ;; storage. | |
521 ;; | |
522 ;; * Some sort of auto-rotate function based on rotate info in the | |
523 ;; EXIF data. | |
524 ;; | |
525 ;; * Check if exiftool exist before trying to call it to give a better | |
526 ;; error message. | |
527 ;; | |
528 ;; * Investigate if it is possible to also write the tags to the image | |
529 ;; files. | |
530 ;; | |
531 ;; * 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
|
532 ;; for thumbnail directory. |
67302 | 533 ;; |
534 ;; * From thumbs.el: Add setroot function. | |
535 ;; | |
68754
9c1ca2e3695c
Added a few todo items.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68682
diff
changeset
|
536 ;; * 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
|
537 ;; "image fit" might be enough) |
9c1ca2e3695c
Added a few todo items.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68682
diff
changeset
|
538 ;; |
9c1ca2e3695c
Added a few todo items.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68682
diff
changeset
|
539 ;; * 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
|
540 ;; monochrome etc). |
9c1ca2e3695c
Added a few todo items.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68682
diff
changeset
|
541 ;; |
67302 | 542 ;; * Asynchronous creation of thumbnails. |
543 ;; | |
544 ;; * Add `tumme-display-thumbs-ring' and functions to cycle that. Find | |
545 ;; out which is best, saving old batch just before inserting new, or | |
546 ;; saving the current batch in the ring when inserting it. Adding it | |
547 ;; probably needs rewriting `tumme-display-thumbs' to be more general. | |
548 ;; | |
549 ;; * Find some way of toggling on and off really nice keybindings in | |
550 ;; dired (for example, using C-n or <down> instead of C-S-n). Richard | |
551 ;; suggested that we could keep C-t as prefix for tumme commands as it | |
552 ;; is currently not used in dired. He also suggested that | |
553 ;; `dired-next-line' and `dired-previous-line' figure out if tumme is | |
554 ;; enabled in the current buffer and, if it is, call | |
555 ;; `tumme-dired-next-line' and `tumme-dired-previous-line', | |
68806
3e96b0954fa1
Enhanced some docstrings. Added todo item about the Thumbnail
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68783
diff
changeset
|
556 ;; respectively. Update: This is partly done; some bindings have now |
3e96b0954fa1
Enhanced some docstrings. Added todo item about the Thumbnail
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68783
diff
changeset
|
557 ;; been added to dired. |
67302 | 558 ;; |
559 ;; * Enhanced gallery creation with basic CSS-support and pagination | |
560 ;; of tag pages with many pictures. | |
561 ;; | |
562 ;; * Rewrite `tumme-modify-mark-on-thumb-original-file' to be less | |
563 ;; ugly. | |
564 ;; | |
565 ;; * In some way keep track of buffers and windows and stuff so that | |
566 ;; it works as the user expects. | |
567 ;; | |
568 ;; * More/better documentation | |
569 ;; | |
570 ;; | |
571 ;;; Code: | |
572 | |
573 (require 'dired) | |
574 (require 'format-spec) | |
575 | |
576 (defgroup tumme nil | |
577 "Use dired to browse your images as thumbnails, and more." | |
578 :prefix "tumme-" | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
579 :group 'multimedia) |
67302 | 580 |
68783
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
581 (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
|
582 "*Directory where thumbnail images are stored." |
67302 | 583 :type 'string |
584 :group 'tumme) | |
585 | |
586 (defcustom tumme-thumbnail-storage 'use-tumme-dir | |
587 "*How to store tumme's thumbnail files. | |
588 Tumme can store thumbnail files in one of two ways and this is | |
589 controlled by this variable. \"Use tumme dir\" means that the | |
590 thumbnails are stored in a central directory. \"Per directory\" | |
591 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
|
592 \".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
|
593 \"Thumbnail Managing Standard\" means that the thumbnails are |
207844891bb3
(tumme-thumbnail-storage): Updated docstring. Added
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68815
diff
changeset
|
594 stored and generated according to the Thumbnail Managing |
207844891bb3
(tumme-thumbnail-storage): Updated docstring. Added
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68815
diff
changeset
|
595 Standard." |
67302 | 596 :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
|
597 (const :tag "Thumbnail Managing Standard" standard) |
67302 | 598 (const :tag "Use tumme-dir" use-tumme-dir) |
599 (const :tag "Per-directory" per-directory)) | |
600 :group 'tumme) | |
601 | |
68783
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
602 (defcustom tumme-db-file "~/.emacs.d/tumme/.tumme_db" |
67302 | 603 "*Database file where file names and their associated tags are stored." |
604 :type 'string | |
605 :group 'tumme) | |
606 | |
68783
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
607 (defcustom tumme-temp-image-file "~/.emacs.d/tumme/.tumme_temp" |
67302 | 608 "*Name of temporary image file used by various commands." |
609 :type 'string | |
610 :group 'tumme) | |
611 | |
68783
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
612 (defcustom tumme-gallery-dir "~/.emacs.d/tumme/.tumme_gallery" |
67302 | 613 "*Directory to store generated gallery html pages. |
614 This path needs to be \"shared\" to the public so that it can access | |
615 the index.html page that tumme creates." | |
616 :type 'string | |
617 :group 'tumme) | |
618 | |
619 (defcustom tumme-gallery-image-root-url | |
620 "http://your.own.server/tummepics" | |
621 "*URL where the full size images are to be found. | |
622 Note that this path has to be configured in your web server. Tumme | |
623 expects to find pictures in this directory." | |
624 :type 'string | |
625 :group 'tumme) | |
626 | |
627 (defcustom tumme-gallery-thumb-image-root-url | |
628 "http://your.own.server/tummethumbs" | |
629 "*URL where the thumbnail images are to be found. | |
630 Note that this path has to be configured in your web server. Tumme | |
631 expects to find pictures in this directory." | |
632 :type 'string | |
633 :group 'tumme) | |
634 | |
635 (defcustom tumme-cmd-create-thumbnail-program | |
636 "convert" | |
637 "*Executable used to create thumbnail. | |
638 Used together with `tumme-cmd-create-thumbnail-options'." | |
639 :type 'string | |
640 :group 'tumme) | |
641 | |
642 (defcustom tumme-cmd-create-thumbnail-options | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
643 "%p -size %wx%h \"%f\" -resize %wx%h +profile \"*\" jpeg:\"%t\"" |
67302 | 644 "*Format of command used to create thumbnail image. |
645 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
|
646 `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
|
647 `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
|
648 %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
|
649 which is replaced by the file name of the thumbnail file." |
67302 | 650 :type 'string |
651 :group 'tumme) | |
652 | |
653 (defcustom tumme-cmd-create-temp-image-program | |
654 "convert" | |
655 "*Executable used to create temporary image. | |
656 Used together with `tumme-cmd-create-temp-image-options'." | |
657 :type 'string | |
658 :group 'tumme) | |
659 | |
660 (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
|
661 "%p -size %wx%h \"%f\" -resize %wx%h +profile \"*\" jpeg:\"%t\"" |
67302 | 662 "*Format of command used to create temporary image for display window. |
663 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
|
664 `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
|
665 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
|
666 %f which is replaced by the file name of the original image and %t which |
67302 | 667 is replaced by the file name of the temporary file." |
668 :type 'string | |
669 :group 'tumme) | |
670 | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
671 (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
|
672 "*The file name of the `pngnq' program. |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
673 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
|
674 :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
|
675 :group 'tumme) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
676 |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
677 (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
|
678 "*The file name of the `pngcrush' program. |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
679 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
|
680 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
|
681 :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
|
682 :group 'tumme) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
683 |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
684 (defcustom tumme-cmd-create-standard-thumbnail-command |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
685 (concat |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
686 tumme-cmd-create-thumbnail-program " " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
687 "-size %wx%h \"%f\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
688 (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
|
689 (concat |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
690 "-set \"Thumb::MTime\" \"%m\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
691 "-set \"Thumb::URI\" \"file://%f\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
692 "-set \"Description\" \"Thumbnail of file://%f\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
693 "-set \"Software\" \"" (emacs-version) "\" ")) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
694 "-thumbnail %wx%h png:\"%t\"" |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
695 (if tumme-cmd-pngnq-program |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
696 (concat |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
697 " ; " tumme-cmd-pngnq-program " -f \"%t\"" |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
698 (unless tumme-cmd-pngcrush-program |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
699 " ; mv %q %t"))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
700 (if tumme-cmd-pngcrush-program |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
701 (concat |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
702 (unless tumme-cmd-pngcrush-program |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
703 " ; cp %t %q") |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
704 " ; " tumme-cmd-pngcrush-program " -q " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
705 "-text b \"Description\" \"Thumbnail of file://%f\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
706 "-text b \"Software\" \"" (emacs-version) "\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
707 ;; "-text b \"Thumb::Image::Height\" \"%oh\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
708 ;; "-text b \"Thumb::Image::Mimetype\" \"%mime\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
709 ;; "-text b \"Thumb::Image::Width\" \"%ow\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
710 "-text b \"Thumb::MTime\" \"%m\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
711 ;; "-text b \"Thumb::Size\" \"%b\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
712 "-text b \"Thumb::URI\" \"file://%f\" " |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
713 "%q %t" |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
714 " ; rm %q"))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
715 "*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
|
716 :type 'string |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
717 :group 'tumme) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
718 |
67302 | 719 (defcustom tumme-cmd-rotate-thumbnail-program |
720 "mogrify" | |
721 "*Executable used to rotate thumbnail. | |
722 Used together with `tumme-cmd-rotate-thumbnail-options'." | |
723 :type 'string | |
724 :group 'tumme) | |
725 | |
726 (defcustom tumme-cmd-rotate-thumbnail-options | |
727 "%p -rotate %d \"%t\"" | |
728 "*Format of command used to rotate thumbnail image. | |
729 Available options are %p which is replaced by | |
730 `tumme-cmd-rotate-thumbnail-program', %d which is replaced by the | |
731 number of (positive) degrees to rotate the image, normally 90 or 270 | |
732 \(for 90 degrees right and left), %t which is replaced by the file name | |
733 of the thumbnail file." | |
734 :type 'string | |
735 :group 'tumme) | |
736 | |
737 (defcustom tumme-cmd-rotate-original-program | |
738 "jpegtran" | |
739 "*Executable used to rotate original image. | |
740 Used together with `tumme-cmd-rotate-original-options'." | |
741 :type 'string | |
742 :group 'tumme) | |
743 | |
744 (defcustom tumme-cmd-rotate-original-options | |
745 "%p -rotate %d -copy all \"%o\" > %t" | |
746 "*Format of command used to rotate original image. | |
747 Available options are %p which is replaced by | |
748 `tumme-cmd-rotate-original-program', %d which is replaced by the | |
749 number of (positive) degrees to rotate the image, normally 90 or | |
750 270 \(for 90 degrees right and left), %o which is replaced by the | |
751 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
|
752 `tumme-temp-image-file'." |
67302 | 753 :type 'string |
754 :group 'tumme) | |
755 | |
756 (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
|
757 "~/.emacs.d/tumme/.tumme_rotate_temp" |
67302 | 758 "*Temporary file for rotate operations." |
759 :type 'string | |
760 :group 'tumme) | |
761 | |
762 (defcustom tumme-rotate-original-ask-before-overwrite t | |
763 "Confirm overwrite of original file after rotate operation. | |
764 If non-nil, ask user for confirmation before overwriting the | |
765 original file with `tumme-temp-rotate-image-file'." | |
766 :type 'boolean | |
767 :group 'tumme) | |
768 | |
769 (defcustom tumme-cmd-write-exif-data-program | |
770 "exiftool" | |
771 "*Program used to write EXIF data to image. | |
772 Used together with `tumme-cmd-write-exif-data-options'." | |
773 :type 'string | |
774 :group 'tumme) | |
775 | |
776 (defcustom tumme-cmd-write-exif-data-options | |
777 "%p -%t=\"%v\" \"%f\"" | |
778 "*Format of command used to write EXIF data. | |
779 Available options are %p which is replaced by | |
780 `tumme-cmd-write-exif-data-program', %f which is replaced by the | |
781 image file name, %t which is replaced by the tag name and %v | |
782 which is replaced by the tag value." | |
783 :type 'string | |
784 :group 'tumme) | |
785 | |
786 (defcustom tumme-cmd-read-exif-data-program | |
787 "exiftool" | |
788 "*Program used to read EXIF data to image. | |
789 Used together with `tumme-cmd-read-exif-data-program-options'." | |
790 :type 'string | |
791 :group 'tumme) | |
792 | |
793 (defcustom tumme-cmd-read-exif-data-options | |
794 "%p -s -s -s -%t \"%f\"" | |
795 "*Format of command used to read EXIF data. | |
796 Available options are %p which is replaced by | |
797 `tumme-cmd-write-exif-data-options', %f which is replaced | |
798 by the image file name and %t which is replaced by the tag name." | |
799 :type 'string | |
800 :group 'tumme) | |
801 | |
802 (defcustom tumme-gallery-hidden-tags | |
803 (list "private" "hidden" "pending") | |
804 "*List of \"hidden\" tags. | |
805 Used by `tumme-gallery-generate' to leave out \"hidden\" images." | |
806 :type '(repeat string) | |
807 :group 'tumme) | |
808 | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
809 (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
|
810 "Size of thumbnails, in pixels. |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
811 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
|
812 :type 'integer |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
813 :group 'tumme) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
814 |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
815 (defcustom tumme-thumb-width tumme-thumb-size |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
816 "Width of thumbnails, in pixels." |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
817 :type 'integer |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
818 :group 'tumme) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
819 |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
820 (defcustom tumme-thumb-height tumme-thumb-size |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
821 "Height of thumbnails, in pixels." |
67302 | 822 :type 'integer |
823 :group 'tumme) | |
824 | |
825 (defcustom tumme-thumb-relief 2 | |
826 "*Size of button-like border around thumbnails." | |
827 :type 'integer | |
828 :group 'tumme) | |
829 | |
830 (defcustom tumme-thumb-margin 2 | |
831 "*Size of the margin around thumbnails. | |
832 This is where you see the cursor." | |
833 :type 'integer | |
834 :group 'tumme) | |
835 | |
836 (defcustom tumme-line-up-method 'dynamic | |
837 "*Default method for line-up of thumbnails in thumbnail buffer. | |
838 Used by `tumme-display-thumbs' and other functions that needs to | |
839 line-up thumbnails. Dynamic means to use the available width of the | |
840 window containing the thumbnail buffer, Fixed means to use | |
841 `tumme-thumbs-per-row', Interactive is for asking the user, and No | |
842 line-up means that no automatic line-up will be done." | |
843 :type '(choice :tag "Default line-up method" | |
844 (const :tag "Dynamic" dynamic) | |
845 (const :tag "Fixed" fixed) | |
846 (const :tag "Interactive" interactive) | |
847 (const :tag "No line-up" none)) | |
848 :group 'tumme) | |
849 | |
850 (defcustom tumme-thumbs-per-row 3 | |
851 "*Number of thumbnails to display per row in thumb buffer." | |
852 :type 'integer | |
853 :group 'tumme) | |
854 | |
855 (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
|
856 "*Number to be used to correct image display window width. |
67302 | 857 Change if the default (1) does not work (i.e. if the image does not |
858 completely fit)." | |
859 :type 'integer | |
860 :group 'tumme) | |
861 | |
862 (defcustom tumme-display-window-height-correction 0 | |
863 "*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
|
864 Change if the default (0) does not work (i.e. if the image does not |
67302 | 865 completely fit)." |
866 :type 'integer | |
867 :group 'tumme) | |
868 | |
869 (defcustom tumme-track-movement nil | |
870 "The current state of the tracking and mirroring. | |
871 For more information, see the documentation for | |
872 `tumme-toggle-movement-tracking'." | |
873 :type 'boolean | |
874 :group 'tumme) | |
875 | |
876 (defcustom tumme-append-when-browsing nil | |
877 "Append thumbnails in thumbnail buffer when browsing. | |
878 If non-nil, using `tumme-next-line-and-display' and | |
879 `tumme-previous-line-and-display' will leave a trail of thumbnail | |
880 images in the thumbnail buffer. If you enable this and want to clean | |
881 the thumbnail buffer because it is filled with too many thumbmnails, | |
882 just call `tumme-display-thumb' to display only the image at point. | |
883 This value can be toggled using `tumme-toggle-append-browsing'." | |
884 :type 'boolean | |
885 :group 'tumme) | |
886 | |
887 (defcustom tumme-dired-disp-props t | |
888 "If non-nil, display properties for dired file when browsing. | |
889 Used by `tumme-next-line-and-display', | |
890 `tumme-previous-line-and-display' and `tumme-mark-and-display-next'. | |
891 If the database file is large, this can slow down image browsing in | |
892 dired and you might want to turn it off." | |
893 :type 'boolean | |
894 :group 'tumme) | |
895 | |
896 (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
|
897 "*Display format for thumbnail properties. |
67302 | 898 %b is replaced with associated dired buffer name, %f with file name |
899 \(without path) of original image file, %t with the list of tags and %c | |
900 with the comment." | |
901 :type 'string | |
902 :group 'tumme) | |
903 | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
904 (defcustom tumme-external-viewer |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
905 ;; TODO: use mailcap, dired-guess-shell-alist-default, dired-view-command-alist |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
906 (cond ((executable-find "display")) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
907 ((executable-find "xli")) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
908 ((executable-find "qiv") "qiv -t")) |
67302 | 909 "*Name of external viewer. |
910 Including parameters. Used when displaying original image from | |
911 `tumme-thumbnail-mode'." | |
912 :type 'string | |
913 :group 'tumme) | |
914 | |
915 (defcustom tumme-main-image-directory "~/pics/" | |
916 "*Name of main image directory, if any. | |
917 Used by `tumme-copy-with-exif-file-name'." | |
918 :type 'string | |
919 :group 'tumme) | |
920 | |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
921 (defcustom tumme-show-all-from-dir-max-files 50 |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
922 "*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
|
923 before warning the user." |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
924 :type 'integer |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
925 :group 'tumme) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
926 |
68783
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
927 (defun tumme-dir () |
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
928 "Return the current thumbnails directory (from `tumme-dir'). |
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
929 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
|
930 (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
|
931 (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
|
932 (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
|
933 (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
|
934 (message "Creating thumbnails directory")) |
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
935 tumme-dir)) |
86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68757
diff
changeset
|
936 |
67302 | 937 (defun tumme-insert-image (file type relief margin) |
938 "Insert image FILE of image TYPE, using RELIEF and MARGIN, at point." | |
939 | |
940 (let ((i `(image :type ,type | |
941 :file ,file | |
942 :relief ,relief | |
943 :margin ,margin))) | |
944 (insert-image i))) | |
945 | |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
946 (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
|
947 "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
|
948 (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
|
949 (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
|
950 (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
|
951 (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
|
952 (<= (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
|
953 (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
|
954 (tumme-create-thumb file thumb-file)) |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
955 (create-image thumb-file) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
956 ;; (list 'image :type 'jpeg |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
957 ;; :file thumb-file |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
958 ;; :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
|
959 )) |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
960 |
67302 | 961 (defun tumme-insert-thumbnail (file original-file-name |
962 associated-dired-buffer) | |
963 "Insert thumbnail image FILE. | |
964 Add text properties ORIGINAL-FILE-NAME and ASSOCIATED-DIRED-BUFFER." | |
965 (let (beg end) | |
966 (setq beg (point)) | |
967 (tumme-insert-image file | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
968 ;; 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
|
969 (if (eq 'standard tumme-thumbnail-storage) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
970 'png 'jpeg) |
67302 | 971 tumme-thumb-relief |
972 tumme-thumb-margin) | |
973 (setq end (point)) | |
974 (add-text-properties | |
975 beg end | |
976 (list 'tumme-thumbnail t | |
977 'original-file-name original-file-name | |
978 'associated-dired-buffer associated-dired-buffer | |
979 'tags (tumme-list-tags original-file-name) | |
980 'mouse-face 'highlight | |
981 'comment (tumme-get-comment original-file-name))))) | |
982 | |
983 (defun tumme-thumb-name (file) | |
984 "Return thumbnail file name for FILE. | |
985 Depending on the value of `tumme-thumbnail-storage', the file | |
986 name will vary. For central thumbnail file storage, make a | |
987 MD5-hash of the image file's directory name and add that to make | |
988 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
|
989 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
|
990 according to the Thumbnail Managing Standard." |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
991 (cond ((eq 'standard tumme-thumbnail-storage) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
992 (expand-file-name |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
993 (concat "~/.thumbnails/normal/" |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
994 (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
|
995 ((eq 'use-tumme-dir tumme-thumbnail-storage) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
996 (let* ((f (expand-file-name file)) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
997 (md5-hash |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
998 ;; 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
|
999 ;; thumbnail file name need not be that |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1000 ;; "cryptographically" good so a faster one could |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1001 ;; be used here. |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1002 (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
|
1003 (format "%s%s%s.thumb.%s" |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1004 (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
|
1005 (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
|
1006 (if md5-hash (concat "_" md5-hash) "") |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1007 (file-name-extension f)))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1008 ((eq 'per-directory tumme-thumbnail-storage) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1009 (let ((f (expand-file-name file))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1010 (format "%s%s%s.thumb.%s" |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1011 (format "%s.tumme/" (file-name-directory f)) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1012 (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
|
1013 (file-name-extension f)))))) |
67302 | 1014 |
1015 (defun tumme-create-thumb (original-file thumbnail-file) | |
1016 "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
|
1017 (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
|
1018 (height (int-to-string tumme-thumb-height)) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1019 (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
|
1020 original-file))))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1021 (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
|
1022 thumbnail-file)) |
67302 | 1023 (command |
1024 (format-spec | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1025 (if (eq 'standard tumme-thumbnail-storage) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1026 tumme-cmd-create-standard-thumbnail-command |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1027 tumme-cmd-create-thumbnail-options) |
67302 | 1028 (list |
1029 (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
|
1030 (cons ?w width) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1031 (cons ?h height) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1032 (cons ?m modif-time) |
67302 | 1033 (cons ?f original-file) |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1034 (cons ?q thumbnail-nq8-file) |
67302 | 1035 (cons ?t thumbnail-file)))) |
1036 thumbnail-dir) | |
1037 (when (not (file-exists-p | |
1038 (setq thumbnail-dir (file-name-directory thumbnail-file)))) | |
1039 (message "Creating thumbnail directory.") | |
1040 (make-directory thumbnail-dir)) | |
1041 (shell-command command nil))) | |
1042 | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1043 ;;;###autoload |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1044 (defun tumme-dired-insert-marked-thumbs () |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1045 "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
|
1046 (interactive) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1047 (dired-map-over-marks |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1048 (let* ((image-pos (dired-move-to-filename)) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1049 (image-file (dired-get-filename)) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1050 (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
|
1051 overlay) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1052 ;; 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
|
1053 (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
|
1054 ;; Can't use (overlays-at (point)), BUG? |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1055 (overlays-in (point) (1+ (point))))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1056 (put-image thumb-file image-pos) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1057 (setq overlay (car (delq nil (mapcar (lambda (o) (and (overlay-get o 'put-image) o)) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1058 (overlays-in (point) (1+ (point))))))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1059 (overlay-put overlay 'image-file image-file) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1060 (overlay-put overlay 'thumb-file thumb-file))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1061 nil) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1062 (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
|
1063 |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1064 (defun tumme-dired-after-readin-hook () |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1065 "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
|
1066 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
|
1067 Otherwise, delete overlays." |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1068 (mapc (lambda (overlay) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1069 (when (overlay-get overlay 'put-image) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1070 (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
|
1071 (image-pos (dired-goto-file image-file))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1072 (if image-pos |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1073 (move-overlay overlay image-pos image-pos) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1074 (delete-overlay overlay))))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1075 (overlays-in (point-min) (point-max)))) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
1076 |
67302 | 1077 (defun tumme-next-line-and-display () |
1078 "Move to next dired line and display thumbnail image." | |
1079 (interactive) | |
1080 (dired-next-line 1) | |
1081 (tumme-display-thumbs | |
1082 t (or tumme-append-when-browsing nil)) | |
1083 (if tumme-dired-disp-props | |
1084 (tumme-dired-display-properties))) | |
1085 | |
1086 (defun tumme-previous-line-and-display () | |
1087 "Move to previous dired line and display thumbnail image." | |
1088 (interactive) | |
1089 (dired-previous-line 1) | |
1090 (tumme-display-thumbs | |
1091 t (or tumme-append-when-browsing nil)) | |
1092 (if tumme-dired-disp-props | |
1093 (tumme-dired-display-properties))) | |
1094 | |
1095 (defun tumme-toggle-append-browsing () | |
1096 "Toggle `tumme-append-when-browsing'." | |
1097 (interactive) | |
1098 (setq tumme-append-when-browsing | |
1099 (not tumme-append-when-browsing)) | |
1100 (message "Append browsing %s." | |
1101 (if tumme-append-when-browsing | |
1102 "on" | |
1103 "off"))) | |
1104 | |
1105 (defun tumme-mark-and-display-next () | |
1106 "Mark current file in dired and display next thumbnail image." | |
1107 (interactive) | |
1108 (dired-mark 1) | |
1109 (tumme-display-thumbs | |
1110 t (or tumme-append-when-browsing nil)) | |
1111 (if tumme-dired-disp-props | |
1112 (tumme-dired-display-properties))) | |
1113 | |
1114 (defun tumme-toggle-dired-display-properties () | |
1115 "Toggle `tumme-dired-disp-props'." | |
1116 (interactive) | |
1117 (setq tumme-dired-disp-props | |
1118 (not tumme-dired-disp-props)) | |
1119 (message "Dired display properties %s." | |
1120 (if tumme-dired-disp-props | |
1121 "on" | |
1122 "off"))) | |
1123 | |
1124 (defvar tumme-thumbnail-buffer "*tumme*" | |
1125 "Tumme's thumbnail buffer.") | |
1126 | |
1127 (defun tumme-create-thumbnail-buffer () | |
1128 "Create thumb buffer and set `tumme-thumbnail-mode'." | |
1129 (let ((buf (get-buffer-create tumme-thumbnail-buffer))) | |
1130 (save-excursion | |
1131 (set-buffer buf) | |
1132 (setq buffer-read-only t) | |
1133 (if (not (eq major-mode 'tumme-thumbnail-mode)) | |
1134 (tumme-thumbnail-mode))) | |
1135 buf)) | |
1136 | |
1137 (defvar tumme-display-image-buffer "*tumme-display-image*" | |
1138 "Where larger versions of the images are display.") | |
1139 | |
1140 (defun tumme-create-display-image-buffer () | |
1141 "Create image display buffer and set `tumme-display-image-mode'." | |
1142 (let ((buf (get-buffer-create tumme-display-image-buffer))) | |
1143 (save-excursion | |
1144 (set-buffer buf) | |
1145 (setq buffer-read-only t) | |
1146 (if (not (eq major-mode 'tumme-display-image-mode)) | |
1147 (tumme-display-image-mode))) | |
1148 buf)) | |
1149 | |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1150 (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
|
1151 "Saved window configuration.") |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1152 |
68404 | 1153 ;;;###autoload |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1154 (defun tumme-dired-with-window-configuration (dir &optional arg) |
67302 | 1155 "Open directory DIR and create a default window configuration. |
1156 | |
1157 Convenience command that: | |
1158 | |
1159 - Opens dired in folder DIR | |
1160 - Splits windows in most useful (?) way | |
1161 - Set `truncate-lines' to t | |
1162 | |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1163 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
|
1164 image files in dired and type |
3c76b1d6eff0
Tried to make docstring less `colloquial'...
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68754
diff
changeset
|
1165 \\[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
|
1166 |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1167 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
|
1168 |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1169 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
|
1170 calling `tumme-restore-window-configuration'." |
67302 | 1171 (interactive "DDirectory: \nP") |
1172 (let ((buf (tumme-create-thumbnail-buffer)) | |
1173 (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
|
1174 (setq tumme-saved-window-configuration |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1175 (current-window-configuration)) |
67302 | 1176 (dired dir) |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1177 (delete-other-windows) |
67302 | 1178 (when (not arg) |
1179 (split-window-horizontally) | |
1180 (setq truncate-lines t) | |
1181 (save-excursion | |
1182 (other-window 1) | |
1183 (switch-to-buffer buf) | |
1184 (split-window-vertically) | |
1185 (other-window 1) | |
1186 (switch-to-buffer buf2) | |
1187 (other-window -2))))) | |
1188 | |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1189 (defun tumme-restore-window-configuration () |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1190 "Restore window configuration. |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1191 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
|
1192 `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
|
1193 (interactive) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1194 (if tumme-saved-window-configuration |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1195 (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
|
1196 (message "No saved window configuration"))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1197 |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1198 ;;;###autoload |
67302 | 1199 (defun tumme-display-thumbs (&optional arg append) |
1200 "Display thumbnails of all marked files, in `tumme-thumbnail-buffer'. | |
1201 If a thumbnail image does not exist for a file, it is created on the | |
1202 fly. With prefix argument ARG, display only thumbnail for file at | |
1203 point (this is useful if you have marked some files but want to show | |
1204 another one). | |
1205 | |
1206 Recommended usage is to split the current frame horizontally so that | |
1207 you have the dired buffer in the left window and the | |
1208 `tumme-thumbnail-buffer' buffer in the right window. | |
1209 | |
1210 With optional argument APPEND, append thumbnail to thumbnail buffer | |
1211 instead of erasing it first." | |
1212 (interactive "P") | |
1213 (let ((buf (tumme-create-thumbnail-buffer)) | |
1214 curr-file thumb-name files count dired-buf beg) | |
1215 (if arg | |
1216 (setq files (list (dired-get-filename))) | |
1217 (setq files (dired-get-marked-files))) | |
1218 (setq dired-buf (current-buffer)) | |
1219 (save-excursion | |
1220 (set-buffer buf) | |
1221 (let ((inhibit-read-only t)) | |
1222 (if (not append) | |
1223 (erase-buffer) | |
1224 (goto-char (point-max))) | |
1225 (mapcar | |
1226 (lambda (curr-file) | |
1227 (setq thumb-name (tumme-thumb-name curr-file)) | |
1228 (if (and (not (file-exists-p thumb-name)) | |
1229 (not (= 0 (tumme-create-thumb curr-file thumb-name)))) | |
1230 (message "Thumb could not be created for file %s" curr-file) | |
1231 (tumme-insert-thumbnail thumb-name curr-file dired-buf))) | |
1232 files)) | |
1233 (cond ((eq 'dynamic tumme-line-up-method) | |
1234 (tumme-line-up-dynamic)) | |
1235 ((eq 'fixed tumme-line-up-method) | |
1236 (tumme-line-up)) | |
1237 ((eq 'interactive tumme-line-up-method) | |
1238 (tumme-line-up-interactive)) | |
1239 ((eq 'none tumme-line-up-method) | |
1240 nil) | |
1241 (t | |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1242 (tumme-line-up-dynamic)))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1243 (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
|
1244 |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1245 (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
|
1246 "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
|
1247 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
|
1248 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
|
1249 displayed." |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1250 (interactive "DDir: ") |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1251 (dired dir) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1252 (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
|
1253 (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
|
1254 (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
|
1255 (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
|
1256 (y-or-n-p |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1257 (format |
68757
3c76b1d6eff0
Tried to make docstring less `colloquial'...
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68754
diff
changeset
|
1258 "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
|
1259 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
|
1260 (progn |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1261 (tumme-display-thumbs) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1262 (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
|
1263 (message "Cancelled.")))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1264 |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1265 ;;;###autoload |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
1266 (defalias 'tumme 'tumme-show-all-from-dir) |
67302 | 1267 |
1268 (defun tumme-write-tag (files tag) | |
1269 "For all FILES, writes TAG to the image database." | |
1270 (save-excursion | |
1271 (let (end buf) | |
1272 (setq buf (find-file tumme-db-file)) | |
1273 (if (not (listp files)) | |
1274 (if (stringp files) | |
1275 (setq files (list files)) | |
1276 (error "Files must be a string or a list of strings!"))) | |
1277 (mapcar | |
1278 (lambda (file) | |
1279 (goto-char (point-min)) | |
1280 (if (search-forward-regexp | |
1281 (format "^%s" file) nil t) | |
1282 (progn | |
1283 (end-of-line) | |
1284 (setq end (point)) | |
1285 (beginning-of-line) | |
1286 (if (not (search-forward (format ";%s" tag) end t)) | |
1287 (progn | |
1288 (end-of-line) | |
1289 (insert (format ";%s" tag))))) | |
1290 (goto-char (point-max)) | |
1291 (insert (format "\n%s;%s" file tag)))) | |
1292 files) | |
1293 (save-buffer) | |
1294 (kill-buffer buf)))) | |
1295 | |
1296 (defun tumme-remove-tag (files tag) | |
1297 "For all FILES, remove TAG from the image database." | |
1298 (save-excursion | |
1299 (let (end buf start) | |
1300 (setq buf (find-file tumme-db-file)) | |
1301 (if (not (listp files)) | |
1302 (if (stringp files) | |
1303 (setq files (list files)) | |
1304 (error "Files must be a string or a list of strings!"))) | |
1305 (mapcar | |
1306 (lambda (file) | |
1307 (goto-char (point-min)) | |
1308 (if (search-forward-regexp | |
1309 (format "^%s" file) nil t) | |
1310 (progn | |
1311 (end-of-line) | |
1312 (setq end (point)) | |
1313 (beginning-of-line) | |
1314 (if (search-forward-regexp (format "\\(;%s\\)" tag) end t) | |
1315 (progn | |
1316 (delete-region (match-beginning 1) (match-end 1)) | |
1317 ;; Check if file should still be in the database. If | |
1318 ;; it has no tags or comments, it will be removed. | |
1319 (end-of-line) | |
1320 (setq end (point)) | |
1321 (beginning-of-line) | |
1322 (if (not (search-forward ";" end t)) | |
1323 (progn | |
1324 (kill-line 1) | |
1325 ;; If on empty line at end of buffer | |
1326 (if (and (eobp) | |
1327 (looking-at "^$")) | |
1328 (delete-backward-char 1))))))))) | |
1329 files) | |
1330 (save-buffer) | |
1331 (kill-buffer buf)))) | |
1332 | |
1333 (defun tumme-list-tags (file) | |
1334 "Read all tags for image FILE from the image database." | |
1335 (save-excursion | |
1336 (let (end buf (tags "")) | |
1337 (setq buf (find-file tumme-db-file)) | |
1338 (goto-char (point-min)) | |
1339 (if (search-forward-regexp | |
1340 (format "^%s" file) nil t) | |
1341 (progn | |
1342 (end-of-line) | |
1343 (setq end (point)) | |
1344 (beginning-of-line) | |
1345 (if (search-forward ";" end t) | |
1346 (if (search-forward "comment:" end t) | |
1347 (if (search-forward ";" end t) | |
1348 (setq tags (buffer-substring (point) end))) | |
1349 (setq tags (buffer-substring (point) end)))))) | |
1350 (kill-buffer buf) | |
1351 (split-string tags ";")))) | |
1352 | |
68682
23eaa0d773ea
Added more autoload cookies.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68675
diff
changeset
|
1353 ;;;###autoload |
67302 | 1354 (defun tumme-tag-files (arg) |
1355 "Tag marked file(s) in dired. With prefix ARG, tag file at point." | |
1356 (interactive "P") | |
1357 (let ((tag (read-string "Tag to add: ")) | |
1358 curr-file files) | |
1359 (if arg | |
1360 (setq files (dired-get-filename)) | |
1361 (setq files (dired-get-marked-files))) | |
1362 (tumme-write-tag files tag))) | |
1363 | |
1364 (defun tumme-tag-thumbnail () | |
1365 "Tag current thumbnail." | |
1366 (interactive) | |
1367 (let ((tag (read-string "Tag to add: "))) | |
1368 (tumme-write-tag (tumme-original-file-name) tag)) | |
1369 (tumme-update-property | |
1370 'tags (tumme-list-tags (tumme-original-file-name)))) | |
1371 | |
68682
23eaa0d773ea
Added more autoload cookies.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68675
diff
changeset
|
1372 ;;;###autoload |
67302 | 1373 (defun tumme-tag-remove (arg) |
1374 "Remove tag for selected file(s). | |
1375 With prefix argument ARG, remove tag from file at point." | |
1376 (interactive "P") | |
1377 (let ((tag (read-string "Tag to remove: ")) | |
1378 files) | |
1379 (if arg | |
1380 (setq files (list (dired-get-filename))) | |
1381 (setq files (dired-get-marked-files))) | |
1382 (tumme-remove-tag files tag))) | |
1383 | |
1384 (defun tumme-tag-thumbnail-remove () | |
1385 "Remove tag from thumbnail." | |
1386 (interactive) | |
1387 (let ((tag (read-string "Tag to remove: "))) | |
1388 (tumme-remove-tag (tumme-original-file-name) tag)) | |
1389 (tumme-update-property | |
1390 'tags (tumme-list-tags (tumme-original-file-name)))) | |
1391 | |
1392 (defun tumme-original-file-name () | |
1393 "Get original file name for thumbnail or display image at point." | |
1394 (get-text-property (point) 'original-file-name)) | |
1395 | |
1396 (defun tumme-associated-dired-buffer () | |
1397 "Get associated dired buffer at point." | |
1398 (get-text-property (point) 'associated-dired-buffer)) | |
1399 | |
1400 (defun tumme-get-buffer-window (buf) | |
1401 "Return window where buffer BUF is." | |
1402 (get-window-with-predicate | |
1403 (lambda (window) | |
1404 (equal (window-buffer window) buf)) | |
1405 nil t)) | |
1406 | |
1407 (defun tumme-track-original-file () | |
1408 "Track the original file in the associated dired buffer. | |
1409 See documentation for `tumme-toggle-movement-tracking'. Interactive | |
1410 use only useful if `tumme-track-movement' is nil." | |
1411 (interactive) | |
1412 (let ((old-buf (current-buffer)) | |
1413 (dired-buf (tumme-associated-dired-buffer)) | |
1414 (file-name (tumme-original-file-name))) | |
1415 (if (and dired-buf file-name) | |
1416 (progn | |
1417 (setq file-name (file-name-nondirectory file-name)) | |
1418 (set-buffer dired-buf) | |
1419 (goto-char (point-min)) | |
1420 (if (not (search-forward file-name nil t)) | |
1421 (message "Could not track file") | |
1422 (dired-move-to-filename) | |
1423 (set-window-point | |
1424 (tumme-get-buffer-window dired-buf) (point))) | |
1425 (set-buffer old-buf))))) | |
1426 | |
1427 (defun tumme-toggle-movement-tracking () | |
1428 "Turn on and off `tumme-track-movement'. | |
1429 Tracking of the movements between thumbnail and dired buffer so that | |
1430 they are \"mirrored\" in the dired buffer. When this is on, moving | |
1431 around in the thumbnail or dired buffer will find the matching | |
1432 position in the other buffer." | |
1433 (interactive) | |
1434 (setq tumme-track-movement (not tumme-track-movement)) | |
1435 (message "Tracking %s" (if tumme-track-movement "on" "off"))) | |
1436 | |
1437 (defun tumme-track-thumbnail () | |
1438 "Track current dired file's thumb in `tumme-thumbnail-buffer'. | |
1439 This is almost the same as what `tumme-track-original-file' does, but | |
1440 the other way around." | |
1441 (let ((file (dired-get-filename)) | |
1442 (old-buf (current-buffer)) | |
1443 prop-val found) | |
1444 (if (get-buffer tumme-thumbnail-buffer) | |
1445 (progn | |
1446 (set-buffer tumme-thumbnail-buffer) | |
1447 (goto-char (point-min)) | |
1448 (while (and (not (eobp)) | |
1449 (not found)) | |
1450 (if (and (setq prop-val | |
1451 (get-text-property (point) 'original-file-name)) | |
1452 (string= prop-val file)) | |
1453 (setq found t)) | |
1454 (if (not found) | |
1455 (forward-char 1))) | |
1456 (if found | |
1457 (progn | |
1458 (set-window-point | |
1459 (tumme-thumbnail-window) (point)) | |
1460 (tumme-display-thumb-properties))) | |
1461 (set-buffer old-buf))))) | |
1462 | |
1463 (defun tumme-dired-next-line (&optional arg) | |
1464 "Call `dired-next-line', then track thumbnail. | |
1465 This can safely replace `dired-next-line'. With prefix argument, move | |
1466 ARG lines." | |
1467 (interactive "P") | |
1468 (dired-next-line (or arg 1)) | |
1469 (if tumme-track-movement | |
1470 (tumme-track-thumbnail))) | |
1471 | |
1472 (defun tumme-dired-previous-line (&optional arg) | |
1473 "Call `dired-previous-line', then track thumbnail. | |
1474 This can safely replace `dired-previous-line'. With prefix argument, | |
1475 move ARG lines." | |
1476 (interactive "P") | |
1477 (dired-previous-line (or arg 1)) | |
1478 (if tumme-track-movement | |
1479 (tumme-track-thumbnail))) | |
1480 | |
1481 (defun tumme-forward-char () | |
1482 "Move to next image and display properties." | |
1483 (interactive) | |
1484 ;; Before we move, make sure that there is an image two positions | |
1485 ;; forward. | |
1486 (if (save-excursion | |
1487 (forward-char 2) | |
1488 (tumme-image-at-point-p)) | |
1489 (progn | |
1490 (forward-char) | |
1491 (while (and (not (eobp)) | |
1492 (not (tumme-image-at-point-p))) | |
1493 (forward-char)) | |
1494 (if tumme-track-movement | |
1495 (tumme-track-original-file)))) | |
1496 (tumme-display-thumb-properties)) | |
1497 | |
1498 (defun tumme-backward-char () | |
1499 "Move to previous image and display properties." | |
1500 (interactive) | |
1501 (if (not (bobp)) | |
1502 (progn | |
1503 (backward-char) | |
1504 (while (and (not (bobp)) | |
1505 (not (tumme-image-at-point-p))) | |
1506 (backward-char)) | |
1507 (if tumme-track-movement | |
1508 (tumme-track-original-file)))) | |
1509 (tumme-display-thumb-properties)) | |
1510 | |
1511 (defun tumme-next-line () | |
1512 "Move to next line and display properties." | |
1513 (interactive) | |
1514 (next-line 1) | |
1515 ;; If we end up in an empty spot, back up to the next thumbnail. | |
1516 (if (not (tumme-image-at-point-p)) | |
1517 (tumme-backward-char)) | |
1518 (if tumme-track-movement | |
1519 (tumme-track-original-file)) | |
1520 (tumme-display-thumb-properties)) | |
1521 | |
1522 | |
1523 (defun tumme-previous-line () | |
1524 "Move to previous line and display properties." | |
1525 (interactive) | |
1526 (previous-line 1) | |
1527 ;; If we end up in an empty spot, back up to the next | |
1528 ;; thumbnail. This should only happen if the user deleted a | |
1529 ;; thumbnail and did not refresh, so it is not very common. But we | |
1530 ;; can handle it in a good manner, so why not? | |
1531 (if (not (tumme-image-at-point-p)) | |
1532 (tumme-backward-char)) | |
1533 (if tumme-track-movement | |
1534 (tumme-track-original-file)) | |
1535 (tumme-display-thumb-properties)) | |
1536 | |
1537 (defun tumme-format-properties-string (buf file props comment) | |
1538 "Format display properties. | |
1539 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
|
1540 name, PROPS is a list of tags and COMMENT is the image files's |
67302 | 1541 comment." |
1542 (format-spec | |
1543 tumme-display-properties-format | |
1544 (list | |
1545 (cons ?b buf) | |
1546 (cons ?f file) | |
1547 (cons ?t (or (princ props) "")) | |
1548 (cons ?c (or comment ""))))) | |
1549 | |
1550 (defun tumme-display-thumb-properties () | |
1551 "Display thumbnail properties in the echo area." | |
1552 (if (not (eobp)) | |
1553 (let ((file-name (file-name-nondirectory (tumme-original-file-name))) | |
1554 (dired-buf (buffer-name (tumme-associated-dired-buffer))) | |
1555 (props (mapconcat | |
1556 'princ | |
1557 (get-text-property (point) 'tags) | |
1558 ", ")) | |
1559 (comment (get-text-property (point) 'comment))) | |
1560 (if file-name | |
1561 (message | |
1562 (tumme-format-properties-string | |
1563 dired-buf | |
1564 file-name | |
1565 props | |
1566 comment)))))) | |
1567 | |
1568 (defun tumme-dired-file-marked-p () | |
1569 "Check whether file on current line is marked or not." | |
1570 (save-excursion | |
1571 (beginning-of-line) | |
1572 (not (looking-at "^ .*$")))) | |
1573 | |
1574 (defun tumme-modify-mark-on-thumb-original-file (command) | |
1575 "Modify mark in dired buffer. | |
1576 This is quite ugly but I don't know how to implemented in a better | |
1577 way. COMMAND is one of 'mark for marking file in dired, 'unmark for | |
1578 unmarking file in dired or 'flag for flagging file for delete in | |
1579 dired." | |
1580 (let ((file-name (tumme-original-file-name)) | |
1581 (dired-buf (tumme-associated-dired-buffer))) | |
1582 (if (not (and dired-buf file-name)) | |
1583 (message "No image, or image with correct properties, at point.") | |
1584 (save-excursion | |
1585 (message file-name) | |
1586 (setq file-name (file-name-nondirectory file-name)) | |
1587 (set-buffer dired-buf) | |
1588 (goto-char (point-min)) | |
1589 (if (search-forward file-name nil t) | |
1590 (cond ((eq command 'mark) (dired-mark 1)) | |
1591 ((eq command 'unmark) (dired-unmark 1)) | |
1592 ((eq command 'toggle) | |
1593 (if (tumme-dired-file-marked-p) | |
1594 (dired-unmark 1) | |
1595 (dired-mark 1))) | |
1596 ((eq command 'flag) (dired-flag-file-deletion 1)))))))) | |
1597 | |
1598 (defun tumme-mark-thumb-original-file () | |
1599 "Mark original image file in associated dired buffer." | |
1600 (interactive) | |
1601 (tumme-modify-mark-on-thumb-original-file 'mark) | |
1602 (tumme-forward-char)) | |
1603 | |
1604 (defun tumme-unmark-thumb-original-file () | |
1605 "Unmark original image file in associated dired buffer." | |
1606 (interactive) | |
1607 (tumme-modify-mark-on-thumb-original-file 'unmark) | |
1608 (tumme-forward-char)) | |
1609 | |
1610 (defun tumme-flag-thumb-original-file () | |
1611 "Flag original image file for deletion in associated dired buffer." | |
1612 (interactive) | |
1613 (tumme-modify-mark-on-thumb-original-file 'flag) | |
1614 (tumme-forward-char)) | |
1615 | |
1616 (defun tumme-toggle-mark-thumb-original-file () | |
1617 "Toggle mark on original image file in associated dired buffer." | |
1618 (interactive) | |
1619 (tumme-modify-mark-on-thumb-original-file 'toggle)) | |
1620 | |
1621 (defun tumme-jump-original-dired-buffer () | |
1622 "Jump to the dired buffer associated with the current image file. | |
1623 You probably want to use this together with | |
1624 `tumme-track-original-file'." | |
1625 (interactive) | |
1626 (let ((buf (tumme-associated-dired-buffer)) | |
1627 window frame) | |
1628 (setq window (tumme-get-buffer-window buf)) | |
1629 (if window | |
1630 (progn | |
1631 (if (not (equal (selected-frame) (setq frame (window-frame window)))) | |
1632 (select-frame-set-input-focus frame)) | |
1633 (select-window window)) | |
1634 (message "Associated dired buffer not visible")))) | |
1635 | |
68682
23eaa0d773ea
Added more autoload cookies.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68675
diff
changeset
|
1636 ;;;###autoload |
67302 | 1637 (defun tumme-jump-thumbnail-buffer () |
1638 "Jump to thumbnail buffer." | |
1639 (interactive) | |
1640 (let ((window (tumme-thumbnail-window)) | |
1641 frame) | |
1642 (if window | |
1643 (progn | |
1644 (if (not (equal (selected-frame) (setq frame (window-frame window)))) | |
1645 (select-frame-set-input-focus frame)) | |
1646 (select-window window)) | |
1647 (message "Thumbnail buffer not visible")))) | |
1648 | |
1649 (defvar tumme-thumbnail-mode-map (make-sparse-keymap) | |
1650 "Keymap for `tumme-thumbnail-mode'.") | |
1651 | |
1652 (defvar tumme-thumbnail-mode-line-up-map (make-sparse-keymap) | |
1653 "Keymap for line-up commands in `tumme-thumbnail-mode'.") | |
1654 | |
1655 (defvar tumme-thumbnail-mode-tag-map (make-sparse-keymap) | |
1656 "Keymap for tag commands in `tumme-thumbnail-mode'.") | |
1657 | |
1658 (defun tumme-define-thumbnail-mode-keymap () | |
1659 "Define keymap for `tumme-thumbnail-mode'." | |
1660 | |
1661 ;; Keys | |
1662 (define-key tumme-thumbnail-mode-map [right] 'tumme-forward-char) | |
1663 (define-key tumme-thumbnail-mode-map [left] 'tumme-backward-char) | |
1664 (define-key tumme-thumbnail-mode-map [up] 'tumme-previous-line) | |
1665 (define-key tumme-thumbnail-mode-map [down] 'tumme-next-line) | |
1666 (define-key tumme-thumbnail-mode-map "\C-f" 'tumme-forward-char) | |
1667 (define-key tumme-thumbnail-mode-map "\C-b" 'tumme-backward-char) | |
1668 (define-key tumme-thumbnail-mode-map "\C-p" 'tumme-previous-line) | |
1669 (define-key tumme-thumbnail-mode-map "\C-n" 'tumme-next-line) | |
1670 | |
1671 (define-key tumme-thumbnail-mode-map "d" 'tumme-flag-thumb-original-file) | |
1672 (define-key tumme-thumbnail-mode-map [delete] | |
1673 'tumme-flag-thumb-original-file) | |
1674 (define-key tumme-thumbnail-mode-map "m" 'tumme-mark-thumb-original-file) | |
1675 (define-key tumme-thumbnail-mode-map "u" 'tumme-unmark-thumb-original-file) | |
1676 (define-key tumme-thumbnail-mode-map "." 'tumme-track-original-file) | |
1677 (define-key tumme-thumbnail-mode-map [tab] 'tumme-jump-original-dired-buffer) | |
1678 | |
1679 ;; add line-up map | |
1680 (define-key tumme-thumbnail-mode-map "g" tumme-thumbnail-mode-line-up-map) | |
1681 | |
1682 ;; map it to "g" so that the user can press it more quickly | |
1683 (define-key tumme-thumbnail-mode-line-up-map "g" 'tumme-line-up-dynamic) | |
1684 ;; "f" for "fixed" number of thumbs per row | |
1685 (define-key tumme-thumbnail-mode-line-up-map "f" 'tumme-line-up) | |
1686 ;; "i" for "interactive" | |
1687 (define-key tumme-thumbnail-mode-line-up-map "i" 'tumme-line-up-interactive) | |
1688 | |
1689 ;; add tag map | |
1690 (define-key tumme-thumbnail-mode-map "t" tumme-thumbnail-mode-tag-map) | |
1691 | |
1692 ;; map it to "t" so that the user can press it more quickly | |
1693 (define-key tumme-thumbnail-mode-tag-map "t" 'tumme-tag-thumbnail) | |
1694 ;; "r" for "remove" | |
1695 (define-key tumme-thumbnail-mode-tag-map "r" 'tumme-tag-thumbnail-remove) | |
1696 | |
1697 (define-key tumme-thumbnail-mode-map "\C-m" | |
1698 'tumme-display-thumbnail-original-image) | |
1699 (define-key tumme-thumbnail-mode-map [C-return] | |
1700 'tumme-thumbnail-display-external) | |
1701 | |
1702 (define-key tumme-thumbnail-mode-map "l" 'tumme-rotate-thumbnail-left) | |
1703 (define-key tumme-thumbnail-mode-map "r" 'tumme-rotate-thumbnail-right) | |
1704 | |
1705 (define-key tumme-thumbnail-mode-map "L" 'tumme-rotate-original-left) | |
1706 (define-key tumme-thumbnail-mode-map "R" 'tumme-rotate-original-right) | |
1707 | |
1708 (define-key tumme-thumbnail-mode-map "D" 'tumme-thumbnail-set-image-description) | |
1709 | |
1710 (define-key tumme-thumbnail-mode-map "\C-d" 'tumme-delete-char) | |
1711 (define-key tumme-thumbnail-mode-map " " | |
1712 'tumme-display-next-thumbnail-original) | |
1713 (define-key tumme-thumbnail-mode-map | |
1714 (kbd "DEL") 'tumme-display-previous-thumbnail-original) | |
1715 (define-key tumme-thumbnail-mode-map "c" 'tumme-comment-thumbnail) | |
1716 (define-key tumme-thumbnail-mode-map "q" 'tumme-kill-buffer-and-window) | |
1717 | |
1718 ;; Mouse | |
1719 (define-key tumme-thumbnail-mode-map [mouse-2] 'tumme-mouse-display-image) | |
1720 (define-key tumme-thumbnail-mode-map [mouse-1] 'tumme-mouse-select-thumbnail) | |
1721 | |
1722 ;; Seems I must first set C-down-mouse-1 to undefined, or else it | |
1723 ;; will trigger the buffer menu. If I try to instead bind | |
1724 ;; C-down-mouse-1 to `tumme-mouse-toggle-mark', I get a message | |
1725 ;; about C-mouse-1 not being defined afterwards. Annoying, but I | |
1726 ;; probably do not completely understand mouse events. | |
1727 | |
1728 (define-key tumme-thumbnail-mode-map [C-down-mouse-1] 'undefined) | |
1729 (define-key tumme-thumbnail-mode-map [C-mouse-1] 'tumme-mouse-toggle-mark) | |
1730 | |
1731 ;; Menu | |
1732 (define-key tumme-thumbnail-mode-map [menu-bar tumme] | |
1733 (cons "Tumme" (make-sparse-keymap "Tumme"))) | |
1734 | |
1735 (define-key tumme-thumbnail-mode-map | |
1736 [menu-bar tumme tumme-kill-buffer-and-window] | |
1737 '("Quit" . tumme-kill-buffer-and-window)) | |
1738 | |
1739 (define-key tumme-thumbnail-mode-map | |
1740 [menu-bar tumme tumme-delete-char] | |
1741 '("Delete thumbnail from buffer" . tumme-delete-char)) | |
1742 | |
1743 (define-key tumme-thumbnail-mode-map | |
1744 [menu-bar tumme tumme-tag-thumbnail-remove] | |
1745 '("Remove tag from thumbnail" . tumme-tag-thumbnail-remove)) | |
1746 | |
1747 (define-key tumme-thumbnail-mode-map | |
1748 [menu-bar tumme tumme-tag-thumbnail] | |
1749 '("Tag thumbnail" . tumme-tag-thumbnail)) | |
1750 | |
1751 (define-key tumme-thumbnail-mode-map | |
1752 [menu-bar tumme tumme-comment-thumbnail] | |
1753 '("Comment thumbnail" . tumme-comment-thumbnail)) | |
1754 | |
1755 (define-key tumme-thumbnail-mode-map | |
1756 [menu-bar tumme tumme-refresh-thumb] | |
1757 '("Refresh thumb" . tumme-refresh-thumb)) | |
1758 (define-key tumme-thumbnail-mode-map | |
1759 [menu-bar tumme tumme-line-up-dynamic] | |
1760 '("Dynamic line up" . tumme-line-up-dynamic)) | |
1761 (define-key tumme-thumbnail-mode-map | |
1762 [menu-bar tumme tumme-line-up] | |
1763 '("Line up thumbnails" . tumme-line-up)) | |
1764 | |
1765 (define-key tumme-thumbnail-mode-map | |
1766 [menu-bar tumme tumme-rotate-thumbnail-left] | |
1767 '("Rotate thumbnail left" . tumme-rotate-thumbnail-left)) | |
1768 (define-key tumme-thumbnail-mode-map | |
1769 [menu-bar tumme tumme-rotate-thumbnail-right] | |
1770 '("Rotate thumbnail right" . tumme-rotate-thumbnail-right)) | |
1771 | |
1772 (define-key tumme-thumbnail-mode-map | |
1773 [menu-bar tumme tumme-rotate-original-left] | |
1774 '("Rotate original left" . tumme-rotate-original-left)) | |
1775 (define-key tumme-thumbnail-mode-map | |
1776 [menu-bar tumme tumme-rotate-original-right] | |
1777 '("Rotate original right" . tumme-rotate-original-right)) | |
1778 | |
1779 (define-key tumme-thumbnail-mode-map | |
1780 [menu-bar tumme tumme-toggle-movement-tracking] | |
1781 '("Toggle movement tracking on/off" . tumme-toggle-movement-tracking)) | |
1782 | |
1783 (define-key tumme-thumbnail-mode-map | |
1784 [menu-bar tumme tumme-jump-original-dired-buffer] | |
1785 '("Jump to dired buffer" . tumme-jump-original-dired-buffer)) | |
1786 (define-key tumme-thumbnail-mode-map | |
1787 [menu-bar tumme tumme-track-original-file] | |
1788 '("Track original" . tumme-track-original-file)) | |
1789 | |
1790 (define-key tumme-thumbnail-mode-map | |
1791 [menu-bar tumme tumme-flag-thumb-original-file] | |
1792 '("Flag original for deletion" . tumme-flag-thumb-original-file)) | |
1793 (define-key tumme-thumbnail-mode-map | |
1794 [menu-bar tumme tumme-unmark-thumb-original-file] | |
1795 '("Unmark original" . tumme-unmark-thumb-original-file)) | |
1796 (define-key tumme-thumbnail-mode-map | |
1797 [menu-bar tumme tumme-mark-thumb-original-file] | |
1798 '("Mark original" . tumme-mark-thumb-original-file)) | |
1799 | |
1800 (define-key tumme-thumbnail-mode-map | |
1801 [menu-bar tumme tumme-thumbnail-display-external] | |
1802 '("Display in external viewer" . tumme-thumbnail-display-external)) | |
1803 (define-key tumme-thumbnail-mode-map | |
1804 [menu-bar tumme tumme-display-thumbnail-original-image] | |
1805 '("Display image" . tumme-display-thumbnail-original-image))) | |
1806 | |
1807 (defvar tumme-display-image-mode-map (make-sparse-keymap) | |
1808 "Keymap for `tumme-display-image-mode'.") | |
1809 | |
1810 (defun tumme-define-display-image-mode-keymap () | |
1811 "Define keymap for `tumme-display-image-mode'." | |
1812 | |
1813 ;; Keys | |
1814 (define-key tumme-display-image-mode-map "q" 'tumme-kill-buffer-and-window) | |
1815 | |
1816 (define-key tumme-display-image-mode-map "f" | |
1817 'tumme-display-current-image-full) | |
1818 | |
1819 (define-key tumme-display-image-mode-map "s" | |
1820 'tumme-display-current-image-sized) | |
1821 | |
1822 ;; Menu | |
1823 (define-key tumme-display-image-mode-map [menu-bar tumme] | |
1824 (cons "Tumme" (make-sparse-keymap "Tumme"))) | |
1825 | |
1826 (define-key tumme-display-image-mode-map | |
1827 [menu-bar tumme tumme-kill-buffer-and-window] | |
1828 '("Quit" . tumme-kill-buffer-and-window)) | |
1829 | |
1830 (define-key tumme-display-image-mode-map | |
1831 [menu-bar tumme tumme-display-current-image-sized] | |
1832 '("Display original, sized to fit" . tumme-display-current-image-sized)) | |
1833 | |
1834 (define-key tumme-display-image-mode-map | |
1835 [menu-bar tumme tumme-display-current-image-full] | |
1836 '("Display original, full size" . tumme-display-current-image-full)) | |
1837 | |
1838 ) | |
1839 | |
1840 (defun tumme-display-current-image-full () | |
1841 "Display current image in full size." | |
1842 (interactive) | |
1843 (let ((file (tumme-original-file-name))) | |
1844 (if file | |
1845 (progn | |
1846 (tumme-display-image file t) | |
1847 (message "Full size image displayed")) | |
1848 (error "No original file name at point")))) | |
1849 | |
1850 (defun tumme-display-current-image-sized () | |
1851 "Display current image in sized to fit window dimensions." | |
1852 (interactive) | |
1853 (let ((file (tumme-original-file-name))) | |
1854 (if file | |
1855 (progn | |
1856 (tumme-display-image file) | |
1857 (message "Full size image displayed")) | |
1858 (error "No original file name at point")))) | |
1859 | |
1860 (define-derived-mode tumme-thumbnail-mode | |
1861 fundamental-mode "tumme-thumbnail" | |
1862 "Browse and manipulate thumbnail images using dired. | |
1863 Use `tumme-dired' and `tumme-setup-dired-keybindings' to get a | |
1864 nice setup to start with." | |
1865 (tumme-define-thumbnail-mode-keymap) | |
1866 (message "tumme-thumbnail-mode enabled")) | |
1867 | |
1868 (define-derived-mode tumme-display-image-mode | |
1869 fundamental-mode "tumme-image-display" | |
1870 "Mode for displaying and manipulating original image. | |
1871 Resized or in full-size." | |
1872 (tumme-define-display-image-mode-keymap) | |
1873 (message "tumme-display-image-mode enabled")) | |
1874 | |
68404 | 1875 ;;;###autoload |
67302 | 1876 (defun tumme-setup-dired-keybindings () |
1877 "Setup easy-to-use keybindings for the commands to be used in dired mode. | |
1878 Note that n, p and <down> and <up> will be hijacked and bound to | |
1879 `tumme-dired-x-line'." | |
1880 (interactive) | |
1881 | |
1882 ;; Hijack previous and next line movement. Let C-p and C-b be | |
1883 ;; though... | |
1884 | |
1885 (define-key dired-mode-map "p" 'tumme-dired-previous-line) | |
1886 (define-key dired-mode-map "n" 'tumme-dired-next-line) | |
1887 (define-key dired-mode-map [up] 'tumme-dired-previous-line) | |
1888 (define-key dired-mode-map [down] 'tumme-dired-next-line) | |
1889 | |
1890 (define-key dired-mode-map (kbd "C-S-n") 'tumme-next-line-and-display) | |
1891 (define-key dired-mode-map (kbd "C-S-p") 'tumme-previous-line-and-display) | |
1892 (define-key dired-mode-map (kbd "C-S-m") 'tumme-mark-and-display-next) | |
1893 | |
1894 (define-key dired-mode-map "\C-td" 'tumme-display-thumbs) | |
1895 (define-key dired-mode-map "\C-tt" 'tumme-tag-files) | |
1896 (define-key dired-mode-map "\C-tr" 'tumme-tag-remove) | |
1897 (define-key dired-mode-map [tab] 'tumme-jump-thumbnail-buffer) | |
1898 (define-key dired-mode-map "\C-ti" 'tumme-display-dired-image) | |
1899 (define-key dired-mode-map "\C-tx" 'tumme-dired-display-external) | |
1900 (define-key dired-mode-map "\C-ta" 'tumme-display-thumbs-append) | |
1901 (define-key dired-mode-map "\C-t." 'tumme-display-thumb) | |
1902 (define-key dired-mode-map "\C-tc" 'tumme-dired-comment-files) | |
1903 (define-key dired-mode-map "\C-tf" 'tumme-mark-tagged-files) | |
1904 | |
1905 ;; Menu for dired | |
1906 (define-key dired-mode-map [menu-bar tumme] | |
1907 (cons "Tumme" (make-sparse-keymap "Tumme"))) | |
1908 | |
1909 (define-key dired-mode-map [menu-bar tumme tumme-copy-with-exif-file-name] | |
1910 '("Copy with EXIF file name" . tumme-copy-with-exif-file-name)) | |
1911 | |
1912 (define-key dired-mode-map [menu-bar tumme tumme-dired-comment-files] | |
1913 '("Comment files" . tumme-dired-comment-files)) | |
1914 | |
1915 (define-key dired-mode-map [menu-bar tumme tumme-mark-tagged-files] | |
1916 '("Mark tagged files" . tumme-mark-tagged-files)) | |
1917 | |
1918 (define-key dired-mode-map [menu-bar tumme tumme-tag-remove] | |
1919 '("Remove tag from files" . tumme-tag-remove)) | |
1920 | |
1921 (define-key dired-mode-map [menu-bar tumme tumme-tag-files] | |
1922 '("Tag files" . tumme-tag-files)) | |
1923 | |
1924 (define-key dired-mode-map [menu-bar tumme tumme-jump-thumbnail-buffer] | |
1925 '("Jump to thumbnail buffer" . tumme-jump-thumbnail-buffer)) | |
1926 | |
1927 (define-key dired-mode-map [menu-bar tumme tumme-toggle-movement-tracking] | |
1928 '("Toggle movement tracking" . tumme-toggle-movement-tracking)) | |
1929 | |
1930 (define-key dired-mode-map | |
1931 [menu-bar tumme tumme-toggle-append-browsing] | |
1932 '("Toggle append browsing" . tumme-toggle-append-browsing)) | |
1933 | |
1934 (define-key dired-mode-map | |
1935 [menu-bar tumme tumme-toggle-disp-props] | |
1936 '("Toggle display properties" . tumme-toggle-dired-display-properties)) | |
1937 | |
1938 (define-key dired-mode-map | |
1939 [menu-bar tumme tumme-dired-display-external] | |
1940 '("Display in external viewer" . tumme-dired-display-external)) | |
1941 (define-key dired-mode-map | |
1942 [menu-bar tumme tumme-display-dired-image] | |
1943 '("Display image" . tumme-display-dired-image)) | |
1944 (define-key dired-mode-map | |
1945 [menu-bar tumme tumme-display-thumb] | |
1946 '("Display this thumbnail" . tumme-display-thumb)) | |
1947 (define-key dired-mode-map | |
1948 [menu-bar tumme tumme-display-thumbs-append] | |
1949 '("Display thumbnails append" . tumme-display-thumbs-append)) | |
1950 (define-key dired-mode-map | |
1951 [menu-bar tumme tumme-display-thumbs] | |
1952 '("Display thumbnails" . tumme-display-thumbs)) | |
1953 | |
1954 (define-key dired-mode-map | |
1955 [menu-bar tumme tumme-create-thumbs] | |
1956 '("Create thumbnails for marked files" . tumme-create-thumbs)) | |
1957 | |
1958 (define-key dired-mode-map | |
1959 [menu-bar tumme tumme-mark-and-display-next] | |
1960 '("Mark and display next" . tumme-mark-and-display-next)) | |
1961 (define-key dired-mode-map | |
1962 [menu-bar tumme tumme-previous-line-and-display] | |
1963 '("Display thumb for previous file" . tumme-previous-line-and-display)) | |
1964 (define-key dired-mode-map | |
1965 [menu-bar tumme tumme-next-line-and-display] | |
1966 '("Display thumb for next file" . tumme-next-line-and-display))) | |
1967 | |
1968 (defun tumme-create-thumbs (&optional arg) | |
1969 "Create thumbnail images for all marked files in dired. | |
1970 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
|
1971 \(i.e. use this to refresh your thumbnails)." |
67302 | 1972 (interactive "P") |
1973 (let (curr-file thumb-name files count) | |
1974 (setq files (dired-get-marked-files)) | |
1975 (mapcar | |
1976 (lambda (curr-file) | |
1977 (setq thumb-name (tumme-thumb-name curr-file)) | |
1978 ;; If the user overrides the exist check, we must clear the | |
1979 ;; image cache so that if the user wants to display the | |
1980 ;; thumnail, it is not fetched from cache. | |
1981 (if arg | |
1982 (clear-image-cache)) | |
1983 (if (or (not (file-exists-p thumb-name)) | |
1984 arg) | |
1985 (if (not (= 0 (tumme-create-thumb curr-file | |
1986 (tumme-thumb-name curr-file)))) | |
1987 (error "Thumb could not be created")))) | |
1988 files))) | |
1989 | |
1990 (defvar tumme-slideshow-timer nil | |
1991 "Slideshow timer.") | |
1992 | |
1993 (defvar tumme-slideshow-count 0 | |
1994 "Keeping track on number of images in slideshow.") | |
1995 | |
1996 (defvar tumme-slideshow-times 0 | |
1997 "Number of pictures to display in slideshow.") | |
1998 | |
1999 (defun tumme-slideshow-step () | |
2000 "Step to next file, if `tumme-slideshow-times' has not been reached." | |
2001 (if (< tumme-slideshow-count tumme-slideshow-times) | |
2002 (progn | |
2003 (message "%s" (1+ tumme-slideshow-count)) | |
2004 (setq tumme-slideshow-count (1+ tumme-slideshow-count)) | |
2005 (tumme-next-line-and-display)) | |
2006 (tumme-slideshow-stop))) | |
2007 | |
2008 (defun tumme-slideshow-start () | |
2009 "Start slideshow. | |
2010 Ask user for number of images to show and the delay in between." | |
2011 (interactive) | |
2012 (setq tumme-slideshow-count 0) | |
2013 (setq tumme-slideshow-times (string-to-number (read-string "How many: "))) | |
2014 (let ((repeat (string-to-number | |
2015 (read-string | |
2016 "Delay, in seconds. Decimals are accepted : " "1")))) | |
2017 (setq tumme-slideshow-timer | |
2018 (run-with-timer | |
2019 0 repeat | |
2020 'tumme-slideshow-step)))) | |
2021 | |
2022 (defun tumme-slideshow-stop () | |
2023 "Cancel slideshow." | |
2024 (interactive) | |
2025 (cancel-timer tumme-slideshow-timer)) | |
2026 | |
2027 (defun tumme-delete-char () | |
2028 "Remove current thumbnail from thumbnail buffer and line up." | |
2029 (interactive) | |
2030 (let ((inhibit-read-only t)) | |
2031 (delete-char 1) | |
2032 (if (looking-at " ") | |
2033 (delete-char 1)))) | |
2034 | |
68682
23eaa0d773ea
Added more autoload cookies.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68675
diff
changeset
|
2035 ;;;###autoload |
67302 | 2036 (defun tumme-display-thumbs-append () |
2037 "Append thumbnails to `tumme-thumbnail-buffer'." | |
2038 (interactive) | |
2039 (tumme-display-thumbs nil t)) | |
2040 | |
68682
23eaa0d773ea
Added more autoload cookies.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68675
diff
changeset
|
2041 ;;;###autoload |
67302 | 2042 (defun tumme-display-thumb () |
2043 "Shorthard for `tumme-display-thumbs' with prefix argument." | |
2044 (interactive) | |
2045 (tumme-display-thumbs t)) | |
2046 | |
2047 (defun tumme-line-up () | |
2048 "Line up thumbnails according to `tumme-thumbs-per-row'. | |
2049 See also `tumme-line-up-dynamic'." | |
2050 (interactive) | |
2051 (let ((inhibit-read-only t)) | |
2052 (goto-char (point-min)) | |
2053 (while (and (not (tumme-image-at-point-p)) | |
2054 (not (eobp))) | |
2055 (delete-char 1)) | |
2056 (while (not (eobp)) | |
2057 (forward-char) | |
2058 (while (and (not (tumme-image-at-point-p)) | |
2059 (not (eobp))) | |
2060 (delete-char 1))) | |
2061 (goto-char (point-min)) | |
2062 (let ((count 0)) | |
2063 (while (not (eobp)) | |
2064 (forward-char) | |
2065 (if (= tumme-thumbs-per-row 1) | |
2066 (insert "\n") | |
2067 (insert " ") | |
2068 (setq count (1+ count)) | |
2069 (if (= count (- tumme-thumbs-per-row 1)) | |
2070 (progn | |
2071 (forward-char) | |
2072 (insert "\n") | |
2073 (setq count 0)))))) | |
2074 (goto-char (point-min)))) | |
2075 | |
2076 (defun tumme-line-up-dynamic () | |
2077 "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
|
2078 Calculate how many thumbnails fit." |
67302 | 2079 (interactive) |
2080 (let* ((char-width (frame-char-width)) | |
2081 (width (tumme-window-width-pixels (tumme-thumbnail-window))) | |
2082 (tumme-thumbs-per-row | |
2083 (/ width | |
2084 (+ (* 2 tumme-thumb-relief) | |
2085 (* 2 tumme-thumb-margin) | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
2086 tumme-thumb-width char-width)))) |
67302 | 2087 (tumme-line-up))) |
2088 | |
2089 (defun tumme-line-up-interactive () | |
2090 "Line up thumbnails interactively. | |
68673
5a7d4aa73d2d
(tumme-get-thumbnail-image): Add missing arg to `error'.
Juanma Barranquero <lekktu@gmail.com>
parents:
68658
diff
changeset
|
2091 Ask user how many thumbnails should be displayed per row." |
67302 | 2092 (interactive) |
2093 (let ((tumme-thumbs-per-row | |
2094 (string-to-number (read-string "How many thumbs per row: ")))) | |
2095 (if (not (> tumme-thumbs-per-row 0)) | |
2096 (message "Number must be greater than 0") | |
2097 (tumme-line-up)))) | |
2098 | |
2099 (defun tumme-thumbnail-display-external () | |
2100 "Display original image for thumbnail at point using external viewer." | |
2101 | |
2102 (interactive) | |
2103 (let ((file (tumme-original-file-name))) | |
2104 (if (not (tumme-image-at-point-p)) | |
2105 (message "No thumbnail at point") | |
2106 (if (not file) | |
2107 (message "No original file name found") | |
2108 (shell-command (format "%s \"%s\"" | |
2109 tumme-external-viewer | |
2110 file)))))) | |
2111 | |
68682
23eaa0d773ea
Added more autoload cookies.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68675
diff
changeset
|
2112 ;;;###autoload |
67302 | 2113 (defun tumme-dired-display-external () |
2114 "Display file at point using an external viewer." | |
2115 (interactive) | |
2116 (let ((file (dired-get-filename))) | |
2117 (shell-command (format "%s \"%s\"" | |
2118 tumme-external-viewer | |
2119 file)))) | |
2120 | |
2121 (defun tumme-window-width-pixels (window) | |
2122 "Calculate WINDOW width in pixels." | |
2123 (* (window-width window) (frame-char-width))) | |
2124 | |
2125 (defun tumme-window-height-pixels (window) | |
2126 "Calculate WINDOW height in pixels." | |
2127 ;; Note: The mode-line consumes one line | |
2128 (* (- (window-height window) 1) (frame-char-height))) | |
2129 | |
2130 (defun tumme-display-window () | |
2131 "Return window where `tumme-display-image-buffer' is visible." | |
2132 (get-window-with-predicate | |
2133 (lambda (window) | |
2134 (equal (buffer-name (window-buffer window)) tumme-display-image-buffer)) | |
2135 nil t)) | |
2136 | |
2137 (defun tumme-thumbnail-window () | |
2138 "Return window where `tumme-thumbnail-buffer' is visible." | |
2139 (get-window-with-predicate | |
2140 (lambda (window) | |
2141 (equal (buffer-name (window-buffer window)) tumme-thumbnail-buffer)) | |
2142 nil t)) | |
2143 | |
2144 (defun tumme-associated-dired-buffer-window () | |
2145 "Return window where associated dired buffer is visible." | |
2146 (let (buf) | |
2147 (if (tumme-image-at-point-p) | |
2148 (progn | |
2149 (setq buf (tumme-associated-dired-buffer)) | |
2150 (get-window-with-predicate | |
2151 (lambda (window) | |
2152 (equal (window-buffer window) buf)))) | |
2153 (error "No thumbnail image at point")))) | |
2154 | |
2155 (defun tumme-display-window-width () | |
2156 "Return width, in pixels, of tumme's image display window." | |
2157 (- (tumme-window-width-pixels (tumme-display-window)) | |
2158 tumme-display-window-width-correction)) | |
2159 | |
2160 (defun tumme-display-window-height () | |
2161 "Return height, in pixels, of tumme's image display window." | |
2162 (- (tumme-window-height-pixels (tumme-display-window)) | |
2163 tumme-display-window-height-correction)) | |
2164 | |
2165 (defun tumme-display-image (file &optional original-size) | |
2166 "Display image FILE in image buffer. | |
2167 Use this when you want to display the image, semi sized, in a window | |
2168 next to the thumbnail window - typically a three-window configuration | |
2169 with dired to the left, thumbnail window to the upper right and image | |
2170 window to the lower right. The image is sized to fit the display | |
2171 window (using a temporary file, don't worry). Because of this, it | |
2172 will not be as quick as opening it directly, but on most modern | |
2173 systems it should feel snappy enough. | |
2174 | |
2175 If optional argument ORIGINAL-SIZE is non-nil, display image in its | |
2176 original size." | |
2177 (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
|
2178 width height command ret) |
67302 | 2179 (setq file (expand-file-name file)) |
2180 (if (not original-size) | |
2181 (progn | |
68815
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
2182 (setq width (tumme-display-window-width)) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
2183 (setq height (tumme-display-window-height)) |
67302 | 2184 (setq command |
2185 (format-spec | |
2186 tumme-cmd-create-temp-image-options | |
2187 (list | |
2188 (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
|
2189 (cons ?w width) |
3e8cc27a9bcf
Remove todo item about Thumbnail Managing Standard.
Juri Linkov <juri@jurta.org>
parents:
68811
diff
changeset
|
2190 (cons ?h height) |
67302 | 2191 (cons ?f file) |
2192 (cons ?t new-file)))) | |
2193 (setq ret (shell-command command nil)) | |
2194 (if (not (= 0 ret)) | |
2195 (error "Could not resize image"))) | |
2196 (copy-file file new-file t)) | |
2197 (save-excursion | |
2198 (set-buffer (tumme-create-display-image-buffer)) | |
2199 (let ((inhibit-read-only t)) | |
2200 (erase-buffer) | |
2201 (clear-image-cache) | |
2202 (tumme-insert-image tumme-temp-image-file 'jpeg 0 0) | |
2203 (goto-char (point-min)) | |
2204 (tumme-update-property 'original-file-name file))))) | |
2205 | |
2206 (defun tumme-display-thumbnail-original-image (&optional arg) | |
2207 "Display current thumbnail's original image in display buffer. | |
2208 See documentation for `tumme-display-image' for more information. | |
2209 With prefix argument ARG, display image in its original size." | |
2210 (interactive "P") | |
2211 (let ((file (tumme-original-file-name))) | |
2212 (if (not (string-equal major-mode "tumme-thumbnail-mode")) | |
2213 (message "Not in tumme-thumbnail-mode") | |
2214 (if (not (tumme-image-at-point-p)) | |
2215 (message "No thumbnail at point") | |
2216 (if (not file) | |
2217 (message "No original file name found") | |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2218 (tumme-display-image file arg) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2219 (display-buffer tumme-display-image-buffer)))))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2220 |
68682
23eaa0d773ea
Added more autoload cookies.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68675
diff
changeset
|
2221 ;;;###autoload |
67302 | 2222 (defun tumme-display-dired-image (&optional arg) |
2223 "Display current image file. | |
2224 See documentation for `tumme-display-image' for more information. | |
2225 With prefix argument ARG, display image in its original size." | |
2226 (interactive "P") | |
2227 (tumme-display-image (dired-get-filename) arg)) | |
2228 | |
2229 (defun tumme-image-at-point-p () | |
2230 "Return true if there is a tumme thumbnail at point." | |
2231 (get-text-property (point) 'tumme-thumbnail)) | |
2232 | |
2233 (defun tumme-rotate-thumbnail (degrees) | |
2234 "Rotate thumbnail DEGREES degrees." | |
2235 (if (not (tumme-image-at-point-p)) | |
2236 (message "No thumbnail at point") | |
2237 (let ((file (tumme-thumb-name (tumme-original-file-name))) | |
2238 command) | |
2239 (setq command (format-spec | |
2240 tumme-cmd-rotate-thumbnail-options | |
2241 (list | |
2242 (cons ?p tumme-cmd-rotate-thumbnail-program) | |
2243 (cons ?d degrees) | |
2244 (cons ?t (expand-file-name file))))) | |
2245 (shell-command command nil) | |
2246 ;; Clear the cache to refresh image. I wish I could just refresh | |
2247 ;; the current file but I do not know how to do that. Yet... | |
2248 (clear-image-cache)))) | |
2249 | |
2250 (defun tumme-rotate-thumbnail-left () | |
2251 "Rotate thumbnail left (counter clockwise) 90 degrees. | |
2252 The result of the rotation is displayed in the image display area | |
2253 and a confirmation is needed before the original image files is | |
2254 overwritten. This confirmation can be turned off using | |
2255 `tumme-rotate-original-ask-before-overwrite'." | |
2256 (interactive) | |
2257 (tumme-rotate-thumbnail "270")) | |
2258 | |
2259 (defun tumme-rotate-thumbnail-right () | |
2260 "Rotate thumbnail counter right (clockwise) 90 degrees. | |
2261 The result of the rotation is displayed in the image display area | |
2262 and a confirmation is needed before the original image files is | |
2263 overwritten. This confirmation can be turned off using | |
2264 `tumme-rotate-original-ask-before-overwrite'." | |
2265 (interactive) | |
2266 (tumme-rotate-thumbnail "90")) | |
2267 | |
2268 (defun tumme-refresh-thumb () | |
2269 "Force creation of new image for current thumbnail." | |
2270 (interactive) | |
2271 (let ((file (tumme-original-file-name))) | |
2272 (clear-image-cache) | |
2273 (tumme-create-thumb file (tumme-thumb-name file)))) | |
2274 | |
2275 (defun tumme-rotate-original (degrees) | |
2276 "Rotate original image DEGREES degrees." | |
2277 (if (not (tumme-image-at-point-p)) | |
2278 (message "No image at point") | |
2279 (let ((file (tumme-original-file-name)) | |
2280 command temp-file) | |
2281 (if (not (string-match "\.[jJ][pP[eE]?[gG]$" file)) | |
2282 (error "Only JPEG images can be rotated!")) | |
2283 (setq command (format-spec | |
2284 tumme-cmd-rotate-original-options | |
2285 (list | |
2286 (cons ?p tumme-cmd-rotate-original-program) | |
2287 (cons ?d degrees) | |
2288 (cons ?o (expand-file-name file)) | |
2289 (cons ?t tumme-temp-rotate-image-file)))) | |
2290 (if (not (= 0 (shell-command command nil))) | |
2291 (error "Could not rotate image") | |
2292 (tumme-display-image tumme-temp-rotate-image-file) | |
2293 (if (or (and tumme-rotate-original-ask-before-overwrite | |
2294 (y-or-n-p "Rotate to temp file OK. Overwrite original image? ")) | |
2295 (not tumme-rotate-original-ask-before-overwrite)) | |
2296 (progn | |
2297 (copy-file tumme-temp-rotate-image-file file t) | |
2298 (tumme-refresh-thumb)) | |
2299 (tumme-display-image file)))))) | |
2300 | |
2301 (defun tumme-rotate-original-left () | |
2302 "Rotate original image left (counter clockwise) 90 degrees." | |
2303 (interactive) | |
2304 (tumme-rotate-original "270")) | |
2305 | |
2306 (defun tumme-rotate-original-right () | |
2307 "Rotate original image right (clockwise) 90 degrees." | |
2308 (interactive) | |
2309 (tumme-rotate-original "90")) | |
2310 | |
2311 (defun tumme-get-exif-file-name (file) | |
2312 "Use the image's EXIF information to return a unique file name. | |
2313 The file name should be unique as long as you do not take more than | |
2314 one picture per second. The original file name is suffixed at the end | |
2315 for traceability. The format of the returned file name is | |
2316 YYYY_MM_DD_HH_MM_DD_ORIG_FILE_NAME.jpg. Used from | |
2317 `tumme-copy-with-exif-file-name'." | |
2318 (let (data no-exif-data-found) | |
2319 (if (not (string-match "\.[Jj][Pp][Ee]?[Gg]$" (expand-file-name file))) | |
2320 (progn | |
2321 (setq no-exif-data-found t) | |
2322 (setq data | |
2323 (format-time-string | |
2324 "%Y:%m:%d %H:%M:%S" | |
2325 (nth 5 (file-attributes (expand-file-name file)))))) | |
2326 (setq data (tumme-get-exif-data (expand-file-name file) "DateTimeOriginal"))) | |
2327 (while (string-match "[ :]" data) | |
2328 (setq data (replace-match "_" nil nil data))) | |
2329 (format "%s%s%s" data | |
2330 (if no-exif-data-found | |
2331 "_noexif_" | |
2332 "_") | |
2333 (file-name-nondirectory file)))) | |
2334 | |
2335 (defun tumme-thumbnail-set-image-description () | |
2336 "Set the ImageDescription EXIF tag for the original image. | |
2337 If the image already has a value for this tag, it is used as the | |
2338 default value at the prompt." | |
2339 (interactive) | |
2340 (if (not (tumme-image-at-point-p)) | |
2341 (message "No thumbnail at point") | |
2342 (let* ((file (tumme-original-file-name)) | |
2343 (old-value (tumme-get-exif-data file "ImageDescription"))) | |
2344 (if (eq 0 | |
2345 (tumme-set-exif-data file "ImageDescription" | |
2346 (read-string "Value of ImageDescription: " old-value))) | |
2347 (message "Successfully wrote ImageDescription tag.") | |
2348 (error "Could not write ImageDescription tag"))))) | |
2349 | |
2350 (defun tumme-set-exif-data (file tag-name tag-value) | |
2351 "In FILE, set EXIF tag TAG-NAME to value TAG-VALUE." | |
2352 (let (command) | |
2353 (setq command (format-spec | |
2354 tumme-cmd-write-exif-data-options | |
2355 (list | |
2356 (cons ?p tumme-cmd-write-exif-data-program) | |
2357 (cons ?f (expand-file-name file)) | |
2358 (cons ?t tag-name) | |
2359 (cons ?v tag-value)))) | |
2360 (shell-command command nil))) | |
2361 | |
2362 (defun tumme-get-exif-data (file tag-name) | |
2363 "From FILE, return EXIF tag TAG-NAME." | |
2364 (let ((buf (get-buffer-create "*tumme-get-exif-data*")) | |
2365 command tag-value) | |
2366 (setq command (format-spec | |
2367 tumme-cmd-read-exif-data-options | |
2368 (list | |
2369 (cons ?p tumme-cmd-read-exif-data-program) | |
2370 (cons ?f file) | |
2371 (cons ?t tag-name)))) | |
2372 (save-excursion | |
2373 (set-buffer buf) | |
2374 (delete-region (point-min) (point-max)) | |
2375 (if (not (eq (shell-command command buf) 0)) | |
2376 (error "Could not get EXIF tag") | |
2377 (goto-char (point-min)) | |
2378 ;; Clean buffer from newlines and carriage returns before | |
2379 ;; getting final info | |
2380 (while (search-forward-regexp "[\n\r]" nil t) | |
2381 (replace-match "" nil t)) | |
2382 (setq tag-value (buffer-substring (point-min) (point-max))))) | |
2383 tag-value)) | |
2384 | |
2385 (defun tumme-copy-with-exif-file-name () | |
2386 "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
|
2387 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
|
2388 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
|
2389 `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
|
2390 copying images from a digital camera into the image directory. |
67302 | 2391 |
68757
3c76b1d6eff0
Tried to make docstring less `colloquial'...
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68754
diff
changeset
|
2392 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
|
2393 digital images, mark the files to be copied, and execute this |
67302 | 2394 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
|
2395 `tumme-main-image-directory' called |
3c76b1d6eff0
Tried to make docstring less `colloquial'...
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68754
diff
changeset
|
2396 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
|
2397 2005_05_08_14_27_45_dscn0320.jpg etc." |
67302 | 2398 (interactive) |
2399 (let (new-name | |
2400 (files (dired-get-marked-files))) | |
2401 (mapcar | |
2402 (lambda (curr-file) | |
2403 (setq new-name | |
2404 (format "%s/%s" | |
2405 (file-name-as-directory | |
2406 (expand-file-name tumme-main-image-directory)) | |
2407 (tumme-get-exif-file-name curr-file))) | |
2408 (message "Copying %s to %s" curr-file new-name) | |
2409 (copy-file curr-file new-name)) | |
2410 files))) | |
2411 | |
2412 (defun tumme-display-next-thumbnail-original () | |
2413 "In thubnail buffer, move to next thumbnail and display the image." | |
2414 (interactive) | |
2415 (tumme-forward-char) | |
2416 (tumme-display-thumbnail-original-image)) | |
2417 | |
2418 (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
|
2419 "Move to previous thumbnail and display image." |
67302 | 2420 |
2421 (interactive) | |
2422 (tumme-backward-char) | |
2423 (tumme-display-thumbnail-original-image)) | |
2424 | |
2425 (defun tumme-write-comment (file comment) | |
2426 "For FILE, write comment COMMENT in database." | |
2427 (save-excursion | |
68811 | 2428 (let (end buf comment-beg) |
67302 | 2429 (setq buf (find-file tumme-db-file)) |
2430 (goto-char (point-min)) | |
2431 (if (search-forward-regexp | |
68811 | 2432 (format "^%s" file) nil t) |
67302 | 2433 (progn |
2434 (end-of-line) | |
2435 (setq end (point)) | |
2436 (beginning-of-line) | |
2437 ;; Delete old comment, if any | |
2438 (cond ((search-forward ";comment:" end t) | |
2439 (setq comment-beg (match-beginning 0)) | |
2440 ;; Any tags after the comment? | |
2441 (if (search-forward ";" end t) | |
2442 (setq comment-end (- (point) 1)) | |
2443 (setq comment-end end)) | |
2444 ;; Delete comment tag and comment | |
2445 (delete-region comment-beg comment-end))) | |
2446 ;; Insert new comment | |
2447 (beginning-of-line) | |
2448 (if (not (search-forward ";" end t)) | |
2449 (progn | |
2450 (end-of-line) | |
2451 (insert ";"))) | |
2452 (insert (format "comment:%s;" comment))) | |
2453 ;; File does not exist in databse - add it. | |
2454 (goto-char (point-max)) | |
68811 | 2455 (insert (format "\n%s;comment:%s" file comment))) |
67302 | 2456 (save-buffer) |
2457 (kill-buffer buf)))) | |
2458 | |
2459 (defun tumme-update-property (prop value) | |
2460 "Update text property PROP with value VALUE at point." | |
2461 (let ((inhibit-read-only t)) | |
2462 (put-text-property | |
2463 (point) (1+ (point)) | |
2464 prop | |
2465 value))) | |
2466 | |
68682
23eaa0d773ea
Added more autoload cookies.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68675
diff
changeset
|
2467 ;;;###autoload |
67302 | 2468 (defun tumme-dired-comment-files () |
2469 "Add comment to current or marked files in dired." | |
2470 (interactive) | |
2471 (let ((files (dired-get-marked-files)) | |
2472 (comment (tumme-read-comment))) | |
2473 (mapcar | |
2474 (lambda (curr-file) | |
2475 (tumme-write-comment curr-file comment)) | |
2476 files))) | |
2477 | |
2478 (defun tumme-comment-thumbnail () | |
2479 "Add comment to current thumbnail in thumbnail buffer." | |
2480 (interactive) | |
2481 (let* ((file (tumme-original-file-name)) | |
2482 (comment (tumme-read-comment file))) | |
2483 (tumme-write-comment file comment) | |
2484 (tumme-update-property 'comment comment)) | |
2485 (tumme-display-thumb-properties)) | |
2486 | |
2487 (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
|
2488 "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
|
2489 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
|
2490 as initial value." |
67302 | 2491 (let ((comment |
2492 (read-string | |
2493 "Comment: " | |
2494 (if file (tumme-get-comment file))))) | |
2495 comment)) | |
2496 | |
2497 (defun tumme-get-comment (file) | |
2498 "Get comment for file FILE." | |
2499 (save-excursion | |
2500 (let (end buf comment-beg comment (base-name (file-name-nondirectory file))) | |
2501 (setq buf (find-file tumme-db-file)) | |
2502 (goto-char (point-min)) | |
2503 (if (search-forward-regexp | |
2504 (format "^%s" base-name) nil t) | |
2505 (progn | |
2506 (end-of-line) | |
2507 (setq end (point)) | |
2508 (beginning-of-line) | |
2509 (cond ((search-forward ";comment:" end t) | |
2510 (setq comment-beg (point)) | |
2511 (if (search-forward ";" end t) | |
2512 (setq comment-end (- (point) 1)) | |
2513 (setq comment-end end)) | |
2514 (setq comment (buffer-substring | |
2515 comment-beg comment-end)))))) | |
2516 (kill-buffer buf) | |
2517 comment))) | |
2518 | |
68682
23eaa0d773ea
Added more autoload cookies.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68675
diff
changeset
|
2519 ;;;###autoload |
67302 | 2520 (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
|
2521 "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
|
2522 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
|
2523 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
|
2524 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
|
2525 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
|
2526 matching tags will be marked in the dired buffer." |
67302 | 2527 (interactive) |
2528 (let ((tag (read-string "Mark tagged files (regexp): ")) | |
2529 (hits 0) | |
2530 files buf) | |
2531 (save-excursion | |
2532 (setq buf (find-file tumme-db-file)) | |
2533 (goto-char (point-min)) | |
2534 ;; Collect matches | |
2535 (while (search-forward-regexp | |
68811 | 2536 (concat "\\(^[^;\n]+\\);.*" tag ".*$") nil t) |
67302 | 2537 (setq files (append (list (match-string 1)) files))) |
2538 (kill-buffer buf) | |
2539 ;; Mark files | |
2540 (mapcar | |
2541 ;; I tried using `dired-mark-files-regexp' but it was | |
2542 ;; waaaay to slow. | |
2543 (lambda (curr-file) | |
2544 ;; Don't bother about hits found in other directories than | |
2545 ;; the current one. | |
2546 (when (string= (file-name-as-directory | |
2547 (expand-file-name default-directory)) | |
2548 (file-name-as-directory | |
2549 (file-name-directory curr-file))) | |
2550 (setq curr-file (file-name-nondirectory curr-file)) | |
2551 (goto-char (point-min)) | |
2552 (when (search-forward-regexp (format "\\s %s$" curr-file) nil t) | |
2553 (setq hits (+ hits 1)) | |
2554 (dired-mark 1)))) | |
2555 files)) | |
2556 (message "%d files with matching tag marked." hits))) | |
2557 | |
2558 (defun tumme-mouse-display-image (event) | |
2559 "Use mouse EVENT, call `tumme-display-image' to display image. | |
2560 Track this in associated dired buffer if `tumme-track-movement' is | |
2561 non-nil." | |
2562 (interactive "e") | |
2563 (let (file) | |
2564 (mouse-set-point event) | |
2565 (goto-char (posn-point (event-end event))) | |
2566 (setq file (tumme-original-file-name)) | |
2567 (if tumme-track-movement | |
2568 (tumme-track-original-file)) | |
2569 (tumme-display-image file))) | |
2570 | |
2571 (defun tumme-mouse-select-thumbnail (event) | |
2572 "Use mouse EVENT to select thumbnail image. | |
2573 Track this in associated dired buffer if `tumme-track-movement' is | |
2574 non-nil." | |
2575 (interactive "e") | |
2576 (let (file) | |
2577 (mouse-set-point event) | |
2578 (goto-char (posn-point (event-end event))) | |
2579 (if tumme-track-movement | |
2580 (tumme-track-original-file))) | |
2581 (tumme-display-thumb-properties)) | |
2582 | |
2583 (defun tumme-mouse-toggle-mark (event) | |
2584 "Use mouse EVENT to toggle dired mark for thumbnail. | |
2585 Track this in associated dired buffer if `tumme-track-movement' is | |
2586 non-nil." | |
2587 (interactive "e") | |
2588 (let (file) | |
2589 (mouse-set-point event) | |
2590 (goto-char (posn-point (event-end event))) | |
2591 (if tumme-track-movement | |
2592 (tumme-track-original-file))) | |
2593 (tumme-toggle-mark-thumb-original-file)) | |
2594 | |
2595 (defun tumme-dired-display-properties () | |
2596 "Display properties for dired file in the echo area." | |
2597 (interactive) | |
2598 (let* ((file (dired-get-filename)) | |
2599 (file-name (file-name-nondirectory file)) | |
2600 (dired-buf (buffer-name (current-buffer))) | |
2601 (props (mapconcat | |
2602 'princ | |
2603 (tumme-list-tags file) | |
2604 ", ")) | |
2605 (comment (tumme-get-comment file))) | |
2606 (if file-name | |
2607 (message | |
2608 (tumme-format-properties-string | |
2609 dired-buf | |
2610 file-name | |
2611 props | |
2612 comment))))) | |
2613 | |
2614 (defvar tumme-tag-file-list nil | |
2615 "List to store tag-file structure.") | |
2616 | |
2617 (defvar tumme-file-tag-list nil | |
2618 "List to store file-tag structure.") | |
2619 | |
2620 (defvar tumme-file-comment-list nil | |
2621 "List to store file comments.") | |
2622 | |
2623 (defun tumme-add-to-tag-file-list (tag file) | |
2624 "Add relation between TAG and FILE." | |
2625 (let (curr) | |
2626 (if tumme-tag-file-list | |
2627 (if (setq curr (assoc tag tumme-tag-file-list)) | |
2628 (if (not (member file curr)) | |
2629 (setcdr curr (cons file (cdr curr)))) | |
2630 (setcdr tumme-tag-file-list | |
2631 (cons (list tag file) (cdr tumme-tag-file-list)))) | |
2632 (setq tumme-tag-file-list (list (list tag file)))))) | |
2633 | |
2634 (defun tumme-add-to-tag-file-lists (tag file) | |
2635 "Helper function used from `tumme-create-gallery-lists'. | |
2636 | |
2637 Add TAG to FILE in one list and FILE to TAG in the other. | |
2638 | |
2639 Lisp structures look like the following: | |
2640 | |
2641 tumme-file-tag-list: | |
2642 | |
2643 ((\"filename1\" \"tag1\" \"tag2\" \"tag3\" ...) | |
2644 (\"filename2\" \"tag1\" \"tag2\" \"tag3\" ...) | |
2645 ...) | |
2646 | |
2647 tumme-tag-file-list: | |
2648 | |
2649 ((\"tag1\" \"filename1\" \"filename2\" \"filename3\" ...) | |
2650 (\"tag2\" \"filename1\" \"filename2\" \"filename3\" ...) | |
2651 ...)" | |
2652 ;; Add tag to file list | |
2653 (let (curr) | |
2654 (if tumme-file-tag-list | |
2655 (if (setq curr (assoc file tumme-file-tag-list)) | |
2656 (setcdr curr (cons tag (cdr curr))) | |
2657 (setcdr tumme-file-tag-list | |
2658 (cons (list file tag) (cdr tumme-file-tag-list)))) | |
2659 (setq tumme-file-tag-list (list (list file tag)))) | |
2660 ;; Add file to tag list | |
2661 (if tumme-tag-file-list | |
2662 (if (setq curr (assoc tag tumme-tag-file-list)) | |
2663 (if (not (member file curr)) | |
2664 (setcdr curr (cons file (cdr curr)))) | |
2665 (setcdr tumme-tag-file-list | |
2666 (cons (list tag file) (cdr tumme-tag-file-list)))) | |
2667 (setq tumme-tag-file-list (list (list tag file)))))) | |
2668 | |
2669 (defun tumme-add-to-file-comment-list (file comment) | |
2670 "Helper function used from `tumme-create-gallery-lists'. | |
2671 | |
2672 For FILE, add COMMENT to list. | |
2673 | |
2674 Lisp structure looks like the following: | |
2675 | |
2676 tumme-file-comment-list: | |
2677 | |
2678 ((\"filename1\" . \"comment1\") | |
2679 (\"filename2\" . \"comment2\") | |
2680 ...)" | |
2681 (if tumme-file-comment-list | |
2682 (if (not (assoc file tumme-file-comment-list)) | |
2683 (setcdr tumme-file-comment-list | |
2684 (cons (cons file comment) | |
2685 (cdr tumme-file-comment-list)))) | |
2686 (setq tumme-file-comment-list (list (cons file comment))))) | |
2687 | |
2688 (defun tumme-create-gallery-lists () | |
2689 "Create temporary lists used by `tumme-gallery-generate'." | |
2690 (let ((buf (find-file tumme-db-file)) | |
2691 end beg file row-tags) | |
2692 (setq tumme-tag-file-list nil) | |
2693 (setq tumme-file-tag-list nil) | |
2694 (setq tumme-file-comment-list nil) | |
2695 (goto-char (point-min)) | |
2696 (while (search-forward-regexp "^." nil t) | |
2697 (end-of-line) | |
2698 (setq end (point)) | |
2699 (beginning-of-line) | |
2700 (setq beg (point)) | |
2701 (if (not (search-forward ";" end nil)) | |
2702 (error "Something is really wrong, check format of database")) | |
2703 (setq row-tags (split-string | |
2704 (buffer-substring beg end) ";")) | |
2705 (setq file (car row-tags)) | |
2706 (mapc | |
2707 (lambda (x) | |
2708 (if (not (string-match "^comment:\\(.*\\)" x)) | |
2709 (tumme-add-to-tag-file-lists x file) | |
2710 (tumme-add-to-file-comment-list file (match-string 1 x)))) | |
2711 (cdr row-tags))) | |
2712 (kill-buffer buf)) | |
2713 ;; Sort tag-file list | |
2714 (setq tumme-tag-file-list | |
2715 (sort tumme-tag-file-list | |
2716 (lambda (x y) | |
2717 (string< (car x) (car y)))))) | |
2718 | |
2719 (defun tumme-hidden-p (file) | |
2720 "Return t if image FILE has a \"hidden\" tag." | |
2721 (let (hidden) | |
2722 (mapc | |
2723 (lambda (tag) | |
2724 (if (member tag tumme-gallery-hidden-tags) | |
2725 (setq hidden t))) | |
2726 (cdr (assoc file tumme-file-tag-list))) | |
2727 hidden)) | |
2728 | |
2729 (defun tumme-gallery-generate () | |
2730 "Generate gallery pages. | |
2731 First we create a couple of Lisp structures from the database to make | |
2732 it easier to generate, then HTML-files are created in | |
2733 `tumme-gallery-dir'" | |
2734 (interactive) | |
2735 (if (eq 'per-directory tumme-thumbnail-storage) | |
2736 (error "Currently, gallery generation is not supported \ | |
2737 when using per-directory thumbnail file storage")) | |
2738 (tumme-create-gallery-lists) | |
2739 (let ((tags tumme-tag-file-list) | |
2740 count curr tag index-buf tag-buf | |
2741 comment file-tags tag-link tag-link-list) | |
2742 ;; Make sure gallery root exist | |
2743 (if (file-exists-p tumme-gallery-dir) | |
2744 (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
|
2745 (error "Variable tumme-gallery-dir is not a directory")) |
67302 | 2746 (make-directory tumme-gallery-dir)) |
2747 ;; Open index file | |
2748 (setq index-buf (find-file | |
2749 (format "%s/index.html" tumme-gallery-dir))) | |
2750 (erase-buffer) | |
2751 (insert "<html>\n") | |
2752 (insert " <body>\n") | |
2753 (insert " <h2>Tumme Gallery</h2>\n") | |
2754 (insert (format "<p>\n Gallery generated %s\n <p>\n" | |
2755 (current-time-string))) | |
2756 (insert " <h3>Tag index</h3>\n") | |
2757 (setq count 1) | |
2758 ;; Pre-generate list of all tag links | |
2759 (mapc | |
2760 (lambda (curr) | |
2761 (setq tag (car curr)) | |
2762 (when (not (member tag tumme-gallery-hidden-tags)) | |
2763 (setq tag-link (format "<a href=\"%d.html\">%s</a>" count tag)) | |
2764 (if tag-link-list | |
2765 (setq tag-link-list | |
2766 (append tag-link-list (list (cons tag tag-link)))) | |
2767 (setq tag-link-list (list (cons tag tag-link)))) | |
2768 (setq count (1+ count)))) | |
2769 tags) | |
2770 (setq count 1) | |
2771 ;; Main loop where we generated thumbnail pages per tag | |
2772 (mapc | |
2773 (lambda (curr) | |
2774 (setq tag (car curr)) | |
2775 ;; Don't display hidden tags | |
2776 (when (not (member tag tumme-gallery-hidden-tags)) | |
2777 ;; Insert link to tag page in index | |
2778 (insert (format " %s<br>\n" (cdr (assoc tag tag-link-list)))) | |
2779 ;; Open per-tag file | |
2780 (setq tag-buf (find-file | |
2781 (format "%s/%s.html" tumme-gallery-dir count))) | |
2782 (erase-buffer) | |
2783 (insert "<html>\n") | |
2784 (insert " <body>\n") | |
2785 (insert " <p><a href=\"index.html\">Index</a></p>\n") | |
2786 (insert (format " <h2>Images with tag "%s"</h2>" tag)) | |
2787 ;; Main loop for files per tag page | |
2788 (mapc | |
2789 (lambda (file) | |
2790 (when (not (tumme-hidden-p file)) | |
2791 ;; Insert thumbnail with link to full image | |
2792 (insert | |
2793 (format "<a href=\"%s/%s\"><img src=\"%s/%s\"%s></a>\n" | |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2794 tumme-gallery-image-root-url (file-name-nondirectory file) |
67302 | 2795 tumme-gallery-thumb-image-root-url |
2796 (file-name-nondirectory (tumme-thumb-name file)) file)) | |
2797 ;; Insert comment, if any | |
2798 (if (setq comment (cdr (assoc file tumme-file-comment-list))) | |
2799 (insert (format "<br>\n%s<br>\n" comment)) | |
2800 (insert "<br>\n")) | |
2801 ;; Insert links to other tags, if any | |
2802 (when (> (length | |
2803 (setq file-tags (assoc file tumme-file-tag-list))) 2) | |
2804 (insert "[ ") | |
2805 (mapc | |
2806 (lambda (extra-tag) | |
2807 ;; Only insert if not file name or the main tag | |
2808 (if (and (not (equal extra-tag tag)) | |
2809 (not (equal extra-tag file))) | |
2810 (insert | |
2811 (format "%s " (cdr (assoc extra-tag tag-link-list)))))) | |
2812 file-tags) | |
2813 (insert "]<br>\n")))) | |
2814 (cdr curr)) | |
2815 (insert " <p><a href=\"index.html\">Index</a></p>\n") | |
2816 (insert " </body>\n") | |
2817 (insert "</html>\n") | |
2818 (save-buffer) | |
2819 (kill-buffer tag-buf) | |
2820 (setq count (1+ count)))) | |
2821 tags) | |
2822 (insert " </body>\n") | |
2823 (insert "</html>") | |
2824 (save-buffer) | |
2825 (kill-buffer index-buf))) | |
2826 | |
2827 (defun tumme-kill-buffer-and-window () | |
2828 "Kill the current buffer and, if possible, also the window." | |
2829 (interactive) | |
2830 (let ((buffer (current-buffer))) | |
2831 (condition-case nil | |
2832 (delete-window (selected-window)) | |
2833 (error nil)) | |
2834 (kill-buffer buffer))) | |
2835 | |
2836 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
2837 ;;;;;;;;; TEST-SECTION ;;;;;;;;;;; | |
2838 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
2839 | |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2840 ;; (defvar tumme-dir-max-size 12300000) |
67302 | 2841 |
68658
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2842 ;; (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
|
2843 ;; "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
|
2844 ;; \"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
|
2845 ;; 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
|
2846 ;; 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
|
2847 ;; (let* ((files |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2848 ;; (sort |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2849 ;; (mapcar |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2850 ;; (lambda (f) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2851 ;; (let ((fattribs (file-attributes f))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2852 ;; ;; 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
|
2853 ;; `(,(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
|
2854 ;; (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
|
2855 ;; ;; 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
|
2856 ;; '(lambda (l1 l2) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2857 ;; (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
|
2858 ;; (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
|
2859 ;; (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
|
2860 ;; (y-or-n-p |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2861 ;; (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
|
2862 ;; dirsize (cadr (cdar files)))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2863 ;; (delete-file (cadr (cdar files))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2864 ;; (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
|
2865 ;; (setq files (cdr files))))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2866 |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2867 ;;;;;;;;;;;;;;;;;;;;;;, |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2868 |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2869 ;; (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
|
2870 ;; (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
|
2871 ;; tumme-use-speedbar) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2872 ;; (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
|
2873 ;; (dired-get-filename)))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2874 ;; (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
|
2875 ;; (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
|
2876 ;; (erase-buffer) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2877 ;; (insert (propertize |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2878 ;; filename |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2879 ;; 'display |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2880 ;; (tumme-get-thumbnail-image filename))))))) |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2881 |
80719021c770
Some user interface changes: added command `tumme', etc.
Mathias Dahl <mathias.dahl@gmail.com>
parents:
68651
diff
changeset
|
2882 ;; (setq tumme-use-speedbar t) |
67302 | 2883 |
2884 (provide 'tumme) | |
2885 | |
67318 | 2886 ;; arch-tag: 9d11411d-331f-4380-8b44-8adfe3a0343e |
67302 | 2887 ;;; tumme.el ends here |