]> code.delx.au - gnu-emacs/blobdiff - lisp/tumme.el
(unload-feature): Handle (t . SYMBOL) entries in load history.
[gnu-emacs] / lisp / tumme.el
index c9f9b83ef32169a2dab0b2783dd6a4c4fef17894..8d4527d8ff4d3b5f30382b17a6c93b848b33f44c 100644 (file)
@@ -1,6 +1,6 @@
 ;;; tumme.el --- use dired to browse and manipulate your images
 ;;
-;; Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
 ;;
 ;; Version: 0.4.11
 ;; Keywords: multimedia
   :group 'multimedia)
 
 (defcustom tumme-dir "~/.emacs.d/tumme/"
-  "*Directory where thumbnail images are stored."
+  "Directory where thumbnail images are stored."
   :type 'string
   :group 'tumme)
 
 (defcustom tumme-thumbnail-storage 'use-tumme-dir
-  "*How to store tumme's thumbnail files.
+  "How to store tumme's thumbnail files.
 Tumme can store thumbnail files in one of two ways and this is
 controlled by this variable.  \"Use tumme dir\" means that the
 thumbnails are stored in a central directory.  \"Per directory\"
@@ -193,17 +193,17 @@ that allows sharing of thumbnails across different programs."
   :group 'tumme)
 
 (defcustom tumme-db-file "~/.emacs.d/tumme/.tumme_db"
-  "*Database file where file names and their associated tags are stored."
+  "Database file where file names and their associated tags are stored."
   :type 'string
   :group 'tumme)
 
 (defcustom tumme-temp-image-file "~/.emacs.d/tumme/.tumme_temp"
-  "*Name of temporary image file used by various commands."
+  "Name of temporary image file used by various commands."
   :type 'string
   :group 'tumme)
 
 (defcustom tumme-gallery-dir "~/.emacs.d/tumme/.tumme_gallery"
-  "*Directory to store generated gallery html pages.
+  "Directory to store generated gallery html pages.
 This path needs to be \"shared\" to the public so that it can access
 the index.html page that tumme creates."
   :type 'string
@@ -211,7 +211,7 @@ the index.html page that tumme creates."
 
 (defcustom tumme-gallery-image-root-url
 "http://your.own.server/tummepics"
-  "*URL where the full size images are to be found.
+  "URL where the full size images are to be found.
 Note that this path has to be configured in your web server.  Tumme
 expects to find pictures in this directory."
   :type 'string
@@ -219,7 +219,7 @@ expects to find pictures in this directory."
 
 (defcustom tumme-gallery-thumb-image-root-url
 "http://your.own.server/tummethumbs"
-  "*URL where the thumbnail images are to be found.
+  "URL where the thumbnail images are to be found.
 Note that this path has to be configured in your web server.  Tumme
 expects to find pictures in this directory."
   :type 'string
@@ -227,14 +227,14 @@ expects to find pictures in this directory."
 
 (defcustom tumme-cmd-create-thumbnail-program
   "convert"
-  "*Executable used to create thumbnail.
+  "Executable used to create thumbnail.
 Used together with `tumme-cmd-create-thumbnail-options'."
   :type 'string
   :group 'tumme)
 
 (defcustom tumme-cmd-create-thumbnail-options
   "%p -size %wx%h \"%f\" -resize %wx%h +profile \"*\" jpeg:\"%t\""
-  "*Format of command used to create thumbnail image.
+  "Format of command used to create thumbnail image.
 Available options are %p which is replaced by
 `tumme-cmd-create-thumbnail-program', %w which is replaced by
 `tumme-thumb-width', %h which is replaced by `tumme-thumb-height',
@@ -245,14 +245,14 @@ which is replaced by the file name of the thumbnail file."
 
 (defcustom tumme-cmd-create-temp-image-program
   "convert"
-  "*Executable used to create temporary image.
+  "Executable used to create temporary image.
 Used together with `tumme-cmd-create-temp-image-options'."
   :type 'string
   :group 'tumme)
 
 (defcustom tumme-cmd-create-temp-image-options
   "%p -size %wx%h \"%f\" -resize %wx%h +profile \"*\" jpeg:\"%t\""
-  "*Format of command used to create temporary image for display window.
+  "Format of command used to create temporary image for display window.
 Available options are %p which is replaced by
 `tumme-cmd-create-temp-image-program', %w and %h which is replaced by
 the calculated max size for width and height in the image display window,
@@ -262,13 +262,13 @@ is replaced by the file name of the temporary file."
   :group 'tumme)
 
 (defcustom tumme-cmd-pngnq-program (executable-find "pngnq")
-  "*The file name of the `pngnq' program.
+  "The file name of the `pngnq' program.
 It quantizes colors of PNG images down to 256 colors."
   :type '(choice (const :tag "Not Set" nil) string)
   :group 'tumme)
 
 (defcustom tumme-cmd-pngcrush-program (executable-find "pngcrush")
-  "*The file name of the `pngcrush' program.
+  "The file name of the `pngcrush' program.
 It optimizes the compression of PNG images.  Also it adds PNG textual chunks
 with the information required by the Thumbnail Managing Standard."
   :type '(choice (const :tag "Not Set" nil) string)
@@ -305,20 +305,20 @@ with the information required by the Thumbnail Managing Standard."
         "-text b \"Thumb::URI\" \"file://%f\" "
         "%q %t"
         " ; rm %q")))
-  "*Command to create thumbnails according to the Thumbnail Managing Standard."
+  "Command to create thumbnails according to the Thumbnail Managing Standard."
   :type 'string
   :group 'tumme)
 
 (defcustom tumme-cmd-rotate-thumbnail-program
   "mogrify"
-  "*Executable used to rotate thumbnail.
+  "Executable used to rotate thumbnail.
 Used together with `tumme-cmd-rotate-thumbnail-options'."
   :type 'string
   :group 'tumme)
 
 (defcustom tumme-cmd-rotate-thumbnail-options
   "%p -rotate %d \"%t\""
-  "*Format of command used to rotate thumbnail image.
+  "Format of command used to rotate thumbnail image.
 Available options are %p which is replaced by
 `tumme-cmd-rotate-thumbnail-program', %d which is replaced by the
 number of (positive) degrees to rotate the image, normally 90 or 270
@@ -329,14 +329,14 @@ of the thumbnail file."
 
 (defcustom tumme-cmd-rotate-original-program
   "jpegtran"
-  "*Executable used to rotate original image.
+  "Executable used to rotate original image.
 Used together with `tumme-cmd-rotate-original-options'."
   :type 'string
   :group 'tumme)
 
 (defcustom tumme-cmd-rotate-original-options
-  "%p -rotate %d -copy all \"%o\" > %t"
-  "*Format of command used to rotate original image.
+  "%p -rotate %d -copy all -outfile %t \"%o\""
+  "Format of command used to rotate original image.
 Available options are %p which is replaced by
 `tumme-cmd-rotate-original-program', %d which is replaced by the
 number of (positive) degrees to rotate the image, normally 90 or
@@ -348,7 +348,7 @@ original image file name and %t which is replaced by
 
 (defcustom tumme-temp-rotate-image-file
   "~/.emacs.d/tumme/.tumme_rotate_temp"
-  "*Temporary file for rotate operations."
+  "Temporary file for rotate operations."
   :type 'string
   :group 'tumme)
 
@@ -361,14 +361,14 @@ original file with `tumme-temp-rotate-image-file'."
 
 (defcustom tumme-cmd-write-exif-data-program
   "exiftool"
-  "*Program used to write EXIF data to image.
+  "Program used to write EXIF data to image.
 Used together with `tumme-cmd-write-exif-data-options'."
   :type 'string
   :group 'tumme)
 
 (defcustom tumme-cmd-write-exif-data-options
   "%p -%t=\"%v\" \"%f\""
-  "*Format of command used to write EXIF data.
+  "Format of command used to write EXIF data.
 Available options are %p which is replaced by
 `tumme-cmd-write-exif-data-program', %f which is replaced by the
 image file name, %t which is replaced by the tag name and %v
@@ -378,14 +378,14 @@ which is replaced by the tag value."
 
 (defcustom tumme-cmd-read-exif-data-program
   "exiftool"
-  "*Program used to read EXIF data to image.
+  "Program used to read EXIF data to image.
 Used together with `tumme-cmd-read-exif-data-program-options'."
   :type 'string
   :group 'tumme)
 
 (defcustom tumme-cmd-read-exif-data-options
   "%p -s -s -s -%t \"%f\""
-  "*Format of command used to read EXIF data.
+  "Format of command used to read EXIF data.
 Available options are %p which is replaced by
 `tumme-cmd-write-exif-data-options', %f which is replaced
 by the image file name and %t which is replaced by the tag name."
@@ -394,7 +394,7 @@ by the image file name and %t which is replaced by the tag name."
 
 (defcustom tumme-gallery-hidden-tags
   (list "private" "hidden" "pending")
-  "*List of \"hidden\" tags.
+  "List of \"hidden\" tags.
 Used by `tumme-gallery-generate' to leave out \"hidden\" images."
   :type '(repeat string)
   :group 'tumme)
@@ -416,18 +416,18 @@ This is the default size for both `tumme-thumb-width' and `tumme-thumb-height'."
   :group 'tumme)
 
 (defcustom tumme-thumb-relief 2
-  "*Size of button-like border around thumbnails."
+  "Size of button-like border around thumbnails."
   :type 'integer
   :group 'tumme)
 
 (defcustom tumme-thumb-margin 2
-  "*Size of the margin around thumbnails.
+  "Size of the margin around thumbnails.
 This is where you see the cursor."
   :type 'integer
   :group 'tumme)
 
 (defcustom tumme-line-up-method 'dynamic
-  "*Default method for line-up of thumbnails in thumbnail buffer.
+  "Default method for line-up of thumbnails in thumbnail buffer.
 Used by `tumme-display-thumbs' and other functions that needs to
 line-up thumbnails.  Dynamic means to use the available width of the
 window containing the thumbnail buffer, Fixed means to use
@@ -441,19 +441,19 @@ line-up means that no automatic line-up will be done."
   :group 'tumme)
 
 (defcustom tumme-thumbs-per-row 3
-  "*Number of thumbnails to display per row in thumb buffer."
+  "Number of thumbnails to display per row in thumb buffer."
   :type 'integer
   :group 'tumme)
 
 (defcustom tumme-display-window-width-correction 1
-  "*Number to be used to correct image display window width.
+  "Number to be used to correct image display window width.
 Change if the default (1) does not work (i.e. if the image does not
 completely fit)."
   :type 'integer
   :group 'tumme)
 
 (defcustom tumme-display-window-height-correction 0
-  "*Number to be used to correct image display window height.
+  "Number to be used to correct image display window height.
 Change if the default (0) does not work (i.e. if the image does not
 completely fit)."
   :type 'integer
@@ -487,7 +487,7 @@ dired and you might want to turn it off."
   :group 'tumme)
 
 (defcustom tumme-display-properties-format "%b: %f (%t): %c"
-  "*Display format for thumbnail properties.
+  "Display format for thumbnail properties.
 %b is replaced with associated dired buffer name, %f with file name
 \(without path) of original image file, %t with the list of tags and %c
 with the comment."
@@ -500,20 +500,20 @@ with the comment."
   (cond ((executable-find "display"))
         ((executable-find "xli"))
         ((executable-find "qiv") "qiv -t"))
-  "*Name of external viewer.
+  "Name of external viewer.
 Including parameters.  Used when displaying original image from
 `tumme-thumbnail-mode'."
   :type 'string
   :group 'tumme)
 
 (defcustom tumme-main-image-directory "~/pics/"
-  "*Name of main image directory, if any.
+  "Name of main image directory, if any.
 Used by `tumme-copy-with-exif-file-name'."
   :type 'string
   :group 'tumme)
 
 (defcustom tumme-show-all-from-dir-max-files 50
-  "*Maximum number of files to show using `tumme-show-all-from-dir'.
+  "Maximum number of files to show using `tumme-show-all-from-dir'.
 before warning the user."
   :type 'integer
   :group 'tumme)
@@ -1009,7 +1009,7 @@ use only useful if `tumme-track-movement' is nil."
   (let ((old-buf (current-buffer))
         (dired-buf (tumme-associated-dired-buffer))
         (file-name (tumme-original-file-name)))
-    (when (and dired-buf file-name)
+    (when (and (buffer-live-p dired-buf) file-name)
       (setq file-name (file-name-nondirectory file-name))
       (set-buffer dired-buf)
       (goto-char (point-min))
@@ -1072,32 +1072,46 @@ move ARG lines."
   (if tumme-track-movement
       (tumme-track-thumbnail)))
 
-(defun tumme-forward-char ()
-  "Move to next image and display properties."
-  (interactive)
-  ;; Before we move, make sure that there is an image two positions
-  ;; forward.
-  (when (save-excursion
-        (forward-char 2)
-        (tumme-image-at-point-p))
-    (forward-char)
-    (while (and (not (eobp))
-                (not (tumme-image-at-point-p)))
-      (forward-char))
-    (if tumme-track-movement
-        (tumme-track-original-file)))
+(defun tumme-forward-image (&optional arg)
+  "Move to next image and display properties.
+Optional prefix ARG says how many images to move; default is one
+image."
+  (interactive "p")
+  (let (pos (steps (or arg 1)))
+    (dotimes (i steps)
+      (if (and (not (eobp))
+               (save-excursion
+                 (forward-char)
+                 (while (and (not (eobp))
+                             (not (tumme-image-at-point-p)))
+                   (forward-char))
+                 (setq pos (point))
+                 (tumme-image-at-point-p)))
+          (goto-char pos)
+        (error "At last image"))))
+  (when tumme-track-movement
+    (tumme-track-original-file))
   (tumme-display-thumb-properties))
 
-(defun tumme-backward-char ()
-  "Move to previous image and display properties."
-  (interactive)
-  (when (not (bobp))
-    (backward-char)
-    (while (and (not (bobp))
-                (not (tumme-image-at-point-p)))
-      (backward-char))
-    (if tumme-track-movement
-        (tumme-track-original-file)))
+(defun tumme-backward-image (&optional arg)
+  "Move to previous image and display properties.
+Optional prefix ARG says how many images to move; default is one
+image."
+  (interactive "p")
+  (let (pos (steps (or arg 1)))
+    (dotimes (i steps)
+      (if (and (not (bobp))
+               (save-excursion
+                 (backward-char)
+                 (while (and (not (bobp))
+                             (not (tumme-image-at-point-p)))
+                   (backward-char))
+                 (setq pos (point))
+                 (tumme-image-at-point-p)))
+          (goto-char pos)
+        (error "At first image"))))
+  (when tumme-track-movement
+    (tumme-track-original-file))
   (tumme-display-thumb-properties))
 
 (defun tumme-next-line ()
@@ -1106,7 +1120,7 @@ move ARG lines."
   (next-line 1)
   ;; If we end up in an empty spot, back up to the next thumbnail.
   (if (not (tumme-image-at-point-p))
-      (tumme-backward-char))
+      (tumme-backward-image))
   (if tumme-track-movement
       (tumme-track-original-file))
   (tumme-display-thumb-properties))
@@ -1121,7 +1135,7 @@ move ARG lines."
   ;; thumbnail and did not refresh, so it is not very common. But we
   ;; can handle it in a good manner, so why not?
   (if (not (tumme-image-at-point-p))
-      (tumme-backward-char))
+      (tumme-backward-image))
   (if tumme-track-movement
       (tumme-track-original-file))
   (tumme-display-thumb-properties))
@@ -1134,7 +1148,7 @@ comment."
   (format-spec
    tumme-display-properties-format
    (list
-    (cons ?b buf)
+    (cons ?b (or buf ""))
     (cons ?f file)
     (cons ?t (or (princ props) ""))
     (cons ?c (or comment "")))))
@@ -1190,19 +1204,19 @@ dired."
   "Mark original image file in associated dired buffer."
   (interactive)
   (tumme-modify-mark-on-thumb-original-file 'mark)
-  (tumme-forward-char))
+  (tumme-forward-image))
 
 (defun tumme-unmark-thumb-original-file ()
   "Unmark original image file in associated dired buffer."
   (interactive)
   (tumme-modify-mark-on-thumb-original-file 'unmark)
-  (tumme-forward-char))
+  (tumme-forward-image))
 
 (defun tumme-flag-thumb-original-file ()
   "Flag original image file for deletion in associated dired buffer."
   (interactive)
   (tumme-modify-mark-on-thumb-original-file 'flag)
-  (tumme-forward-char))
+  (tumme-forward-image))
 
 (defun tumme-toggle-mark-thumb-original-file ()
   "Toggle mark on original image file in associated dired buffer."
@@ -1250,12 +1264,12 @@ You probably want to use this together with
   "Define keymap for `tumme-thumbnail-mode'."
 
   ;; Keys
-  (define-key tumme-thumbnail-mode-map [right] 'tumme-forward-char)
-  (define-key tumme-thumbnail-mode-map [left] 'tumme-backward-char)
+  (define-key tumme-thumbnail-mode-map [right] 'tumme-forward-image)
+  (define-key tumme-thumbnail-mode-map [left] 'tumme-backward-image)
   (define-key tumme-thumbnail-mode-map [up] 'tumme-previous-line)
   (define-key tumme-thumbnail-mode-map [down] 'tumme-next-line)
-  (define-key tumme-thumbnail-mode-map "\C-f" 'tumme-forward-char)
-  (define-key tumme-thumbnail-mode-map "\C-b" 'tumme-backward-char)
+  (define-key tumme-thumbnail-mode-map "\C-f" 'tumme-forward-image)
+  (define-key tumme-thumbnail-mode-map "\C-b" 'tumme-backward-image)
   (define-key tumme-thumbnail-mode-map "\C-p" 'tumme-previous-line)
   (define-key tumme-thumbnail-mode-map "\C-n" 'tumme-next-line)
 
@@ -1632,7 +1646,7 @@ Ask user for number of images to show and the delay in between."
 
 ;;;###autoload
 (defun tumme-display-thumb ()
-  "Shorthard for `tumme-display-thumbs' with prefix argument."
+  "Shorthand for `tumme-display-thumbs' with prefix argument."
   (interactive)
   (tumme-display-thumbs t nil t))
 
@@ -2007,13 +2021,13 @@ function.  The result is a couple of new files in
 (defun tumme-display-next-thumbnail-original ()
   "In thubnail buffer, move to next thumbnail and display the image."
   (interactive)
-  (tumme-forward-char)
+  (tumme-forward-image)
   (tumme-display-thumbnail-original-image))
 
 (defun tumme-display-previous-thumbnail-original ()
   "Move to previous thumbnail and display image."
   (interactive)
-  (tumme-backward-char)
+  (tumme-backward-image)
   (tumme-display-thumbnail-original-image))
 
 (defun tumme-write-comments (file-comments)
@@ -2021,7 +2035,7 @@ function.  The result is a couple of new files in
 Write file comments to one or more files.  FILE-COMMENTS is an alist on
 the following form:
  ((FILE . COMMENT) ... )"
-  (let (end comment-beg file comment)
+  (let (end comment-beg-pos comment-end-pos file comment)
     (with-temp-file tumme-db-file
       (insert-file-contents tumme-db-file)
       (dolist (elt file-comments)
@@ -2034,13 +2048,13 @@ the following form:
              (beginning-of-line)
              ;; Delete old comment, if any
              (when (search-forward ";comment:" end t)
-               (setq comment-beg (match-beginning 0))
+               (setq comment-beg-pos (match-beginning 0))
                ;; Any tags after the comment?
                (if (search-forward ";" end t)
-                   (setq comment-end (- (point) 1))
-                 (setq comment-end end))
+                   (setq comment-end-pos (- (point) 1))
+                 (setq comment-end-pos end))
                ;; Delete comment tag and comment
-               (delete-region comment-beg comment-end))
+               (delete-region comment-beg-pos comment-end-pos))
              ;; Insert new comment
              (beginning-of-line)
              (unless (search-forward ";" end t)
@@ -2092,7 +2106,7 @@ as initial value."
 (defun tumme-get-comment (file)
   "Get comment for file FILE."
   (save-excursion
-    (let (end buf comment-beg comment)
+    (let (end buf comment-beg-pos comment-end-pos comment)
       (setq buf (find-file tumme-db-file))
       (goto-char (point-min))
       (when (search-forward-regexp
@@ -2101,12 +2115,12 @@ as initial value."
         (setq end (point))
         (beginning-of-line)
         (cond ((search-forward ";comment:" end t)
-               (setq comment-beg (point))
+               (setq comment-beg-pos (point))
                (if (search-forward ";" end t)
-                   (setq comment-end (- (point) 1))
-                 (setq comment-end end))
+                   (setq comment-end-pos (- (point) 1))
+                 (setq comment-end-pos end))
                (setq comment (buffer-substring
-                              comment-beg comment-end)))))
+                              comment-beg-pos comment-end-pos)))))
       (kill-buffer buf)
       comment)))