diff options
| author | Tassilo Horn | 2008-01-30 18:53:38 +0000 |
|---|---|---|
| committer | Tassilo Horn | 2008-01-30 18:53:38 +0000 |
| commit | 23ceed9a6bc889e1677c3ff8802e6028b1537226 (patch) | |
| tree | f35ddbbf9fe4a790705acf2b60935c82a93c77f4 | |
| parent | 02cbe062bee38a6705bafb1699d77e3c44cfafcf (diff) | |
| download | emacs-23ceed9a6bc889e1677c3ff8802e6028b1537226.tar.gz emacs-23ceed9a6bc889e1677c3ff8802e6028b1537226.zip | |
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/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/info.el | 80 |
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 @@ | |||
| 1 | 2008-01-30 Tassilo Horn <tassilo@member.fsf.org> | ||
| 2 | |||
| 3 | * info.el (Info-bookmark-make-cell, Info-bookmark-jump): New | ||
| 4 | functions. Implement bookmark support the new make-cell/handler | ||
| 5 | way. | ||
| 6 | (Info-mode): Bind bookmark-make-cell-function to | ||
| 7 | Info-bookmark-make-cell buffer locally. | ||
| 8 | |||
| 1 | 2008-01-30 Richard Stallman <rms@gnu.org> | 9 | 2008-01-30 Richard Stallman <rms@gnu.org> |
| 2 | 10 | ||
| 3 | * progmodes/etags.el (tags-query-replace): Delete unused optional args. | 11 | * 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: | |||
| 3486 | (set (make-local-variable 'revert-buffer-function) | 3486 | (set (make-local-variable 'revert-buffer-function) |
| 3487 | 'Info-revert-buffer-function) | 3487 | 'Info-revert-buffer-function) |
| 3488 | (Info-set-mode-line) | 3488 | (Info-set-mode-line) |
| 3489 | (set (make-local-variable 'bookmark-make-cell-function) | ||
| 3490 | 'Info-bookmark-make-cell) | ||
| 3489 | (run-mode-hooks 'Info-mode-hook)) | 3491 | (run-mode-hooks 'Info-mode-hook)) |
| 3490 | 3492 | ||
| 3491 | ;; When an Info buffer is killed, make sure the associated tags buffer | 3493 | ;; 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." | |||
| 4315 | (add-to-list 'desktop-buffer-mode-handlers | 4317 | (add-to-list 'desktop-buffer-mode-handlers |
| 4316 | '(Info-mode . Info-restore-desktop-buffer)) | 4318 | '(Info-mode . Info-restore-desktop-buffer)) |
| 4317 | 4319 | ||
| 4320 | ;;;; Bookmark support | ||
| 4321 | |||
| 4322 | (defun Info-bookmark-make-cell (annotation &rest args) | ||
| 4323 | (let ((the-record | ||
| 4324 | `((filename . ,(bookmark-buffer-file-name)) | ||
| 4325 | (front-context-string | ||
| 4326 | . ,(if (>= (- (point-max) (point)) bookmark-search-size) | ||
| 4327 | (buffer-substring-no-properties | ||
| 4328 | (point) | ||
| 4329 | (+ (point) bookmark-search-size)) | ||
| 4330 | nil)) | ||
| 4331 | (rear-context-string | ||
| 4332 | . ,(if (>= (- (point) (point-min)) bookmark-search-size) | ||
| 4333 | (buffer-substring-no-properties | ||
| 4334 | (point) | ||
| 4335 | (- (point) bookmark-search-size)) | ||
| 4336 | nil)) | ||
| 4337 | (position . ,(point)) | ||
| 4338 | (info-node . ,info-node) | ||
| 4339 | (handler . Info-bookmark-jump)))) | ||
| 4340 | |||
| 4341 | ;; Now fill in the optional parts: | ||
| 4342 | |||
| 4343 | ;; Take no chances with text properties | ||
| 4344 | (set-text-properties 0 (length annotation) nil annotation) | ||
| 4345 | |||
| 4346 | (if annotation | ||
| 4347 | (nconc the-record (list (cons 'annotation annotation)))) | ||
| 4348 | |||
| 4349 | ;; Finally, return the completed record. | ||
| 4350 | the-record)) | ||
| 4351 | |||
| 4352 | ;;;###autoload | ||
| 4353 | (defun Info-bookmark-jump (bmk) | ||
| 4354 | ;; This implements the `handler' function interface for record type returned | ||
| 4355 | ;; by `Info-make-cell-function', which see. | ||
| 4356 | (let* ((file (expand-file-name (bookmark-get-filename bmk))) | ||
| 4357 | (forward-str (bookmark-get-front-context-string bmk)) | ||
| 4358 | (behind-str (bookmark-get-rear-context-string bmk)) | ||
| 4359 | (place (bookmark-get-position bmk)) | ||
| 4360 | (info-node (bookmark-get-info-node bmk)) | ||
| 4361 | (orig-file file)) | ||
| 4362 | (if (setq file (bookmark-file-or-variation-thereof file)) | ||
| 4363 | (save-excursion | ||
| 4364 | (save-window-excursion | ||
| 4365 | (require 'info) | ||
| 4366 | (with-no-warnings | ||
| 4367 | (Info-find-node file info-node)) | ||
| 4368 | ;; Go searching forward first. Then, if forward-str exists and was | ||
| 4369 | ;; found in the file, we can search backward for behind-str. | ||
| 4370 | ;; Rationale is that if text was inserted between the two in the | ||
| 4371 | ;; file, it's better to be put before it so you can read it, rather | ||
| 4372 | ;; than after and remain perhaps unaware of the changes. | ||
| 4373 | (if forward-str | ||
| 4374 | (if (search-forward forward-str (point-max) t) | ||
| 4375 | (goto-char (match-beginning 0)))) | ||
| 4376 | (if behind-str | ||
| 4377 | (if (search-backward behind-str (point-min) t) | ||
| 4378 | (goto-char (match-end 0)))) | ||
| 4379 | ;; added by db | ||
| 4380 | (setq bookmark-current-bookmark bmk) | ||
| 4381 | `((buffer ,(current-buffer)) (position ,(point))))) | ||
| 4382 | |||
| 4383 | ;; Else unable to find the marked file, so ask if user wants to | ||
| 4384 | ;; relocate the bookmark, else remind them to consider deletion. | ||
| 4385 | (ding) | ||
| 4386 | (if (y-or-n-p (concat (file-name-nondirectory orig-file) | ||
| 4387 | " nonexistent. Relocate \"" | ||
| 4388 | bmk | ||
| 4389 | "\"? ")) | ||
| 4390 | (progn | ||
| 4391 | (bookmark-relocate bmk) | ||
| 4392 | ;; gasp! It's a recursive function call in Emacs Lisp! | ||
| 4393 | (bookmark-jump-noselect bmk)) | ||
| 4394 | (message | ||
| 4395 | "Bookmark not relocated; consider removing it \(%s\)." bmk) | ||
| 4396 | nil)))) | ||
| 4397 | |||
| 4318 | (provide 'info) | 4398 | (provide 'info) |
| 4319 | 4399 | ||
| 4320 | ;; arch-tag: f2480fe2-2139-40c1-a49b-6314991164ac | 4400 | ;; arch-tag: f2480fe2-2139-40c1-a49b-6314991164ac |