Mercurial > emacs
annotate lisp/thumbs.el @ 83319:8f5787c83345
Change key-translation-map to be terminal-local.
* src/keymap.c (Vkey_translation_map): Remove.
(syms_of_keymap): Remove DEFVAR for key-translation-map.
(Fdescribe_buffer_bindings): Update for terminal-local key-translation-map.
* src/keyboard.h (kboard): Add Vkey_translation_map field.
(Vglobal_key_translation_map): Declare.
* src/keyboard.c (Vglobal_key_translation_map): New variable.
(syms_of_keyboard): DEFVAR it and Vkey_translation_map.
(mark_kboards): Mark key-translation-map.
(read_key_sequence): Update for terminal-local key-translation-map.
* src/emacs.c (main): Call syms_of_keymap before syms_of_keyboard.
* lisp/term/mac-win.el (mac-handle-language-change): Use
global-key-translation-map instead of key-translation-map.
* lisp/obsolete/iso-acc.el (iso-accents-customize): Ditto.
* lisp/international/iso-transl.el (iso-transl-ctl-x-8-map): Ditto.
* lisp/double.el (double-setup): Ditto.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-359
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Sun, 26 Jun 2005 21:06:46 +0000 |
parents | 2d9ef16c13be |
children | 6fb026ad601f a1b34dec1104 |
rev | line source |
---|---|
54186 | 1 ;;; thumbs.el --- Thumbnails previewer for images files |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
2 |
60920
242e5edee3ce
* complete.el, thumbs.el: Replace `legal' with `valid'.
Werner LEMBERG <wl@gnu.org>
parents:
59996
diff
changeset
|
3 ;; Copyright 2004, 2005 Free Software Foundation, Inc |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
4 |
54186 | 5 ;; Author: Jean-Philippe Theberge <jphiltheberge@videotron.ca> |
6 ;; Keywords: Multimedia | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
57831
diff
changeset
|
24 ;; |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
25 ;; Thanks: Alex Schroeder <alex@gnu.org> for maintaining the package at some time |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
26 ;; The peoples at #emacs@freenode.net for numerous help |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
27 ;; RMS for emacs and the GNU project. |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
28 ;; |
54186 | 29 |
30 ;;; Commentary: | |
31 | |
32 ;; This package create two new mode: thumbs-mode and | |
57831
5e17e1a1eacf
(group thumbs): Add :version keyword.
John Paul Wallington <jpw@pobox.com>
parents:
56934
diff
changeset
|
33 ;; thumbs-view-image-mode. It is used for images browsing and viewing |
5e17e1a1eacf
(group thumbs): Add :version keyword.
John Paul Wallington <jpw@pobox.com>
parents:
56934
diff
changeset
|
34 ;; from within Emacs. Minimal image manipulation functions are also |
54186 | 35 ;; available via external programs. |
36 ;; | |
37 ;; The 'convert' program from 'ImageMagick' | |
38 ;; [URL:http://www.imagemagick.org/] is required. | |
39 ;; | |
40 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
41 ;; CHANGELOG | |
42 ;; | |
43 ;; This is version 2.0 | |
44 ;; | |
45 ;; USAGE | |
46 ;; | |
47 ;; Type M-x thumbs RET DIR RET to view the directory DIR in Thumbs mode. | |
48 ;; That should be a directory containing image files. | |
49 ;; from dired, C-t m enter in thumbs-mode with all marked files | |
50 ;; C-t a enter in thumbs-mode with all files in current-directory | |
51 ;; In thumbs-mode, pressing <return> on a image will bring you in image view mode | |
52 ;; for that image. C-h m will give you a list of available keybinding. | |
53 | |
54 ;;; History: | |
55206
c2c29cafaa74
(time-less-p): Remove.
Juanma Barranquero <lekktu@gmail.com>
parents:
54193
diff
changeset
|
55 ;; |
54186 | 56 |
57 ;;; Code: | |
58 | |
59 (require 'dired) | |
60 | |
61 ;; CUSTOMIZATIONS | |
62 | |
63 (defgroup thumbs nil | |
64 "Thumbnails previewer." | |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
57831
diff
changeset
|
65 :version "22.1" |
54186 | 66 :group 'multimedia) |
67 | |
63155
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
68 (defcustom thumbs-thumbsdir "~/.emacs-thumbs" |
54186 | 69 "*Directory to store thumbnails." |
70 :type 'directory | |
71 :group 'thumbs) | |
72 | |
73 (defcustom thumbs-geometry "100x100" | |
74 "*Size of thumbnails." | |
75 :type 'string | |
76 :group 'thumbs) | |
77 | |
78 (defcustom thumbs-per-line 5 | |
79 "*Number of thumbnails per line to show in directory." | |
63313
2d9ef16c13be
(thumbs-per-line, thumbs-thumbsdir-max-size)
Eli Zaretskii <eliz@gnu.org>
parents:
63280
diff
changeset
|
80 :type 'integer |
54186 | 81 :group 'thumbs) |
82 | |
83 (defcustom thumbs-thumbsdir-max-size 50000000 | |
84 "Max size for thumbnails directory. | |
63078
2d7151e2c3ee
(thumbs-thumbsdir-max-size, thumbs-image-resizing-step,
Juanma Barranquero <lekktu@gmail.com>
parents:
62927
diff
changeset
|
85 When it reaches that size (in bytes), a warning is sent." |
63313
2d9ef16c13be
(thumbs-per-line, thumbs-thumbsdir-max-size)
Eli Zaretskii <eliz@gnu.org>
parents:
63280
diff
changeset
|
86 :type 'integer |
54186 | 87 :group 'thumbs) |
88 | |
89 (defcustom thumbs-conversion-program | |
63155
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
90 (if (eq system-type 'windows-nt) |
54186 | 91 "convert.exe" |
92 (or (executable-find "convert") | |
93 "/usr/X11R6/bin/convert")) | |
94 "*Name of conversion program for thumbnails generation. | |
95 It must be 'convert'." | |
96 :type 'string | |
97 :group 'thumbs) | |
98 | |
99 (defcustom thumbs-setroot-command | |
100 "xloadimage -onroot -fullscreen *" | |
101 "Command to set the root window." | |
102 :type 'string | |
103 :group 'thumbs) | |
104 | |
105 (defcustom thumbs-relief 5 | |
106 "*Size of button-like border around thumbnails." | |
63313
2d9ef16c13be
(thumbs-per-line, thumbs-thumbsdir-max-size)
Eli Zaretskii <eliz@gnu.org>
parents:
63280
diff
changeset
|
107 :type 'integer |
54186 | 108 :group 'thumbs) |
109 | |
110 (defcustom thumbs-margin 2 | |
111 "*Size of the margin around thumbnails. | |
112 This is where you see the cursor." | |
63313
2d9ef16c13be
(thumbs-per-line, thumbs-thumbsdir-max-size)
Eli Zaretskii <eliz@gnu.org>
parents:
63280
diff
changeset
|
113 :type 'integer |
54186 | 114 :group 'thumbs) |
115 | |
116 (defcustom thumbs-thumbsdir-auto-clean t | |
117 "If set, delete older file in the thumbnails directory. | |
118 Deletion is done at load time when the directory size is bigger | |
63078
2d7151e2c3ee
(thumbs-thumbsdir-max-size, thumbs-image-resizing-step,
Juanma Barranquero <lekktu@gmail.com>
parents:
62927
diff
changeset
|
119 than `thumbs-thumbsdir-max-size'." |
54186 | 120 :type 'boolean |
121 :group 'thumbs) | |
122 | |
123 (defcustom thumbs-image-resizing-step 10 | |
63078
2d7151e2c3ee
(thumbs-thumbsdir-max-size, thumbs-image-resizing-step,
Juanma Barranquero <lekktu@gmail.com>
parents:
62927
diff
changeset
|
124 "Step by which to resize image." |
63313
2d9ef16c13be
(thumbs-per-line, thumbs-thumbsdir-max-size)
Eli Zaretskii <eliz@gnu.org>
parents:
63280
diff
changeset
|
125 :type 'integer |
54186 | 126 :group 'thumbs) |
127 | |
63155
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
128 (defcustom thumbs-temp-dir temporary-file-directory |
54186 | 129 "Temporary directory to use. |
63155
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
130 Defaults to `temporary-file-directory'. Leaving it to |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
131 this value can let another user see some of your images." |
54186 | 132 :type 'directory |
133 :group 'thumbs) | |
134 | |
135 (defcustom thumbs-temp-prefix "emacsthumbs" | |
136 "Prefix to add to temp files." | |
137 :type 'string | |
138 :group 'thumbs) | |
139 | |
140 ;; Initialize some variable, for later use. | |
55206
c2c29cafaa74
(time-less-p): Remove.
Juanma Barranquero <lekktu@gmail.com>
parents:
54193
diff
changeset
|
141 (defvar thumbs-current-tmp-filename |
c2c29cafaa74
(time-less-p): Remove.
Juanma Barranquero <lekktu@gmail.com>
parents:
54193
diff
changeset
|
142 nil |
54186 | 143 "Temporary filename of current image.") |
55206
c2c29cafaa74
(time-less-p): Remove.
Juanma Barranquero <lekktu@gmail.com>
parents:
54193
diff
changeset
|
144 (defvar thumbs-current-image-filename |
54186 | 145 nil |
146 "Filename of current image.") | |
55206
c2c29cafaa74
(time-less-p): Remove.
Juanma Barranquero <lekktu@gmail.com>
parents:
54193
diff
changeset
|
147 (defvar thumbs-current-image-size |
54186 | 148 nil |
149 "Size of current image.") | |
55206
c2c29cafaa74
(time-less-p): Remove.
Juanma Barranquero <lekktu@gmail.com>
parents:
54193
diff
changeset
|
150 (defvar thumbs-image-num |
54186 | 151 nil |
152 "Number of current image.") | |
55206
c2c29cafaa74
(time-less-p): Remove.
Juanma Barranquero <lekktu@gmail.com>
parents:
54193
diff
changeset
|
153 (defvar thumbs-current-dir |
54186 | 154 nil |
155 "Current directory.") | |
55206
c2c29cafaa74
(time-less-p): Remove.
Juanma Barranquero <lekktu@gmail.com>
parents:
54193
diff
changeset
|
156 (defvar thumbs-markedL |
54186 | 157 nil |
158 "List of marked files.") | |
159 | |
63155
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
160 (defalias 'thumbs-gensym |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
161 (if (fboundp 'gensym) |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
162 'gensym |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
163 ;; Copied from cl-macs.el |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
164 (defvar thumbs-gensym-counter 0) |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
165 (lambda (&optional prefix) |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
166 "Generate a new uninterned symbol. |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
167 The name is made by appending a number to PREFIX, default \"G\"." |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
168 (let ((pfix (if (stringp prefix) prefix "G")) |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
169 (num (if (integerp prefix) prefix |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
170 (prog1 thumbs-gensym-counter |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
171 (setq thumbs-gensym-counter |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
172 (1+ thumbs-gensym-counter)))))) |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
173 (make-symbol (format "%s%d" pfix num)))))) |
54186 | 174 |
63280
69ae2aff114c
Fixes for changes of 2005-06-09.
Juanma Barranquero <lekktu@gmail.com>
parents:
63155
diff
changeset
|
175 (defsubst thumbs-temp-dir () |
69ae2aff114c
Fixes for changes of 2005-06-09.
Juanma Barranquero <lekktu@gmail.com>
parents:
63155
diff
changeset
|
176 (file-name-as-directory (expand-file-name thumbs-temp-dir))) |
69ae2aff114c
Fixes for changes of 2005-06-09.
Juanma Barranquero <lekktu@gmail.com>
parents:
63155
diff
changeset
|
177 |
63155
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
178 (defun thumbs-temp-file () |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
179 "Return a unique temporary filename for an image." |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
180 (format "%s%s-%s.jpg" |
63280
69ae2aff114c
Fixes for changes of 2005-06-09.
Juanma Barranquero <lekktu@gmail.com>
parents:
63155
diff
changeset
|
181 (thumbs-temp-dir) |
63155
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
182 thumbs-temp-prefix |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
183 (thumbs-gensym "T"))) |
54186 | 184 |
63155
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
185 (defun thumbs-thumbsdir () |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
186 "Return the current thumbnails directory (from `thumbs-thumbsdir'). |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
187 Create the thumbnails directory if it does not exist." |
63280
69ae2aff114c
Fixes for changes of 2005-06-09.
Juanma Barranquero <lekktu@gmail.com>
parents:
63155
diff
changeset
|
188 (let ((thumbs-thumbsdir (file-name-as-directory |
69ae2aff114c
Fixes for changes of 2005-06-09.
Juanma Barranquero <lekktu@gmail.com>
parents:
63155
diff
changeset
|
189 (expand-file-name thumbs-thumbsdir)))) |
63155
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
190 (unless (file-directory-p thumbs-thumbsdir) |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
191 (make-directory thumbs-thumbsdir) |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
192 (message "Creating thumbnails directory")) |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
193 thumbs-thumbsdir)) |
54186 | 194 |
195 (defun thumbs-cleanup-thumbsdir () | |
196 "Clean the thumbnails directory. | |
62692
6dd34b690fa9
(thumbs-thumbsdir-max-size, thumbs-temp-file, thumbs-cleanup-thumbsdir,
Juanma Barranquero <lekktu@gmail.com>
parents:
60920
diff
changeset
|
197 If the total size of all files in `thumbs-thumbsdir' is bigger than |
6dd34b690fa9
(thumbs-thumbsdir-max-size, thumbs-temp-file, thumbs-cleanup-thumbsdir,
Juanma Barranquero <lekktu@gmail.com>
parents:
60920
diff
changeset
|
198 `thumbs-thumbsdir-max-size', files are deleted until the max size is |
54186 | 199 reached." |
200 (let* ((filesL | |
201 (sort | |
202 (mapcar | |
203 (lambda (f) | |
204 (let ((fattribsL (file-attributes f))) | |
205 `(,(nth 4 fattribsL) ,(nth 7 fattribsL) ,f))) | |
63155
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
206 (directory-files (thumbs-thumbsdir) t (image-file-name-regexp))) |
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
207 '(lambda (l1 l2) (time-less-p (car l1) (car l2))))) |
54186 | 208 (dirsize (apply '+ (mapcar (lambda (x) (cadr x)) filesL)))) |
209 (while (> dirsize thumbs-thumbsdir-max-size) | |
210 (progn | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
211 (message "Deleting file %s" (cadr (cdar filesL)))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
212 (delete-file (cadr (cdar filesL))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
213 (setq dirsize (- dirsize (car (cdar filesL)))) |
54186 | 214 (setq filesL (cdr filesL))))) |
215 | |
216 ;; Check the thumbsnail directory size and clean it if necessary. | |
217 (when thumbs-thumbsdir-auto-clean | |
218 (thumbs-cleanup-thumbsdir)) | |
219 | |
220 (defun thumbs-call-convert (filein fileout action | |
221 &optional arg output-format action-prefix) | |
222 "Call the convert program. | |
223 FILEIN is the input file, | |
224 FILEOUT is the output file, | |
225 ACTION is the command to send to convert. | |
62692
6dd34b690fa9
(thumbs-thumbsdir-max-size, thumbs-temp-file, thumbs-cleanup-thumbsdir,
Juanma Barranquero <lekktu@gmail.com>
parents:
60920
diff
changeset
|
226 Optional arguments are: |
54186 | 227 ARG any arguments to the ACTION command, |
62692
6dd34b690fa9
(thumbs-thumbsdir-max-size, thumbs-temp-file, thumbs-cleanup-thumbsdir,
Juanma Barranquero <lekktu@gmail.com>
parents:
60920
diff
changeset
|
228 OUTPUT-FORMAT is the file format to output (default is jpeg), |
54186 | 229 ACTION-PREFIX is the symbol to place before the ACTION command |
62692
6dd34b690fa9
(thumbs-thumbsdir-max-size, thumbs-temp-file, thumbs-cleanup-thumbsdir,
Juanma Barranquero <lekktu@gmail.com>
parents:
60920
diff
changeset
|
230 (defaults to '-' but can sometimes be '+')." |
54186 | 231 (let ((command (format "%s %s%s %s \"%s\" \"%s:%s\"" |
232 thumbs-conversion-program | |
233 (or action-prefix "-") | |
234 action | |
235 (or arg "") | |
236 filein | |
237 (or output-format "jpeg") | |
238 fileout))) | |
239 (shell-command command))) | |
240 | |
241 (defun thumbs-increment-image-size-element (n d) | |
242 "Increment number N by D percent." | |
243 (round (+ n (/ (* d n) 100)))) | |
244 | |
245 (defun thumbs-decrement-image-size-element (n d) | |
246 "Decrement number N by D percent." | |
247 (round (- n (/ (* d n) 100)))) | |
248 | |
249 (defun thumbs-increment-image-size (s) | |
62692
6dd34b690fa9
(thumbs-thumbsdir-max-size, thumbs-temp-file, thumbs-cleanup-thumbsdir,
Juanma Barranquero <lekktu@gmail.com>
parents:
60920
diff
changeset
|
250 "Increment S (a cons of width x height)." |
54186 | 251 (cons |
252 (thumbs-increment-image-size-element (car s) | |
253 thumbs-image-resizing-step) | |
254 (thumbs-increment-image-size-element (cdr s) | |
255 thumbs-image-resizing-step))) | |
55206
c2c29cafaa74
(time-less-p): Remove.
Juanma Barranquero <lekktu@gmail.com>
parents:
54193
diff
changeset
|
256 |
54186 | 257 (defun thumbs-decrement-image-size (s) |
62692
6dd34b690fa9
(thumbs-thumbsdir-max-size, thumbs-temp-file, thumbs-cleanup-thumbsdir,
Juanma Barranquero <lekktu@gmail.com>
parents:
60920
diff
changeset
|
258 "Decrement S (a cons of width x height)." |
54186 | 259 (cons |
260 (thumbs-decrement-image-size-element (car s) | |
261 thumbs-image-resizing-step) | |
262 (thumbs-decrement-image-size-element (cdr s) | |
263 thumbs-image-resizing-step))) | |
264 | |
265 (defun thumbs-resize-image (&optional increment size) | |
266 "Resize image in current buffer. | |
63155
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
267 If INCREMENT is set, make the image bigger, else smaller. |
54186 | 268 Or, alternatively, a SIZE may be specified." |
269 (interactive) | |
270 ;; cleaning of old temp file | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
271 (condition-case nil |
54186 | 272 (apply 'delete-file |
273 (directory-files | |
63280
69ae2aff114c
Fixes for changes of 2005-06-09.
Juanma Barranquero <lekktu@gmail.com>
parents:
63155
diff
changeset
|
274 (thumbs-temp-dir) t |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
275 thumbs-temp-prefix)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
276 (error nil)) |
54186 | 277 (let ((buffer-read-only nil) |
278 (x (if size | |
279 size | |
280 (if increment | |
281 (thumbs-increment-image-size | |
282 thumbs-current-image-size) | |
283 (thumbs-decrement-image-size | |
284 thumbs-current-image-size)))) | |
63155
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
285 (tmp (thumbs-temp-file))) |
54186 | 286 (erase-buffer) |
287 (thumbs-call-convert thumbs-current-image-filename | |
288 tmp "sample" | |
289 (concat (number-to-string (car x)) "x" | |
290 (number-to-string (cdr x)))) | |
291 (thumbs-insert-image tmp 'jpeg 0) | |
292 (setq thumbs-current-tmp-filename tmp))) | |
293 | |
294 (defun thumbs-resize-interactive (width height) | |
63155
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
295 "Resize image interactively to specified WIDTH and HEIGHT." |
54186 | 296 (interactive "nWidth: \nnHeight: ") |
297 (thumbs-resize-image nil (cons width height))) | |
55206
c2c29cafaa74
(time-less-p): Remove.
Juanma Barranquero <lekktu@gmail.com>
parents:
54193
diff
changeset
|
298 |
54186 | 299 (defun thumbs-resize-image-size-down () |
300 "Resize image (smaller)." | |
301 (interactive) | |
302 (thumbs-resize-image nil)) | |
303 | |
304 (defun thumbs-resize-image-size-up () | |
305 "Resize image (bigger)." | |
306 (interactive) | |
307 (thumbs-resize-image t)) | |
308 | |
309 (defun thumbs-thumbname (img) | |
310 "Return a thumbnail name for the image IMG." | |
62891
58c1e48ab7bc
(thumbs-thumbname): The resulting thubname includes a hash value to improve its
Juanma Barranquero <lekktu@gmail.com>
parents:
62692
diff
changeset
|
311 (convert-standard-filename |
58c1e48ab7bc
(thumbs-thumbname): The resulting thubname includes a hash value to improve its
Juanma Barranquero <lekktu@gmail.com>
parents:
62692
diff
changeset
|
312 (let ((filename (expand-file-name img))) |
63280
69ae2aff114c
Fixes for changes of 2005-06-09.
Juanma Barranquero <lekktu@gmail.com>
parents:
63155
diff
changeset
|
313 (format "%s%08x-%s.jpg" |
63155
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
314 (thumbs-thumbsdir) |
62891
58c1e48ab7bc
(thumbs-thumbname): The resulting thubname includes a hash value to improve its
Juanma Barranquero <lekktu@gmail.com>
parents:
62692
diff
changeset
|
315 (sxhash filename) |
58c1e48ab7bc
(thumbs-thumbname): The resulting thubname includes a hash value to improve its
Juanma Barranquero <lekktu@gmail.com>
parents:
62692
diff
changeset
|
316 (subst-char-in-string |
58c1e48ab7bc
(thumbs-thumbname): The resulting thubname includes a hash value to improve its
Juanma Barranquero <lekktu@gmail.com>
parents:
62692
diff
changeset
|
317 ?\s ?\_ |
58c1e48ab7bc
(thumbs-thumbname): The resulting thubname includes a hash value to improve its
Juanma Barranquero <lekktu@gmail.com>
parents:
62692
diff
changeset
|
318 (apply |
58c1e48ab7bc
(thumbs-thumbname): The resulting thubname includes a hash value to improve its
Juanma Barranquero <lekktu@gmail.com>
parents:
62692
diff
changeset
|
319 'concat |
58c1e48ab7bc
(thumbs-thumbname): The resulting thubname includes a hash value to improve its
Juanma Barranquero <lekktu@gmail.com>
parents:
62692
diff
changeset
|
320 (split-string filename "/"))))))) |
54186 | 321 |
322 (defun thumbs-make-thumb (img) | |
323 "Create the thumbnail for IMG." | |
62891
58c1e48ab7bc
(thumbs-thumbname): The resulting thubname includes a hash value to improve its
Juanma Barranquero <lekktu@gmail.com>
parents:
62692
diff
changeset
|
324 (let ((fn (expand-file-name img)) |
58c1e48ab7bc
(thumbs-thumbname): The resulting thubname includes a hash value to improve its
Juanma Barranquero <lekktu@gmail.com>
parents:
62692
diff
changeset
|
325 (tn (thumbs-thumbname img))) |
54186 | 326 (if (or (not (file-exists-p tn)) |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
327 ;; This is not the right fix, but I don't understand |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
328 ;; the external program or why it produces a geometry |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
329 ;; unequal to the one requested -- rms. |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
330 ;;; (not (equal (thumbs-file-size tn) thumbs-geometry)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
331 ) |
54186 | 332 (thumbs-call-convert fn tn "sample" thumbs-geometry)) |
333 tn)) | |
55206
c2c29cafaa74
(time-less-p): Remove.
Juanma Barranquero <lekktu@gmail.com>
parents:
54193
diff
changeset
|
334 |
54186 | 335 (defun thumbs-image-type (img) |
336 "Return image type from filename IMG." | |
337 (cond ((string-match ".*\\.jpe?g\\'" img) 'jpeg) | |
338 ((string-match ".*\\.xpm\\'" img) 'xpm) | |
339 ((string-match ".*\\.xbm\\'" img) 'xbm) | |
340 ((string-match ".*\\.gif\\'" img) 'gif) | |
341 ((string-match ".*\\.bmp\\'" img) 'bmp) | |
342 ((string-match ".*\\.png\\'" img) 'png) | |
343 ((string-match ".*\\.tiff?\\'" img) 'tiff))) | |
344 | |
345 (defun thumbs-file-size (img) | |
346 (let ((i (image-size (find-image `((:type ,(thumbs-image-type img) :file ,img))) t))) | |
347 (concat (number-to-string (round (car i))) | |
348 "x" | |
349 (number-to-string (round (cdr i)))))) | |
55206
c2c29cafaa74
(time-less-p): Remove.
Juanma Barranquero <lekktu@gmail.com>
parents:
54193
diff
changeset
|
350 |
54186 | 351 ;;;###autoload |
352 (defun thumbs-find-thumb (img) | |
353 "Display the thumbnail for IMG." | |
354 (interactive "f") | |
355 (find-file (thumbs-make-thumb img))) | |
356 | |
357 (defun thumbs-insert-image (img type relief &optional marked) | |
358 "Insert image IMG at point. | |
359 TYPE and RELIEF will be used in constructing the image; see `image' | |
360 in the emacs-lisp manual for further documentation. | |
62692
6dd34b690fa9
(thumbs-thumbsdir-max-size, thumbs-temp-file, thumbs-cleanup-thumbsdir,
Juanma Barranquero <lekktu@gmail.com>
parents:
60920
diff
changeset
|
361 If MARKED is non-nil, the image is marked." |
54186 | 362 (let ((i `(image :type ,type |
363 :file ,img | |
364 :relief ,relief | |
365 :conversion ,(if marked 'disabled) | |
366 :margin ,thumbs-margin))) | |
367 (insert-image i) | |
368 (setq thumbs-current-image-size | |
369 (image-size i t)))) | |
370 | |
371 (defun thumbs-insert-thumb (img &optional marked) | |
372 "Insert the thumbnail for IMG at point. | |
62692
6dd34b690fa9
(thumbs-thumbsdir-max-size, thumbs-temp-file, thumbs-cleanup-thumbsdir,
Juanma Barranquero <lekktu@gmail.com>
parents:
60920
diff
changeset
|
373 If MARKED is non-nil, the image is marked." |
54186 | 374 (thumbs-insert-image |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
375 (thumbs-make-thumb img) 'jpeg thumbs-relief marked) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
376 (put-text-property (1- (point)) (point) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
377 'thumb-image-file img)) |
54186 | 378 |
379 (defun thumbs-do-thumbs-insertion (L) | |
380 "Insert all thumbs in list L." | |
381 (let ((i 0)) | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
382 (dolist (img L) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
383 (thumbs-insert-thumb img |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
384 (member img thumbs-markedL)) |
54186 | 385 (when (= 0 (mod (setq i (1+ i)) thumbs-per-line)) |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
386 (newline))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
387 (unless (bobp) (newline)))) |
54186 | 388 |
389 (defun thumbs-show-thumbs-list (L &optional buffer-name same-window) | |
62891
58c1e48ab7bc
(thumbs-thumbname): The resulting thubname includes a hash value to improve its
Juanma Barranquero <lekktu@gmail.com>
parents:
62692
diff
changeset
|
390 (unless (and (display-images-p) |
58c1e48ab7bc
(thumbs-thumbname): The resulting thubname includes a hash value to improve its
Juanma Barranquero <lekktu@gmail.com>
parents:
62692
diff
changeset
|
391 (image-type-available-p 'jpeg)) |
58c1e48ab7bc
(thumbs-thumbname): The resulting thubname includes a hash value to improve its
Juanma Barranquero <lekktu@gmail.com>
parents:
62692
diff
changeset
|
392 (error "Required image type is not supported in this Emacs session")) |
54186 | 393 (funcall (if same-window 'switch-to-buffer 'pop-to-buffer) |
394 (or buffer-name "*THUMB-View*")) | |
395 (let ((inhibit-read-only t)) | |
396 (erase-buffer) | |
397 (thumbs-mode) | |
398 (thumbs-do-thumbs-insertion L) | |
399 (goto-char (point-min)) | |
400 (setq thumbs-current-dir default-directory) | |
401 (make-variable-buffer-local 'thumbs-current-dir))) | |
402 | |
403 ;;;###autoload | |
404 (defun thumbs-show-all-from-dir (dir &optional reg same-window) | |
405 "Make a preview buffer for all images in DIR. | |
406 Optional argument REG to select file matching a regexp, | |
407 and SAME-WINDOW to show thumbs in the same window." | |
408 (interactive "DDir: ") | |
409 (thumbs-show-thumbs-list | |
410 (directory-files dir t | |
411 (or reg (image-file-name-regexp))) | |
412 (concat "*Thumbs: " dir) same-window)) | |
413 | |
414 ;;;###autoload | |
415 (defun thumbs-dired-show-marked () | |
62692
6dd34b690fa9
(thumbs-thumbsdir-max-size, thumbs-temp-file, thumbs-cleanup-thumbsdir,
Juanma Barranquero <lekktu@gmail.com>
parents:
60920
diff
changeset
|
416 "In dired, make a thumbs buffer with all marked files." |
54186 | 417 (interactive) |
418 (thumbs-show-thumbs-list (dired-get-marked-files) nil t)) | |
419 | |
420 ;;;###autoload | |
421 (defun thumbs-dired-show-all () | |
422 "In dired, make a thumbs buffer with all files in current directory." | |
423 (interactive) | |
424 (thumbs-show-all-from-dir default-directory nil t)) | |
425 | |
426 ;;;###autoload | |
427 (defalias 'thumbs 'thumbs-show-all-from-dir) | |
428 | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
429 (defun thumbs-find-image (img &optional num otherwin) |
57831
5e17e1a1eacf
(group thumbs): Add :version keyword.
John Paul Wallington <jpw@pobox.com>
parents:
56934
diff
changeset
|
430 (funcall |
54186 | 431 (if otherwin 'switch-to-buffer-other-window 'switch-to-buffer) |
432 (concat "*Image: " (file-name-nondirectory img) " - " | |
433 (number-to-string (or num 0)) "*")) | |
434 (thumbs-view-image-mode) | |
435 (let ((inhibit-read-only t)) | |
436 (setq thumbs-current-image-filename img | |
437 thumbs-current-tmp-filename nil | |
438 thumbs-image-num (or num 0)) | |
439 (make-variable-buffer-local 'thumbs-current-image-filename) | |
440 (make-variable-buffer-local 'thumbs-current-tmp-filename) | |
441 (make-variable-buffer-local 'thumbs-current-image-size) | |
442 (make-variable-buffer-local 'thumbs-image-num) | |
443 (delete-region (point-min)(point-max)) | |
444 (thumbs-insert-image img (thumbs-image-type img) 0))) | |
445 | |
446 (defun thumbs-find-image-at-point (&optional img otherwin) | |
447 "Display image IMG for thumbnail at point. | |
62692
6dd34b690fa9
(thumbs-thumbsdir-max-size, thumbs-temp-file, thumbs-cleanup-thumbsdir,
Juanma Barranquero <lekktu@gmail.com>
parents:
60920
diff
changeset
|
448 Use another window if OTHERWIN is t." |
54186 | 449 (interactive) |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
450 (let* ((i (or img (thumbs-current-image)))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
451 (thumbs-find-image i (point) otherwin))) |
54186 | 452 |
453 (defun thumbs-find-image-at-point-other-window () | |
454 "Display image for thumbnail at point in the preview buffer. | |
455 Open another window." | |
456 (interactive) | |
457 (thumbs-find-image-at-point nil t)) | |
458 | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
459 (defun thumbs-mouse-find-image (event) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
460 "Display image for thumbnail at mouse click EVENT." |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
461 (interactive "e") |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
462 (mouse-set-point event) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
463 (thumbs-find-image-at-point)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
464 |
54186 | 465 (defun thumbs-call-setroot-command (img) |
466 "Call the setroot program for IMG." | |
467 (run-hooks 'thumbs-before-setroot-hook) | |
468 (shell-command (replace-regexp-in-string | |
469 "\\*" | |
470 (shell-quote-argument (expand-file-name img)) | |
471 thumbs-setroot-command nil t)) | |
472 (run-hooks 'thumbs-after-setroot-hook)) | |
55206
c2c29cafaa74
(time-less-p): Remove.
Juanma Barranquero <lekktu@gmail.com>
parents:
54193
diff
changeset
|
473 |
54186 | 474 (defun thumbs-set-image-at-point-to-root-window () |
475 "Set the image at point as the desktop wallpaper." | |
476 (interactive) | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
477 (thumbs-call-setroot-command |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
478 (thumbs-current-image))) |
54186 | 479 |
480 (defun thumbs-set-root () | |
481 "Set the current image as root." | |
482 (interactive) | |
483 (thumbs-call-setroot-command | |
484 (or thumbs-current-tmp-filename | |
485 thumbs-current-image-filename))) | |
486 | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
487 (defun thumbs-file-alist () |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
488 "Make an alist of elements (POS . FILENAME) for all images in thumb buffer." |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
489 (save-excursion |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
490 (let (list) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
491 (goto-char (point-min)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
492 (while (not (eobp)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
493 (if (thumbs-current-image) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
494 (push (cons (point-marker) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
495 (thumbs-current-image)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
496 list)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
497 (forward-char 1)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
498 list))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
499 |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
500 (defun thumbs-file-list () |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
501 "Make a list of file names for all images in thumb buffer." |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
502 (save-excursion |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
503 (let (list) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
504 (goto-char (point-min)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
505 (while (not (eobp)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
506 (if (thumbs-current-image) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
507 (push (thumbs-current-image) list)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
508 (forward-char 1)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
509 (nreverse list)))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
510 |
54186 | 511 (defun thumbs-delete-images () |
62692
6dd34b690fa9
(thumbs-thumbsdir-max-size, thumbs-temp-file, thumbs-cleanup-thumbsdir,
Juanma Barranquero <lekktu@gmail.com>
parents:
60920
diff
changeset
|
512 "Delete the image at point (and its thumbnail) (or marked files if any)." |
54186 | 513 (interactive) |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
514 (let ((files (or thumbs-markedL (list (thumbs-current-image))))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
515 (if (yes-or-no-p (format "Really delete %d files? " (length files))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
516 (let ((thumbs-fileL (thumbs-file-alist)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
517 (inhibit-read-only t)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
518 (dolist (x files) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
519 (let (failure) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
520 (condition-case () |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
521 (progn |
54186 | 522 (delete-file x) |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
523 (delete-file (thumbs-thumbname x))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
524 (file-error (setq failure t))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
525 (unless failure |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
526 (when (rassoc x thumbs-fileL) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
527 (goto-char (car (rassoc x thumbs-fileL))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
528 (delete-region (point) (1+ (point)))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
529 (setq thumbs-markedL |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
530 (delq x thumbs-markedL))))))))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
531 |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
532 (defun thumbs-rename-images (newfile) |
62692
6dd34b690fa9
(thumbs-thumbsdir-max-size, thumbs-temp-file, thumbs-cleanup-thumbsdir,
Juanma Barranquero <lekktu@gmail.com>
parents:
60920
diff
changeset
|
533 "Rename the image at point (and its thumbnail) (or marked files if any)." |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
534 (interactive "FRename to file or directory: ") |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
535 (let ((files (or thumbs-markedL (list (thumbs-current-image)))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
536 failures) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
537 (if (and (not (file-directory-p newfile)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
538 thumbs-markedL) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
539 (if (file-exists-p newfile) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
540 (error "Renaming marked files to file name `%s'" newfile) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
541 (make-directory newfile t))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
542 (if (yes-or-no-p (format "Really rename %d files? " (length files))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
543 (let ((thumbs-fileL (thumbs-file-alist)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
544 (inhibit-read-only t)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
545 (dolist (file files) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
546 (let (failure) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
547 (condition-case () |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
548 (if (file-directory-p newfile) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
549 (rename-file file |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
550 (expand-file-name |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
551 (file-name-nondirectory file) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
552 newfile)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
553 (rename-file file newfile)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
554 (file-error (setq failure t) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
555 (push file failures))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
556 (unless failure |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
557 (when (rassoc file thumbs-fileL) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
558 (goto-char (car (rassoc file thumbs-fileL))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
559 (delete-region (point) (1+ (point)))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
560 (setq thumbs-markedL |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
561 (delq file thumbs-markedL))))))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
562 (if failures |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
563 (display-warning 'file-error |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
564 (format "Rename failures for %s into %s" |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
565 failures newfile) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
566 :error)))) |
54186 | 567 |
568 (defun thumbs-kill-buffer () | |
569 "Kill the current buffer." | |
570 (interactive) | |
63155
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
571 (quit-window t (selected-window))) |
54186 | 572 |
573 (defun thumbs-show-image-num (num) | |
574 "Show the image with number NUM." | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
575 (let ((image-buffer (get-buffer-create "*Image*"))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
576 (let ((i (thumbs-current-image))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
577 (with-current-buffer image-buffer |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
578 (thumbs-insert-image i (thumbs-image-type i) 0)) |
55213
a911edb6dadf
(thumbs-delete-images): Fix formatting of prompt.
John Paul Wallington <jpw@pobox.com>
parents:
55206
diff
changeset
|
579 (setq thumbs-image-num num |
a911edb6dadf
(thumbs-delete-images): Fix formatting of prompt.
John Paul Wallington <jpw@pobox.com>
parents:
55206
diff
changeset
|
580 thumbs-current-image-filename i)))) |
54186 | 581 |
582 (defun thumbs-next-image () | |
62692
6dd34b690fa9
(thumbs-thumbsdir-max-size, thumbs-temp-file, thumbs-cleanup-thumbsdir,
Juanma Barranquero <lekktu@gmail.com>
parents:
60920
diff
changeset
|
583 "Show the next image." |
54186 | 584 (interactive) |
585 (let* ((i (1+ thumbs-image-num)) | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
586 (list (thumbs-file-alist)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
587 (l (caar list))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
588 (while (and (/= i thumbs-image-num) (not (assoc i list))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
589 (setq i (if (>= i l) 1 (1+ i)))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
590 (thumbs-show-image-num i))) |
54186 | 591 |
592 (defun thumbs-previous-image () | |
593 "Show the previous image." | |
594 (interactive) | |
595 (let* ((i (- thumbs-image-num 1)) | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
596 (list (thumbs-file-alist)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
597 (l (caar list))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
598 (while (and (/= i thumbs-image-num) (not (assoc i list))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
599 (setq i (if (<= i 1) l (1- i)))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
600 (thumbs-show-image-num i))) |
54186 | 601 |
602 (defun thumbs-redraw-buffer () | |
603 "Redraw the current thumbs buffer." | |
604 (let ((p (point)) | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
605 (inhibit-read-only t) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
606 (files (thumbs-file-list))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
607 (erase-buffer) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
608 (thumbs-do-thumbs-insertion files) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
609 (goto-char p))) |
55206
c2c29cafaa74
(time-less-p): Remove.
Juanma Barranquero <lekktu@gmail.com>
parents:
54193
diff
changeset
|
610 |
54186 | 611 (defun thumbs-mark () |
612 "Mark the image at point." | |
613 (interactive) | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
614 (let ((elt (thumbs-current-image))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
615 (unless elt |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
616 (error "No image here")) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
617 (push elt thumbs-markedL) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
618 (let ((inhibit-read-only t)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
619 (delete-char 1) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
620 (thumbs-insert-thumb elt t))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
621 (when (eolp) (forward-char))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
622 |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
623 (defun thumbs-unmark () |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
624 "Unmark the image at point." |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
625 (interactive) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
626 (let ((elt (thumbs-current-image))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
627 (unless elt |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
628 (error "No image here")) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
629 (setq thumbs-markedL (delete elt thumbs-markedL)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
630 (let ((inhibit-read-only t)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
631 (delete-char 1) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
632 (thumbs-insert-thumb elt nil))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
633 (when (eolp) (forward-char))) |
55206
c2c29cafaa74
(time-less-p): Remove.
Juanma Barranquero <lekktu@gmail.com>
parents:
54193
diff
changeset
|
634 |
54186 | 635 ;; Image modification routines |
636 | |
637 (defun thumbs-modify-image (action &optional arg) | |
638 "Call convert to do ACTION on image with argument ARG. | |
60920
242e5edee3ce
* complete.el, thumbs.el: Replace `legal' with `valid'.
Werner LEMBERG <wl@gnu.org>
parents:
59996
diff
changeset
|
639 ACTION and ARG should be a valid convert command." |
54186 | 640 (interactive "sAction: \nsValue: ") |
641 ;; cleaning of old temp file | |
642 (mapc 'delete-file | |
643 (directory-files | |
63280
69ae2aff114c
Fixes for changes of 2005-06-09.
Juanma Barranquero <lekktu@gmail.com>
parents:
63155
diff
changeset
|
644 (thumbs-temp-dir) |
54186 | 645 t |
646 thumbs-temp-prefix)) | |
647 (let ((buffer-read-only nil) | |
63155
911109216331
Don't set `auto-image-file-mode'. Do not create the thumbnails directory on
Juanma Barranquero <lekktu@gmail.com>
parents:
63078
diff
changeset
|
648 (tmp (thumbs-temp-file))) |
54186 | 649 (erase-buffer) |
650 (thumbs-call-convert thumbs-current-image-filename | |
651 tmp | |
652 action | |
653 (or arg "")) | |
654 (thumbs-insert-image tmp 'jpeg 0) | |
655 (setq thumbs-current-tmp-filename tmp))) | |
656 | |
657 (defun thumbs-emboss-image (emboss) | |
658 "Emboss the image with value EMBOSS." | |
659 (interactive "nEmboss value: ") | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
660 (if (or (< emboss 3) (> emboss 31) (zerop (% emboss 2))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
661 (error "Arg must be an odd number between 3 and 31")) |
54186 | 662 (thumbs-modify-image "emboss" (number-to-string emboss))) |
663 | |
664 (defun thumbs-monochrome-image () | |
665 "Turn the image to monochrome." | |
666 (interactive) | |
667 (thumbs-modify-image "monochrome")) | |
668 | |
669 (defun thumbs-negate-image () | |
670 "Negate the image." | |
671 (interactive) | |
672 (thumbs-modify-image "negate")) | |
673 | |
674 (defun thumbs-rotate-left () | |
675 "Rotate the image 90 degrees counter-clockwise." | |
676 (interactive) | |
677 (thumbs-modify-image "rotate" "270")) | |
678 | |
679 (defun thumbs-rotate-right () | |
680 "Rotate the image 90 degrees clockwise." | |
681 (interactive) | |
682 (thumbs-modify-image "rotate" "90")) | |
683 | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
684 (defun thumbs-current-image () |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
685 "Return the name of the image file name at point." |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
686 (get-text-property (point) 'thumb-image-file)) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
687 |
54186 | 688 (defun thumbs-forward-char () |
689 "Move forward one image." | |
690 (interactive) | |
691 (forward-char) | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
692 (while (and (not (eobp)) (not (thumbs-current-image))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
693 (forward-char)) |
54186 | 694 (thumbs-show-name)) |
695 | |
696 (defun thumbs-backward-char () | |
697 "Move backward one image." | |
698 (interactive) | |
699 (forward-char -1) | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
700 (while (and (not (bobp)) (not (thumbs-current-image))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
701 (forward-char -1)) |
54186 | 702 (thumbs-show-name)) |
703 | |
704 (defun thumbs-forward-line () | |
705 "Move down one line." | |
706 (interactive) | |
707 (forward-line 1) | |
708 (thumbs-show-name)) | |
709 | |
710 (defun thumbs-backward-line () | |
711 "Move up one line." | |
712 (interactive) | |
713 (forward-line -1) | |
714 (thumbs-show-name)) | |
715 | |
716 (defun thumbs-show-name () | |
717 "Show the name of the current file." | |
718 (interactive) | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
719 (let ((f (thumbs-current-image))) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
720 (and f (message "%s [%s]" f (thumbs-file-size f))))) |
54186 | 721 |
722 (defun thumbs-save-current-image () | |
723 "Save the current image." | |
724 (interactive) | |
725 (let ((f (or thumbs-current-tmp-filename | |
726 thumbs-current-image-filename)) | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
727 (sa (read-from-minibuffer "Save image file as: " |
54186 | 728 thumbs-current-image-filename))) |
729 (copy-file f sa))) | |
730 | |
731 (defun thumbs-dired () | |
732 "Use `dired' on the current thumbs directory." | |
733 (interactive) | |
734 (dired thumbs-current-dir)) | |
735 | |
736 ;; thumbs-mode | |
737 | |
738 (defvar thumbs-mode-map | |
739 (let ((map (make-sparse-keymap))) | |
740 (define-key map [return] 'thumbs-find-image-at-point) | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
741 (define-key map [mouse-2] 'thumbs-mouse-find-image) |
54186 | 742 (define-key map [(meta return)] 'thumbs-find-image-at-point-other-window) |
743 (define-key map [(control return)] 'thumbs-set-image-at-point-to-root-window) | |
744 (define-key map [delete] 'thumbs-delete-images) | |
745 (define-key map [right] 'thumbs-forward-char) | |
746 (define-key map [left] 'thumbs-backward-char) | |
747 (define-key map [up] 'thumbs-backward-line) | |
748 (define-key map [down] 'thumbs-forward-line) | |
749 (define-key map "d" 'thumbs-dired) | |
750 (define-key map "m" 'thumbs-mark) | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
751 (define-key map "u" 'thumbs-unmark) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
752 (define-key map "R" 'thumbs-rename-images) |
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
753 (define-key map "x" 'thumbs-delete-images) |
54186 | 754 (define-key map "s" 'thumbs-show-name) |
755 (define-key map "q" 'thumbs-kill-buffer) | |
756 map) | |
757 "Keymap for `thumbs-mode'.") | |
758 | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
759 (put 'thumbs-mode 'mode-class 'special) |
54186 | 760 (define-derived-mode thumbs-mode |
761 fundamental-mode "thumbs" | |
762 "Preview images in a thumbnails buffer" | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
763 (setq buffer-read-only t) |
62927
bb23fe0bf1d3
(thumbs-mode): Fix misuse of make-variable-buffer-local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62891
diff
changeset
|
764 (set (make-local-variable 'thumbs-markedL) nil)) |
54186 | 765 |
766 (defvar thumbs-view-image-mode-map | |
767 (let ((map (make-sparse-keymap))) | |
768 (define-key map [prior] 'thumbs-previous-image) | |
769 (define-key map [next] 'thumbs-next-image) | |
770 (define-key map "-" 'thumbs-resize-image-size-down) | |
771 (define-key map "+" 'thumbs-resize-image-size-up) | |
772 (define-key map "<" 'thumbs-rotate-left) | |
773 (define-key map ">" 'thumbs-rotate-right) | |
774 (define-key map "e" 'thumbs-emboss-image) | |
775 (define-key map "r" 'thumbs-resize-interactive) | |
776 (define-key map "s" 'thumbs-save-current-image) | |
777 (define-key map "q" 'thumbs-kill-buffer) | |
56934
ff141f26a0cb
(thumbs-view-image-mode-map): Fix `thumbs-set-root' command name typo.
John Paul Wallington <jpw@pobox.com>
parents:
55827
diff
changeset
|
778 (define-key map "w" 'thumbs-set-root) |
54186 | 779 map) |
780 "Keymap for `thumbs-view-image-mode'.") | |
781 | |
782 ;; thumbs-view-image-mode | |
55827
c5c73c8c2b3e
Don't include cl. Don't bother with old Emacs versions.
Richard M. Stallman <rms@gnu.org>
parents:
55221
diff
changeset
|
783 (put 'thumbs-view-image-mode 'mode-class 'special) |
54186 | 784 (define-derived-mode thumbs-view-image-mode |
56934
ff141f26a0cb
(thumbs-view-image-mode-map): Fix `thumbs-set-root' command name typo.
John Paul Wallington <jpw@pobox.com>
parents:
55827
diff
changeset
|
785 fundamental-mode "image-view-mode" |
ff141f26a0cb
(thumbs-view-image-mode-map): Fix `thumbs-set-root' command name typo.
John Paul Wallington <jpw@pobox.com>
parents:
55827
diff
changeset
|
786 (setq buffer-read-only t)) |
54186 | 787 |
788 ;;;###autoload | |
789 (defun thumbs-dired-setroot () | |
62692
6dd34b690fa9
(thumbs-thumbsdir-max-size, thumbs-temp-file, thumbs-cleanup-thumbsdir,
Juanma Barranquero <lekktu@gmail.com>
parents:
60920
diff
changeset
|
790 "In dired, call the setroot program on the image at point." |
54186 | 791 (interactive) |
792 (thumbs-call-setroot-command (dired-get-filename))) | |
793 | |
794 ;; Modif to dired mode map | |
795 (define-key dired-mode-map "\C-ta" 'thumbs-dired-show-all) | |
796 (define-key dired-mode-map "\C-tm" 'thumbs-dired-show-marked) | |
797 (define-key dired-mode-map "\C-tw" 'thumbs-dired-setroot) | |
798 | |
799 (provide 'thumbs) | |
800 | |
62927
bb23fe0bf1d3
(thumbs-mode): Fix misuse of make-variable-buffer-local.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62891
diff
changeset
|
801 ;; arch-tag: f9ac1ef8-83fc-42c0-8069-1fae43fd2e5c |
54186 | 802 ;;; thumbs.el ends here |