~ubuntu-branches/ubuntu/karmic/emacs-snapshot/karmic

« back to all changes in this revision

Viewing changes to lisp/image-mode.el

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-04-05 09:14:30 UTC
  • mto: This revision was merged to the branch mainline in revision 34.
  • Revision ID: james.westby@ubuntu.com-20090405091430-nw07lynn2arotjbe
Tags: upstream-20090320
ImportĀ upstreamĀ versionĀ 20090320

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
;;; image-mode.el --- support for visiting image files
2
2
;;
3
 
;; Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
3
;; Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
4
4
;;
5
5
;; Author: Richard Stallman <rms@gnu.org>
6
6
;; Keywords: multimedia
321
321
to toggle between display as an image and display as text."
322
322
  (interactive)
323
323
  (kill-all-local-variables)
324
 
  (setq mode-name "Image[text]")
325
324
  (setq major-mode 'image-mode)
326
325
  ;; Use our own bookmarking function for images.
327
326
  (set (make-local-variable 'bookmark-make-record-function)
332
331
 
333
332
  (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t)
334
333
  (if (display-images-p)
335
 
      (if (not (get-text-property (point-min) 'display))
 
334
      (if (not (image-get-display-property))
336
335
          (image-toggle-display)
337
336
        ;; Set next vars when image is already displayed but local
338
337
        ;; variables were cleared by kill-all-local-variables
339
338
        (use-local-map image-mode-map)
340
 
        (setq cursor-type nil truncate-lines t))
 
339
        (setq cursor-type nil truncate-lines t
 
340
              image-type (plist-get (cdr (image-get-display-property)) :type)))
 
341
    (setq image-type "text")
341
342
    (use-local-map image-mode-text-map))
 
343
  (setq mode-name (format "Image[%s]" image-type))
342
344
  (run-mode-hooks 'image-mode-hook)
343
345
  (if (display-images-p)
344
346
      (message "%s" (concat
357
359
  :version "22.1"
358
360
  (if (not image-minor-mode)
359
361
      (image-toggle-display-text)
360
 
    (if (image-get-display-property)
361
 
        (setq cursor-type nil truncate-lines t)
362
 
      (setq image-type "text"))
363
362
    (image-mode-setup-winprops)
364
363
    (add-hook 'change-major-mode-hook (lambda () (image-minor-mode -1)) nil t)
365
 
    (message "%s" (concat (substitute-command-keys
366
 
                           "Type \\[image-toggle-display] to view the image as ")
367
 
                          (if (image-get-display-property)
368
 
                              "text" "an image") "."))))
 
364
    (if (display-images-p)
 
365
        (if (not (image-get-display-property))
 
366
            (image-toggle-display)
 
367
          (setq cursor-type nil truncate-lines t
 
368
                image-type (plist-get (cdr (image-get-display-property)) :type)))
 
369
      (setq image-type "text")
 
370
      (use-local-map image-mode-text-map))
 
371
    (if (display-images-p)
 
372
        (message "%s" (concat
 
373
                       (substitute-command-keys
 
374
                        "Type \\[image-toggle-display] to view the image as ")
 
375
                       (if (image-get-display-property)
 
376
                           "text" "an image") ".")))))
369
377
 
370
378
;;;###autoload
371
379
(defun image-mode-maybe ()
449
457
           (buffer-undo-list t)
450
458
           (modified (buffer-modified-p)))
451
459
      (image-refresh image)
452
 
      (add-text-properties (point-min) (point-max) props)
453
 
      (set-buffer-modified-p modified)
 
460
      (let ((buffer-file-truename nil)) ; avoid changing dir mtime by lock_file
 
461
        (add-text-properties (point-min) (point-max) props)
 
462
        (restore-buffer-modified-p modified))
454
463
      ;; Inhibit the cursor when the buffer contains only an image,
455
464
      ;; because cursors look very strange on top of images.
456
465
      (setq cursor-type nil)
465
474
          (setq mode-name (format "Image[%s]" type)))
466
475
      (if (called-interactively-p)
467
476
          (message "Repeat this command to go back to displaying the file as text")))))
468
 
 
 
477
 
469
478
;;; Support for bookmark.el
470
479
(declare-function bookmark-make-record-default "bookmark"
471
480
                  (&optional point-only))
477
486
         `((image-type . ,image-type)
478
487
           (handler    . image-bookmark-jump))))
479
488
 
480
 
 
481
 
 
482
489
;;;###autoload
483
490
(defun image-bookmark-jump (bmk)
484
491
  ;; This implements the `handler' function interface for record type
486
493
  (prog1 (bookmark-default-handler bmk)
487
494
    (when (not (string= image-type (bookmark-prop-get bmk 'image-type)))
488
495
      (image-toggle-display))))
489
 
 
 
496
 
490
497
(provide 'image-mode)
491
498
 
492
499
;; arch-tag: b5b2b7e6-26a7-4b79-96e3-1546b5c4c6cb