Mercurial > emacs
comparison lisp/bookmark.el @ 89909:68c22ea6027c
Sync to HEAD
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 16 Apr 2004 12:51:06 +0000 |
parents | 375f2633d815 |
children | 4c90ffeb71c5 |
comparison
equal
deleted
inserted
replaced
89908:ee1402f7b568 | 89909:68c22ea6027c |
---|---|
333 | 333 |
334 (defun bookmark-get-bookmark (bookmark) | 334 (defun bookmark-get-bookmark (bookmark) |
335 "Return the full entry for BOOKMARK in bookmark-alist. | 335 "Return the full entry for BOOKMARK in bookmark-alist. |
336 If BOOKMARK is not a string, return nil." | 336 If BOOKMARK is not a string, return nil." |
337 (when (stringp bookmark) | 337 (when (stringp bookmark) |
338 (apply (if bookmark-completion-ignore-case | 338 (assoc-string bookmark bookmark-alist bookmark-completion-ignore-case))) |
339 #'assoc-ignore-case | |
340 #'assoc) | |
341 (list bookmark bookmark-alist)))) | |
342 | 339 |
343 | 340 |
344 (defun bookmark-get-bookmark-record (bookmark) | 341 (defun bookmark-get-bookmark-record (bookmark) |
345 "Return the guts of the entry for BOOKMARK in bookmark-alist. | 342 "Return the guts of the entry for BOOKMARK in bookmark-alist. |
346 That is, all information but the name." | 343 That is, all information but the name." |
454 PROMPT will get a \": \" stuck on the end no matter what, so you | 451 PROMPT will get a \": \" stuck on the end no matter what, so you |
455 probably don't want to include one yourself. | 452 probably don't want to include one yourself. |
456 Optional second arg DEFAULT is a string to return if the user enters | 453 Optional second arg DEFAULT is a string to return if the user enters |
457 the empty string." | 454 the empty string." |
458 (bookmark-maybe-load-default-file) ; paranoia | 455 (bookmark-maybe-load-default-file) ; paranoia |
459 (let* ((completion-ignore-case bookmark-completion-ignore-case) | 456 (if (listp last-nonmenu-event) |
460 (default default) | 457 (bookmark-menu-popup-paned-menu t prompt (bookmark-all-names)) |
461 (prompt (if default | 458 (let* ((completion-ignore-case bookmark-completion-ignore-case) |
462 (concat prompt (format " (%s): " default)) | 459 (default default) |
463 (concat prompt ": "))) | 460 (prompt (if default |
464 (str | 461 (concat prompt (format " (%s): " default)) |
465 (completing-read prompt | 462 (concat prompt ": "))) |
466 bookmark-alist | 463 (str |
467 nil | 464 (completing-read prompt |
468 0 | 465 bookmark-alist |
469 nil | 466 nil |
470 'bookmark-history))) | 467 0 |
471 (if (string-equal "" str) | 468 nil |
472 (list default) | 469 'bookmark-history))) |
473 (list str)))) | 470 (if (string-equal "" str) default str)))) |
474 | 471 |
475 | 472 |
476 (defmacro bookmark-maybe-historicize-string (string) | 473 (defmacro bookmark-maybe-historicize-string (string) |
477 "Put STRING into the bookmark prompt history, if caller non-interactive. | 474 "Put STRING into the bookmark prompt history, if caller non-interactive. |
478 We need this because sometimes bookmark functions are invoked from | 475 We need this because sometimes bookmark functions are invoked from |
922 (kill-buffer (current-buffer))) | 919 (kill-buffer (current-buffer))) |
923 | 920 |
924 | 921 |
925 (defun bookmark-edit-annotation (bookmark) | 922 (defun bookmark-edit-annotation (bookmark) |
926 "Pop up a buffer for editing bookmark BOOKMARK's annotation." | 923 "Pop up a buffer for editing bookmark BOOKMARK's annotation." |
927 (let ((buf (current-buffer)) | 924 (pop-to-buffer (generate-new-buffer-name "*Bookmark Annotation Compose*")) |
928 (point (point))) | 925 (bookmark-edit-annotation-mode bookmark)) |
929 (pop-to-buffer (generate-new-buffer-name "*Bookmark Annotation Compose*")) | |
930 (bookmark-edit-annotation-mode bookmark))) | |
931 | 926 |
932 | 927 |
933 (defun bookmark-insert-current-bookmark () | 928 (defun bookmark-insert-current-bookmark () |
934 "Insert this buffer's value of bookmark-current-bookmark. | 929 "Insert this buffer's value of bookmark-current-bookmark. |
935 Default to file name if it's nil." | 930 Default to file name if it's nil." |
1044 If the file pointed to by BOOKMARK no longer exists, you will be asked | 1039 If the file pointed to by BOOKMARK no longer exists, you will be asked |
1045 if you wish to give the bookmark a new location, and bookmark-jump | 1040 if you wish to give the bookmark a new location, and bookmark-jump |
1046 will then jump to the new location, as well as recording it in place | 1041 will then jump to the new location, as well as recording it in place |
1047 of the old one in the permanent bookmark record." | 1042 of the old one in the permanent bookmark record." |
1048 (interactive | 1043 (interactive |
1049 (bookmark-completing-read "Jump to bookmark" bookmark-current-bookmark)) | 1044 (list (bookmark-completing-read "Jump to bookmark" |
1045 bookmark-current-bookmark))) | |
1050 (bookmark-maybe-historicize-string bookmark) | 1046 (bookmark-maybe-historicize-string bookmark) |
1051 (let ((cell (bookmark-jump-noselect bookmark))) | 1047 (let ((cell (bookmark-jump-noselect bookmark))) |
1052 (and cell | 1048 (and cell |
1053 (switch-to-buffer (car cell)) | 1049 (switch-to-buffer (car cell)) |
1054 (goto-char (cdr cell)) | 1050 (goto-char (cdr cell)) |
1137 (defun bookmark-relocate (bookmark) | 1133 (defun bookmark-relocate (bookmark) |
1138 "Relocate BOOKMARK to another file (reading file name with minibuffer). | 1134 "Relocate BOOKMARK to another file (reading file name with minibuffer). |
1139 This makes an already existing bookmark point to that file, instead of | 1135 This makes an already existing bookmark point to that file, instead of |
1140 the one it used to point at. Useful when a file has been renamed | 1136 the one it used to point at. Useful when a file has been renamed |
1141 after a bookmark was set in it." | 1137 after a bookmark was set in it." |
1142 (interactive (bookmark-completing-read "Bookmark to relocate")) | 1138 (interactive (list (bookmark-completing-read "Bookmark to relocate"))) |
1143 (bookmark-maybe-historicize-string bookmark) | 1139 (bookmark-maybe-historicize-string bookmark) |
1144 (bookmark-maybe-load-default-file) | 1140 (bookmark-maybe-load-default-file) |
1145 (let* ((bmrk-filename (bookmark-get-filename bookmark)) | 1141 (let* ((bmrk-filename (bookmark-get-filename bookmark)) |
1146 (newloc (expand-file-name | 1142 (newloc (expand-file-name |
1147 (read-file-name | 1143 (read-file-name |
1154 ;;;###autoload | 1150 ;;;###autoload |
1155 (defun bookmark-insert-location (bookmark &optional no-history) | 1151 (defun bookmark-insert-location (bookmark &optional no-history) |
1156 "Insert the name of the file associated with BOOKMARK. | 1152 "Insert the name of the file associated with BOOKMARK. |
1157 Optional second arg NO-HISTORY means don't record this in the | 1153 Optional second arg NO-HISTORY means don't record this in the |
1158 minibuffer history list `bookmark-history'." | 1154 minibuffer history list `bookmark-history'." |
1159 (interactive (bookmark-completing-read "Insert bookmark location")) | 1155 (interactive (list (bookmark-completing-read "Insert bookmark location"))) |
1160 (or no-history (bookmark-maybe-historicize-string bookmark)) | 1156 (or no-history (bookmark-maybe-historicize-string bookmark)) |
1161 (let ((start (point))) | 1157 (let ((start (point))) |
1162 (prog1 | 1158 (prog1 |
1163 (insert (bookmark-location bookmark)) ; *Return this line* | 1159 (insert (bookmark-location bookmark)) ; *Return this line* |
1164 (if (and (display-color-p) (display-mouse-p)) | 1160 (if (and (display-color-p) (display-mouse-p)) |
1189 must pass at least OLD when calling from Lisp. | 1185 must pass at least OLD when calling from Lisp. |
1190 | 1186 |
1191 While you are entering the new name, consecutive C-w's insert | 1187 While you are entering the new name, consecutive C-w's insert |
1192 consecutive words from the text of the buffer into the new bookmark | 1188 consecutive words from the text of the buffer into the new bookmark |
1193 name." | 1189 name." |
1194 (interactive (bookmark-completing-read "Old bookmark name")) | 1190 (interactive (list (bookmark-completing-read "Old bookmark name"))) |
1195 (bookmark-maybe-historicize-string old) | 1191 (bookmark-maybe-historicize-string old) |
1196 (bookmark-maybe-load-default-file) | 1192 (bookmark-maybe-load-default-file) |
1197 | 1193 |
1198 (setq bookmark-current-point (point)) | 1194 (setq bookmark-current-point (point)) |
1199 (setq bookmark-yank-point (point)) | 1195 (setq bookmark-yank-point (point)) |
1222 "Insert the text of the file pointed to by bookmark BOOKMARK. | 1218 "Insert the text of the file pointed to by bookmark BOOKMARK. |
1223 You may have a problem using this function if the value of variable | 1219 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 | 1220 `bookmark-alist' is nil. If that happens, you need to load in some |
1225 bookmarks. See help on function `bookmark-load' for more about | 1221 bookmarks. See help on function `bookmark-load' for more about |
1226 this." | 1222 this." |
1227 (interactive (bookmark-completing-read "Insert bookmark contents")) | 1223 (interactive (list (bookmark-completing-read "Insert bookmark contents"))) |
1228 (bookmark-maybe-historicize-string bookmark) | 1224 (bookmark-maybe-historicize-string bookmark) |
1229 (bookmark-maybe-load-default-file) | 1225 (bookmark-maybe-load-default-file) |
1230 (let ((orig-point (point)) | 1226 (let ((orig-point (point)) |
1231 (str-to-insert | 1227 (str-to-insert |
1232 (save-excursion | 1228 (save-excursion |
1245 not be deleted. Defaults to the \"current\" bookmark \(that is, the | 1241 not be deleted. Defaults to the \"current\" bookmark \(that is, the |
1246 one most recently used in this file, if any\). | 1242 one most recently used in this file, if any\). |
1247 Optional second arg BATCH means don't update the bookmark list buffer, | 1243 Optional second arg BATCH means don't update the bookmark list buffer, |
1248 probably because we were called from there." | 1244 probably because we were called from there." |
1249 (interactive | 1245 (interactive |
1250 (bookmark-completing-read "Delete bookmark" bookmark-current-bookmark)) | 1246 (list (bookmark-completing-read "Delete bookmark" |
1247 bookmark-current-bookmark))) | |
1251 (bookmark-maybe-historicize-string bookmark) | 1248 (bookmark-maybe-historicize-string bookmark) |
1252 (bookmark-maybe-load-default-file) | 1249 (bookmark-maybe-load-default-file) |
1253 (let ((will-go (bookmark-get-bookmark bookmark))) | 1250 (let ((will-go (bookmark-get-bookmark bookmark))) |
1254 (setq bookmark-alist (delq will-go bookmark-alist)) | 1251 (setq bookmark-alist (delq will-go bookmark-alist)) |
1255 ;; Added by db, nil bookmark-current-bookmark if the last | 1252 ;; Added by db, nil bookmark-current-bookmark if the last |
1531 (interactive) | 1528 (interactive) |
1532 (bookmark-maybe-load-default-file) | 1529 (bookmark-maybe-load-default-file) |
1533 (if (interactive-p) | 1530 (if (interactive-p) |
1534 (switch-to-buffer (get-buffer-create "*Bookmark List*")) | 1531 (switch-to-buffer (get-buffer-create "*Bookmark List*")) |
1535 (set-buffer (get-buffer-create "*Bookmark List*"))) | 1532 (set-buffer (get-buffer-create "*Bookmark List*"))) |
1536 (let ((buffer-read-only nil)) | 1533 (let ((inhibit-read-only t)) |
1537 (delete-region (point-max) (point-min)) | 1534 (erase-buffer) |
1538 (goto-char (point-min)) ;sure are playing it safe... | |
1539 (insert "% Bookmark\n- --------\n") | 1535 (insert "% Bookmark\n- --------\n") |
1540 (bookmark-maybe-sort-alist) | 1536 (bookmark-maybe-sort-alist) |
1541 (mapcar | 1537 (mapcar |
1542 (lambda (full-record) | 1538 (lambda (full-record) |
1543 ;; if a bookmark has an annotation, prepend a "*" | 1539 ;; if a bookmark has an annotation, prepend a "*" |
1636 (save-excursion | 1632 (save-excursion |
1637 (save-window-excursion | 1633 (save-window-excursion |
1638 (goto-char (point-min)) | 1634 (goto-char (point-min)) |
1639 (forward-line 2) | 1635 (forward-line 2) |
1640 (setq bookmark-bmenu-hidden-bookmarks ()) | 1636 (setq bookmark-bmenu-hidden-bookmarks ()) |
1641 (let ((buffer-read-only nil)) | 1637 (let ((inhibit-read-only t)) |
1642 (while (< (point) (point-max)) | 1638 (while (< (point) (point-max)) |
1643 (let ((bmrk (bookmark-bmenu-bookmark))) | 1639 (let ((bmrk (bookmark-bmenu-bookmark))) |
1644 (setq bookmark-bmenu-hidden-bookmarks | 1640 (setq bookmark-bmenu-hidden-bookmarks |
1645 (cons bmrk bookmark-bmenu-hidden-bookmarks)) | 1641 (cons bmrk bookmark-bmenu-hidden-bookmarks)) |
1646 (let ((start (save-excursion (end-of-line) (point)))) | 1642 (let ((start (save-excursion (end-of-line) (point)))) |
1669 (goto-char (point-min)) | 1665 (goto-char (point-min)) |
1670 (search-forward "Bookmark") | 1666 (search-forward "Bookmark") |
1671 (backward-word 1) | 1667 (backward-word 1) |
1672 (setq bookmark-bmenu-bookmark-column (current-column))) | 1668 (setq bookmark-bmenu-bookmark-column (current-column))) |
1673 (save-excursion | 1669 (save-excursion |
1674 (let ((buffer-read-only nil)) | 1670 (let ((inhibit-read-only t)) |
1675 (while bookmark-bmenu-hidden-bookmarks | 1671 (while bookmark-bmenu-hidden-bookmarks |
1676 (move-to-column bookmark-bmenu-bookmark-column t) | 1672 (move-to-column bookmark-bmenu-bookmark-column t) |
1677 (bookmark-kill-line) | 1673 (bookmark-kill-line) |
1678 (let ((start (point))) | 1674 (let ((start (point))) |
1679 (insert (car bookmark-bmenu-hidden-bookmarks)) | 1675 (insert (car bookmark-bmenu-hidden-bookmarks)) |
1772 (defun bookmark-bmenu-mark () | 1768 (defun bookmark-bmenu-mark () |
1773 "Mark bookmark on this line to be displayed by \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-select]." | 1769 "Mark bookmark on this line to be displayed by \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-select]." |
1774 (interactive) | 1770 (interactive) |
1775 (beginning-of-line) | 1771 (beginning-of-line) |
1776 (if (bookmark-bmenu-check-position) | 1772 (if (bookmark-bmenu-check-position) |
1777 (let ((buffer-read-only nil)) | 1773 (let ((inhibit-read-only t)) |
1778 (delete-char 1) | 1774 (delete-char 1) |
1779 (insert ?>) | 1775 (insert ?>) |
1780 (forward-line 1) | 1776 (forward-line 1) |
1781 (bookmark-bmenu-check-position)))) | 1777 (bookmark-bmenu-check-position)))) |
1782 | 1778 |
1791 (others ()) | 1787 (others ()) |
1792 tem) | 1788 tem) |
1793 (goto-char (point-min)) | 1789 (goto-char (point-min)) |
1794 (while (re-search-forward "^>" nil t) | 1790 (while (re-search-forward "^>" nil t) |
1795 (setq tem (bookmark-bmenu-bookmark)) | 1791 (setq tem (bookmark-bmenu-bookmark)) |
1796 (let ((buffer-read-only nil)) | 1792 (let ((inhibit-read-only t)) |
1797 (delete-char -1) | 1793 (delete-char -1) |
1798 (insert ?\ )) | 1794 (insert ?\ )) |
1799 (or (string-equal tem bmrk) | 1795 (or (string-equal tem bmrk) |
1800 (member tem others) | 1796 (member tem others) |
1801 (setq others (cons tem others)))) | 1797 (setq others (cons tem others)))) |
1938 Optional BACKUP means move up." | 1934 Optional BACKUP means move up." |
1939 (interactive "P") | 1935 (interactive "P") |
1940 (beginning-of-line) | 1936 (beginning-of-line) |
1941 (if (bookmark-bmenu-check-position) | 1937 (if (bookmark-bmenu-check-position) |
1942 (progn | 1938 (progn |
1943 (let ((buffer-read-only nil)) | 1939 (let ((inhibit-read-only t)) |
1944 (delete-char 1) | 1940 (delete-char 1) |
1945 ;; any flags to reset according to circumstances? How about a | 1941 ;; any flags to reset according to circumstances? How about a |
1946 ;; flag indicating whether this bookmark is being visited? | 1942 ;; flag indicating whether this bookmark is being visited? |
1947 ;; well, we don't have this now, so maybe later. | 1943 ;; well, we don't have this now, so maybe later. |
1948 (insert " ")) | 1944 (insert " ")) |
1965 "Mark bookmark on this line to be deleted. | 1961 "Mark bookmark on this line to be deleted. |
1966 To carry out the deletions that you've marked, use \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-execute-deletions]." | 1962 To carry out the deletions that you've marked, use \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-execute-deletions]." |
1967 (interactive) | 1963 (interactive) |
1968 (beginning-of-line) | 1964 (beginning-of-line) |
1969 (if (bookmark-bmenu-check-position) | 1965 (if (bookmark-bmenu-check-position) |
1970 (let ((buffer-read-only nil)) | 1966 (let ((inhibit-read-only t)) |
1971 (delete-char 1) | 1967 (delete-char 1) |
1972 (insert ?D) | 1968 (insert ?D) |
1973 (forward-line 1) | 1969 (forward-line 1) |
1974 (bookmark-bmenu-check-position)))) | 1970 (bookmark-bmenu-check-position)))) |
1975 | 1971 |
2045 | 2041 |
2046 | 2042 |
2047 | 2043 |
2048 ;;; Menu bar stuff. Prefix is "bookmark-menu". | 2044 ;;; Menu bar stuff. Prefix is "bookmark-menu". |
2049 | 2045 |
2050 (defun bookmark-menu-build-paned-menu (name entries) | |
2051 "Build a multi-paned menu named NAME from the strings in ENTRIES. | |
2052 That is, ENTRIES is a list of strings which appear as the choices | |
2053 in the menu. The number of panes depends on the number of entries. | |
2054 The visible entries are truncated to `bookmark-menu-length', but the | |
2055 strings 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) | 2046 (defun bookmark-menu-popup-paned-menu (event name entries) |
2089 "Pop up multi-paned menu at EVENT, return string chosen from ENTRIES. | 2047 "Pop up multi-paned menu at EVENT, return string chosen from ENTRIES. |
2090 That is, ENTRIES is a list of strings which appear as the choices | 2048 That is, ENTRIES is a list of strings which appear as the choices |
2091 in the menu. | 2049 in the menu. |
2092 The number of panes depends on the number of entries." | 2050 The number of panes depends on the number of entries. |
2093 (interactive "e") | 2051 The visible entries are truncated to `bookmark-menu-length', but the |
2094 (x-popup-menu event (bookmark-menu-build-paned-menu name entries))) | 2052 strings returned are not." |
2095 | 2053 (let ((f-height (/ (frame-height) 2)) |
2096 | 2054 (pane-list nil) |
2097 (defun bookmark-menu-popup-paned-bookmark-menu (event name) | 2055 (iter 0)) |
2098 "Pop up menu of bookmarks, return chosen bookmark. | 2056 (while entries |
2099 Pop up at EVENT, menu's name is NAME. | 2057 (let (lst |
2100 The number of panes depends on the number of bookmarks." | 2058 (count 0)) |
2101 (bookmark-menu-popup-paned-menu event name (bookmark-all-names))) | 2059 (while (and (< count f-height) entries) |
2102 | 2060 (let ((str (car entries))) |
2103 | 2061 (push (cons |
2104 (defun bookmark-popup-menu-and-apply-function (func-sym menu-label event) | 2062 (if (> (length str) bookmark-menu-length) |
2105 ;; help function for making menus that need to apply a bookmark | 2063 (substring str 0 bookmark-menu-length) |
2106 ;; function to a string. | 2064 str) |
2107 (let* ((choice (bookmark-menu-popup-paned-bookmark-menu | 2065 str) |
2108 event menu-label))) | 2066 lst) |
2109 (if choice (apply func-sym (list choice))))) | 2067 (setq entries (cdr entries)) |
2110 | 2068 (setq count (1+ count)))) |
2111 | 2069 (setq iter (1+ iter)) |
2112 ;;;###autoload | 2070 (push (cons |
2113 (defun bookmark-menu-insert (event) | 2071 (format "-*- %s (%d) -*-" name iter) |
2114 "Insert the text of the file pointed to by bookmark BOOKMARK. | 2072 (nreverse lst)) |
2115 You may have a problem using this function if the value of variable | 2073 pane-list))) |
2116 `bookmark-alist' is nil. If that happens, you need to load in some | 2074 |
2117 bookmarks. See help on function `bookmark-load' for more about | 2075 ;; Popup the menu and return the string. |
2118 this. | 2076 (x-popup-menu event (cons (concat "-*- " name " -*-") |
2119 | 2077 (nreverse pane-list))))) |
2120 Warning: this function only takes an EVENT as argument. Use the | |
2121 corresponding 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). | |
2131 You 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 | |
2133 bookmarks. See help on function `bookmark-load' for more about | |
2134 this. | |
2135 | |
2136 Warning: this function only takes an EVENT as argument. Use the | |
2137 corresponding 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 | |
2149 Warning: this function only takes an EVENT as argument. Use the | |
2150 corresponding 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. | |
2160 If called from keyboard, prompts for OLD-BOOKMARK and NEWNAME. | |
2161 If called from menubar, OLD-BOOKMARK is selected from a menu, and | |
2162 prompts for NEWNAME. | |
2163 If called from Lisp, prompts for NEWNAME if only OLD-BOOKMARK was | |
2164 passed as an argument. If called with two strings, then no prompting | |
2165 is done. You must pass at least OLD-BOOKMARK when calling from Lisp. | |
2166 | |
2167 While you are entering the new name, consecutive C-w's insert | |
2168 consecutive words from the text of the buffer into the new bookmark | |
2169 name. | |
2170 | |
2171 Warning: this function only takes an EVENT as argument. Use the | |
2172 corresponding 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. | |
2182 Removes only the first instance of a bookmark with that name. If | |
2183 there are one or more other bookmarks with the same name, they will | |
2184 not be deleted. Defaults to the \"current\" bookmark \(that is, the | |
2185 one most recently used in this file, if any\). | |
2186 | |
2187 Warning: this function only takes an EVENT as argument. Use the | |
2188 corresponding 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 | 2078 |
2194 | 2079 |
2195 ;; Thanks to Roland McGrath for fixing menubar.el so that the | 2080 ;; Thanks to Roland McGrath for fixing menubar.el so that the |
2196 ;; following works, and for explaining what to do to make it work. | 2081 ;; following works, and for explaining what to do to make it work. |
2197 | 2082 |
2199 ;; that the whole job is done in loaddefs.el. | 2084 ;; that the whole job is done in loaddefs.el. |
2200 | 2085 |
2201 ;; Emacs menubar stuff. | 2086 ;; Emacs menubar stuff. |
2202 | 2087 |
2203 ;;;###autoload | 2088 ;;;###autoload |
2204 (defvar menu-bar-bookmark-map (make-sparse-keymap "Bookmark functions")) | 2089 (defvar menu-bar-bookmark-map |
2090 (let ((map (make-sparse-keymap "Bookmark functions"))) | |
2091 (define-key map [load] '("Load a Bookmark File..." . bookmark-load)) | |
2092 (define-key map [write] '("Save Bookmarks As..." . bookmark-write)) | |
2093 (define-key map [save] '("Save Bookmarks" . bookmark-save)) | |
2094 (define-key map [edit] '("Edit Bookmark List" . bookmark-bmenu-list)) | |
2095 (define-key map [delete] '("Delete Bookmark" . bookmark-delete)) | |
2096 (define-key map [rename] '("Rename Bookmark" . bookmark-rename)) | |
2097 (define-key map [locate] '("Insert Location" . bookmark-locate)) | |
2098 (define-key map [insert] '("Insert Contents" . bookmark-insert)) | |
2099 (define-key map [set] '("Set Bookmark" . bookmark-set)) | |
2100 (define-key map [jump] '("Jump to Bookmark" . bookmark-jump)) | |
2101 map)) | |
2205 | 2102 |
2206 ;;;###autoload | 2103 ;;;###autoload |
2207 (defalias 'menu-bar-bookmark-map (symbol-value 'menu-bar-bookmark-map)) | 2104 (defalias 'menu-bar-bookmark-map menu-bar-bookmark-map) |
2208 | 2105 |
2209 ;; make bookmarks appear toward the right side of the menu. | 2106 ;; make bookmarks appear toward the right side of the menu. |
2210 (if (boundp 'menu-bar-final-items) | 2107 (if (boundp 'menu-bar-final-items) |
2211 (if menu-bar-final-items | 2108 (if menu-bar-final-items |
2212 (setq menu-bar-final-items | 2109 (setq menu-bar-final-items |
2213 (cons 'bookmark menu-bar-final-items))) | 2110 (cons 'bookmark menu-bar-final-items))) |
2214 (setq menu-bar-final-items '(bookmark))) | 2111 (setq menu-bar-final-items '(bookmark))) |
2215 | 2112 |
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 ;;;; | 2113 ;;;; end bookmark menu stuff ;;;; |
2247 | 2114 |
2248 | 2115 |
2249 ;;; Load Hook | 2116 ;;; Load Hook |
2250 (defvar bookmark-load-hook nil | 2117 (defvar bookmark-load-hook nil |
2251 "Hook to run at the end of loading bookmark.") | 2118 "Hook run at the end of loading bookmark.") |
2252 | 2119 |
2253 ;;; Exit Hook, called from kill-emacs-hook | 2120 ;;; Exit Hook, called from kill-emacs-hook |
2254 (defvar bookmark-exit-hook nil | 2121 (defvar bookmark-exit-hook nil |
2255 "Hook to run when emacs exits") | 2122 "Hook run when emacs exits.") |
2256 | 2123 |
2257 (defun bookmark-exit-hook-internal () | 2124 (defun bookmark-exit-hook-internal () |
2258 "Save bookmark state, if necessary, at Emacs exit time. | 2125 "Save bookmark state, if necessary, at Emacs exit time. |
2259 This also runs `bookmark-exit-hooks'." | 2126 This also runs `bookmark-exit-hooks'." |
2260 (and | 2127 (run-hooks 'bookmark-exit-hooks) |
2261 (progn (run-hooks 'bookmark-exit-hooks) t) | 2128 (and bookmark-alist |
2262 bookmark-alist | 2129 (bookmark-time-to-save-p t) |
2263 (bookmark-time-to-save-p t) | 2130 (bookmark-save))) |
2264 (bookmark-save))) | |
2265 | 2131 |
2266 (add-hook 'kill-emacs-hook 'bookmark-exit-hook-internal) | 2132 (add-hook 'kill-emacs-hook 'bookmark-exit-hook-internal) |
2267 | 2133 |
2268 | 2134 |
2269 (run-hooks 'bookmark-load-hook) | 2135 (run-hooks 'bookmark-load-hook) |
2270 | 2136 |
2271 (provide 'bookmark) | 2137 (provide 'bookmark) |
2272 | 2138 |
2139 ;;; arch-tag: 139f519a-dd0c-4b8d-8b5d-f9fcf53ca8f6 | |
2273 ;;; bookmark.el ends here | 2140 ;;; bookmark.el ends here |