unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* [patch] 21.3 filecache.el - Added Cygwin support
@ 2004-01-24  9:25 Jari Aalto+mail.emacs
  2004-01-24 10:46 ` Eli Zaretskii
       [not found] ` <mailman.1267.1074941456.928.bug-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 10+ messages in thread
From: Jari Aalto+mail.emacs @ 2004-01-24  9:25 UTC (permalink / raw)



2004-01-24 Sat  Jari Aalto  <jari.aalto@poboxes.com>

        * filecache.el
        (file-cache-find-unix-p): New function. Detect Cygwin.
        (file-cache-add-directory-using-find): Added Cygwin support
        (file-cache-find-command-unix-flag): New user variable.


Index: filecache.el
===================================================================
RCS file: /cygdrive/h/data/version-control/cvsroot/emacs/gnu-emacs/lisp213/filecache.el,v
retrieving revision 1.2
diff -u -IId: -b -w -u -r1.2 filecache.el
--- filecache.el	24 Jan 2004 08:32:49 -0000	1.2
+++ filecache.el	24 Jan 2004 09:18:06 -0000
@@ -165,6 +165,17 @@
   :type 'string
   :group 'file-cache)
 
+(defcustom file-cache-find-command-unix-flag 'not-defined
+  "*Set to t, if `file-cache-find-command' us Unix type find.
+This variable is automatically set to nil or non-nil if the initial value
+is 'not-defined by first call to function
+`file-cache-add-directory-using-find'.
+
+Under Windows operating system where Cygwin is available, this value
+should be set to t."
+  :type  'boolean
+  :group 'file-cache)
+
 (defcustom file-cache-locate-command "locate"
   "*External program used by `file-cache-add-directory-using-locate'."
   :type 'string
@@ -316,17 +327,39 @@
                     file-cache-alist)))
       )))
 
