unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Want to grep for text in selected coding...
@ 2012-02-15  9:52 Oleksandr Gavenko
  2012-02-15 15:57 ` Kevin Rodgers
  2012-02-15 17:07 ` Eli Zaretskii
  0 siblings, 2 replies; 9+ messages in thread
From: Oleksandr Gavenko @ 2012-02-15  9:52 UTC (permalink / raw)
  To: help-gnu-emacs

I am big fun of 'rgrep' but some times I need search for text in coding that
differ from system coding (like for text in koi8-r in UTF-8 Debian or UTF-8
text in cp1251 Windows).

I try 'C-x RET C coding... RET M-x rgrep' (universal-coding-system-argument)
but this is not help.

-- 
Best regards!




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

* Re: Want to grep for text in selected coding...
  2012-02-15  9:52 Want to grep for text in selected coding Oleksandr Gavenko
@ 2012-02-15 15:57 ` Kevin Rodgers
  2012-02-15 17:07 ` Eli Zaretskii
  1 sibling, 0 replies; 9+ messages in thread
From: Kevin Rodgers @ 2012-02-15 15:57 UTC (permalink / raw)
  To: help-gnu-emacs

On 2/15/12 2:52 AM, Oleksandr Gavenko wrote:
> I am big fun of 'rgrep' but some times I need search for text in coding that
> differ from system coding (like for text in koi8-r in UTF-8 Debian or UTF-8
> text in cp1251 Windows).
>
> I try 'C-x RET C coding... RET M-x rgrep' (universal-coding-system-argument)
> but this is not help.

This is an issue with the system grep command that rgrep invokes.

-- 
Kevin Rodgers
Denver, Colorado, USA




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

* Re: Want to grep for text in selected coding...
  2012-02-15  9:52 Want to grep for text in selected coding Oleksandr Gavenko
  2012-02-15 15:57 ` Kevin Rodgers
@ 2012-02-15 17:07 ` Eli Zaretskii
  2012-02-28 19:47   ` Oleksandr Gavenko
  1 sibling, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2012-02-15 17:07 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Oleksandr Gavenko <gavenko@bifit.com.ua>
> Date: Wed, 15 Feb 2012 11:52:44 +0200
> 
> I am big fun of 'rgrep' but some times I need search for text in coding that
> differ from system coding (like for text in koi8-r in UTF-8 Debian or UTF-8
> text in cp1251 Windows).
> 
> I try 'C-x RET C coding... RET M-x rgrep' (universal-coding-system-argument)
> but this is not help.

You cannot change the grep program by Emacs wizardry.

I suggest to use "M-x occur" and its derivatives instead.



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

* Re: Want to grep for text in selected coding...
  2012-02-15 17:07 ` Eli Zaretskii
@ 2012-02-28 19:47   ` Oleksandr Gavenko
  2012-02-28 20:29     ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Oleksandr Gavenko @ 2012-02-28 19:47 UTC (permalink / raw)
  To: help-gnu-emacs

On 2012-02-15, Eli Zaretskii wrote:

>> From: Oleksandr Gavenko <gavenko@bifit.com.ua>
>> Date: Wed, 15 Feb 2012 11:52:44 +0200
>> 
>> I am big fun of 'rgrep' but some times I need search for text in coding that
>> differ from system coding (like for text in koi8-r in UTF-8 Debian or UTF-8
>> text in cp1251 Windows).
>> 
>> I try 'C-x RET C coding... RET M-x rgrep' (universal-coding-system-argument)
>> but this is not help.
>
> You cannot change the grep program by Emacs wizardry.
>
> I suggest to use "M-x occur" and its derivatives instead.
>
Sorry for long delay in respond.

Just for info I ask same question at:

http://stackoverflow.com/questions/9290211/look-how-to-search-a-text-in-selected-coding-system-in-files-hierarhy


Personally I found bad about Emacs that it depends on tools which come from
'70 (like find, grep, ls) and work perfectly only with LANG=C.

Two year ago with help from gnu.emacs.help I make Dired independent from
system 'ls' (Cygwin ls use my LANG=cp1251 but Cygwin /etc/passwd always use
UTF-8 so I have wrongly displayed owner filed which broke column indenting):

  ;; If non-nil - use 'insert-directory-program', which I dislike.
  (setq ls-lisp-use-insert-directory-program nil)
  (setq ls-lisp-ignore-case t)
  (setq ls-lisp-dirs-first t)
  (if (memq system-type '(windows-nt cygwin))
      (setq ls-lisp-verbosity nil)
    (setq  ls-lisp-verbosity '(links uid gid)))
  ;; Force use 'ls-lisp-format-time-list'.
  (setq ls-lisp-use-localized-time-format t)
  (setq ls-lisp-format-time-list
        '("%Y-%m-%d %H:%M:%S"
          "%Y-%m-%d %H:%M   "))
  (require 'ls-lisp)


Now time for ))GREP(( independent search... Only with Emacs build-ins...

Emacs must take example from Far manager which have option to perform search
in all codings suitable  for Russian lang (cp866, cp1251, koi8-r, UTF-8).

I can not use Emacs in translation project where I need fix all occurrence of
wrong translation.

What possibilities exist in this filed?

-- 
Best regards!




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

* Re: Want to grep for text in selected coding...
  2012-02-28 19:47   ` Oleksandr Gavenko
