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