+(defun file-cache-find-unix-p ()
+  "Check if `file-cache-find-command' is Unix type program."
+  (or (not (eq system-type 'windows-nt))  ;; Assume Unix system
+      (with-temp-buffer                   ;; Cygwin?
+        (call-process file-cache-find-command
+                      nil
+                      (current-buffer)
+                      nil
+                      "--version")
+        (goto-char (point-min))
+        ;; Cygwin
+        (if (re-search-forward "GNU" nil t)
+            (buffer-string)))))
+
 (defun file-cache-add-directory-using-find (directory)
   "Use the `find' command to add files to the file cache.
 Find is run in DIRECTORY."
   (interactive "DAdd files under directory: ")
   (let ((dir (expand-file-name directory)))
+    (if (eq file-cache-find-command-unix-flag 'not-defined)
+        (setq file-cache-find-command-unix-flag (file-cache-find-unix-p)))
     (set-buffer (get-buffer-create file-cache-buffer))
     (erase-buffer)
     (call-process file-cache-find-command nil
                   (get-buffer file-cache-buffer) nil
                   dir "-name"
-                  (if (eq system-type 'windows-nt) "'*'" "*")
+                  (cond
+                   (file-cache-find-command-unix-flag
+                    "\\*")
+                   ((eq system-type 'windows-nt)
+                    "'*'")
+                   (t
+                    "*"))
                   "-print")
     (file-cache-add-from-file-cache-buffer)))

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

* Re: [patch] 21.3 filecache.el - Added Cygwin support
  2004-01-24  9:25 [patch] 21.3 filecache.el - Added Cygwin support Jari Aalto+mail.emacs
@ 2004-01-24 10:46 ` Eli Zaretskii
       [not found] ` <mailman.1267.1074941456.928.bug-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2004-01-24 10:46 UTC (permalink / raw)
  Cc: bug-gnu-emacs

> From: jari.aalto@poboxes.com (Jari Aalto+mail.emacs)
> Date: Sat, 24 Jan 2004 11:25:08 +0200
> 
> 2004-01-24 Sat  Jari Aalto  <jari.aalto@poboxes.com>
> 
>         * filecache.el
>         (file-cache-find-unix-p): New function. Detect Cygwin.
>         (file-cache-add-directory-using-find): Added Cygwin support
>         (file-cache-find-command-unix-flag): New user variable.

Thanks.

One thing I don't understand about these changes: why do we need all
those ugly system-dependent tests?  Why not test if `find' is
installed on all supported platforms regardless?

But if you do want to avoid the test on Unix, let's do it on all
non-Unix systems, not only on windows-nt.

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

* Re: [patch] 21.3 filecache.el - Added Cygwin support
       [not found] ` <mailman.1267.1074941456.928.bug-gnu-emacs@gnu.org>
@ 2004-01-25 11:52   ` Jari Aalto+mail.linux
  2004-01-25 14:09     ` Eli Zaretskii
       [not found]     ` <mailman.1309.1075039727.928.bug-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 10+ messages in thread
From: Jari Aalto+mail.linux @ 2004-01-25 11:52 UTC (permalink / raw)


* Sat 2004-01-24 Eli Zaretskii <eliz@elta.co.il> gnu.emacs.bug
* <http://groups.google.com/groups?oi=djq&as_umsgid=%3Cmailman.1267.1074941456.928.bug-gnu-emacs@gnu.org>
| > From: jari.aalto@poboxes.com (Jari Aalto+mail.emacs)
| > Date: Sat, 24 Jan 2004 11:25:08 +0200
| > 
| > 2004-01-24 Sat  Jari Aalto  <jari.aalto@poboxes.com>
| > 
| >         * filecache.el
| >         (file-cache-find-unix-p): New function. Detect Cygwin.
| >         (file-cache-add-directory-using-find): Added Cygwin support
| >         (file-cache-find-command-unix-flag): New user variable.
| 
| Thanks.
| 
| One thing I don't understand about these changes: why do we need all
| those ugly system-dependent tests?  Why not test if `find' is
| installed on all supported platforms regardless?

The "find" from Windows is different from the Cygwin (Unix) "find", so
this distinctions must be examined.
 
| But if you do want to avoid the test on Unix, let's do it on all
| non-Unix systems, not only on windows-nt.

Right. Anything else missing?
Jari




2004-01-25 Sun  Jari Aalto  <jari.aalto@poboxes.com>

        * filecache.el (file-cache-find-unix-p): Added
        check for `ms-dos' as well.


Index: filecache.el
===================================================================
RCS file: /cygdrive/h/data/version-control/cvsroot/emacs/gnu-emacs/lisp213/filecache.el,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -IId: -b -w -u -r1.3 -r1.4
--- filecache.el        24 Jan 2004 09:25:44 -0000      1.3
+++ filecache.el        25 Jan 2004 11:49:15 -0000      1.4
@@ -329,7 +329,9 @@

 (defun file-cache-find-unix-p ()
   "Check if `file-cache-find-command' is Unix type program."
-  (or (not (eq system-type 'windows-nt))  ;; Assume Unix system
+  (or (not (memq system-type              ;; Assume Unix system
+                 '(windows-nt
+                   'ms-dos)))
       (with-temp-buffer                   ;; Cygwin?
         (call-process file-cache-find-command
                       nil



-- 
http://tiny-tools.sourceforge.net/
Swatch @time   http://www.mir.com.my/iTime/itime.htm
               http://www.ryanthiessen.com/swatch/resources.htm
Use Licenses!  http://www.linuxjournal.com/article.php?sid=6225
Which Licence? http://www.linuxjournal.com/article.php?sid=4825
OSI Licences   http://www.opensource.org/licenses/

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

* Re: [patch] 21.3 filecache.el - Added Cygwin support
  2004-01-25 11:52   ` Jari Aalto+mail.linux
@ 2004-01-25 14:09     ` Eli Zaretskii
       [not found]     ` <mailman.1309.1075039727.928.bug-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2004-01-25 14:09 UTC (permalink / raw)
  Cc: gnu-emacs-bug

> From: jari.aalto@poboxes.com (Jari Aalto+mail.linux)
> Newsgroups: gnu.emacs.bug
> Date: Sun, 25 Jan 2004 13:52:12 +0200
> | 
> | One thing I don't understand about these changes: why do we need all
> | those ugly system-dependent tests?  Why not test if `find' is
> | installed on all supported platforms regardless?
> 
> The "find" from Windows is different from the Cygwin (Unix) "find", so
> this distinctions must be examined.

I know that on Windows one must test whether `find' is the Unix-style
`find'.  What I was asking was something different: why not make that
test unconditionally, on all systems.

> Right. Anything else missing?
> Jari
> 
> 
> 
> 
> 2004-01-25 Sun  Jari Aalto  <jari.aalto@poboxes.com>
> 
>         * filecache.el (file-cache-find-unix-p): Added
>         check for `ms-dos' as well.

What about the Mac?

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

* Re: [patch] 21.3 filecache.el - Added Cygwin support
       [not found]     ` <mailman.1309.1075039727.928.bug-gnu-emacs@gnu.org>
@ 2004-01-26  0:25       ` Jari Aalto+mail.linux
  2004-01-26  6:59         ` Eli Zaretskii
       [not found]         ` <mailman.1345.1075100321.928.bug-gnu-emacs@gnu.org>
  2004-01-26 18:51       ` Kevin Rodgers
  1 sibling, 2 replies; 10+ messages in thread
From: Jari Aalto+mail.linux @ 2004-01-26  0:25 UTC (permalink / raw)


* 2004-01-25 Eli Zaretskii <eliz@elta.co.il> gnu.emacs.bug
* <http://groups.google.com/groups?oi=djq&as_umsgid=%3Cmailman.1309.1075039727.928.bug-gnu-emacs@gnu.org>
| > From: jari.aalto@poboxes.com (Jari Aalto+mail.linux)
| > Newsgroups: gnu.emacs.bug
| > Date: Sun, 25 Jan 2004 13:52:12 +0200
| > | 
| > | One thing I don't understand about these changes: why do we need all
| > | those ugly system-dependent tests?  Why not test if `find' is
| > | installed on all supported platforms regardless?
| > 
| > The "find" from Windows is different from the Cygwin (Unix) "find", so
| > this distinctions must be examined.
| 
| I know that on Windows one must test whether `find' is the Unix-style
| `find'.  What I was asking was something different: why not make that
| test unconditionally, on all systems.

Hard to do. The code currently tests GNU find by searching "GNU" from
--version.  But --version does not work in SunOS, HP, SGI, IBM, they have
their own find and making tests for all of those is beyond my reach.

So:

1) If it's not PC, assume Unix find
2) If it's PC, then test for GNU find (most likely Cygwin GNU find)

Anything else, I don't know what to test. Please take it from there to
improve.
 
| > Right. Anything else missing?  Jari
| > 
| > 
| > 
| > 
| > 2004-01-25 Sun  Jari Aalto  <jari.aalto@poboxes.com>
| > 
| >         * filecache.el (file-cache-find-unix-p): Added
| >         check for `ms-dos' as well.
| 
| What about the Mac?

elisp-manual-21-2.8 reports variable window-system like this:


 - Variable: window-system
     This variable tells Lisp programs what window system Emacs is
     running under.  The possible values are
    `x'
          Emacs is displaying using X.
    `pc'
          Emacs is displaying using MS-DOS.
    `w32'
          Emacs is displaying using Windows.
    `mac'
          Emacs is displaying using a Macintosh.
    `nil'
          Emacs is using a character-based terminal.

Is there a bug in documentation, because I canät see `windows-nt' or
`ms-dos' values? Perhaps someone should check the latest if it's
being edited.

Here is more fixes, based on your comment and the manual.
Jari



2004-01-26 Mon  Jari Aalto  <jari.aalto@poboxes.com>

        * filecache.el (file-cache-find-unix-p): Added
        `mac' `pc' and `w32' tests.


Index: filecache.el
===================================================================
RCS file: /cygdrive/h/data/version-control/cvsroot/emacs/gnu-emacs/lisp213/filecache.el,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -IId: -b -w -u -r1.4 -r1.5
--- filecache.el	25 Jan 2004 11:49:15 -0000	1.4
+++ filecache.el	26 Jan 2004 00:12:13 -0000	1.5
@@ -329,10 +329,17 @@
 
 (defun file-cache-find-unix-p ()
   "Check if `file-cache-find-command' is Unix type program."
-  (or (not (memq system-type              ;; Assume Unix system
+  ;;  First, assume Unix system, which has find(1).
+  ;;  SunOS, HP, IBM have their own versions of find(1).
+  (or (not (memq system-type
                  '(windows-nt
-                   'ms-dos)))
-      (with-temp-buffer                   ;; Cygwin?
+                   pc
+                   w32
+                   mac
+                   ms-dos)))
+      ;;  This is PC system, can we see GNU find(1)
+      ;;  like one bundled in Cygwin?
+      (with-temp-buffer
         (call-process file-cache-find-command
                       nil
                       (current-buffer)



-- 
http://tiny-tools.sourceforge.net/
Swatch @time   http://www.mir.com.my/iTime/itime.htm
               http://www.ryanthiessen.com/swatch/resources.htm
Use Licenses!  http://www.linuxjournal.com/article.php?sid=6225
Which Licence? http://www.linuxjournal.com/article.php?sid=4825
OSI Licences   http://www.opensource.org/licenses/

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

* Re: [patch] 21.3 filecache.el - Added Cygwin support
  2004-01-26  0:25       ` Jari Aalto+mail.linux
@ 2004-01-26  6:59         ` Eli Zaretskii
       [not found]         ` <mailman.1345.1075100321.928.bug-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2004-01-26  6:59 UTC (permalink / raw)
  Cc: gnu-emacs-bug

> From: jari.aalto@poboxes.com (Jari Aalto+mail.linux)
> Newsgroups: gnu.emacs.bug
> Date: Mon, 26 Jan 2004 02:25:26 +0200
> | 
> | I know that on Windows one must test whether `find' is the Unix-style
> | `find'.  What I was asking was something different: why not make that
> | test unconditionally, on all systems.
> 
> Hard to do. The code currently tests GNU find by searching "GNU" from
> --version.  But --version does not work in SunOS, HP, SGI, IBM, they have
> their own find and making tests for all of those is beyond my reach.

You could create a file and see if "find . -name THAT-FILE" finds it
and prints its name like a Unixy `find' should, for example.

> | What about the Mac?
> 
> elisp-manual-21-2.8 reports variable window-system like this:
> 
> 
>  - Variable: window-system
>      This variable tells Lisp programs what window system Emacs is
>      running under.  The possible values are
>     `x'
>           Emacs is displaying using X.
>     `pc'
>           Emacs is displaying using MS-DOS.
>     `w32'
>           Emacs is displaying using Windows.
>     `mac'
>           Emacs is displaying using a Macintosh.
>     `nil'
>           Emacs is using a character-based terminal.
> 
> Is there a bug in documentation, because I can't see `windows-nt' or
> `ms-dos' values?

You are looking at the docs for the wrong variable: your code, quite
correctly, works with system-type, not with window-system.
windows-nt and ms-dos are values of system-type, while the
corresponding values for window-system are pc and w32 (assuming these
ports are not run with the -nw switch).

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

* Re: [patch] 21.3 filecache.el - Added Cygwin support
       [not found]     ` <mailman.1309.1075039727.928.bug-gnu-emacs@gnu.org>
  2004-01-26  0:25       ` Jari Aalto+mail.linux
@ 2004-01-26 18:51       ` Kevin Rodgers
  2004-01-27  8:20         ` Eli Zaretskii
  1 sibling, 1 reply; 10+ messages in thread
From: Kevin Rodgers @ 2004-01-26 18:51 UTC (permalink / raw)


Eli Zaretskii wrote:

> I know that on Windows one must test whether `find' is the Unix-style
> `find'.


Why?  `M-x grep-find' assumes that the find progam is the Unix command
(see grep-find-command).  There are probably other Emacs commands that
do as well -- why is filecache.el different?

-- 
Kevin Rodgers

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

* Re: [patch] 21.3 filecache.el - Added Cygwin support
       [not found]         ` <mailman.1345.1075100321.928.bug-gnu-emacs@gnu.org>
@ 2004-01-26 19:22           ` Jari Aalto+mail.linux
  2004-01-27  8:10             ` Eli Zaretskii
  0 siblings, 1 reply; 10+ messages in thread
From: Jari Aalto+mail.linux @ 2004-01-26 19:22 UTC (permalink / raw)


* 2004-01-26 Eli Zaretskii <eliz <AT> elta.co.il> gnu.emacs.bug
* <http://groups.google.com/groups?oi=djq&as_umsgid=%3Cmailman.1345.1075100321.928.bug-gnu-emacs@gnu.org>
| > From: jari.aalto <AT> poboxes.com (Jari Aalto+mail.linux)
| > But --version does not work in SunOS, HP, SGI, IBM, they have
| > their own find and making tests for all of those is beyond my reach.
| 
| You could create a file and see if "find . -name THAT-FILE" finds it
| and prints its name like a Unixy `find' should, for example.

Yes, that would work. Patch below.

| > | What about the Mac?
| 
| You are looking at the docs for the wrong variable: your code, quite
| correctly, works with system-type, not with window-system.
| windows-nt and ms-dos are values of system-type, while the
| corresponding values for window-system are pc and w32 (assuming these
| ports are not run with the -nw switch).
 
Correct. I was looking at wrong variable. But about that mac, is it covered
by values?

    ms-dos windows-nt

Would it be good to mention mac somewhere in the documentation as well?

    `ms-dos'
          Microsoft MS-DOS "operating system."  Emacs compiled with
          DJGPP for MS-DOS binds `system-type' to `ms-dos' even when
          you run it on MS-Windows.

    `windows-nt'
          Microsoft windows NT.  The same executable supports Windows
          9X, but the value of `system-type' is `windows-nt' in either
          case.

Jari


2004-01-26 Mon  Jari Aalto  <jari.aalto <AT> poboxes.com>

        (file-cache-find-unix-p): 1.6 Rewrote. Search a file
        by using Unix find(1) syntax. OS independent check.



Index: filecache.el
===================================================================
RCS file: /cygdrive/h/data/version-control/cvsroot/emacs/gnu-emacs/lisp213/filecache.el,v
retrieving revision 1.5
retrieving revision 1.7
diff -u -IId: -b -w -u -r1.5 -r1.7
--- filecache.el	26 Jan 2004 00:12:13 -0000	1.5
+++ filecache.el	26 Jan 2004 19:16:23 -0000	1.7
@@ -329,26 +329,26 @@
 
 (defun file-cache-find-unix-p ()
   "Check if `file-cache-find-command' is Unix type program."
-  ;;  First, assume Unix system, which alreat has find(1).
-  ;;  SunOS, HP, IBM have their own versions of find(1).
-  (or (not (memq system-type
-                 '(windows-nt
-                   pc
-                   w32
-                   mac
-                   ms-dos)))
-      ;;  This is PC system, do we expect to find GNU find(1)
-      ;;  like one bundled in Cygwin?
+  ;;  Pick file to search from location we know
+  (let* ((dir   (car load-path))
+         (file  (find-if
+                 (lambda (x)
+                   ;; Filter directories . and ..
+                   (not (string-match "^\\.\\.?$" x)))
+                 (directory-files dir))))
       (with-temp-buffer
         (call-process file-cache-find-command
                       nil
                       (current-buffer)
                       nil
-                      "--version")
+                    dir
+                    "-name"
+                    file
+                    "-maxdepth"
+                    "1")
         (goto-char (point-min))
-        ;; Cygwin
-        (if (re-search-forward "GNU" nil t)
-            (buffer-string)))))
+        (if (search-forward file nil t)
+            t))))
 
 (defun file-cache-add-directory-using-find (directory)
   "Use the `find' command to add files to the file cache.

 

-- 
http://tiny-tools.sourceforge.net/
Swatch @time   http://www.mir.com.my/iTime/itime.htm
               http://www.ryanthiessen.com/swatch/resources.htm
Use Licenses!  http://www.linuxjournal.com/article.php?sid=6225
Which Licence? http://www.linuxjournal.com/article.php?sid=4825
OSI Licences   http://www.opensource.org/licenses/

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

* Re: [patch] 21.3 filecache.el - Added Cygwin support
  2004-01-26 19:22           ` Jari Aalto+mail.linux
@ 2004-01-27  8:10             ` Eli Zaretskii
  0 siblings, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2004-01-27  8:10 UTC (permalink / raw)
  Cc: gnu-emacs-bug

> From: jari.aalto@poboxes.com (Jari Aalto+mail.linux)
> Newsgroups: gnu.emacs.bug
> Date: Mon, 26 Jan 2004 21:22:42 +0200
>  
> Correct. I was looking at wrong variable. But about that mac, is it covered
> by values?
> 
>     ms-dos windows-nt

I think the Mac port advertises its system-type as `darwin'.

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

* Re: [patch] 21.3 filecache.el - Added Cygwin support
  2004-01-26 18:51       ` Kevin Rodgers
@ 2004-01-27  8:20         ` Eli Zaretskii
  0 siblings, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2004-01-27  8:20 UTC (permalink / raw)
  Cc: gnu-emacs-bug

> From: Kevin Rodgers <ihs_4664@yahoo.com>
> Newsgroups: gnu.emacs.bug
> Date: Mon, 26 Jan 2004 11:51:22 -0700
> 
> > I know that on Windows one must test whether `find' is the Unix-style
> > `find'.
> 
> Why?

Because there's another find.exe, one that comes with Windows, and
which is a completely different program, more like Grep.

> `M-x grep-find' assumes that the find progam is the Unix command
> (see grep-find-command).

IMHO, it's a bug in grep-find.

> There are probably other Emacs commands that do as well

What commands are those?

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

end of thread, other threads:[~2004-01-27  8:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-24  9:25 [patch] 21.3 filecache.el - Added Cygwin support Jari Aalto+mail.emacs
2004-01-24 10:46 ` Eli Zaretskii
     [not found] ` <mailman.1267.1074941456.928.bug-gnu-emacs@gnu.org>
2004-01-25 11:52   ` Jari Aalto+mail.linux
2004-01-25 14:09     ` Eli Zaretskii
     [not found]     ` <mailman.1309.1075039727.928.bug-gnu-emacs@gnu.org>
2004-01-26  0:25       ` Jari Aalto+mail.linux
2004-01-26  6:59         ` Eli Zaretskii
     [not found]         ` <mailman.1345.1075100321.928.bug-gnu-emacs@gnu.org>
2004-01-26 19:22           ` Jari Aalto+mail.linux
2004-01-27  8:10             ` Eli Zaretskii
2004-01-26 18:51       ` Kevin Rodgers
2004-01-27  8:20         ` 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).