diff options
| -rw-r--r-- | lisp/bookmark.el | 262 |
1 files changed, 137 insertions, 125 deletions
diff --git a/lisp/bookmark.el b/lisp/bookmark.el index b41d9fc1158..511c237b028 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | ;; Author: Karl Fogel <kfogel@red-bean.com> | 5 | ;; Author: Karl Fogel <kfogel@red-bean.com> |
| 6 | ;; Maintainer: Karl Fogel <kfogel@red-bean.com> | 6 | ;; Maintainer: Karl Fogel <kfogel@red-bean.com> |
| 7 | ;; Created: July, 1993 | 7 | ;; Created: July, 1993 |
| 8 | ;; Author's Update Number: see variable `bookmark-version'. | ||
| 9 | ;; Keywords: bookmarks, placeholders, annotations | 8 | ;; Keywords: bookmarks, placeholders, annotations |
| 10 | 9 | ||
| 11 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| @@ -82,11 +81,6 @@ | |||
| 82 | 81 | ||
| 83 | (require 'pp) | 82 | (require 'pp) |
| 84 | 83 | ||
| 85 | (defconst bookmark-version "2.6.4" | ||
| 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 | ||
| 88 | maintainers to avoid version confusion.") | ||
| 89 | |||
| 90 | ;;; Misc comments: | 84 | ;;; Misc comments: |
| 91 | ;; | 85 | ;; |
| 92 | ;; If variable bookmark-use-annotations is non-nil, an annotation is | 86 | ;; If variable bookmark-use-annotations is non-nil, an annotation is |
| @@ -379,7 +373,9 @@ That is, all information but the name." | |||
| 379 | 373 | ||
| 380 | (defun bookmark-set-name (bookmark newname) | 374 | (defun bookmark-set-name (bookmark newname) |
| 381 | "Set BOOKMARK's name to NEWNAME." | 375 | "Set BOOKMARK's name to NEWNAME." |
| 382 | (setcar (bookmark-get-bookmark bookmark) newname)) | 376 | (setcar |
| 377 | (if (stringp bookmark) (bookmark-get-bookmark bookmark) bookmark) | ||
| 378 | newname)) | ||
| 383 | 379 | ||
| 384 | 380 | ||
| 385 | (defun bookmark-get-annotation (bookmark) | 381 | (defun bookmark-get-annotation (bookmark) |
| @@ -571,6 +567,11 @@ INFO-NODE, so record this fact in the bookmark's entry." | |||
| 571 | )))) | 567 | )))) |
| 572 | 568 | ||
| 573 | ;; Now fill in the optional parts: | 569 | ;; Now fill in the optional parts: |
| 570 | |||
| 571 | ;; Take no chances with text properties | ||
| 572 | (set-text-properties 0 (length annotation) nil annotation) | ||
| 573 | (set-text-properties 0 (length info-node) nil info-node) | ||
| 574 | |||
| 574 | (if annotation | 575 | (if annotation |
| 575 | (nconc the-record (list (cons 'annotation annotation)))) | 576 | (nconc the-record (list (cons 'annotation annotation)))) |
| 576 | (if info-node | 577 | (if info-node |
| @@ -782,21 +783,18 @@ the list of bookmarks.\)" | |||
| 782 | (format "Set bookmark (%s): " default) | 783 | (format "Set bookmark (%s): " default) |
| 783 | nil | 784 | nil |
| 784 | (let ((now-map (copy-keymap minibuffer-local-map))) | 785 | (let ((now-map (copy-keymap minibuffer-local-map))) |
| 785 | (progn (define-key now-map "\C-w" | 786 | (define-key now-map "\C-w" 'bookmark-yank-word) |
| 786 | 'bookmark-yank-word) | 787 | (define-key now-map "\C-u" 'bookmark-insert-current-bookmark) |
| 787 | (define-key now-map "\C-u" | ||
| 788 | 'bookmark-insert-current-bookmark)) | ||
| 789 | now-map)))) | 788 | now-map)))) |
| 790 | (annotation nil)) | 789 | (annotation nil)) |
| 791 | (and (string-equal str "") (setq str default)) | 790 | (and (string-equal str "") (setq str default)) |
| 792 | ;; Ask for an annotation buffer for this bookmark | 791 | ;; Ask for an annotation buffer for this bookmark |
| 793 | (if bookmark-use-annotations | 792 | (if bookmark-use-annotations |
| 794 | (bookmark-read-annotation parg str) | 793 | (bookmark-read-annotation parg str) |
| 795 | (progn | 794 | (bookmark-make str annotation parg (bookmark-info-current-node)) |
| 796 | (bookmark-make str annotation parg (bookmark-info-current-node)) | 795 | (setq bookmark-current-bookmark str) |
| 797 | (setq bookmark-current-bookmark str) | 796 | (bookmark-bmenu-surreptitiously-rebuild-list) |
| 798 | (bookmark-bmenu-surreptitiously-rebuild-list) | 797 | (goto-char bookmark-current-point)))) |
| 799 | (goto-char bookmark-current-point))))) | ||
| 800 | 798 | ||
| 801 | 799 | ||
| 802 | (defun bookmark-info-current-node () | 800 | (defun bookmark-info-current-node () |
| @@ -836,7 +834,7 @@ the bookmark (and file, and point) specified in buffer local variables." | |||
| 836 | (if (looking-at "^#") | 834 | (if (looking-at "^#") |
| 837 | (bookmark-kill-line t) | 835 | (bookmark-kill-line t) |
| 838 | (forward-line 1))) | 836 | (forward-line 1))) |
| 839 | (let ((annotation (buffer-substring (point-min) (point-max))) | 837 | (let ((annotation (buffer-string)) |
| 840 | (parg bookmark-annotation-paragraph) | 838 | (parg bookmark-annotation-paragraph) |
| 841 | (bookmark bookmark-annotation-name) | 839 | (bookmark bookmark-annotation-name) |
| 842 | (pt bookmark-annotation-point) | 840 | (pt bookmark-annotation-point) |
| @@ -926,8 +924,7 @@ When you have finished composing, type \\[bookmark-send-annotation]. | |||
| 926 | (setq major-mode 'bookmark-edit-annotation-mode) | 924 | (setq major-mode 'bookmark-edit-annotation-mode) |
| 927 | (insert (funcall bookmark-read-annotation-text-func bookmark)) | 925 | (insert (funcall bookmark-read-annotation-text-func bookmark)) |
| 928 | (let ((annotation (bookmark-get-annotation bookmark))) | 926 | (let ((annotation (bookmark-get-annotation bookmark))) |
| 929 | (if (and (not (eq annotation nil)) | 927 | (if (and annotation (not (string-equal annotation ""))) |
| 930 | (not (string-equal annotation ""))) | ||
| 931 | (insert annotation))) | 928 | (insert annotation))) |
| 932 | (run-hooks 'text-mode-hook)) | 929 | (run-hooks 'text-mode-hook)) |
| 933 | 930 | ||
| @@ -942,7 +939,7 @@ When you have finished composing, type \\[bookmark-send-annotation]. | |||
| 942 | (if (looking-at "^#") | 939 | (if (looking-at "^#") |
| 943 | (bookmark-kill-line t) | 940 | (bookmark-kill-line t) |
| 944 | (forward-line 1))) | 941 | (forward-line 1))) |
| 945 | (let ((annotation (buffer-substring (point-min) (point-max))) | 942 | (let ((annotation (buffer-string)) |
| 946 | (bookmark bookmark-annotation-name)) | 943 | (bookmark bookmark-annotation-name)) |
| 947 | (bookmark-set-annotation bookmark annotation) | 944 | (bookmark-set-annotation bookmark annotation) |
| 948 | (bookmark-bmenu-surreptitiously-rebuild-list) | 945 | (bookmark-bmenu-surreptitiously-rebuild-list) |
| @@ -1013,7 +1010,7 @@ In Info, return the current node." | |||
| 1013 | (goto-char bookmark-yank-point) | 1010 | (goto-char bookmark-yank-point) |
| 1014 | (buffer-substring-no-properties | 1011 | (buffer-substring-no-properties |
| 1015 | (point) | 1012 | (point) |
| 1016 | (save-excursion | 1013 | (progn |
| 1017 | (forward-word 1) | 1014 | (forward-word 1) |
| 1018 | (setq bookmark-yank-point (point))))))) | 1015 | (setq bookmark-yank-point (point))))))) |
| 1019 | (insert string))) | 1016 | (insert string))) |
| @@ -1047,9 +1044,8 @@ For example, if this is a Info buffer, return the Info file's name." | |||
| 1047 | t) | 1044 | t) |
| 1048 | 1045 | ||
| 1049 | (file-readable-p (expand-file-name bookmark-default-file)) | 1046 | (file-readable-p (expand-file-name bookmark-default-file)) |
| 1050 | (progn | 1047 | (bookmark-load bookmark-default-file t t) |
| 1051 | (bookmark-load bookmark-default-file t t) | 1048 | (setq bookmarks-already-loaded t))) |
| 1052 | (setq bookmarks-already-loaded t)))) | ||
| 1053 | 1049 | ||
| 1054 | 1050 | ||
| 1055 | (defun bookmark-maybe-sort-alist () | 1051 | (defun bookmark-maybe-sort-alist () |
| @@ -1139,19 +1135,20 @@ of the old one in the permanent bookmark record." | |||
| 1139 | ;; added by db | 1135 | ;; added by db |
| 1140 | (setq bookmark-current-bookmark str) | 1136 | (setq bookmark-current-bookmark str) |
| 1141 | (cons (current-buffer) (point))) | 1137 | (cons (current-buffer) (point))) |
| 1142 | (progn | 1138 | ;; Else unable to find the marked file, so ask if user wants to |
| 1143 | (ding) | 1139 | ;; relocate the bookmark, else remind them to consider deletion. |
| 1144 | (if (y-or-n-p (concat (file-name-nondirectory orig-file) | 1140 | (ding) |
| 1145 | " nonexistent. Relocate \"" | 1141 | (if (y-or-n-p (concat (file-name-nondirectory orig-file) |
| 1146 | str | 1142 | " nonexistent. Relocate \"" |
| 1147 | "\"? ")) | 1143 | str |
| 1148 | (progn | 1144 | "\"? ")) |
| 1149 | (bookmark-relocate str) | 1145 | (progn |
| 1150 | ;; gasp! It's a recursive function call in Emacs Lisp! | 1146 | (bookmark-relocate str) |
| 1151 | (bookmark-jump-noselect str)) | 1147 | ;; gasp! It's a recursive function call in Emacs Lisp! |
| 1152 | (message | 1148 | (bookmark-jump-noselect str)) |
| 1153 | "Bookmark not relocated; consider removing it \(%s\)." str) | 1149 | (message |
| 1154 | nil))))) | 1150 | "Bookmark not relocated; consider removing it \(%s\)." str) |
| 1151 | nil)))) | ||
| 1155 | 1152 | ||
| 1156 | 1153 | ||
| 1157 | ;;;###autoload | 1154 | ;;;###autoload |
| @@ -1168,7 +1165,8 @@ after a bookmark was set in it." | |||
| 1168 | (read-file-name | 1165 | (read-file-name |
| 1169 | (format "Relocate %s to: " bookmark) | 1166 | (format "Relocate %s to: " bookmark) |
| 1170 | (file-name-directory bmrk-filename))))) | 1167 | (file-name-directory bmrk-filename))))) |
| 1171 | (bookmark-set-filename bookmark newloc))) | 1168 | (bookmark-set-filename bookmark newloc) |
| 1169 | (bookmark-bmenu-surreptitiously-rebuild-list))) | ||
| 1172 | 1170 | ||
| 1173 | 1171 | ||
| 1174 | ;;;###autoload | 1172 | ;;;###autoload |
| @@ -1213,28 +1211,27 @@ name." | |||
| 1213 | (interactive (bookmark-completing-read "Old bookmark name")) | 1211 | (interactive (bookmark-completing-read "Old bookmark name")) |
| 1214 | (bookmark-maybe-historicize-string old) | 1212 | (bookmark-maybe-historicize-string old) |
| 1215 | (bookmark-maybe-load-default-file) | 1213 | (bookmark-maybe-load-default-file) |
| 1216 | (progn | 1214 | |
| 1217 | (setq bookmark-current-point (point)) | 1215 | (setq bookmark-current-point (point)) |
| 1218 | (setq bookmark-yank-point (point)) | 1216 | (setq bookmark-yank-point (point)) |
| 1219 | (setq bookmark-current-buffer (current-buffer)) | 1217 | (setq bookmark-current-buffer (current-buffer)) |
| 1220 | (let ((newname | 1218 | (let ((newname |
| 1221 | (or new ; use second arg, if non-nil | 1219 | (or new ; use second arg, if non-nil |
| 1222 | (read-from-minibuffer | 1220 | (read-from-minibuffer |
| 1223 | "New name: " | 1221 | "New name: " |
| 1224 | nil | 1222 | nil |
| 1225 | (let ((now-map (copy-keymap minibuffer-local-map))) | 1223 | (let ((now-map (copy-keymap minibuffer-local-map))) |
| 1226 | (define-key now-map "\C-w" 'bookmark-yank-word) | 1224 | (define-key now-map "\C-w" 'bookmark-yank-word) |
| 1227 | now-map) | 1225 | now-map) |
| 1228 | nil | 1226 | nil |
| 1229 | 'bookmark-history)))) | 1227 | 'bookmark-history)))) |
| 1230 | (progn | 1228 | (bookmark-set-name old newname) |
| 1231 | (bookmark-set-name old newname) | 1229 | (setq bookmark-current-bookmark newname) |
| 1232 | (setq bookmark-current-bookmark newname) | 1230 | (bookmark-bmenu-surreptitiously-rebuild-list) |
| 1233 | (bookmark-bmenu-surreptitiously-rebuild-list) | 1231 | (setq bookmark-alist-modification-count |
| 1234 | (setq bookmark-alist-modification-count | 1232 | (1+ bookmark-alist-modification-count)) |
| 1235 | (1+ bookmark-alist-modification-count)) | 1233 | (if (bookmark-time-to-save-p) |
| 1236 | (if (bookmark-time-to-save-p) | 1234 | (bookmark-save)))) |
| 1237 | (bookmark-save)))))) | ||
| 1238 | 1235 | ||
| 1239 | 1236 | ||
| 1240 | ;;;###autoload | 1237 | ;;;###autoload |
| @@ -1251,7 +1248,7 @@ this." | |||
| 1251 | (str-to-insert | 1248 | (str-to-insert |
| 1252 | (save-excursion | 1249 | (save-excursion |
| 1253 | (set-buffer (car (bookmark-jump-noselect bookmark))) | 1250 | (set-buffer (car (bookmark-jump-noselect bookmark))) |
| 1254 | (buffer-substring (point-min) (point-max))))) | 1251 | (buffer-string)))) |
| 1255 | (insert str-to-insert) | 1252 | (insert str-to-insert) |
| 1256 | (push-mark) | 1253 | (push-mark) |
| 1257 | (goto-char orig-point))) | 1254 | (goto-char orig-point))) |
| @@ -1375,11 +1372,43 @@ for a file, defaulting to the file defined by variable | |||
| 1375 | )))) | 1372 | )))) |
| 1376 | 1373 | ||
| 1377 | 1374 | ||
| 1375 | (defun bookmark-import-new-list (new-list) | ||
| 1376 | ;; Walk over the new list, adding each individual bookmark | ||
| 1377 | ;; carefully. "Carefully" means checking against the existing | ||
| 1378 | ;; bookmark-alist and renaming the new bookmarks with <N> extensions | ||
| 1379 | ;; as necessary. | ||
| 1380 | (let ((lst new-list) | ||
| 1381 | (names (bookmark-all-names))) | ||
| 1382 | (while lst | ||
| 1383 | (let* ((full-record (car lst))) | ||
| 1384 | (bookmark-maybe-rename full-record names) | ||
| 1385 | (setq bookmark-alist (nconc bookmark-alist (list full-record))) | ||
| 1386 | (setq names (cons (bookmark-name-from-full-record full-record) names)) | ||
| 1387 | (setq lst (cdr lst)))))) | ||
| 1388 | |||
| 1389 | |||
| 1390 | (defun bookmark-maybe-rename (full-record names) | ||
| 1391 | ;; just a helper for bookmark-import-new-list; it is only for | ||
| 1392 | ;; readability that this is not inlined. | ||
| 1393 | ;; | ||
| 1394 | ;; Once this has found a free name, it sets full-record to that | ||
| 1395 | ;; name. | ||
| 1396 | (let ((found-name (bookmark-name-from-full-record full-record))) | ||
| 1397 | (if (member found-name names) | ||
| 1398 | ;; We've got a conflict, so generate a new name | ||
| 1399 | (let ((count 2) | ||
| 1400 | (new-name found-name)) | ||
| 1401 | (while (member new-name names) | ||
| 1402 | (setq new-name (concat found-name (format "<%d>" count))) | ||
| 1403 | (setq count (1+ count))) | ||
| 1404 | (bookmark-set-name full-record new-name))))) | ||
| 1405 | |||
| 1406 | |||
| 1378 | ;;;###autoload | 1407 | ;;;###autoload |
| 1379 | (defun bookmark-load (file &optional revert no-msg) | 1408 | (defun bookmark-load (file &optional overwrite no-msg) |
| 1380 | "Load bookmarks from FILE (which must be in bookmark format). | 1409 | "Load bookmarks from FILE (which must be in bookmark format). |
| 1381 | Appends loaded bookmarks to the front of the list of bookmarks. If | 1410 | Appends loaded bookmarks to the front of the list of bookmarks. If |
| 1382 | optional second argument REVERT is non-nil, existing bookmarks are | 1411 | optional second argument OVERWRITE is non-nil, existing bookmarks are |
| 1383 | destroyed. Optional third arg NO-MSG means don't display any messages | 1412 | destroyed. Optional third arg NO-MSG means don't display any messages |
| 1384 | while loading. | 1413 | while loading. |
| 1385 | 1414 | ||
| @@ -1388,7 +1417,12 @@ will corrupt Emacs's bookmark list. Generally, you should only load | |||
| 1388 | in files that were created with the bookmark functions in the first | 1417 | in files that were created with the bookmark functions in the first |
| 1389 | place. Your own personal bookmark file, `~/.emacs.bmk', is | 1418 | place. Your own personal bookmark file, `~/.emacs.bmk', is |
| 1390 | maintained automatically by Emacs; you shouldn't need to load it | 1419 | maintained automatically by Emacs; you shouldn't need to load it |
| 1391 | explicitly." | 1420 | explicitly. |
| 1421 | |||
| 1422 | If you load a file containing bookmarks with the same names as | ||
| 1423 | bookmarks already present in your Emacs, the new bookmarks will get | ||
| 1424 | unique numeric suffixes \"<2>\", \"<3>\", ... following the same | ||
| 1425 | method buffers use to resolve name collisions." | ||
| 1392 | (interactive | 1426 | (interactive |
| 1393 | (list (read-file-name | 1427 | (list (read-file-name |
| 1394 | (format "Load bookmarks from: (%s) " | 1428 | (format "Load bookmarks from: (%s) " |
| @@ -1410,12 +1444,18 @@ explicitly." | |||
| 1410 | (let ((blist (bookmark-alist-from-buffer))) | 1444 | (let ((blist (bookmark-alist-from-buffer))) |
| 1411 | (if (listp blist) | 1445 | (if (listp blist) |
| 1412 | (progn | 1446 | (progn |
| 1413 | (if (not revert) | 1447 | (if overwrite |
| 1414 | (setq bookmark-alist-modification-count | 1448 | (progn |
| 1415 | (1+ bookmark-alist-modification-count)) | 1449 | (setq bookmark-alist blist) |
| 1416 | (setq bookmark-alist-modification-count 0)) | 1450 | (setq bookmark-alist-modification-count 0)) |
| 1417 | (setq bookmark-alist | 1451 | ;; else |
| 1418 | (append blist (if (not revert) bookmark-alist))) | 1452 | (bookmark-import-new-list blist) |
| 1453 | (setq bookmark-alist-modification-count | ||
| 1454 | (1+ bookmark-alist-modification-count))) | ||
| 1455 | (if (string-equal | ||
| 1456 | (expand-file-name bookmark-default-file) | ||
| 1457 | file) | ||
| 1458 | (setq bookmarks-already-loaded t)) | ||
| 1419 | (bookmark-bmenu-surreptitiously-rebuild-list)) | 1459 | (bookmark-bmenu-surreptitiously-rebuild-list)) |
| 1420 | (error "Invalid bookmark list in %s" file))) | 1460 | (error "Invalid bookmark list in %s" file))) |
| 1421 | (kill-buffer (current-buffer))) | 1461 | (kill-buffer (current-buffer))) |
| @@ -1519,8 +1559,7 @@ deletion, or > if it is flagged for displaying." | |||
| 1519 | ;; in the list of bookmarks. | 1559 | ;; in the list of bookmarks. |
| 1520 | (let ((annotation (bookmark-get-annotation | 1560 | (let ((annotation (bookmark-get-annotation |
| 1521 | (bookmark-name-from-full-record full-record)))) | 1561 | (bookmark-name-from-full-record full-record)))) |
| 1522 | (if (and (not (eq annotation nil)) | 1562 | (if (and annotation (not (string-equal annotation ""))) |
| 1523 | (not (string-equal annotation ""))) | ||
| 1524 | (insert " *") | 1563 | (insert " *") |
| 1525 | (insert " ")) | 1564 | (insert " ")) |
| 1526 | (let ((start (point))) | 1565 | (let ((start (point))) |
| @@ -1663,22 +1702,19 @@ Optional argument SHOW means show them unconditionally." | |||
| 1663 | (forward-line 1)))))))) | 1702 | (forward-line 1)))))))) |
| 1664 | 1703 | ||
| 1665 | 1704 | ||
| 1666 | ;; if you look at this next function from far away, it resembles a | ||
| 1667 | ;; gun. But only with this comment above... | ||
| 1668 | (defun bookmark-bmenu-check-position () | 1705 | (defun bookmark-bmenu-check-position () |
| 1669 | ;; Returns t if on a line with a bookmark. | 1706 | ;; Returns non-nil if on a line with a bookmark. |
| 1670 | ;; Otherwise, repositions and returns t. | 1707 | ;; (The actual value returned is bookmark-alist). |
| 1671 | ;; written by David Hughes <djh@harston.cv.com> | 1708 | ;; Else reposition and try again, else return nil. |
| 1672 | ;; Mucho thanks, David! -karl | ||
| 1673 | (cond ((< (count-lines (point-min) (point)) 2) | 1709 | (cond ((< (count-lines (point-min) (point)) 2) |
| 1674 | (goto-char (point-min)) | 1710 | (goto-char (point-min)) |
| 1675 | (forward-line 2) | 1711 | (forward-line 2) |
| 1676 | t) | 1712 | bookmark-alist) |
| 1677 | ((and (bolp) (eobp)) | 1713 | ((and (bolp) (eobp)) |
| 1678 | (beginning-of-line 0) | 1714 | (beginning-of-line 0) |
| 1679 | t) | 1715 | bookmark-alist) |
| 1680 | (t | 1716 | (t |
| 1681 | t))) | 1717 | bookmark-alist))) |
| 1682 | 1718 | ||
| 1683 | 1719 | ||
| 1684 | (defun bookmark-bmenu-bookmark () | 1720 | (defun bookmark-bmenu-bookmark () |
| @@ -1710,17 +1746,15 @@ Optional argument SHOW means show them unconditionally." | |||
| 1710 | "Display the annotation for bookmark named BOOKMARK in a buffer, | 1746 | "Display the annotation for bookmark named BOOKMARK in a buffer, |
| 1711 | if an annotation exists." | 1747 | if an annotation exists." |
| 1712 | (let ((annotation (bookmark-get-annotation bookmark))) | 1748 | (let ((annotation (bookmark-get-annotation bookmark))) |
| 1713 | (if (and (not (eq annotation nil)) | 1749 | (if (and annotation (not (string-equal annotation ""))) |
| 1714 | (not (string-equal annotation ""))) | 1750 | (save-excursion |
| 1715 | (progn | 1751 | (let ((old-buf (current-buffer))) |
| 1716 | (save-excursion | 1752 | (pop-to-buffer (get-buffer-create "*Bookmark Annotation*") t) |
| 1717 | (let ((old-buf (current-buffer))) | 1753 | (delete-region (point-min) (point-max)) |
| 1718 | (pop-to-buffer (get-buffer-create "*Bookmark Annotation*") t) | 1754 | ;; (insert (concat "Annotation for bookmark '" bookmark "':\n\n")) |
| 1719 | (delete-region (point-min) (point-max)) | 1755 | (insert annotation) |
| 1720 | ; (insert (concat "Annotation for bookmark '" bookmark "':\n\n")) | 1756 | (goto-char (point-min)) |
| 1721 | (insert annotation) | 1757 | (pop-to-buffer old-buf)))))) |
| 1722 | (goto-char (point-min)) | ||
| 1723 | (pop-to-buffer old-buf))))))) | ||
| 1724 | 1758 | ||
| 1725 | 1759 | ||
| 1726 | (defun bookmark-show-all-annotations () | 1760 | (defun bookmark-show-all-annotations () |
| @@ -1733,7 +1767,7 @@ if an annotation exists." | |||
| 1733 | (let* ((name (bookmark-name-from-full-record full-record)) | 1767 | (let* ((name (bookmark-name-from-full-record full-record)) |
| 1734 | (ann (bookmark-get-annotation name))) | 1768 | (ann (bookmark-get-annotation name))) |
| 1735 | (insert (concat name ":\n")) | 1769 | (insert (concat name ":\n")) |
| 1736 | (if (and (not (eq ann nil)) (not (string-equal ann ""))) | 1770 | (if (and ann (not (string-equal ann ""))) |
| 1737 | ;; insert the annotation, indented by 4 spaces. | 1771 | ;; insert the annotation, indented by 4 spaces. |
| 1738 | (progn | 1772 | (progn |
| 1739 | (save-excursion (insert ann)) | 1773 | (save-excursion (insert ann)) |
| @@ -1755,7 +1789,8 @@ if an annotation exists." | |||
| 1755 | (let ((buffer-read-only nil)) | 1789 | (let ((buffer-read-only nil)) |
| 1756 | (delete-char 1) | 1790 | (delete-char 1) |
| 1757 | (insert ?>) | 1791 | (insert ?>) |
| 1758 | (forward-line 1)))) | 1792 | (forward-line 1) |
| 1793 | (bookmark-bmenu-check-position)))) | ||
| 1759 | 1794 | ||
| 1760 | 1795 | ||
| 1761 | (defun bookmark-bmenu-select () | 1796 | (defun bookmark-bmenu-select () |
| @@ -1928,7 +1963,8 @@ Optional BACKUP means move up." | |||
| 1928 | ;; flag indicating whether this bookmark is being visited? | 1963 | ;; flag indicating whether this bookmark is being visited? |
| 1929 | ;; well, we don't have this now, so maybe later. | 1964 | ;; well, we don't have this now, so maybe later. |
| 1930 | (insert " ")) | 1965 | (insert " ")) |
| 1931 | (forward-line (if backup -1 1))))) | 1966 | (forward-line (if backup -1 1)) |
| 1967 | (bookmark-bmenu-check-position)))) | ||
| 1932 | 1968 | ||
| 1933 | 1969 | ||
| 1934 | (defun bookmark-bmenu-backup-unmark () | 1970 | (defun bookmark-bmenu-backup-unmark () |
| @@ -1938,7 +1974,8 @@ Optional BACKUP means move up." | |||
| 1938 | (if (bookmark-bmenu-check-position) | 1974 | (if (bookmark-bmenu-check-position) |
| 1939 | (progn | 1975 | (progn |
| 1940 | (bookmark-bmenu-unmark) | 1976 | (bookmark-bmenu-unmark) |
| 1941 | (forward-line -1)))) | 1977 | (forward-line -1) |
| 1978 | (bookmark-bmenu-check-position)))) | ||
| 1942 | 1979 | ||
| 1943 | 1980 | ||
| 1944 | (defun bookmark-bmenu-delete () | 1981 | (defun bookmark-bmenu-delete () |
| @@ -1950,7 +1987,8 @@ To carry out the deletions that you've marked, use \\<bookmark-bmenu-mode-map>\\ | |||
| 1950 | (let ((buffer-read-only nil)) | 1987 | (let ((buffer-read-only nil)) |
| 1951 | (delete-char 1) | 1988 | (delete-char 1) |
| 1952 | (insert ?D) | 1989 | (insert ?D) |
| 1953 | (forward-line 1)))) | 1990 | (forward-line 1) |
| 1991 | (bookmark-bmenu-check-position)))) | ||
| 1954 | 1992 | ||
| 1955 | 1993 | ||
| 1956 | (defun bookmark-bmenu-delete-backwards () | 1994 | (defun bookmark-bmenu-delete-backwards () |
| @@ -1960,7 +1998,8 @@ To carry out the deletions that you've marked, use \\<bookmark-bmenu-mode-map>\\ | |||
| 1960 | (bookmark-bmenu-delete) | 1998 | (bookmark-bmenu-delete) |
| 1961 | (forward-line -2) | 1999 | (forward-line -2) |
| 1962 | (if (bookmark-bmenu-check-position) | 2000 | (if (bookmark-bmenu-check-position) |
| 1963 | (forward-line 1))) | 2001 | (forward-line 1)) |
| 2002 | (bookmark-bmenu-check-position)) | ||
| 1964 | 2003 | ||
| 1965 | 2004 | ||
| 1966 | (defun bookmark-bmenu-execute-deletions () | 2005 | (defun bookmark-bmenu-execute-deletions () |
| @@ -2063,33 +2102,6 @@ strings returned are not." | |||
| 2063 | (cons (concat "-*- " name " -*-") pane-list))) | 2102 | (cons (concat "-*- " name " -*-") pane-list))) |
| 2064 | 2103 | ||
| 2065 | 2104 | ||
| 2066 | (defun bookmark-build-xemacs-menu (name entries function) | ||
| 2067 | "Build a menu named NAME from the strings in ENTRIES. | ||
| 2068 | That is, ENTRIES is a list of strings that appear as the choices | ||
| 2069 | in the menu. | ||
| 2070 | The visible entries are truncated to `bookmark-menu-length', but the | ||
| 2071 | strings returned are not." | ||
| 2072 | (let* (lst | ||
| 2073 | (pane-list | ||
| 2074 | (progn | ||
| 2075 | (while entries | ||
| 2076 | (let ((str (car entries))) | ||
| 2077 | (setq lst (cons | ||
| 2078 | (vector | ||
| 2079 | (if (> (length str) bookmark-menu-length) | ||
| 2080 | (substring str 0 bookmark-menu-length) | ||
| 2081 | str) | ||
| 2082 | (list function str) | ||
| 2083 | t) | ||
| 2084 | lst)) | ||
| 2085 | (setq entries (cdr entries)))) | ||
| 2086 | (nreverse lst)))) | ||
| 2087 | |||
| 2088 | ;; Return the menu: | ||
| 2089 | (append (if popup-menu-titles (list (concat "-*- " name " -*-"))) | ||
| 2090 | pane-list))) | ||
| 2091 | |||
| 2092 | |||
| 2093 | (defun bookmark-menu-popup-paned-menu (event name entries) | 2105 | (defun bookmark-menu-popup-paned-menu (event name entries) |
| 2094 | "Pop up multi-paned menu at EVENT, return string chosen from ENTRIES. | 2106 | "Pop up multi-paned menu at EVENT, return string chosen from ENTRIES. |
| 2095 | That is, ENTRIES is a list of strings which appear as the choices | 2107 | That is, ENTRIES is a list of strings which appear as the choices |