Commit fc9d6ad6 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

(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.
parent eb7fdcd9
2009-11-21 Thierry Volpiatto <thierry.volpiatto@gmail.com>
Stefan Monnier <monnier@iro.umontreal.ca>
* bookmark.el (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.
2009-11-21 Stefan Monnier <monnier@iro.umontreal.ca> 2009-11-21 Stefan Monnier <monnier@iro.umontreal.ca>
* bookmark.el (bookmark-search-prompt, bookmark-search-timer): Remove. * bookmark.el (bookmark-search-prompt, bookmark-search-timer): Remove.
......
...@@ -1493,9 +1493,6 @@ method buffers use to resolve name collisions." ...@@ -1493,9 +1493,6 @@ method buffers use to resolve name collisions."
;; Prefix is "bookmark-bmenu" for "buffer-menu": ;; Prefix is "bookmark-bmenu" for "buffer-menu":
(defvar bookmark-bmenu-bookmark-column nil)
(defvar bookmark-bmenu-hidden-bookmarks ()) (defvar bookmark-bmenu-hidden-bookmarks ())
...@@ -1579,29 +1576,29 @@ deletion, or > if it is flagged for displaying." ...@@ -1579,29 +1576,29 @@ deletion, or > if it is flagged for displaying."
(add-text-properties (point-min) (point) (add-text-properties (point-min) (point)
'(font-lock-face bookmark-menu-heading)) '(font-lock-face bookmark-menu-heading))
(dolist (full-record (bookmark-maybe-sort-alist)) (dolist (full-record (bookmark-maybe-sort-alist))
;; if a bookmark has an annotation, prepend a "*" (let ((name (bookmark-name-from-full-record full-record))
;; in the list of bookmarks. (annotation (bookmark-get-annotation full-record))
(let ((annotation (bookmark-get-annotation full-record))) (start (point))
end)
;; if a bookmark has an annotation, prepend a "*"
;; in the list of bookmarks.
(insert (if (and annotation (not (string-equal annotation ""))) (insert (if (and annotation (not (string-equal annotation "")))
" *" " ")) " *" " ")
(let ((start (point))) name)
(insert (bookmark-name-from-full-record full-record)) (setq end (point))
(if (display-mouse-p) (put-text-property start (+ 2 start) 'bookmark-name-prop name)
(add-text-properties (when (display-mouse-p)
start (add-text-properties
(save-excursion (re-search-backward (+ 2 start) end
"[^ \t]") '(mouse-face highlight
(1+ (point))) follow-link t
'(mouse-face highlight help-echo "mouse-2: go to this bookmark in other window")))
follow-link t (insert "\n")))
help-echo "mouse-2: go to this bookmark in other window"))) (goto-char (point-min))
(insert "\n"))))) (forward-line 2)
(bookmark-bmenu-mode)
(goto-char (point-min)) (if bookmark-bmenu-toggle-filenames
(forward-line 2) (bookmark-bmenu-toggle-filenames t))))
(bookmark-bmenu-mode)
(if bookmark-bmenu-toggle-filenames
(bookmark-bmenu-toggle-filenames t)))
;;;###autoload ;;;###autoload
(defalias 'list-bookmarks 'bookmark-bmenu-list) (defalias 'list-bookmarks 'bookmark-bmenu-list)
...@@ -1683,8 +1680,7 @@ mainly for debugging, and should not be necessary in normal use." ...@@ -1683,8 +1680,7 @@ mainly for debugging, and should not be necessary in normal use."
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
(while (< (point) (point-max)) (while (< (point) (point-max))
(let ((bmrk (bookmark-bmenu-bookmark))) (let ((bmrk (bookmark-bmenu-bookmark)))
(setq bookmark-bmenu-hidden-bookmarks (push bmrk bookmark-bmenu-hidden-bookmarks)
(cons bmrk bookmark-bmenu-hidden-bookmarks))
(let ((start (save-excursion (end-of-line) (point)))) (let ((start (save-excursion (end-of-line) (point))))
(move-to-column bookmark-bmenu-file-column t) (move-to-column bookmark-bmenu-file-column t)
;; Strip off `mouse-face' from the white spaces region. ;; 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,39 +1698,33 @@ mainly for debugging, and should not be necessary in normal use."
"In an interactive bookmark list, hide the filenames of the bookmarks. "In an interactive bookmark list, hide the filenames of the bookmarks.
Non-nil FORCE forces a redisplay showing the filenames. FORCE is used Non-nil FORCE forces a redisplay showing the filenames. FORCE is used
mainly for debugging, and should not be necessary in normal use." mainly for debugging, and should not be necessary in normal use."
(if (and (not force) bookmark-bmenu-toggle-filenames) (when (and (not force) bookmark-bmenu-toggle-filenames)
;; nothing to hide if above is nil ;; nothing to hide if above is nil
(save-excursion (save-excursion
(save-window-excursion (goto-char (point-min))
(goto-char (point-min)) (forward-line 2)
(forward-line 2) (setq bookmark-bmenu-hidden-bookmarks
(setq bookmark-bmenu-hidden-bookmarks (nreverse bookmark-bmenu-hidden-bookmarks))
(nreverse bookmark-bmenu-hidden-bookmarks)) (let ((inhibit-read-only t)
(save-excursion (column (save-excursion
(goto-char (point-min)) (goto-char (point-min))
(search-forward "Bookmark") (search-forward "Bookmark")
(backward-word 1) (backward-word 1)
(setq bookmark-bmenu-bookmark-column (current-column))) (setq bookmark-bmenu-bookmark-column (current-column)))))
(save-excursion (while bookmark-bmenu-hidden-bookmarks
(let ((inhibit-read-only t)) (move-to-column column t)
(while bookmark-bmenu-hidden-bookmarks (bookmark-kill-line)
(move-to-column bookmark-bmenu-bookmark-column t) (let ((name (pop bookmark-bmenu-hidden-bookmarks))
(bookmark-kill-line) (start (point)))
(let ((start (point))) (insert name)
(insert (car bookmark-bmenu-hidden-bookmarks)) (if (display-mouse-p)
(if (display-mouse-p) (add-text-properties
(add-text-properties start (point)
start '(mouse-face highlight
(save-excursion (re-search-backward follow-link t
"[^ \t]") help-echo
(1+ (point))) "mouse-2: go to this bookmark in other window"))))
'(mouse-face highlight (forward-line 1))))))
follow-link t
help-echo
"mouse-2: go to this bookmark in other window"))))
(setq bookmark-bmenu-hidden-bookmarks
(cdr bookmark-bmenu-hidden-bookmarks))
(forward-line 1))))))))
(defun bookmark-bmenu-check-position () (defun bookmark-bmenu-check-position ()
...@@ -1761,27 +1751,8 @@ Return `bookmark-alist'" ...@@ -1761,27 +1751,8 @@ Return `bookmark-alist'"
(defun bookmark-bmenu-bookmark () (defun bookmark-bmenu-bookmark ()
"Return the bookmark for this line in an interactive bookmark list buffer." "Return the bookmark for this line in an interactive bookmark list buffer."
(if (bookmark-bmenu-check-position) (when (bookmark-bmenu-check-position)
(save-excursion (get-text-property (line-beginning-position) 'bookmark-name-prop)))
(save-window-excursion
(goto-char (point-min))
(search-forward "Bookmark")
(backward-word 1)
(setq bookmark-bmenu-bookmark-column (current-column)))))
(if bookmark-bmenu-toggle-filenames
(bookmark-bmenu-hide-filenames))
(save-excursion
(save-window-excursion
(beginning-of-line)
(forward-char bookmark-bmenu-bookmark-column)
(prog1
(buffer-substring-no-properties (point)
(progn
(end-of-line)
(point)))
;; well, this is certainly crystal-clear:
(if bookmark-bmenu-toggle-filenames
(bookmark-bmenu-toggle-filenames t))))))
(defun bookmark-show-annotation (bookmark) (defun bookmark-show-annotation (bookmark)
...@@ -2023,26 +1994,19 @@ To carry out the deletions that you've marked, use \\<bookmark-bmenu-mode-map>\\ ...@@ -2023,26 +1994,19 @@ To carry out the deletions that you've marked, use \\<bookmark-bmenu-mode-map>\\
"Delete bookmarks marked with \\<Buffer-menu-mode-map>\\[Buffer-menu-delete] commands." "Delete bookmarks marked with \\<Buffer-menu-mode-map>\\[Buffer-menu-delete] commands."
(interactive) (interactive)
(message "Deleting bookmarks...") (message "Deleting bookmarks...")
(let ((hide-em bookmark-bmenu-toggle-filenames) (let ((o-point (point))
(o-point (point))
(o-str (save-excursion (o-str (save-excursion
(beginning-of-line) (beginning-of-line)
(if (looking-at "^D") (unless (looking-at "^D")
nil
(buffer-substring (buffer-substring
(point) (point)
(progn (end-of-line) (point)))))) (progn (end-of-line) (point))))))
(o-col (current-column))) (o-col (current-column)))
(if hide-em (bookmark-bmenu-hide-filenames))
(setq bookmark-bmenu-toggle-filenames nil)
(goto-char (point-min)) (goto-char (point-min))
(forward-line 1) (forward-line 1)
(while (re-search-forward "^D" (point-max) t) (while (re-search-forward "^D" (point-max) t)
(bookmark-delete (bookmark-bmenu-bookmark) t)) ; pass BATCH arg (bookmark-delete (bookmark-bmenu-bookmark) t)) ; pass BATCH arg
(bookmark-bmenu-list) (bookmark-bmenu-list)
(setq bookmark-bmenu-toggle-filenames hide-em)
(if bookmark-bmenu-toggle-filenames
(bookmark-bmenu-toggle-filenames t))
(if o-str (if o-str
(progn (progn
(goto-char (point-min)) (goto-char (point-min))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment