diff options
author | Tassilo Horn <tassilo@member.fsf.org> | 2007-12-26 11:48:37 +0000 |
---|---|---|
committer | Tassilo Horn <tassilo@member.fsf.org> | 2007-12-26 11:48:37 +0000 |
commit | 137187c884c1082d20ee014bc692e8e59734919e (patch) | |
tree | 0f36817826afde8406ab2bee596d5621a983f423 /lisp/image-mode.el | |
parent | 1666a6b3e851967e9b37de28c4c2ece2926a0cf5 (diff) | |
download | emacs-137187c884c1082d20ee014bc692e8e59734919e.tar.gz emacs-137187c884c1082d20ee014bc692e8e59734919e.tar.bz2 emacs-137187c884c1082d20ee014bc692e8e59734919e.zip |
2007-12-26 Tassilo Horn <tassilo@member.fsf.org>
* image-mode.el (image-bookmark-make-cell, image-bookmark-jump):
New functions.
(image-mode): Set bookmark-make-cell-function appropriately.
* doc-view.el (doc-view-bookmark-jump): Correct misspelled arg
name.
Diffstat (limited to 'lisp/image-mode.el')
-rw-r--r-- | lisp/image-mode.el | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lisp/image-mode.el b/lisp/image-mode.el index 283f6ae3ff1..4041db8ebf2 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -219,6 +219,9 @@ to toggle between display as an image and display as text." (kill-all-local-variables) (setq mode-name "Image[text]") (setq major-mode 'image-mode) + ;; Use our own bookmarking function for images. + (set (make-local-variable 'bookmark-make-cell-function) + 'image-bookmark-make-cell) (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t) (if (and (display-images-p) (not (get-char-property (point-min) 'display))) @@ -352,6 +355,37 @@ and showing the image as an image." (if (called-interactively-p) (message "Repeat this command to go back to displaying the file as text"))))) +;;; Support for bookmark.el + +(defun image-bookmark-make-cell (annotation &rest args) + (let ((the-record + `((filename . ,(buffer-file-name)) + (image-type . ,image-type) + (position . ,(point)) + (handler . image-bookmark-jump)))) + + ;; Take no chances with text properties + (set-text-properties 0 (length annotation) nil annotation) + + (when annotation + (nconc the-record (list (cons 'annotation annotation)))) + + ;; Finally, return the completed record. + the-record)) + +;;;###autoload +(defun image-bookmark-jump (bmk) + (save-window-excursion + (let ((filename (bookmark-get-filename bmk)) + (type (cdr (assq 'image-type (bookmark-get-bookmark-record bmk)))) + (pos (bookmark-get-position bmk))) + (find-file filename) + (when (not (string= image-type type)) + (image-toggle-display)) + (when (string= image-type "text") + (goto-char pos)) + (cons (current-buffer) pos)))) + (provide 'image-mode) ;; arch-tag: b5b2b7e6-26a7-4b79-96e3-1546b5c4c6cb |