1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-29 11:02:01 +00:00

* bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.

(bookmark-search-pattern, bookmark-search-timer, bookmark-quit-flag): New vars.
(bookmark-read-search-input, bookmark-filtered-alist-by-regexp-only)
(bookmark-bmenu-filter-alist-by-regexp)
(bookmark-bmenu-goto-bookmark, bookmark-bmenu-cancel-search): New funs.
(bookmark-bmenu-search): New command.
(bookmark-bmenu-mode-map): Bind it.
This commit is contained in:
Stefan Monnier 2009-11-20 15:47:26 +00:00
parent acfad775d2
commit 1e7d447511
3 changed files with 133 additions and 21 deletions

View File

@ -153,6 +153,11 @@ when the value of the new variable `completions-format' is `vertical'.
* Changes in Specialized Modes and Packages in Emacs 23.2
** The bookmark menu has a narrowing search via bookmark-bmenu-search.
** LaTeX mode now provides completion via latex-complete and
latex-indent-or-complete.
** lucid.el and levents.el are now declared obsolete.
** pcomplete provides a new command `pcomplete-std-completion' which

View File

@ -1,7 +1,18 @@
2009-11-20 Thierry Volpiatto <thierry.volpiatto@gmail.com>
* bookmark.el (bookmark-search-delay, bookmark-search-prompt):
New options.
(bookmark-search-pattern, bookmark-search-timer, bookmark-quit-flag):
New vars.
(bookmark-read-search-input, bookmark-filtered-alist-by-regexp-only)
(bookmark-bmenu-filter-alist-by-regexp)
(bookmark-bmenu-goto-bookmark, bookmark-bmenu-cancel-search): New funs.
(bookmark-bmenu-search): New command.
(bookmark-bmenu-mode-map): Bind it.
2009-11-20 Chong Yidong <cyd@stupidchicken.com>
* cedet/semantic/complete.el (semantic-complete-inline-map): Doc
fix.
* cedet/semantic/complete.el (semantic-complete-inline-map): Doc fix.
* cedet/semantic/idle.el (define-semantic-idle-service)
(semantic-idle-summary-mode, semantic-idle-completions): Doc fix.
@ -16,29 +27,27 @@
* Makefile.in: Don't refer cc-subword.elc but subword.elc.
* progmodes/cc-cmds.el (c-update-modeline)
(c-forward-into-nomenclature, c-backward-into-nomenclature): Refer
to subword.el functions instead of cc-subword.el.
(c-forward-into-nomenclature, c-backward-into-nomenclature):
Refer to subword.el functions instead of cc-subword.el.
* progmodes/cc-mode.el (subword-mode, c-mode-base-map): Refer to
subword.el functions instead of cc-subword.el.
* progmodes/cc-subword.el: Renamed to subword.el.
* subword.el: Renamed from progmodes/cc-subword.el.
(subword-mode-map): Renamed from c-subword-mode-map.
(subword-mode): Renamed from c-subword-mode.
* progmodes/cc-subword.el: Rename to subword.el.
* subword.el: Rename from progmodes/cc-subword.el.
(subword-mode-map): Rename from c-subword-mode-map.
(subword-mode): Rename from c-subword-mode.
(global-subword-mode): New global minor mode.
(forward-subword): Renamed from c-forward-subword.
(backward-subword): Renamed from c-backward-subword.
(mark-subword): Renamed from c-mark-subword.
(kill-subword): Renamed from c-kill-subword.
(backward-kill-subword): Renamed from c-backward-kill-subword.
(transpose-subwords): Renamed from c-tranpose-subword.
(downcase-subword): Renamed from c-downcase-subword.
(capitalize-subword): Renamed from c-capitalize-subword.
(forward-subword-internal): Renamed from
c-forward-subword-internal.
(backward-subword-internal): Renamed from
c-backward-subword-internal.
(forward-subword): Rename from c-forward-subword.
(backward-subword): Rename from c-backward-subword.
(mark-subword): Rename from c-mark-subword.
(kill-subword): Rename from c-kill-subword.
(backward-kill-subword): Rename from c-backward-kill-subword.
(transpose-subwords): Rename from c-tranpose-subword.
(downcase-subword): Rename from c-downcase-subword.
(capitalize-subword): Rename from c-capitalize-subword.
(forward-subword-internal): Rename from c-forward-subword-internal.
(backward-subword-internal): Rename from c-backward-subword-internal.
2009-11-20 Dan Nicolaescu <dann@ics.uci.edu>
@ -352,7 +361,7 @@
* vc-mtn.el (vc-mtn-print-log):
* vc-hg.el (vc-hg-print-log):
* vc-bzr.el (vc-bzr-print-log): Add new optional argument LIMIT,
pass it to the log command when set. Make the BUFFER argument
pass it to the log command when set. Make the BUFFER argument
non-optional.
* vc-sccs.el (vc-sccs-print-log):

View File

@ -197,6 +197,18 @@ following in your `.emacs' file:
:group 'bookmark)
(defcustom bookmark-search-delay 0.2
"*Display when searching bookmarks is updated all `bookmark-search-delay' seconds."
:group 'bookmark
:type 'integer)
(defcustom bookmark-search-prompt "Pattern: "
"*Prompt used for `bookmark-bmenu-search'."
:group 'bookmark
:type 'string)
(defface bookmark-menu-heading
'((t (:inherit font-lock-type-face)))
"Face used to highlight the heading in bookmark menu buffers."
@ -320,6 +332,18 @@ the source buffer for that information; see `bookmark-yank-word' and
This point is in `bookmark-curent-buffer'.")
(defvar bookmark-search-pattern ""
"Store keyboard input for incremental search.")
(defvar bookmark-search-timer nil
"Timer used for searching")
(defvar bookmark-quit-flag nil
"Non nil make `bookmark-bmenu-search' quit immediately.")
;; Helper functions.
@ -1525,6 +1549,7 @@ method buffers use to resolve name collisions."
(define-key map "a" 'bookmark-bmenu-show-annotation)
(define-key map "A" 'bookmark-bmenu-show-all-annotations)
(define-key map "e" 'bookmark-bmenu-edit-annotation)
(define-key map "\M-g" 'bookmark-bmenu-search)
(define-key map [mouse-2] 'bookmark-bmenu-other-window-with-mouse)
map))
@ -2072,6 +2097,79 @@ To carry out the deletions that you've marked, use \\<bookmark-bmenu-mode-map>\\
(bookmark-relocate bmrk)
(goto-char thispoint))))
;;; Bookmark-bmenu search
(defun bookmark-read-search-input ()
"Read each keyboard input and add it to `bookmark-search-pattern'."
(setq bookmark-search-pattern "") ; Always reset pattern to empty string
(let ((prompt (propertize bookmark-search-prompt 'face '((:foreground "cyan"))))
(inhibit-quit t)
(tmp-list ())
char)
(catch 'break
(while 1
(catch 'continue
(condition-case nil
(setq char (read-char (concat prompt bookmark-search-pattern)))
(error (throw 'break nil)))
(case char
((or ?\e ?\r) (throw 'break nil)) ; RET or ESC break search loop and lead to [1].
(?\d (pop tmp-list) ; Delete last char of `bookmark-search-pattern' with DEL
(setq bookmark-search-pattern (mapconcat 'identity (reverse tmp-list) ""))
(throw 'continue nil))
(?\C-g (setq bookmark-quit-flag t) (throw 'break nil))
(t
(push (text-char-description char) tmp-list)
(setq bookmark-search-pattern (mapconcat 'identity (reverse tmp-list) ""))
(throw 'continue nil))))))))
(defun bookmark-filtered-alist-by-regexp-only (regexp)
"Return a filtered `bookmark-alist' with bookmarks matching REGEXP."
(loop for i in bookmark-alist
when (string-match regexp (car i)) collect i into new
finally return new))
(defun bookmark-bmenu-filter-alist-by-regexp (regexp)
"Filter `bookmark-alist' with bookmarks matching REGEXP and rebuild list."
(let ((bookmark-alist (bookmark-filtered-alist-by-regexp-only regexp)))
(bookmark-bmenu-list)))
;;;###autoload
(defun bookmark-bmenu-search ()
"Incremental search of bookmarks matching `bookmark-search-pattern'.
`bookmark-search-pattern' is build incrementally with `bookmark-read-search-input'"
(interactive)
(when (string= (buffer-name (current-buffer)) "*Bookmark List*")
(let ((bmk (bookmark-bmenu-bookmark)))
(unwind-protect
(progn
(setq bookmark-search-timer
(run-with-idle-timer bookmark-search-delay 'repeat
#'(lambda ()
(bookmark-bmenu-filter-alist-by-regexp bookmark-search-pattern))))
(bookmark-read-search-input))
(progn ; [1] Stop timer.
(bookmark-bmenu-cancel-search)
(when bookmark-quit-flag ; C-g hit restore menu list.
(bookmark-bmenu-list) (bookmark-bmenu-goto-bookmark bmk))
(setq bookmark-quit-flag nil))))))
(defun bookmark-bmenu-goto-bookmark (name)
"Move point to bookmark with name NAME."
(goto-char (point-min))
(bookmark-bmenu-check-position)
(while (not (equal name (bookmark-bmenu-bookmark)))
(forward-line 1))
(forward-line 0))
(defun bookmark-bmenu-cancel-search ()
"Cancel timer used for searching in bookmarks."
(cancel-timer bookmark-search-timer)
(setq bookmark-search-timer nil))
;;; Menu bar stuff. Prefix is "bookmark-menu".