Mercurial > emacs
comparison lisp/bookmark.el @ 17265:ddbe17ae5280
Added mouse-selection feature for bookmark list buffer.
(bookmark-bmenu-other-window-with-mouse): New function.
(bookmark-bmenu-mode-map): Bind mouse-2.
(bookmark-bmenu-list, bookmark-insert-location,
bookmark-bmenu-hide-filenames): Put text property on bookmarks.
(bookmark-bmenu-show-filenames): Remove text property from
white spaces generated by `move-to-column'.
(bookmark-bmenu-bookmark): Use `buffer-substring-no-properties'
instead of `buffer-substring'.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 30 Mar 1997 21:38:43 +0000 |
parents | d436e2536685 |
children | f0ff96a35eb8 |
comparison
equal
deleted
inserted
replaced
17264:fad065a280dc | 17265:ddbe17ae5280 |
---|---|
1158 "Insert the name of the file associated with BOOKMARK. | 1158 "Insert the name of the file associated with BOOKMARK. |
1159 Optional second arg NO-HISTORY means don't record this in the | 1159 Optional second arg NO-HISTORY means don't record this in the |
1160 minibuffer history list `bookmark-history'." | 1160 minibuffer history list `bookmark-history'." |
1161 (interactive (bookmark-completing-read "Insert bookmark location")) | 1161 (interactive (bookmark-completing-read "Insert bookmark location")) |
1162 (or no-history (bookmark-maybe-historicize-string bookmark)) | 1162 (or no-history (bookmark-maybe-historicize-string bookmark)) |
1163 (insert (bookmark-location bookmark))) | 1163 (let ((start (point))) |
1164 (prog1 | |
1165 (insert (bookmark-location bookmark)) ; *Return this line* | |
1166 (if window-system | |
1167 (put-text-property start | |
1168 (save-excursion (re-search-backward | |
1169 "[^ \t]") | |
1170 (1+ (point))) | |
1171 'mouse-face 'highlight))))) | |
1164 | 1172 |
1165 ;;;###autoload | 1173 ;;;###autoload |
1166 (defalias 'bookmark-locate 'bookmark-insert-location) | 1174 (defalias 'bookmark-locate 'bookmark-insert-location) |
1167 | 1175 |
1168 (defun bookmark-location (bookmark) | 1176 (defun bookmark-location (bookmark) |
1442 (define-key bookmark-bmenu-mode-map "l" 'bookmark-bmenu-load) | 1450 (define-key bookmark-bmenu-mode-map "l" 'bookmark-bmenu-load) |
1443 (define-key bookmark-bmenu-mode-map "r" 'bookmark-bmenu-rename) | 1451 (define-key bookmark-bmenu-mode-map "r" 'bookmark-bmenu-rename) |
1444 (define-key bookmark-bmenu-mode-map "t" 'bookmark-bmenu-toggle-filenames) | 1452 (define-key bookmark-bmenu-mode-map "t" 'bookmark-bmenu-toggle-filenames) |
1445 (define-key bookmark-bmenu-mode-map "a" 'bookmark-bmenu-show-annotation) | 1453 (define-key bookmark-bmenu-mode-map "a" 'bookmark-bmenu-show-annotation) |
1446 (define-key bookmark-bmenu-mode-map "A" 'bookmark-bmenu-show-all-annotations) | 1454 (define-key bookmark-bmenu-mode-map "A" 'bookmark-bmenu-show-all-annotations) |
1447 (define-key bookmark-bmenu-mode-map "e" 'bookmark-bmenu-edit-annotation)) | 1455 (define-key bookmark-bmenu-mode-map "e" 'bookmark-bmenu-edit-annotation) |
1456 (define-key bookmark-bmenu-mode-map [mouse-2] | |
1457 'bookmark-bmenu-other-window-with-mouse)) | |
1448 | 1458 |
1449 | 1459 |
1450 | 1460 |
1451 ;; Bookmark Buffer Menu mode is suitable only for specially formatted | 1461 ;; Bookmark Buffer Menu mode is suitable only for specially formatted |
1452 ;; data. | 1462 ;; data. |
1493 (bookmark-name-from-full-record full-record)))) | 1503 (bookmark-name-from-full-record full-record)))) |
1494 (if (and (not (eq annotation nil)) | 1504 (if (and (not (eq annotation nil)) |
1495 (not (string-equal annotation ""))) | 1505 (not (string-equal annotation ""))) |
1496 (insert " *") | 1506 (insert " *") |
1497 (insert " ")) | 1507 (insert " ")) |
1498 (insert (concat (bookmark-name-from-full-record full-record) "\n")))) | 1508 (let ((start (point))) |
1509 (insert (bookmark-name-from-full-record full-record)) | |
1510 (if window-system | |
1511 (put-text-property start | |
1512 (save-excursion (re-search-backward | |
1513 "[^ \t]") | |
1514 (1+ (point))) | |
1515 'mouse-face 'highlight)) | |
1516 (insert "\n") | |
1517 ))) | |
1499 bookmark-alist)) | 1518 bookmark-alist)) |
1500 (goto-char (point-min)) | 1519 (goto-char (point-min)) |
1501 (forward-line 2) | 1520 (forward-line 2) |
1502 (bookmark-bmenu-mode) | 1521 (bookmark-bmenu-mode) |
1503 (if bookmark-bmenu-toggle-filenames | 1522 (if bookmark-bmenu-toggle-filenames |
1579 (let ((buffer-read-only nil)) | 1598 (let ((buffer-read-only nil)) |
1580 (while (< (point) (point-max)) | 1599 (while (< (point) (point-max)) |
1581 (let ((bmrk (bookmark-bmenu-bookmark))) | 1600 (let ((bmrk (bookmark-bmenu-bookmark))) |
1582 (setq bookmark-bmenu-hidden-bookmarks | 1601 (setq bookmark-bmenu-hidden-bookmarks |
1583 (cons bmrk bookmark-bmenu-hidden-bookmarks)) | 1602 (cons bmrk bookmark-bmenu-hidden-bookmarks)) |
1584 (move-to-column bookmark-bmenu-file-column t) | 1603 (let ((start (save-excursion (end-of-line) (point)))) |
1585 (delete-region (point) (progn (end-of-line) (point))) | 1604 (move-to-column bookmark-bmenu-file-column t) |
1605 ;; Strip off `mouse-face' from the white spaces region. | |
1606 (if window-system | |
1607 (remove-text-properties start (point) | |
1608 '(mouse-face)))) | |
1609 (delete-region (point) (progn (end-of-line) (point))) | |
1586 (insert " ") | 1610 (insert " ") |
1587 ;; Pass the NO-HISTORY arg: | 1611 ;; Pass the NO-HISTORY arg: |
1588 (bookmark-insert-location bmrk t) | 1612 (bookmark-insert-location bmrk t) |
1589 (forward-line 1)))))))) | 1613 (forward-line 1)))))))) |
1590 | 1614 |
1606 (save-excursion | 1630 (save-excursion |
1607 (let ((buffer-read-only nil)) | 1631 (let ((buffer-read-only nil)) |
1608 (while bookmark-bmenu-hidden-bookmarks | 1632 (while bookmark-bmenu-hidden-bookmarks |
1609 (move-to-column bookmark-bmenu-bookmark-column t) | 1633 (move-to-column bookmark-bmenu-bookmark-column t) |
1610 (bookmark-kill-line) | 1634 (bookmark-kill-line) |
1611 (insert (car bookmark-bmenu-hidden-bookmarks)) | 1635 (let ((start (point))) |
1636 (insert (car bookmark-bmenu-hidden-bookmarks)) | |
1637 (if window-system | |
1638 (put-text-property start | |
1639 (save-excursion (re-search-backward | |
1640 "[^ \t]") | |
1641 (1+ (point))) | |
1642 'mouse-face 'highlight))) | |
1612 (setq bookmark-bmenu-hidden-bookmarks | 1643 (setq bookmark-bmenu-hidden-bookmarks |
1613 (cdr bookmark-bmenu-hidden-bookmarks)) | 1644 (cdr bookmark-bmenu-hidden-bookmarks)) |
1614 (forward-line 1)))))))) | 1645 (forward-line 1)))))))) |
1615 | 1646 |
1616 | 1647 |
1646 (save-excursion | 1677 (save-excursion |
1647 (save-window-excursion | 1678 (save-window-excursion |
1648 (beginning-of-line) | 1679 (beginning-of-line) |
1649 (forward-char bookmark-bmenu-bookmark-column) | 1680 (forward-char bookmark-bmenu-bookmark-column) |
1650 (prog1 | 1681 (prog1 |
1651 (buffer-substring (point) | 1682 (buffer-substring-no-properties (point) |
1652 (progn | 1683 (progn |
1653 (end-of-line) | 1684 (end-of-line) |
1654 (point))) | 1685 (point))) |
1655 ;; well, this is certainly crystal-clear: | 1686 ;; well, this is certainly crystal-clear: |
1656 (if bookmark-bmenu-toggle-filenames | 1687 (if bookmark-bmenu-toggle-filenames |
1823 (set-buffer buff) | 1854 (set-buffer buff) |
1824 (goto-char pos) | 1855 (goto-char pos) |
1825 (set-window-point (get-buffer-window buff) pos) | 1856 (set-window-point (get-buffer-window buff) pos) |
1826 (set-buffer o-buffer)) | 1857 (set-buffer o-buffer)) |
1827 (bookmark-show-annotation bookmark))))) | 1858 (bookmark-show-annotation bookmark))))) |
1859 | |
1860 (defun bookmark-bmenu-other-window-with-mouse (event) | |
1861 "Select bookmark at the mouse pointer in other window, leaving bookmark menu visible." | |
1862 (interactive "e") | |
1863 (save-excursion | |
1864 (set-buffer (window-buffer (posn-window (event-end event)))) | |
1865 (save-excursion | |
1866 (goto-char (posn-point (event-end event))) | |
1867 (bookmark-bmenu-other-window)))) | |
1828 | 1868 |
1829 | 1869 |
1830 (defun bookmark-bmenu-show-annotation () | 1870 (defun bookmark-bmenu-show-annotation () |
1831 "Show the annotation for the current bookmark in another window." | 1871 "Show the annotation for the current bookmark in another window." |
1832 (interactive) | 1872 (interactive) |