unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Calling occur from within isearch
@ 2007-11-21 19:57 Lennart Borgman (gmail)
  2007-11-21 20:03 ` Juri Linkov
                   ` (2 more replies)
  0 siblings, 3 replies; 33+ messages in thread
From: Lennart Borgman (gmail) @ 2007-11-21 19:57 UTC (permalink / raw)
  To: Emacs Devel

Sometimes I think it would be good to call occur from within isearch. 
Anyone else that thinks it would be good to be able to do so?

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

* Re: Calling occur from within isearch
  2007-11-21 19:57 Calling occur from within isearch Lennart Borgman (gmail)
@ 2007-11-21 20:03 ` Juri Linkov
  2007-11-21 20:25   ` Lennart Borgman (gmail)
  2007-11-22  0:30   ` Johan Bockgård
  2007-11-21 20:07 ` Drew Adams
  2007-11-22 16:21 ` Richard Stallman
  2 siblings, 2 replies; 33+ messages in thread
From: Juri Linkov @ 2007-11-21 20:03 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: Emacs Devel

> Sometimes I think it would be good to call occur from within isearch.
> Anyone else that thinks it would be good to be able to do so?

This is possible with the following patch.  I'm still not sure
whether it is better to quit isearch before calling occur or not.
Anyway, it works without quitting isearch, and displays the results
of occur in another window.

Index: lisp/isearch.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.306
diff -c -r1.306 isearch.el
*** lisp/isearch.el	10 Nov 2007 23:03:24 -0000	1.306
--- lisp/isearch.el	21 Nov 2007 20:01:07 -0000
***************
*** 1256,1265 ****
--- 1257,1276 ----
    (interactive)
    (isearch-query-replace t))
  
+ (defun isearch-occur (regexp &optional nlines)
+   "Run `occur' with string to search from the current search string.
+ REGEXP is a regexp from the last search queted when the search was not regexp.
+ NLINES has the same meaning as in `occur'."
+   (interactive
+    (list
+     (if isearch-regexp isearch-string (regexp-quote isearch-string))
+     (when current-prefix-arg
+       (prefix-numeric-value current-prefix-arg))))
+   (let ((case-fold-search isearch-case-fold-search))
+     ;; (isearch-done)
+     ;; (isearch-clean-overlays)
+     (occur regexp nlines)))
+ 
  \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] 33+ messages in thread

* RE: Calling occur from within isearch
  2007-11-21 19:57 Calling occur from within isearch Lennart Borgman (gmail)
  2007-11-21 20:03 ` Juri Linkov
@ 2007-11-21 20:07 ` Drew Adams
  2007-11-22 16:21 ` Richard Stallman
  2 siblings, 0 replies; 33+ messages in thread
From: Drew Adams @ 2007-11-21 20:07 UTC (permalink / raw)
  To: Lennart Borgman (gmail), Emacs Devel; +Cc: Alex Schroeder

> Sometimes I think it would be good to call occur from within isearch.
> Anyone else that thinks it would be good to be able to do so?

