unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#7308: [patch] locate under windoze
@ 2010-10-30 19:50 Eduard Wiebe
  2010-10-30 21:21 ` Eli Zaretskii
                   ` (3 more replies)
  0 siblings, 4 replies; 24+ messages in thread
From: Eduard Wiebe @ 2010-10-30 19:50 UTC (permalink / raw)
  To: 7308

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


  Hello,

i want to use `locate' under windoze system.  Unfortunately locate (in
interaction with dired) doesn't work proper in such a case.
The problem is the unquoted backslash in a located file path.
So i fix this issue by following patch. BTW i customized hook variables
and added autoloads.

-- 
Eduard Wiebe

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: locate_under_windoze.diff --]
[-- Type: text/x-diff, Size: 2557 bytes --]

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d7a6399..37f09e7 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
+2010-10-23  Eduard Wiebe <usenet@pusto.de>
+
+	* dired.el (dired-get-filename): Quote path delimiter under
+	windows-nt and ms-dos systems, needed for `locate' under this
+	systems.
+	* locate.el (locate-default-make-command-line): Simplify
+	`directory-listing-before-filename-regexp'.
+	(locate-post-command-hook, locate-post-command-hook): Customized
+	and add autoload.
+
 2010-10-30  Alan Mackenzie  <acm@muc.de>
 
 	* progmodes/cc-fonts.el (c-font-lock-enum-tail): New function
diff --git a/lisp/dired.el b/lisp/dired.el
index f840b60..d1c2ccb 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -2011,6 +2011,10 @@ Otherwise, an error occurs in these cases."
           ;; with quotation marks in their names.
 	  (while (string-match "\\(?:[^\\]\\|\\`\\)\\(\"\\)" file)
 	    (setq file (replace-match "\\\"" nil t file 1)))
+	  
+	  (when (member system-type '(ms-dos windows-nt))
+	    (setq file (replace-regexp-in-string "\\\\" "\\\\\\\\" file)))
+
           (setq file (read (concat "\"" file "\"")))
 	  ;; The above `read' will return a unibyte string if FILE
 	  ;; contains eight-bit-control/graphic characters.
diff --git a/lisp/locate.el b/lisp/locate.el
index f1983a3..e07acde 100644
--- a/lisp/locate.el
+++ b/lisp/locate.el
@@ -145,6 +145,12 @@ the version.)"
   :type 'string
   :group 'locate)
 
+;;;###autoload
+(defcustom locate-post-command-hook nil
+  "List of hook functions run after `locate' (see `run-hooks')."
+  :type  'hook
+  :group 'locate)
+
 (defvar locate-history-list nil
   "The history list used by the \\[locate] command.")
 
@@ -226,6 +232,12 @@ that is, with a prefix arg, you get the default behavior."
   :group 'locate
   :type 'boolean)
 
