[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Yanking isearch to highlight-regexp
From: |
Juri Linkov |
Subject: |
Re: Yanking isearch to highlight-regexp |
Date: |
Wed, 25 Jun 2008 02:09:36 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu) |
> That sounds good.
I'd like to submit a series of patches instead of lumping all changes
together in one patch. The first patch below adds a new global prefix
key M-s for search related commands. It provides global bindings for
the often used command `occur' and a set of hi-lock commands with the
mnemonic subprefix key `h'.
But I'm not sure if a better way to do this is to define a new key map
explicitly, e.g. with the name like "search-map"?
Index: lisp/bindings.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/bindings.el,v
retrieving revision 1.207
diff -c -r1.207 bindings.el
*** lisp/bindings.el 5 Jun 2008 19:59:15 -0000 1.207
--- lisp/bindings.el 24 Jun 2008 23:00:45 -0000
***************
*** 815,820 ****
--- 815,828 ----
(define-key esc-map "gp" 'previous-error)
(define-key esc-map "g\M-p" 'previous-error)
+ (define-key esc-map "so" 'occur)
+ (define-key esc-map "shr" 'highlight-regexp)
+ (define-key esc-map "shp" 'highlight-phrase)
+ (define-key esc-map "shl" 'highlight-lines-matching-regexp)
+ (define-key esc-map "shu" 'unhighlight-regexp)
+ (define-key esc-map "shf" 'hi-lock-find-patterns)
+ (define-key esc-map "shw" 'hi-lock-write-interactive-patterns)
+
;;(defun function-key-error ()
;; (interactive)
;; (error "That function key is not bound to anything"))
Index: lisp/isearch.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.321
diff -c -r1.321 isearch.el
*** lisp/isearch.el 11 May 2008 20:30:27 -0000 1.321
--- lisp/isearch.el 24 Jun 2008 23:00:38 -0000
***************
*** 494,499 ****
--- 494,500 ----
(define-key map [?\M-%] 'isearch-query-replace)
(define-key map [?\C-\M-%] 'isearch-query-replace-regexp)
(define-key map "\M-so" 'isearch-occur)
+ (define-key map "\M-shr" 'isearch-highlight-regexp)
map)
"Keymap for `isearch-mode'.")
***************
*** 1364,1369 ****
--- 1365,1385 ----
(search-upper-case nil))
(occur regexp nlines)))
+ (defun isearch-highlight-regexp (regexp &optional face)
+ "Run `highlight-regexp' with regexp from the current search string.
+ Interactively, REGEXP is the current search regexp or a quoted search
+ string. FACE has the same meaning as in `highlight-regexp'."
+ (interactive
+ (list
+ (hi-lock-regexp-okay
+ (if isearch-regexp isearch-string (regexp-quote isearch-string)))
+ (hi-lock-read-face-name)))
+ (isearch-done)
+ (isearch-clean-overlays)
+ ;; (add-to-history 'hi-lock-regexp-history regexp)
+ (let ((case-fold-search isearch-case-fold-search))
+ (hi-lock-face-buffer regexp face)))
+
(defun isearch-delete-char ()
"Discard last input item and move point back.
--
Juri Linkov
http://www.jurta.org/emacs/
- Re: Yanking isearch to highlight-regexp, (continued)
- Re: Yanking isearch to highlight-regexp, Lennart Borgman (gmail), 2008/06/15
- Re: Yanking isearch to highlight-regexp, Juri Linkov, 2008/06/15
- Re: Yanking isearch to highlight-regexp, Lennart Borgman (gmail), 2008/06/15
- Re: Yanking isearch to highlight-regexp, Juri Linkov, 2008/06/16
- Re: Yanking isearch to highlight-regexp, Lennart Borgman, 2008/06/16
- Re: Yanking isearch to highlight-regexp, Juri Linkov, 2008/06/16
- Re: Yanking isearch to highlight-regexp, David Koppelman, 2008/06/16
- Re: Yanking isearch to highlight-regexp, Lennart Borgman (gmail), 2008/06/16
- Re: Yanking isearch to highlight-regexp, Juri Linkov, 2008/06/16
- Re: Yanking isearch to highlight-regexp, David Koppelman, 2008/06/17
- Re: Yanking isearch to highlight-regexp,
Juri Linkov <=
- Re: Yanking isearch to highlight-regexp, Stefan Monnier, 2008/06/24
- Re: Yanking isearch to highlight-regexp, Juri Linkov, 2008/06/25
- Re: Yanking isearch to highlight-regexp, Miles Bader, 2008/06/25
- Re: Yanking isearch to highlight-regexp, Lennart Borgman (gmail), 2008/06/25
- Re: Yanking isearch to highlight-regexp, Miles Bader, 2008/06/25
- Global keymaps [was: Yanking isearch to highlight-regexp], Juri Linkov, 2008/06/27
- Re: Global keymaps [was: Yanking isearch to highlight-regexp], Lennart Borgman (gmail), 2008/06/27
- Re: Global keymaps [was: Yanking isearch to highlight-regexp], Juri Linkov, 2008/06/27
- Re: Global keymaps, Miles Bader, 2008/06/27
- Re: Global keymaps, Stefan Monnier, 2008/06/27