diff options
| author | Stefan Monnier | 2012-10-01 22:47:12 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2012-10-01 22:47:12 -0400 |
| commit | d83ef9762efd4efe833c0c9687b057d6b62cdcb7 (patch) | |
| tree | 0b2c507e086e8e1b833e706b12f691d69cd8f2fe | |
| parent | 64edc7770f7fe5d6912c5f950fb998ae255415d3 (diff) | |
| download | emacs-d83ef9762efd4efe833c0c9687b057d6b62cdcb7.tar.gz emacs-d83ef9762efd4efe833c0c9687b057d6b62cdcb7.zip | |
* lisp/bookmark.el (bookmark-search-pattern): Remove var.
(bookmark-read-search-input): Remove function.
(bookmark-bmenu-search): Reimplement using a minibuffer.
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/bookmark.el | 54 |
2 files changed, 20 insertions, 38 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 758453c99b3..f125aca980a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | 2012-10-02 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2012-10-02 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * bookmark.el (bookmark-search-pattern): Remove var. | ||
| 4 | (bookmark-read-search-input): Remove function. | ||
| 5 | (bookmark-bmenu-search): Reimplement using a minibuffer. | ||
| 6 | |||
| 3 | * faces.el (modeline): Remove obsolete face name. | 7 | * faces.el (modeline): Remove obsolete face name. |
| 4 | 8 | ||
| 5 | * vc/add-log.el (add-log-buffer-file-name-function): Demote to defvar | 9 | * vc/add-log.el (add-log-buffer-file-name-function): Demote to defvar |
diff --git a/lisp/bookmark.el b/lisp/bookmark.el index 861aa6e06dd..838e5a5ec00 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el | |||
| @@ -2010,32 +2010,6 @@ To carry out the deletions that you've marked, use \\<bookmark-bmenu-mode-map>\\ | |||
| 2010 | 2010 | ||
| 2011 | ;;; Bookmark-bmenu search | 2011 | ;;; Bookmark-bmenu search |
| 2012 | 2012 | ||
| 2013 | ;; Store keyboard input for incremental search. | ||
| 2014 | (defvar bookmark-search-pattern) | ||
| 2015 | |||
| 2016 | (defun bookmark-read-search-input () | ||
| 2017 | "Read each keyboard input and add it to `bookmark-search-pattern'." | ||
| 2018 | (let ((prompt (propertize "Pattern: " 'face 'minibuffer-prompt)) | ||
| 2019 | ;; (inhibit-quit t) ; inhibit-quit is evil. Use it with extreme care! | ||
| 2020 | (tmp-list ())) | ||
| 2021 | (while | ||
| 2022 | (let ((char (read-key (concat prompt bookmark-search-pattern)))) | ||
| 2023 | (pcase char | ||
| 2024 | ((or ?\e ?\r) nil) ; RET or ESC break the search loop. | ||
| 2025 | (?\C-g (setq bookmark-quit-flag t) nil) | ||
| 2026 | (?\d (pop tmp-list) t) ; Delete last char of pattern with DEL | ||
| 2027 | (_ | ||
| 2028 | (if (characterp char) | ||
| 2029 | (push char tmp-list) | ||
| 2030 | (setq unread-command-events | ||
| 2031 | (nconc (mapcar 'identity | ||
| 2032 | (this-single-command-raw-keys)) | ||
| 2033 | unread-command-events)) | ||
| 2034 | nil)))) | ||
| 2035 | (setq bookmark-search-pattern | ||
| 2036 | (apply 'string (reverse tmp-list)))))) | ||
| 2037 | |||
| 2038 | |||
| 2039 | (defun bookmark-bmenu-filter-alist-by-regexp (regexp) | 2013 | (defun bookmark-bmenu-filter-alist-by-regexp (regexp) |
| 2040 | "Filter `bookmark-alist' with bookmarks matching REGEXP and rebuild list." | 2014 | "Filter `bookmark-alist' with bookmarks matching REGEXP and rebuild list." |
| 2041 | (let ((bookmark-alist | 2015 | (let ((bookmark-alist |
| @@ -2050,19 +2024,23 @@ To carry out the deletions that you've marked, use \\<bookmark-bmenu-mode-map>\\ | |||
| 2050 | "Incremental search of bookmarks, hiding the non-matches as we go." | 2024 | "Incremental search of bookmarks, hiding the non-matches as we go." |
| 2051 | (interactive) | 2025 | (interactive) |
| 2052 | (let ((bmk (bookmark-bmenu-bookmark)) | 2026 | (let ((bmk (bookmark-bmenu-bookmark)) |
| 2053 | (bookmark-search-pattern "") | 2027 | (timer nil)) |
| 2054 | (timer (run-with-idle-timer | ||
| 2055 | bookmark-search-delay 'repeat | ||
| 2056 | #'(lambda () | ||
| 2057 | (bookmark-bmenu-filter-alist-by-regexp | ||
| 2058 | bookmark-search-pattern))))) | ||
| 2059 | (unwind-protect | 2028 | (unwind-protect |
| 2060 | (bookmark-read-search-input) | 2029 | (minibuffer-with-setup-hook |
| 2061 | (cancel-timer timer) | 2030 | (lambda () |
| 2062 | (message nil) | 2031 | (setq timer (run-with-idle-timer |
| 2063 | (when bookmark-quit-flag ; C-g hit restore menu list. | 2032 | bookmark-search-delay 'repeat |
| 2064 | (bookmark-bmenu-list) (bookmark-bmenu-goto-bookmark bmk)) | 2033 | #'(lambda (buf) |
| 2065 | (setq bookmark-quit-flag nil)))) | 2034 | (with-current-buffer buf |
| 2035 | (bookmark-bmenu-filter-alist-by-regexp | ||
| 2036 | (minibuffer-contents)))) | ||
| 2037 | (current-buffer)))) | ||
| 2038 | (read-string "Pattern: ") | ||
| 2039 | (when timer (cancel-timer timer) (setq timer nil))) | ||
| 2040 | (when timer ;; Signalled an error or a `quit'. | ||
| 2041 | (cancel-timer timer) | ||
| 2042 | (bookmark-bmenu-list) | ||
| 2043 | (bookmark-bmenu-goto-bookmark bmk))))) | ||
| 2066 | 2044 | ||
| 2067 | (defun bookmark-bmenu-goto-bookmark (name) | 2045 | (defun bookmark-bmenu-goto-bookmark (name) |
| 2068 | "Move point to bookmark with name NAME." | 2046 | "Move point to bookmark with name NAME." |