summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTassilo Horn <tassilo@member.fsf.org>2008-01-30 18:53:38 +0000
committerTassilo Horn <tassilo@member.fsf.org>2008-01-30 18:53:38 +0000
commit23ceed9a6bc889e1677c3ff8802e6028b1537226 (patch)
treef35ddbbf9fe4a790705acf2b60935c82a93c77f4
parent02cbe062bee38a6705bafb1699d77e3c44cfafcf (diff)
downloademacs-23ceed9a6bc889e1677c3ff8802e6028b1537226.tar.gz
2008-01-30 Tassilo Horn <tassilo@member.fsf.org>
* info.el (Info-bookmark-make-cell, Info-bookmark-jump): New functions. Implement bookmark support the new make-cell/handler way. (Info-mode): Bind bookmark-make-cell-function to Info-bookmark-make-cell buffer locally.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/info.el80
2 files changed, 88 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 686d54fb3cf..4e2af23a41c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2008-01-30 Tassilo Horn <tassilo@member.fsf.org>
+
+ * info.el (Info-bookmark-make-cell, Info-bookmark-jump): New
+ functions. Implement bookmark support the new make-cell/handler
+ way.
+ (Info-mode): Bind bookmark-make-cell-function to
+ Info-bookmark-make-cell buffer locally.
+
2008-01-30 Richard Stallman <rms@gnu.org>
* progmodes/etags.el (tags-query-replace): Delete unused optional args.
diff --git a/lisp/info.el b/lisp/info.el
index 13c417ccdd7..a25c6e380cc 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -3486,6 +3486,8 @@ Advanced commands:
(set (make-local-variable 'revert-buffer-function)
'Info-revert-buffer-function)
(Info-set-mode-line)
+ (set (make-local-variable 'bookmark-make-cell-function)
+ 'Info-bookmark-make-cell)
(run-mode-hooks 'Info-mode-hook))
;; When an Info buffer is killed, make sure the associated tags buffer
@@ -4315,6 +4317,84 @@ BUFFER is the buffer speedbar is requesting buttons for."
(add-to-list 'desktop-buffer-mode-handlers
'(Info-mode . Info-restore-desktop-buffer))
+;;;; Bookmark support
+
+(defun Info-bookmark-make-cell (annotation &rest args)
+ (let ((the-record
+ `((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))
+ (position . ,(point))
+ (info-node . ,info-node)
+ (handler . Info-bookmark-jump))))
+
+ ;; Now fill in the optional parts:
+
+ ;; Take no chances with text properties
+ (set-text-properties 0 (length annotation) nil annotation)
+
+ (if annotation
+ (nconc the-record (list (cons 'annotation annotation))))
+
+ ;; Finally, return the completed record.
+ the-record))
+
+;;;###autoload
+(defun Info-bookmark-jump (bmk)
+ ;; This implements the `handler' function interface for record type returned
+ ;; by `Info-make-cell-function', which see.
+ (let* ((file (expand-file-name (bookmark-get-filename bmk)))
+ (forward-str (bookmark-get-front-context-string bmk))
+ (behind-str (bookmark-get-rear-context-string bmk))
+ (place (bookmark-get-position bmk))
+ (info-node (bookmark-get-info-node bmk))
+ (orig-file file))
+ (if (setq file (bookmark-file-or-variation-thereof file))
+ (save-excursion
+ (save-window-excursion
+ (require 'info)
+ (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))))
+ ;; added by db
+ (setq bookmark-current-bookmark bmk)
+ `((buffer ,(current-buffer)) (position ,(point)))))
+
+ ;; Else unable to find the marked file, so ask if user wants to
+ ;; relocate the bookmark, else remind them to consider deletion.
+ (ding)
+ (if (y-or-n-p (concat (file-name-nondirectory orig-file)
+ " nonexistent. Relocate \""
+ bmk
+ "\"? "))
+ (progn
+ (bookmark-relocate bmk)
+ ;; gasp! It's a recursive function call in Emacs Lisp!
+ (bookmark-jump-noselect bmk))
+ (message
+ "Bookmark not relocated; consider removing it \(%s\)." bmk)
+ nil))))
+
(provide 'info)
;; arch-tag: f2480fe2-2139-40c1-a49b-6314991164ac