aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2009-11-21 06:43:45 +0000
committerStefan Monnier2009-11-21 06:43:45 +0000
commitfc9d6ad645ab0332811bcd7b79341f68ddd958e8 (patch)
tree40fe9469fc2d65a93b041d8f45806af5c76c5f07
parenteb7fdcd95056e9727c50dbe6f3ee16d73e2f598c (diff)
downloademacs-fc9d6ad645ab0332811bcd7b79341f68ddd958e8.tar.gz
emacs-fc9d6ad645ab0332811bcd7b79341f68ddd958e8.zip
(bookmark-bmenu-bookmark-column): Remove var.
(bookmark-bmenu-list): Save name on `bookmark-name-prop' text-prop. (bookmark-bmenu-show-filenames): Use push. (bookmark-bmenu-hide-filenames): Use local var instead of bookmark-bmenu-bookmark-column. Use pop. Don't save window-excursion. (bookmark-bmenu-bookmark): Use the new `bookmark-name-prop' text-prop. (bookmark-bmenu-execute-deletions): Don't bother adding/removing the filenames now that the bookmark names are always available.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/bookmark.el144
2 files changed, 66 insertions, 90 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 74be1167bd9..ad78b4e986c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12009-11-21 Thierry Volpiatto <thierry.volpiatto@gmail.com>
2 Stefan Monnier <monnier@iro.umontreal.ca>
3
4 * bookmark.el (bookmark-bmenu-bookmark-column): Remove var.
5 (bookmark-bmenu-list): Save name on `bookmark-name-prop' text-prop.
6 (bookmark-bmenu-show-filenames): Use push.
7 (bookmark-bmenu-hide-filenames): Use local var instead of
8 bookmark-bmenu-bookmark-column. Use pop. Don't save window-excursion.
9 (bookmark-bmenu-bookmark): Use the new `bookmark-name-prop' text-prop.
10 (bookmark-bmenu-execute-deletions): Don't bother adding/removing the
11 filenames now that the bookmark names are always available.
12
12009-11-21 Stefan Monnier <monnier@iro.umontreal.ca> 132009-11-21 Stefan Monnier <monnier@iro.umontreal.ca>
2 14
3 * bookmark.el (bookmark-search-prompt, bookmark-search-timer): Remove. 15 * bookmark.el (bookmark-search-prompt, bookmark-search-timer): Remove.
diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 017eed8128a..77b51a14f67 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -1493,9 +1493,6 @@ method buffers use to resolve name collisions."
1493;; Prefix is "bookmark-bmenu" for "buffer-menu": 1493;; Prefix is "bookmark-bmenu" for "buffer-menu":
1494 1494
1495 1495
1496(defvar bookmark-bmenu-bookmark-column nil)
1497
1498
1499(defvar bookmark-bmenu-hidden-bookmarks ()) 1496(defvar bookmark-bmenu-hidden-bookmarks ())
1500 1497
1501 1498
@@ -1579,29 +1576,29 @@ deletion, or > if it is flagged for displaying."
1579 (add-text-properties (point-min) (point) 1576 (add-text-properties (point-min) (point)
1580 '(font-lock-face bookmark-menu-heading)) 1577 '(font-lock-face bookmark-menu-heading))
1581 (dolist (full-record (bookmark-maybe-sort-alist)) 1578 (dolist (full-record (bookmark-maybe-sort-alist))
1582 ;; if a bookmark has an annotation, prepend a "*" 1579 (let ((name (bookmark-name-from-full-record full-record))
1583 ;; in the list of bookmarks. 1580 (annotation (bookmark-get-annotation full-record))
1584 (let ((annotation (bookmark-get-annotation full-record))) 1581 (start (point))
1582 end)
1583 ;; if a bookmark has an annotation, prepend a "*"
1584 ;; in the list of bookmarks.
1585 (insert (if (and annotation (not (string-equal annotation ""))) 1585 (insert (if (and annotation (not (string-equal annotation "")))
1586 " *" " ")) 1586 " *" " ")
1587 (let ((start (point))) 1587 name)
1588 (insert (bookmark-name-from-full-record full-record)) 1588 (setq end (point))
1589 (if (display-mouse-p) 1589 (put-text-property start (+ 2 start) 'bookmark-name-prop name)
1590 (add-text-properties 1590 (when (display-mouse-p)
1591 start 1591 (add-text-properties
1592 (save-excursion (re-search-backward 1592 (+ 2 start) end
1593 "[^ \t]") 1593 '(mouse-face highlight
1594 (1+ (point))) 1594 follow-link t
1595 '(mouse-face highlight 1595 help-echo "mouse-2: go to this bookmark in other window")))
1596 follow-link t 1596 (insert "\n")))
1597 help-echo "mouse-2: go to this bookmark in other window"))) 1597 (goto-char (point-min))
1598 (insert "\n"))))) 1598 (forward-line 2)
1599 1599 (bookmark-bmenu-mode)
1600 (goto-char (point-min)) 1600 (if bookmark-bmenu-toggle-filenames
1601 (forward-line 2) 1601 (bookmark-bmenu-toggle-filenames t))))
1602 (bookmark-bmenu-mode)
1603 (if bookmark-bmenu-toggle-filenames
1604 (bookmark-bmenu-toggle-filenames t)))
1605 1602
1606;;;###autoload 1603;;;###autoload
1607(defalias 'list-bookmarks 'bookmark-bmenu-list) 1604(defalias 'list-bookmarks 'bookmark-bmenu-list)
@@ -1683,8 +1680,7 @@ mainly for debugging, and should not be necessary in normal use."
1683 (let ((inhibit-read-only t)) 1680 (let ((inhibit-read-only t))
1684 (while (< (point) (point-max)) 1681 (while (< (point) (point-max))
1685 (let ((bmrk (bookmark-bmenu-bookmark))) 1682 (let ((bmrk (bookmark-bmenu-bookmark)))
1686 (setq bookmark-bmenu-hidden-bookmarks 1683 (push bmrk bookmark-bmenu-hidden-bookmarks)
1687 (cons bmrk bookmark-bmenu-hidden-bookmarks))
1688 (let ((start (save-excursion (end-of-line) (point)))) 1684 (let ((start (save-excursion (end-of-line) (point))))
1689 (move-to-column bookmark-bmenu-file-column t) 1685 (move-to-column bookmark-bmenu-file-column t)
1690 ;; Strip off `mouse-face' from the white spaces region. 1686 ;; Strip off `mouse-face' from the white spaces region.
@@ -1702,39 +1698,33 @@ mainly for debugging, and should not be necessary in normal use."
1702 "In an interactive bookmark list, hide the filenames of the bookmarks. 1698 "In an interactive bookmark list, hide the filenames of the bookmarks.
1703Non-nil FORCE forces a redisplay showing the filenames. FORCE is used 1699Non-nil FORCE forces a redisplay showing the filenames. FORCE is used
1704mainly for debugging, and should not be necessary in normal use." 1700mainly for debugging, and should not be necessary in normal use."
1705 (if (and (not force) bookmark-bmenu-toggle-filenames) 1701 (when (and (not force) bookmark-bmenu-toggle-filenames)
1706 ;; nothing to hide if above is nil 1702 ;; nothing to hide if above is nil
1707 (save-excursion 1703 (save-excursion
1708 (save-window-excursion 1704 (goto-char (point-min))
1709 (goto-char (point-min)) 1705 (forward-line 2)
1710 (forward-line 2) 1706 (setq bookmark-bmenu-hidden-bookmarks
1711 (setq bookmark-bmenu-hidden-bookmarks 1707 (nreverse bookmark-bmenu-hidden-bookmarks))
1712 (nreverse bookmark-bmenu-hidden-bookmarks)) 1708 (let ((inhibit-read-only t)
1713 (save-excursion 1709 (column (save-excursion
1714 (goto-char (point-min)) 1710 (goto-char (point-min))
1715 (search-forward "Bookmark") 1711 (search-forward "Bookmark")
1716 (backward-word 1) 1712 (backward-word 1)
1717 (setq bookmark-bmenu-bookmark-column (current-column))) 1713 (setq bookmark-bmenu-bookmark-column (current-column)))))
1718 (save-excursion 1714 (while bookmark-bmenu-hidden-bookmarks
1719 (let ((inhibit-read-only t)) 1715 (move-to-column column t)
1720 (while bookmark-bmenu-hidden-bookmarks 1716 (bookmark-kill-line)
1721 (move-to-column bookmark-bmenu-bookmark-column t) 1717 (let ((name (pop bookmark-bmenu-hidden-bookmarks))
1722 (bookmark-kill-line) 1718 (start (point)))
1723 (let ((start (point))) 1719 (insert name)
1724 (insert (car bookmark-bmenu-hidden-bookmarks)) 1720 (if (display-mouse-p)
1725 (if (display-mouse-p) 1721 (add-text-properties
1726 (add-text-properties 1722 start (point)
1727 start 1723 '(mouse-face highlight
1728 (save-excursion (re-search-backward 1724 follow-link t
1729 "[^ \t]") 1725 help-echo
1730 (1+ (point))) 1726 "mouse-2: go to this bookmark in other window"))))
1731 '(mouse-face highlight 1727 (forward-line 1))))))
1732 follow-link t
1733 help-echo
1734 "mouse-2: go to this bookmark in other window"))))
1735 (setq bookmark-bmenu-hidden-bookmarks
1736 (cdr bookmark-bmenu-hidden-bookmarks))
1737 (forward-line 1))))))))
1738 1728
1739 1729
1740(defun bookmark-bmenu-check-position () 1730(defun bookmark-bmenu-check-position ()
@@ -1761,27 +1751,8 @@ Return `bookmark-alist'"
1761 1751
1762(defun bookmark-bmenu-bookmark () 1752(defun bookmark-bmenu-bookmark ()
1763 "Return the bookmark for this line in an interactive bookmark list buffer." 1753 "Return the bookmark for this line in an interactive bookmark list buffer."
1764 (if (bookmark-bmenu-check-position) 1754 (when (bookmark-bmenu-check-position)
1765 (save-excursion 1755 (get-text-property (line-beginning-position) 'bookmark-name-prop)))
1766 (save-window-excursion
1767 (goto-char (point-min))
1768 (search-forward "Bookmark")
1769 (backward-word 1)
1770 (setq bookmark-bmenu-bookmark-column (current-column)))))
1771 (if bookmark-bmenu-toggle-filenames
1772 (bookmark-bmenu-hide-filenames))
1773 (save-excursion
1774 (save-window-excursion
1775 (beginning-of-line)
1776 (forward-char bookmark-bmenu-bookmark-column)
1777 (prog1
1778 (buffer-substring-no-properties (point)
1779 (progn
1780 (end-of-line)
1781 (point)))
1782 ;; well, this is certainly crystal-clear:
1783 (if bookmark-bmenu-toggle-filenames
1784 (bookmark-bmenu-toggle-filenames t))))))
1785 1756
1786 1757
1787(defun bookmark-show-annotation (bookmark) 1758(defun bookmark-show-annotation (bookmark)
@@ -2023,26 +1994,19 @@ To carry out the deletions that you've marked, use \\<bookmark-bmenu-mode-map>\\
2023 "Delete bookmarks marked with \\<Buffer-menu-mode-map>\\[Buffer-menu-delete] commands." 1994 "Delete bookmarks marked with \\<Buffer-menu-mode-map>\\[Buffer-menu-delete] commands."
2024 (interactive) 1995 (interactive)
2025 (message "Deleting bookmarks...") 1996 (message "Deleting bookmarks...")
2026 (let ((hide-em bookmark-bmenu-toggle-filenames) 1997 (let ((o-point (point))
2027 (o-point (point))
2028 (o-str (save-excursion 1998 (o-str (save-excursion
2029 (beginning-of-line) 1999 (beginning-of-line)
2030 (if (looking-at "^D") 2000 (unless (looking-at "^D")
2031 nil
2032 (buffer-substring 2001 (buffer-substring
2033 (point) 2002 (point)
2034 (progn (end-of-line) (point)))))) 2003 (progn (end-of-line) (point))))))
2035 (o-col (current-column))) 2004 (o-col (current-column)))
2036 (if hide-em (bookmark-bmenu-hide-filenames))
2037 (setq bookmark-bmenu-toggle-filenames nil)
2038 (goto-char (point-min)) 2005 (goto-char (point-min))
2039 (forward-line 1) 2006 (forward-line 1)
2040 (while (re-search-forward "^D" (point-max) t) 2007 (while (re-search-forward "^D" (point-max) t)
2041 (bookmark-delete (bookmark-bmenu-bookmark) t)) ; pass BATCH arg 2008 (bookmark-delete (bookmark-bmenu-bookmark) t)) ; pass BATCH arg
2042 (bookmark-bmenu-list) 2009 (bookmark-bmenu-list)
2043 (setq bookmark-bmenu-toggle-filenames hide-em)
2044 (if bookmark-bmenu-toggle-filenames
2045 (bookmark-bmenu-toggle-filenames t))
2046 (if o-str 2010 (if o-str
2047 (progn 2011 (progn
2048 (goto-char (point-min)) 2012 (goto-char (point-min))