Commit 43f8b275 authored by Stefan Monnier's avatar Stefan Monnier

* bookmark.el (bookmark-alist): Allow the 2 slightly different formats

used until now in bookmark.el's code.
(bookmark-get-bookmark): Accept bookmark names or bookmark records.
(bookmark-get-bookmark-record): Allow the 2 slightly different formats
used until now in bookmark.el's code.
(bookmark-set-filename): Remove special code, moved to its only caller.
(bookmark-store): Use the newer format.
(bookmark-make-record-default): Add arg `point-only'.
Rename from bookmark-make-record-for-text-file.
(bookmark--jump-via): New function.
(bookmark-jump, bookmark-jump-other-window, bookmark-bmenu-2-window)
(bookmark-bmenu-other-window, bookmark-bmenu-switch-other-window):
Use it.
(bookmark-jump-noselect, bookmark-default-handler):
Don't return an alist, instead return the data implicitly by changing
current buffer and point.  Signal an error if the file doesn't exist.
* info.el (Info-bookmark-make-record):
Use bookmark-make-record-default.
(Info-bookmark-jump): Use bookmark-default-handler.
* image-mode.el (image-bookmark-make-record):
Use bookmark-make-record-default.
(image-bookmark-jump): Use bookmark-default-handler.
* doc-view.el (doc-view-bookmark-make-record):
Use bookmark-make-record-default.
(doc-view-bookmark-jump): Use bookmark-default-handler.
parent ac935997
......@@ -864,6 +864,9 @@ functions and variables (formerly used for Tamil script).
* Lisp Changes in Emacs 23.1
** bookmark provides `bookmark-make-record-function' so special major modes
like Info can teach bookmark.el how to save&restore the relevant data.
** The new variable next-error-recenter specifies how next-error should
recenter the visited source file. Its value can be a number (for example,
0 for top line, -1 for bottom line), or nil for no recentering.
......
2008-06-25 Stefan Monnier <monnier@iro.umontreal.ca>
* info.el (Info-bookmark-make-record):
Use bookmark-make-record-default.
(Info-bookmark-jump): Use bookmark-default-handler.
* image-mode.el (image-bookmark-make-record):
Use bookmark-make-record-default.
(image-bookmark-jump): Use bookmark-default-handler.
* doc-view.el (doc-view-bookmark-make-record):
Use bookmark-make-record-default.
(doc-view-bookmark-jump): Use bookmark-default-handler.
* bookmark.el (bookmark-alist): Allow the 2 slightly different formats
used until now in bookmark.el's code.
(bookmark-get-bookmark): Accept bookmark names or bookmark records.
(bookmark-get-bookmark-record): Allow the 2 slightly different formats
used until now in bookmark.el's code.
(bookmark-set-filename): Remove special code, moved to its only caller.
(bookmark-store): Use the newer format.
(bookmark-make-record-default): Add arg `point-only'.
Rename from bookmark-make-record-for-text-file.
(bookmark--jump-via): New function.
(bookmark-jump, bookmark-jump-other-window, bookmark-bmenu-2-window)
(bookmark-bmenu-other-window, bookmark-bmenu-switch-other-window):
Use it.
(bookmark-jump-noselect, bookmark-default-handler):
Don't return an alist, instead return the data implicitly by changing
current buffer and point. Signal an error if the file doesn't exist.
* buff-menu.el: Use with-current-buffer and inhibit-read-only.
(Buffer-menu-toggle-read-only): Avoid vc-toggle-read-only.
......
This diff is collapsed.
......@@ -1187,29 +1187,28 @@ See the command `doc-view-mode' for more information on this mode."
;;;; Bookmark integration
(declare-function bookmark-buffer-file-name "bookmark" ())
(declare-function bookmark-make-record-default "bookmark" ())
(declare-function bookmark-prop-get "bookmark" (bookmark prop))
(declare-function bookmark-default-handler "bookmark" (bmk))
(defun doc-view-bookmark-make-record ()
`((filename . ,(bookmark-buffer-file-name))
(page . ,(doc-view-current-page))
(handler . doc-view-bookmark-jump)))
(nconc (bookmark-make-record-default)
`((page . ,(doc-view-current-page))
(handler . doc-view-bookmark-jump))))
;;;###autoload
(defun doc-view-bookmark-jump (bmk)
;; This implements the `handler' function interface for record type
;; returned by `doc-view-bookmark-make-record', which see.
(let ((filename (bookmark-prop-get bmk 'filename))
(page (bookmark-prop-get bmk 'page)))
(with-current-buffer (find-file-noselect filename)
(prog1 (bookmark-default-handler bmk)
(let ((page (bookmark-prop-get bmk 'page)))
(when (not (eq major-mode 'doc-view-mode))
(doc-view-toggle-display))
(doc-view-toggle-display))
(with-selected-window
(or (get-buffer-window (current-buffer) 0)
(selected-window))
(doc-view-goto-page page))
`((buffer ,(current-buffer)) (position ,1)))))
(doc-view-goto-page page)))))
(provide 'doc-view)
......
......@@ -467,41 +467,24 @@ and showing the image as an image."
(message "Repeat this command to go back to displaying the file as text")))))
;;; Support for bookmark.el
(declare-function bookmark-make-record-default "bookmark" ())
(declare-function bookmark-prop-get "bookmark" (bookmark prop))
(declare-function bookmark-default-handler "bookmark" (bmk))
(defun image-bookmark-make-record (annotation)
(let ((the-record
`((filename . ,(buffer-file-name))
(image-type . ,image-type)
(position . ,(point))
(handler . image-bookmark-jump))))
(defun image-bookmark-make-record ()
(nconc (bookmark-make-record-default)
`((image-type . ,image-type)
(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))
(declare-function bookmark-get-filename "bookmark" (bookmark))
(declare-function bookmark-get-bookmark-record "bookmark" (bookmark))
(declare-function bookmark-get-position "bookmark" (bookmark))
;;;###autoload
(defun image-bookmark-jump (bmk)
;; This implements the `handler' function interface for record type
;; returned by `bookmark-make-record-function', which see.
(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))
`((buffer ,(current-buffer)) (position ,(point))))))
(prog1 (bookmark-default-handler bmk)
(when (not (string= image-type (bookmark-prop-get bmk 'image-type)))
(image-toggle-display))))
(provide 'image-mode)
......
......@@ -34,7 +34,7 @@
;;; Code:
(eval-when-compile (require 'jka-compr))
(eval-when-compile (require 'jka-compr) (require 'cl))
(defgroup info nil
"Info subsystem."
......@@ -4379,62 +4379,30 @@ BUFFER is the buffer speedbar is requesting buttons for."
'(Info-mode . Info-restore-desktop-buffer))
;;;; Bookmark support
(defvar bookmark-search-size)
;; This is only called from bookmark.el.
(declare-function bookmark-buffer-file-name "bookmark" ())
(declare-function bookmark-make-record-default "bookmark" (&optional pos-only))
(declare-function bookmark-prop-get "bookmark" (bookmark prop))
(declare-function bookmark-default-handler "bookmark" (bmk))
(declare-function bookmark-get-bookmark-record "bookmark" (bmk))
(defun Info-bookmark-make-record ()
`(,Info-current-node
(filename . ,(bookmark-buffer-file-name))
(front-context-string
. ,(if (>= (- (point-max) (point)) bookmark-search-size)
(buffer-substring-no-properties
(point)
(+ (point) bookmark-search-size))
nil))
(rear-context-string
. ,(if (>= (- (point) (point-min)) bookmark-search-size)
(buffer-substring-no-properties
(point)
(- (point) bookmark-search-size))
nil))
,@(bookmark-make-record-default 'point-only)
(filename . ,Info-current-file)
(info-node . ,Info-current-node)
(handler . Info-bookmark-jump)))
(defvar bookmark-current-bookmark)
(declare-function bookmark-prop-get "bookmark" (bookmark prop))
(declare-function bookmark-file-or-variation-thereof "bookmark" (file))
(declare-function bookmark-jump-noselect "bookmark" (str))
(declare-function bookmark-get-bookmark-record "bookmark" (bookmark))
;;;###autoload
(defun Info-bookmark-jump (bmk)
;; This implements the `handler' function interface for record type returned
;; by `Info-bookmark-make-record', which see.
(let* ((file (expand-file-name (bookmark-prop-get bmk 'filename)))
(forward-str (bookmark-prop-get bmk 'front-context-string))
(behind-str (bookmark-prop-get bmk 'rear-context-string))
(info-node (bookmark-prop-get bmk 'info-node)))
(if (setq file (bookmark-file-or-variation-thereof file))
(save-excursion
(save-window-excursion
(with-no-warnings
(Info-find-node file info-node))
;; Go searching forward first. Then, if forward-str exists and was
;; found in the file, we can search backward for behind-str.
;; Rationale is that if text was inserted between the two in the
;; file, it's better to be put before it so you can read it, rather
;; than after and remain perhaps unaware of the changes.
(if forward-str
(if (search-forward forward-str (point-max) t)
(goto-char (match-beginning 0))))
(if behind-str
(if (search-backward behind-str (point-min) t)
(goto-char (match-end 0))))
`((buffer ,(current-buffer)) (position ,(point))))))))
(let* ((file (bookmark-prop-get bmk 'filename))
(info-node (bookmark-prop-get bmk 'info-node))
(buf (save-window-excursion ;FIXME: doesn't work with frames!
(Info-find-node file info-node) (current-buffer))))
;; Use bookmark-default-handler to move to the appropriate location
;; within the node.
(bookmark-default-handler
(list* "" `(buffer . ,buf) (bookmark-get-bookmark-record bmk)))))
(provide 'info)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment