unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Yanking isearch to highlight-regexp
@ 2008-06-14 16:57 Lennart Borgman (gmail)
  2008-06-14 21:42 ` Mathias Dahl
  0 siblings, 1 reply; 64+ messages in thread
From: Lennart Borgman (gmail) @ 2008-06-14 16:57 UTC (permalink / raw)
  To: Emacs Devel

Would it be practical to use C-s at higlight-regexp prompt to yank/paste 
last isearch search string?




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-14 16:57 Yanking isearch to highlight-regexp Lennart Borgman (gmail)
@ 2008-06-14 21:42 ` Mathias Dahl
  2008-06-14 21:50   ` Stefan Monnier
  0 siblings, 1 reply; 64+ messages in thread
From: Mathias Dahl @ 2008-06-14 21:42 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: Emacs Devel

> Would it be practical to use C-s at higlight-regexp prompt to yank/paste
> last isearch search string?

I can definitely see how it could be useful. It would probably also be
useful to go directly from an isearch into highlight-regexp. How
important these things are (use vs increased code complexity etc) is
of course another matter




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-14 21:42 ` Mathias Dahl
@ 2008-06-14 21:50   ` Stefan Monnier
  2008-06-14 21:54     ` Mathias Dahl
  2008-06-15  0:08     ` Lennart Borgman (gmail)
  0 siblings, 2 replies; 64+ messages in thread
From: Stefan Monnier @ 2008-06-14 21:50 UTC (permalink / raw)
  To: Mathias Dahl; +Cc: Lennart Borgman (gmail), Emacs Devel

> I can definitely see how it could be useful. It would probably also be
> useful to go directly from an isearch into highlight-regexp. How

You mean in the same way as C-M-% has a special binding in isearch?
I guess that would make a lot of sense, except that highlight-regexp
doesn't have any keybinding,


        Stefan




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-14 21:50   ` Stefan Monnier
@ 2008-06-14 21:54     ` Mathias Dahl
  2008-06-15  0:32       ` Juri Linkov
  2008-06-15  0:08     ` Lennart Borgman (gmail)
  1 sibling, 1 reply; 64+ messages in thread
From: Mathias Dahl @ 2008-06-14 21:54 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Lennart Borgman (gmail), Emacs Devel

>> It would probably also be
>> useful to go directly from an isearch into highlight-regexp. How
>
> You mean in the same way as C-M-% has a special binding in isearch?

Yes.

> I guess that would make a lot of sense, except that highlight-regexp
> doesn't have any keybinding,

Now, I don't even need this feature because I use highlight-regexp
very seldom so I am not arguing, but generally speaking, why is it a
problem if we wanted to add this even though highlight-regexp has no
default keybinding? Is it because having no default keybinding implies
that a command is not very much used (by most users)?




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-14 21:50   ` Stefan Monnier
  2008-06-14 21:54     ` Mathias Dahl
@ 2008-06-15  0:08     ` Lennart Borgman (gmail)
  2008-06-15  0:33       ` Juri Linkov
  2008-06-15  1:48       ` Stefan Monnier
  1 sibling, 2 replies; 64+ messages in thread
From: Lennart Borgman (gmail) @ 2008-06-15  0:08 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs Devel, Mathias Dahl

Stefan Monnier wrote:
>> I can definitely see how it could be useful. It would probably also be
>> useful to go directly from an isearch into highlight-regexp. How
> 
> You mean in the same way as C-M-% has a special binding in isearch?
> I guess that would make a lot of sense, except that highlight-regexp
> doesn't have any keybinding,


One possibility is of course bind it to C-x w h in isearch, like in 
hi-lock-mode. Could that possible disturb?




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-14 21:54     ` Mathias Dahl
@ 2008-06-15  0:32       ` Juri Linkov
  0 siblings, 0 replies; 64+ messages in thread
From: Juri Linkov @ 2008-06-15  0:32 UTC (permalink / raw)
  To: Mathias Dahl; +Cc: Lennart Borgman (gmail), Stefan Monnier, Emacs Devel

>>> It would probably also be
>>> useful to go directly from an isearch into highlight-regexp. How
>>
>> You mean in the same way as C-M-% has a special binding in isearch?
>
> Yes.
>
>> I guess that would make a lot of sense, except that highlight-regexp
>> doesn't have any keybinding,
>
> Now, I don't even need this feature because I use highlight-regexp
> very seldom so I am not arguing, but generally speaking, why is it a
> problem if we wanted to add this even though highlight-regexp has no
> default keybinding? Is it because having no default keybinding implies
> that a command is not very much used (by most users)?

This usually means there are no more free keybindings :-)

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-15  0:08     ` Lennart Borgman (gmail)
@ 2008-06-15  0:33       ` Juri Linkov
  2008-06-15  1:48       ` Stefan Monnier
  1 sibling, 0 replies; 64+ messages in thread
From: Juri Linkov @ 2008-06-15  0:33 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: Mathias Dahl, Stefan Monnier, Emacs Devel

> Stefan Monnier wrote:
>>> I can definitely see how it could be useful. It would probably also be
>>> useful to go directly from an isearch into highlight-regexp. How
>>
>> You mean in the same way as C-M-% has a special binding in isearch?
>> I guess that would make a lot of sense, except that highlight-regexp
>> doesn't have any keybinding,
>
> One possibility is of course bind it to C-x w h in isearch, like in
> hi-lock-mode. Could that possible disturb?

FWIW, I bind this to `M-s h'.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-15  0:08     ` Lennart Borgman (gmail)
  2008-06-15  0:33       ` Juri Linkov
@ 2008-06-15  1:48       ` Stefan Monnier
  2008-06-15  9:47         ` Lennart Borgman (gmail)
  1 sibling, 1 reply; 64+ messages in thread
From: Stefan Monnier @ 2008-06-15  1:48 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: Emacs Devel, Mathias Dahl

> One possibility is of course bind it to C-x w h in isearch, like in
> hi-lock-mode. Could that possible disturb?

C-x exits isearch, so it would be difficult to do.


        Stefan




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-15  1:48       ` Stefan Monnier
@ 2008-06-15  9:47         ` Lennart Borgman (gmail)
  2008-06-15 20:48           ` Juri Linkov
  0 siblings, 1 reply; 64+ messages in thread
From: Lennart Borgman (gmail) @ 2008-06-15  9:47 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs Devel, Mathias Dahl

