[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

misc thumbs changes

From: John Paul Wallington
Subject: misc thumbs changes
Date: Mon, 03 May 2004 06:46:37 +0100

How about installing the following changes?

2004-05-03  John Paul Wallington  <address@hidden>

        * thumbs.el (thumbs-subst-char-in-string): Doc fix.
        (thumbs-insert-image): Bind `inhibit-read-only' to t when
        inserting image.
        (thumbs-find-image-at-point): Do nothing if there is
        no image specified nor at point.
        (thumbs-show-name): Do nothing if no image at point.
        (thumbs-mouse-find-image): New command.
        (thumbs-mode-map): Bind it to mouse-2.
        (thumbs-mode): Make buffer read only.  Make mode-class special.
        (thumbs-view-image-mode): Likewise.

--- thumbs.el   29 Apr 2004 00:19:43 +0100      1.5
+++ thumbs.el   03 May 2004 06:45:08 +0100      
@@ -309,9 +309,10 @@
   (thumbs-resize-image t))
+;; borrowed from Dave Love
 (defun thumbs-subst-char-in-string (orig rep string)
   "Replace occurrences of character ORIG with character REP in STRING.
-Return the resulting (new) string.  -- (defun borowed to Dave Love)"
+Return the resulting (new) string."
   (let ((string (copy-sequence string))
        (l (length string))
        (i 0))
@@ -372,7 +373,8 @@
                   :relief ,relief
                   :conversion ,(if marked 'disabled)
                   :margin ,thumbs-margin)))
-    (insert-image i)
+    (let ((inhibit-read-only t))
+      (insert-image i))
     (setq thumbs-current-image-size
          (image-size i t))))
@@ -461,7 +463,7 @@
   (let* ((L thumbs-fileL)
         (n (point))
         (i (or img (cdr (assoc n L)))))
-    (thumbs-find-image i L n otherwin)))
+    (and i (thumbs-find-image i L n otherwin))))
 (defun thumbs-find-image-at-point-other-window ()
   "Display image for thumbnail at point in the preview buffer.
@@ -469,6 +471,12 @@
   (thumbs-find-image-at-point nil t))
+(defun thumbs-mouse-find-image (event)
+  "Display image for thumbnail at mouse click EVENT."
+  (interactive "e")
+  (mouse-set-point event)
+  (thumbs-find-image-at-point))
 (defun thumbs-call-setroot-command (img)
   "Call the setroot program for IMG."
   (run-hooks 'thumbs-before-setroot-hook)
@@ -640,7 +648,7 @@
   "Show the name of the current file."
   (let ((f (cdr (assoc (point) thumbs-fileL))))
-    (message "%s [%s]" f (thumbs-file-size f))))
+    (and f (message "%s [%s]" f (thumbs-file-size f)))))
 (defun thumbs-save-current-image ()
   "Save the current image."
@@ -661,6 +669,7 @@
 (defvar thumbs-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map [return] 'thumbs-find-image-at-point)
+    (define-key map [mouse-2] 'thumbs-mouse-find-image)
     (define-key map [(meta return)] 'thumbs-find-image-at-point-other-window)
     (define-key map [(control return)] 
     (define-key map [delete] 'thumbs-delete-images)
@@ -675,9 +684,11 @@
   "Keymap for `thumbs-mode'.")
+(put 'thumbs-mode 'mode-class 'special)
 (define-derived-mode thumbs-mode
   fundamental-mode "thumbs"
   "Preview images in a thumbnails buffer"
+  (setq buffer-read-only t)
   (make-variable-buffer-local 'thumbs-markedL)
   (setq thumbs-markedL nil))
@@ -697,9 +708,10 @@
   "Keymap for `thumbs-view-image-mode'.")
-;; thumbs-view-image-mode
+(put 'thumbs-mode 'mode-class 'special)
 (define-derived-mode thumbs-view-image-mode
-  fundamental-mode "image-view-mode")
+  fundamental-mode "image-view-mode"
+  (setq buffer-read-only t))
 (defun thumbs-dired-setroot ()

reply via email to

[Prev in Thread] Current Thread [Next in Thread]