diff options
| author | Juri Linkov | 2009-12-04 21:43:07 +0000 |
|---|---|---|
| committer | Juri Linkov | 2009-12-04 21:43:07 +0000 |
| commit | 9b9debd1fbccfba419e7b6b66ae8e3df2c076674 (patch) | |
| tree | c6869158333c9f6171c6c3b62c06e29ccf39d5f4 | |
| parent | 0c74a3010d0df673d26eeed71ebd11944140df85 (diff) | |
| download | emacs-9b9debd1fbccfba419e7b6b66ae8e3df2c076674.tar.gz emacs-9b9debd1fbccfba419e7b6b66ae8e3df2c076674.zip | |
Change roles of modes and functions in image-mode.el (Bug#5062).
* image-mode.el: Replace `image-mode-maybe' with `image-mode'
in `auto-mode-alist'.
(image-mode-previous-major-mode): New variable.
(image-minor-mode-map): Rename from `image-mode-text-map'.
(image-mode): Move graceful error-handling code from
`image-minor-mode' to here. On errors call `image-mode-as-text'.
(image-minor-mode): Remove all image-handling code.
Replace `image-mode-text-map' with `image-minor-mode-map'.
Check for `image-type' in mode-line format string.
(image-mode-maybe): Make obsolete with an alias to `image-mode'.
(image-mode-as-text): New function with most code from
`image-mode-maybe'.
(image-toggle-display-text): Move code that removes image
properties from `image-toggle-display' to here.
(image-toggle-display-image): New function with code that adds
image properties copied from `image-toggle-display'.
(image-toggle-display): Remove most code with leaving only code
that toggles between `image-mode-as-text' and `image-mode'.
| -rw-r--r-- | etc/NEWS | 11 | ||||
| -rw-r--r-- | lisp/ChangeLog | 23 | ||||
| -rw-r--r-- | lisp/image-mode.el | 305 |
3 files changed, 195 insertions, 144 deletions
| @@ -351,6 +351,17 @@ be in use: | |||
| 351 | ** Support for generating Emacs 18 compatible bytecode (by setting | 351 | ** Support for generating Emacs 18 compatible bytecode (by setting |
| 352 | the variable `byte-compile-compatibility') has been removed. | 352 | the variable `byte-compile-compatibility') has been removed. |
| 353 | 353 | ||
| 354 | ** In image-mode.el `image-mode-maybe' is obsolete. Instead, you can | ||
| 355 | either use `image-mode' that displays an image file as the actual image | ||
| 356 | inititally, or `image-mode-as-text' when you want to display an image file | ||
| 357 | as text inititally. `image-mode-as-text' is a combination of a non-image | ||
| 358 | mode from `auto-mode-alist' (or Fundamental mode) and `image-minor-mode'. | ||
| 359 | `image-minor-mode' provides `C-c C-c' key binding to toggle image display. | ||
| 360 | `image-toggle-display-text' removes image properties. | ||
| 361 | `image-toggle-display-image' adds image properties. | ||
| 362 | `image-toggle-display' toggles between `image-mode-as-text' and | ||
| 363 | `image-mode'. | ||
| 364 | |||
| 354 | 365 | ||
| 355 | * Lisp changes in Emacs 23.2 | 366 | * Lisp changes in Emacs 23.2 |
| 356 | 367 | ||
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cfcb63c4116..732c204f82b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,26 @@ | |||
| 1 | 2009-12-04 Juri Linkov <juri@jurta.org> | ||
| 2 | |||
| 3 | Change roles of modes and functions in image-mode.el (Bug#5062). | ||
| 4 | |||
| 5 | * image-mode.el: Replace `image-mode-maybe' with `image-mode' | ||
| 6 | in `auto-mode-alist'. | ||
| 7 | (image-mode-previous-major-mode): New variable. | ||
| 8 | (image-minor-mode-map): Rename from `image-mode-text-map'. | ||
| 9 | (image-mode): Move graceful error-handling code from | ||
| 10 | `image-minor-mode' to here. On errors call `image-mode-as-text'. | ||
| 11 | (image-minor-mode): Remove all image-handling code. | ||
| 12 | Replace `image-mode-text-map' with `image-minor-mode-map'. | ||
| 13 | Check for `image-type' in mode-line format string. | ||
| 14 | (image-mode-maybe): Make obsolete with an alias to `image-mode'. | ||
| 15 | (image-mode-as-text): New function with most code from | ||
| 16 | `image-mode-maybe'. | ||
| 17 | (image-toggle-display-text): Move code that removes image | ||
| 18 | properties from `image-toggle-display' to here. | ||
| 19 | (image-toggle-display-image): New function with code that adds | ||
| 20 | image properties copied from `image-toggle-display'. | ||
| 21 | (image-toggle-display): Remove most code with leaving only code | ||
| 22 | that toggles between `image-mode-as-text' and `image-mode'. | ||
| 23 | |||
| 1 | 2009-12-04 Ulf Jasper <ulf.jasper@web.de> | 24 | 2009-12-04 Ulf Jasper <ulf.jasper@web.de> |
| 2 | 25 | ||
| 3 | * net/newst-treeview.el | 26 | * net/newst-treeview.el |
diff --git a/lisp/image-mode.el b/lisp/image-mode.el index 2351edc934c..9ca16273a74 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el | |||
| @@ -42,10 +42,10 @@ | |||
| 42 | ;;;###autoload (push (cons (purecopy "\\.p[bpgn]m\\'") 'image-mode) auto-mode-alist) | 42 | ;;;###autoload (push (cons (purecopy "\\.p[bpgn]m\\'") 'image-mode) auto-mode-alist) |
| 43 | 43 | ||
| 44 | ;;;###autoload (push (cons (purecopy "\\.x[bp]m\\'") 'c-mode) auto-mode-alist) | 44 | ;;;###autoload (push (cons (purecopy "\\.x[bp]m\\'") 'c-mode) auto-mode-alist) |
| 45 | ;;;###autoload (push (cons (purecopy "\\.x[bp]m\\'") 'image-mode-maybe) auto-mode-alist) | 45 | ;;;###autoload (push (cons (purecopy "\\.x[bp]m\\'") 'image-mode) auto-mode-alist) |
| 46 | 46 | ||
| 47 | ;;;###autoload (push (cons (purecopy "\\.svgz?\\'") 'xml-mode) auto-mode-alist) | 47 | ;;;###autoload (push (cons (purecopy "\\.svgz?\\'") 'xml-mode) auto-mode-alist) |
| 48 | ;;;###autoload (push (cons (purecopy "\\.svgz?\\'") 'image-mode-maybe) auto-mode-alist) | 48 | ;;;###autoload (push (cons (purecopy "\\.svgz?\\'") 'image-mode) auto-mode-alist) |
| 49 | 49 | ||
| 50 | ;;; Image mode window-info management. | 50 | ;;; Image mode window-info management. |
| 51 | 51 | ||
| @@ -286,6 +286,9 @@ This function assumes the current frame has only one window." | |||
| 286 | This variable is used to display the current image type in the mode line.") | 286 | This variable is used to display the current image type in the mode line.") |
| 287 | (make-variable-buffer-local 'image-type) | 287 | (make-variable-buffer-local 'image-type) |
| 288 | 288 | ||
| 289 | (defvar image-mode-previous-major-mode nil | ||
| 290 | "Internal variable to keep the previous non-image major mode.") | ||
| 291 | |||
| 289 | (defvar image-mode-map | 292 | (defvar image-mode-map |
| 290 | (let ((map (make-sparse-keymap))) | 293 | (let ((map (make-sparse-keymap))) |
| 291 | (suppress-keymap map) | 294 | (suppress-keymap map) |
| @@ -306,11 +309,11 @@ This variable is used to display the current image type in the mode line.") | |||
| 306 | map) | 309 | map) |
| 307 | "Major mode keymap for viewing images in Image mode.") | 310 | "Major mode keymap for viewing images in Image mode.") |
| 308 | 311 | ||
| 309 | (defvar image-mode-text-map | 312 | (defvar image-minor-mode-map |
| 310 | (let ((map (make-sparse-keymap))) | 313 | (let ((map (make-sparse-keymap))) |
| 311 | (define-key map "\C-c\C-c" 'image-toggle-display) | 314 | (define-key map "\C-c\C-c" 'image-toggle-display) |
| 312 | map) | 315 | map) |
| 313 | "Major mode keymap for viewing images as text in Image mode.") | 316 | "Minor mode keymap for viewing images as text in Image mode.") |
| 314 | 317 | ||
| 315 | (defvar bookmark-make-record-function) | 318 | (defvar bookmark-make-record-function) |
| 316 | 319 | ||
| @@ -320,168 +323,182 @@ This variable is used to display the current image type in the mode line.") | |||
| 320 | You can use \\<image-mode-map>\\[image-toggle-display] | 323 | You can use \\<image-mode-map>\\[image-toggle-display] |
| 321 | to toggle between display as an image and display as text." | 324 | to toggle between display as an image and display as text." |
| 322 | (interactive) | 325 | (interactive) |
| 323 | (kill-all-local-variables) | 326 | (condition-case err |
| 324 | (setq major-mode 'image-mode) | 327 | (progn |
| 325 | ;; Use our own bookmarking function for images. | 328 | (unless (display-images-p) |
| 326 | (set (make-local-variable 'bookmark-make-record-function) | 329 | (error "Display does not support images")) |
| 327 | 'image-bookmark-make-record) | 330 | |
| 328 | 331 | (kill-all-local-variables) | |
| 329 | ;; Keep track of [vh]scroll when switching buffers | 332 | (setq major-mode 'image-mode) |
| 330 | (image-mode-setup-winprops) | 333 | |
| 331 | 334 | (if (not (image-get-display-property)) | |
| 332 | (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t) | 335 | (progn |
| 333 | (if (display-images-p) | 336 | (image-toggle-display-image) |
| 334 | (if (not (image-get-display-property)) | 337 | ;; If attempt to display the image fails. |
| 335 | (image-toggle-display) | 338 | (if (not (image-get-display-property)) |
| 336 | ;; Set next vars when image is already displayed but local | 339 | (error "Invalid image"))) |
| 337 | ;; variables were cleared by kill-all-local-variables | 340 | ;; Set next vars when image is already displayed but local |
| 341 | ;; variables were cleared by kill-all-local-variables | ||
| 342 | (setq cursor-type nil truncate-lines t | ||
| 343 | image-type (plist-get (cdr (image-get-display-property)) :type))) | ||
| 344 | |||
| 345 | (setq mode-name (if image-type (format "Image[%s]" image-type) "Image")) | ||
| 338 | (use-local-map image-mode-map) | 346 | (use-local-map image-mode-map) |
| 339 | (setq cursor-type nil truncate-lines t | 347 | |
| 340 | image-type (plist-get (cdr (image-get-display-property)) :type))) | 348 | ;; Use our own bookmarking function for images. |
| 341 | (setq image-type "text") | 349 | (set (make-local-variable 'bookmark-make-record-function) |
| 342 | (use-local-map image-mode-text-map)) | 350 | 'image-bookmark-make-record) |
| 343 | (setq mode-name (format "Image[%s]" image-type)) | 351 | |
| 344 | (run-mode-hooks 'image-mode-hook) | 352 | ;; Keep track of [vh]scroll when switching buffers |
| 345 | (if (display-images-p) | 353 | (image-mode-setup-winprops) |
| 346 | (message "%s" (concat | 354 | |
| 347 | (substitute-command-keys | 355 | (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t) |
| 348 | "Type \\[image-toggle-display] to view as ") | 356 | (run-mode-hooks 'image-mode-hook) |
| 349 | (if (image-get-display-property) | 357 | (message "%s" (concat |
| 350 | "text" "an image") ".")))) | 358 | (substitute-command-keys |
| 359 | "Type \\[image-toggle-display] to view the image as ") | ||
| 360 | (if (image-get-display-property) | ||
| 361 | "text" "an image") "."))) | ||
| 362 | (error | ||
| 363 | (image-mode-as-text) | ||
| 364 | (funcall | ||
| 365 | (if (called-interactively-p 'any) 'error 'message) | ||
| 366 | "Cannot display image: %s" (cdr err))))) | ||
| 351 | 367 | ||
| 352 | ;;;###autoload | 368 | ;;;###autoload |
| 353 | (define-minor-mode image-minor-mode | 369 | (define-minor-mode image-minor-mode |
| 354 | "Toggle Image minor mode. | 370 | "Toggle Image minor mode. |
| 355 | With arg, turn Image minor mode on if arg is positive, off otherwise. | 371 | With arg, turn Image minor mode on if arg is positive, off otherwise. |
| 356 | See the command `image-mode' for more information on this mode." | 372 | It provides the key \\<image-mode-map>\\[image-toggle-display] \ |
| 357 | nil (:eval (format " Image[%s]" image-type)) image-mode-text-map | 373 | to switch back to `image-mode' |
| 374 | to display an image file as the actual image." | ||
| 375 | nil (:eval (if image-type (format " Image[%s]" image-type) " Image")) | ||
| 376 | image-minor-mode-map | ||
| 358 | :group 'image | 377 | :group 'image |
| 359 | :version "22.1" | 378 | :version "22.1" |
| 360 | (if (not image-minor-mode) | 379 | (if image-minor-mode |
| 361 | (image-toggle-display-text) | 380 | (add-hook 'change-major-mode-hook (lambda () (image-minor-mode -1)) nil t))) |
| 362 | (image-mode-setup-winprops) | ||
| 363 | (add-hook 'change-major-mode-hook (lambda () (image-minor-mode -1)) nil t) | ||
| 364 | (if (display-images-p) | ||
| 365 | (condition-case err | ||
| 366 | (progn | ||
| 367 | (if (not (image-get-display-property)) | ||
| 368 | (image-toggle-display) | ||
| 369 | (setq cursor-type nil truncate-lines t | ||
| 370 | image-type (plist-get (cdr (image-get-display-property)) | ||
| 371 | :type))) | ||
| 372 | (message "%s" | ||
| 373 | (concat | ||
| 374 | (substitute-command-keys | ||
| 375 | "Type \\[image-toggle-display] to view the image as ") | ||
| 376 | (if (image-get-display-property) | ||
| 377 | "text" "an image") "."))) | ||
| 378 | (error | ||
| 379 | (image-toggle-display-text) | ||
| 380 | (funcall | ||
| 381 | (if (called-interactively-p 'any) 'error 'message) | ||
| 382 | "Cannot display image: %s" (cdr err)))) | ||
| 383 | (setq image-type "text") | ||
| 384 | (use-local-map image-mode-text-map)))) | ||
| 385 | 381 | ||
| 386 | ;;;###autoload | 382 | ;;;###autoload |
| 387 | (defun image-mode-maybe () | 383 | (defun image-mode-as-text () |
| 388 | "Set major or minor mode for image files. | 384 | "Set a non-image mode as major mode in combination with image minor mode. |
| 389 | Set Image major mode only when there are no other major modes | 385 | A non-image major mode found from `auto-mode-alist' or Fundamental mode |
| 390 | associated with a filename in `auto-mode-alist'. When an image | 386 | displays an image file as text. `image-minor-mode' provides the key |
| 391 | filename matches another major mode in `auto-mode-alist' then | 387 | \\<image-mode-map>\\[image-toggle-display] to switch back to `image-mode' |
| 392 | set that major mode and Image minor mode. | 388 | to display an image file as the actual image. |
| 393 | 389 | ||
| 394 | See commands `image-mode' and `image-minor-mode' for more | 390 | You can use `image-mode-as-text' in `auto-mode-alist' when you want |
| 395 | information on these modes." | 391 | to display an image file as text inititally. |
| 392 | |||
| 393 | See commands `image-mode' and `image-minor-mode' for more information | ||
| 394 | on these modes." | ||
| 396 | (interactive) | 395 | (interactive) |
| 397 | (let* ((mode-alist | 396 | ;; image-mode-as-text = normal-mode + image-minor-mode |
| 398 | (delq nil (mapcar | 397 | (let ((previous-image-type image-type)) ; preserve `image-type' |
| 399 | (lambda (elt) | 398 | (if image-mode-previous-major-mode |
| 400 | (unless (memq (or (car-safe (cdr elt)) (cdr elt)) | 399 | ;; Restore previous major mode that was already found by this |
| 401 | '(image-mode image-mode-maybe)) | 400 | ;; function and cached in `image-mode-previous-major-mode' |
| 402 | elt)) | 401 | (funcall image-mode-previous-major-mode) |
| 403 | auto-mode-alist)))) | 402 | (let ((auto-mode-alist |
| 404 | (if (assoc-default buffer-file-name mode-alist 'string-match) | 403 | (delq nil (mapcar |
| 405 | (let ((auto-mode-alist mode-alist) | 404 | (lambda (elt) |
| 406 | (magic-mode-alist nil)) | 405 | (unless (memq (or (car-safe (cdr elt)) (cdr elt)) |
| 407 | (set-auto-mode) | 406 | '(image-mode image-mode-maybe image-mode-as-text)) |
| 408 | (image-minor-mode t)) | 407 | elt)) |
| 409 | (image-mode)))) | 408 | auto-mode-alist))) |
| 409 | (magic-fallback-mode-alist | ||
| 410 | (delq nil (mapcar | ||
| 411 | (lambda (elt) | ||
| 412 | (unless (memq (or (car-safe (cdr elt)) (cdr elt)) | ||
| 413 | '(image-mode image-mode-maybe image-mode-as-text)) | ||
| 414 | elt)) | ||
| 415 | magic-fallback-mode-alist)))) | ||
| 416 | (normal-mode) | ||
| 417 | (set (make-local-variable 'image-mode-previous-major-mode) major-mode))) | ||
| 418 | ;; Restore `image-type' after `kill-all-local-variables' in `normal-mode'. | ||
| 419 | (setq image-type previous-image-type) | ||
| 420 | ;; Enable image minor mode with `C-c C-c'. | ||
| 421 | (image-minor-mode 1) | ||
| 422 | ;; Show the image file as text. | ||
| 423 | (image-toggle-display-text) | ||
| 424 | (message "%s" (concat | ||
| 425 | (substitute-command-keys | ||
| 426 | "Type \\[image-toggle-display] to view the image as ") | ||
| 427 | (if (image-get-display-property) | ||
| 428 | "text" "an image") ".")))) | ||
| 429 | |||
| 430 | (define-obsolete-function-alias 'image-mode-maybe 'image-mode "23.2") | ||
| 410 | 431 | ||
| 411 | (defun image-toggle-display-text () | 432 | (defun image-toggle-display-text () |
| 412 | "Showing the text of the image file." | 433 | "Show the image file as text. |
| 413 | (if (image-get-display-property) | 434 | Remove text properties that display the image." |
| 414 | (image-toggle-display))) | 435 | (let ((inhibit-read-only t) |
| 436 | (buffer-undo-list t) | ||
| 437 | (modified (buffer-modified-p))) | ||
| 438 | (remove-list-of-text-properties (point-min) (point-max) | ||
| 439 | '(display intangible read-nonsticky | ||
| 440 | read-only front-sticky)) | ||
| 441 | (set-buffer-modified-p modified) | ||
| 442 | (if (called-interactively-p 'any) | ||
| 443 | (message "Repeat this command to go back to displaying the image")))) | ||
| 415 | 444 | ||
| 416 | (defvar archive-superior-buffer) | 445 | (defvar archive-superior-buffer) |
| 417 | (defvar tar-superior-buffer) | 446 | (defvar tar-superior-buffer) |
| 418 | (declare-function image-refresh "image.c" (spec &optional frame)) | 447 | (declare-function image-refresh "image.c" (spec &optional frame)) |
| 419 | 448 | ||
| 449 | (defun image-toggle-display-image () | ||
| 450 | "Show the image of the image file. | ||
| 451 | Turn the image data into a real image, but only if the whole file | ||
| 452 | was inserted." | ||
| 453 | (let* ((filename (buffer-file-name)) | ||
| 454 | (data-p (not (and filename | ||
| 455 | (file-readable-p filename) | ||
| 456 | (not (file-remote-p filename)) | ||
| 457 | (not (buffer-modified-p)) | ||
| 458 | (not (and (boundp 'archive-superior-buffer) | ||
| 459 | archive-superior-buffer)) | ||
| 460 | (not (and (boundp 'tar-superior-buffer) | ||
| 461 | tar-superior-buffer))))) | ||
| 462 | (file-or-data (if data-p | ||
| 463 | (string-make-unibyte | ||
| 464 | (buffer-substring-no-properties (point-min) (point-max))) | ||
| 465 | filename)) | ||
| 466 | (type (image-type file-or-data nil data-p)) | ||
| 467 | (image (create-image file-or-data type data-p)) | ||
| 468 | (props | ||
| 469 | `(display ,image | ||
| 470 | intangible ,image | ||
| 471 | rear-nonsticky (display intangible) | ||
| 472 | read-only t front-sticky (read-only))) | ||
| 473 | (inhibit-read-only t) | ||
| 474 | (buffer-undo-list t) | ||
| 475 | (modified (buffer-modified-p))) | ||
| 476 | (image-refresh image) | ||
| 477 | (let ((buffer-file-truename nil)) ; avoid changing dir mtime by lock_file | ||
| 478 | (add-text-properties (point-min) (point-max) props) | ||
| 479 | (restore-buffer-modified-p modified)) | ||
| 480 | ;; Inhibit the cursor when the buffer contains only an image, | ||
| 481 | ;; because cursors look very strange on top of images. | ||
| 482 | (setq cursor-type nil) | ||
| 483 | ;; This just makes the arrow displayed in the right fringe | ||
| 484 | ;; area look correct when the image is wider than the window. | ||
| 485 | (setq truncate-lines t) | ||
| 486 | ;; Allow navigation of large images | ||
| 487 | (set (make-local-variable 'auto-hscroll-mode) nil) | ||
| 488 | (setq image-type type) | ||
| 489 | (if (eq major-mode 'image-mode) | ||
| 490 | (setq mode-name (format "Image[%s]" type))) | ||
| 491 | (if (called-interactively-p 'any) | ||
| 492 | (message "Repeat this command to go back to displaying the file as text")))) | ||
| 493 | |||
| 420 | (defun image-toggle-display () | 494 | (defun image-toggle-display () |
| 421 | "Start or stop displaying an image file as the actual image. | 495 | "Start or stop displaying an image file as the actual image. |
| 422 | This command toggles between showing the text of the image file | 496 | This command toggles between `image-mode-as-text' showing the text of |
| 423 | and showing the image as an image." | 497 | the image file and `image-mode' showing the image as an image." |
| 424 | (interactive) | 498 | (interactive) |
| 425 | (if (image-get-display-property) | 499 | (if (image-get-display-property) |
| 426 | (let ((inhibit-read-only t) | 500 | (image-mode-as-text) |
| 427 | (buffer-undo-list t) | 501 | (image-mode))) |
| 428 | (modified (buffer-modified-p))) | ||
| 429 | (remove-list-of-text-properties (point-min) (point-max) | ||
| 430 | '(display intangible read-nonsticky | ||
| 431 | read-only front-sticky)) | ||
| 432 | (set-buffer-modified-p modified) | ||
| 433 | (kill-local-variable 'cursor-type) | ||
| 434 | (kill-local-variable 'truncate-lines) | ||
| 435 | (kill-local-variable 'auto-hscroll-mode) | ||
| 436 | (use-local-map image-mode-text-map) | ||
| 437 | (setq image-type "text") | ||
| 438 | (if (eq major-mode 'image-mode) | ||
| 439 | (setq mode-name "Image[text]")) | ||
| 440 | (if (called-interactively-p 'any) | ||
| 441 | (message "Repeat this command to go back to displaying the image"))) | ||
| 442 | ;; Turn the image data into a real image, but only if the whole file | ||
| 443 | ;; was inserted | ||
| 444 | (let* ((filename (buffer-file-name)) | ||
| 445 | (data-p (not (and filename | ||
| 446 | (file-readable-p filename) | ||
| 447 | (not (file-remote-p filename)) | ||
| 448 | (not (buffer-modified-p)) | ||
| 449 | (not (and (boundp 'archive-superior-buffer) | ||
| 450 | archive-superior-buffer)) | ||
| 451 | (not (and (boundp 'tar-superior-buffer) | ||
| 452 | tar-superior-buffer))))) | ||
| 453 | (file-or-data (if data-p | ||
| 454 | (string-make-unibyte | ||
| 455 | (buffer-substring-no-properties (point-min) (point-max))) | ||
| 456 | filename)) | ||
| 457 | (type (image-type file-or-data nil data-p)) | ||
| 458 | (image (create-image file-or-data type data-p)) | ||
| 459 | (props | ||
| 460 | `(display ,image | ||
| 461 | intangible ,image | ||
| 462 | rear-nonsticky (display intangible) | ||
| 463 | read-only t front-sticky (read-only))) | ||
| 464 | (inhibit-read-only t) | ||
| 465 | (buffer-undo-list t) | ||
| 466 | (modified (buffer-modified-p))) | ||
| 467 | (image-refresh image) | ||
| 468 | (let ((buffer-file-truename nil)) ; avoid changing dir mtime by lock_file | ||
| 469 | (add-text-properties (point-min) (point-max) props) | ||
| 470 | (restore-buffer-modified-p modified)) | ||
| 471 | ;; Inhibit the cursor when the buffer contains only an image, | ||
| 472 | ;; because cursors look very strange on top of images. | ||
| 473 | (setq cursor-type nil) | ||
| 474 | ;; This just makes the arrow displayed in the right fringe | ||
| 475 | ;; area look correct when the image is wider than the window. | ||
| 476 | (setq truncate-lines t) | ||
| 477 | ;; Allow navigation of large images | ||
| 478 | (set (make-local-variable 'auto-hscroll-mode) nil) | ||
| 479 | (use-local-map image-mode-map) | ||
| 480 | (setq image-type type) | ||
| 481 | (if (eq major-mode 'image-mode) | ||
| 482 | (setq mode-name (format "Image[%s]" type))) | ||
| 483 | (if (called-interactively-p 'any) | ||
| 484 | (message "Repeat this command to go back to displaying the file as text"))))) | ||
| 485 | 502 | ||
| 486 | ;;; Support for bookmark.el | 503 | ;;; Support for bookmark.el |
| 487 | (declare-function bookmark-make-record-default "bookmark" | 504 | (declare-function bookmark-make-record-default "bookmark" |