annotate lisp/tumme.el @ 74197:a6d2e4685692

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