Mercurial > hg > xemacs-beta
comparison lisp/packages/bookmark.el @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | ec9a17fef872 |
children | 360340f9fd5f |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
1147 If called from Lisp, prompts for NEW if only OLD was passed as an | 1147 If called from Lisp, prompts for NEW if only OLD was passed as an |
1148 argument. If called with two strings, then no prompting is done. You | 1148 argument. If called with two strings, then no prompting is done. You |
1149 must pass at least OLD when calling from Lisp. | 1149 must pass at least OLD when calling from Lisp. |
1150 | 1150 |
1151 While you are entering the new name, consecutive C-w's insert | 1151 While you are entering the new name, consecutive C-w's insert |
1152 consecutive words from the text of the buffer into the new bookmark | 1152 consectutive words from the text of the buffer into the new bookmark |
1153 name." | 1153 name." |
1154 (interactive (bookmark-completing-read "Old bookmark name")) | 1154 (interactive (bookmark-completing-read "Old bookmark name")) |
1155 (bookmark-maybe-historicize-string old) | 1155 (bookmark-maybe-historicize-string old) |
1156 (bookmark-maybe-load-default-file) | 1156 (bookmark-maybe-load-default-file) |
1157 (progn | 1157 (progn |
1294 | 1294 |
1295 (defun bookmark-write-file (file) | 1295 (defun bookmark-write-file (file) |
1296 (save-excursion | 1296 (save-excursion |
1297 (save-window-excursion | 1297 (save-window-excursion |
1298 (if (>= (device-baud-rate) 9600) | 1298 (if (>= (device-baud-rate) 9600) |
1299 (message (format "Saving bookmarks to file %s..." file))) | 1299 (message "Saving bookmarks to file %s..." file)) |
1300 (set-buffer (let ((enable-local-variables nil)) | 1300 (set-buffer (let ((enable-local-variables nil)) |
1301 (find-file-noselect file))) | 1301 (find-file-noselect file))) |
1302 (goto-char (point-min)) | 1302 (goto-char (point-min)) |
1303 (delete-region (point-min) (point-max)) | 1303 (delete-region (point-min) (point-max)) |
1304 (bookmark-insert-file-format-version-stamp) | 1304 (bookmark-insert-file-format-version-stamp) |
1311 (t | 1311 (t |
1312 t)))) | 1312 t)))) |
1313 (write-file file) | 1313 (write-file file) |
1314 (kill-buffer (current-buffer)) | 1314 (kill-buffer (current-buffer)) |
1315 (if (>= (device-baud-rate) 9600) | 1315 (if (>= (device-baud-rate) 9600) |
1316 (message (format "Saving bookmarks to file %s... done." file))) | 1316 (message "Saving bookmarks to file %s... done." file)) |
1317 )))) | 1317 )))) |
1318 | 1318 |
1319 | 1319 |
1320 ;;;###autoload | 1320 ;;;###autoload |
1321 (defun bookmark-load (file &optional revert no-msg) | 1321 (defun bookmark-load (file &optional revert no-msg) |
1342 (setq file (expand-file-name file)) | 1342 (setq file (expand-file-name file)) |
1343 (if (file-readable-p file) | 1343 (if (file-readable-p file) |
1344 (save-excursion | 1344 (save-excursion |
1345 (save-window-excursion | 1345 (save-window-excursion |
1346 (if (and (null no-msg) (>= (device-baud-rate) 9600)) | 1346 (if (and (null no-msg) (>= (device-baud-rate) 9600)) |
1347 (message (format "Loading bookmarks from %s..." file))) | 1347 (message "Loading bookmarks from %s..." file)) |
1348 (set-buffer (let ((enable-local-variables nil)) | 1348 (set-buffer (let ((enable-local-variables nil)) |
1349 (find-file-noselect file))) | 1349 (find-file-noselect file))) |
1350 (goto-char (point-min)) | 1350 (goto-char (point-min)) |
1351 (bookmark-maybe-upgrade-file-format) | 1351 (bookmark-maybe-upgrade-file-format) |
1352 (let ((blist (bookmark-alist-from-buffer))) | 1352 (let ((blist (bookmark-alist-from-buffer))) |
1357 (1+ bookmark-alist-modification-count)) | 1357 (1+ bookmark-alist-modification-count)) |
1358 (setq bookmark-alist-modification-count 0)) | 1358 (setq bookmark-alist-modification-count 0)) |
1359 (setq bookmark-alist | 1359 (setq bookmark-alist |
1360 (append blist (if (not revert) bookmark-alist))) | 1360 (append blist (if (not revert) bookmark-alist))) |
1361 (bookmark-bmenu-surreptitiously-rebuild-list)) | 1361 (bookmark-bmenu-surreptitiously-rebuild-list)) |
1362 (error (format "Invalid bookmark list in %s." file)))) | 1362 (error "Invalid bookmark list in %s." file))) |
1363 (kill-buffer (current-buffer))) | 1363 (kill-buffer (current-buffer))) |
1364 (if (and (null no-msg) (>= (device-baud-rate) 9600)) | 1364 (if (and (null no-msg) (>= (device-baud-rate) 9600)) |
1365 (message (format "Loading bookmarks from %s... done" file)))) | 1365 (message "Loading bookmarks from %s... done" file))) |
1366 (error (format "Cannot read bookmark file %s." file)))) | 1366 (error "Cannot read bookmark file %s." file))) |
1367 | 1367 |
1368 | 1368 |
1369 | 1369 |
1370 ;;; Code supporting the dired-like bookmark menu. Prefix is | 1370 ;;; Code supporting the dired-like bookmark menu. Prefix is |
1371 ;;; "bookmark-bmenu" for "buffer-menu": | 1371 ;;; "bookmark-bmenu" for "buffer-menu": |
1452 (goto-char (point-min)) ;sure are playing it safe... | 1452 (goto-char (point-min)) ;sure are playing it safe... |
1453 (insert "% Bookmark\n- --------\n") | 1453 (insert "% Bookmark\n- --------\n") |
1454 (bookmark-maybe-sort-alist) | 1454 (bookmark-maybe-sort-alist) |
1455 (mapcar | 1455 (mapcar |
1456 (lambda (full-record) | 1456 (lambda (full-record) |
1457 ;; if a bookmark has an annotation, precede it with a "*" | 1457 ;; if a bookmark has an annotation, preceed it with a "*" |
1458 ;; in the list of bookmarks. | 1458 ;; in the list of bookmarks. |
1459 (let ((annotation (bookmark-get-annotation | 1459 (let ((annotation (bookmark-get-annotation |
1460 (bookmark-name-from-full-record full-record)))) | 1460 (bookmark-name-from-full-record full-record)))) |
1461 (if (and (not (eq annotation nil)) | 1461 (if (and (not (eq annotation nil)) |
1462 (not (string-equal annotation ""))) | 1462 (not (string-equal annotation ""))) |
1479 | 1479 |
1480 (defun bookmark-bmenu-mode () | 1480 (defun bookmark-bmenu-mode () |
1481 "Major mode for editing a list of bookmarks. | 1481 "Major mode for editing a list of bookmarks. |
1482 Each line describes one of the bookmarks in Emacs. | 1482 Each line describes one of the bookmarks in Emacs. |
1483 Letters do not insert themselves; instead, they are commands. | 1483 Letters do not insert themselves; instead, they are commands. |
1484 Bookmark names preceded by a \"*\" have annotations. | 1484 Bookmark names preceeded by a \"*\" have annotations. |
1485 \\<bookmark-bmenu-mode-map> | 1485 \\<bookmark-bmenu-mode-map> |
1486 \\[bookmark-bmenu-mark] -- mark bookmark to be displayed. | 1486 \\[bookmark-bmenu-mark] -- mark bookmark to be displayed. |
1487 \\[bookmark-bmenu-select] -- select bookmark of line point is on. | 1487 \\[bookmark-bmenu-select] -- select bookmark of line point is on. |
1488 Also show bookmarks marked using m in other windows. | 1488 Also show bookmarks marked using m in other windows. |
1489 \\[bookmark-bmenu-toggle-filenames] -- toggle displaying of filenames (they may obscure long bookmark names). | 1489 \\[bookmark-bmenu-toggle-filenames] -- toggle displaying of filenames (they may obscure long bookmark names). |
2076 If called from Lisp, prompts for NEWNAME if only OLD-BOOKMARK was | 2076 If called from Lisp, prompts for NEWNAME if only OLD-BOOKMARK was |
2077 passed as an argument. If called with two strings, then no prompting | 2077 passed as an argument. If called with two strings, then no prompting |
2078 is done. You must pass at least OLD-BOOKMARK when calling from Lisp. | 2078 is done. You must pass at least OLD-BOOKMARK when calling from Lisp. |
2079 | 2079 |
2080 While you are entering the new name, consecutive C-w's insert | 2080 While you are entering the new name, consecutive C-w's insert |
2081 consecutive words from the text of the buffer into the new bookmark | 2081 consectutive words from the text of the buffer into the new bookmark |
2082 name. | 2082 name. |
2083 | 2083 |
2084 Warning: this function only takes an EVENT as argument. Use the | 2084 Warning: this function only takes an EVENT as argument. Use the |
2085 corresponding bookmark function from Lisp \(the one without the | 2085 corresponding bookmark function from Lisp \(the one without the |
2086 \"-menu-\" in its name\)." | 2086 \"-menu-\" in its name\)." |