aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2003-08-11 17:30:47 +0000
committerStefan Monnier2003-08-11 17:30:47 +0000
commit175d0960bf4c904ff90bd4329ce11e093ac259b1 (patch)
tree02656a85576b984a8e94de2f61a4322c1926fdeb
parent3666daf637cfa85ce61c22181e940707f3a79e21 (diff)
downloademacs-175d0960bf4c904ff90bd4329ce11e093ac259b1.tar.gz
emacs-175d0960bf4c904ff90bd4329ce11e093ac259b1.zip
(bookmark-completing-read): Use a popup menu if activated from the mouse.
Return a string, instead of a list of one string. (bookmark-edit-annotation): Remove unused vars. (bookmark-jump, bookmark-relocate, bookmark-insert-location) (bookmark-rename, bookmark-insert, bookmark-delete): Adjust calls to bookmark-completing-read. (bookmark-bmenu-show-filenames, bookmark-bmenu-hide-filenames) (bookmark-bmenu-mark, bookmark-bmenu-select, bookmark-bmenu-unmark) (bookmark-bmenu-delete, bookmark-bmenu-list): Use inhibit-read-only and erase-buffer. (bookmark-menu-delete, bookmark-menu-rename, bookmark-menu-locate) (bookmark-menu-jump, bookmark-menu-insert) (bookmark-popup-menu-and-apply-function) (bookmark-menu-popup-paned-bookmark-menu): Remove. (bookmark-menu-build-paned-menu): Remove by folding it into bookmark-menu-popup-paned-menu. (menu-bar-bookmark-map): Move the define-key statements here. Use the "non-menu" commands since they now pop up a menu if needed. (bookmark-exit-hook-internal): Simplify.
-rw-r--r--lisp/ChangeLog78
-rw-r--r--lisp/bookmark.el293
2 files changed, 130 insertions, 241 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 08531227872..f628ba00780 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,16 +1,39 @@
12003-08-11 Stefan Monnier <monnier@cs.yale.edu>
2
3 * bookmark.el (bookmark-completing-read):
4 Return a string, instead of a list of one string.
5 Use a popup menu if activated from the mouse.
6 (bookmark-edit-annotation): Remove unused vars.
7 (bookmark-jump, bookmark-relocate, bookmark-insert-location)
8 (bookmark-rename, bookmark-insert, bookmark-delete): Adjust calls
9 to bookmark-completing-read.
10 (bookmark-bmenu-show-filenames, bookmark-bmenu-hide-filenames)
11 (bookmark-bmenu-mark, bookmark-bmenu-select, bookmark-bmenu-unmark)
12 (bookmark-bmenu-delete, bookmark-bmenu-list): Use inhibit-read-only
13 and erase-buffer.
14 (bookmark-menu-delete, bookmark-menu-rename, bookmark-menu-locate)
15 (bookmark-menu-jump, bookmark-menu-insert)
16 (bookmark-popup-menu-and-apply-function)
17 (bookmark-menu-popup-paned-bookmark-menu): Remove.
18 (bookmark-menu-build-paned-menu): Remove by folding it into
19 bookmark-menu-popup-paned-menu.
20 (menu-bar-bookmark-map): Move the define-key statements here.
21 Use the "non-menu" commands since they now pop up a menu if needed.
22 (bookmark-exit-hook-internal): Simplify.
23
12003-08-11 Carsten Dominik <dominik@sand.science.uva.nl> 242003-08-11 Carsten Dominik <dominik@sand.science.uva.nl>
2 25
3 * textmodes/reftex.el: Updated to version 4.21 26 * textmodes/reftex.el: Updated to version 4.21
4 * reftex-auc.el: likewise 27 * reftex-auc.el: likewise.
5 * reftex-cite.el: likewise 28 * reftex-cite.el: likewise.
6 * reftex-dcr.el: likewise 29 * reftex-dcr.el: likewise.
7 * reftex-global.el: likewise 30 * reftex-global.el: likewise.
8 * reftex-index.el: likewise 31 * reftex-index.el: likewise.
9 * reftex-parse.el: likewise 32 * reftex-parse.el: likewise.
10 * reftex-ref.el: likewise 33 * reftex-ref.el: likewise.
11 * reftex-sel.el: likewise 34 * reftex-sel.el: likewise.
12 * reftex-toc.el: likewise 35 * reftex-toc.el: likewise.
13 * reftex-vars.el: likewise 36 * reftex-vars.el: likewise.
14 37
152003-08-08 Vinicius Jose Latorre <viniciusjl@ig.com.br> 382003-08-08 Vinicius Jose Latorre <viniciusjl@ig.com.br>
16 39
@@ -21,13 +44,12 @@
21 44
22 * progmodes/ebnf2ps.el (ebnf-begin-job): Code fix. 45 * progmodes/ebnf2ps.el (ebnf-begin-job): Code fix.
23 46
24
252003-08-06 Glenn Morris <gmorris@ast.cam.ac.uk> 472003-08-06 Glenn Morris <gmorris@ast.cam.ac.uk>
26 48
27 * calendar/calendar.el (list-diary-entries-hook) 49 * calendar/calendar.el (list-diary-entries-hook)
28 (diary-display-hook, nongregorian-diary-listing-hook) 50 (diary-display-hook, nongregorian-diary-listing-hook)
29 (mark-diary-entries-hook, nongregorian-diary-marking-hook): Add 51 (mark-diary-entries-hook, nongregorian-diary-marking-hook):
30 some customize options for these hooks. 52 Add some customize options for these hooks.
31 (calendar-abbrev-construct): Don't try to take a substring longer 53 (calendar-abbrev-construct): Don't try to take a substring longer
32 than the original string. 54 than the original string.
33 55
@@ -37,13 +59,13 @@
37 (testcover-reinstrument-clauses): Doc fix. 59 (testcover-reinstrument-clauses): Doc fix.
38 60
39 * emacs-lisp/warnings.el: Doc fixes, args renamed. 61 * emacs-lisp/warnings.el: Doc fixes, args renamed.
40 (warning-type-format): Renamed from warning-group-format. 62 (warning-type-format): Rename from warning-group-format.
41 63
42 * emacs-lisp/bytecomp.el (byte-compile-not-obsolete-var): New var. 64 * emacs-lisp/bytecomp.el (byte-compile-not-obsolete-var): New var.
43 (byte-compile-variable-ref): Handle byte-compile-not-obsolete-var. 65 (byte-compile-variable-ref): Handle byte-compile-not-obsolete-var.
44 (byte-compile-defvar): Bind byte-compile-not-obsolete-var 66 (byte-compile-defvar): Bind byte-compile-not-obsolete-var
45 to prevent warnings about defvar for an obsolete variable. 67 to prevent warnings about defvar for an obsolete variable.
46 68
47 * emacs-lisp/bytecomp.el (byte-compile-log-warning): 69 * emacs-lisp/bytecomp.el (byte-compile-log-warning):
48 warning-group-format renamed to warning-type-format. 70 warning-group-format renamed to warning-type-format.
49 71
@@ -64,8 +86,8 @@
64 86
65 * international/code-pages.el: Don't require mule-diag. 87 * international/code-pages.el: Don't require mule-diag.
66 88
67 * international/mule-diag.el (non-iso-charset-alist): Add 89 * international/mule-diag.el (non-iso-charset-alist):
68 autoload cookie. 90 Add autoload cookie.
69 91
70 * language/devan-util.el (dev-glyph-order): Add an entry for the 92 * language/devan-util.el (dev-glyph-order): Add an entry for the
71 glyph code #xC4. 93 glyph code #xC4.
@@ -87,8 +109,7 @@
87 `calendar-day-name' and `calendar-month-name' functions. 109 `calendar-day-name' and `calendar-month-name' functions.
88 110
89 * calendar/diary-lib.el (list-diary-entries): Adapt for new 111 * calendar/diary-lib.el (list-diary-entries): Adapt for new
90 behaviour of `calendar-day-name' and `calendar-month-name' 112 behaviour of `calendar-day-name' and `calendar-month-name' functions.
91 functions.
92 (diary-name-pattern): Use abbrev arrays, rather than fixing 113 (diary-name-pattern): Use abbrev arrays, rather than fixing
93 abbrevs at three chars. Calling syntax change. 114 abbrevs at three chars. Calling syntax change.
94 (mark-diary-entries): Adapt for new behaviours of 115 (mark-diary-entries): Adapt for new behaviours of
@@ -109,8 +130,8 @@
109 (mark-hebrew-diary-entries): Adapt for new behaviours of 130 (mark-hebrew-diary-entries): Adapt for new behaviours of
110 `diary-name-pattern' and `calendar-make-alist' functions. 131 `diary-name-pattern' and `calendar-make-alist' functions.
111 132
112 * calendar/cal-islam.el (calendar-islamic-month-name-array): Add 133 * calendar/cal-islam.el (calendar-islamic-month-name-array):
113 doc string. 134 Add doc string.
114 (list-islamic-diary-entries): Adapt for new behaviours of 135 (list-islamic-diary-entries): Adapt for new behaviours of
115 `calendar-day-name' and `add-to-diary-list' functions. 136 `calendar-day-name' and `add-to-diary-list' functions.
116 (mark-islamic-diary-entries): Adapt for new behaviours of 137 (mark-islamic-diary-entries): Adapt for new behaviours of
@@ -153,8 +174,8 @@
153 (c-search-decl-header-end): Don't trip up on operator identifiers 174 (c-search-decl-header-end): Don't trip up on operator identifiers
154 in C++ and operators like == in all languages. 175 in C++ and operators like == in all languages.
155 176
156 * progmodes/cc-engine.el (c-backward-to-decl-anchor): Detect 177 * progmodes/cc-engine.el (c-backward-to-decl-anchor):
157 leading labels correctly. 178 Detect leading labels correctly.
158 179
1592003-08-02 Andreas Schwab <schwab@suse.de> 1802003-08-02 Andreas Schwab <schwab@suse.de>
160 181
@@ -180,8 +201,8 @@
180 201
1812003-07-30 Kenichi Handa <handa@m17n.org> 2022003-07-30 Kenichi Handa <handa@m17n.org>
182 203
183 * international/fontset.el (setup-default-fontset): Change 204 * international/fontset.el (setup-default-fontset):
184 registry names of Akurti fonts. 205 Change registry names of Akurti fonts.
185 206
1862003-07-29 Jesper Harder <harder@ifa.au.dk> (tiny change) 2072003-07-29 Jesper Harder <harder@ifa.au.dk> (tiny change)
187 208
@@ -194,8 +215,8 @@
194 215
1952003-07-28 Nick Roberts <nick@nick.uklinux.net> 2162003-07-28 Nick Roberts <nick@nick.uklinux.net>
196 217
197 * gdb-ui.el (gdb-setup-windows, gdb-restore-windows): Restore 218 * gdb-ui.el (gdb-setup-windows, gdb-restore-windows):
198 assembler in source window if that is what has been selected. 219 Restore assembler in source window if that is what has been selected.
199 (menu): Add gdb-restore-windows to menu. Make gdba 220 (menu): Add gdb-restore-windows to menu. Make gdba
200 specific menus only visible from gdba. 221 specific menus only visible from gdba.
201 222
@@ -228,8 +249,7 @@
228 249
2292003-07-26 Markus Rost <rost@math.ohio-state.edu> 2502003-07-26 Markus Rost <rost@math.ohio-state.edu>
230 251
231 * international/quail.el (quail-translate-key): Fix previous 252 * international/quail.el (quail-translate-key): Fix previous change.
232 change.
233 253
2342003-07-25 John Paul Wallington <jpw@gnu.org> 2542003-07-25 John Paul Wallington <jpw@gnu.org>
235 255
diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 2e1a7595094..999e2c623e0 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -456,21 +456,21 @@ probably don't want to include one yourself.
456Optional second arg DEFAULT is a string to return if the user enters 456Optional second arg DEFAULT is a string to return if the user enters
457the empty string." 457the empty string."
458 (bookmark-maybe-load-default-file) ; paranoia 458 (bookmark-maybe-load-default-file) ; paranoia
459 (let* ((completion-ignore-case bookmark-completion-ignore-case) 459 (if (listp last-nonmenu-event)
460 (default default) 460 (bookmark-menu-popup-paned-menu t prompt (bookmark-all-names))
461 (prompt (if default 461 (let* ((completion-ignore-case bookmark-completion-ignore-case)
462 (concat prompt (format " (%s): " default)) 462 (default default)
463 (concat prompt ": "))) 463 (prompt (if default
464 (str 464 (concat prompt (format " (%s): " default))
465 (completing-read prompt 465 (concat prompt ": ")))
466 bookmark-alist 466 (str
467 nil 467 (completing-read prompt
468 0 468 bookmark-alist
469 nil 469 nil
470 'bookmark-history))) 470 0
471 (if (string-equal "" str) 471 nil
472 (list default) 472 'bookmark-history)))
473 (list str)))) 473 (if (string-equal "" str) default str))))
474 474
475 475
476(defmacro bookmark-maybe-historicize-string (string) 476(defmacro bookmark-maybe-historicize-string (string)
@@ -924,10 +924,8 @@ When you have finished composing, type \\[bookmark-send-annotation].
924 924
925(defun bookmark-edit-annotation (bookmark) 925(defun bookmark-edit-annotation (bookmark)
926 "Pop up a buffer for editing bookmark BOOKMARK's annotation." 926 "Pop up a buffer for editing bookmark BOOKMARK's annotation."
927 (let ((buf (current-buffer)) 927 (pop-to-buffer (generate-new-buffer-name "*Bookmark Annotation Compose*"))
928 (point (point))) 928 (bookmark-edit-annotation-mode bookmark))
929 (pop-to-buffer (generate-new-buffer-name "*Bookmark Annotation Compose*"))
930 (bookmark-edit-annotation-mode bookmark)))
931 929
932 930
933(defun bookmark-insert-current-bookmark () 931(defun bookmark-insert-current-bookmark ()
@@ -1046,7 +1044,8 @@ if you wish to give the bookmark a new location, and bookmark-jump
1046will then jump to the new location, as well as recording it in place 1044will then jump to the new location, as well as recording it in place
1047of the old one in the permanent bookmark record." 1045of the old one in the permanent bookmark record."
1048 (interactive 1046 (interactive
1049 (bookmark-completing-read "Jump to bookmark" bookmark-current-bookmark)) 1047 (list (bookmark-completing-read "Jump to bookmark"
1048 bookmark-current-bookmark)))
1050 (bookmark-maybe-historicize-string bookmark) 1049 (bookmark-maybe-historicize-string bookmark)
1051 (let ((cell (bookmark-jump-noselect bookmark))) 1050 (let ((cell (bookmark-jump-noselect bookmark)))
1052 (and cell 1051 (and cell
@@ -1139,7 +1138,7 @@ be retrieved from a VC backend, else return nil."
1139This makes an already existing bookmark point to that file, instead of 1138This makes an already existing bookmark point to that file, instead of
1140the one it used to point at. Useful when a file has been renamed 1139the one it used to point at. Useful when a file has been renamed
1141after a bookmark was set in it." 1140after a bookmark was set in it."
1142 (interactive (bookmark-completing-read "Bookmark to relocate")) 1141 (interactive (list (bookmark-completing-read "Bookmark to relocate")))
1143 (bookmark-maybe-historicize-string bookmark) 1142 (bookmark-maybe-historicize-string bookmark)
1144 (bookmark-maybe-load-default-file) 1143 (bookmark-maybe-load-default-file)
1145 (let* ((bmrk-filename (bookmark-get-filename bookmark)) 1144 (let* ((bmrk-filename (bookmark-get-filename bookmark))
@@ -1156,7 +1155,7 @@ after a bookmark was set in it."
1156 "Insert the name of the file associated with BOOKMARK. 1155 "Insert the name of the file associated with BOOKMARK.
1157Optional second arg NO-HISTORY means don't record this in the 1156Optional second arg NO-HISTORY means don't record this in the
1158minibuffer history list `bookmark-history'." 1157minibuffer history list `bookmark-history'."
1159 (interactive (bookmark-completing-read "Insert bookmark location")) 1158 (interactive (list (bookmark-completing-read "Insert bookmark location")))
1160 (or no-history (bookmark-maybe-historicize-string bookmark)) 1159 (or no-history (bookmark-maybe-historicize-string bookmark))
1161 (let ((start (point))) 1160 (let ((start (point)))
1162 (prog1 1161 (prog1
@@ -1191,7 +1190,7 @@ must pass at least OLD when calling from Lisp.
1191While you are entering the new name, consecutive C-w's insert 1190While you are entering the new name, consecutive C-w's insert
1192consecutive words from the text of the buffer into the new bookmark 1191consecutive words from the text of the buffer into the new bookmark
1193name." 1192name."
1194 (interactive (bookmark-completing-read "Old bookmark name")) 1193 (interactive (list (bookmark-completing-read "Old bookmark name")))
1195 (bookmark-maybe-historicize-string old) 1194 (bookmark-maybe-historicize-string old)
1196 (bookmark-maybe-load-default-file) 1195 (bookmark-maybe-load-default-file)
1197 1196
@@ -1224,7 +1223,7 @@ You may have a problem using this function if the value of variable
1224`bookmark-alist' is nil. If that happens, you need to load in some 1223`bookmark-alist' is nil. If that happens, you need to load in some
1225bookmarks. See help on function `bookmark-load' for more about 1224bookmarks. See help on function `bookmark-load' for more about
1226this." 1225this."
1227 (interactive (bookmark-completing-read "Insert bookmark contents")) 1226 (interactive (list (bookmark-completing-read "Insert bookmark contents")))
1228 (bookmark-maybe-historicize-string bookmark) 1227 (bookmark-maybe-historicize-string bookmark)
1229 (bookmark-maybe-load-default-file) 1228 (bookmark-maybe-load-default-file)
1230 (let ((orig-point (point)) 1229 (let ((orig-point (point))
@@ -1247,7 +1246,8 @@ one most recently used in this file, if any\).
1247Optional second arg BATCH means don't update the bookmark list buffer, 1246Optional second arg BATCH means don't update the bookmark list buffer,
1248probably because we were called from there." 1247probably because we were called from there."
1249 (interactive 1248 (interactive
1250 (bookmark-completing-read "Delete bookmark" bookmark-current-bookmark)) 1249 (list (bookmark-completing-read "Delete bookmark"
1250 bookmark-current-bookmark)))
1251 (bookmark-maybe-historicize-string bookmark) 1251 (bookmark-maybe-historicize-string bookmark)
1252 (bookmark-maybe-load-default-file) 1252 (bookmark-maybe-load-default-file)
1253 (let ((will-go (bookmark-get-bookmark bookmark))) 1253 (let ((will-go (bookmark-get-bookmark bookmark)))
@@ -1533,9 +1533,8 @@ deletion, or > if it is flagged for displaying."
1533 (if (interactive-p) 1533 (if (interactive-p)
1534 (switch-to-buffer (get-buffer-create "*Bookmark List*")) 1534 (switch-to-buffer (get-buffer-create "*Bookmark List*"))
1535 (set-buffer (get-buffer-create "*Bookmark List*"))) 1535 (set-buffer (get-buffer-create "*Bookmark List*")))
1536 (let ((buffer-read-only nil)) 1536 (let ((inhibit-read-only t))
1537 (delete-region (point-max) (point-min)) 1537 (erase-buffer)
1538 (goto-char (point-min)) ;sure are playing it safe...
1539 (insert "% Bookmark\n- --------\n") 1538 (insert "% Bookmark\n- --------\n")
1540 (bookmark-maybe-sort-alist) 1539 (bookmark-maybe-sort-alist)
1541 (mapcar 1540 (mapcar
@@ -1638,7 +1637,7 @@ Optional argument SHOW means show them unconditionally."
1638 (goto-char (point-min)) 1637 (goto-char (point-min))
1639 (forward-line 2) 1638 (forward-line 2)
1640 (setq bookmark-bmenu-hidden-bookmarks ()) 1639 (setq bookmark-bmenu-hidden-bookmarks ())
1641 (let ((buffer-read-only nil)) 1640 (let ((inhibit-read-only t))
1642 (while (< (point) (point-max)) 1641 (while (< (point) (point-max))
1643 (let ((bmrk (bookmark-bmenu-bookmark))) 1642 (let ((bmrk (bookmark-bmenu-bookmark)))
1644 (setq bookmark-bmenu-hidden-bookmarks 1643 (setq bookmark-bmenu-hidden-bookmarks
@@ -1671,7 +1670,7 @@ Optional argument SHOW means show them unconditionally."
1671 (backward-word 1) 1670 (backward-word 1)
1672 (setq bookmark-bmenu-bookmark-column (current-column))) 1671 (setq bookmark-bmenu-bookmark-column (current-column)))
1673 (save-excursion 1672 (save-excursion
1674 (let ((buffer-read-only nil)) 1673 (let ((inhibit-read-only t))
1675 (while bookmark-bmenu-hidden-bookmarks 1674 (while bookmark-bmenu-hidden-bookmarks
1676 (move-to-column bookmark-bmenu-bookmark-column t) 1675 (move-to-column bookmark-bmenu-bookmark-column t)
1677 (bookmark-kill-line) 1676 (bookmark-kill-line)
@@ -1774,7 +1773,7 @@ if an annotation exists."
1774 (interactive) 1773 (interactive)
1775 (beginning-of-line) 1774 (beginning-of-line)
1776 (if (bookmark-bmenu-check-position) 1775 (if (bookmark-bmenu-check-position)
1777 (let ((buffer-read-only nil)) 1776 (let ((inhibit-read-only t))
1778 (delete-char 1) 1777 (delete-char 1)
1779 (insert ?>) 1778 (insert ?>)
1780 (forward-line 1) 1779 (forward-line 1)
@@ -1793,7 +1792,7 @@ You can mark bookmarks with the \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-mar
1793 (goto-char (point-min)) 1792 (goto-char (point-min))
1794 (while (re-search-forward "^>" nil t) 1793 (while (re-search-forward "^>" nil t)
1795 (setq tem (bookmark-bmenu-bookmark)) 1794 (setq tem (bookmark-bmenu-bookmark))
1796 (let ((buffer-read-only nil)) 1795 (let ((inhibit-read-only t))
1797 (delete-char -1) 1796 (delete-char -1)
1798 (insert ?\ )) 1797 (insert ?\ ))
1799 (or (string-equal tem bmrk) 1798 (or (string-equal tem bmrk)
@@ -1940,7 +1939,7 @@ Optional BACKUP means move up."
1940 (beginning-of-line) 1939 (beginning-of-line)
1941 (if (bookmark-bmenu-check-position) 1940 (if (bookmark-bmenu-check-position)
1942 (progn 1941 (progn
1943 (let ((buffer-read-only nil)) 1942 (let ((inhibit-read-only t))
1944 (delete-char 1) 1943 (delete-char 1)
1945 ;; any flags to reset according to circumstances? How about a 1944 ;; any flags to reset according to circumstances? How about a
1946 ;; flag indicating whether this bookmark is being visited? 1945 ;; flag indicating whether this bookmark is being visited?
@@ -1967,7 +1966,7 @@ To carry out the deletions that you've marked, use \\<bookmark-bmenu-mode-map>\\
1967 (interactive) 1966 (interactive)
1968 (beginning-of-line) 1967 (beginning-of-line)
1969 (if (bookmark-bmenu-check-position) 1968 (if (bookmark-bmenu-check-position)
1970 (let ((buffer-read-only nil)) 1969 (let ((inhibit-read-only t))
1971 (delete-char 1) 1970 (delete-char 1)
1972 (insert ?D) 1971 (insert ?D)
1973 (forward-line 1) 1972 (forward-line 1)
@@ -2047,149 +2046,38 @@ To carry out the deletions that you've marked, use \\<bookmark-bmenu-mode-map>\\
2047 2046
2048;;; Menu bar stuff. Prefix is "bookmark-menu". 2047;;; Menu bar stuff. Prefix is "bookmark-menu".
2049 2048
2050(defun bookmark-menu-build-paned-menu (name entries)
2051 "Build a multi-paned menu named NAME from the strings in ENTRIES.
2052That is, ENTRIES is a list of strings which appear as the choices
2053in the menu. The number of panes depends on the number of entries.
2054The visible entries are truncated to `bookmark-menu-length', but the
2055strings returned are not."
2056 (let* ((f-height (/ (frame-height) 2))
2057 (pane-list
2058 (let (temp-pane-list
2059 (iter 0))
2060 (while entries
2061 (let (lst
2062 (count 0))
2063 (while (and (< count f-height) entries)
2064 (let ((str (car entries)))
2065 (setq lst (cons
2066 (cons
2067 (if (> (length str) bookmark-menu-length)
2068 (substring str 0 bookmark-menu-length)
2069 str)
2070 str)
2071 lst))
2072 (setq entries (cdr entries))
2073 (setq count (1+ count))))
2074 (setq iter (1+ iter))
2075 (setq
2076 temp-pane-list
2077 (cons
2078 (cons
2079 (format "-*- %s (%d) -*-" name iter)
2080 (nreverse lst))
2081 temp-pane-list))))
2082 (nreverse temp-pane-list))))
2083
2084 ;; Return the menu:
2085 (cons (concat "-*- " name " -*-") pane-list)))
2086
2087
2088(defun bookmark-menu-popup-paned-menu (event name entries) 2049(defun bookmark-menu-popup-paned-menu (event name entries)
2089 "Pop up multi-paned menu at EVENT, return string chosen from ENTRIES. 2050 "Pop up multi-paned menu at EVENT, return string chosen from ENTRIES.
2090That is, ENTRIES is a list of strings which appear as the choices 2051That is, ENTRIES is a list of strings which appear as the choices
2091in the menu. 2052in the menu.
2092The number of panes depends on the number of entries." 2053The number of panes depends on the number of entries.
2093 (interactive "e") 2054The visible entries are truncated to `bookmark-menu-length', but the
2094 (x-popup-menu event (bookmark-menu-build-paned-menu name entries))) 2055strings returned are not."
2095 2056 (let ((f-height (/ (frame-height) 2))
2096 2057 (pane-list nil)
2097(defun bookmark-menu-popup-paned-bookmark-menu (event name) 2058 (iter 0))
2098 "Pop up menu of bookmarks, return chosen bookmark. 2059 (while entries
2099Pop up at EVENT, menu's name is NAME. 2060 (let (lst
2100The number of panes depends on the number of bookmarks." 2061 (count 0))
2101 (bookmark-menu-popup-paned-menu event name (bookmark-all-names))) 2062 (while (and (< count f-height) entries)
2102 2063 (let ((str (car entries)))
2103 2064 (push (cons
2104(defun bookmark-popup-menu-and-apply-function (func-sym menu-label event) 2065 (if (> (length str) bookmark-menu-length)
2105 ;; help function for making menus that need to apply a bookmark 2066 (substring str 0 bookmark-menu-length)
2106 ;; function to a string. 2067 str)
2107 (let* ((choice (bookmark-menu-popup-paned-bookmark-menu 2068 str)
2108 event menu-label))) 2069 lst)
2109 (if choice (apply func-sym (list choice))))) 2070 (setq entries (cdr entries))
2110 2071 (setq count (1+ count))))
2111 2072 (setq iter (1+ iter))
2112;;;###autoload 2073 (push (cons
2113(defun bookmark-menu-insert (event) 2074 (format "-*- %s (%d) -*-" name iter)
2114 "Insert the text of the file pointed to by bookmark BOOKMARK. 2075 (nreverse lst))
2115You may have a problem using this function if the value of variable 2076 pane-list)))
2116`bookmark-alist' is nil. If that happens, you need to load in some 2077
2117bookmarks. See help on function `bookmark-load' for more about 2078 ;; Popup the menu and return the string.
2118this. 2079 (x-popup-menu event (cons (concat "-*- " name " -*-")
2119 2080 (nreverse pane-list)))))
2120Warning: this function only takes an EVENT as argument. Use the
2121corresponding bookmark function from Lisp \(the one without the
2122\"-menu-\" in its name\)."
2123 (interactive "e")
2124 (bookmark-popup-menu-and-apply-function
2125 'bookmark-insert "Insert Bookmark Contents" event))
2126
2127
2128;;;###autoload
2129(defun bookmark-menu-jump (event)
2130 "Jump to bookmark BOOKMARK (a point in some file).
2131You may have a problem using this function if the value of variable
2132`bookmark-alist' is nil. If that happens, you need to load in some
2133bookmarks. See help on function `bookmark-load' for more about
2134this.
2135
2136Warning: this function only takes an EVENT as argument. Use the
2137corresponding bookmark function from Lisp \(the one without the
2138\"-menu-\" in its name\)."
2139 (interactive "e")
2140 (bookmark-popup-menu-and-apply-function
2141 'bookmark-jump "Jump to Bookmark" event))
2142
2143
2144;;;###autoload
2145(defun bookmark-menu-locate (event)
2146 "Insert the name of the file associated with BOOKMARK.
2147\(This is not the same as the contents of that file\).
2148
2149Warning: this function only takes an EVENT as argument. Use the
2150corresponding bookmark function from Lisp \(the one without the
2151\"-menu-\" in its name\)."
2152 (interactive "e")
2153 (bookmark-popup-menu-and-apply-function
2154 'bookmark-insert-location "Insert Bookmark Location" event))
2155
2156
2157;;;###autoload
2158(defun bookmark-menu-rename (event)
2159 "Change the name of OLD-BOOKMARK to NEWNAME.
2160If called from keyboard, prompts for OLD-BOOKMARK and NEWNAME.
2161If called from menubar, OLD-BOOKMARK is selected from a menu, and
2162prompts for NEWNAME.
2163If called from Lisp, prompts for NEWNAME if only OLD-BOOKMARK was
2164passed as an argument. If called with two strings, then no prompting
2165is done. You must pass at least OLD-BOOKMARK when calling from Lisp.
2166
2167While you are entering the new name, consecutive C-w's insert
2168consecutive words from the text of the buffer into the new bookmark
2169name.
2170
2171Warning: this function only takes an EVENT as argument. Use the
2172corresponding bookmark function from Lisp \(the one without the
2173\"-menu-\" in its name\)."
2174 (interactive "e")
2175 (bookmark-popup-menu-and-apply-function
2176 'bookmark-rename "Rename Bookmark" event))
2177
2178
2179;;;###autoload
2180(defun bookmark-menu-delete (event)
2181 "Delete the bookmark named NAME from the bookmark list.
2182Removes only the first instance of a bookmark with that name. If
2183there are one or more other bookmarks with the same name, they will
2184not be deleted. Defaults to the \"current\" bookmark \(that is, the
2185one most recently used in this file, if any\).
2186
2187Warning: this function only takes an EVENT as argument. Use the
2188corresponding bookmark function from Lisp \(the one without the
2189\"-menu-\" in its name\)."
2190 (interactive "e")
2191 (bookmark-popup-menu-and-apply-function
2192 'bookmark-delete "Delete Bookmark" event))
2193 2081
2194 2082
2195;; Thanks to Roland McGrath for fixing menubar.el so that the 2083;; Thanks to Roland McGrath for fixing menubar.el so that the
@@ -2201,10 +2089,22 @@ corresponding bookmark function from Lisp \(the one without the
2201;; Emacs menubar stuff. 2089;; Emacs menubar stuff.
2202 2090
2203;;;###autoload 2091;;;###autoload
2204(defvar menu-bar-bookmark-map (make-sparse-keymap "Bookmark functions")) 2092(defvar menu-bar-bookmark-map
2093 (let ((map (make-sparse-keymap "Bookmark functions")))
2094 (define-key map [load] '("Load a Bookmark File..." . bookmark-load))
2095 (define-key map [write] '("Save Bookmarks As..." . bookmark-write))
2096 (define-key map [save] '("Save Bookmarks" . bookmark-save))
2097 (define-key map [edit] '("Edit Bookmark List" . bookmark-bmenu-list))
2098 (define-key map [delete] '("Delete Bookmark" . bookmark-delete))
2099 (define-key map [rename] '("Rename Bookmark" . bookmark-rename))
2100 (define-key map [locate] '("Insert Location" . bookmark-locate))
2101 (define-key map [insert] '("Insert Contents" . bookmark-insert))
2102 (define-key map [set] '("Set Bookmark" . bookmark-set))
2103 (define-key map [jump] '("Jump to Bookmark" . bookmark-jump))
2104 map))
2205 2105
2206;;;###autoload 2106;;;###autoload
2207(defalias 'menu-bar-bookmark-map (symbol-value 'menu-bar-bookmark-map)) 2107(defalias 'menu-bar-bookmark-map menu-bar-bookmark-map)
2208 2108
2209;; make bookmarks appear toward the right side of the menu. 2109;; make bookmarks appear toward the right side of the menu.
2210(if (boundp 'menu-bar-final-items) 2110(if (boundp 'menu-bar-final-items)
@@ -2213,55 +2113,24 @@ corresponding bookmark function from Lisp \(the one without the
2213 (cons 'bookmark menu-bar-final-items))) 2113 (cons 'bookmark menu-bar-final-items)))
2214 (setq menu-bar-final-items '(bookmark))) 2114 (setq menu-bar-final-items '(bookmark)))
2215 2115
2216;;;###autoload (define-key menu-bar-bookmark-map [load]
2217;;;###autoload '("Load a Bookmark File..." . bookmark-load))
2218
2219;;;###autoload (define-key menu-bar-bookmark-map [write]
2220;;;###autoload '("Save Bookmarks As..." . bookmark-write))
2221
2222;;;###autoload (define-key menu-bar-bookmark-map [save]
2223;;;###autoload '("Save Bookmarks" . bookmark-save))
2224
2225;;;###autoload (define-key menu-bar-bookmark-map [edit]
2226;;;###autoload '("Edit Bookmark List" . bookmark-bmenu-list))
2227
2228;;;###autoload (define-key menu-bar-bookmark-map [delete]
2229;;;###autoload '("Delete Bookmark" . bookmark-menu-delete))
2230
2231;;;###autoload (define-key menu-bar-bookmark-map [rename]
2232;;;###autoload '("Rename Bookmark" . bookmark-menu-rename))
2233
2234;;;###autoload (define-key menu-bar-bookmark-map [locate]
2235;;;###autoload '("Insert Location" . bookmark-menu-locate))
2236
2237;;;###autoload (define-key menu-bar-bookmark-map [insert]
2238;;;###autoload '("Insert Contents" . bookmark-menu-insert))
2239
2240;;;###autoload (define-key menu-bar-bookmark-map [set]
2241;;;###autoload '("Set Bookmark" . bookmark-set))
2242
2243;;;###autoload (define-key menu-bar-bookmark-map [jump]
2244;;;###autoload '("Jump to Bookmark" . bookmark-menu-jump))
2245
2246;;;; end bookmark menu stuff ;;;; 2116;;;; end bookmark menu stuff ;;;;
2247 2117
2248 2118
2249;;; Load Hook 2119;;; Load Hook
2250(defvar bookmark-load-hook nil 2120(defvar bookmark-load-hook nil
2251 "Hook to run at the end of loading bookmark.") 2121 "Hook run at the end of loading bookmark.")
2252 2122
2253;;; Exit Hook, called from kill-emacs-hook 2123;;; Exit Hook, called from kill-emacs-hook
2254(defvar bookmark-exit-hook nil 2124(defvar bookmark-exit-hook nil
2255 "Hook to run when emacs exits") 2125 "Hook run when emacs exits.")
2256 2126
2257(defun bookmark-exit-hook-internal () 2127(defun bookmark-exit-hook-internal ()
2258 "Save bookmark state, if necessary, at Emacs exit time. 2128 "Save bookmark state, if necessary, at Emacs exit time.
2259This also runs `bookmark-exit-hooks'." 2129This also runs `bookmark-exit-hooks'."
2260 (and 2130 (run-hooks 'bookmark-exit-hooks)
2261 (progn (run-hooks 'bookmark-exit-hooks) t) 2131 (and bookmark-alist
2262 bookmark-alist 2132 (bookmark-time-to-save-p t)
2263 (bookmark-time-to-save-p t) 2133 (bookmark-save)))
2264 (bookmark-save)))
2265 2134
2266(add-hook 'kill-emacs-hook 'bookmark-exit-hook-internal) 2135(add-hook 'kill-emacs-hook 'bookmark-exit-hook-internal)
2267 2136