mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
(image-type): New variable.
(image-mode): Set default major mode name to "Image[text]". (image-minor-mode): Change LIGHTER to display image-type in the mode line. (image-minor-mode): Set default image-type to "text". (image-toggle-display): After switching to text mode, set image-type to "text" and major mode name to "Image[text]". After switching to image mode, set image-type to actual image type, and add image type to major mode name. Let-bind the same variable names as arguments of `image-type' and `create-image'. Bind `type' to the result of `image-type' and use it as arg of `create-image' to not determine the image type twice.
This commit is contained in:
parent
a081814834
commit
d487ca7d8e
2 changed files with 44 additions and 17 deletions
|
|
@ -1,3 +1,18 @@
|
|||
2007-08-28 Juri Linkov <juri@jurta.org>
|
||||
|
||||
* image-mode.el (image-type): New variable.
|
||||
(image-mode): Set default major mode name to "Image[text]".
|
||||
(image-minor-mode): Change LIGHTER to display image-type in the
|
||||
mode line.
|
||||
(image-minor-mode): Set default image-type to "text".
|
||||
(image-toggle-display): After switching to text mode, set
|
||||
image-type to "text" and major mode name to "Image[text]".
|
||||
After switching to image mode, set image-type to actual image
|
||||
type, and add image type to major mode name. Let-bind the same
|
||||
variable names as arguments of `image-type' and `create-image'.
|
||||
Bind `type' to the result of `image-type' and use it as arg
|
||||
of `create-image' to not determine the image type twice.
|
||||
|
||||
2007-08-28 Michael Albinus <michael.albinus@gmx.de>
|
||||
|
||||
* net/tramp.el (tramp-handle-set-file-times): Flush the file
|
||||
|
|
|
|||
|
|
@ -183,6 +183,11 @@ stopping if the top or bottom edge of the image is reached."
|
|||
|
||||
;;; Image Mode setup
|
||||
|
||||
(defvar image-type nil
|
||||
"Current image type.
|
||||
This variable is used to display the current image type in the mode line.")
|
||||
(make-variable-buffer-local 'image-type)
|
||||
|
||||
(defvar image-mode-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(define-key map "\C-c\C-c" 'image-toggle-display)
|
||||
|
|
@ -212,7 +217,7 @@ You can use \\<image-mode-map>\\[image-toggle-display]
|
|||
to toggle between display as an image and display as text."
|
||||
(interactive)
|
||||
(kill-all-local-variables)
|
||||
(setq mode-name "Image")
|
||||
(setq mode-name "Image[text]")
|
||||
(setq major-mode 'image-mode)
|
||||
(add-hook 'change-major-mode-hook 'image-toggle-display-text nil t)
|
||||
(if (and (display-images-p)
|
||||
|
|
@ -235,13 +240,14 @@ to toggle between display as an image and display as text."
|
|||
"Toggle Image minor mode.
|
||||
With arg, turn Image minor mode on if arg is positive, off otherwise.
|
||||
See the command `image-mode' for more information on this mode."
|
||||
nil " Image" image-mode-text-map
|
||||
nil (:eval (format " Image[%s]" image-type)) image-mode-text-map
|
||||
:group 'image
|
||||
:version "22.1"
|
||||
(if (not image-minor-mode)
|
||||
(image-toggle-display-text)
|
||||
(if (get-text-property (point-min) 'display)
|
||||
(setq cursor-type nil truncate-lines t))
|
||||
(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 ")
|
||||
|
|
@ -298,25 +304,28 @@ and showing the image as an image."
|
|||
(kill-local-variable 'truncate-lines)
|
||||
(kill-local-variable 'auto-hscroll-mode)
|
||||
(use-local-map image-mode-text-map)
|
||||
(setq image-type "text")
|
||||
(if (eq major-mode 'image-mode)
|
||||
(setq mode-name "Image[text]"))
|
||||
(if (called-interactively-p)
|
||||
(message "Repeat this command to go back to displaying the image")))
|
||||
;; Turn the image data into a real image, but only if the whole file
|
||||
;; was inserted
|
||||
(let* ((filename (buffer-file-name))
|
||||
(image
|
||||
(if (and filename
|
||||
(file-readable-p filename)
|
||||
(not (file-remote-p filename))
|
||||
(not (buffer-modified-p))
|
||||
(not (and (boundp 'archive-superior-buffer)
|
||||
archive-superior-buffer))
|
||||
(not (and (boundp 'tar-superior-buffer)
|
||||
tar-superior-buffer)))
|
||||
(create-image filename)
|
||||
(create-image
|
||||
(string-make-unibyte
|
||||
(buffer-substring-no-properties (point-min) (point-max)))
|
||||
nil t)))
|
||||
(data-p (not (and filename
|
||||
(file-readable-p filename)
|
||||
(not (file-remote-p filename))
|
||||
(not (buffer-modified-p))
|
||||
(not (and (boundp 'archive-superior-buffer)
|
||||
archive-superior-buffer))
|
||||
(not (and (boundp 'tar-superior-buffer)
|
||||
tar-superior-buffer)))))
|
||||
(file-or-data (if data-p
|
||||
(string-make-unibyte
|
||||
(buffer-substring-no-properties (point-min) (point-max)))
|
||||
filename))
|
||||
(type (image-type file-or-data nil data-p))
|
||||
(image (create-image file-or-data type data-p))
|
||||
(props
|
||||
`(display ,image
|
||||
intangible ,image
|
||||
|
|
@ -337,6 +346,9 @@ and showing the image as an image."
|
|||
;; Allow navigation of large images
|
||||
(set (make-local-variable 'auto-hscroll-mode) nil)
|
||||
(use-local-map image-mode-map)
|
||||
(setq image-type type)
|
||||
(if (eq major-mode 'image-mode)
|
||||
(setq mode-name (format "Image[%s]" type)))
|
||||
(if (called-interactively-p)
|
||||
(message "Repeat this command to go back to displaying the file as text")))))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue