annotate lisp/tumme.el @ 71362:7f937fd4d17f

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