diff options
| author | Karl Fogel | 1995-03-13 22:50:35 +0000 |
|---|---|---|
| committer | Karl Fogel | 1995-03-13 22:50:35 +0000 |
| commit | 4c0b5ad1cba82d3e8dbc16d86cdb897e22be955c (patch) | |
| tree | 9bca0a2453a7b62399cac4744454bb497d8508e4 | |
| parent | 7ae137a96fb44f02ae83e6b47adaced0eb550de9 (diff) | |
| download | emacs-4c0b5ad1cba82d3e8dbc16d86cdb897e22be955c.tar.gz emacs-4c0b5ad1cba82d3e8dbc16d86cdb897e22be955c.zip | |
Removed C-v bindings; they were inconsistent.
Defvarred some variables to nil, solely to avoid compilation warnings.
Use "Author's Update Number:" instead of "Version:".
(bookmark-history): new var.
(bookmark-completing-read): use `bookmark-history'.
(bookmark-historicize-string): new macro.
Use this everywhere `bookmark-completing-read' is used, because
`completing-read' won't get a chance to add to `bookmark-history' if
we were invoked via a menu.
(bookmark-rename): use `bookmark-history' when reading the new name.
No need for the strange C-o binding anymore.
| -rw-r--r-- | lisp/bookmark.el | 86 |
1 files changed, 53 insertions, 33 deletions
diff --git a/lisp/bookmark.el b/lisp/bookmark.el index beeccf6373e..c17d6db4c42 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | ;; Author: Karl Fogel <kfogel@cyclic.com> | 5 | ;; Author: Karl Fogel <kfogel@cyclic.com> |
| 6 | ;; Maintainer: Karl Fogel <kfogel@cyclic.com> | 6 | ;; Maintainer: Karl Fogel <kfogel@cyclic.com> |
| 7 | ;; Created: July, 1993 | 7 | ;; Created: July, 1993 |
| 8 | ;; Version: 2.6.6 | 8 | ;; Author's Update Number: 2.6.8 |
| 9 | ;; Keywords: bookmarks, placeholders, annotations | 9 | ;; Keywords: bookmarks, placeholders, annotations |
| 10 | 10 | ||
| 11 | ;;; Summary: | 11 | ;;; Summary: |
| @@ -65,11 +65,6 @@ | |||
| 65 | ;; Based on info-bookmark.el, by Karl Fogel and Ken Olstad | 65 | ;; Based on info-bookmark.el, by Karl Fogel and Ken Olstad |
| 66 | ;; <olstad@msc.edu>. | 66 | ;; <olstad@msc.edu>. |
| 67 | 67 | ||
| 68 | ;; LCD Archive Entry: | ||
| 69 | ;; bookmark|Karl Fogel|kfogel@cyclic.com| | ||
| 70 | ;; Setting bookmarks in files or directories, jumping to them later.| | ||
| 71 | ;; 06-March-1995|Version: 2.6.6|~/misc/bookmark.el.Z| | ||
| 72 | |||
| 73 | ;; Enough with the credits already, get on to the good stuff: | 68 | ;; Enough with the credits already, get on to the good stuff: |
| 74 | 69 | ||
| 75 | ;; FAVORITE CHINESE RESTAURANT: | 70 | ;; FAVORITE CHINESE RESTAURANT: |
| @@ -225,8 +220,12 @@ bookmark-default-file, which is `~/.emacs.bmk' by default.") | |||
| 225 | "*The .emacs.bmk file used to be called this.") | 220 | "*The .emacs.bmk file used to be called this.") |
| 226 | 221 | ||
| 227 | 222 | ||
| 223 | ;; defvarred to avoid a compilation warning: | ||
| 224 | (defvar bookmark-file nil | ||
| 225 | "Old name for `bookmark-default-file'.") | ||
| 226 | |||
| 228 | (defvar bookmark-default-file | 227 | (defvar bookmark-default-file |
| 229 | (if (and (boundp 'bookmark-file) bookmark-file) | 228 | (if bookmark-file |
| 230 | ;; In case user set `bookmark-file' in her .emacs: | 229 | ;; In case user set `bookmark-file' in her .emacs: |
| 231 | bookmark-file | 230 | bookmark-file |
| 232 | (if (eq system-type 'ms-dos) | 231 | (if (eq system-type 'ms-dos) |
| @@ -385,6 +384,10 @@ That is, all information but the name." | |||
| 385 | (list (cons 'info-node node)))))) | 384 | (list (cons 'info-node node)))))) |
| 386 | 385 | ||
| 387 | 386 | ||
| 387 | (defvar bookmark-history nil | ||
| 388 | "The history list for bookmark functions.") | ||
| 389 | |||
| 390 | |||
| 388 | (defun bookmark-completing-read (prompt &optional default) | 391 | (defun bookmark-completing-read (prompt &optional default) |
| 389 | "Prompting with PROMPT, read a bookmark name in completion. | 392 | "Prompting with PROMPT, read a bookmark name in completion. |
| 390 | PROMPT will get a \": \" stuck on the end no matter what, so you | 393 | PROMPT will get a \": \" stuck on the end no matter what, so you |
| @@ -401,12 +404,23 @@ the empty string." | |||
| 401 | (completing-read prompt | 404 | (completing-read prompt |
| 402 | bookmark-alist | 405 | bookmark-alist |
| 403 | nil | 406 | nil |
| 404 | 0))) | 407 | 0 |
| 408 | nil | ||
| 409 | 'bookmark-history))) | ||
| 405 | (if (string-equal "" str) | 410 | (if (string-equal "" str) |
| 406 | (list default) | 411 | (list default) |
| 407 | (list str)))) | 412 | (list str)))) |
| 408 | 413 | ||
| 409 | 414 | ||
| 415 | (defmacro bookmark-maybe-historicize-string (string) | ||
| 416 | "Put STRING into the bookmark prompt history, if caller non-interactive. | ||
| 417 | We need this because sometimes bookmark functions are invoked from | ||
| 418 | menus, so `completing-read' never gets a chance to set `bookmark-history'." | ||
| 419 | (` (or | ||
| 420 | (interactive-p) | ||
| 421 | (setq bookmark-history (cons (, string) bookmark-history))))) | ||
| 422 | |||
| 423 | |||
| 410 | (defun bookmark-make (str &optional annotation overwrite) | 424 | (defun bookmark-make (str &optional annotation overwrite) |
| 411 | "Make a bookmark named NAME. | 425 | "Make a bookmark named NAME. |
| 412 | Optional second arg ANNOTATION gives it an annotation. | 426 | Optional second arg ANNOTATION gives it an annotation. |
| @@ -642,11 +656,10 @@ To yank words from the text of the buffer and use them as part of the | |||
| 642 | bookmark name, type C-w while setting a bookmark. Successive C-w's | 656 | bookmark name, type C-w while setting a bookmark. Successive C-w's |
| 643 | yank successive words. | 657 | yank successive words. |
| 644 | 658 | ||
| 645 | Typing C-v inserts the name of the current file being visited. Typing | 659 | Typing C-u inserts the name of the last bookmark used in the buffer |
| 646 | C-u inserts the name of the last bookmark used in the buffer \(as an | 660 | \(as an aid in using a single bookmark name to track your progress |
| 647 | aid in using a single bookmark name to track your progress through a | 661 | through a large file\). If no bookmark was used, then C-u inserts the |
| 648 | large file\). If no bookmark was used, then C-u behaves like C-v and | 662 | name of the file being visited. |
| 649 | inserts the name of the file being visited. | ||
| 650 | 663 | ||
| 651 | Use \\[bookmark-delete] to remove bookmarks \(you give it a name, | 664 | Use \\[bookmark-delete] to remove bookmarks \(you give it a name, |
| 652 | and it removes only the first instance of a bookmark with that name from | 665 | and it removes only the first instance of a bookmark with that name from |
| @@ -671,8 +684,6 @@ the list of bookmarks.\)" | |||
| 671 | (let ((now-map (copy-keymap minibuffer-local-map))) | 684 | (let ((now-map (copy-keymap minibuffer-local-map))) |
| 672 | (progn (define-key now-map "\C-w" | 685 | (progn (define-key now-map "\C-w" |
| 673 | 'bookmark-yank-word) | 686 | 'bookmark-yank-word) |
| 674 | (define-key now-map "\C-v" | ||
| 675 | 'bookmark-insert-buffer-name) | ||
| 676 | (define-key now-map "\C-u" | 687 | (define-key now-map "\C-u" |
| 677 | 'bookmark-insert-current-bookmark)) | 688 | 'bookmark-insert-current-bookmark)) |
| 678 | now-map))) | 689 | now-map))) |
| @@ -701,6 +712,14 @@ Does not affect the kill-ring." | |||
| 701 | (delete-char 1)))) | 712 | (delete-char 1)))) |
| 702 | 713 | ||
| 703 | 714 | ||
| 715 | ;; Defvars to avoid compilation warnings: | ||
| 716 | (defvar bookmark-annotation-paragraph nil) | ||
| 717 | (defvar bookmark-annotation-name nil) | ||
| 718 | (defvar bookmark-annotation-buffer nil) | ||
| 719 | (defvar bookmark-annotation-file nil) | ||
| 720 | (defvar bookmark-annotation-point nil) | ||
| 721 | |||
| 722 | |||
| 704 | (defun bookmark-send-annotation () | 723 | (defun bookmark-send-annotation () |
| 705 | "After remove lines beginning with '#', use the contents of this buffer | 724 | "After remove lines beginning with '#', use the contents of this buffer |
| 706 | as the annotation for a bookmark, and store it in the bookmark list with | 725 | as the annotation for a bookmark, and store it in the bookmark list with |
| @@ -956,6 +975,7 @@ will then jump to the new location, as well as recording it in place | |||
| 956 | of the old one in the permanent bookmark record." | 975 | of the old one in the permanent bookmark record." |
| 957 | (interactive | 976 | (interactive |
| 958 | (bookmark-completing-read "Jump to bookmark" bookmark-current-bookmark)) | 977 | (bookmark-completing-read "Jump to bookmark" bookmark-current-bookmark)) |
| 978 | (bookmark-maybe-historicize-string str) | ||
| 959 | (let ((cell (bookmark-jump-noselect str))) | 979 | (let ((cell (bookmark-jump-noselect str))) |
| 960 | (and cell | 980 | (and cell |
| 961 | (switch-to-buffer (car cell)) | 981 | (switch-to-buffer (car cell)) |
| @@ -1039,6 +1059,7 @@ existing bookmark point to that file, instead of the one it used to | |||
| 1039 | point at. Useful when a file has been renamed after a bookmark was | 1059 | point at. Useful when a file has been renamed after a bookmark was |
| 1040 | set in it." | 1060 | set in it." |
| 1041 | (interactive (bookmark-completing-read "Bookmark to relocate")) | 1061 | (interactive (bookmark-completing-read "Bookmark to relocate")) |
| 1062 | (bookmark-maybe-historicize-string str) | ||
| 1042 | (bookmark-maybe-load-default-file) | 1063 | (bookmark-maybe-load-default-file) |
| 1043 | (let* ((bmrk-filename (bookmark-get-filename str)) | 1064 | (let* ((bmrk-filename (bookmark-get-filename str)) |
| 1044 | (newloc (expand-file-name | 1065 | (newloc (expand-file-name |
| @@ -1049,9 +1070,12 @@ set in it." | |||
| 1049 | 1070 | ||
| 1050 | 1071 | ||
| 1051 | ;;;###autoload | 1072 | ;;;###autoload |
| 1052 | (defun bookmark-insert-location (str) | 1073 | (defun bookmark-insert-location (str &optional no-history) |
| 1053 | "Insert the name of the file associated with BOOKMARK." | 1074 | "Insert the name of the file associated with BOOKMARK. |
| 1075 | Optional second arg NO-HISTORY means don't record this in the | ||
| 1076 | minibuffer history list `bookmark-history'." | ||
| 1054 | (interactive (bookmark-completing-read "Insert bookmark location")) | 1077 | (interactive (bookmark-completing-read "Insert bookmark location")) |
| 1078 | (or no-history (bookmark-maybe-historicize-string str)) | ||
| 1055 | (insert (bookmark-location str))) | 1079 | (insert (bookmark-location str))) |
| 1056 | 1080 | ||
| 1057 | 1081 | ||
| @@ -1073,11 +1097,9 @@ is done. You must pass at least OLD-BOOKMARK when calling from Lisp. | |||
| 1073 | 1097 | ||
| 1074 | While you are entering the new name, consecutive C-w's insert | 1098 | While you are entering the new name, consecutive C-w's insert |
| 1075 | consectutive words from the text of the buffer into the new bookmark | 1099 | consectutive words from the text of the buffer into the new bookmark |
| 1076 | name. | 1100 | name." |
| 1077 | C-v inserts the name of the file. | ||
| 1078 | C-o inserts the old name of the bookmark; this is helpful when you | ||
| 1079 | just want to make minor changes to the old name." | ||
| 1080 | (interactive (bookmark-completing-read "Old bookmark name")) | 1101 | (interactive (bookmark-completing-read "Old bookmark name")) |
| 1102 | (bookmark-maybe-historicize-string old) | ||
| 1081 | (bookmark-maybe-load-default-file) | 1103 | (bookmark-maybe-load-default-file) |
| 1082 | (progn | 1104 | (progn |
| 1083 | (setq bookmark-current-point (point)) | 1105 | (setq bookmark-current-point (point)) |
| @@ -1085,19 +1107,14 @@ just want to make minor changes to the old name." | |||
| 1085 | (setq bookmark-current-buffer (current-buffer)) | 1107 | (setq bookmark-current-buffer (current-buffer)) |
| 1086 | (let ((newname | 1108 | (let ((newname |
| 1087 | (or new ; use second arg, if non-nil | 1109 | (or new ; use second arg, if non-nil |
| 1088 | (read-from-minibuffer | 1110 | (read-from-minibuffer |
| 1089 | "New name: " | 1111 | "New name: " |
| 1090 | nil | 1112 | nil |
| 1091 | (let ((now-map (copy-keymap minibuffer-local-map))) | 1113 | (let ((now-map (copy-keymap minibuffer-local-map))) |
| 1092 | (progn (define-key now-map "\C-w" | 1114 | (define-key now-map "\C-w" 'bookmark-yank-word) |
| 1093 | 'bookmark-yank-word) | 1115 | now-map) |
| 1094 | (define-key now-map "\C-o" | 1116 | nil |
| 1095 | (lambda () | 1117 | 'bookmark-history)))) |
| 1096 | (interactive) | ||
| 1097 | (insert old))) | ||
| 1098 | (define-key now-map "\C-v" | ||
| 1099 | 'bookmark-insert-buffer-name)) | ||
| 1100 | now-map))))) | ||
| 1101 | (progn | 1118 | (progn |
| 1102 | (bookmark-set-name old newname) | 1119 | (bookmark-set-name old newname) |
| 1103 | (setq bookmark-current-bookmark newname) | 1120 | (setq bookmark-current-bookmark newname) |
| @@ -1116,6 +1133,7 @@ You may have a problem using this function if the value of variable | |||
| 1116 | bookmarks. See help on function `bookmark-load' for more about | 1133 | bookmarks. See help on function `bookmark-load' for more about |
| 1117 | this." | 1134 | this." |
| 1118 | (interactive (bookmark-completing-read "Insert bookmark contents")) | 1135 | (interactive (bookmark-completing-read "Insert bookmark contents")) |
| 1136 | (bookmark-maybe-historicize-string str) | ||
| 1119 | (bookmark-maybe-load-default-file) | 1137 | (bookmark-maybe-load-default-file) |
| 1120 | (let ((orig-point (point)) | 1138 | (let ((orig-point (point)) |
| 1121 | (str-to-insert | 1139 | (str-to-insert |
| @@ -1138,6 +1156,7 @@ Optional second arg BATCH means don't update the bookmark list buffer, | |||
| 1138 | probably because we were called from there." | 1156 | probably because we were called from there." |
| 1139 | (interactive | 1157 | (interactive |
| 1140 | (bookmark-completing-read "Delete bookmark" bookmark-current-bookmark)) | 1158 | (bookmark-completing-read "Delete bookmark" bookmark-current-bookmark)) |
| 1159 | (bookmark-maybe-historicize-string bookmark) | ||
| 1141 | (bookmark-maybe-load-default-file) | 1160 | (bookmark-maybe-load-default-file) |
| 1142 | (let ((will-go (bookmark-get-bookmark bookmark))) | 1161 | (let ((will-go (bookmark-get-bookmark bookmark))) |
| 1143 | (setq bookmark-alist (delq will-go bookmark-alist)) | 1162 | (setq bookmark-alist (delq will-go bookmark-alist)) |
| @@ -1491,7 +1510,8 @@ Optional argument SHOW means show them unconditionally." | |||
| 1491 | (move-to-column bookmark-bmenu-file-column t) | 1510 | (move-to-column bookmark-bmenu-file-column t) |
| 1492 | (delete-region (point) (progn (end-of-line) (point))) | 1511 | (delete-region (point) (progn (end-of-line) (point))) |
| 1493 | (insert " ") | 1512 | (insert " ") |
| 1494 | (bookmark-insert-location bmrk) | 1513 | ;; Pass the NO-HISTORY arg: |
| 1514 | (bookmark-insert-location bmrk t) | ||
| 1495 | (forward-line 1)))))))) | 1515 | (forward-line 1)))))))) |
| 1496 | 1516 | ||
| 1497 | 1517 | ||
| @@ -1962,7 +1982,7 @@ is done. You must pass at least OLD-BOOKMARK when calling from Lisp. | |||
| 1962 | 1982 | ||
| 1963 | While you are entering the new name, consecutive C-w's insert | 1983 | While you are entering the new name, consecutive C-w's insert |
| 1964 | consectutive words from the text of the buffer into the new bookmark | 1984 | consectutive words from the text of the buffer into the new bookmark |
| 1965 | name, and C-v inserts the name of the file." | 1985 | name." |
| 1966 | (interactive "e") | 1986 | (interactive "e") |
| 1967 | (bookmark-popup-menu-and-apply-function | 1987 | (bookmark-popup-menu-and-apply-function |
| 1968 | 'bookmark-rename "Rename Bookmark" event)) | 1988 | 'bookmark-rename "Rename Bookmark" event)) |