@ 2012-02-28 20:29     ` Eli Zaretskii
  2012-02-28 21:18       ` Oleksandr Gavenko
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2012-02-28 20:29 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Oleksandr Gavenko <gavenkoa@gmail.com>
> Date: Tue, 28 Feb 2012 21:47:10 +0200
> 
> > I suggest to use "M-x occur" and its derivatives instead.
> 
> Personally I found bad about Emacs that it depends on tools which come from
> '70 (like find, grep, ls) and work perfectly only with LANG=C.

??? But I just suggested (above) that you use "M-x occur", which does
NOT depend on any external tool, and DOES handle every possible
encoding and locale on Earth.

> Emacs must take example from Far manager which have option to perform search
> in all codings suitable  for Russian lang (cp866, cp1251, koi8-r, UTF-8).

??? But "occur" can already do that.

> I can not use Emacs in translation project where I need fix all occurrence of
> wrong translation.
> 
> What possibilities exist in this filed?

Is anything wrong with "M-x occur"?



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

* Re: Want to grep for text in selected coding...
  2012-02-28 20:29     ` Eli Zaretskii
@ 2012-02-28 21:18       ` Oleksandr Gavenko
  2012-02-28 21:33         ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Oleksandr Gavenko @ 2012-02-28 21:18 UTC (permalink / raw)
  To: help-gnu-emacs

On 2012-02-28, Eli Zaretskii wrote:

>> From: Oleksandr Gavenko <gavenkoa@gmail.com>
>> Date: Tue, 28 Feb 2012 21:47:10 +0200
>> 
>> > I suggest to use "M-x occur" and its derivatives instead.
>> 
>> Personally I found bad about Emacs that it depends on tools which come from
>> '70 (like find, grep, ls) and work perfectly only with LANG=C.
>
> ??? But I just suggested (above) that you use "M-x occur", which does
> NOT depend on any external tool, and DOES handle every possible
> encoding and locale on Earth.
>

==>Show all lines in the **current buffer** containing a match for REGEXP.

I highlight limitation of occur. Sorry for bad explaining of problem in
previous posts...

"M-s o" is my most frequent key sequence after "C-s" and "C-x o" ))

But when I need search in a set of files... occur fail.

>> Emacs must take example from Far manager which have option to perform search
>> in all codings suitable  for Russian lang (cp866, cp1251, koi8-r, UTF-8).
>
> ??? But "occur" can already do that.
>
Yes for single file and NO for multiply files...

What I forget mention that Far file manager make search in all possible encodings
in single user request!

For English people this feature may look quite silly but I am sad when see how
my colleges just perform work in Far while I read about coding system, read
Emacs manual and look for answer over Internet for basic feature like
searching...


Currently I think that I need enhanced version of "find/grep" and bind in to
Emacs (which perform search in >>file hierarchy<< in selected set of >>coding system<<
at once).

Anyone have suggestions?


I would like to see recursive search in selected coding system as Emacs core
feature without any external dependency... Has it sense to request this feature
at bug-gnu-emacs@gnu.org?

-- 
Best regards!




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

* Re: Want to grep for text in selected coding...
  2012-02-28 21:18       ` Oleksandr Gavenko
@ 2012-02-28 21:33         ` Eli Zaretskii
  2012-02-28 21:46           ` Oleksandr Gavenko
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2012-02-28 21:33 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Oleksandr Gavenko <gavenkoa@gmail.com>
> Date: Tue, 28 Feb 2012 23:18:25 +0200
> 
> > ??? But "occur" can already do that.
> >
> Yes for single file and NO for multiply files...
> 
> What I forget mention that Far file manager make search in all possible encodings
> in single user request!

Have some faith in Emacs!  There's "M-x multi-occur" to search
multiple buffers, and there're the `A' and `Q' commands in Dired.  And
that's just for starters.

And, btw, you should be able to use "C-x RET c" before "M-x rgrep" to
search for any encoding with Grep as well.



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

