aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2008-02-18 04:08:04 +0000
committerStefan Monnier2008-02-18 04:08:04 +0000
commit917844623bc50499a6b06c0d5f30d6a21dd1e7a5 (patch)
tree620e355d94c3bd2d1be3afcb881c8b3fcd0c8a48
parent228de8de4f72d92bdf4b3395086c826933ab6a72 (diff)
downloademacs-917844623bc50499a6b06c0d5f30d6a21dd1e7a5.tar.gz
emacs-917844623bc50499a6b06c0d5f30d6a21dd1e7a5.zip
(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.
-rw-r--r--lisp/ChangeLog15
-rw-r--r--lisp/image-mode.el26
2 files changed, 27 insertions, 14 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 24800d3bad1..ee3be593fb2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12008-02-18 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * image-mode.el (image-get-display-property): New fun.
4 (image-forward-hscroll, image-next-line, image-eol, image-eob)
5 (image-mode, image-minor-mode, image-toggle-display-text)
6 (image-toggle-display): Use it.
7
12008-02-18 Jason Rumney <jasonr@gnu.org> 82008-02-18 Jason Rumney <jasonr@gnu.org>
2 9
3 * international/mule.el (xml-find-file-coding-system): Don't warn 10 * international/mule.el (xml-find-file-coding-system): Don't warn
@@ -5,8 +12,8 @@
5 12
6 * nxml/nxml-mode.el (nxml-mode): Don't add a write-contents-hook. 13 * nxml/nxml-mode.el (nxml-mode): Don't add a write-contents-hook.
7 14
8 * international/mule.el (sgml-xml-auto-coding-function): Detect 15 * international/mule.el (sgml-xml-auto-coding-function): Detect and
9 and warn if file encoding is not utf-8 and encoding not specified. 16 warn if file encoding is not utf-8 and encoding not specified.
10 (xml-find-file-coding-system): New function. 17 (xml-find-file-coding-system): New function.
11 * international/mule-conf.el (file-coding-system-alist): Use it. 18 * international/mule-conf.el (file-coding-system-alist): Use it.
12 19
@@ -531,8 +538,8 @@
531 * net/tramp-cache.el (tramp-flush-connection-property): Remove EVENT. 538 * net/tramp-cache.el (tramp-flush-connection-property): Remove EVENT.
532 539
533 * net/tramp-fish.el (tramp-fish-maybe-open-connection): 540 * net/tramp-fish.el (tramp-fish-maybe-open-connection):
534 * net/tramp-smb.el (tramp-smb-maybe-open-connection): Use 541 * net/tramp-smb.el (tramp-smb-maybe-open-connection):
535 `tramp-process-sentinel' as process sentinel. 542 Use `tramp-process-sentinel' as process sentinel.
536 543
5372008-02-02 Juanma Barranquero <lekktu@gmail.com> 5442008-02-02 Juanma Barranquero <lekktu@gmail.com>
538 545
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index 9411e5d5688..56dff23e9ba 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -88,6 +88,12 @@
88 'nomini 88 'nomini
89 (selected-frame))) 89 (selected-frame)))
90 90
91(defun image-get-display-property ()
92 (get-char-property (point-min) 'display
93 ;; There might be different images for different displays.
94 (if (eq (window-buffer) (current-buffer))
95 (selected-window))))
96
91(defun image-forward-hscroll (&optional n) 97(defun image-forward-hscroll (&optional n)
92 "Scroll image in current window to the left by N character widths. 98 "Scroll image in current window to the left by N character widths.
93Stop if the right edge of the image is reached." 99Stop if the right edge of the image is reached."
@@ -97,7 +103,7 @@ Stop if the right edge of the image is reached."
97 (image-set-window-hscroll (selected-window) 103 (image-set-window-hscroll (selected-window)
98 (max 0 (+ (window-hscroll) n)))) 104 (max 0 (+ (window-hscroll) n))))
99 (t 105 (t
100 (let* ((image (get-char-property (point-min) 'display)) 106 (let* ((image (image-get-display-property))
101 (edges (window-inside-edges)) 107 (edges (window-inside-edges))
102 (win-width (- (nth 2 edges) (nth 0 edges))) 108 (win-width (- (nth 2 edges) (nth 0 edges)))
103 (img-width (ceiling (car (image-size image))))) 109 (img-width (ceiling (car (image-size image)))))
@@ -120,7 +126,7 @@ Stop if the bottom edge of the image is reached."
120 (image-set-window-vscroll (selected-window) 126 (image-set-window-vscroll (selected-window)
121 (max 0 (+ (window-vscroll) n)))) 127 (max 0 (+ (window-vscroll) n))))
122 (t 128 (t
123 (let* ((image (get-char-property (point-min) 'display)) 129 (let* ((image (image-get-display-property))
124 (edges (window-inside-edges)) 130 (edges (window-inside-edges))
125 (win-height (- (nth 3 edges) (nth 1 edges))) 131 (win-height (- (nth 3 edges) (nth 1 edges)))
126 (img-height (ceiling (cdr (image-size image))))) 132 (img-height (ceiling (cdr (image-size image)))))
@@ -194,7 +200,7 @@ stopping if the top or bottom edge of the image is reached."
194 (and arg 200 (and arg
195 (/= (setq arg (prefix-numeric-value arg)) 1) 201 (/= (setq arg (prefix-numeric-value arg)) 1)
196 (image-next-line (- arg 1))) 202 (image-next-line (- arg 1)))
197 (let* ((image (get-char-property (point-min) 'display)) 203 (let* ((image (image-get-display-property))
198 (edges (window-inside-edges)) 204 (edges (window-inside-edges))
199 (win-width (- (nth 2 edges) (nth 0 edges))) 205 (win-width (- (nth 2 edges) (nth 0 edges)))
200 (img-width (ceiling (car (image-size image))))) 206 (img-width (ceiling (car (image-size image)))))
@@ -210,7 +216,7 @@ stopping if the top or bottom edge of the image is reached."
210(defun image-eob () 216(defun image-eob ()
211 "Scroll to the bottom-right corner of the image in the current window." 217 "Scroll to the bottom-right corner of the image in the current window."
212 (interactive) 218 (interactive)
213 (let* ((image (get-char-property (point-min) 'display)) 219 (let* ((image (image-get-display-property))
214 (edges (window-inside-edges)) 220 (edges (window-inside-edges))
215 (win-width (- (nth 2 edges) (nth 0 edges))) 221 (win-width (- (nth 2 edges) (nth 0 edges)))
216 (img-width (ceiling (car (image-size image)))) 222 (img-width (ceiling (car (image-size image))))
@@ -271,7 +277,7 @@ to toggle between display as an image and display as text."
271 277
272 (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t) 278 (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t)
273 (if (and (display-images-p) 279 (if (and (display-images-p)
274 (not (get-char-property (point-min) 'display))) 280 (not (image-get-display-property)))
275 (image-toggle-display) 281 (image-toggle-display)
276 ;; Set next vars when image is already displayed but local 282 ;; Set next vars when image is already displayed but local
277 ;; variables were cleared by kill-all-local-variables 283 ;; variables were cleared by kill-all-local-variables
@@ -282,7 +288,7 @@ to toggle between display as an image and display as text."
282 (message "%s" (concat 288 (message "%s" (concat
283 (substitute-command-keys 289 (substitute-command-keys
284 "Type \\[image-toggle-display] to view as ") 290 "Type \\[image-toggle-display] to view as ")
285 (if (get-char-property (point-min) 'display) 291 (if (image-get-display-property)
286 "text" "an image") ".")))) 292 "text" "an image") "."))))
287 293
288;;;###autoload 294;;;###autoload
@@ -295,13 +301,13 @@ See the command `image-mode' for more information on this mode."
295 :version "22.1" 301 :version "22.1"
296 (if (not image-minor-mode) 302 (if (not image-minor-mode)
297 (image-toggle-display-text) 303 (image-toggle-display-text)
298 (if (get-char-property (point-min) 'display) 304 (if (image-get-display-property)
299 (setq cursor-type nil truncate-lines t) 305 (setq cursor-type nil truncate-lines t)
300 (setq image-type "text")) 306 (setq image-type "text"))
301 (add-hook 'change-major-mode-hook (lambda () (image-minor-mode -1)) nil t) 307 (add-hook 'change-major-mode-hook (lambda () (image-minor-mode -1)) nil t)
302 (message "%s" (concat (substitute-command-keys 308 (message "%s" (concat (substitute-command-keys
303 "Type \\[image-toggle-display] to view the image as ") 309 "Type \\[image-toggle-display] to view the image as ")
304 (if (get-char-property (point-min) 'display) 310 (if (image-get-display-property)
305 "text" "an image") ".")))) 311 "text" "an image") "."))))
306 312
307;;;###autoload 313;;;###autoload
@@ -331,7 +337,7 @@ information on these modes."
331 337
332(defun image-toggle-display-text () 338(defun image-toggle-display-text ()
333 "Showing the text of the image file." 339 "Showing the text of the image file."
334 (if (get-char-property (point-min) 'display) 340 (if (image-get-display-property)
335 (image-toggle-display))) 341 (image-toggle-display)))
336 342
337(defvar archive-superior-buffer) 343(defvar archive-superior-buffer)
@@ -342,7 +348,7 @@ information on these modes."
342This command toggles between showing the text of the image file 348This command toggles between showing the text of the image file
343and showing the image as an image." 349and showing the image as an image."
344 (interactive) 350 (interactive)
345 (if (get-char-property (point-min) 'display) 351 (if (image-get-display-property)
346 (let ((inhibit-read-only t) 352 (let ((inhibit-read-only t)
347 (buffer-undo-list t) 353 (buffer-undo-list t)
348 (modified (buffer-modified-p))) 354 (modified (buffer-modified-p)))