Mercurial > emacs
comparison lisp/image-mode.el @ 87412:f6ce12419345
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.
author | Tassilo Horn <tassilo@member.fsf.org> |
---|---|
date | Wed, 26 Dec 2007 11:48:37 +0000 |
parents | 0810efbbb396 |
children | 0140d3ebb262 |
comparison
equal
deleted
inserted
replaced
87411:9ac481bc897b | 87412:f6ce12419345 |
---|---|
217 to toggle between display as an image and display as text." | 217 to toggle between display as an image and display as text." |
218 (interactive) | 218 (interactive) |
219 (kill-all-local-variables) | 219 (kill-all-local-variables) |
220 (setq mode-name "Image[text]") | 220 (setq mode-name "Image[text]") |
221 (setq major-mode 'image-mode) | 221 (setq major-mode 'image-mode) |
222 ;; Use our own bookmarking function for images. | |
223 (set (make-local-variable 'bookmark-make-cell-function) | |
224 'image-bookmark-make-cell) | |
222 (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t) | 225 (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t) |
223 (if (and (display-images-p) | 226 (if (and (display-images-p) |
224 (not (get-char-property (point-min) 'display))) | 227 (not (get-char-property (point-min) 'display))) |
225 (image-toggle-display) | 228 (image-toggle-display) |
226 ;; Set next vars when image is already displayed but local | 229 ;; Set next vars when image is already displayed but local |
350 (if (eq major-mode 'image-mode) | 353 (if (eq major-mode 'image-mode) |
351 (setq mode-name (format "Image[%s]" type))) | 354 (setq mode-name (format "Image[%s]" type))) |
352 (if (called-interactively-p) | 355 (if (called-interactively-p) |
353 (message "Repeat this command to go back to displaying the file as text"))))) | 356 (message "Repeat this command to go back to displaying the file as text"))))) |
354 | 357 |
358 ;;; Support for bookmark.el | |
359 | |
360 (defun image-bookmark-make-cell (annotation &rest args) | |
361 (let ((the-record | |
362 `((filename . ,(buffer-file-name)) | |
363 (image-type . ,image-type) | |
364 (position . ,(point)) | |
365 (handler . image-bookmark-jump)))) | |
366 | |
367 ;; Take no chances with text properties | |
368 (set-text-properties 0 (length annotation) nil annotation) | |
369 | |
370 (when annotation | |
371 (nconc the-record (list (cons 'annotation annotation)))) | |
372 | |
373 ;; Finally, return the completed record. | |
374 the-record)) | |
375 | |
376 ;;;###autoload | |
377 (defun image-bookmark-jump (bmk) | |
378 (save-window-excursion | |
379 (let ((filename (bookmark-get-filename bmk)) | |
380 (type (cdr (assq 'image-type (bookmark-get-bookmark-record bmk)))) | |
381 (pos (bookmark-get-position bmk))) | |
382 (find-file filename) | |
383 (when (not (string= image-type type)) | |
384 (image-toggle-display)) | |
385 (when (string= image-type "text") | |
386 (goto-char pos)) | |
387 (cons (current-buffer) pos)))) | |
388 | |
355 (provide 'image-mode) | 389 (provide 'image-mode) |
356 | 390 |
357 ;; arch-tag: b5b2b7e6-26a7-4b79-96e3-1546b5c4c6cb | 391 ;; arch-tag: b5b2b7e6-26a7-4b79-96e3-1546b5c4c6cb |
358 ;;; image-mode.el ends here | 392 ;;; image-mode.el ends here |