* Re: Want to grep for text in selected coding...
  2012-02-28 21:33         ` Eli Zaretskii
@ 2012-02-28 21:46           ` Oleksandr Gavenko
  2012-02-29 16:58             ` Oleksandr Gavenko
  0 siblings, 1 reply; 9+ messages in thread
From: Oleksandr Gavenko @ 2012-02-28 21:46 UTC (permalink / raw)
  To: help-gnu-emacs

On 2012-02-28, Eli Zaretskii wrote:

>> From: Oleksandr Gavenko <gavenkoa@gmail.com>
>> Date: Tue, 28 Feb 2012 23:18:25 +0200
>> 
>> > ??? But "occur" can already do that.
>> >
>> Yes for single file and NO for multiply files...
>> 
>> What I forget mention that Far file manager make search in all possible
>> encodings in single user request!
>
> Have some faith in Emacs!  There's "M-x multi-occur" to search
> multiple buffers, and there're the `A' and `Q' commands in Dired.  And
> that's just for starters.
>
This is new to me. Thanks for info.

Next your suggestion is more suitable for me:

> And, btw, you should be able to use "C-x RET c" before "M-x rgrep" to
> search for any encoding with Grep as well.
>
I often use "C-x RET c" and try your suggestion previously.

My first attempt work under Linux but I forget condition when it fail.

Next morning I try all cases that I can use in practice...

-- 
Best regards!




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

* Re: Want to grep for text in selected coding...
  2012-02-28 21:46           ` Oleksandr Gavenko
@ 2012-02-29 16:58             ` Oleksandr Gavenko
  0 siblings, 0 replies; 9+ messages in thread
From: Oleksandr Gavenko @ 2012-02-29 16:58 UTC (permalink / raw)
  To: help-gnu-emacs

On 2012-02-28, Oleksandr Gavenko wrote:
> On 2012-02-28, Eli Zaretskii wrote:
>> And, btw, you should be able to use "C-x RET c" before "M-x rgrep" to
>> search for any encoding with Grep as well.
>>
> I often use "C-x RET c" and try your suggestion previously.
>
> My first attempt work under Linux but I forget condition when it fail.
>
> Next morning I try all cases that I can use in practice...

I checked with negative result...

Both Emacs 23.3 and 24.0.91 are affected. Both are from ftp.gnu.org for
Windows with Cygwin grep command.

My setup is system wide 'LANG=ru_RU.cp1251' to make Cygwin Russian friendly.

Then I start "emacs -q" I start experimenting with M-x lgrep and such file:

  cp866       ЏаЁўҐв!
  cp1251      Привет!
  koi8-r      рТЙЧЕФ!
  utf-8       Привет!

All work fine ("C-x RET c cp1251 RET M-x lgrep RET Привет! RET *.txt RET"):

  text.txt:2:cp1251      Привет!

But if I load my .emacs file test was failed.

I debug issue to most simple call:

  (call-process shell-file-name nil t nil "-c" "grep -nH -e 'Привет!' *.txt")

which fail with or without loading my .emacs

So I start "emacs -q" and try evaluate above expression. All fine!

Next I eval (if you remember my LANG=ru_RU.cp1251)

 (setenv "LANG" "C")

because 'lgrep' call 'compilation-start' with temporary change LANG env var
before 'call-process'.

Evaluation of 'call-process' return "1" without output!

Next I eval

  (setq shell-file-name "bash")

to get more close environment to my .emacs and get from 'call-process':

  /usr/bin/bash: $'grep   -nH -e \'\320\237\321\200\320\270\320\262\320\265\321\202\' *.txt': command not found

If you remember I say that under Debian and Windows with -q "M-x lgrep" work
fine with Russian search string.

If I change LANG from Cygwin shell (mintty) - grep work fine:

  $ LANG=C grep -nH -e 'Привет!' *.txt
  text.txt:2:cp1251      Привет!

  $ LANG=C grep -nH -e 'ЏаЁўҐв!' *.txt
  text.txt:1:cp866       ЏаЁўҐв!

Is this a bug in Emacs or in Cygwin?

Currently I don't need to work in Widows as leave my job but next job can
change this statement...

That is why I am so harsh in my previous post...

-- 
Best regards!




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

end of thread, other threads:[~2012-02-29 16:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-15  9:52 Want to grep for text in selected coding Oleksandr Gavenko
2012-02-15 15:57 ` Kevin Rodgers
2012-02-15 17:07 ` Eli Zaretskii
2012-02-28 19:47   ` Oleksandr Gavenko
2012-02-28 20:29     ` Eli Zaretskii
2012-02-28 21:18       ` Oleksandr Gavenko
2012-02-28 21:33         ` Eli Zaretskii
2012-02-28 21:46           ` Oleksandr Gavenko
2012-02-29 16:58             ` Oleksandr Gavenko

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