]> git.eshelyaron.com Git - emacs.git/commitdiff
2007-12-26 Tassilo Horn <tassilo@member.fsf.org>
authorTassilo Horn <tassilo@member.fsf.org>
Wed, 26 Dec 2007 11:48:37 +0000 (11:48 +0000)
committerTassilo Horn <tassilo@member.fsf.org>
Wed, 26 Dec 2007 11:48:37 +0000 (11:48 +0000)
* 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.

lisp/ChangeLog
lisp/doc-view.el
lisp/image-mode.el

index 060e932b23cd3317a715839a68e352cc4b0d6f04..7dde34cb55dbd5aa96c4fc1881523c7750804c25 100644 (file)
@@ -1,5 +1,12 @@
 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.
+
        * bookmark.el (bookmark-make-cell-function): New variable.
        (bookmark-make): Call bookmark-make-cell-function's function
        instead of bookmark-make-cell.
index 12b3012448e3d23630cf2f6164c73a09242b54bc..388d30b381b9e718a2e3a08f2e7f6b1abf46b28b 100644 (file)
@@ -1019,7 +1019,7 @@ See the command `doc-view-mode' for more information on this mode."
 (defun doc-view-bookmark-jump (bmk)
   (save-window-excursion
     (let ((filename (bookmark-get-filename bmk))
-         (page (cdr (assq 'page (bookmark-get-bookmark-record bookmark)))))
+         (page (cdr (assq 'page (bookmark-get-bookmark-record bmk)))))
       (find-file filename)
       (when (not (eq major-mode 'doc-view-mode))
        (doc-view-toggle-display))
index 283f6ae3ff108e66e33c1a0bb45361bf63a17f9d..4041db8ebf2542bcc1dfa67262c5b33bb10039fd 100644 (file)
@@ -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