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