Yes. I've done that for some time, using this code by Alex Schroeder
(http://www.emacswiki.org/cgi-bin/wiki/AlexSchroederConfigInit):

(defun isearch-occur ()
  "Invoke `occur' from within isearch."
  (interactive)
  (let ((case-fold-search isearch-case-fold-search))
    (occur (if isearch-regexp
               isearch-string
             (regexp-quote isearch-string)))))

(define-key isearch-mode-map (kbd "C-o") 'isearch-occur)

(defun my-occur (&optional arg)
  "Switch to *Occur* buffer, or run `occur'.
Without a prefix argument, switch to the buffer.
With a universal prefix argument, run occur again.
With a numeric prefix argument, run occur with NLINES
set to that number."
  (interactive "P")
  (if (and (not arg) (get-buffer "*Occur*"))
      (switch-to-buffer "*Occur*")
    (occur (read-from-minibuffer "Regexp: ")
	   (if (listp arg) 0 arg))))

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

* Re: Calling occur from within isearch
  2007-11-21 20:03 ` Juri Linkov
@ 2007-11-21 20:25   ` Lennart Borgman (gmail)
  2007-11-22 19:08     ` Juri Linkov
  2007-11-22  0:30   ` Johan Bockgård
  1 sibling, 1 reply; 33+ messages in thread
From: Lennart Borgman (gmail) @ 2007-11-21 20:25 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Alex Schroeder, Drew Adams, Emacs Devel

Juri Linkov wrote:
>> Sometimes I think it would be good to call occur from within isearch.
>> Anyone else that thinks it would be good to be able to do so?
> 
> This is possible with the following patch.  I'm still not sure
> whether it is better to quit isearch before calling occur or not.
> Anyway, it works without quitting isearch, and displays the results
> of occur in another window.


That is nice. I see no reason to end isearch, that is easy to do afterwards.

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

* Re: Calling occur from within isearch
  2007-11-21 20:03 ` Juri Linkov
  2007-11-21 20:25   ` Lennart Borgman (gmail)
@ 2007-11-22  0:30   ` Johan Bockgård
  2007-11-22 19:04     ` Juri Linkov
  1 sibling, 1 reply; 33+ messages in thread
From: Johan Bockgård @ 2007-11-22  0:30 UTC (permalink / raw)
  To: emacs-devel

Juri Linkov <juri@jurta.org> writes:

> +   (let ((case-fold-search isearch-case-fold-search))

isearch-case-fold-search is almost but not quite the same as
case-fold-search. Cf isearch-no-upper-case-p.

    ; case-fold-search while searching.
    ;   either nil, t, or 'yes.  'yes means the same as t except that mixed
    ;   case in the search string is ignored.
    (defvar isearch-case-fold-search nil)

-- 
Johan Bockgård

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

* Re: Calling occur from within isearch
  2007-11-21 19:57 Calling occur from within isearch Lennart Borgman (gmail)
  2007-11-21 20:03 ` Juri Linkov
  2007-11-21 20:07 ` Drew Adams
@ 2007-11-22 16:21 ` Richard Stallman
  2007-11-22 18:16   ` Stefan Monnier
  2007-11-22 19:05   ` Juri Linkov
  2 siblings, 2 replies; 33+ messages in thread
From: Richard Stallman @ 2007-11-22 16:21 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: emacs-devel

    Sometimes I think it would be good to call occur from within isearch. 
    Anyone else that thinks it would be good to be able to do so?

I don't want any more special search-mode bindings unless
it is very important.

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

* Re: Calling occur from within isearch
  2007-11-22 16:21 ` Richard Stallman
@ 2007-11-22 18:16   ` Stefan Monnier
  2007-11-22 19:05     ` Juri Linkov
  2007-11-22 19:05   ` Juri Linkov
  1 sibling, 1 reply; 33+ messages in thread
From: Stefan Monnier @ 2007-11-22 18:16 UTC (permalink / raw)
  To: rms; +Cc: Lennart Borgman (gmail), emacs-devel

>     Sometimes I think it would be good to call occur from within isearch. 
>     Anyone else that thinks it would be good to be able to do so?

> I don't want any more special search-mode bindings unless
> it is very important.

Agreed.  OTOH it might make a lot of sense to do something such that if
you type M-x occur RET from within an isearch session, the regexp is
taken directly from isearch-string.


        Stefan

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

* Re: Calling occur from within isearch
  2007-11-22  0:30   ` Johan Bockgård
@ 2007-11-22 19:04     ` Juri Linkov
  2007-11-23  0:52       ` Juri Linkov
  2007-11-23  1:05       ` Johan Bockgård
  0 siblings, 2 replies; 33+ messages in thread
From: Juri Linkov @ 2007-11-22 19:04 UTC (permalink / raw)
  To: emacs-devel

>> +   (let ((case-fold-search isearch-case-fold-search))
>
> isearch-case-fold-search is almost but not quite the same as
> case-fold-search. Cf isearch-no-upper-case-p.
>
>     ; case-fold-search while searching.
>     ;   either nil, t, or 'yes.  'yes means the same as t except that mixed
>     ;   case in the search string is ignored.
>     (defvar isearch-case-fold-search nil)

Right, below is a more correct patch:

Index: lisp/isearch.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.306
diff -c -r1.306 isearch.el
*** lisp/isearch.el	10 Nov 2007 23:03:24 -0000	1.306
--- lisp/isearch.el	22 Nov 2007 19:02:59 -0000
***************
*** 1256,1265 ****
--- 1257,1276 ----
    (interactive)
    (isearch-query-replace t))
  
+ (defun isearch-occur (regexp &optional nlines)
+   "Run `occur' with regexp to search from the current search string.
+ Interactively, REGEXP is the current search regexp or a quoted search
+ string.  NLINES has the same meaning as in `occur'."
+   (interactive
+    (list
+     (if isearch-regexp isearch-string (regexp-quote isearch-string))
+     (if current-prefix-arg (prefix-numeric-value current-prefix-arg))))
+   (let ((case-fold-search isearch-case-fold-search))
+     (if (and (eq case-fold-search t) search-upper-case)
+ 	(setq case-fold-search
+ 	      (isearch-no-upper-case-p isearch-string isearch-regexp)))
+     (occur regexp nlines)))
+ 
  \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] 33+ messages in thread

* Re: Calling occur from within isearch
  2007-11-22 16:21 ` Richard Stallman
  2007-11-22 18:16   ` Stefan Monnier
@ 2007-11-22 19:05   ` Juri Linkov
  2007-11-23  4:35     ` Richard Stallman
  1 sibling, 1 reply; 33+ messages in thread
From: Juri Linkov @ 2007-11-22 19:05 UTC (permalink / raw)
  To: rms; +Cc: Lennart Borgman (gmail), emacs-devel

>     Sometimes I think it would be good to call occur from within isearch.
>     Anyone else that thinks it would be good to be able to do so?
>
> I don't want any more special search-mode bindings unless
> it is very important.

This is a very useful function.  I see people are using C-o in isearch mode
to call it.  Do you often use C-o to exit isearch and insert a newline with
`open-line'?  If not, we could bind C-o to `isearch-occur' by default.

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

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

* Re: Calling occur from within isearch
  2007-11-22 18:16   ` Stefan Monnier
@ 2007-11-22 19:05     ` Juri Linkov
  2007-11-22 21:23       ` Stefan Monnier
  0 siblings, 1 reply; 33+ messages in thread
From: Juri Linkov @ 2007-11-22 19:05 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Lennart Borgman (gmail), rms, emacs-devel

>>     Sometimes I think it would be good to call occur from within isearch.
>>     Anyone else that thinks it would be good to be able to do so?
>
>> I don't want any more special search-mode bindings unless
>> it is very important.
>
> Agreed.  OTOH it might make a lot of sense to do something such that if
> you type M-x occur RET from within an isearch session, the regexp is
> taken directly from isearch-string.

Do you propose to not exit isearch with M-x?  Even if this is possible
or desirable, I think occur deserves a dedicated short key binding
instead of `M-x occur RET'.

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

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

* Re: Calling occur from within isearch
  2007-11-21 20:25   ` Lennart Borgman (gmail)
@ 2007-11-22 19:08     ` Juri Linkov
  2007-11-22 19:38       ` Drew Adams
  2007-11-22 21:48       ` Lennart Borgman (gmail)
  0 siblings, 2 replies; 33+ messages in thread
From: Juri Linkov @ 2007-11-22 19:08 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: Alex Schroeder, Drew Adams, Emacs Devel

>>> Sometimes I think it would be good to call occur from within isearch.
>>> Anyone else that thinks it would be good to be able to do so?
>>
>> This is possible with the following patch.  I'm still not sure
>> whether it is better to quit isearch before calling occur or not.
>> Anyway, it works without quitting isearch, and displays the results
>> of occur in another window.
>
> That is nice. I see no reason to end isearch, that is easy to do afterwards.

Wouldn't it be more nice if the current search line was also highlighted
in the *Occur* buffer in sync with the position in the original buffer?

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

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

* RE: Calling occur from within isearch
  2007-11-22 19:08     ` Juri Linkov
@ 2007-11-22 19:38       ` Drew Adams
  2007-11-22 21:48       ` Lennart Borgman (gmail)
  1 sibling, 0 replies; 33+ messages in thread
From: Drew Adams @ 2007-11-22 19:38 UTC (permalink / raw)
  To: Juri Linkov, Lennart Borgman (gmail); +Cc: Alex Schroeder, Emacs Devel

> >>> Sometimes I think it would be good to call occur from within isearch.
> >>> Anyone else that thinks it would be good to be able to do so?
> >>
> >> This is possible with the following patch.  I'm still not sure
> >> whether it is better to quit isearch before calling occur or not.
> >> Anyway, it works without quitting isearch, and displays the results
> >> of occur in another window.
> >
> > That is nice. I see no reason to end isearch, that is easy to
> do afterwards.
>
> Wouldn't it be more nice if the current search line was also highlighted
> in the *Occur* buffer in sync with the position in the original buffer?

Yes. It's enough to highlight the line number (of the current search line).
And any such highlighting should be temporary in some way.

FWIW, I use code that highlights the line number after you visit the line -
a la visited links in Info or on Web pages. I find it helps me keep track of
what I've already looked at.

Code: http://www.emacswiki.org/cgi-bin/wiki/replace%2b.el.
Doc: http://www.emacswiki.org/cgi-bin/emacs-en/ReplacePlus.

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

* Re: Calling occur from within isearch
  2007-11-22 19:05     ` Juri Linkov
@ 2007-11-22 21:23       ` Stefan Monnier
  0 siblings, 0 replies; 33+ messages in thread
From: Stefan Monnier @ 2007-11-22 21:23 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Lennart Borgman (gmail), rms, emacs-devel

>> Agreed.  OTOH it might make a lot of sense to do something such that if
>> you type M-x occur RET from within an isearch session, the regexp is
>> taken directly from isearch-string.

> Do you propose to not exit isearch with M-x?

No.


        Stefan

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

* Re: Calling occur from within isearch
  2007-11-22 19:08     ` Juri Linkov
  2007-11-22 19:38       ` Drew Adams
@ 2007-11-22 21:48       ` Lennart Borgman (gmail)
  1 sibling, 0 replies; 33+ messages in thread
From: Lennart Borgman (gmail) @ 2007-11-22 21:48 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Alex Schroeder, Drew Adams, Emacs Devel

Juri Linkov wrote:
>>>> Sometimes I think it would be good to call occur from within isearch.
>>>> Anyone else that thinks it would be good to be able to do so?
>>> This is possible with the following patch.  I'm still not sure
>>> whether it is better to quit isearch before calling occur or not.
>>> Anyway, it works without quitting isearch, and displays the results
>>> of occur in another window.
>> That is nice. I see no reason to end isearch, that is easy to do afterwards.
> 
> Wouldn't it be more nice if the current search line was also highlighted
> in the *Occur* buffer in sync with the position in the original buffer?

Indeed it would IMO. That would make it easier to get an overview.

Since not everyone want more key bindings during isearch then maybe it 
could be an option so that users could easily turn on/off a binding for 
this? Would that be acceptable?

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

* Re: Calling occur from within isearch
  2007-11-22 19:04     ` Juri Linkov
@ 2007-11-23  0:52       ` Juri Linkov
  2007-11-23  1:05       ` Johan Bockgård
  1 sibling, 0 replies; 33+ messages in thread
From: Juri Linkov @ 2007-11-23  0:52 UTC (permalink / raw)
  To: emacs-devel

>>> +   (let ((case-fold-search isearch-case-fold-search))
>>
>> isearch-case-fold-search is almost but not quite the same as
>> case-fold-search. Cf isearch-no-upper-case-p.
>>
>>     ; case-fold-search while searching.
>>     ;   either nil, t, or 'yes.  'yes means the same as t except that mixed
>>     ;   case in the search string is ignored.
>>     (defvar isearch-case-fold-search nil)

BTW, `isearch-query-replace' and `isearch-query-replace-regexp' don't take
into account `isearch-no-upper-case-p' too.  I think they should be fixed
as well.

Also I noticed that these commands don't accept exactly the same arguments
as their normal counterparts `query-replace' and `query-replace-regexp'.
For instance, the latter supports the prefix argument `delimited' that
means replace only matches surrounded by word boundaries.  But corresponding
isearch commands don't accept this prefix argument.  Perhaps they should do.
They currently use the value of `isearch-word' for the `delimited'
argument, but it is inconvenient to switch the search type to isearch-word
before starting replacing delimited words.  Maybe this need will be
obsoleted by adding a new easy-to-type isearch keybinding to turn on/off
the word search.

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

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

* Re: Calling occur from within isearch
  2007-11-22 19:04     ` Juri Linkov
  2007-11-23  0:52       ` Juri Linkov
@ 2007-11-23  1:05       ` Johan Bockgård
  2007-11-24 17:45         ` Juri Linkov
  1 sibling, 1 reply; 33+ messages in thread
From: Johan Bockgård @ 2007-11-23  1:05 UTC (permalink / raw)
  To: emacs-devel

Juri Linkov <juri@jurta.org> writes:

> +   (let ((case-fold-search isearch-case-fold-search))
> +     (if (and (eq case-fold-search t) search-upper-case)
> + 	(setq case-fold-search
> + 	      (isearch-no-upper-case-p isearch-string isearch-regexp)))
> +     (occur regexp nlines)))
> + 

Occur already does the "upper-case implies case-sensitive" step.  The
interesting case is where this should not be done--that is when the
search string is mixed case, and the user explicitly turns off
case-sensitivity with M-c (this is the situation where
isearch-case-fold-search is `yes').

So the idea is more like

  ;; Except that this doesn't really work, since occur doesn't care
  ;; about `search-upper-case'.
  (let ((case-fold-search isearch-case-fold-search)
        (search-upper-case nil))
    (occur regexp nlines))

Maybe upper-case input should only have magic effects in
interactive calls.

  (occur REGEXP &optional NLINES UPPER-CASE-IMPLIES-CASE-SENSITIVE)

-- 
Johan Bockgård

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

* Re: Calling occur from within isearch
  2007-11-22 19:05   ` Juri Linkov
@ 2007-11-23  4:35     ` Richard Stallman
  2007-11-24 17:45       ` Juri Linkov
  0 siblings, 1 reply; 33+ messages in thread
From: Richard Stallman @ 2007-11-23  4:35 UTC (permalink / raw)
  To: Juri Linkov; +Cc: lennart.borgman, emacs-devel

I don't want any more special search-mode bindings unless it is very
important.  In fact, I would like to reduce them if possible.  Please
do not ask for this.

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

* Re: Calling occur from within isearch
  2007-11-23  1:05       ` Johan Bockgård
@ 2007-11-24 17:45         ` Juri Linkov
  2007-11-25  3:42           ` Richard Stallman
  2007-12-03 23:25           ` Johan Bockgård
  0 siblings, 2 replies; 33+ messages in thread
From: Juri Linkov @ 2007-11-24 17:45 UTC (permalink / raw)
  To: emacs-devel

> Occur already does the "upper-case implies case-sensitive" step.  The
> interesting case is where this should not be done--that is when the
> search string is mixed case, and the user explicitly turns off
> case-sensitivity with M-c (this is the situation where
> isearch-case-fold-search is `yes').
>
> So the idea is more like
>
>   ;; Except that this doesn't really work, since occur doesn't care
>   ;; about `search-upper-case'.
>   (let ((case-fold-search isearch-case-fold-search)
>         (search-upper-case nil))
>     (occur regexp nlines))
>
> Maybe upper-case input should only have magic effects in
> interactive calls.
>
>   (occur REGEXP &optional NLINES UPPER-CASE-IMPLIES-CASE-SENSITIVE)

Since occur uses `isearch-no-upper-case-p' it seems reasonable for it
to respect the value of `search-upper-case' as well.

Do you see any flaw in the following patch?

Index: lisp/replace.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/replace.el,v
retrieving revision 1.263
diff -c -r1.263 replace.el
*** lisp/replace.el	22 Nov 2007 03:01:36 -0000	1.263
--- lisp/replace.el	24 Nov 2007 17:42:32 -0000
***************
*** 1030,1037 ****
  It serves as a menu to find any of the occurrences in this buffer.
  \\<occur-mode-map>\\[describe-mode] in that buffer will explain how.
  
! If REGEXP contains upper case characters (excluding those preceded by `\\'),
! the matching is case-sensitive."
    (interactive (occur-read-primary-args))
    (occur-1 regexp nlines (list (current-buffer))))
  
--- 1030,1037 ----
  It serves as a menu to find any of the occurrences in this buffer.
  \\<occur-mode-map>\\[describe-mode] in that buffer will explain how.
  
! If REGEXP contains upper case characters (excluding those preceded by `\\')
! and `search-upper-case' is non-nil, the matching is case-sensitive."
    (interactive (occur-read-primary-args))
    (occur-1 regexp nlines (list (current-buffer))))
  
***************
*** 1119,1126 ****
  	(let ((count (occur-engine
  		      regexp active-bufs occur-buf
  		      (or nlines list-matching-lines-default-context-lines)
! 		      (and case-fold-search
! 			   (isearch-no-upper-case-p regexp t))
  		      list-matching-lines-buffer-name-face
  		      nil list-matching-lines-face
  		      (not (eq occur-excluded-properties t)))))
--- 1119,1127 ----
  	(let ((count (occur-engine
  		      regexp active-bufs occur-buf
  		      (or nlines list-matching-lines-default-context-lines)
! 		      (if (and (eq case-fold-search t) search-upper-case)
! 			  (isearch-no-upper-case-p regexp t)
! 			case-fold-search)
  		      list-matching-lines-buffer-name-face
  		      nil list-matching-lines-face
  		      (not (eq occur-excluded-properties t)))))

Index: lisp/isearch.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.306
diff -c -r1.306 isearch.el
*** lisp/isearch.el	10 Nov 2007 23:03:24 -0000	1.306
--- lisp/isearch.el	24 Nov 2007 17:44:57 -0000
***************
*** 1256,1265 ****
--- 1257,1273 ----
    (interactive)
    (isearch-query-replace t))
  
+ (defun isearch-occur (regexp &optional nlines)
+   "Run `occur' with regexp to search from the current search string.
+ Interactively, REGEXP is the current search regexp or a quoted search
+ string.  NLINES has the same meaning as in `occur'."
+   (interactive
+    (list
+     (if isearch-regexp isearch-string (regexp-quote isearch-string))
+     (if current-prefix-arg (prefix-numeric-value current-prefix-arg))))
+   (let ((case-fold-search isearch-case-fold-search))
+     (occur regexp nlines)))
+ 
  \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] 33+ messages in thread

* Re: Calling occur from within isearch
  2007-11-23  4:35     ` Richard Stallman
@ 2007-11-24 17:45       ` Juri Linkov
  2007-11-25  3:42         ` Richard Stallman
  0 siblings, 1 reply; 33+ messages in thread
From: Juri Linkov @ 2007-11-24 17:45 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

> I don't want any more special search-mode bindings unless it is very
> important.  In fact, I would like to reduce them if possible.

I think this is an important feature.  But there is no need to add more
search-mode bindings that can be used to exit isearch.  It is even
possible to reduce them with the suggestion I already made a few times -
to use a new conflict-free key prefix M-s.

So I propose to install the following patch as a starting point
for adding more isearch key bindings to it later:

Index: lisp/isearch.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.306
diff -c -r1.306 isearch.el
*** lisp/isearch.el	10 Nov 2007 23:03:24 -0000	1.306
--- lisp/isearch.el	24 Nov 2007 17:45:45 -0000
***************
*** 411,416 ****
--- 411,417 ----
  
      (define-key map [?\M-%] 'isearch-query-replace)
      (define-key map [?\C-\M-%] 'isearch-query-replace-regexp)
+     (define-key map "\M-so" 'isearch-occur)
  
      map)
    "Keymap for `isearch-mode'.")

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

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

* Re: Calling occur from within isearch
  2007-11-24 17:45         ` Juri Linkov
@ 2007-11-25  3:42           ` Richard Stallman
  2007-11-25 15:27             ` Juri Linkov
  2007-12-03 23:25           ` Johan Bockgård
  1 sibling, 1 reply; 33+ messages in thread
From: Richard Stallman @ 2007-11-25  3:42 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel

    Since occur uses `isearch-no-upper-case-p' it seems reasonable for it
    to respect the value of `search-upper-case' as well.

That seems to make sense, but what does `isearch-occur' have
to do with it?

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

* Re: Calling occur from within isearch
  2007-11-24 17:45       ` Juri Linkov
@ 2007-11-25  3:42         ` Richard Stallman
  0 siblings, 0 replies; 33+ messages in thread
From: Richard Stallman @ 2007-11-25  3:42 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel

      It is even
    possible to reduce them with the suggestion I already made a few times -
    to use a new conflict-free key prefix M-s.

That might be a good idea, especially if we can eliminate a few of the
existing special isearch chars by moving them to M-s subcommands.  I
would very much like to get rid of the special isearch meaning of
M-TAB, M-c, M-r and M-e.  How about moving them to M-s TAB, M-s c, M-s
r and M-s e?

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

* Re: Calling occur from within isearch
  2007-11-25  3:42           ` Richard Stallman
@ 2007-11-25 15:27             ` Juri Linkov
  2007-12-03  0:37               ` Juri Linkov
  0 siblings, 1 reply; 33+ messages in thread
From: Juri Linkov @ 2007-11-25 15:27 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

>     Since occur uses `isearch-no-upper-case-p' it seems reasonable for it
>     to respect the value of `search-upper-case' as well.
>
> That seems to make sense, but what does `isearch-occur' have
> to do with it?

`isearch-occur' calls `occur', and occur needs to find exactly the
same occurrences as found by isearch.  Otherwise, it would be very
confusing to see the mismatch between the occurrences found by isearch
and occur.

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

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

* Re: Calling occur from within isearch
  2007-11-25 15:27             ` Juri Linkov
@ 2007-12-03  0:37               ` Juri Linkov
  2007-12-03 18:43                 ` Richard Stallman
  0 siblings, 1 reply; 33+ messages in thread
From: Juri Linkov @ 2007-12-03  0:37 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

>>     Since occur uses `isearch-no-upper-case-p' it seems reasonable for it
>>     to respect the value of `search-upper-case' as well.
>>
>> That seems to make sense, but what does `isearch-occur' have
>> to do with it?
>
> `isearch-occur' calls `occur', and occur needs to find exactly the
> same occurrences as found by isearch.  Otherwise, it would be very
> confusing to see the mismatch between the occurrences found by isearch
> and occur.

I think `keep-lines', `flush-lines', `how-many' and `perform-replace'
should respect the value of `search-upper-case' as well for exactly
the same reasons:

Index: lisp/replace.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/replace.el,v
retrieving revision 1.263
diff -c -r1.263 replace.el
*** lisp/replace.el	22 Nov 2007 03:01:36 -0000	1.263
--- lisp/replace.el	3 Dec 2007 00:37:19 -0000
***************
*** 597,604 ****
    (save-excursion
      (or (bolp) (forward-line 1))
      (let ((start (point))
! 	  (case-fold-search  (and case-fold-search
! 				  (isearch-no-upper-case-p regexp t))))
        (while (< (point) rend)
  	;; Start is first char not preserved by previous match.
  	(if (not (re-search-forward regexp rend 'move))
--- 597,606 ----
    (save-excursion
      (or (bolp) (forward-line 1))
      (let ((start (point))
! 	  (case-fold-search
! 	   (if (and (eq case-fold-search t) search-upper-case)
! 	       (isearch-no-upper-case-p regexp t)
! 	     case-fold-search)))
        (while (< (point) rend)
  	;; Start is first char not preserved by previous match.
  	(if (not (re-search-forward regexp rend 'move))
***************
*** 657,664 ****
        (setq rstart (point)
  	    rend (point-max-marker)))
      (goto-char rstart))
!   (let ((case-fold-search (and case-fold-search
! 			       (isearch-no-upper-case-p regexp t))))
      (save-excursion
        (while (and (< (point) rend)
  		  (re-search-forward regexp rend t))
--- 659,668 ----
        (setq rstart (point)
  	    rend (point-max-marker)))
      (goto-char rstart))
!   (let ((case-fold-search
! 	 (if (and (eq case-fold-search t) search-upper-case)
! 	     (isearch-no-upper-case-p regexp t)
! 	   case-fold-search)))
      (save-excursion
        (while (and (< (point) rend)
  		  (re-search-forward regexp rend t))
***************
*** 704,711 ****
        (goto-char rstart))
      (let ((count 0)
  	  opoint
! 	  (case-fold-search (and case-fold-search
! 				 (isearch-no-upper-case-p regexp t))))
        (while (and (< (point) rend)
  		  (progn (setq opoint (point))
  			 (re-search-forward regexp rend t)))
--- 708,717 ----
        (goto-char rstart))
      (let ((count 0)
  	  opoint
! 	  (case-fold-search
! 	   (if (and (eq case-fold-search t) search-upper-case)
! 	       (isearch-no-upper-case-p regexp t)
! 	     case-fold-search)))
        (while (and (< (point) rend)
  		  (progn (setq opoint (point))
  			 (re-search-forward regexp rend t)))
***************
*** 1119,1126 ****
  	(let ((count (occur-engine
  		      regexp active-bufs occur-buf
  		      (or nlines list-matching-lines-default-context-lines)
! 		      (and case-fold-search
! 			   (isearch-no-upper-case-p regexp t))
  		      list-matching-lines-buffer-name-face
  		      nil list-matching-lines-face
  		      (not (eq occur-excluded-properties t)))))
--- 1131,1139 ----
  	(let ((count (occur-engine
  		      regexp active-bufs occur-buf
  		      (or nlines list-matching-lines-default-context-lines)
! 		      (if (and (eq case-fold-search t) search-upper-case)
! 			  (isearch-no-upper-case-p regexp t)
! 			case-fold-search)
  		      list-matching-lines-buffer-name-face
  		      nil list-matching-lines-face
  		      (not (eq occur-excluded-properties t)))))
***************
*** 1459,1466 ****
    (and query-flag minibuffer-auto-raise
         (raise-frame (window-frame (minibuffer-window))))
    (let* ((case-fold-search
!           (and case-fold-search
!                (isearch-no-upper-case-p from-string regexp-flag)))
           (nocasify (not (and case-replace case-fold-search)))
           (literal (or (not regexp-flag) (eq regexp-flag 'literal)))
           (search-function (if regexp-flag 're-search-forward 'search-forward))
--- 1472,1480 ----
    (and query-flag minibuffer-auto-raise
         (raise-frame (window-frame (minibuffer-window))))
    (let* ((case-fold-search
! 	  (if (and (eq case-fold-search t) search-upper-case)
! 	      (isearch-no-upper-case-p from-string regexp-flag)
! 	    case-fold-search))
           (nocasify (not (and case-replace case-fold-search)))
           (literal (or (not regexp-flag) (eq regexp-flag 'literal)))
           (search-function (if regexp-flag 're-search-forward 'search-forward))

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

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

* Re: Calling occur from within isearch
  2007-12-03  0:37               ` Juri Linkov
@ 2007-12-03 18:43                 ` Richard Stallman
  2007-12-05 22:17                   ` Juri Linkov
  0 siblings, 1 reply; 33+ messages in thread
From: Richard Stallman @ 2007-12-03 18:43 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel

    I think `keep-lines', `flush-lines', `how-many' and `perform-replace'
    should respect the value of `search-upper-case' as well for exactly
    the same reasons:

That sounds reasonable to me.  Please update the doc string of
`search-upper-case' to go with these changes.

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

* Re: Calling occur from within isearch
  2007-11-24 17:45         ` Juri Linkov
  2007-11-25  3:42           ` Richard Stallman
@ 2007-12-03 23:25           ` Johan Bockgård
  2007-12-04  0:27             ` Juri Linkov
  1 sibling, 1 reply; 33+ messages in thread
From: Johan Bockgård @ 2007-12-03 23:25 UTC (permalink / raw)
  To: emacs-devel

Juri Linkov <juri@jurta.org> writes:

> !  (if (and (eq case-fold-search t) search-upper-case)
> !      (isearch-no-upper-case-p regexp t)
> !    case-fold-search)

This seems kind of ugly.  The documentation for case-fold-search doesn't
talk about any special meaning of a non-nil, non-t value.

-- 
Johan Bockgård

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

* Re: Calling occur from within isearch
  2007-12-03 23:25           ` Johan Bockgård
@ 2007-12-04  0:27             ` Juri Linkov
  2007-12-04  1:24               ` Johan Bockgård
  2007-12-04 10:35               ` Andreas Schwab
  0 siblings, 2 replies; 33+ messages in thread
From: Juri Linkov @ 2007-12-04  0:27 UTC (permalink / raw)
  To: emacs-devel

>> !  (if (and (eq case-fold-search t) search-upper-case)
>> !      (isearch-no-upper-case-p regexp t)
>> !    case-fold-search)
>
> This seems kind of ugly.  The documentation for case-fold-search doesn't
> talk about any special meaning of a non-nil, non-t value.

What is ugly is that the distinction between `yes' and `t' is mentioned
only in the comments of `isearch-case-fold-search' as if they were
"unofficial" values:

    ; case-fold-search while searching.
    ;   either nil, t, or 'yes.  'yes means the same as t except that mixed
    ;   case in the search string is ignored.
    (defvar isearch-case-fold-search nil)

If these values are valid, then perhaps they should be documented in the
docstrings of `isearch-case-fold-search' and `case-fold-search' saying
that the distinction between `yes' and `t' is valid for some searching
interactive commands.

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

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

* Re: Calling occur from within isearch
  2007-12-04  0:27             ` Juri Linkov
@ 2007-12-04  1:24               ` Johan Bockgård
  2007-12-04 22:43                 ` Juri Linkov
  2007-12-04 10:35               ` Andreas Schwab
  1 sibling, 1 reply; 33+ messages in thread
From: Johan Bockgård @ 2007-12-04  1:24 UTC (permalink / raw)
  To: emacs-devel

Juri Linkov <juri@jurta.org> writes:

> What is ugly is that the distinction between `yes' and `t' is
> mentioned only in the comments of `isearch-case-fold-search' as if
> they were "unofficial" values:

I think they are.  isearch-case-fold-search is an internal detail of
isearch...

> If these values are valid, then perhaps they should be documented in
> the docstrings of `isearch-case-fold-search'

...it doesn't even *have* a doc string.

> saying that the distinction between `yes' and `t' is valid for some
> searching interactive commands.

I can't see how this distinction is at all useful for the user.
`search-uppercase' already provides a (the) way to decide whether "mixed
case in the search string [should be] ignored":

    (if (and case-fold-search search-upper-case)
        (isearch-no-upper-case-p regexp t)
      case-fold-search)


In the case of occur from within isearch, the current value of
isearch-case-fold-search will make searching find the right matches--if
occur does *not* look at the case of the input again

    (let ((case-fold-search isearch-case-fold-search)
          (search-upper-case nil))
      (occur regexp nlines))

-- 
Johan Bockgård

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

* Re: Calling occur from within isearch
  2007-12-04  0:27             ` Juri Linkov
  2007-12-04  1:24               ` Johan Bockgård
@ 2007-12-04 10:35               ` Andreas Schwab
  1 sibling, 0 replies; 33+ messages in thread
From: Andreas Schwab @ 2007-12-04 10:35 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel

Juri Linkov <juri@jurta.org> writes:

> What is ugly is that the distinction between `yes' and `t' is mentioned
> only in the comments of `isearch-case-fold-search' as if they were
> "unofficial" values:
>
>     ; case-fold-search while searching.
>     ;   either nil, t, or 'yes.  'yes means the same as t except that mixed
>     ;   case in the search string is ignored.
>     (defvar isearch-case-fold-search nil)

I'd rather use a more descriptive name for the value, like
'ignore-mixed-case.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: Calling occur from within isearch
  2007-12-04  1:24               ` Johan Bockgård
@ 2007-12-04 22:43                 ` Juri Linkov
  2007-12-04 23:59                   ` Johan Bockgård
  0 siblings, 1 reply; 33+ messages in thread
From: Juri Linkov @ 2007-12-04 22:43 UTC (permalink / raw)
  To: emacs-devel

>> saying that the distinction between `yes' and `t' is valid for some
>> searching interactive commands.
>
> I can't see how this distinction is at all useful for the user.
> `search-uppercase' already provides a (the) way to decide whether "mixed
> case in the search string [should be] ignored":
>
>     (if (and case-fold-search search-upper-case)
>         (isearch-no-upper-case-p regexp t)
>       case-fold-search)

I can't comment why isearch functions use `(eq case-fold-search t)',
but I think other interactive search-related commands like occur
should use the same condition, whatever it is.

> In the case of occur from within isearch, the current value of
> isearch-case-fold-search will make searching find the right matches--if
> occur does *not* look at the case of the input again
>
>     (let ((case-fold-search isearch-case-fold-search)
>           (search-upper-case nil))
>       (occur regexp nlines))

What code in occur for this case do you have in mind?

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

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

* Re: Calling occur from within isearch
  2007-12-04 22:43                 ` Juri Linkov
@ 2007-12-04 23:59                   ` Johan Bockgård
  2007-12-05 22:16                     ` Juri Linkov
  0 siblings, 1 reply; 33+ messages in thread
From: Johan Bockgård @ 2007-12-04 23:59 UTC (permalink / raw)
  To: emacs-devel

Juri Linkov <juri@jurta.org> writes:

>>> saying that the distinction between `yes' and `t' is valid for some
>>> searching interactive commands.
>>
>> I can't see how this distinction is at all useful for the user.
>> `search-uppercase' already provides a (the) way to decide whether "mixed
>> case in the search string [should be] ignored":
>>
>>     (if (and case-fold-search search-upper-case)
>>         (isearch-no-upper-case-p regexp t)
>>       case-fold-search)
>
> I can't comment why isearch functions use `(eq case-fold-search t)',
> but I think other interactive search-related commands like occur
> should use the same condition, whatever it is.

Note that the preceding line is

    (let ((case-fold-search isearch-case-fold-search))

and that there are two other places in isearch that use

    (and (eq isearch-case-fold-search t) search-upper-case)


Isearch needs the third value `yes' to handle the M-c feature (see
isearch-toggle-case-fold)

    C-s ABC M-c   => search is now case-insensitive, despite uppercase input

This is the only situation where `yes' is used; case-fold-search never
has this value outside isearch.

Other search functions have no use for this.

>> In the case of occur from within isearch, the current value of
>> isearch-case-fold-search will make searching find the right matches--if
>> occur does *not* look at the case of the input again
>>
>>     (let ((case-fold-search isearch-case-fold-search)
>>           (search-upper-case nil))
>>       (occur regexp nlines))
>
> What code in occur for this case do you have in mind?

isearch-occur should do this.  Isearch has already decided if the search
should be case-sensitive or not, so occur should not consider input
case.

-- 
Johan Bockgård

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

* Re: Calling occur from within isearch
  2007-12-04 23:59                   ` Johan Bockgård
@ 2007-12-05 22:16                     ` Juri Linkov
  0 siblings, 0 replies; 33+ messages in thread
From: Juri Linkov @ 2007-12-05 22:16 UTC (permalink / raw)
  To: emacs-devel

>>> In the case of occur from within isearch, the current value of
>>> isearch-case-fold-search will make searching find the right matches--if
>>> occur does *not* look at the case of the input again
>>>
>>>     (let ((case-fold-search isearch-case-fold-search)
>>>           (search-upper-case nil))
>>>       (occur regexp nlines))
>>
>> What code in occur for this case do you have in mind?
>
> isearch-occur should do this.  Isearch has already decided if the search
> should be case-sensitive or not, so occur should not consider input case.

Setting `search-upper-case' to nil in `isearch-occur' just to skip
the `isearch-no-upper-case-p' test in occur can be named ugly too.
But perhaps this is less ugly that testing for `(eq case-fold-search t)'
in occur.  So I am not against using this approach that produces the same
results with the following patch:

Index: lisp/isearch.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.306
diff -c -r1.306 isearch.el
*** lisp/isearch.el	10 Nov 2007 23:03:24 -0000	1.306
--- lisp/isearch.el	5 Dec 2007 22:16:03 -0000
***************
*** 1230,1236 ****
    (interactive)
    (barf-if-buffer-read-only)
    (if regexp-flag (setq isearch-regexp t))
!   (let ((case-fold-search isearch-case-fold-search))
      (isearch-done)
      (isearch-clean-overlays)
      (if (and isearch-other-end
--- 1231,1238 ----
    (interactive)
    (barf-if-buffer-read-only)
    (if regexp-flag (setq isearch-regexp t))
!   (let ((case-fold-search isearch-case-fold-search)
! 	(search-upper-case nil))
      (isearch-done)
      (isearch-clean-overlays)
      (if (and isearch-other-end
***************
*** 1256,1265 ****
--- 1258,1275 ----
    (interactive)
    (isearch-query-replace t))
  
+ (defun isearch-occur (regexp &optional nlines)
+   "Run `occur' with regexp to search from the current search string.
+ Interactively, REGEXP is the current search regexp or a quoted search
+ string.  NLINES has the same meaning as in `occur'."
+   (interactive
+    (list
+     (if isearch-regexp isearch-string (regexp-quote isearch-string))
+     (if current-prefix-arg (prefix-numeric-value current-prefix-arg))))
+   (let ((case-fold-search isearch-case-fold-search)
+ 	(search-upper-case nil))
+     (occur regexp nlines)))
+ 
  \f
  (defun isearch-delete-char ()
    "Discard last input item and move point back.

Index: lisp/replace.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/replace.el,v
retrieving revision 1.263
diff -c -r1.263 replace.el
*** lisp/replace.el	22 Nov 2007 03:01:36 -0000	1.263
--- lisp/replace.el	5 Dec 2007 22:16:09 -0000
***************
*** 552,559 ****
  When called from Lisp (and usually interactively as well, see below)
  applies to all lines starting after point.
  
! If REGEXP contains upper case characters (excluding those preceded by `\\'),
! the matching is case-sensitive.
  
  Second and third arg RSTART and REND specify the region to operate on.
  This command operates on (the accessible part of) all lines whose
--- 552,559 ----
  When called from Lisp (and usually interactively as well, see below)
  applies to all lines starting after point.
  
! If REGEXP contains upper case characters (excluding those preceded by `\\')
! and `search-upper-case' is non-nil, the matching is case-sensitive.
  
  Second and third arg RSTART and REND specify the region to operate on.
  This command operates on (the accessible part of) all lines whose
***************
*** 597,604 ****
    (save-excursion
      (or (bolp) (forward-line 1))
      (let ((start (point))
! 	  (case-fold-search  (and case-fold-search
! 				  (isearch-no-upper-case-p regexp t))))
        (while (< (point) rend)
  	;; Start is first char not preserved by previous match.
  	(if (not (re-search-forward regexp rend 'move))
--- 597,606 ----
    (save-excursion
      (or (bolp) (forward-line 1))
      (let ((start (point))
! 	  (case-fold-search
! 	   (if (and case-fold-search search-upper-case)
! 	       (isearch-no-upper-case-p regexp t)
! 	     case-fold-search)))
        (while (< (point) rend)
  	;; Start is first char not preserved by previous match.
  	(if (not (re-search-forward regexp rend 'move))
***************
*** 626,633 ****
  The line point is in is deleted if and only if it contains a
  match for regexp starting after point.
  
! If REGEXP contains upper case characters (excluding those preceded by `\\'),
! the matching is case-sensitive.
  
  Second and third arg RSTART and REND specify the region to operate on.
  Lines partially contained in this region are deleted if and only if
--- 628,635 ----
  The line point is in is deleted if and only if it contains a
  match for regexp starting after point.
  
! If REGEXP contains upper case characters (excluding those preceded by `\\')
! and `search-upper-case' is non-nil, the matching is case-sensitive.
  
  Second and third arg RSTART and REND specify the region to operate on.
  Lines partially contained in this region are deleted if and only if
***************
*** 657,664 ****
        (setq rstart (point)
  	    rend (point-max-marker)))
      (goto-char rstart))
!   (let ((case-fold-search (and case-fold-search
! 			       (isearch-no-upper-case-p regexp t))))
      (save-excursion
        (while (and (< (point) rend)
  		  (re-search-forward regexp rend t))
--- 659,668 ----
        (setq rstart (point)
  	    rend (point-max-marker)))
      (goto-char rstart))
!   (let ((case-fold-search
! 	 (if (and case-fold-search search-upper-case)
! 	     (isearch-no-upper-case-p regexp t)
! 	   case-fold-search)))
      (save-excursion
        (while (and (< (point) rend)
  		  (re-search-forward regexp rend t))
***************
*** 676,683 ****
  the number, do not print it; if INTERACTIVE is t, the function behaves
  in all respects has if it had been called interactively.
  
! If REGEXP contains upper case characters (excluding those preceded by `\\'),
! the matching is case-sensitive.
  
  Second and third arg RSTART and REND specify the region to operate on.
  
--- 680,687 ----
  the number, do not print it; if INTERACTIVE is t, the function behaves
  in all respects has if it had been called interactively.
  
! If REGEXP contains upper case characters (excluding those preceded by `\\')
! and `search-upper-case' is non-nil, the matching is case-sensitive.
  
  Second and third arg RSTART and REND specify the region to operate on.
  
***************
*** 704,711 ****
        (goto-char rstart))
      (let ((count 0)
  	  opoint
! 	  (case-fold-search (and case-fold-search
! 				 (isearch-no-upper-case-p regexp t))))
        (while (and (< (point) rend)
  		  (progn (setq opoint (point))
  			 (re-search-forward regexp rend t)))
--- 708,717 ----
        (goto-char rstart))
      (let ((count 0)
  	  opoint
! 	  (case-fold-search
! 	   (if (and case-fold-search search-upper-case)
! 	       (isearch-no-upper-case-p regexp t)
! 	     case-fold-search)))
        (while (and (< (point) rend)
  		  (progn (setq opoint (point))
  			 (re-search-forward regexp rend t)))
***************
*** 1030,1037 ****
  It serves as a menu to find any of the occurrences in this buffer.
  \\<occur-mode-map>\\[describe-mode] in that buffer will explain how.
  
! If REGEXP contains upper case characters (excluding those preceded by `\\'),
! the matching is case-sensitive."
    (interactive (occur-read-primary-args))
    (occur-1 regexp nlines (list (current-buffer))))
  
--- 1042,1049 ----
  It serves as a menu to find any of the occurrences in this buffer.
  \\<occur-mode-map>\\[describe-mode] in that buffer will explain how.
  
! If REGEXP contains upper case characters (excluding those preceded by `\\')
! and `search-upper-case' is non-nil, the matching is case-sensitive."
    (interactive (occur-read-primary-args))
    (occur-1 regexp nlines (list (current-buffer))))
  
***************
*** 1119,1126 ****
  	(let ((count (occur-engine
  		      regexp active-bufs occur-buf
  		      (or nlines list-matching-lines-default-context-lines)
! 		      (and case-fold-search
! 			   (isearch-no-upper-case-p regexp t))
  		      list-matching-lines-buffer-name-face
  		      nil list-matching-lines-face
  		      (not (eq occur-excluded-properties t)))))
--- 1131,1139 ----
  	(let ((count (occur-engine
  		      regexp active-bufs occur-buf
  		      (or nlines list-matching-lines-default-context-lines)
! 		      (if (and case-fold-search search-upper-case)
! 			  (isearch-no-upper-case-p regexp t)
! 			case-fold-search)
  		      list-matching-lines-buffer-name-face
  		      nil list-matching-lines-face
  		      (not (eq occur-excluded-properties t)))))
***************
*** 1459,1466 ****
    (and query-flag minibuffer-auto-raise
         (raise-frame (window-frame (minibuffer-window))))
    (let* ((case-fold-search
!           (and case-fold-search
!                (isearch-no-upper-case-p from-string regexp-flag)))
           (nocasify (not (and case-replace case-fold-search)))
           (literal (or (not regexp-flag) (eq regexp-flag 'literal)))
           (search-function (if regexp-flag 're-search-forward 'search-forward))
--- 1472,1480 ----
    (and query-flag minibuffer-auto-raise
         (raise-frame (window-frame (minibuffer-window))))
    (let* ((case-fold-search
! 	  (if (and case-fold-search search-upper-case)
! 	      (isearch-no-upper-case-p from-string regexp-flag)
! 	    case-fold-search))
           (nocasify (not (and case-replace case-fold-search)))
           (literal (or (not regexp-flag) (eq regexp-flag 'literal)))
           (search-function (if regexp-flag 're-search-forward 'search-forward))

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

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

* Re: Calling occur from within isearch
  2007-12-03 18:43                 ` Richard Stallman
@ 2007-12-05 22:17                   ` Juri Linkov
  2007-12-06  1:29                     ` Johan Bockgård
  0 siblings, 1 reply; 33+ messages in thread
From: Juri Linkov @ 2007-12-05 22:17 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

>     I think `keep-lines', `flush-lines', `how-many' and `perform-replace'
>     should respect the value of `search-upper-case' as well for exactly
>     the same reasons:
>
> That sounds reasonable to me.  Please update the doc string of
> `search-upper-case' to go with these changes.

I see that the doc string of `search-upper-case' is already complete.
What is necessary is to mention `search-upper-case' in doc strings
of functions `keep-lines', `flush-lines', `how-many' that use it.
I did this in the latest sent patch.

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

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

* Re: Calling occur from within isearch
  2007-12-05 22:17                   ` Juri Linkov
@ 2007-12-06  1:29                     ` Johan Bockgård
  0 siblings, 0 replies; 33+ messages in thread
From: Johan Bockgård @ 2007-12-06  1:29 UTC (permalink / raw)
  To: emacs-devel

Juri Linkov <juri@jurta.org> writes:

> I see that the doc string of `search-upper-case' is already complete.
> What is necessary is to mention `search-upper-case' in doc strings
> of functions `keep-lines', `flush-lines', `how-many' that use it.

The doc for `search-upper-case' might want to mention that the
`not-yanks' value has a special effect only in isearch.

-- 
Johan Bockgård

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

end of thread, other threads:[~2007-12-06  1:29 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-21 19:57 Calling occur from within isearch Lennart Borgman (gmail)
2007-11-21 20:03 ` Juri Linkov
2007-11-21 20:25   ` Lennart Borgman (gmail)
2007-11-22 19:08     ` Juri Linkov
2007-11-22 19:38       ` Drew Adams
2007-11-22 21:48       ` Lennart Borgman (gmail)
2007-11-22  0:30   ` Johan Bockgård
2007-11-22 19:04     ` Juri Linkov
2007-11-23  0:52       ` Juri Linkov
2007-11-23  1:05       ` Johan Bockgård
2007-11-24 17:45         ` Juri Linkov
2007-11-25  3:42           ` Richard Stallman
2007-11-25 15:27             ` Juri Linkov
2007-12-03  0:37               ` Juri Linkov
2007-12-03 18:43                 ` Richard Stallman
2007-12-05 22:17                   ` Juri Linkov
2007-12-06  1:29                     ` Johan Bockgård
2007-12-03 23:25           ` Johan Bockgård
2007-12-04  0:27             ` Juri Linkov
2007-12-04  1:24               ` Johan Bockgård
2007-12-04 22:43                 ` Juri Linkov
2007-12-04 23:59                   ` Johan Bockgård
2007-12-05 22:16                     ` Juri Linkov
2007-12-04 10:35               ` Andreas Schwab
2007-11-21 20:07 ` Drew Adams
2007-11-22 16:21 ` Richard Stallman
2007-11-22 18:16   ` Stefan Monnier
2007-11-22 19:05     ` Juri Linkov
2007-11-22 21:23       ` Stefan Monnier
2007-11-22 19:05   ` Juri Linkov
2007-11-23  4:35     ` Richard Stallman
2007-11-24 17:45       ` Juri Linkov
2007-11-25  3:42         ` Richard Stallman

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).