Re: woman doesn't work if current buffer's directory doesn't exist
Eli Zaretskii [EMAIL PROTECTED] writes: At this late stage in the pretest, won't it be safer to bind default-directory only if the original value doesn't exist? I don't think so, because it's possible for the original value to exist and yet not be accessible to us. Okay, then test for accessibility instead of a mere existence. I checked in such a fix. Thanks. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: woman doesn't work if current buffer's directory doesn't exist
Eli Zaretskii [EMAIL PROTECTED] writes: At this late stage in the pretest, won't it be safer to bind default-directory only if the original value doesn't exist? I don't think so, because it's possible for the original value to exist and yet not be accessible to us. For example, if the original value exists but we don't have execute permission on it, then call-process still fails like this: Debugger entered--Lisp error: (file-error Setting current directory permission denied /tmp/444/) On the other hand, if we can't cd to (file-name-directory infile) then we won't be able to read infile anyway. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: woman doesn't work if current buffer's directory doesn't exist
Cc: [EMAIL PROTECTED], emacs-pretest-bug@gnu.org From: Chris Moore [EMAIL PROTECTED] Date: Sat, 27 Jan 2007 10:53:24 +0100 Eli Zaretskii [EMAIL PROTECTED] writes: At this late stage in the pretest, won't it be safer to bind default-directory only if the original value doesn't exist? I don't think so, because it's possible for the original value to exist and yet not be accessible to us. Okay, then test for accessibility instead of a mere existence. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: woman doesn't work if current buffer's directory doesn't exist
Richard Stallman [EMAIL PROTECTED] writes: We need to fix all the file handlers that use call-process, I agree. Fortunately there are not too many. I agree it would be easier if we could fix this in call-process. That was the first direction I looked in. However, someone pointed out why changing the home directory magically in call-process just isn't acceptable: because it would change the meaning of relative file name arguments. Fixing the callers is our only option. Therefore, I ask people to start actually doing this. Michael, could you fix Tramp and ange-ftp? For Tramp and ange-ftp, it is start-process who needs a proper setting of default-directory. I've fixed this for Tramp. ange-ftp was already clean with respect to this. Best regards, Michael. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: woman doesn't work if current buffer's directory doesn't exist
Thanks. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: woman doesn't work if current buffer's directory doesn't exist
I guess all I mean is that we need to fix Tramp (and other file handlers) as well as jka-compr, because this also causes an error: We need to fix all the file handlers that use call-process, I agree. Fortunately there are not too many. I agree it would be easier if we could fix this in call-process. That was the first direction I looked in. However, someone pointed out why changing the home directory magically in call-process just isn't acceptable: because it would change the meaning of relative file name arguments. Fixing the callers is our only option. Therefore, I ask people to start actually doing this. Michael, could you fix Tramp and ange-ftp? ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: woman doesn't work if current buffer's directory doesn't exist
On 1/26/07, Richard Stallman [EMAIL PROTECTED] wrote: Let's not go around in circles. We've already seen why this can't be fixed in a natural way. Yes, sorry. I missed the start of the thread. BTW, I think the comments in jka-compr.el and some doctrings (notoriously those of `jka-compr-shell' and `ja-compr-compression-info-list') do lie about the use of a shell and the following patch should be applied. /L/e/k/t/u Index: lisp/jka-cmpr-hook.el === RCS file: /cvsroot/emacs/emacs/lisp/jka-cmpr-hook.el,v retrieving revision 1.14 diff -c -r1.14 jka-cmpr-hook.el *** lisp/jka-cmpr-hook.el 21 Jan 2007 03:53:11 - 1.14 --- lisp/jka-cmpr-hook.el 26 Jan 2007 12:13:47 - *** *** 248,257 file-magic-chars is a string of characters that you would find at the beginning of a file compressed in this way. - Because of the way `call-process' is defined, discarding the stderr output of - a program adds the overhead of starting a shell each time the program is - invoked. - If you set this outside Custom while Auto Compression mode is already enabled \(as it is by default), you have to call `jka-compr-update' after setting it to properly update other --- 248,253 Index: lisp/jka-compr.el === RCS file: /cvsroot/emacs/emacs/lisp/jka-compr.el,v retrieving revision 1.92 diff -c -r1.92 jka-compr.el *** lisp/jka-compr.el 21 Jan 2007 03:53:11 - 1.92 --- lisp/jka-compr.el 26 Jan 2007 12:15:06 - *** *** 47,64 ;; The default value of this variable allows jka-compr to work with ;; Unix compress and gzip. ;; - ;; If you are concerned about the stderr output of gzip and other - ;; compression/decompression programs showing up in your buffers, you - ;; should set the discard-error flag in the compression-info-list. - ;; This will cause the stderr of all programs to be discarded. - ;; However, it also causes emacs to call compression/uncompression - ;; programs through a shell (which is specified by jka-compr-shell). - ;; This may be a drag if, on your system, starting up a shell is - ;; slow. - ;; ;; If you don't want messages about compressing and decompressing ! ;; to show up in the echo area, you can set the compress-name and ! ;; decompress-name fields of the jka-compr-compression-info-list to ;; nil. --- 47,55 ;; The default value of this variable allows jka-compr to work with ;; Unix compress and gzip. ;; ;; If you don't want messages about compressing and decompressing ! ;; to show up in the echo area, you can set the compress-msg and ! ;; decompress-msg fields of the jka-compr-compression-info-list to ;; nil. *** *** 105,113 (defcustom jka-compr-shell sh *Shell to be used for calling compression programs. ! The value of this variable only matters if you want to discard the ! stderr of a compression/decompression program (see the documentation ! for `jka-compr-compression-info-list'). :type 'string :group 'jka-compr) --- 96,102 (defcustom jka-compr-shell sh *Shell to be used for calling compression programs. ! NOTE: Not used in MS-DOS and Windows systems. :type 'string :group 'jka-compr) ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: woman doesn't work if current buffer's directory doesn't exist
Richard Stallman [EMAIL PROTECTED] writes: To see jka-compr failing, evaluate this: (let ((default-directory /a/b/c)) (insert-file-contents /usr/share/man/man1/ls.1.gz)) Can someone please fix jka-compr? My post which started this thread contained a fix for jka-compr. The modified functions will need reindenting. I've left the indentation alone to make the patch more readable. $ cvs diff -c lisp/jka-compr.el Index: lisp/jka-compr.el === RCS file: /sources/emacs/emacs/lisp/jka-compr.el,v retrieving revision 1.92 diff -c -r1.92 jka-compr.el *** lisp/jka-compr.el 21 Jan 2007 03:53:11 - 1.92 --- lisp/jka-compr.el 26 Jan 2007 14:46:48 - *** *** 166,171 --- 166,172 ;; to discard the part we don't want. (let ((skip (/ beg jka-compr-dd-blocksize)) (err-file (jka-compr-make-temp-name)) + (default-directory (file-name-directory infile)) count) ;; Update PREFIX based on the text that we won't read in. (setq prefix (- beg (* skip jka-compr-dd-blocksize)) *** *** 204,209 --- 205,211 (defun jka-compr-call-process (prog message infile output temp args) + (let ((default-directory (file-name-directory infile))) (if jka-compr-use-shell (let ((err-file (jka-compr-make-temp-name)) *** *** 243,248 --- 245,251 (with-current-buffer temp (write-region (point-min) (point-max) output) (erase-buffer) + ) ;; Support for temp files. Much of this was inspired if not lifted ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: woman doesn't work if current buffer's directory doesn't exist
Cc: [EMAIL PROTECTED], emacs-pretest-bug@gnu.org From: Chris Moore [EMAIL PROTECTED] Date: Fri, 26 Jan 2007 15:52:36 +0100 *** lisp/jka-compr.el 21 Jan 2007 03:53:11 - 1.92 --- lisp/jka-compr.el 26 Jan 2007 14:46:48 - *** *** 166,171 --- 166,172 ;; to discard the part we don't want. (let ((skip (/ beg jka-compr-dd-blocksize)) (err-file (jka-compr-make-temp-name)) + (default-directory (file-name-directory infile)) count) ;; Update PREFIX based on the text that we won't read in. (setq prefix (- beg (* skip jka-compr-dd-blocksize)) *** *** 204,209 --- 205,211 (defun jka-compr-call-process (prog message infile output temp args) + (let ((default-directory (file-name-directory infile))) (if jka-compr-use-shell At this late stage in the pretest, won't it be safer to bind default-directory only if the original value doesn't exist? ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: woman doesn't work if current buffer's directory doesn't exist
BTW, I think the comments in jka-compr.el and some doctrings (notoriously those of `jka-compr-shell' and `ja-compr-compression-info-list') do lie about the use of a shell and the following patch should be applied. Please install your patch. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: woman doesn't work if current buffer's directory doesn't exist
At this late stage in the pretest, won't it be safer to bind default-directory only if the original value doesn't exist? I am not sure whether it is safer, but it can't really hurt, and it avoids the issue of installing more code by Chris Moore before his papers come. Would you please install that change? ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: woman doesn't work if current buffer's directory doesn't exist
Chris Moore wrote: Kevin Rodgers [EMAIL PROTECTED] writes: It should signal an error, that the directory doesn't exist. How does one create a buffer whose default-directory doesn't exist? One finds a file or creates a buffer which isn't associated with a file, but has default-directory set anyway, and then has someone else: rename the directory containing the file or rename one of the directories higher up the tree or umount the filesystem holding the file or ... I don't find those scenarios compelling, but I did find out that it's even easier: C-x C-f /this/directory/doesn't/exist/and_neither_does_this_file RET I don't see why I shouldn't be allowed to pipe the contents of a buffer through 'wc -w' for example to count the words in the buffer just because the buffer's default-directory doesn't exist. Now _that_ is a compelling argument. In the case where I first saw this bug, the buffer in question wasn't associated with a file at all. I had simply typed C-x b tmp RET to create a temporary buffer. I was in a '*shell*' buffer at the time, which was in the ~/tmp/foo directory. The 'tmp' buffer which I created therefore had a default-directory of ~/tmp/foo - a directory which I then deleted before attempting to run a shell command on the contents of the tmp buffer. Hmmm. So what is the appropriate directory to use in that situation? As someone else pointed out, that will affect how relative pathnames are interpreted: usefully and safely, or not. Note that when checking for the existance of default-directory, we need to take the filename handlers into account. /ssh:[EMAIL PROTECTED]:/tmp might look like a bad pathname, but it makes sense to Tramp. That is a whole other can of worms. In that case, Tramp is responsible for ensuring that file-directory-p returns the correct result (which is noncontroversial) and also for ensuring that shell-command, call-process, etc. Do The Right Thing i.e. run the command on the remote host in the specified directory (which may or may not be implemented yet). -- Kevin Rodgers Denver, Colorado, USA ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: woman doesn't work if current buffer's directory doesn't exist
To see jka-compr failing, evaluate this: (let ((default-directory /a/b/c)) (insert-file-contents /usr/share/man/man1/ls.1.gz)) Can someone please fix jka-compr? ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: woman doesn't work if current buffer's directory doesn't exist
On 1/25/07, Richard Stallman [EMAIL PROTECTED] wrote: To see jka-compr failing, evaluate this: (let ((default-directory /a/b/c)) (insert-file-contents /usr/share/man/man1/ls.1.gz)) Can someone please fix jka-compr? It's at a lower level than jka-compr: (let ((default-directory a/b/c)) (call-process gzip c:/emacs/otros/quack.el.gz t nil -d)) = *** Eval error *** Setting current directory: no such file or directory, a/b/c /L/e/k/t/u ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: woman doesn't work if current buffer's directory doesn't exist
On 1/25/07, Eli Zaretskii [EMAIL PROTECTED] wrote: What do you mean by ``take into account''? File primitives already do take that into account, in a way, so I'm unsure what you meant here. I'm sorry. I guess all I mean is that we need to fix Tramp (and other file handlers) as well as jka-compr, because this also causes an error: $ emacs -Q (require 'shell) (let ((default-directory /a/b/c)) (insert-file-contents /scp:lukhas:/home/dooglus/.BASH_PROFILE nil)) and so does this: $ emacs -Q (let ((default-directory /a/b/c)) (require 'shell)) Both of these errors are caused by call-process not working when the current directory doesn't exist. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: woman doesn't work if current buffer's directory doesn't exist
It's at a lower level than jka-compr: (let ((default-directory a/b/c)) (call-process gzip c:/emacs/otros/quack.el.gz t nil -d)) Let's not go around in circles. We've already seen why this can't be fixed in a natural way. So jka-compr needs to be fixed to avoid doing this. Would someone please fix jka-compr? ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: woman doesn't work if current buffer's directory doesn't exist
There's no ``best way'', it depends on what code calls call-process. In some cases, you could bind default-directory to something sensible (e.g., invocation-directory), in others you _must_ fail, because the command arguments could use something like ./foo/bar which precludes us from changing directories. That is a good point. Could you fix woman? ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: woman doesn't work if current buffer's directory doesn't exist
Kevin Rodgers [EMAIL PROTECTED] writes: It should signal an error, that the directory doesn't exist. How does one create a buffer whose default-directory doesn't exist? One finds a file or creates a buffer which isn't associated with a file, but has default-directory set anyway, and then has someone else: rename the directory containing the file or rename one of the directories higher up the tree or umount the filesystem holding the file or ... I don't see why I shouldn't be allowed to pipe the contents of a buffer through 'wc -w' for example to count the words in the buffer just because the buffer's default-directory doesn't exist. In the case where I first saw this bug, the buffer in question wasn't associated with a file at all. I had simply typed C-x b tmp RET to create a temporary buffer. I was in a '*shell*' buffer at the time, which was in the ~/tmp/foo directory. The 'tmp' buffer which I created therefore had a default-directory of ~/tmp/foo - a directory which I then deleted before attempting to run a shell command on the contents of the tmp buffer. Note that when checking for the existance of default-directory, we need to take the filename handlers into account. /ssh:[EMAIL PROTECTED]:/tmp might look like a bad pathname, but it makes sense to Tramp. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: woman doesn't work if current buffer's directory doesn't exist
Richard Stallman [EMAIL PROTECTED] writes: There's no ``best way'', it depends on what code calls call-process. In some cases, you could bind default-directory to something sensible (e.g., invocation-directory), in others you _must_ fail, because the command arguments could use something like ./foo/bar which precludes us from changing directories. That is a good point. Could you fix woman? I don't think woman needs fixing. Woman is failing because jka-compr is failing, and that's where this can be fixed. To see jka-compr failing, evaluate this: (let ((default-directory /a/b/c)) (insert-file-contents /usr/share/man/man1/ls.1.gz)) I see a backtrace like this: Debugger entered--Lisp error: (file-error Setting current directory no suc signal(file-error (Setting current directory no such file or directory (if (and (eq ... ...) (eq ... local-file)) (if visit (setq notfound error-c (condition-case error-code (let (...) (if replace ...) (setq start ...) (if (progn (and uncompress-message (message %s %s... uncompress-message base- (unwind-protect (progn (and uncompress-message ...) (condition-case error-c (let ((uncompress-message ...) (uncompress-program ...) (uncompress-args .. (if info (let (... ... ... ... ... ... local-file size start) (setq local-f (let* ((filename ...) (info ...)) (if info (let ... ... ... ... ... ... ... jka-compr-insert-file-contents(/usr/share/man/man1/ls.1.gz nil nil nil ni apply(jka-compr-insert-file-contents (/usr/share/man/man1/ls.1.gz nil nil jka-compr-handler(insert-file-contents /usr/share/man/man1/ls.1.gz nil ni insert-file-contents(/usr/share/man/man1/ls.1.gz) (let ((default-directory /a/b/c)) (insert-file-contents /usr/share/man/m eval((let ((default-directory /a/b/c)) (insert-file-contents /usr/share/ eval-last-sexp-1(nil) eval-last-sexp(nil) call-interactively(eval-last-sexp) (assuming /a/b/c doesn't exist, and /usr/share/man/man1/ls.1.gz does, and is in gzip format) ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: woman doesn't work if current buffer's directory doesn't exist
From: Chris Moore [EMAIL PROTECTED] Date: Wed, 24 Jan 2007 22:58:37 +0100 Cc: emacs-pretest-bug@gnu.org Note that when checking for the existance of default-directory, we need to take the filename handlers into account. What do you mean by ``take into account''? File primitives already do take that into account, in a way, so I'm unsure what you meant here. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
woman doesn't work if current buffer's directory doesn't exist
In GNU Emacs 22.0.92.24 (i686-pc-linux-gnu, GTK+ Version 2.8.20) of 2007-01-21 on trpaslik X server distributor `The X.Org Foundation', version 11.0.70101000 configured using `configure '--with-gtk' '--prefix' '/usr/local' '--with-xpm' '--with-jpeg' '--with-png' '--with-gif'' $ mkdir /tmp/foo $ cd /tmp/foo $ emacs -Q# current directory is /tmp/foo M-x delete-directory RET RET # remove the current directory M-x woman RET ls RET # woman fails * File /usr/share/man/man1/ls.1.gz not found! * The error message is misleading, since the file does exist, and is readable. The cause of the problem is that call-process doesn't work if default-directory doesn't exist, and jka-compr.el uses call-process in a few places. This should probably be fixed in call-process (I can't use shell-command-on-region to pipe a region of a buffer through a shell command if default-directory doesn't exist, for example, and I'd like to be able to). Perhaps default-directory could default to the value of temporary-file-directory if it doesn't exist. Alternatively, a less far-ranging fix is to modify just jka-compr.el to bind default-directory while call-process is running: --- lisp/old/jka-compr.el 2006-12-05 07:15:38.0 +0100 +++ lisp/jka-compr.el 2007-01-22 04:50:57.0 +0100 @@ -166,6 +166,7 @@ ;; to discard the part we don't want. (let ((skip (/ beg jka-compr-dd-blocksize)) (err-file (jka-compr-make-temp-name)) + (default-directory (file-name-directory infile)) count) ;; Update PREFIX based on the text that we won't read in. (setq prefix (- beg (* skip jka-compr-dd-blocksize)) @@ -204,6 +205,7 @@ (defun jka-compr-call-process (prog message infile output temp args) + (let ((default-directory (file-name-directory infile))) (if jka-compr-use-shell (let ((err-file (jka-compr-make-temp-name)) @@ -243,6 +245,7 @@ (with-current-buffer temp (write-region (point-min) (point-max) output) (erase-buffer) + ) ;; Support for temp files. Much of this was inspired if not lifted Chris. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: woman doesn't work if current buffer's directory doesn't exist
This should probably be fixed in call-process (I can't use shell-command-on-region to pipe a region of a buffer through a shell command if default-directory doesn't exist, for example, and I'd like to be able to). Perhaps default-directory could default to the value of temporary-file-directory if it doesn't exist. It would be easy to change what call-process does when default-directory does not exist. What is the best thing for it to do in that case? ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: woman doesn't work if current buffer's directory doesn't exist
Richard Stallman wrote: This should probably be fixed in call-process (I can't use shell-command-on-region to pipe a region of a buffer through a shell command if default-directory doesn't exist, for example, and I'd like to be able to). Perhaps default-directory could default to the value of temporary-file-directory if it doesn't exist. It would be easy to change what call-process does when default-directory does not exist. What is the best thing for it to do in that case? It should signal an error, that the directory doesn't exist. How does one create a buffer whose default-directory doesn't exist? -- Kevin Rodgers Denver, Colorado, USA ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: woman doesn't work if current buffer's directory doesn't exist
From: Richard Stallman [EMAIL PROTECTED] Date: Mon, 22 Jan 2007 21:07:03 -0500 Cc: emacs-pretest-bug@gnu.org Reply-To: [EMAIL PROTECTED] This should probably be fixed in call-process (I can't use shell-command-on-region to pipe a region of a buffer through a shell command if default-directory doesn't exist, for example, and I'd like to be able to). Perhaps default-directory could default to the value of temporary-file-directory if it doesn't exist. It would be easy to change what call-process does when default-directory does not exist. What is the best thing for it to do in that case? There's no ``best way'', it depends on what code calls call-process. In some cases, you could bind default-directory to something sensible (e.g., invocation-directory), in others you _must_ fail, because the command arguments could use something like ./foo/bar which precludes us from changing directories. So I think this problem cannot be solved inside call-process, but instead an application (WoMan in this case) should cater to such situations, where it indeed doesn't matter what is the value of default-directory. Another possibility would be to add an optional argument to call-process, which, when non-nil, will bind default-directory to some value that is guaranteed to be an existing directory, if default-directory is nil. Applications like WoMan could then use that optional argument. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug