diff options
| author | Karl Fogel | 1996-05-08 02:22:12 +0000 |
|---|---|---|
| committer | Karl Fogel | 1996-05-08 02:22:12 +0000 |
| commit | a15269c0d04259277ff1d9d6a6dac8b60184ece3 (patch) | |
| tree | cae858773490c740d14ff0ea46d5a58a95fad1a2 | |
| parent | 9fa128e82a612fbec633793e117d9a341e4f7749 (diff) | |
| download | emacs-a15269c0d04259277ff1d9d6a6dac8b60184ece3.tar.gz emacs-a15269c0d04259277ff1d9d6a6dac8b60184ece3.zip | |
(bookmark-make): take optional arg `info-node', pass it on to
bookmark-make-cell.
(bookmark-make-cell): if new optional arg `info-node' is non-nil, make
it be the bookmark's info-node.
(bookmark-info-current-node): new func.
(bookmark-set): call bookmark-make, passing result from above
bookmark-info-current-node.
(bookmark-send-annotation): same as above.
(bookmark-locate): defalias to bookmark-insert-location for backward
compatibility.
(bookmark-version): upped to 2.6.3.
| -rw-r--r-- | lisp/bookmark.el | 84 |
1 files changed, 53 insertions, 31 deletions
diff --git a/lisp/bookmark.el b/lisp/bookmark.el index bdb9ef4364d..58e490ff3ec 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el | |||
| @@ -82,7 +82,7 @@ | |||
| 82 | 82 | ||
| 83 | (require 'pp) | 83 | (require 'pp) |
| 84 | 84 | ||
| 85 | (defconst bookmark-version "2.6.20" | 85 | (defconst bookmark-version "2.6.3" |
| 86 | "Version number of bookmark.el. This is not related to the version | 86 | "Version number of bookmark.el. This is not related to the version |
| 87 | of Emacs bookmark comes with; it is used solely by bookmark's | 87 | of Emacs bookmark comes with; it is used solely by bookmark's |
| 88 | maintainers to avoid version confusion.") | 88 | maintainers to avoid version confusion.") |
| @@ -450,7 +450,11 @@ That is, all information but the name." | |||
| 450 | (if cell | 450 | (if cell |
| 451 | (setcdr cell node) | 451 | (setcdr cell node) |
| 452 | (nconc (bookmark-get-bookmark-record bookmark) | 452 | (nconc (bookmark-get-bookmark-record bookmark) |
| 453 | (list (cons 'info-node node)))))) | 453 | (list (cons 'info-node node))))) |
| 454 | |||
| 455 | (message "%S" (assq 'info-node (bookmark-get-bookmark-record bookmark))) | ||
| 456 | (sit-for 4) | ||
| 457 | ) | ||
| 454 | 458 | ||
| 455 | 459 | ||
| 456 | (defvar bookmark-history nil | 460 | (defvar bookmark-history nil |
| @@ -490,11 +494,13 @@ menus, so `completing-read' never gets a chance to set `bookmark-history'." | |||
| 490 | (setq bookmark-history (cons (, string) bookmark-history))))) | 494 | (setq bookmark-history (cons (, string) bookmark-history))))) |
| 491 | 495 | ||
| 492 | 496 | ||
| 493 | (defun bookmark-make (name &optional annotation overwrite) | 497 | (defun bookmark-make (name &optional annotation overwrite info-node) |
| 494 | "Make a bookmark named NAME. | 498 | "Make a bookmark named NAME. |
| 495 | Optional second arg ANNOTATION gives it an annotation. | 499 | Optional second arg ANNOTATION gives it an annotation. |
| 496 | Optional third arg OVERWRITE means replace any existing bookmarks with | 500 | Optional third arg OVERWRITE means replace any existing bookmarks with |
| 497 | this name." | 501 | this name. |
| 502 | Optional fourth arg INFO-NODE means this bookmark is at info node | ||
| 503 | INFO-NODE, so record this fact in the bookmark's entry." | ||
| 498 | (bookmark-maybe-load-default-file) | 504 | (bookmark-maybe-load-default-file) |
| 499 | (let ((stripped-name (copy-sequence name))) | 505 | (let ((stripped-name (copy-sequence name))) |
| 500 | (or bookmark-xemacsp | 506 | (or bookmark-xemacsp |
| @@ -505,7 +511,7 @@ this name." | |||
| 505 | ;; already existing bookmark under that name and | 511 | ;; already existing bookmark under that name and |
| 506 | ;; no prefix arg means just overwrite old bookmark | 512 | ;; no prefix arg means just overwrite old bookmark |
| 507 | (setcdr (bookmark-get-bookmark stripped-name) | 513 | (setcdr (bookmark-get-bookmark stripped-name) |
| 508 | (list (bookmark-make-cell annotation))) | 514 | (list (bookmark-make-cell annotation info-node))) |
| 509 | 515 | ||
| 510 | ;; otherwise just cons it onto the front (either the bookmark | 516 | ;; otherwise just cons it onto the front (either the bookmark |
| 511 | ;; doesn't exist already, or there is no prefix arg. In either | 517 | ;; doesn't exist already, or there is no prefix arg. In either |
| @@ -514,7 +520,7 @@ this name." | |||
| 514 | (setq bookmark-alist | 520 | (setq bookmark-alist |
| 515 | (cons | 521 | (cons |
| 516 | (list stripped-name | 522 | (list stripped-name |
| 517 | (bookmark-make-cell annotation)) | 523 | (bookmark-make-cell annotation info-node)) |
| 518 | bookmark-alist))) | 524 | bookmark-alist))) |
| 519 | 525 | ||
| 520 | ;; Added by db | 526 | ;; Added by db |
| @@ -525,25 +531,38 @@ this name." | |||
| 525 | (bookmark-save)))) | 531 | (bookmark-save)))) |
| 526 | 532 | ||
| 527 | 533 | ||
| 528 | (defun bookmark-make-cell (annotation) | 534 | (defun bookmark-make-cell (annotation &optional info-node) |
| 529 | "Return the record part of a new bookmark, given ANNOTATION. | 535 | "Return the record part of a new bookmark, given ANNOTATION. |
| 530 | Must be at the correct position in the buffer in which the bookmark is | 536 | Must be at the correct position in the buffer in which the bookmark is |
| 531 | being set. This will change soon." | 537 | being set. This might change someday. |
| 532 | (` ((filename . (, (bookmark-buffer-file-name))) | 538 | Optional second arg INFO-NODE means this bookmark is at info node |
| 533 | (front-context-string | 539 | INFO-NODE, so record this fact in the bookmark's entry." |
| 534 | . (, (if (>= (- (point-max) (point)) bookmark-search-size) | 540 | (let ((the-record |
| 535 | (buffer-substring-no-properties | 541 | (` ((filename . (, (bookmark-buffer-file-name))) |
| 536 | (point) | 542 | (front-context-string |
| 537 | (+ (point) bookmark-search-size)) | 543 | . (, (if (>= (- (point-max) (point)) bookmark-search-size) |
| 538 | nil))) | 544 | (buffer-substring-no-properties |
| 539 | (rear-context-string | 545 | (point) |
| 540 | . (, (if (>= (- (point) (point-min)) bookmark-search-size) | 546 | (+ (point) bookmark-search-size)) |
| 541 | (buffer-substring-no-properties | 547 | nil))) |
| 542 | (point) | 548 | (rear-context-string |
| 543 | (- (point) bookmark-search-size)) | 549 | . (, (if (>= (- (point) (point-min)) bookmark-search-size) |
| 544 | nil))) | 550 | (buffer-substring-no-properties |
| 545 | (position . (, (point))) | 551 | (point) |
| 546 | (annotation . (, annotation))))) | 552 | (- (point) bookmark-search-size)) |
| 553 | nil))) | ||
| 554 | (position . (, (point))) | ||
| 555 | )))) | ||
| 556 | |||
| 557 | ;; Now fill in the optional parts: | ||
| 558 | (if annotation | ||
| 559 | (nconc the-record (list (cons 'annotation annotation)))) | ||
| 560 | (if info-node | ||
| 561 | (nconc the-record (list (cons 'info-node info-node)))) | ||
| 562 | |||
| 563 | ;; Finally, return the completed record. | ||
| 564 | the-record)) | ||
| 565 | |||
| 547 | 566 | ||
| 548 | 567 | ||
| 549 | ;;; File format stuff | 568 | ;;; File format stuff |
| @@ -590,11 +609,9 @@ being set. This will change soon." | |||
| 590 | ;; bookmark-jump will search for STRING-BEHIND and STRING-IN-FRONT in | 609 | ;; bookmark-jump will search for STRING-BEHIND and STRING-IN-FRONT in |
| 591 | ;; case the file has changed since the bookmark was set. It will | 610 | ;; case the file has changed since the bookmark was set. It will |
| 592 | ;; attempt to place the user before the changes, if there were any. | 611 | ;; attempt to place the user before the changes, if there were any. |
| 593 | ;; annotation is the annotation for the bookmark; it may not exist | 612 | ;; ANNOTATION is the annotation for the bookmark; it may not exist |
| 594 | ;; (for backward compatibility), be nil (no annotation), or be a | 613 | ;; (for backward compatibility), be nil (no annotation), or be a |
| 595 | ;; string. | 614 | ;; string. |
| 596 | ;; | ||
| 597 | ;; ANNOTATION is an annotation for the bookmark. | ||
| 598 | 615 | ||
| 599 | 616 | ||
| 600 | (defconst bookmark-file-format-version 1 | 617 | (defconst bookmark-file-format-version 1 |
| @@ -760,15 +777,18 @@ the list of bookmarks.\)" | |||
| 760 | (if bookmark-use-annotations | 777 | (if bookmark-use-annotations |
| 761 | (bookmark-read-annotation parg str) | 778 | (bookmark-read-annotation parg str) |
| 762 | (progn | 779 | (progn |
| 763 | (bookmark-make str annotation parg) | 780 | (bookmark-make str annotation parg (bookmark-info-current-node)) |
| 764 | ;; In Info, there's a little more information to record: | ||
| 765 | (if (eq major-mode 'Info-mode) | ||
| 766 | (bookmark-set-info-node str Info-current-node)) | ||
| 767 | (setq bookmark-current-bookmark str) | 781 | (setq bookmark-current-bookmark str) |
| 768 | (bookmark-bmenu-surreptitiously-rebuild-list) | 782 | (bookmark-bmenu-surreptitiously-rebuild-list) |
| 769 | (goto-char bookmark-current-point))))) | 783 | (goto-char bookmark-current-point))))) |
| 770 | 784 | ||
| 771 | 785 | ||
| 786 | (defun bookmark-info-current-node () | ||
| 787 | "If in Info-mode, return current node name (a string), else nil." | ||
| 788 | (if (eq major-mode 'Info-mode) | ||
| 789 | Info-current-node)) | ||
| 790 | |||
| 791 | |||
| 772 | (defun bookmark-kill-line (&optional newline-too) | 792 | (defun bookmark-kill-line (&optional newline-too) |
| 773 | "Kill from point to end of line. | 793 | "Kill from point to end of line. |
| 774 | If optional arg NEWLINE-TOO is non-nil, delete the newline too. | 794 | If optional arg NEWLINE-TOO is non-nil, delete the newline too. |
| @@ -812,7 +832,7 @@ the bookmark (and file, and point) specified in buffer local variables." | |||
| 812 | (save-excursion | 832 | (save-excursion |
| 813 | (pop-to-buffer buf) | 833 | (pop-to-buffer buf) |
| 814 | (goto-char pt) | 834 | (goto-char pt) |
| 815 | (bookmark-make bookmark annotation parg) | 835 | (bookmark-make bookmark annotation parg (bookmark-info-current-node)) |
| 816 | (setq bookmark-current-bookmark bookmark)) | 836 | (setq bookmark-current-bookmark bookmark)) |
| 817 | (bookmark-bmenu-surreptitiously-rebuild-list) | 837 | (bookmark-bmenu-surreptitiously-rebuild-list) |
| 818 | (goto-char bookmark-current-point)) | 838 | (goto-char bookmark-current-point)) |
| @@ -1147,6 +1167,8 @@ minibuffer history list `bookmark-history'." | |||
| 1147 | (or no-history (bookmark-maybe-historicize-string bookmark)) | 1167 | (or no-history (bookmark-maybe-historicize-string bookmark)) |
| 1148 | (insert (bookmark-location bookmark))) | 1168 | (insert (bookmark-location bookmark))) |
| 1149 | 1169 | ||
| 1170 | ;;; old name for above: | ||
| 1171 | (defalias 'bookmark-locate 'bookmark-insert-location) | ||
| 1150 | 1172 | ||
| 1151 | (defun bookmark-location (bookmark) | 1173 | (defun bookmark-location (bookmark) |
| 1152 | "Return the name of the file associated with BOOKMARK." | 1174 | "Return the name of the file associated with BOOKMARK." |