+;;;###autoload
+(defcustom locate-mode-hook nil
+  "List of hook functions run by `locate-mode' (see `run-mode-hooks')."
+  :type  'hook
+  :group 'locate)
+
 ;; Functions
 
 (defun locate-default-make-command-line (search-string)
@@ -473,9 +485,9 @@ do not work in subdirectories.
   (make-local-variable 'directory-listing-before-filename-regexp)
   ;; This should support both Unix and Windoze style names
   (setq directory-listing-before-filename-regexp
-	(concat "^."
+	(concat "^.\\("
 		(make-string (1- locate-filename-indentation) ?\s)
-		"\\(/\\|[A-Za-z]:\\)\\|"
+		 "\\)\\|"
 		(default-value 'directory-listing-before-filename-regexp)))
   (make-local-variable 'dired-actual-switches)
   (setq dired-actual-switches "")

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

* bug#7308: [patch] locate under windoze
  2010-10-30 19:50 bug#7308: [patch] locate under windoze Eduard Wiebe
@ 2010-10-30 21:21 ` Eli Zaretskii
  2010-10-31  9:36   ` Eduard Wiebe
  2010-10-31  6:56 ` Thierry Volpiatto
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 24+ messages in thread
From: Eli Zaretskii @ 2010-10-30 21:21 UTC (permalink / raw)
  To: Eduard Wiebe; +Cc: 7308

> From: Eduard Wiebe <usenet@pusto.de>
> Date: Sat, 30 Oct 2010 21:50:18 +0200
> Cc: 
> 
> i want to use `locate' under windoze system.  Unfortunately locate (in
> interaction with dired) doesn't work proper in such a case.
> The problem is the unquoted backslash in a located file path.
> So i fix this issue by following patch.

Thanks.

Please tell what version of `locate' is that, and in which Emacs
version it happened to you.

I understand that the problem happens because your version of `locate'
returns Windows file names with backslashes as directory separators
(as opposed to forward slashes), is that right?

If so, wouldn't it be better to replace backslashes with forward
slashes before the unquote loop?

If backslashes as directory separators are not the reason, could you
please elaborate about the reason?





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

* bug#7308: [patch] locate under windoze
  2010-10-30 19:50 bug#7308: [patch] locate under windoze Eduard Wiebe
  2010-10-30 21:21 ` Eli Zaretskii
@ 2010-10-31  6:56 ` Thierry Volpiatto
  2010-10-31  7:49   ` Eli Zaretskii
  2010-11-01  6:54 ` Glenn Morris
  2010-11-01 14:59 ` Eduard Wiebe
  3 siblings, 1 reply; 24+ messages in thread
From: Thierry Volpiatto @ 2010-10-31  6:56 UTC (permalink / raw)
  To: bug-gnu-emacs

Eduard Wiebe <usenet@pusto.de> writes:

>   Hello,
>
> i want to use `locate' under windoze system.  Unfortunately locate (in
> interaction with dired) doesn't work proper in such a case.
> The problem is the unquoted backslash in a located file path.
> So i fix this issue by following patch. BTW i customized hook variables
> and added autoloads.
Under windows, you can use everything and his command line (es) instead of
locate. http://www.voidtools.com/download.php

Maybe you use a locate version of cygwin, otherwise the locate
version of gnuwin32 doesn't have a updatedb command...
Maybe that is fixed now, don't know.

Anyway everything under windows work fine and very fast, it's what i use
by default in anything-locate (find it in anything-config.el).

-- 
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 






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

* bug#7308: [patch] locate under windoze
  2010-10-31  6:56 ` Thierry Volpiatto
@ 2010-10-31  7:49   ` Eli Zaretskii
  2010-10-31  9:41     ` Thierry Volpiatto
  0 siblings, 1 reply; 24+ messages in thread
From: Eli Zaretskii @ 2010-10-31  7:49 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: bug-gnu-emacs

> From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
> Date: Sun, 31 Oct 2010 07:56:26 +0100
> Cc: 
> 
> Maybe you use a locate version of cygwin, otherwise the locate
> version of gnuwin32 doesn't have a updatedb command...

It's very easy to write a Windows batch file to emulate updatedb.
(I've done that and am using it ever since.)  Most of the things the
original updatedb does are not applicable to Windows anyway.





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

* bug#7308: [patch] locate under windoze
  2010-10-30 21:21 ` Eli Zaretskii
@ 2010-10-31  9:36   ` Eduard Wiebe
  2010-10-31  9:48     ` Thierry Volpiatto
  2010-10-31 10:51     ` Eli Zaretskii
  0 siblings, 2 replies; 24+ messages in thread
From: Eduard Wiebe @ 2010-10-31  9:36 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 7308

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Eduard Wiebe <usenet@pusto.de>
>> Date: Sat, 30 Oct 2010 21:50:18 +0200
>> Cc: 
>> 
>> i want to use `locate' under windoze system.  Unfortunately locate (in
>> interaction with dired) doesn't work proper in such a case.
>> The problem is the unquoted backslash in a located file path.
>> So i fix this issue by following patch.
>
> Thanks.
>
> Please tell what version of `locate' is that, and in which Emacs
> version it happened to you.

I use emacs-23.2 with command line interface of everything search engine
from http://www.voidtools.com (es.exe) as locate command under MS
Windows XP.

> I understand that the problem happens because your version of `locate'
> returns Windows file names with backslashes as directory separators
> (as opposed to forward slashes), is that right?

Yes, that is correct. 

The second culprit is `directory-listing-before-filename-regex', which
is to restrict and cause fails under Windoze. Under Linux leads the
restricted regexp only to incorrect display (the point is always after
the first slash character).

I tested the simplyfied version of
`directory-listing-before-filename-regex' under Windoze with everything
(es.exe)m and Linux with GNU locate and it works well.

> If so, wouldn't it be better to replace backslashes with forward
> slashes before the unquote loop?

Hmm. I'm not sure. How about an UNC path ala \\sever\share\path?

If emacs correctly resolve an UNC path with forward slashes so i would
agree.

> If backslashes as directory separators are not the reason, could you
> please elaborate about the reason?

See above.

-- 
Eduard Wiebe





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

* bug#7308: [patch] locate under windoze
  2010-10-31  7:49   ` Eli Zaretskii
@ 2010-10-31  9:41     ` Thierry Volpiatto
  2010-10-31 10:47       ` Eli Zaretskii
  0 siblings, 1 reply; 24+ messages in thread
From: Thierry Volpiatto @ 2010-10-31  9:41 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: bug-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
>> Date: Sun, 31 Oct 2010 07:56:26 +0100
>> Cc: 
>> 
>> Maybe you use a locate version of cygwin, otherwise the locate
>> version of gnuwin32 doesn't have a updatedb command...
>
> It's very easy to write a Windows batch file to emulate updatedb.
> (I've done that and am using it ever since.)  Most of the things the
> original updatedb does are not applicable to Windows anyway.
>
Maybe, but the locate Gnuwin32 should provide this script.
I personnally use really few Windows systems and i don't want to learn
how to write DOS scripts.

OTOH the everything program work out of the box.

-- 
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 





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

* bug#7308: [patch] locate under windoze
  2010-10-31  9:36   ` Eduard Wiebe
@ 2010-10-31  9:48     ` Thierry Volpiatto
  2010-10-31 10:51     ` Eli Zaretskii
  1 sibling, 0 replies; 24+ messages in thread
From: Thierry Volpiatto @ 2010-10-31  9:48 UTC (permalink / raw)
  To: bug-gnu-emacs

Eduard Wiebe <usenet@pusto.de> writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> From: Eduard Wiebe <usenet@pusto.de>
>>> Date: Sat, 30 Oct 2010 21:50:18 +0200
>>> Cc: 
>>> 
>>> i want to use `locate' under windoze system.  Unfortunately locate (in
>>> interaction with dired) doesn't work proper in such a case.
>>> The problem is the unquoted backslash in a located file path.
>>> So i fix this issue by following patch.
>>
>> Thanks.
>>
>> Please tell what version of `locate' is that, and in which Emacs
>> version it happened to you.
>
> I use emacs-23.2 with command line interface of everything search engine
> from http://www.voidtools.com (es.exe) as locate command under MS
> Windows XP.

So if you use this, you should try anything-locate that work fine with
everything.(no setting needed)

>> I understand that the problem happens because your version of `locate'
>> returns Windows file names with backslashes as directory separators
>> (as opposed to forward slashes), is that right?
>
> Yes, that is correct. 
>
> The second culprit is `directory-listing-before-filename-regex', which
> is to restrict and cause fails under Windoze. Under Linux leads the
> restricted regexp only to incorrect display (the point is always after
> the first slash character).
>
> I tested the simplyfied version of
> `directory-listing-before-filename-regex' under Windoze with everything
> (es.exe)m and Linux with GNU locate and it works well.
>
>> If so, wouldn't it be better to replace backslashes with forward
>> slashes before the unquote loop?
>
> Hmm. I'm not sure. How about an UNC path ala \\sever\share\path?
>
> If emacs correctly resolve an UNC path with forward slashes so i would
> agree.
>
>> If backslashes as directory separators are not the reason, could you
>> please elaborate about the reason?
>
> See above.

-- 
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 






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

* bug#7308: [patch] locate under windoze
  2010-10-31  9:41     ` Thierry Volpiatto
@ 2010-10-31 10:47       ` Eli Zaretskii
  2010-10-31 11:13         ` Thierry Volpiatto
  0 siblings, 1 reply; 24+ messages in thread
From: Eli Zaretskii @ 2010-10-31 10:47 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: bug-gnu-emacs

> From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
> Cc: bug-gnu-emacs@gnu.org
> Date: Sun, 31 Oct 2010 10:41:04 +0100
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >> From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
> >> Date: Sun, 31 Oct 2010 07:56:26 +0100
> >> Cc: 
> >> 
> >> Maybe you use a locate version of cygwin, otherwise the locate
> >> version of gnuwin32 doesn't have a updatedb command...
> >
> > It's very easy to write a Windows batch file to emulate updatedb.
> > (I've done that and am using it ever since.)  Most of the things the
> > original updatedb does are not applicable to Windows anyway.
> >
> Maybe, but the locate Gnuwin32 should provide this script.

I agree, but the GnuWin32 people obviously decided differently, and
neither I nor even you can do anything about that.  In fact, I did my
own port of `find' because the one from GnuWin32 was ridiculously slow
(due to a misfeature in a library they used to ease the porting job).

> I personnally use really few Windows systems and i don't want to learn
> how to write DOS scripts.

That's fine, but I was not talking about you, I was talking about
people whom you advise to.  Their preferences could be different.

> OTOH the everything program work out of the box.

But it looks like it's not 100% compatible with GNU `locate', is it?
And I don't see that sources are available.





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

* bug#7308: [patch] locate under windoze
  2010-10-31  9:36   ` Eduard Wiebe
  2010-10-31  9:48     ` Thierry Volpiatto
@ 2010-10-31 10:51     ` Eli Zaretskii
  2010-10-31 19:54       ` Eduard Wiebe
  1 sibling, 1 reply; 24+ messages in thread
From: Eli Zaretskii @ 2010-10-31 10:51 UTC (permalink / raw)
  To: Eduard Wiebe; +Cc: 7308

> From: Eduard Wiebe <usenet@pusto.de>
> Cc: 7308@debbugs.gnu.org
> Date: Sun, 31 Oct 2010 10:36:21 +0100
> 
> > If so, wouldn't it be better to replace backslashes with forward
> > slashes before the unquote loop?
> 
> Hmm. I'm not sure. How about an UNC path ala \\sever\share\path?

No problem, //server/share/path will work.

> If emacs correctly resolve an UNC path with forward slashes so i would
> agree.

Great.  Then running the file name through convert-standard-filename
for windows-nt and doing nothing at all for ms-dos should do the
trick.  (The MSDOS build does not need any changes because the only
DOS port of GNU Findutils I'm aware of returns file names with forward
slashes.)

Thanks.





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

* bug#7308: [patch] locate under windoze
  2010-10-31 10:47       ` Eli Zaretskii
@ 2010-10-31 11:13         ` Thierry Volpiatto
  0 siblings, 0 replies; 24+ messages in thread
From: Thierry Volpiatto @ 2010-10-31 11:13 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: bug-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

> I agree, but the GnuWin32 people obviously decided differently, and
> neither I nor even you can do anything about that.  In fact, I did my
> own port of `find' because the one from GnuWin32 was ridiculously slow
> (due to a misfeature in a library they used to ease the porting job).

It would be great people involved in Gnu apps development collaborate more.
 

>> I personnally use really few Windows systems and i don't want to learn
>> how to write DOS scripts.
>
> That's fine, but I was not talking about you, I was talking about
> people whom you advise to.  Their preferences could be different.

Yes i understand, i was just pointing the difficulty for a user to make
working Gnuwin32 apps in Emacs, it is not easy unless people have your knowledge.

>> OTOH the everything program work out of the box.
>
> But it looks like it's not 100% compatible with GNU `locate', is it?
> And I don't see that sources are available.

It share nothing with GNU locate, but maybe you are speaking of license?

-- 
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 





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

* bug#7308: [patch] locate under windoze
  2010-10-31 10:51     ` Eli Zaretskii
@ 2010-10-31 19:54       ` Eduard Wiebe
  2010-10-31 20:26         ` Eli Zaretskii
  0 siblings, 1 reply; 24+ messages in thread
From: Eduard Wiebe @ 2010-10-31 19:54 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 7308

Eli Zaretskii <eliz@gnu.org> writes:

>> > If so, wouldn't it be better to replace backslashes with forward
>> > slashes before the unquote loop?
>> 
>> Hmm. I'm not sure. How about an UNC path ala \\sever\share\path?
>
> No problem, //server/share/path will work.
>
>> If emacs correctly resolve an UNC path with forward slashes so i would
>> agree.
>
> Great.  Then running the file name through convert-standard-filename
> for windows-nt and doing nothing at all for ms-dos should do the
> trick.  (The MSDOS build does not need any changes because the only
> DOS port of GNU Findutils I'm aware of returns file names with forward
> slashes.)

Sorry Eli, but i cannot follow you :-)

If i understand the doc of `convert-standard-filename' correct, then the
function turns slashes to backslashes under MS-Windows instead of other
way around.

Please illuminate me :-)





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

* bug#7308: [patch] locate under windoze
  2010-10-31 19:54       ` Eduard Wiebe
@ 2010-10-31 20:26         ` Eli Zaretskii
  0 siblings, 0 replies; 24+ messages in thread
From: Eli Zaretskii @ 2010-10-31 20:26 UTC (permalink / raw)
  To: Eduard Wiebe; +Cc: 7308

> From: Eduard Wiebe <ew@pusto.de>
> Cc: 7308@debbugs.gnu.org
> Date: Sun, 31 Oct 2010 20:54:53 +0100
> 
> > Great.  Then running the file name through convert-standard-filename
> > for windows-nt and doing nothing at all for ms-dos should do the
> > trick.  (The MSDOS build does not need any changes because the only
> > DOS port of GNU Findutils I'm aware of returns file names with forward
> > slashes.)
> 
> Sorry Eli, but i cannot follow you :-)
> 
> If i understand the doc of `convert-standard-filename' correct, then the
> function turns slashes to backslashes under MS-Windows instead of other
> way around.

Sorry, you are right.  I was confused.

So just replace the backslashes with forward slashes, instead of
doubling each one of them.





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

* bug#7308: [patch] locate under windoze
  2010-10-30 19:50 bug#7308: [patch] locate under windoze Eduard Wiebe
  2010-10-30 21:21 ` Eli Zaretskii
  2010-10-31  6:56 ` Thierry Volpiatto
@ 2010-11-01  6:54 ` Glenn Morris
  2010-11-01  7:46   ` Eduard Wiebe
  2010-11-01 14:06   ` Stefan Monnier
  2010-11-01 14:59 ` Eduard Wiebe
  3 siblings, 2 replies; 24+ messages in thread
From: Glenn Morris @ 2010-11-01  6:54 UTC (permalink / raw)
  To: Eduard Wiebe; +Cc: 7308

Eduard Wiebe wrote:

> +;;;###autoload
> +(defcustom locate-post-command-hook nil
[...]
> +;;;###autoload
> +(defcustom locate-mode-hook nil

Just a comment that -hook variables do not need to be defined; and
they absolutely do not need to be autoloaded.





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

* bug#7308: [patch] locate under windoze
  2010-11-01  6:54 ` Glenn Morris
@ 2010-11-01  7:46   ` Eduard Wiebe
  2010-11-01 14:06   ` Stefan Monnier
  1 sibling, 0 replies; 24+ messages in thread
From: Eduard Wiebe @ 2010-11-01  7:46 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 7308

Glenn Morris <rgm@gnu.org> writes:

> Eduard Wiebe wrote:
>
>> +;;;###autoload
>> +(defcustom locate-post-command-hook nil
> [...]
>> +;;;###autoload
>> +(defcustom locate-mode-hook nil
>
> Just a comment that -hook variables do not need to be defined; 

Huch? Don't even defcustomized? 

grep -nH -e "^(defcustom .*hook" *.el

abbrev.el:465:(defcustom pre-abbrev-expand-hook nil
align.el:129:(defcustom align-load-hook nil
arc-mode.el:144:(defcustom archive-extract-hooks nil
...

How will you customize such a variable?

> and they absolutely do not need to be autoloaded.

Ok. Thanks for the hint.

-- 
Eduard Wiebe





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

* bug#7308: [patch] locate under windoze
  2010-11-01  6:54 ` Glenn Morris
  2010-11-01  7:46   ` Eduard Wiebe
@ 2010-11-01 14:06   ` Stefan Monnier
  1 sibling, 0 replies; 24+ messages in thread
From: Stefan Monnier @ 2010-11-01 14:06 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 7308, Eduard Wiebe

>> +;;;###autoload
>> +(defcustom locate-post-command-hook nil
> [...]
>> +;;;###autoload
>> +(defcustom locate-mode-hook nil
> Just a comment that -hook variables do not need to be defined;

While that's true, it's good to define them so as to give them
a docstring, and so they can be found via C-h v.

> and they absolutely do not need to be autoloaded.

That is indeed true.  Every ;;;###autoload for a variable should come
with a clear convincing comment explaining why this variable needs to
be autoloaded.


        Stefan





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

* bug#7308: [patch] locate under windoze
  2010-10-30 19:50 bug#7308: [patch] locate under windoze Eduard Wiebe
                   ` (2 preceding siblings ...)
  2010-11-01  6:54 ` Glenn Morris
@ 2010-11-01 14:59 ` Eduard Wiebe
  2010-11-12 20:28   ` Eduard Wiebe
  3 siblings, 1 reply; 24+ messages in thread
From: Eduard Wiebe @ 2010-11-01 14:59 UTC (permalink / raw)
  To: bug-gnu-emacs

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


Ok, here is the improved version of my patch.
Thanks all for the feedback.

PS: Can we commit it to emacs-23 branch too?

-- 
Eduard Wiebe


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: locate_under_windoze2.diff --]
[-- Type: text/x-diff, Size: 2584 bytes --]

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index fb84bb6..86538cc 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
+2010-11-01  Eduard Wiebe <usenet@pusto.de>
+
+	* dired.el (dired-get-filename): Replace backslashes with slashes
+	in file path on windows-nt, needed by `locate'. (Bug#7308)
+	* locate.el (locate-default-make-command-line): Simplify
+	`directory-listing-before-filename-regexp'.
+	(locate-post-command-hook, locate-post-command-hook):
+	Defcustomize.
+
 2010-11-01  Kenichi Handa  <handa@m17n.org>
 
 	* faces.el (glyphless-char): Inherit underline for tty.
diff --git a/lisp/dired.el b/lisp/dired.el
index f840b60..180d727 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -2011,6 +2011,14 @@ Otherwise, an error occurs in these cases."
           ;; with quotation marks in their names.
 	  (while (string-match "\\(?:[^\\]\\|\\`\\)\\(\"\\)" file)
 	    (setq file (replace-match "\\\"" nil t file 1)))
+	  
+	  (when (eq system-type 'windows-nt)
+	    (save-match-data
+	      (let ((start 0))
+		(while (string-match "\\\\" file start)
+		  (aset file (match-beginning 0) ?/)
+		  (setq start (match-end 0))))))
+
           (setq file (read (concat "\"" file "\"")))
 	  ;; The above `read' will return a unibyte string if FILE
 	  ;; contains eight-bit-control/graphic characters.
diff --git a/lisp/locate.el b/lisp/locate.el
index f1983a3..6e21047 100644
--- a/lisp/locate.el
+++ b/lisp/locate.el
@@ -145,6 +145,11 @@ the version.)"
   :type 'string
   :group 'locate)
 
+(defcustom locate-post-command-hook nil
+  "List of hook functions run after `locate' (see `run-hooks')."
+  :type  'hook
+  :group 'locate)
+
 (defvar locate-history-list nil
   "The history list used by the \\[locate] command.")
 
@@ -226,6 +231,11 @@ that is, with a prefix arg, you get the default behavior."
   :group 'locate
   :type 'boolean)
 
+(defcustom locate-mode-hook nil
+  "List of hook functions run by `locate-mode' (see `run-mode-hooks')."
+  :type  'hook
+  :group 'locate)
+
 ;; Functions
 
 (defun locate-default-make-command-line (search-string)
@@ -473,9 +483,9 @@ do not work in subdirectories.
   (make-local-variable 'directory-listing-before-filename-regexp)
   ;; This should support both Unix and Windoze style names
   (setq directory-listing-before-filename-regexp
-	(concat "^."
+	(concat "^.\\("
 		(make-string (1- locate-filename-indentation) ?\s)
-		"\\(/\\|[A-Za-z]:\\)\\|"
+		 "\\)\\|"
 		(default-value 'directory-listing-before-filename-regexp)))
   (make-local-variable 'dired-actual-switches)
   (setq dired-actual-switches "")

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

* bug#7308: [patch] locate under windoze
  2010-11-01 14:59 ` Eduard Wiebe
@ 2010-11-12 20:28   ` Eduard Wiebe
  2010-11-13 18:57     ` Chong Yidong
  0 siblings, 1 reply; 24+ messages in thread
From: Eduard Wiebe @ 2010-11-12 20:28 UTC (permalink / raw)
  To: bug-gnu-emacs

Eduard Wiebe <usenet@pusto.de> writes:

Ping.

> Ok, here is the improved version of my patch.
> Thanks all for the feedback.

Any concerns?

> PS: Can we commit it to emacs-23 branch too?

-- 
Eduard Wiebe






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

* bug#7308: [patch] locate under windoze
  2010-11-12 20:28   ` Eduard Wiebe
@ 2010-11-13 18:57     ` Chong Yidong
  2010-11-13 21:18       ` Eli Zaretskii
  0 siblings, 1 reply; 24+ messages in thread
From: Chong Yidong @ 2010-11-13 18:57 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 7308, Eduard Wiebe

Eduard Wiebe <usenet@pusto.de> writes:

> Eduard Wiebe <usenet@pusto.de> writes:
>
> Ping.

Eli, are you happy with the patch introducing the backslash changes from

 http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7308#50

?  It looks OK to me, but I am not sure I've correctly followed the
discussion in this bug report.





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

* bug#7308: [patch] locate under windoze
  2010-11-13 18:57     ` Chong Yidong
@ 2010-11-13 21:18       ` Eli Zaretskii
  2010-11-13 22:33         ` Eduard Wiebe
  0 siblings, 1 reply; 24+ messages in thread
From: Eli Zaretskii @ 2010-11-13 21:18 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 7308, usenet

> From: Chong Yidong <cyd@stupidchicken.com>
> Cc: Eduard Wiebe <usenet@pusto.de>, 7308@debbugs.gnu.org
> Date: Sat, 13 Nov 2010 13:57:03 -0500
> 
> Eduard Wiebe <usenet@pusto.de> writes:
> 
> > Eduard Wiebe <usenet@pusto.de> writes:
> >
> > Ping.
> 
> Eli, are you happy with the patch introducing the backslash changes from
> 
>  http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7308#50
> 
> ?  It looks OK to me, but I am not sure I've correctly followed the
> discussion in this bug report.

I'm okay with the main change, but I don't understand the reason (or
need) for this hunk:

  @@ -473,9 +483,9 @@ do not work in subdirectories.
     (make-local-variable 'directory-listing-before-filename-regexp)
     ;; This should support both Unix and Windoze style names
     (setq directory-listing-before-filename-regexp
  -	(concat "^."
  +	(concat "^.\\("
		  (make-string (1- locate-filename-indentation) ?\s)
  -		"\\(/\\|[A-Za-z]:\\)\\|"
  +		 "\\)\\|"
		  (default-value 'directory-listing-before-filename-regexp)))
     (make-local-variable 'dired-actual-switches)
     (setq dired-actual-switches "")





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

* bug#7308: [patch] locate under windoze
  2010-11-13 21:18       ` Eli Zaretskii
@ 2010-11-13 22:33         ` Eduard Wiebe
  2010-11-14  3:59           ` Eli Zaretskii
  0 siblings, 1 reply; 24+ messages in thread
From: Eduard Wiebe @ 2010-11-13 22:33 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 7308, Chong Yidong

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Chong Yidong <cyd@stupidchicken.com>
>> Cc: Eduard Wiebe <usenet@pusto.de>, 7308@debbugs.gnu.org
>> Date: Sat, 13 Nov 2010 13:57:03 -0500
>> 
>> Eduard Wiebe <usenet@pusto.de> writes:
>> 
>> > Eduard Wiebe <usenet@pusto.de> writes:
>> >
>> > Ping.
>> 
>> Eli, are you happy with the patch introducing the backslash changes from
>> 
>>  http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7308#50
>> 
>> ?  It looks OK to me, but I am not sure I've correctly followed the
>> discussion in this bug report.
>
> I'm okay with the main change, but I don't understand the reason (or
> need) for this hunk:
>
>   @@ -473,9 +483,9 @@ do not work in subdirectories.
>      (make-local-variable 'directory-listing-before-filename-regexp)
>      ;; This should support both Unix and Windoze style names
>      (setq directory-listing-before-filename-regexp
>   -	(concat "^."
>   +	(concat "^.\\("
> 		  (make-string (1- locate-filename-indentation) ?\s)
>   -		"\\(/\\|[A-Za-z]:\\)\\|"
                ^^^^^^^^^^^^^^^^^^^^

>   +		 "\\)\\|"
> 		  (default-value 'directory-listing-before-filename-regexp)))
>      (make-local-variable 'dired-actual-switches)
>      (setq dired-actual-switches "")

This hunk is essential.  The new value of the regexp avoids the
truncation of the drive letter from absolute path of the selected file.

Btw. Under GNU/Linux this change leads to correct position of cursor in
*Locate* buffer, too.

PS: I tested my patch under GNU/Linux with GNU locate und MS-Windows
with everything-Tool for a while and it works fine.

-- 
Eduard Wiebe





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

* bug#7308: [patch] locate under windoze
  2010-11-13 22:33         ` Eduard Wiebe
@ 2010-11-14  3:59           ` Eli Zaretskii
  2010-11-14  9:15             ` Eduard Wiebe
  0 siblings, 1 reply; 24+ messages in thread
From: Eli Zaretskii @ 2010-11-14  3:59 UTC (permalink / raw)
  To: Eduard Wiebe; +Cc: 7308, cyd

> From: Eduard Wiebe <usenet@pusto.de>
> Cc: Chong Yidong <cyd@stupidchicken.com>, 7308@debbugs.gnu.org
> Date: Sat, 13 Nov 2010 23:33:08 +0100
> 
> > I'm okay with the main change, but I don't understand the reason (or
> > need) for this hunk:
> >
> >   @@ -473,9 +483,9 @@ do not work in subdirectories.
> >      (make-local-variable 'directory-listing-before-filename-regexp)
> >      ;; This should support both Unix and Windoze style names
> >      (setq directory-listing-before-filename-regexp
> >   -	(concat "^."
> >   +	(concat "^.\\("
> > 		  (make-string (1- locate-filename-indentation) ?\s)
> >   -		"\\(/\\|[A-Za-z]:\\)\\|"
>                 ^^^^^^^^^^^^^^^^^^^^
> 
> >   +		 "\\)\\|"
> > 		  (default-value 'directory-listing-before-filename-regexp)))
> >      (make-local-variable 'dired-actual-switches)
> >      (setq dired-actual-switches "")
> 
> This hunk is essential.  The new value of the regexp avoids the
> truncation of the drive letter from absolute path of the selected file.
> 
> Btw. Under GNU/Linux this change leads to correct position of cursor in
> *Locate* buffer, too.

Sorry, I still don't understand: what truncation? what incorrect
position?  Please explain more.

> PS: I tested my patch under GNU/Linux with GNU locate und MS-Windows
> with everything-Tool for a while and it works fine.

I never doubted that you tested the change.  I just want to understand
it.





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

* bug#7308: [patch] locate under windoze
  2010-11-14  3:59           ` Eli Zaretskii
@ 2010-11-14  9:15             ` Eduard Wiebe
  2010-11-27  9:59               ` Eli Zaretskii
  0 siblings, 1 reply; 24+ messages in thread
From: Eduard Wiebe @ 2010-11-14  9:15 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 7308, cyd, Eduard Wiebe

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Eduard Wiebe <usenet@pusto.de>
>> Cc: Chong Yidong <cyd@stupidchicken.com>, 7308@debbugs.gnu.org
>> Date: Sat, 13 Nov 2010 23:33:08 +0100
>> 
>> > I'm okay with the main change, but I don't understand the reason (or
>> > need) for this hunk:
>> >
>> >   @@ -473,9 +483,9 @@ do not work in subdirectories.
>> >      (make-local-variable 'directory-listing-before-filename-regexp)
>> >      ;; This should support both Unix and Windoze style names
>> >      (setq directory-listing-before-filename-regexp
>> >   -	(concat "^."
>> >   +	(concat "^.\\("
>> > 		  (make-string (1- locate-filename-indentation) ?\s)
>> >   -		"\\(/\\|[A-Za-z]:\\)\\|"
>>                 ^^^^^^^^^^^^^^^^^^^^
>> 
>> >   +		 "\\)\\|"
>> > 		  (default-value 'directory-listing-before-filename-regexp)))
>> >      (make-local-variable 'dired-actual-switches)
>> >      (setq dired-actual-switches "")
>> 
>> This hunk is essential.  The new value of the regexp avoids the
>> truncation of the drive letter from absolute path of the selected file.
>> 
>> Btw. Under GNU/Linux this change leads to correct position of cursor in
>> *Locate* buffer, too.

> Sorry, I still don't understand: what truncation? 

Under MS-Windows my *Locate* buffer looks like this (* is the point):
----------------------------------------------------------------------
e:*\path\to\file1
e:\path\to\file2
f:\path\to\another\file

-- *Locate*-----------------------------------------------------------

If i choose 'e:\path\to\file1', the function `dired-get-filename' is
called and tries to visit '\path\to\file1' (without the drive letter)
and fails because the path is incomplete.

> what incorrect position? 

Consider the same example on GNU/Linux with following *Locate* buffer:
----------------------------------------------------------------------
/*home/ew/.emacs
/home/ew/.emacs.d

-- *Locate*-----------------------------------------------------------

if i choose '/home/ew/.emacs' the function `dired-get-file' is called and
visits 'home/ew/.emacs', but not fails (albeit more by chance) because
of `default-directory' is '/' and the extracted path is interpreted as a
relative path to `default-directory'.

> Please explain more.

With my patch, the point is always in front of a file path in the
*Locate* buffer and leads to correct file path extraction if i try to
visit selected file path.

I hope that helps and sorry for previous poor explanation.

-- 
Eduard Wiebe





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

* bug#7308: [patch] locate under windoze
  2010-11-14  9:15             ` Eduard Wiebe
@ 2010-11-27  9:59               ` Eli Zaretskii
       [not found]                 ` <87bp5970hs.fsf@pusto.de>
  0 siblings, 1 reply; 24+ messages in thread
From: Eli Zaretskii @ 2010-11-27  9:59 UTC (permalink / raw)
  To: Eduard Wiebe; +Cc: 7308-done, cyd, usenet

> From: Eduard Wiebe <ew@pusto.de>
> Cc: Eduard Wiebe <usenet@pusto.de>,  cyd@stupidchicken.com,  7308@debbugs.gnu.org
> Date: Sun, 14 Nov 2010 10:15:20 +0100
> 
> I hope that helps and sorry for previous poor explanation.

Thanks, and sorry for the long delay.  I convinced myself that these
changes are correct, and committed them to the Emacs 23 branch.





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

* bug#5462: bug#7308: [patch] locate under windoze
       [not found]                 ` <87bp5970hs.fsf@pusto.de>
@ 2010-11-28 19:46                   ` Eli Zaretskii
  0 siblings, 0 replies; 24+ messages in thread
From: Eli Zaretskii @ 2010-11-28 19:46 UTC (permalink / raw)
  To: Eduard Wiebe; +Cc: 7308-done, 5462-done

> From: Eduard Wiebe <ew@pusto.de>
> Date: Sun, 28 Nov 2010 19:43:11 +0100
> 
> Could you close Bug#5462 too, which adress the "same" issue.

Done by this mail.





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

end of thread, other threads:[~2010-11-28 19:46 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-30 19:50 bug#7308: [patch] locate under windoze Eduard Wiebe
2010-10-30 21:21 ` Eli Zaretskii
2010-10-31  9:36   ` Eduard Wiebe
2010-10-31  9:48     ` Thierry Volpiatto
2010-10-31 10:51     ` Eli Zaretskii
2010-10-31 19:54       ` Eduard Wiebe
2010-10-31 20:26         ` Eli Zaretskii
2010-10-31  6:56 ` Thierry Volpiatto
2010-10-31  7:49   ` Eli Zaretskii
2010-10-31  9:41     ` Thierry Volpiatto
2010-10-31 10:47       ` Eli Zaretskii
2010-10-31 11:13         ` Thierry Volpiatto
2010-11-01  6:54 ` Glenn Morris
2010-11-01  7:46   ` Eduard Wiebe
2010-11-01 14:06   ` Stefan Monnier
2010-11-01 14:59 ` Eduard Wiebe
2010-11-12 20:28   ` Eduard Wiebe
2010-11-13 18:57     ` Chong Yidong
2010-11-13 21:18       ` Eli Zaretskii
2010-11-13 22:33         ` Eduard Wiebe
2010-11-14  3:59           ` Eli Zaretskii
2010-11-14  9:15             ` Eduard Wiebe
2010-11-27  9:59               ` Eli Zaretskii
     [not found]                 ` <87bp5970hs.fsf@pusto.de>
2010-11-28 19:46                   ` bug#5462: " Eli Zaretskii

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