]> code.delx.au - gnu-emacs/commitdiff
(image-get-display-property): New fun.
authorStefan Monnier <monnier@iro.umontreal.ca>
Mon, 18 Feb 2008 04:08:04 +0000 (04:08 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Mon, 18 Feb 2008 04:08:04 +0000 (04:08 +0000)
(image-forward-hscroll, image-next-line, image-eol, image-eob, image-mode)
(image-minor-mode, image-toggle-display-text, image-toggle-display): Use it.

lisp/ChangeLog
lisp/image-mode.el

index 24800d3bad1ecd43458cb72196c8a21c8e2abd1f..ee3be593fb26ce7d0eac3a9ba26ccb6d45ff29d9 100644 (file)
@@ -1,3 +1,10 @@
+2008-02-18  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * image-mode.el (image-get-display-property): New fun.
+       (image-forward-hscroll, image-next-line, image-eol, image-eob)
+       (image-mode, image-minor-mode, image-toggle-display-text)
+       (image-toggle-display): Use it.
+
 2008-02-18  Jason Rumney  <jasonr@gnu.org>
 
        * international/mule.el (xml-find-file-coding-system): Don't warn
@@ -5,8 +12,8 @@
 
        * nxml/nxml-mode.el (nxml-mode): Don't add a write-contents-hook.
 
-       * international/mule.el (sgml-xml-auto-coding-function): Detect
-       and warn if file encoding is not utf-8 and encoding not specified.
+       * international/mule.el (sgml-xml-auto-coding-function): Detect and
+       warn if file encoding is not utf-8 and encoding not specified.
        (xml-find-file-coding-system): New function.
        * international/mule-conf.el (file-coding-system-alist): Use it.
 
        * net/tramp-cache.el (tramp-flush-connection-property): Remove EVENT.
 
        * net/tramp-fish.el (tramp-fish-maybe-open-connection):
-       * net/tramp-smb.el (tramp-smb-maybe-open-connection): Use
-       `tramp-process-sentinel' as process sentinel.
+       * net/tramp-smb.el (tramp-smb-maybe-open-connection):
+       Use `tramp-process-sentinel' as process sentinel.
 
 2008-02-02  Juanma Barranquero  <lekktu@gmail.com>
 
index 9411e5d56888e0d6c9bb66442da7b4561c8f0c4f..56dff23e9ba9bdd11dc3843bda1aabda6143ffcf 100644 (file)
    'nomini
    (selected-frame)))
 
+(defun image-get-display-property ()
+  (get-char-property (point-min) 'display
+                     ;; There might be different images for different displays.
+                     (if (eq (window-buffer) (current-buffer))
+                         (selected-window))))
+
 (defun image-forward-hscroll (&optional n)
   "Scroll image in current window to the left by N character widths.
 Stop if the right edge of the image is reached."
@@ -97,7 +103,7 @@ Stop if the right edge of the image is reached."
         (image-set-window-hscroll (selected-window)
                                   (max 0 (+ (window-hscroll) n))))
        (t
-        (let* ((image (get-char-property (point-min) 'display))
+        (let* ((image (image-get-display-property))
                (edges (window-inside-edges))
                (win-width (- (nth 2 edges) (nth 0 edges)))
                (img-width (ceiling (car (image-size image)))))
@@ -120,7 +126,7 @@ Stop if the bottom edge of the image is reached."
         (image-set-window-vscroll (selected-window)
                                   (max 0 (+ (window-vscroll) n))))
        (t
-        (let* ((image (get-char-property (point-min) 'display))
+        (let* ((image (image-get-display-property))
                (edges (window-inside-edges))
                (win-height (- (nth 3 edges) (nth 1 edges)))
                (img-height (ceiling (cdr (image-size image)))))
@@ -194,7 +200,7 @@ stopping if the top or bottom edge of the image is reached."
   (and arg
        (/= (setq arg (prefix-numeric-value arg)) 1)
        (image-next-line (- arg 1)))
-  (let* ((image (get-char-property (point-min) 'display))
+  (let* ((image (image-get-display-property))
         (edges (window-inside-edges))
         (win-width (- (nth 2 edges) (nth 0 edges)))
         (img-width (ceiling (car (image-size image)))))
@@ -210,7 +216,7 @@ stopping if the top or bottom edge of the image is reached."
 (defun image-eob ()
   "Scroll to the bottom-right corner of the image in the current window."
   (interactive)
-  (let* ((image (get-char-property (point-min) 'display))
+  (let* ((image (image-get-display-property))
         (edges (window-inside-edges))
         (win-width (- (nth 2 edges) (nth 0 edges)))
         (img-width (ceiling (car (image-size image))))
@@ -271,7 +277,7 @@ to toggle between display as an image and display as text."
 
   (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t)
   (if (and (display-images-p)
-          (not (get-char-property (point-min) 'display)))
+          (not (image-get-display-property)))
       (image-toggle-display)
     ;; Set next vars when image is already displayed but local
     ;; variables were cleared by kill-all-local-variables
@@ -282,7 +288,7 @@ to toggle between display as an image and display as text."
       (message "%s" (concat
                     (substitute-command-keys
                      "Type \\[image-toggle-display] to view as ")
-                    (if (get-char-property (point-min) 'display)
+                    (if (image-get-display-property)
                         "text" "an image") "."))))
 
 ;;;###autoload
@@ -295,13 +301,13 @@ See the command `image-mode' for more information on this mode."
   :version "22.1"
   (if (not image-minor-mode)
       (image-toggle-display-text)
-    (if (get-char-property (point-min) 'display)
+    (if (image-get-display-property)
        (setq cursor-type nil truncate-lines t)
       (setq image-type "text"))
     (add-hook 'change-major-mode-hook (lambda () (image-minor-mode -1)) nil t)
     (message "%s" (concat (substitute-command-keys
                           "Type \\[image-toggle-display] to view the image as ")
-                         (if (get-char-property (point-min) 'display)
+                         (if (image-get-display-property)
                              "text" "an image") "."))))
 
 ;;;###autoload
@@ -331,7 +337,7 @@ information on these modes."
 
 (defun image-toggle-display-text ()
   "Showing the text of the image file."
-  (if (get-char-property (point-min) 'display)
+  (if (image-get-display-property)
       (image-toggle-display)))
 
 (defvar archive-superior-buffer)
@@ -342,7 +348,7 @@ information on these modes."
 This command toggles between showing the text of the image file
 and showing the image as an image."
   (interactive)
-  (if (get-char-property (point-min) 'display)
+  (if (image-get-display-property)
       (let ((inhibit-read-only t)
            (buffer-undo-list t)
            (modified (buffer-modified-p)))