[-- Attachment #1: Type: text/plain, Size: 437 bytes --]

Stefan Monnier wrote:
>> One possibility is of course bind it to C-x w h in isearch, like in
>> hi-lock-mode. Could that possible disturb?
> 
> C-x exits isearch, so it would be difficult to do.


If highlight-regexp was always bound to C-x w h then something like the 
simple patched attached could be used. Of course the test for 
`last-command' could be made a bit more pretty ...

Why is not C-x w h always bound to higlight-regexp?

[-- Attachment #2: hi-lock-from-isearch.diff --]
[-- Type: text/plain, Size: 1001 bytes --]

Index: hi-lock.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/hi-lock.el,v
retrieving revision 1.51
diff -u -r1.51 hi-lock.el
--- hi-lock.el	6 May 2008 07:57:38 -0000	1.51
+++ hi-lock.el	15 Jun 2008 09:42:35 -0000
@@ -421,7 +421,12 @@
    (list
     (hi-lock-regexp-okay
      (read-from-minibuffer "Regexp to highlight: "
-                           (cons (or (car hi-lock-regexp-history) "") 1 )
+                           (cons (or (when (eq last-command
+                                               'isearch-other-control-char)
+                                       (if isearch-regexp
+                                           isearch-string
+                                         (regexp-quote isearch-string)))
+                                     (car hi-lock-regexp-history) "") 1 )
                            nil nil 'hi-lock-regexp-history))
     (hi-lock-read-face-name)))
   (or (facep face) (setq face 'hi-yellow))

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-15  9:47         ` Lennart Borgman (gmail)
@ 2008-06-15 20:48           ` Juri Linkov
  2008-06-15 21:10             ` Lennart Borgman (gmail)
                               ` (2 more replies)
  0 siblings, 3 replies; 64+ messages in thread
From: Juri Linkov @ 2008-06-15 20:48 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: David Koppelman, emacs-devel

> Why is not C-x w h always bound to higlight-regexp?

I think the key `C-x w' by its mnemonics would be more suitable for
a command that writes to the file like `C-x C-w'.

As the comment in hi-lock.el suggests to bind it rather to `C-z h',
below is a patch for isearch.el with a new command `isearch-highlight-regexp'
bound to `M-s h'.  It is equivalent to the previously implemented
`isearch-occur' in regard to calling the command with the last isearch
string/regexp.  `isearch-highlight-regexp' is a useful command, and
it is much better than setting `lazy-highlight-cleanup' to nil, because
`lazy-highlight-cleanup' leaves highlighting limited only to the current
window boundaries, whereas `highlight-regexp' highlights the entire buffer.

As for the separate case of running `highlight-regexp' after isearch is
finished, I suggest using the same default values as already provided by
`occur-read-primary-args' and `keep-lines-read-args' that collect a list
of useful regexps from different places including the last isearch string
and put them to the list of default values.

This also suggests to get rid of `hi-lock-regexp-history' in favor of
the single regexp history variable `regexp-history' shared among all
regexp-reading commands (perhaps `keep-lines-read-args' should be
renamed to more general name like `read-regexp').

Another improvement I propose is to put a list of default faces to the
minibuffer's list of default values accessible via M-n instead of
putting default values to the history list where the user expects
to find the history list of previous input.

Index: lisp/isearch.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.321
diff -u -r1.321 isearch.el
--- lisp/isearch.el	11 May 2008 20:30:27 -0000	1.321
+++ lisp/isearch.el	15 Jun 2008 20:43:00 -0000
@@ -494,6 +494,7 @@
     (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-sh" 'isearch-highlight-regexp)
 
     map)
   "Keymap for `isearch-mode'.")
@@ -1364,6 +1365,21 @@
 	(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)
+  (let ((case-fold-search isearch-case-fold-search))
+    (hi-lock-face-buffer regexp face)))
+
 \f
 (defun isearch-delete-char ()
   "Discard last input item and move point back.

Index: lisp/hi-lock.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/hi-lock.el,v
retrieving revision 1.51
diff -u -r1.51 hi-lock.el
--- lisp/hi-lock.el	6 May 2008 07:57:38 -0000	1.51
+++ lisp/hi-lock.el	15 Jun 2008 20:43:34 -0000
@@ -206,12 +206,12 @@
 (defvar hi-lock-interactive-patterns nil
   "Patterns provided to hi-lock by user.  Should not be changed.")
 
-(defvar hi-lock-face-history
+(defvar hi-lock-face-defaults
   (list "hi-yellow" "hi-pink" "hi-green" "hi-blue" "hi-black-b"
         "hi-blue-b" "hi-red-b" "hi-green-b" "hi-black-hb")
-      "History list of faces for hi-lock interactive functions.")
+      "A list of default faces for hi-lock interactive functions.")
 
-;(dolist (f hi-lock-face-history) (unless (facep f) (error "%s not a face" f)))
+;(dolist (f hi-lock-face-defaults) (unless (facep f) (error "%s not a face" f)))
 
 (defvar hi-lock-regexp-history nil
   "History of regexps used for interactive fontification.")
@@ -390,14 +390,13 @@
 
 Interactively, prompt for REGEXP then FACE.  Buffer-local history
 list maintained for regexps, global history maintained for faces.
-\\<minibuffer-local-map>Use \\[next-history-element] and \\[previous-history-element] to retrieve next or previous history item.
+\\<minibuffer-local-map>Use \\[previous-history-element] to retrieve previous history items,
+and \\[next-history-element] to retrieve default values.
 \(See info node `Minibuffer History'.)"
   (interactive
    (list
     (hi-lock-regexp-okay
-     (read-from-minibuffer "Regexp to highlight line: "
-                           (cons (or (car hi-lock-regexp-history) "") 1 )
-                           nil nil 'hi-lock-regexp-history))
+     (keep-lines-read-args "Regexp to highlight line: "))
     (hi-lock-read-face-name)))
   (or (facep face) (setq face 'hi-yellow))
   (unless hi-lock-mode (hi-lock-mode 1))
@@ -415,14 +414,13 @@
 
 Interactively, prompt for REGEXP then FACE.  Buffer-local history
 list maintained for regexps, global history maintained for faces.
-\\<minibuffer-local-map>Use \\[next-history-element] and \\[previous-history-element] to retrieve next or previous history item.
+\\<minibuffer-local-map>Use \\[previous-history-element] to retrieve previous history items,
+and \\[next-history-element] to retrieve default values.
 \(See info node `Minibuffer History'.)"
   (interactive
    (list
     (hi-lock-regexp-okay
-     (read-from-minibuffer "Regexp to highlight: "
-                           (cons (or (car hi-lock-regexp-history) "") 1 )
-                           nil nil 'hi-lock-regexp-history))
+     (keep-lines-read-args "Regexp to highlight: "))
     (hi-lock-read-face-name)))
   (or (facep face) (setq face 'hi-yellow))
   (unless hi-lock-mode (hi-lock-mode 1))
@@ -440,9 +438,7 @@
    (list
     (hi-lock-regexp-okay
      (hi-lock-process-phrase
-      (read-from-minibuffer "Phrase to highlight: "
-                            (cons (or (car hi-lock-regexp-history) "") 1 )
-                            nil nil 'hi-lock-regexp-history)))
+      (keep-lines-read-args "Phrase to highlight: ")))
     (hi-lock-read-face-name)))
   (or (facep face) (setq face 'hi-yellow))
   (unless hi-lock-mode (hi-lock-mode 1))
@@ -457,7 +453,8 @@
 Interactively, prompt for REGEXP.  Buffer-local history of inserted
 regexp's maintained.  Will accept only regexps inserted by hi-lock
 interactive functions.  \(See `hi-lock-interactive-patterns'.\)
-\\<minibuffer-local-must-match-map>Use \\[minibuffer-complete] to complete a partially typed regexp.
+\\<minibuffer-local-map>Use \\[previous-history-element] to retrieve previous history items,
+and \\[next-history-element] to retrieve default values.
 \(See info node `Minibuffer History'.\)"
   (interactive
    (if (and (display-popup-menus-p) (not last-nonmenu-event))
@@ -552,16 +549,18 @@
   (intern (completing-read
            "Highlight using face: "
            obarray 'facep t
-           (cons (car hi-lock-face-history)
+           (cons (car hi-lock-face-defaults)
                  (let ((prefix
                         (try-completion
-                         (substring (car hi-lock-face-history) 0 1)
+                         (substring (car hi-lock-face-defaults) 0 1)
                          (mapcar (lambda (f) (cons f f))
-                                 hi-lock-face-history))))
+                                 hi-lock-face-defaults))))
                    (if (and (stringp prefix)
-                            (not (equal prefix (car hi-lock-face-history))))
+                            (not (equal prefix (car hi-lock-face-defaults))))
                        (length prefix) 0)))
-           '(hi-lock-face-history . 0))))
+           nil
+           hi-lock-face-defaults
+	   )))
 
 (defun hi-lock-set-pattern (regexp face)
   "Highlight REGEXP with face FACE."

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-15 20:48           ` Juri Linkov
@ 2008-06-15 21:10             ` Lennart Borgman (gmail)
  2008-06-15 22:54               ` Juri Linkov
  2008-06-16 18:50             ` David Koppelman
  2008-06-28 22:02             ` Yanking isearch to highlight-regexp Juri Linkov
  2 siblings, 1 reply; 64+ messages in thread
From: Lennart Borgman (gmail) @ 2008-06-15 21:10 UTC (permalink / raw)
  To: Juri Linkov; +Cc: David Koppelman, emacs-devel

Juri Linkov wrote:
>> Why is not C-x w h always bound to higlight-regexp?
> 
> I think the key `C-x w' by its mnemonics would be more suitable for
> a command that writes to the file like `C-x C-w'.
> 
> As the comment in hi-lock.el suggests to bind it rather to `C-z h',

I just want the key binding to be the same as I use outside of isearch.

There were no global binding for `occur' so in that case I thought `M-s 
o' was good, but in this case I would really prefer the same binding 
inside isearch. My rather cryptic patch to hi-lock.el provided that - 
you are very welcome to make it better if you want.

> below is a patch for isearch.el with a new command `isearch-highlight-regexp'
> bound to `M-s h'.  It is equivalent to the previously implemented
> `isearch-occur' in regard to calling the command with the last isearch
> string/regexp.  `isearch-highlight-regexp' is a useful command, and
> it is much better than setting `lazy-highlight-cleanup' to nil, because
> `lazy-highlight-cleanup' leaves highlighting limited only to the current
> window boundaries, whereas `highlight-regexp' highlights the entire buffer.
> 
> As for the separate case of running `highlight-regexp' after isearch is
> finished, I suggest using the same default values as already provided by
> `occur-read-primary-args' and `keep-lines-read-args' that collect a list
> of useful regexps from different places including the last isearch string
> and put them to the list of default values.

I am not sure I understand this. If highlight-regexp is bound to `C-x w 
h' and I type that at the isearch prompt would that start that 
highlight-regexp with the current isearch regexp as the default regexp 
at the prompt?

> This also suggests to get rid of `hi-lock-regexp-history' in favor of
> the single regexp history variable `regexp-history' shared among all
> regexp-reading commands (perhaps `keep-lines-read-args' should be
> renamed to more general name like `read-regexp').

Agree.





^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-15 21:10             ` Lennart Borgman (gmail)
@ 2008-06-15 22:54               ` Juri Linkov
  2008-06-15 23:09                 ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 64+ messages in thread
From: Juri Linkov @ 2008-06-15 22:54 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: David Koppelman, emacs-devel

>> I think the key `C-x w' by its mnemonics would be more suitable for
>> a command that writes to the file like `C-x C-w'.
>>
>> As the comment in hi-lock.el suggests to bind it rather to `C-z h',
>
> I just want the key binding to be the same as I use outside of isearch.
>
> There were no global binding for `occur' so in that case I thought
> `M-s o' was good, but in this case I would really prefer the same
> binding inside isearch.

`C-x w h' is not available until hi-lock.el is loaded, but `M-s h'
is the pretty harmless and convenient key binding to keep the
isearch highlighting permanent in the entire buffer.

> My rather cryptic patch to hi-lock.el provided that -
> you are very welcome to make it better if you want.

Your patch looks like a good idea, so perhaps the same thing
should be applied also to occur, keep-lines, flush-lines, etc.
(in a new unified function `read-regexp').  This means that
e.g. `C-s string M-x keep-lines RET' will provide the last
isearch string as the minibuffer default input value.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-15 22:54               ` Juri Linkov
@ 2008-06-15 23:09                 ` Lennart Borgman (gmail)
  2008-06-16  9:34                   ` Juri Linkov
  0 siblings, 1 reply; 64+ messages in thread
From: Lennart Borgman (gmail) @ 2008-06-15 23:09 UTC (permalink / raw)
  To: Juri Linkov; +Cc: David Koppelman, emacs-devel

Juri Linkov wrote:
>>> I think the key `C-x w' by its mnemonics would be more suitable for
>>> a command that writes to the file like `C-x C-w'.
>>>
>>> As the comment in hi-lock.el suggests to bind it rather to `C-z h',
>> I just want the key binding to be the same as I use outside of isearch.
>>
>> There were no global binding for `occur' so in that case I thought
>> `M-s o' was good, but in this case I would really prefer the same
>> binding inside isearch.
> 
> `C-x w h' is not available until hi-lock.el is loaded, but `M-s h'
> is the pretty harmless and convenient key binding to keep the
> isearch highlighting permanent in the entire buffer.

Yes, but I suggested adding `C-x w h' to global-map too. Is there any 
reason not to do that? (It is useful, not dangerous and the binding 
seems to be reserved.)




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-15 23:09                 ` Lennart Borgman (gmail)
@ 2008-06-16  9:34                   ` Juri Linkov
  2008-06-16 11:13                     ` Lennart Borgman
  0 siblings, 1 reply; 64+ messages in thread
From: Juri Linkov @ 2008-06-16  9:34 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: David Koppelman, emacs-devel

>>>> I think the key `C-x w' by its mnemonics would be more suitable for
>>>> a command that writes to the file like `C-x C-w'.
>>>>
>>>> As the comment in hi-lock.el suggests to bind it rather to `C-z h',
>>> I just want the key binding to be the same as I use outside of isearch.
>>>
>>> There were no global binding for `occur' so in that case I thought
>>> `M-s o' was good, but in this case I would really prefer the same
>>> binding inside isearch.
>>
>> `C-x w h' is not available until hi-lock.el is loaded, but `M-s h'
>> is the pretty harmless and convenient key binding to keep the
>> isearch highlighting permanent in the entire buffer.
>
> Yes, but I suggested adding `C-x w h' to global-map too. Is there any
> reason not to do that? (It is useful, not dangerous and the binding seems
> to be reserved.)

I think it is better to reserve the global `C-x w' for more
mnemonic commands (e.g. "write" or "window"), and rebind hi-lock
keys to the search specific prefix key.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-16  9:34                   ` Juri Linkov
@ 2008-06-16 11:13                     ` Lennart Borgman
  2008-06-16 21:48                       ` Juri Linkov
  0 siblings, 1 reply; 64+ messages in thread
From: Lennart Borgman @ 2008-06-16 11:13 UTC (permalink / raw)
  To: Juri Linkov; +Cc: David Koppelman, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1168 bytes --]

On 6/16/08, Juri Linkov <juri@jurta.org> wrote:
>
> >>>> I think the key `C-x w' by its mnemonics would be more suitable for
> >>>> a command that writes to the file like `C-x C-w'.
> >>>>
> >>>> As the comment in hi-lock.el suggests to bind it rather to `C-z h',
> >>> I just want the key binding to be the same as I use outside of isearch.
> >>>
> >>> There were no global binding for `occur' so in that case I thought
> >>> `M-s o' was good, but in this case I would really prefer the same
> >>> binding inside isearch.
> >>
> >> `C-x w h' is not available until hi-lock.el is loaded, but `M-s h'
> >> is the pretty harmless and convenient key binding to keep the
> >> isearch highlighting permanent in the entire buffer.
> >
> > Yes, but I suggested adding `C-x w h' to global-map too. Is there any
> > reason not to do that? (It is useful, not dangerous and the binding seems
> > to be reserved.)
>
> I think it is better to reserve the global `C-x w' for more
> mnemonic commands (e.g. "write" or "window"), and rebind hi-lock
> keys to the search specific prefix key.


That idea seems good to me as long as a key for highlight-regexp is defined
in global-map.

[-- Attachment #2: Type: text/html, Size: 1679 bytes --]

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-15 20:48           ` Juri Linkov
  2008-06-15 21:10             ` Lennart Borgman (gmail)
@ 2008-06-16 18:50             ` David Koppelman
  2008-06-16 19:08               ` Lennart Borgman (gmail)
  2008-06-16 21:50               ` Juri Linkov
  2008-06-28 22:02             ` Yanking isearch to highlight-regexp Juri Linkov
  2 siblings, 2 replies; 64+ messages in thread
From: David Koppelman @ 2008-06-16 18:50 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Lennart Borgman (gmail), emacs-devel

I like the idea of combining regexp histories, but we might want to be
careful. I can see sharing patterns between hi-lock and occur because
they are used for locating things, but isearch patterns are used for
navigation and so might contain many regexps matching little pieces of
text that only occasionally would make good highlight targets.

I'd suggest having a shared history for occur and hi-lock with a few
recent isearch targets mixed in.



Juri Linkov <juri@jurta.org> writes:

> As for the separate case of running `highlight-regexp' after isearch is
> finished, I suggest using the same default values as already provided by
> `occur-read-primary-args' and `keep-lines-read-args' that collect a list
> of useful regexps from different places including the last isearch string
> and put them to the list of default values.
>
> This also suggests to get rid of `hi-lock-regexp-history' in favor of
> the single regexp history variable `regexp-history' shared among all
> regexp-reading commands (perhaps `keep-lines-read-args' should be
> renamed to more general name like `read-regexp').
>




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-16 18:50             ` David Koppelman
@ 2008-06-16 19:08               ` Lennart Borgman (gmail)
  2008-06-16 21:50               ` Juri Linkov
  1 sibling, 0 replies; 64+ messages in thread
From: Lennart Borgman (gmail) @ 2008-06-16 19:08 UTC (permalink / raw)
  To: David Koppelman; +Cc: Juri Linkov, emacs-devel

David Koppelman wrote:
> I like the idea of combining regexp histories, but we might want to be
> careful. I can see sharing patterns between hi-lock and occur because
> they are used for locating things, but isearch patterns are used for
> navigation and so might contain many regexps matching little pieces of
> text that only occasionally would make good highlight targets.
> 
> I'd suggest having a shared history for occur and hi-lock with a few
> recent isearch targets mixed in.


I am not sure but I think it does not matter that much for hi-lock and 
occur if the history is a bit longer since they are used more seldom.

So I think it would be better to have one history list for all three by 
defaults. How is it done now, is there a variable telling which history 
list to use for each of these three cases?




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-16 11:13                     ` Lennart Borgman
@ 2008-06-16 21:48                       ` Juri Linkov
  0 siblings, 0 replies; 64+ messages in thread
From: Juri Linkov @ 2008-06-16 21:48 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: David Koppelman, emacs-devel

>> >>>> I think the key `C-x w' by its mnemonics would be more suitable for
>> >>>> a command that writes to the file like `C-x C-w'.
>> >>>>
>> >>>> As the comment in hi-lock.el suggests to bind it rather to `C-z h',
>> >>> I just want the key binding to be the same as I use outside of isearch.
>> >>>
>> >>> There were no global binding for `occur' so in that case I thought
>> >>> `M-s o' was good, but in this case I would really prefer the same
>> >>> binding inside isearch.
>> >>
>> >> `C-x w h' is not available until hi-lock.el is loaded, but `M-s h'
>> >> is the pretty harmless and convenient key binding to keep the
>> >> isearch highlighting permanent in the entire buffer.
>> >
>> > Yes, but I suggested adding `C-x w h' to global-map too. Is there any
>> > reason not to do that? (It is useful, not dangerous and the binding seems
>> > to be reserved.)
>>
>> I think it is better to reserve the global `C-x w' for more
>> mnemonic commands (e.g. "write" or "window"), and rebind hi-lock
>> keys to the search specific prefix key.
>
> That idea seems good to me as long as a key for highlight-regexp is defined
> in global-map.

M-s is the ideal prefix key for search related commands in the global map.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-16 18:50             ` David Koppelman
  2008-06-16 19:08               ` Lennart Borgman (gmail)
@ 2008-06-16 21:50               ` Juri Linkov
  2008-06-17 18:50                 ` David Koppelman
  1 sibling, 1 reply; 64+ messages in thread
From: Juri Linkov @ 2008-06-16 21:50 UTC (permalink / raw)
  To: David Koppelman; +Cc: Lennart Borgman (gmail), emacs-devel

> I like the idea of combining regexp histories, but we might want to be
> careful. I can see sharing patterns between hi-lock and occur because
> they are used for locating things, but isearch patterns are used for
> navigation and so might contain many regexps matching little pieces of
> text that only occasionally would make good highlight targets.

Isearch doesn't add regexps to the regexp history for the good reason,
and I don't propose to do this anyway.  What I propose is to add the
last isearch string to the list of default values available in the
minibuffer by typing M-n (not history values available by M-p).
And Lennart proposed also to put the last isearch string to the
minibuffer's initial input if the last command was isearch-other-control-char.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-16 21:50               ` Juri Linkov
@ 2008-06-17 18:50                 ` David Koppelman
  2008-06-24 23:09                   ` Juri Linkov
  0 siblings, 1 reply; 64+ messages in thread
From: David Koppelman @ 2008-06-17 18:50 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Lennart Borgman (gmail), emacs-devel

That sounds good.

Juri Linkov <juri@jurta.org> writes:

>> I like the idea of combining regexp histories, but we might want to be
>> careful. I can see sharing patterns between hi-lock and occur because
>> they are used for locating things, but isearch patterns are used for
>> navigation and so might contain many regexps matching little pieces of
>> text that only occasionally would make good highlight targets.
>
> Isearch doesn't add regexps to the regexp history for the good reason,
> and I don't propose to do this anyway.  What I propose is to add the
> last isearch string to the list of default values available in the
> minibuffer by typing M-n (not history values available by M-p).
> And Lennart proposed also to put the last isearch string to the
> minibuffer's initial input if the last command was isearch-other-control-char.




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-17 18:50                 ` David Koppelman
@ 2008-06-24 23:09                   ` Juri Linkov
  2008-06-25  1:43                     ` Stefan Monnier
  0 siblings, 1 reply; 64+ messages in thread
From: Juri Linkov @ 2008-06-24 23:09 UTC (permalink / raw)
  To: David Koppelman; +Cc: Lennart Borgman (gmail), emacs-devel

> 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)))
+ 
  \f
  (defun isearch-delete-char ()
    "Discard last input item and move point back.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-24 23:09                   ` Juri Linkov
@ 2008-06-25  1:43                     ` Stefan Monnier
  2008-06-25 20:32                       ` Juri Linkov
  0 siblings, 1 reply; 64+ messages in thread
From: Stefan Monnier @ 2008-06-25  1:43 UTC (permalink / raw)
  To: Juri Linkov; +Cc: David Koppelman, Lennart Borgman (gmail), emacs-devel

> 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"?

Yes, a `search-map' sounds better.


        Stefan




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-25  1:43                     ` Stefan Monnier
@ 2008-06-25 20:32                       ` Juri Linkov
  2008-06-25 22:16                         ` Miles Bader
  0 siblings, 1 reply; 64+ messages in thread
From: Juri Linkov @ 2008-06-25 20:32 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: David Koppelman, Lennart Borgman (gmail), emacs-devel

>> 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"?
>
> Yes, a `search-map' sounds better.

Done.  I also created a new keymap `goto-map' for `goto-line' and other
related command on the `M-g' prefix.

I see bindings.el has other candidates for dedicated keymaps like
recently discussed `C-x n' for narrow-related command, and also
`C-x r' for register commands, `C-x a' for abbrev commands.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-25 20:32                       ` Juri Linkov
@ 2008-06-25 22:16                         ` Miles Bader
  2008-06-25 22:22                           ` Lennart Borgman (gmail)
  2008-06-27 23:15                           ` Global keymaps [was: Yanking isearch to highlight-regexp] Juri Linkov
  0 siblings, 2 replies; 64+ messages in thread
From: Miles Bader @ 2008-06-25 22:16 UTC (permalink / raw)
  To: Juri Linkov
  Cc: David Koppelman, Lennart Borgman (gmail), Stefan Monnier,
	emacs-devel

Juri Linkov <juri@jurta.org> writes:
> I see bindings.el has other candidates for dedicated keymaps like
> recently discussed `C-x n' for narrow-related command, and also
> `C-x r' for register commands, `C-x a' for abbrev commands.

Tho C-x r is a bit of a weird puppy, as it's both "register" and
"rectangle" commands (with some overlap).

[Anyone know why there isn't a copy-rectangle command, btw?
I often want one, and copy-rectangle-to-register is annoying.]

-Miles

-- 
Abstainer, n. A weak person who yields to the temptation of denying himself a
pleasure. A total abstainer is one who abstains from everything but
abstention, and especially from inactivity in the affairs of others.




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-25 22:16                         ` Miles Bader
@ 2008-06-25 22:22                           ` Lennart Borgman (gmail)
  2008-06-25 22:58                             ` Miles Bader
  2008-06-27 23:15                           ` Global keymaps [was: Yanking isearch to highlight-regexp] Juri Linkov
  1 sibling, 1 reply; 64+ messages in thread
From: Lennart Borgman (gmail) @ 2008-06-25 22:22 UTC (permalink / raw)
  To: Miles Bader; +Cc: Juri Linkov, David Koppelman, Stefan Monnier, emacs-devel

Miles Bader wrote:
> [Anyone know why there isn't a copy-rectangle command, btw?
> I often want one, and copy-rectangle-to-register is annoying.]

I have just used it a few times, but I have got the impression that the 
best rectangle commands are in cua-mode. There you can copy a rectangle 
with the usual copying/cutting commands in cua-mode (ie C-c/C-x).





^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-25 22:22                           ` Lennart Borgman (gmail)
@ 2008-06-25 22:58                             ` Miles Bader
  0 siblings, 0 replies; 64+ messages in thread
From: Miles Bader @ 2008-06-25 22:58 UTC (permalink / raw)
  To: Lennart Borgman (gmail)
  Cc: Juri Linkov, David Koppelman, Stefan Monnier, emacs-devel

"Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:
>> [Anyone know why there isn't a copy-rectangle command, btw?
>> I often want one, and copy-rectangle-to-register is annoying.]
>
> I have just used it a few times, but I have got the impression that the
> best rectangle commands are in cua-mode. There you can copy a rectangle
> with the usual copying/cutting commands in cua-mode (ie C-c/C-x).

I'm not about to start using CUA mode to get rectangle commands...

-Miles

-- 
Zeal, n. A certain nervous disorder afflicting the young and inexperienced.




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Global keymaps [was: Yanking isearch to highlight-regexp]
  2008-06-25 22:16                         ` Miles Bader
  2008-06-25 22:22                           ` Lennart Borgman (gmail)
@ 2008-06-27 23:15                           ` Juri Linkov
  2008-06-27 23:20                             ` Lennart Borgman (gmail)
  2008-06-28  0:28                             ` Global keymaps Miles Bader
  1 sibling, 2 replies; 64+ messages in thread
From: Juri Linkov @ 2008-06-27 23:15 UTC (permalink / raw)
  To: Miles Bader; +Cc: Stefan Monnier, emacs-devel

>> I see bindings.el has other candidates for dedicated keymaps like
>> recently discussed `C-x n' for narrow-related command, and also
>> `C-x r' for register commands, `C-x a' for abbrev commands.
>
> Tho C-x r is a bit of a weird puppy, as it's both "register" and
> "rectangle" commands (with some overlap).

Then we can use the same naming convention as for C-x 4 and C-x 5 maps:

    ctl-x-4-map - keymap for subcommands of C-x 4
    ctl-x-5-map - keymap for frame commands

Such names don't restrict the map to commands of only one feature.

By analogy, we could have:

    ctl-x-a-map - keymap for abbreviation commands
    ctl-x-n-map - keymap for narrowing commands
    ctl-x-r-map - keymap for register/rectangle subcommands of C-x r
    esc-g-map   - keymap for navigation subcommands of M-g
    etc.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Global keymaps [was: Yanking isearch to highlight-regexp]
  2008-06-27 23:15                           ` Global keymaps [was: Yanking isearch to highlight-regexp] Juri Linkov
@ 2008-06-27 23:20                             ` Lennart Borgman (gmail)
  2008-06-27 23:32                               ` Juri Linkov
  2008-06-28  0:28                             ` Global keymaps Miles Bader
  1 sibling, 1 reply; 64+ messages in thread
From: Lennart Borgman (gmail) @ 2008-06-27 23:20 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel, Stefan Monnier, Miles Bader

Juri Linkov wrote:
>     esc-g-map   - keymap for navigation subcommands of M-g

I like those, but please call this meta-g-map. Escape can not always be 
used.




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Global keymaps [was: Yanking isearch to highlight-regexp]
  2008-06-27 23:20                             ` Lennart Borgman (gmail)
@ 2008-06-27 23:32                               ` Juri Linkov
  0 siblings, 0 replies; 64+ messages in thread
From: Juri Linkov @ 2008-06-27 23:32 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: emacs-devel, Stefan Monnier, Miles Bader

>>     esc-g-map   - keymap for navigation subcommands of M-g
>
> I like those, but please call this meta-g-map. Escape can not always
> be used.

This is just a name, and we already have `esc-map'.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Global keymaps
  2008-06-27 23:15                           ` Global keymaps [was: Yanking isearch to highlight-regexp] Juri Linkov
  2008-06-27 23:20                             ` Lennart Borgman (gmail)
@ 2008-06-28  0:28                             ` Miles Bader
  2008-06-28  1:25                               ` Stefan Monnier
  2008-06-28 19:45                               ` Juri Linkov
  1 sibling, 2 replies; 64+ messages in thread
From: Miles Bader @ 2008-06-28  0:28 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Stefan Monnier, emacs-devel

Juri Linkov <juri@jurta.org> writes:
>> Tho C-x r is a bit of a weird puppy, as it's both "register" and
>> "rectangle" commands (with some overlap).
>
> Then we can use the same naming convention as for C-x 4 and C-x 5 maps:
>
>     ctl-x-4-map - keymap for subcommands of C-x 4
>     ctl-x-5-map - keymap for frame commands
>
> Such names don't restrict the map to commands of only one feature.
>
> By analogy, we could have:
>
>     ctl-x-a-map - keymap for abbreviation commands
>     ctl-x-n-map - keymap for narrowing commands
>     ctl-x-r-map - keymap for register/rectangle subcommands of C-x r
>     esc-g-map   - keymap for navigation subcommands of M-g

That's a bad naming convention, we shouldn't copy it if it's possible to
do better.  If keymaps have a coherent meaning associated with the, we
should use it.

So, "narrowing-map" and "goto-map" are pretty good.

For the rectangle/register map, well, it's an ugly case, but
"rect-reg-map" more or less tells the story.

-Miles

-- 
Barometer, n. An ingenious instrument which indicates what kind of weather we
are having.




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Global keymaps
  2008-06-28  0:28                             ` Global keymaps Miles Bader
@ 2008-06-28  1:25                               ` Stefan Monnier
  2008-06-28 19:45                               ` Juri Linkov
  1 sibling, 0 replies; 64+ messages in thread
From: Stefan Monnier @ 2008-06-28  1:25 UTC (permalink / raw)
  To: Miles Bader; +Cc: Juri Linkov, emacs-devel

>> ctl-x-a-map - keymap for abbreviation commands
>> ctl-x-n-map - keymap for narrowing commands
>> ctl-x-r-map - keymap for register/rectangle subcommands of C-x r
>> esc-g-map   - keymap for navigation subcommands of M-g

> That's a bad naming convention, we shouldn't copy it if it's possible to
> do better.  If keymaps have a coherent meaning associated with the, we
> should use it.

Agreed.

> So, "narrowing-map" and "goto-map" are pretty good.

> For the rectangle/register map, well, it's an ugly case, but
> "rect-reg-map" more or less tells the story.

ctl-x-r-map would work as well, tho.


        Stefan




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Global keymaps
  2008-06-28  0:28                             ` Global keymaps Miles Bader
  2008-06-28  1:25                               ` Stefan Monnier
@ 2008-06-28 19:45                               ` Juri Linkov
  2008-06-28 22:51                                 ` Stefan Monnier
  1 sibling, 1 reply; 64+ messages in thread
From: Juri Linkov @ 2008-06-28 19:45 UTC (permalink / raw)
  To: Miles Bader; +Cc: Stefan Monnier, emacs-devel

>> Then we can use the same naming convention as for C-x 4 and C-x 5 maps:
>>
>>     ctl-x-4-map - keymap for subcommands of C-x 4
>>     ctl-x-5-map - keymap for frame commands
>>
>> Such names don't restrict the map to commands of only one feature.
>>
>> By analogy, we could have:
>>
>>     ctl-x-a-map - keymap for abbreviation commands
>>     ctl-x-n-map - keymap for narrowing commands
>>     ctl-x-r-map - keymap for register/rectangle subcommands of C-x r
>>     esc-g-map   - keymap for navigation subcommands of M-g
>
> That's a bad naming convention, we shouldn't copy it if it's possible to
> do better.  If keymaps have a coherent meaning associated with the, we
> should use it.
>
> So, "narrowing-map" and "goto-map" are pretty good.
>
> For the rectangle/register map, well, it's an ugly case, but
> "rect-reg-map" more or less tells the story.

A name like `ctl-x-n-map' is not descriptive indeed, but at least it
doesn't limit the keymap to one particular functionality, and keeps
it open for further unrelated bindings.  Since we already very tight
on available keys, who knows what commands we will need in future on
these keymaps especially if they will have unrelated but good mnemonics.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-15 20:48           ` Juri Linkov
  2008-06-15 21:10             ` Lennart Borgman (gmail)
  2008-06-16 18:50             ` David Koppelman
@ 2008-06-28 22:02             ` Juri Linkov
  2008-06-28 22:23               ` Stefan Monnier
  2 siblings, 1 reply; 64+ messages in thread
From: Juri Linkov @ 2008-06-28 22:02 UTC (permalink / raw)
  To: emacs-devel

Below is a patch that unifies two similar regexp-reading functions
`keep-lines-read-args' and `occur-read-primary-args' into the general
function `read-regexp'.  It reads a regexp using the regexp history
and provides some useful defaults.  Like `keep-lines-read-args'
it accepts the prompt as its argument, but without the trailing colon
to be able to add the default value in parentheses.

But now the prompt for `keep-lines' doesn't look nice since
it displays parentheses twice as:

  Keep lines (containing match for regexp) (default regexp): 

maybe a better format would be:

  Keep lines, containing match for regexp (default regexp): 

This new function could be used later in other packages like hi-lock.

Index: lisp/replace.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/replace.el,v
retrieving revision 1.272
diff -c -r1.272 replace.el
*** lisp/replace.el	6 Jun 2008 20:32:11 -0000	1.272
--- lisp/replace.el	28 Jun 2008 22:00:32 -0000
***************
*** 522,527 ****
--- 522,559 ----
  Maximum length of the history list is determined by the value
  of `history-length', which see.")
  
+ (defun read-regexp (prompt)
+   "Read regexp as a string using the regexp history and some useful defaults.
+ Prompt for a regular expression with PROMPT.  Provide the last element
+ of the regexp history as the basic default, and return it on typing RET.
+ Additional defaults are the string under point, the last search regexp,
+ the last search string, and the last replacement regexp.
+ Return the regexp as a string."
+   (let* ((default (car regexp-history))
+ 	 (defaults
+ 	   (list (regexp-quote
+ 		  (or (funcall (or find-tag-default-function
+ 				   (get major-mode 'find-tag-default-function)
+ 				   'find-tag-default))
+ 		      ""))
+ 		 (car regexp-search-ring)
+ 		 (regexp-quote (or (car search-ring) ""))
+ 		 (car (symbol-value
+ 		       query-replace-from-history-variable))))
+ 	 (defaults (delete-dups (delq nil (delete "" defaults))))
+ 	 ;; Don't add automatically the car of defaults for empty input
+ 	 (history-add-new-input nil)
+ 	 (input
+ 	  (read-from-minibuffer
+ 	   (if default
+ 	       (format "%s (default %s): " prompt (query-replace-descr default))
+ 	     (format "%s: " prompt))
+ 	   nil nil nil 'regexp-history defaults t)))
+     (if (equal input "")
+ 	default
+       (prog1 input
+ 	(add-to-history 'regexp-history input)))))
+ 
  
  (defalias 'delete-non-matching-lines 'keep-lines)
  (defalias 'delete-matching-lines 'flush-lines)
***************
*** 532,551 ****
    "Read arguments for `keep-lines' and friends.
  Prompt for a regexp with PROMPT.
  Value is a list, (REGEXP)."
!   (let* ((default (list
! 		   (regexp-quote
! 		    (or (funcall (or find-tag-default-function
! 				     (get major-mode 'find-tag-default-function)
! 				     'find-tag-default))
! 			""))
! 		   (car regexp-search-ring)
! 		   (regexp-quote (or (car search-ring) ""))
! 		   (car (symbol-value
! 			 query-replace-from-history-variable))))
! 	 (default (delete-dups (delq nil (delete "" default)))))
!     (list (read-from-minibuffer prompt nil nil nil
! 				'regexp-history default t)
! 	  nil nil t)))
  
  (defun keep-lines (regexp &optional rstart rend interactive)
    "Delete all lines except those containing matches for REGEXP.
--- 564,570 ----
    "Read arguments for `keep-lines' and friends.
  Prompt for a regexp with PROMPT.
  Value is a list, (REGEXP)."
!   (list (read-regexp prompt) nil nil t))
  
  (defun keep-lines (regexp &optional rstart rend interactive)
    "Delete all lines except those containing matches for REGEXP.
***************
*** 574,580 ****
    (interactive
     (progn
       (barf-if-buffer-read-only)
!      (keep-lines-read-args "Keep lines (containing match for regexp): ")))
    (if rstart
        (progn
  	(goto-char (min rstart rend))
--- 593,599 ----
    (interactive
     (progn
       (barf-if-buffer-read-only)
!      (keep-lines-read-args "Keep lines (containing match for regexp)")))
    (if rstart
        (progn
  	(goto-char (min rstart rend))
***************
*** 649,655 ****
    (interactive
     (progn
       (barf-if-buffer-read-only)
!      (keep-lines-read-args "Flush lines (containing match for regexp): ")))
    (if rstart
        (progn
  	(goto-char (min rstart rend))
--- 668,674 ----
    (interactive
     (progn
       (barf-if-buffer-read-only)
!      (keep-lines-read-args "Flush lines (containing match for regexp)")))
    (if rstart
        (progn
  	(goto-char (min rstart rend))
***************
*** 695,701 ****
  a previously found match."
  
    (interactive
!    (keep-lines-read-args "How many matches for (regexp): "))
    (save-excursion
      (if rstart
  	(progn
--- 714,720 ----
  a previously found match."
  
    (interactive
!    (keep-lines-read-args "How many matches for (regexp)"))
    (save-excursion
      (if rstart
  	(progn
***************
*** 1003,1040 ****
        (nreverse result))))
  
  (defun occur-read-primary-args ()
!   (let* ((default (car regexp-history))
! 	 (defaults
! 	   (list (and transient-mark-mode mark-active
! 		      (regexp-quote
! 		       (buffer-substring-no-properties
! 			(region-beginning) (region-end))))
! 		 (regexp-quote
! 		  (or (funcall
! 		       (or find-tag-default-function
! 			   (get major-mode 'find-tag-default-function)
! 			   'find-tag-default))
! 		      ""))
! 		 (car regexp-search-ring)
! 		 (regexp-quote (or (car search-ring) ""))
! 		 (car (symbol-value
! 		       query-replace-from-history-variable))))
! 	 (defaults (delete-dups (delq nil (delete "" defaults))))
! 	 ;; Don't add automatically the car of defaults for empty input
! 	 (history-add-new-input nil)
! 	 (input
! 	  (read-from-minibuffer
! 	   (if default
! 	       (format "List lines matching regexp (default %s): "
! 		       (query-replace-descr default))
! 	     "List lines matching regexp: ")
! 	   nil nil nil 'regexp-history defaults)))
!     (list (if (equal input "")
! 	      default
! 	    (prog1 input
! 	      (add-to-history 'regexp-history input)))
! 	  (when current-prefix-arg
! 	    (prefix-numeric-value current-prefix-arg)))))
  
  (defun occur-rename-buffer (&optional unique-p interactive-p)
    "Rename the current *Occur* buffer to *Occur: original-buffer-name*.
--- 1022,1030 ----
        (nreverse result))))
  
  (defun occur-read-primary-args ()
!   (list (read-regexp "List lines matching regexp")
! 	(when current-prefix-arg
! 	  (prefix-numeric-value current-prefix-arg))))
  
  (defun occur-rename-buffer (&optional unique-p interactive-p)
    "Rename the current *Occur* buffer to *Occur: original-buffer-name*.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-28 22:02             ` Yanking isearch to highlight-regexp Juri Linkov
@ 2008-06-28 22:23               ` Stefan Monnier
  2008-06-29 16:19                 ` Juri Linkov
  0 siblings, 1 reply; 64+ messages in thread
From: Stefan Monnier @ 2008-06-28 22:23 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel

> Below is a patch that unifies two similar regexp-reading functions
> `keep-lines-read-args' and `occur-read-primary-args' into the general
> function `read-regexp'.  It reads a regexp using the regexp history
> and provides some useful defaults.  Like `keep-lines-read-args'
> it accepts the prompt as its argument, but without the trailing colon
> to be able to add the default value in parentheses.

Sounds good.

> But now the prompt for `keep-lines' doesn't look nice since
> it displays parentheses twice as:

>   Keep lines (containing match for regexp) (default regexp): 

> maybe a better format would be:

>   Keep lines, containing match for regexp (default regexp): 

Yes, that's better, tho I'd even drop the comma.


        Stefan




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Global keymaps
  2008-06-28 19:45                               ` Juri Linkov
@ 2008-06-28 22:51                                 ` Stefan Monnier
  2008-06-29 16:17                                   ` Juri Linkov
  0 siblings, 1 reply; 64+ messages in thread
From: Stefan Monnier @ 2008-06-28 22:51 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel, Miles Bader

> A name like `ctl-x-n-map' is not descriptive indeed, but at least it
> doesn't limit the keymap to one particular functionality, and keeps
> it open for further unrelated bindings.  Since we already very tight
> on available keys, who knows what commands we will need in future on
> these keymaps especially if they will have unrelated but good mnemonics.

Hopefully, by the time we bump into this problem, we'll have multiple
inheritance for keymaps, so we can just define ctl-x-n-map to be a map
that inherits from narrow-map and from the-other-n-thing-map.


        Stefan




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Global keymaps
  2008-06-28 22:51                                 ` Stefan Monnier
@ 2008-06-29 16:17                                   ` Juri Linkov
  2008-06-29 18:03                                     ` Stefan Monnier
  0 siblings, 1 reply; 64+ messages in thread
From: Juri Linkov @ 2008-06-29 16:17 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel, Miles Bader

>> A name like `ctl-x-n-map' is not descriptive indeed, but at least it
>> doesn't limit the keymap to one particular functionality, and keeps
>> it open for further unrelated bindings.  Since we already very tight
>> on available keys, who knows what commands we will need in future on
>> these keymaps especially if they will have unrelated but good mnemonics.
>
> Hopefully, by the time we bump into this problem, we'll have multiple
> inheritance for keymaps, so we can just define ctl-x-n-map to be a map
> that inherits from narrow-map and from the-other-n-thing-map.

I'd like to ascertain what could be done now.  In addition
to register and rectangle commands, `C-x r' also includes
keybindings for the bookmark package. So a keymap name like
`register-rectangle-bookmark-and-anything-more-map' clearly
is not an option.  So we need to separate "physical" maps
(bound to physical key sequences) and "logical" maps (like
narrow-map and abbrev-map where keys are grouped by functionality).

The package bookmark.el already defines a map `bookmark-map',
but it is not bound to any key by default.  It also adds
three keys to the `C-x r' prefix as:

  ;;;###autoload (define-key ctl-x-map "rb" 'bookmark-jump)
  ;;;###autoload (define-key ctl-x-map "rm" 'bookmark-set)
  ;;;###autoload (define-key ctl-x-map "rl" 'bookmark-bmenu-list)

So it seems inevitable to create a new map `ctl-x-r-map' and bind
these key to it as:

  ;;;###autoload (define-key ctl-x-r-map "b" 'bookmark-jump)
  ;;;###autoload (define-key ctl-x-r-map "m" 'bookmark-set)
  ;;;###autoload (define-key ctl-x-r-map "l" 'bookmark-bmenu-list)

Alternatively, when multiple inheritance will be available, a keymap
with these three keys could be named as `bookmark-mixin-map' to be
merged with register and rectangle maps in ctl-x-r-map.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-28 22:23               ` Stefan Monnier
@ 2008-06-29 16:19                 ` Juri Linkov
  2008-06-29 18:07                   ` Stefan Monnier
  0 siblings, 1 reply; 64+ messages in thread
From: Juri Linkov @ 2008-06-29 16:19 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: David Koppelman, emacs-devel

>> Below is a patch that unifies two similar regexp-reading functions
>> `keep-lines-read-args' and `occur-read-primary-args' into the general
>> function `read-regexp'.  It reads a regexp using the regexp history
>> and provides some useful defaults.  Like `keep-lines-read-args'
>> it accepts the prompt as its argument, but without the trailing colon
>> to be able to add the default value in parentheses.
>
> Sounds good.

Installed.

Now here is a patch for hi-lock.el that uses `read-regexp'.
It also marks `hi-lock-regexp-history' as an obsolete variable
that is replaced with `regexp-history'.

Another change is renaming `hi-lock-face-history' to
`hi-lock-face-defaults' and putting the face list to the
minibuffer's default list instead of the history list:

Index: lisp/hi-lock.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/hi-lock.el,v
retrieving revision 1.51
diff -c -r1.51 hi-lock.el
*** lisp/hi-lock.el	6 May 2008 07:57:38 -0000	1.51
--- lisp/hi-lock.el	29 Jun 2008 16:11:16 -0000
***************
*** 206,220 ****
  (defvar hi-lock-interactive-patterns nil
    "Patterns provided to hi-lock by user.  Should not be changed.")
  
! (defvar hi-lock-face-history
!   (list "hi-yellow" "hi-pink" "hi-green" "hi-blue" "hi-black-b"
!         "hi-blue-b" "hi-red-b" "hi-green-b" "hi-black-hb")
!       "History list of faces for hi-lock interactive functions.")
! 
! ;(dolist (f hi-lock-face-history) (unless (facep f) (error "%s not a face" f)))
! 
! (defvar hi-lock-regexp-history nil
!   "History of regexps used for interactive fontification.")
  
  (defvar hi-lock-file-patterns-prefix "Hi-lock"
    "Search target for finding hi-lock patterns at top of file.")
--- 206,221 ----
  (defvar hi-lock-interactive-patterns nil
    "Patterns provided to hi-lock by user.  Should not be changed.")
  
! (defvar hi-lock-face-defaults
!   '("hi-yellow" "hi-pink" "hi-green" "hi-blue" "hi-black-b"
!     "hi-blue-b" "hi-red-b" "hi-green-b" "hi-black-hb")
!   "Default faces for hi-lock interactive functions.")
! 
! ;(dolist (f hi-lock-face-defaults) (unless (facep f) (error "%s not a face" f)))
! 
! (define-obsolete-variable-alias 'hi-lock-regexp-history
!                                 'regexp-history
!                                 "23.1")
  
  (defvar hi-lock-file-patterns-prefix "Hi-lock"
    "Search target for finding hi-lock patterns at top of file.")
***************
*** 232,239 ****
  
  (make-variable-buffer-local 'hi-lock-interactive-patterns)
  (put 'hi-lock-interactive-patterns 'permanent-local t)
- (make-variable-buffer-local 'hi-lock-regexp-history)
- (put 'hi-lock-regexp-history 'permanent-local t)
  (make-variable-buffer-local 'hi-lock-file-patterns)
  (put 'hi-lock-file-patterns 'permanent-local t)
  
--- 233,238 ----
***************
*** 390,403 ****
  
  Interactively, prompt for REGEXP then FACE.  Buffer-local history
  list maintained for regexps, global history maintained for faces.
! \\<minibuffer-local-map>Use \\[next-history-element] and \\[previous-history-element] to retrieve next or previous history item.
  \(See info node `Minibuffer History'.)"
    (interactive
     (list
!     (hi-lock-regexp-okay
!      (read-from-minibuffer "Regexp to highlight line: "
!                            (cons (or (car hi-lock-regexp-history) "") 1 )
!                            nil nil 'hi-lock-regexp-history))
      (hi-lock-read-face-name)))
    (or (facep face) (setq face 'hi-yellow))
    (unless hi-lock-mode (hi-lock-mode 1))
--- 389,400 ----
  
  Interactively, prompt for REGEXP then FACE.  Buffer-local history
  list maintained for regexps, global history maintained for faces.
! \\<minibuffer-local-map>Use \\[previous-history-element] to retrieve previous history items,
! and \\[next-history-element] to retrieve default values.
  \(See info node `Minibuffer History'.)"
    (interactive
     (list
!     (hi-lock-regexp-okay (read-regexp "Regexp to highlight line"))
      (hi-lock-read-face-name)))
    (or (facep face) (setq face 'hi-yellow))
    (unless hi-lock-mode (hi-lock-mode 1))
***************
*** 415,428 ****
  
  Interactively, prompt for REGEXP then FACE.  Buffer-local history
  list maintained for regexps, global history maintained for faces.
! \\<minibuffer-local-map>Use \\[next-history-element] and \\[previous-history-element] to retrieve next or previous history item.
  \(See info node `Minibuffer History'.)"
    (interactive
     (list
!     (hi-lock-regexp-okay
!      (read-from-minibuffer "Regexp to highlight: "
!                            (cons (or (car hi-lock-regexp-history) "") 1 )
!                            nil nil 'hi-lock-regexp-history))
      (hi-lock-read-face-name)))
    (or (facep face) (setq face 'hi-yellow))
    (unless hi-lock-mode (hi-lock-mode 1))
--- 412,423 ----
  
  Interactively, prompt for REGEXP then FACE.  Buffer-local history
  list maintained for regexps, global history maintained for faces.
! \\<minibuffer-local-map>Use \\[previous-history-element] to retrieve previous history items,
! and \\[next-history-element] to retrieve default values.
  \(See info node `Minibuffer History'.)"
    (interactive
     (list
!     (hi-lock-regexp-okay (read-regexp "Regexp to highlight"))
      (hi-lock-read-face-name)))
    (or (facep face) (setq face 'hi-yellow))
    (unless hi-lock-mode (hi-lock-mode 1))
***************
*** 440,448 ****
     (list
      (hi-lock-regexp-okay
       (hi-lock-process-phrase
!       (read-from-minibuffer "Phrase to highlight: "
!                             (cons (or (car hi-lock-regexp-history) "") 1 )
!                             nil nil 'hi-lock-regexp-history)))
      (hi-lock-read-face-name)))
    (or (facep face) (setq face 'hi-yellow))
    (unless hi-lock-mode (hi-lock-mode 1))
--- 435,441 ----
     (list
      (hi-lock-regexp-okay
       (hi-lock-process-phrase
!       (read-regexp "Phrase to highlight")))
      (hi-lock-read-face-name)))
    (or (facep face) (setq face 'hi-yellow))
    (unless hi-lock-mode (hi-lock-mode 1))
***************
*** 457,463 ****
  Interactively, prompt for REGEXP.  Buffer-local history of inserted
  regexp's maintained.  Will accept only regexps inserted by hi-lock
  interactive functions.  \(See `hi-lock-interactive-patterns'.\)
! \\<minibuffer-local-must-match-map>Use \\[minibuffer-complete] to complete a partially typed regexp.
  \(See info node `Minibuffer History'.\)"
    (interactive
     (if (and (display-popup-menus-p) (not last-nonmenu-event))
--- 450,457 ----
  Interactively, prompt for REGEXP.  Buffer-local history of inserted
  regexp's maintained.  Will accept only regexps inserted by hi-lock
  interactive functions.  \(See `hi-lock-interactive-patterns'.\)
! \\<minibuffer-local-map>Use \\[previous-history-element] to retrieve previous history items,
! and \\[next-history-element] to retrieve default values.
  \(See info node `Minibuffer History'.\)"
    (interactive
     (if (and (display-popup-menus-p) (not last-nonmenu-event))
***************
*** 552,567 ****
    (intern (completing-read
             "Highlight using face: "
             obarray 'facep t
!            (cons (car hi-lock-face-history)
                   (let ((prefix
                          (try-completion
!                          (substring (car hi-lock-face-history) 0 1)
                           (mapcar (lambda (f) (cons f f))
!                                  hi-lock-face-history))))
                     (if (and (stringp prefix)
!                             (not (equal prefix (car hi-lock-face-history))))
                         (length prefix) 0)))
!            '(hi-lock-face-history . 0))))
  
  (defun hi-lock-set-pattern (regexp face)
    "Highlight REGEXP with face FACE."
--- 546,561 ----
    (intern (completing-read
             "Highlight using face: "
             obarray 'facep t
!            (cons (car hi-lock-face-defaults)
                   (let ((prefix
                          (try-completion
!                          (substring (car hi-lock-face-defaults) 0 1)
                           (mapcar (lambda (f) (cons f f))
!                                  hi-lock-face-defaults))))
                     (if (and (stringp prefix)
!                             (not (equal prefix (car hi-lock-face-defaults))))
                         (length prefix) 0)))
!            nil (cdr hi-lock-face-defaults))))
  
  (defun hi-lock-set-pattern (regexp face)
    "Highlight REGEXP with face FACE."

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Global keymaps
  2008-06-29 16:17                                   ` Juri Linkov
@ 2008-06-29 18:03                                     ` Stefan Monnier
  2008-06-29 19:28                                       ` Juri Linkov
  0 siblings, 1 reply; 64+ messages in thread
From: Stefan Monnier @ 2008-06-29 18:03 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel, Miles Bader

>>> A name like `ctl-x-n-map' is not descriptive indeed, but at least it
>>> doesn't limit the keymap to one particular functionality, and keeps
>>> it open for further unrelated bindings.  Since we already very tight
>>> on available keys, who knows what commands we will need in future on
>>> these keymaps especially if they will have unrelated but good mnemonics.
>> 
>> Hopefully, by the time we bump into this problem, we'll have multiple
>> inheritance for keymaps, so we can just define ctl-x-n-map to be a map
>> that inherits from narrow-map and from the-other-n-thing-map.

> I'd like to ascertain what could be done now.  In addition
> to register and rectangle commands, `C-x r' also includes
> keybindings for the bookmark package. So a keymap name like
> `register-rectangle-bookmark-and-anything-more-map' clearly
> is not an option.  So we need to separate "physical" maps
> (bound to physical key sequences) and "logical" maps (like
> narrow-map and abbrev-map where keys are grouped by functionality).

> The package bookmark.el already defines a map `bookmark-map',
> but it is not bound to any key by default.  It also adds
> three keys to the `C-x r' prefix as:

>   ;;;###autoload (define-key ctl-x-map "rb" 'bookmark-jump)
>   ;;;###autoload (define-key ctl-x-map "rm" 'bookmark-set)
>   ;;;###autoload (define-key ctl-x-map "rl" 'bookmark-bmenu-list)

> So it seems inevitable to create a new map `ctl-x-r-map' and bind
> these key to it as:

>   ;;;###autoload (define-key ctl-x-r-map "b" 'bookmark-jump)
>   ;;;###autoload (define-key ctl-x-r-map "m" 'bookmark-set)
>   ;;;###autoload (define-key ctl-x-r-map "l" 'bookmark-bmenu-list)

> Alternatively, when multiple inheritance will be available, a keymap
> with these three keys could be named as `bookmark-mixin-map' to be
> merged with register and rectangle maps in ctl-x-r-map.

Yes,


        Stefan




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-29 16:19                 ` Juri Linkov
@ 2008-06-29 18:07                   ` Stefan Monnier
  2008-06-29 19:29                     ` Juri Linkov
  0 siblings, 1 reply; 64+ messages in thread
From: Stefan Monnier @ 2008-06-29 18:07 UTC (permalink / raw)
  To: Juri Linkov; +Cc: David Koppelman, emacs-devel

> Now here is a patch for hi-lock.el that uses `read-regexp'.
> It also marks `hi-lock-regexp-history' as an obsolete variable
> that is replaced with `regexp-history'.

Sounds good.

> Another change is renaming `hi-lock-face-history' to
> `hi-lock-face-defaults' and putting the face list to the
> minibuffer's default list instead of the history list:

Why is that good?

>                           (try-completion
> !                          (substring (car hi-lock-face-history) 0 1)
>                            (mapcar (lambda (f) (cons f f))
> !                                  hi-lock-face-history))))

I believe the "(mapcar (lambda (f) (cons f f))" can be removed, since
try-completion accepts lists of strings since Emacs-21 IIRC.


        Stefan




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Global keymaps
  2008-06-29 18:03                                     ` Stefan Monnier
@ 2008-06-29 19:28                                       ` Juri Linkov
  2008-06-29 20:03                                         ` Stefan Monnier
  0 siblings, 1 reply; 64+ messages in thread
From: Juri Linkov @ 2008-06-29 19:28 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel, Miles Bader

>> The package bookmark.el already defines a map `bookmark-map',
>> but it is not bound to any key by default.  It also adds
>> three keys to the `C-x r' prefix as:
>
>>   ;;;###autoload (define-key ctl-x-map "rb" 'bookmark-jump)
>>   ;;;###autoload (define-key ctl-x-map "rm" 'bookmark-set)
>>   ;;;###autoload (define-key ctl-x-map "rl" 'bookmark-bmenu-list)
>
>> So it seems inevitable to create a new map `ctl-x-r-map' and bind
>> these key to it as:
>
>>   ;;;###autoload (define-key ctl-x-r-map "b" 'bookmark-jump)
>>   ;;;###autoload (define-key ctl-x-r-map "m" 'bookmark-set)
>>   ;;;###autoload (define-key ctl-x-r-map "l" 'bookmark-bmenu-list)
>
>> Alternatively, when multiple inheritance will be available, a keymap
>> with these three keys could be named as `bookmark-mixin-map' to be
>> merged with register and rectangle maps in ctl-x-r-map.
>
> Yes,

Please review the following patch.  It creates a new keymap
ctl-x-r-map, and moves its keybindings to their corresponding
files rect.el and register.el.  The file bookmark.el already
has these autoloads, so this patch just changes ctl-x-map to
ctl-x-r-map in bookmark.el.  It also creates new keymaps
`abbrev-map' and `narrow-map' (it seems this name is better
as an identifier than `narrowing-map'), and rebinds global
keys to these maps.

Index: lisp/bindings.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/bindings.el,v
retrieving revision 1.208
diff -c -r1.208 bindings.el
*** lisp/bindings.el	25 Jun 2008 20:17:07 -0000	1.208
--- lisp/bindings.el	29 Jun 2008 19:27:01 -0000
***************
*** 700,709 ****
  ;These commands are defined in editfns.c
  ;but they are not assigned to keys there.
  (put 'narrow-to-region 'disabled t)
! (define-key ctl-x-map "nn" 'narrow-to-region)
! (define-key ctl-x-map "nw" 'widen)
! ;; (define-key ctl-x-map "n" 'narrow-to-region)
! ;; (define-key ctl-x-map "w" 'widen)
  
  ;; Quitting
  (define-key global-map "\e\e\e" 'keyboard-escape-quit)
--- 700,713 ----
  ;These commands are defined in editfns.c
  ;but they are not assigned to keys there.
  (put 'narrow-to-region 'disabled t)
! 
! (defvar narrow-map (make-sparse-keymap)
!   "Keymap for narrowing commands.")
! (defalias 'narrow-map-prefix narrow-map)
! (define-key ctl-x-map "n" 'narrow-map-prefix)
! 
! (define-key narrow-map "n" 'narrow-to-region)
! (define-key narrow-map "w" 'widen)
  
  ;; Quitting
  (define-key global-map "\e\e\e" 'keyboard-escape-quit)
***************
*** 744,753 ****
  (define-key esc-map "!" 'shell-command)
  (define-key esc-map "|" 'shell-command-on-region)
  
! (define-key global-map [?\C-x right] 'next-buffer)
! (define-key global-map [?\C-x C-right] 'next-buffer)
! (define-key global-map [?\C-x left] 'previous-buffer)
! (define-key global-map [?\C-x C-left] 'previous-buffer)
  
  (let ((map minibuffer-local-map))
    (define-key map "\en"   'next-history-element)
--- 748,757 ----
  (define-key esc-map "!" 'shell-command)
  (define-key esc-map "|" 'shell-command-on-region)
  
! (define-key ctl-x-map [right] 'next-buffer)
! (define-key ctl-x-map [C-right] 'next-buffer)
! (define-key ctl-x-map [left] 'previous-buffer)
! (define-key ctl-x-map [C-left] 'previous-buffer)
  
  (let ((map minibuffer-local-map))
    (define-key map "\en"   'next-history-element)
***************
*** 809,815 ****
  
  (defvar goto-map (make-sparse-keymap)
    "Keymap for navigation commands.")
! (define-key esc-map "g" goto-map)
  
  (define-key goto-map    "g" 'goto-line)
  (define-key goto-map "\M-g" 'goto-line)
--- 813,820 ----
  
  (defvar goto-map (make-sparse-keymap)
    "Keymap for navigation commands.")
! (defalias 'goto-map-prefix goto-map)
! (define-key esc-map "g" 'goto-map-prefix)
  
  (define-key goto-map    "g" 'goto-line)
  (define-key goto-map "\M-g" 'goto-line)
***************
*** 820,826 ****
  
  (defvar search-map (make-sparse-keymap)
    "Keymap for search related commands.")
! (define-key esc-map "s" search-map)
  
  (define-key search-map "o"  'occur)
  (define-key search-map "hr" 'highlight-regexp)
--- 825,832 ----
  
  (defvar search-map (make-sparse-keymap)
    "Keymap for search related commands.")
! (defalias 'search-map-prefix search-map)
! (define-key esc-map "s" 'search-map-prefix)
  
  (define-key search-map "o"  'occur)
  (define-key search-map "hr" 'highlight-regexp)
***************
*** 1089,1113 ****
  (define-key ctl-x-4-map "m" 'compose-mail-other-window)
  (define-key ctl-x-5-map "m" 'compose-mail-other-frame)
  \f
! (define-key ctl-x-map "r\C-@" 'point-to-register)
! (define-key ctl-x-map [?r ?\C-\ ] 'point-to-register)
! (define-key ctl-x-map "r " 'point-to-register)
! (define-key ctl-x-map "rj" 'jump-to-register)
! (define-key ctl-x-map "rs" 'copy-to-register)
! (define-key ctl-x-map "rx" 'copy-to-register)
! (define-key ctl-x-map "ri" 'insert-register)
! (define-key ctl-x-map "rg" 'insert-register)
! (define-key ctl-x-map "rr" 'copy-rectangle-to-register)
! (define-key ctl-x-map "rn" 'number-to-register)
! (define-key ctl-x-map "r+" 'increment-register)
! (define-key ctl-x-map "rc" 'clear-rectangle)
! (define-key ctl-x-map "rk" 'kill-rectangle)
! (define-key ctl-x-map "rd" 'delete-rectangle)
! (define-key ctl-x-map "ry" 'yank-rectangle)
! (define-key ctl-x-map "ro" 'open-rectangle)
! (define-key ctl-x-map "rt" 'string-rectangle)
! (define-key ctl-x-map "rw" 'window-configuration-to-register)
! (define-key ctl-x-map "rf" 'frame-configuration-to-register)
  
  (define-key esc-map "q" 'fill-paragraph)
  (define-key ctl-x-map "." 'set-fill-prefix)
--- 1095,1105 ----
  (define-key ctl-x-4-map "m" 'compose-mail-other-window)
  (define-key ctl-x-5-map "m" 'compose-mail-other-frame)
  \f
! 
! (defvar ctl-x-r-map (make-sparse-keymap)
!   "Keymap for subcommands of C-x r.")
! (defalias 'ctl-x-r-prefix ctl-x-r-map)
! (define-key ctl-x-map "r" 'ctl-x-r-prefix)
  
  (define-key esc-map "q" 'fill-paragraph)
  (define-key ctl-x-map "." 'set-fill-prefix)
***************
*** 1127,1142 ****
  (define-key ctl-x-map "np" 'narrow-to-page)
  ;; (define-key ctl-x-map "p" 'narrow-to-page)
  \f
! (define-key ctl-x-map "al" 'add-mode-abbrev)
! (define-key ctl-x-map "a\C-a" 'add-mode-abbrev)
! (define-key ctl-x-map "ag" 'add-global-abbrev)
! (define-key ctl-x-map "a+" 'add-mode-abbrev)
! (define-key ctl-x-map "aig" 'inverse-add-global-abbrev)
! (define-key ctl-x-map "ail" 'inverse-add-mode-abbrev)
! ;; (define-key ctl-x-map "a\C-h" 'inverse-add-global-abbrev)
! (define-key ctl-x-map "a-" 'inverse-add-global-abbrev)
! (define-key ctl-x-map "ae" 'expand-abbrev)
! (define-key ctl-x-map "a'" 'expand-abbrev)
  ;; (define-key ctl-x-map "\C-a" 'add-mode-abbrev)
  ;; (define-key ctl-x-map "\+" 'add-global-abbrev)
  ;; (define-key ctl-x-map "\C-h" 'inverse-add-mode-abbrev)
--- 1119,1139 ----
  (define-key ctl-x-map "np" 'narrow-to-page)
  ;; (define-key ctl-x-map "p" 'narrow-to-page)
  \f
! (defvar abbrev-map (make-sparse-keymap)
!   "Keymap for abbrev commands.")
! (defalias 'abbrev-map-prefix abbrev-map)
! (define-key ctl-x-map "a" 'abbrev-map-prefix)
! 
! (define-key abbrev-map "l" 'add-mode-abbrev)
! (define-key abbrev-map "\C-a" 'add-mode-abbrev)
! (define-key abbrev-map "g" 'add-global-abbrev)
! (define-key abbrev-map "+" 'add-mode-abbrev)
! (define-key abbrev-map "ig" 'inverse-add-global-abbrev)
! (define-key abbrev-map "il" 'inverse-add-mode-abbrev)
! ;; (define-key abbrev-map "\C-h" 'inverse-add-global-abbrev)
! (define-key abbrev-map "-" 'inverse-add-global-abbrev)
! (define-key abbrev-map "e" 'expand-abbrev)
! (define-key abbrev-map "'" 'expand-abbrev)
  ;; (define-key ctl-x-map "\C-a" 'add-mode-abbrev)
  ;; (define-key ctl-x-map "\+" 'add-global-abbrev)
  ;; (define-key ctl-x-map "\C-h" 'inverse-add-mode-abbrev)

Index: lisp/bookmark.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/bookmark.el,v
retrieving revision 1.114
diff -c -r1.114 bookmark.el
*** lisp/bookmark.el	25 Jun 2008 16:51:32 -0000	1.114
--- lisp/bookmark.el	29 Jun 2008 19:27:14 -0000
***************
*** 217,225 ****
  ;; Set up these bindings dumping time *only*;
  ;; if the user alters them, don't override the user when loading bookmark.el.
  
! ;;;###autoload (define-key ctl-x-map "rb" 'bookmark-jump)
! ;;;###autoload (define-key ctl-x-map "rm" 'bookmark-set)
! ;;;###autoload (define-key ctl-x-map "rl" 'bookmark-bmenu-list)
  
  ;;;###autoload
  (defvar bookmark-map
--- 217,225 ----
  ;; Set up these bindings dumping time *only*;
  ;; if the user alters them, don't override the user when loading bookmark.el.
  
! ;;;###autoload (define-key ctl-x-r-map "b" 'bookmark-jump)
! ;;;###autoload (define-key ctl-x-r-map "m" 'bookmark-set)
! ;;;###autoload (define-key ctl-x-r-map "l" 'bookmark-bmenu-list)
  
  ;;;###autoload
  (defvar bookmark-map

Index: lisp/rect.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/rect.el,v
retrieving revision 1.58
diff -c -r1.58 rect.el
*** lisp/rect.el	6 May 2008 07:57:48 -0000	1.58
--- lisp/rect.el	29 Jun 2008 19:27:18 -0000
***************
*** 31,36 ****
--- 31,44 ----
  ;; intrusive and fill lines with whitespaces only when needed. A few functions
  ;; are untouched though, as noted above their definition.
  
+ ;;; Global key bindings
+ 
+ ;;;###autoload (define-key ctl-x-r-map "c" 'clear-rectangle)
+ ;;;###autoload (define-key ctl-x-r-map "k" 'kill-rectangle)
+ ;;;###autoload (define-key ctl-x-r-map "d" 'delete-rectangle)
+ ;;;###autoload (define-key ctl-x-r-map "y" 'yank-rectangle)
+ ;;;###autoload (define-key ctl-x-r-map "o" 'open-rectangle)
+ ;;;###autoload (define-key ctl-x-r-map "t" 'string-rectangle)
  
  ;;; Code:
  
Index: lisp/register.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/register.el,v
retrieving revision 1.60
diff -c -r1.60 register.el
*** lisp/register.el	6 May 2008 07:57:48 -0000	1.60
--- lisp/register.el	29 Jun 2008 19:27:35 -0000
***************
*** 28,33 ****
--- 28,49 ----
  ;; pieces of buffer state to named variables.  The entry points are
  ;; documented in the Emacs user's manual.
  
+ ;;; Global key bindings
+ 
+ ;;;###autoload (define-key ctl-x-r-map "\C-@" 'point-to-register)
+ ;;;###autoload (define-key ctl-x-r-map [?\C-\ ] 'point-to-register)
+ ;;;###autoload (define-key ctl-x-r-map " " 'point-to-register)
+ ;;;###autoload (define-key ctl-x-r-map "j" 'jump-to-register)
+ ;;;###autoload (define-key ctl-x-r-map "s" 'copy-to-register)
+ ;;;###autoload (define-key ctl-x-r-map "x" 'copy-to-register)
+ ;;;###autoload (define-key ctl-x-r-map "i" 'insert-register)
+ ;;;###autoload (define-key ctl-x-r-map "g" 'insert-register)
+ ;;;###autoload (define-key ctl-x-r-map "r" 'copy-rectangle-to-register)
+ ;;;###autoload (define-key ctl-x-r-map "n" 'number-to-register)
+ ;;;###autoload (define-key ctl-x-r-map "+" 'increment-register)
+ ;;;###autoload (define-key ctl-x-r-map "w" 'window-configuration-to-register)
+ ;;;###autoload (define-key ctl-x-r-map "f" 'frame-configuration-to-register)
+ 
  ;;; Code:
  
  (defvar register-alist nil

Index: lisp/expand.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/expand.el,v
retrieving revision 1.22
diff -c -r1.22 expand.el
*** lisp/expand.el	6 May 2008 07:57:34 -0000	1.22
--- lisp/expand.el	29 Jun 2008 19:27:55 -0000
***************
*** 427,434 ****
  	(goto-char (aref expand-pos expand-index))
  	(run-hooks 'expand-jump-hook))))
  
! ;;;###autoload (define-key ctl-x-map "ap" 'expand-jump-to-previous-slot)
! ;;;###autoload (define-key ctl-x-map "an" 'expand-jump-to-next-slot)
  
  (defun expand-build-list (len l)
    "Build a vector of offset positions from the list of positions."
--- 427,434 ----
  	(goto-char (aref expand-pos expand-index))
  	(run-hooks 'expand-jump-hook))))
  
! ;;;###autoload (define-key abbrev-map "p" 'expand-jump-to-previous-slot)
! ;;;###autoload (define-key abbrev-map "n" 'expand-jump-to-next-slot)
  
  (defun expand-build-list (len l)
    "Build a vector of offset positions from the list of positions."

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-29 18:07                   ` Stefan Monnier
@ 2008-06-29 19:29                     ` Juri Linkov
  2008-06-29 20:05                       ` Stefan Monnier
  0 siblings, 1 reply; 64+ messages in thread
From: Juri Linkov @ 2008-06-29 19:29 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: David Koppelman, emacs-devel

>> Now here is a patch for hi-lock.el that uses `read-regexp'.
>> It also marks `hi-lock-regexp-history' as an obsolete variable
>> that is replaced with `regexp-history'.
>
> Sounds good.
>
>> Another change is renaming `hi-lock-face-history' to
>> `hi-lock-face-defaults' and putting the face list to the
>> minibuffer's default list instead of the history list:
>
> Why is that good?

Because the standard behavior for M-p is to retrieve previous input
from the history list, and M-n to retrieve default values like from
a list of default faces in this case.

However, I think it is inconvenient when face names are mixed with other
input in the default history list `minibuffer-history'.  We could create
a new history list `face-name-history' specially for face names entered
in the face-reading commands.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Global keymaps
  2008-06-29 19:28                                       ` Juri Linkov
@ 2008-06-29 20:03                                         ` Stefan Monnier
  2008-06-29 20:52                                           ` Juri Linkov
  0 siblings, 1 reply; 64+ messages in thread
From: Stefan Monnier @ 2008-06-29 20:03 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel, Miles Bader

> Please review the following patch.  It creates a new keymap

It looks OK, tho I wonder why you introduce all those
foo-map-prefix thingies.  I know such things are already used elsehwere,
but they've never made much sense to me.


        Stefan




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-29 19:29                     ` Juri Linkov
@ 2008-06-29 20:05                       ` Stefan Monnier
  2008-06-29 20:55                         ` Juri Linkov
  0 siblings, 1 reply; 64+ messages in thread
From: Stefan Monnier @ 2008-06-29 20:05 UTC (permalink / raw)
  To: Juri Linkov; +Cc: David Koppelman, emacs-devel

> However, I think it is inconvenient when face names are mixed with other
> input in the default history list `minibuffer-history'.  We could create
> a new history list `face-name-history' specially for face names entered
> in the face-reading commands.

That sounds cleaner, indeed.


        Stefan




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Global keymaps
  2008-06-29 20:03                                         ` Stefan Monnier
@ 2008-06-29 20:52                                           ` Juri Linkov
  2008-06-29 21:24                                             ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 64+ messages in thread
From: Juri Linkov @ 2008-06-29 20:52 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel, Miles Bader

>> Please review the following patch.  It creates a new keymap
>
> It looks OK, tho I wonder why you introduce all those
> foo-map-prefix thingies.  I know such things are already used elsehwere,
> but they've never made much sense to me.

I took them from ctl-x-4-prefix, ctl-x-5-prefix and other similar maps
and don't know what they are good for.  So I could install the patch
without them.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-29 20:05                       ` Stefan Monnier
@ 2008-06-29 20:55                         ` Juri Linkov
  2008-06-30  1:01                           ` Stefan Monnier
  0 siblings, 1 reply; 64+ messages in thread
From: Juri Linkov @ 2008-06-29 20:55 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: David Koppelman, emacs-devel

>> However, I think it is inconvenient when face names are mixed with other
>> input in the default history list `minibuffer-history'.  We could create
>> a new history list `face-name-history' specially for face names entered
>> in the face-reading commands.
>
> That sounds cleaner, indeed.

The following patch creates a new variable `face-name-history' and
adds it to face-reading commands (most important is `read-face-name'
that is used by many other commands).

Index: lisp/faces.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/faces.el,v
retrieving revision 1.416
diff -c -r1.416 faces.el
*** lisp/faces.el	28 Jun 2008 15:53:07 -0000	1.416
--- lisp/faces.el	29 Jun 2008 20:55:34 -0000
***************
*** 31,36 ****
--- 31,42 ----
  (declare-function xw-defined-colors "term/x-win" (&optional frame))
  
  (defvar help-xref-stack-item)
+ 
+ (defvar face-name-history nil
+   "History list for some commands that read face names.
+ Maximum length of the history list is determined by the value
+ of `history-length', which see.")
+ 
  \f
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;; Font selection.
***************
*** 123,129 ****
  variants of FACE from X resources.  (X resources recognized are found
  in the global variable `face-x-resources'.)  If FACE is already known
  as a face, leave it unmodified.  Value is FACE."
!   (interactive "SMake face: ")
    (unless (facep face)
      ;; Make frame-local faces (this also makes the global one).
      (dolist (frame (frame-list))
--- 129,136 ----
  variants of FACE from X resources.  (X resources recognized are found
  in the global variable `face-x-resources'.)  If FACE is already known
  as a face, leave it unmodified.  Value is FACE."
!   (interactive (list (read-from-minibuffer
! 		      "Make face: " nil nil t 'face-name-history)))
    (unless (facep face)
      ;; Make frame-local faces (this also makes the global one).
      (dolist (frame (frame-list))
***************
*** 140,146 ****
  (defun make-empty-face (face)
    "Define a new, empty face with name FACE.
  If the face already exists, it is left unmodified.  Value is FACE."
!   (interactive "SMake empty face: ")
    (make-face face 'no-init-from-resources))
  
  
--- 147,154 ----
  (defun make-empty-face (face)
    "Define a new, empty face with name FACE.
  If the face already exists, it is left unmodified.  Value is FACE."
!   (interactive (list (read-from-minibuffer
! 		      "Make empty face: " nil nil t 'face-name-history)))
    (make-face face 'no-init-from-resources))
  
  
***************
*** 940,946 ****
  			   string-describing-default))
  	       (format "%s: " prompt))
  	     (completion-table-in-turn nonaliasfaces aliasfaces)
! 	     nil t nil nil
  	     (if faces (mapconcat 'symbol-name faces ","))))
  	   ;; Canonicalize the output.
  	   (output
--- 948,954 ----
  			   string-describing-default))
  	       (format "%s: " prompt))
  	     (completion-table-in-turn nonaliasfaces aliasfaces)
! 	     nil t nil 'face-name-history
  	     (if faces (mapconcat 'symbol-name faces ","))))
  	   ;; Canonicalize the output.
  	   (output
***************
*** 1227,1233 ****
  this regular expression.  When called interactively with a prefix
  arg, prompt for a regular expression."
    (interactive (list (and current-prefix-arg
!                           (read-string "List faces matching regexp: "))))
    (let ((all-faces (zerop (length regexp)))
  	(frame (selected-frame))
  	(max-length 0)
--- 1235,1241 ----
  this regular expression.  When called interactively with a prefix
  arg, prompt for a regular expression."
    (interactive (list (and current-prefix-arg
!                           (read-regexp "List faces matching regexp"))))
    (let ((all-faces (zerop (length regexp)))
  	(frame (selected-frame))
  	(max-length 0)

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Global keymaps
  2008-06-29 20:52                                           ` Juri Linkov
@ 2008-06-29 21:24                                             ` Lennart Borgman (gmail)
  2008-06-30  1:00                                               ` Stefan Monnier
  0 siblings, 1 reply; 64+ messages in thread
From: Lennart Borgman (gmail) @ 2008-06-29 21:24 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Miles Bader, Stefan Monnier, emacs-devel

Juri Linkov wrote:
>>> Please review the following patch.  It creates a new keymap
>> It looks OK, tho I wonder why you introduce all those
>> foo-map-prefix thingies.  I know such things are already used elsehwere,
>> but they've never made much sense to me.
> 
> I took them from ctl-x-4-prefix, ctl-x-5-prefix and other similar maps
> and don't know what they are good for.  So I could install the patch
> without them.

I think names like ctl-x-4-prefix could make sense for a user trying to 
add new key bindings.




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Global keymaps
  2008-06-29 21:24                                             ` Lennart Borgman (gmail)
@ 2008-06-30  1:00                                               ` Stefan Monnier
  0 siblings, 0 replies; 64+ messages in thread
From: Stefan Monnier @ 2008-06-30  1:00 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: Juri Linkov, Miles Bader, emacs-devel

>>>> Please review the following patch.  It creates a new keymap
>>> It looks OK, tho I wonder why you introduce all those
>>> foo-map-prefix thingies.  I know such things are already used elsehwere,
>>> but they've never made much sense to me.
>> 
>> I took them from ctl-x-4-prefix, ctl-x-5-prefix and other similar maps
>> and don't know what they are good for.  So I could install the patch
>> without them.

Then please install it without them.

> I think names like ctl-x-4-prefix could make sense for a user trying to add
> new key bindings.

The issue is not the name, but the fact of providing the keymap both as
variables and as functions.


        Stefan




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-29 20:55                         ` Juri Linkov
@ 2008-06-30  1:01                           ` Stefan Monnier
  2008-06-30 19:59                             ` Juri Linkov
  0 siblings, 1 reply; 64+ messages in thread
From: Stefan Monnier @ 2008-06-30  1:01 UTC (permalink / raw)
  To: Juri Linkov; +Cc: David Koppelman, emacs-devel

> The following patch creates a new variable `face-name-history' and
> adds it to face-reading commands (most important is `read-face-name'
> that is used by many other commands).

OK.

> ***************
> *** 1227,1233 ****
>   this regular expression.  When called interactively with a prefix
>   arg, prompt for a regular expression."
>     (interactive (list (and current-prefix-arg
> !                           (read-string "List faces matching regexp: "))))
>     (let ((all-faces (zerop (length regexp)))
>   	(frame (selected-frame))
>   	(max-length 0)
> --- 1235,1241 ----
>   this regular expression.  When called interactively with a prefix
>   arg, prompt for a regular expression."
>     (interactive (list (and current-prefix-arg
> !                           (read-regexp "List faces matching regexp"))))
>     (let ((all-faces (zerop (length regexp)))
>   	(frame (selected-frame))
>   	(max-length 0)

This is part of the other patch, isn't it?


        Stefan




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-30  1:01                           ` Stefan Monnier
@ 2008-06-30 19:59                             ` Juri Linkov
  2008-07-01 21:34                               ` Grep key bindings (was: Yanking isearch to highlight-regexp) Juri Linkov
  2008-07-30 17:49                               ` Yanking isearch to highlight-regexp Juri Linkov
  0 siblings, 2 replies; 64+ messages in thread
From: Juri Linkov @ 2008-06-30 19:59 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: David Koppelman, emacs-devel

>> The following patch creates a new variable `face-name-history' and
>> adds it to face-reading commands (most important is `read-face-name'
>> that is used by many other commands).
>
> OK.

Done.

>> ***************
>> *** 1227,1233 ****
>>   this regular expression.  When called interactively with a prefix
>>   arg, prompt for a regular expression."
>>     (interactive (list (and current-prefix-arg
>> !                           (read-string "List faces matching regexp: "))))
>>     (let ((all-faces (zerop (length regexp)))
>>   	(frame (selected-frame))
>>   	(max-length 0)
>> --- 1235,1241 ----
>>   this regular expression.  When called interactively with a prefix
>>   arg, prompt for a regular expression."
>>     (interactive (list (and current-prefix-arg
>> !                           (read-regexp "List faces matching regexp"))))
>>     (let ((all-faces (zerop (length regexp)))
>>   	(frame (selected-frame))
>>   	(max-length 0)
>
> This is part of the other patch, isn't it?

Yes, this is not related to the face history, but an attempt to use
`read-regexp' where it makes sense.

I now noticed that `read-regexp' doesn't provide backward compatible
behavior for `keep-lines' and other commands.  It puts the last history
element in parens as the default value.  I don't know why users insist
on this behavior for `occur' since the last history is easy available
via M-p.  But at least I propose to keep old and different behavior
for `occur' vs `keep-lines' and friends.

The patch below adds a new argument `default' to `read-regexp'
that is displayed in parens, and in `occur-read-primary-args' sets it
to `(car regexp-history)'.

A slightly different case is hi-lock.  It used to put the last regexp
from the history as initial input.  But since using initial input is
deprecated, this patch also sets the new `default' arg to
`(car regexp-history)' for hi-lock commands as well.

Index: lisp/replace.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/replace.el,v
retrieving revision 1.273
diff -c -r1.273 replace.el
*** lisp/replace.el	29 Jun 2008 16:09:08 -0000	1.273
--- lisp/replace.el	30 Jun 2008 19:54:43 -0000
***************
*** 522,536 ****
  Maximum length of the history list is determined by the value
  of `history-length', which see.")
  
! (defun read-regexp (prompt)
    "Read regexp as a string using the regexp history and some useful defaults.
! Prompt for a regular expression with PROMPT in the minibuffer.
! Provide the last element of the regexp history as the basic default,
! and return it on typing RET.  Additional defaults are the string
! at point, the last isearch regexp, the last isearch string, and the
! last replacement regexp.  Return the regexp as a string."
!   (let* ((default (car regexp-history))
! 	 (defaults
  	   (list (regexp-quote
  		  (or (funcall (or find-tag-default-function
  				   (get major-mode 'find-tag-default-function)
--- 522,535 ----
  Maximum length of the history list is determined by the value
  of `history-length', which see.")
  
! (defun read-regexp (prompt &optional default)
    "Read regexp as a string using the regexp history and some useful defaults.
! Prompt for a regular expression with PROMPT (without a colon and
! space) in the minibuffer.  The optional string argument DEFAULT
! provides the basic default value, that is returned on typing RET.
! Additional defaults are the string at point, the last isearch regexp,
! the last isearch string, and the last replacement regexp."
!   (let* ((defaults
  	   (list (regexp-quote
  		  (or (funcall (or find-tag-default-function
  				   (get major-mode 'find-tag-default-function)
***************
*** 1022,1028 ****
        (nreverse result))))
  
  (defun occur-read-primary-args ()
!   (list (read-regexp "List lines matching regexp")
  	(when current-prefix-arg
  	  (prefix-numeric-value current-prefix-arg))))
  
--- 1021,1028 ----
        (nreverse result))))
  
  (defun occur-read-primary-args ()
!   (list (read-regexp "List lines matching regexp"
! 		     (car regexp-history))
  	(when current-prefix-arg
  	  (prefix-numeric-value current-prefix-arg))))

Index: lisp/hi-lock.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/hi-lock.el,v
retrieving revision 1.52
diff -c -r1.52 hi-lock.el
*** lisp/hi-lock.el	30 Jun 2008 19:36:38 -0000	1.52
--- lisp/hi-lock.el	30 Jun 2008 19:57:29 -0000
***************
*** 398,404 ****
  \(See info node `Minibuffer History'.)"
    (interactive
     (list
!     (hi-lock-regexp-okay (read-regexp "Regexp to highlight line"))
      (hi-lock-read-face-name)))
    (or (facep face) (setq face 'hi-yellow))
    (unless hi-lock-mode (hi-lock-mode 1))
--- 398,405 ----
  \(See info node `Minibuffer History'.)"
    (interactive
     (list
!     (hi-lock-regexp-okay
!      (read-regexp "Regexp to highlight line" (car regexp-history)))
      (hi-lock-read-face-name)))
    (or (facep face) (setq face 'hi-yellow))
    (unless hi-lock-mode (hi-lock-mode 1))
***************
*** 421,427 ****
  \(See info node `Minibuffer History'.)"
    (interactive
     (list
!     (hi-lock-regexp-okay (read-regexp "Regexp to highlight"))
      (hi-lock-read-face-name)))
    (or (facep face) (setq face 'hi-yellow))
    (unless hi-lock-mode (hi-lock-mode 1))
--- 422,429 ----
  \(See info node `Minibuffer History'.)"
    (interactive
     (list
!     (hi-lock-regexp-okay
!      (read-regexp "Regexp to highlight" (car regexp-history)))
      (hi-lock-read-face-name)))
    (or (facep face) (setq face 'hi-yellow))
    (unless hi-lock-mode (hi-lock-mode 1))
***************
*** 439,445 ****
     (list
      (hi-lock-regexp-okay
       (hi-lock-process-phrase
!       (read-regexp "Phrase to highlight")))
      (hi-lock-read-face-name)))
    (or (facep face) (setq face 'hi-yellow))
    (unless hi-lock-mode (hi-lock-mode 1))
--- 441,447 ----
     (list
      (hi-lock-regexp-okay
       (hi-lock-process-phrase
!       (read-regexp "Phrase to highlight" (car regexp-history))))
      (hi-lock-read-face-name)))
    (or (facep face) (setq face 'hi-yellow))
    (unless hi-lock-mode (hi-lock-mode 1))

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Grep key bindings (was: Yanking isearch to highlight-regexp)
  2008-06-30 19:59                             ` Juri Linkov
@ 2008-07-01 21:34                               ` Juri Linkov
  2008-07-01 21:44                                 ` Grep key bindings Miles Bader
  2008-07-30 17:49                               ` Yanking isearch to highlight-regexp Juri Linkov
  1 sibling, 1 reply; 64+ messages in thread
From: Juri Linkov @ 2008-07-01 21:34 UTC (permalink / raw)
  To: emacs-devel

Another set of commands that need global key bindings is `grep'
and more useful `rgrep' and `lgrep'.  We have now global key maps
to bind most frequently used commands, but I'm not sure what keymap
is better since both `search-map' and `goto-map' make sense for grep:
`search-map' because grep searches in files, and `goto-map' because
it provides keys to navigate in grep results `M-g n' and `M-g p'.

One variant is `M-s g r' with mnemonics "Search - Grep - Recursively"
and `M-s g l' with "Search - Grep - Locally".

A command that grep inherits from needs a key binding too -
`compile' is not less frequently used command.  However, `compile'
semantically doesn't fit to `search-map'.  So it could be bound
to a key in `goto-map', for instance, to `M-g c'.

If these two related set of commands should be in one keymap,
then another variant for grep is `M-g r r' "GRep - Recursively"
and `M-g r l' "GRep - Locally".

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Grep key bindings
  2008-07-01 21:34                               ` Grep key bindings (was: Yanking isearch to highlight-regexp) Juri Linkov
@ 2008-07-01 21:44                                 ` Miles Bader
  2008-07-01 21:54                                   ` Juri Linkov
  0 siblings, 1 reply; 64+ messages in thread
From: Miles Bader @ 2008-07-01 21:44 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel

Juri Linkov <juri@jurta.org> writes:
> Another set of commands that need global key bindings is `grep'
> and more useful `rgrep' and `lgrep'.

Why?

Not every command needs a binding, and "rgrep" and "lgrep" are quite
convenient to use with M-x.

Trying to bind _everything_ just reduces the quality of bindings in
general.

-Miles

-- 
If you can't beat them, arrange to have them beaten.  [George Carlin]




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Grep key bindings
  2008-07-01 21:44                                 ` Grep key bindings Miles Bader
@ 2008-07-01 21:54                                   ` Juri Linkov
  2008-07-01 22:11                                     ` Miles Bader
  0 siblings, 1 reply; 64+ messages in thread
From: Juri Linkov @ 2008-07-01 21:54 UTC (permalink / raw)
  To: Miles Bader; +Cc: emacs-devel

>> Another set of commands that need global key bindings is `grep'
>> and more useful `rgrep' and `lgrep'.
>
> Why?
>
> Not every command needs a binding, and "rgrep" and "lgrep" are quite
> convenient to use with M-x.
>
> Trying to bind _everything_ just reduces the quality of bindings in
> general.

But I don't propose to bind everything.   Only most frequently used
commands deserve global key bindings, and grep family of commands
undoubtedly belong to this category.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Grep key bindings
  2008-07-01 21:54                                   ` Juri Linkov
@ 2008-07-01 22:11                                     ` Miles Bader
  2008-07-02 22:42                                       ` Juri Linkov
                                                         ` (2 more replies)
  0 siblings, 3 replies; 64+ messages in thread
From: Miles Bader @ 2008-07-01 22:11 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel

Juri Linkov <juri@jurta.org> writes:
>> Not every command needs a binding, and "rgrep" and "lgrep" are quite
>> convenient to use with M-x.
>>
>> Trying to bind _everything_ just reduces the quality of bindings in
>> general.
>
> But I don't propose to bind everything.   Only most frequently used
> commands deserve global key bindings, and grep family of commands
> undoubtedly belong to this category.

That's quite debatable; I actually use "M-x grep" many many times a day,
but have never felt it needed a binding.

-Miles

-- 
"I distrust a research person who is always obviously busy on a task."
   --Robert Frosch, VP, GM Research




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Grep key bindings
  2008-07-01 22:11                                     ` Miles Bader
@ 2008-07-02 22:42                                       ` Juri Linkov
  2008-07-03  6:53                                         ` joakim
                                                           ` (2 more replies)
  2008-07-03 15:37                                       ` Phil Jackson
  2008-07-04 10:46                                       ` Eli Zaretskii
  2 siblings, 3 replies; 64+ messages in thread
From: Juri Linkov @ 2008-07-02 22:42 UTC (permalink / raw)
  To: Miles Bader; +Cc: emacs-devel

>>> Not every command needs a binding, and "rgrep" and "lgrep" are quite
>>> convenient to use with M-x.
>>>
>>> Trying to bind _everything_ just reduces the quality of bindings in
>>> general.
>>
>> But I don't propose to bind everything.   Only most frequently used
>> commands deserve global key bindings, and grep family of commands
>> undoubtedly belong to this category.
>
> That's quite debatable; I actually use "M-x grep" many many times a day,
> but have never felt it needed a binding.

Do you type `M-x compile RET' as often as `M-x grep RET'?
I think it needs a key binding as well.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Grep key bindings
  2008-07-02 22:42                                       ` Juri Linkov
@ 2008-07-03  6:53                                         ` joakim
  2008-07-03  7:07                                           ` Miles Bader
  2008-07-03 13:18                                         ` Ted Zlatanov
  2008-07-03 14:50                                         ` Dan Nicolaescu
  2 siblings, 1 reply; 64+ messages in thread
From: joakim @ 2008-07-03  6:53 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel, Miles Bader

Juri Linkov <juri@jurta.org> writes:

>>>> Not every command needs a binding, and "rgrep" and "lgrep" are quite
>>>> convenient to use with M-x.
>>>>
>>>> Trying to bind _everything_ just reduces the quality of bindings in
>>>> general.
>>>
>>> But I don't propose to bind everything.   Only most frequently used
>>> commands deserve global key bindings, and grep family of commands
>>> undoubtedly belong to this category.
>>
>> That's quite debatable; I actually use "M-x grep" many many times a day,
>> but have never felt it needed a binding.
>
> Do you type `M-x compile RET' as often as `M-x grep RET'?
> I think it needs a key binding as well.

+1

All emacs users I know that uses compile binds it to something.
My binding is F8.

-- 
Joakim Verona




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Grep key bindings
  2008-07-03  6:53                                         ` joakim
@ 2008-07-03  7:07                                           ` Miles Bader
  0 siblings, 0 replies; 64+ messages in thread
From: Miles Bader @ 2008-07-03  7:07 UTC (permalink / raw)
  To: joakim; +Cc: Juri Linkov, emacs-devel

joakim@verona.se writes:
>> Do you type `M-x compile RET' as often as `M-x grep RET'?
>> I think it needs a key binding as well.
>
> +1
>
> All emacs users I know that uses compile binds it to something.
> My binding is F8.

Yup, I bind compile too:  C-x C-e
(the old gosmacs binding, IIRC)

-Miles

-- 
Bigot, n. One who is obstinately and zealously attached to an opinion that
you do not entertain.




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Grep key bindings
  2008-07-02 22:42                                       ` Juri Linkov
  2008-07-03  6:53                                         ` joakim
@ 2008-07-03 13:18                                         ` Ted Zlatanov
  2008-07-03 22:06                                           ` Stefan Monnier
  2008-07-03 14:50                                         ` Dan Nicolaescu
  2 siblings, 1 reply; 64+ messages in thread
From: Ted Zlatanov @ 2008-07-03 13:18 UTC (permalink / raw)
  To: emacs-devel

On Thu, 03 Jul 2008 01:42:48 +0300 Juri Linkov <juri@jurta.org> wrote: 

JL> Do you type `M-x compile RET' as often as `M-x grep RET'?
JL> I think it needs a key binding as well.

M-x gr TAB

-> grep is the default, so you just need to hit ENTER (grep-find is the
   only other candidate).  5 keystrokes (6 if you use ESC x for M-x as I
   do).  I know I could type `grep' instead of `gr TAB' but I'm used to
   TAB-completion.

M-x co TAB

-> about 50 candidates, can't hit ENTER, need to type the whole word
   `compile'.  10-11 keystrokes.

This is why I bind `compile' to a key, personally.

Ted





^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Grep key bindings
  2008-07-02 22:42                                       ` Juri Linkov
  2008-07-03  6:53                                         ` joakim
  2008-07-03 13:18                                         ` Ted Zlatanov
@ 2008-07-03 14:50                                         ` Dan Nicolaescu
  2 siblings, 0 replies; 64+ messages in thread
From: Dan Nicolaescu @ 2008-07-03 14:50 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel, Miles Bader

Juri Linkov <juri@jurta.org> writes:

  > >>> Not every command needs a binding, and "rgrep" and "lgrep" are quite
  > >>> convenient to use with M-x.
  > >>>
  > >>> Trying to bind _everything_ just reduces the quality of bindings in
  > >>> general.
  > >>
  > >> But I don't propose to bind everything.   Only most frequently used
  > >> commands deserve global key bindings, and grep family of commands
  > >> undoubtedly belong to this category.
  > >
  > > That's quite debatable; I actually use "M-x grep" many many times a day,
  > > but have never felt it needed a binding.
  > 
  > Do you type `M-x compile RET' as often as `M-x grep RET'?
  > I think it needs a key binding as well.

IMO we should have some bindings for compile and debug commands for the
function keys.  

The best would be to default to the function keys that, for example,
Eclipse uses and have an easy way to change all these bindings to the
keys that other popular IDEs use.





^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Grep key bindings
  2008-07-01 22:11                                     ` Miles Bader
  2008-07-02 22:42                                       ` Juri Linkov
@ 2008-07-03 15:37                                       ` Phil Jackson
  2008-07-03 16:59                                         ` Drew Adams
  2008-07-04 10:46                                       ` Eli Zaretskii
  2 siblings, 1 reply; 64+ messages in thread
From: Phil Jackson @ 2008-07-03 15:37 UTC (permalink / raw)
  To: Miles Bader; +Cc: Juri Linkov, emacs-devel

Miles Bader <miles@gnu.org> writes:

> Juri Linkov <juri@jurta.org> writes:

[...]

>>> Trying to bind _everything_ just reduces the quality of bindings in
>>> general.
>>
>> But I don't propose to bind everything.   Only most frequently used
>> commands deserve global key bindings, and grep family of commands
>> undoubtedly belong to this category.
>
> That's quite debatable; I actually use "M-x grep" many many times a day,
> but have never felt it needed a binding.

For what it's worth I use project-root.el[1] and bind 'C-c p g' to grep
(actually I use ack[2] more) from the current project root. I do that
several times a day. If, on the rare occasion, I want to grep from
`default-directory' I just type M-x grep.

Cheers,
Phil

[1] http://www.shellarchive.co.uk/content/lisp/project-root.el
[2] http://www.shellarchive.co.uk/content/lisp/ack.el




^ permalink raw reply	[flat|nested] 64+ messages in thread

* RE: Grep key bindings
  2008-07-03 15:37                                       ` Phil Jackson
@ 2008-07-03 16:59                                         ` Drew Adams
  0 siblings, 0 replies; 64+ messages in thread
From: Drew Adams @ 2008-07-03 16:59 UTC (permalink / raw)
  To: 'Phil Jackson', 'Miles Bader'
  Cc: 'Juri Linkov', emacs-devel

Yes, most users use `grep' and `compile' frequently.
And many users bind them to keys they like.
Does that mean Emacs should pre-bind them?

I personally don't think we need a predefined global binding for `grep' or
`compile'. It's not hard for users to do that on their own, using exactly the
keys they want.


FWIW -

I find that I often reuse the same grep output buffer for a different grep
command - changing either the pattern or the file list (e.g. */*.el vs *.el) or
both.

So I bind `g' in the *grep* buffer to `grep'. That's different from what Emacs
does by default, which is to bind `g' to `recompile', which just repeats the
last compile command exactly.

I also bind `+' to a command that renames the current grep buffer to *grep*<N>
and pops to a new buffer *grep*.






^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Grep key bindings
  2008-07-03 13:18                                         ` Ted Zlatanov
@ 2008-07-03 22:06                                           ` Stefan Monnier
  0 siblings, 0 replies; 64+ messages in thread
From: Stefan Monnier @ 2008-07-03 22:06 UTC (permalink / raw)
  To: Ted Zlatanov; +Cc: emacs-devel

> M-x co TAB

I bind minibuffer-force-complete to M-TAB, in which case

  M-x co M-TAB

gives me `compile'.


        Stefan "who binds it to C-c C-c"




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Grep key bindings
  2008-07-01 22:11                                     ` Miles Bader
  2008-07-02 22:42                                       ` Juri Linkov
  2008-07-03 15:37                                       ` Phil Jackson
@ 2008-07-04 10:46                                       ` Eli Zaretskii
  2008-07-04 10:59                                         ` Miles Bader
  2 siblings, 1 reply; 64+ messages in thread
From: Eli Zaretskii @ 2008-07-04 10:46 UTC (permalink / raw)
  To: Miles Bader; +Cc: juri, emacs-devel

> From: Miles Bader <miles@gnu.org>
> Date: Wed, 02 Jul 2008 07:11:27 +0900
> Cc: emacs-devel@gnu.org
> 
> > But I don't propose to bind everything.   Only most frequently used
> > commands deserve global key bindings, and grep family of commands
> > undoubtedly belong to this category.
> 
> That's quite debatable; I actually use "M-x grep" many many times a day,
> but have never felt it needed a binding.

Actually, after the first "M-x grep", it can be reached very quickly
via the command history machinery.




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Grep key bindings
  2008-07-04 10:46                                       ` Eli Zaretskii
@ 2008-07-04 10:59                                         ` Miles Bader
  0 siblings, 0 replies; 64+ messages in thread
From: Miles Bader @ 2008-07-04 10:59 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: juri, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:
>> That's quite debatable; I actually use "M-x grep" many many times a day,
>> but have never felt it needed a binding.
>
> Actually, after the first "M-x grep", it can be reached very quickly
> via the command history machinery.

Indeed, that's usually how I do it if I'm doing a bunch of greps in a
row.

-Miles

-- 
Un-American, adj. Wicked, intolerable, heathenish.




^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: Yanking isearch to highlight-regexp
  2008-06-30 19:59                             ` Juri Linkov
  2008-07-01 21:34                               ` Grep key bindings (was: Yanking isearch to highlight-regexp) Juri Linkov
@ 2008-07-30 17:49                               ` Juri Linkov
  1 sibling, 0 replies; 64+ messages in thread
From: Juri Linkov @ 2008-07-30 17:49 UTC (permalink / raw)
  To: emacs-devel

One problem with `isearch-highlight-regexp': after typing `M-s h r'
in Isearch mode, it asks for the face name in the minibuffer but
Isearch mode is still active with its keybindings.  Two calls to
(isearch-clean-overlays) and (isearch-done) could be moved to the
interactive spec before calling `hi-lock-read-face-name' with the
assumption that `isearch-highlight-regexp' will be never used
non-interactively.  But in this case the functions arguments
`(regexp &optional face)' make no sense.

So it seems we should drop the idea of keeping the function arguments
the same as in `highlight-regexp' and change `isearch-highlight-regexp'
as follows:

Index: lisp/isearch.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.325
diff -c -r1.325 isearch.el
*** lisp/isearch.el	30 Jul 2008 16:40:23 -0000	1.325
--- lisp/isearch.el	30 Jul 2008 17:48:40 -0000
***************
*** 1394,1415 ****
  (declare-function hi-lock-regexp-okay "hi-lock" (regexp))
  (declare-function hi-lock-read-face-name "hi-lock" ())
  
! (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
!     (progn
!       (require 'hi-lock nil t)
!       (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)))
  
  \f
  (defun isearch-delete-char ()
--- 1394,1416 ----
  (declare-function hi-lock-regexp-okay "hi-lock" (regexp))
  (declare-function hi-lock-read-face-name "hi-lock" ())
  
! (defun isearch-highlight-regexp ()
    "Run `highlight-regexp' with regexp from the current search string.
! It exits Isearch mode and calls `hi-lock-face-buffer' with its regexp
! argument from the last search regexp or a quoted search string,
! and reads its face argument using `hi-lock-read-face-name'."
!   (interactive)
    (isearch-done)
    (isearch-clean-overlays)
+   (require 'hi-lock nil t)
    ;; (add-to-history 'hi-lock-regexp-history regexp)
!   (let ((case-fold-search isearch-case-fold-search))
!     (hi-lock-face-buffer
!      (hi-lock-regexp-okay
!       (if isearch-regexp isearch-string (regexp-quote isearch-string)))
!      (hi-lock-read-face-name))))
  
  \f
  (defun isearch-delete-char ()

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 64+ messages in thread

end of thread, other threads:[~2008-07-30 17:49 UTC | newest]

Thread overview: 64+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-14 16:57 Yanking isearch to highlight-regexp Lennart Borgman (gmail)
2008-06-14 21:42 ` Mathias Dahl
2008-06-14 21:50   ` Stefan Monnier
2008-06-14 21:54     ` Mathias Dahl
2008-06-15  0:32       ` Juri Linkov
2008-06-15  0:08     ` Lennart Borgman (gmail)
2008-06-15  0:33       ` Juri Linkov
2008-06-15  1:48       ` Stefan Monnier
2008-06-15  9:47         ` Lennart Borgman (gmail)
2008-06-15 20:48           ` Juri Linkov
2008-06-15 21:10             ` Lennart Borgman (gmail)
2008-06-15 22:54               ` Juri Linkov
2008-06-15 23:09                 ` Lennart Borgman (gmail)
2008-06-16  9:34                   ` Juri Linkov
2008-06-16 11:13                     ` Lennart Borgman
2008-06-16 21:48                       ` Juri Linkov
2008-06-16 18:50             ` David Koppelman
2008-06-16 19:08               ` Lennart Borgman (gmail)
2008-06-16 21:50               ` Juri Linkov
2008-06-17 18:50                 ` David Koppelman
2008-06-24 23:09                   ` Juri Linkov
2008-06-25  1:43                     ` Stefan Monnier
2008-06-25 20:32                       ` Juri Linkov
2008-06-25 22:16                         ` Miles Bader
2008-06-25 22:22                           ` Lennart Borgman (gmail)
2008-06-25 22:58                             ` Miles Bader
2008-06-27 23:15                           ` Global keymaps [was: Yanking isearch to highlight-regexp] Juri Linkov
2008-06-27 23:20                             ` Lennart Borgman (gmail)
2008-06-27 23:32                               ` Juri Linkov
2008-06-28  0:28                             ` Global keymaps Miles Bader
2008-06-28  1:25                               ` Stefan Monnier
2008-06-28 19:45                               ` Juri Linkov
2008-06-28 22:51                                 ` Stefan Monnier
2008-06-29 16:17                                   ` Juri Linkov
2008-06-29 18:03                                     ` Stefan Monnier
2008-06-29 19:28                                       ` Juri Linkov
2008-06-29 20:03                                         ` Stefan Monnier
2008-06-29 20:52                                           ` Juri Linkov
2008-06-29 21:24                                             ` Lennart Borgman (gmail)
2008-06-30  1:00                                               ` Stefan Monnier
2008-06-28 22:02             ` Yanking isearch to highlight-regexp Juri Linkov
2008-06-28 22:23               ` Stefan Monnier
2008-06-29 16:19                 ` Juri Linkov
2008-06-29 18:07                   ` Stefan Monnier
2008-06-29 19:29                     ` Juri Linkov
2008-06-29 20:05                       ` Stefan Monnier
2008-06-29 20:55                         ` Juri Linkov
2008-06-30  1:01                           ` Stefan Monnier
2008-06-30 19:59                             ` Juri Linkov
2008-07-01 21:34                               ` Grep key bindings (was: Yanking isearch to highlight-regexp) Juri Linkov
2008-07-01 21:44                                 ` Grep key bindings Miles Bader
2008-07-01 21:54                                   ` Juri Linkov
2008-07-01 22:11                                     ` Miles Bader
2008-07-02 22:42                                       ` Juri Linkov
2008-07-03  6:53                                         ` joakim
2008-07-03  7:07                                           ` Miles Bader
2008-07-03 13:18                                         ` Ted Zlatanov
2008-07-03 22:06                                           ` Stefan Monnier
2008-07-03 14:50                                         ` Dan Nicolaescu
2008-07-03 15:37                                       ` Phil Jackson
2008-07-03 16:59                                         ` Drew Adams
2008-07-04 10:46                                       ` Eli Zaretskii
2008-07-04 10:59                                         ` Miles Bader
2008-07-30 17:49                               ` Yanking isearch to highlight-regexp Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).