all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* find a file and put it in a window
@ 2004-07-26  2:28 Jasen
  0 siblings, 0 replies; 5+ messages in thread
From: Jasen @ 2004-07-26  2:28 UTC (permalink / raw)


Hi all,

Would someone please advise me how can I resolve this problem:

I would like to find a file in a directory through a shell command:

;; Get the newest version of file
   (setq file (string (shell command "ls -tc 
C:\\dir1\\dir2\\dir3/file*.txt | head -1")))

;; Put the file is a windows
   (find-file-other-window file)

The problem is that either Emacs or Windows can't interpret the full
file name along with directory path correctly and I don't know how to
fix it?

Thanks,
Austin

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

* find a file and put it in a window
@ 2004-07-26  2:28 Jasen
  2004-07-26  4:57 ` Eli Zaretskii
       [not found] ` <mailman.1472.1090814571.1960.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 5+ messages in thread
From: Jasen @ 2004-07-26  2:28 UTC (permalink / raw)


Hi all,

Would someone please advise me how can I resolve this problem:

I would like to find a file in a directory through a shell command:

;; Get the newest version of file
   (setq file (string (shell command "ls -tc 
C:\\dir1\\dir2\\dir3/file*.txt | head -1")))

;; Put the file is a windows
   (find-file-other-window file)

The problem is that either Emacs or Windows can't interpret the full
file name along with directory path correctly and I don't know how to
fix it?

Thanks,
Austin

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

* Re: find a file and put it in a window
  2004-07-26  2:28 find a file and put it in a window Jasen
@ 2004-07-26  4:57 ` Eli Zaretskii
       [not found] ` <mailman.1472.1090814571.1960.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2004-07-26  4:57 UTC (permalink / raw)


> From: Jasen <xx@yy.zz>
> Newsgroups: gnu.emacs.help
> Date: Sun, 25 Jul 2004 19:28:38 -0700
> 
> I would like to find a file in a directory through a shell command:
> 
> ;; Get the newest version of file
>    (setq file (string (shell command "ls -tc 
> C:\\dir1\\dir2\\dir3/file*.txt | head -1")))
> 
> ;; Put the file is a windows
>    (find-file-other-window file)
> 
> The problem is that either Emacs or Windows can't interpret the full
> file name along with directory path correctly and I don't know how to
> fix it?

I think the problem is that the string you get includes a newline
after the name of the file.  You need to remove that before you use
the string as a file name.

(You can see what string Emacs gets by using shell-command-to-string.)

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

* Re: find a file and put it in a window
       [not found] ` <mailman.1472.1090814571.1960.help-gnu-emacs@gnu.org>
@ 2004-07-26  5:34   ` Jasen
  2004-07-26 18:26     ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Jasen @ 2004-07-26  5:34 UTC (permalink / raw)




Eli Zaretskii wrote:

>>From: Jasen <xx@yy.zz>
>>Newsgroups: gnu.emacs.help
>>Date: Sun, 25 Jul 2004 19:28:38 -0700
>>
>>I would like to find a file in a directory through a shell command:
>>
>>;; Get the newest version of file
>>   (setq file (string (shell command "ls -tc 
>>C:\\dir1\\dir2\\dir3/file*.txt | head -1")))
>>
>>;; Put the file is a windows
>>   (find-file-other-window file)
>>
>>The problem is that either Emacs or Windows can't interpret the full
>>file name along with directory path correctly and I don't know how to
>>fix it?
> 
> 
> I think the problem is that the string you get includes a newline
> after the name of the file.  You need to remove that before you use
> the string as a file name.
> 
> (You can see what string Emacs gets by using shell-command-to-string.)
> 
> 

Ok, I'm almost there but Emacs gets me an empty new file rather than the 
  existing file?  Could this be the problem of space in the directory 
path because I'm using Windows XP and there are spaces in the path? 
c:/Documents and Settings/austin/Local Settings/Temp

Thanks,
Austin

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

* Re: find a file and put it in a window
  2004-07-26  5:34   ` Jasen
@ 2004-07-26 18:26     ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2004-07-26 18:26 UTC (permalink / raw)


> From: Jasen <xx@yy.zz>
> Newsgroups: gnu.emacs.help
> Date: Sun, 25 Jul 2004 22:34:40 -0700
> 
> Ok, I'm almost there but Emacs gets me an empty new file rather than the 
>   existing file?  Could this be the problem of space in the directory 
> path because I'm using Windows XP and there are spaces in the path? 
> c:/Documents and Settings/austin/Local Settings/Temp

I don't think it should matter in this case, but it's easy to check:
just run the same code on a directory where the result of the shell
command gives you a file name without embedded whitespace, and see if
that succeeds.

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

end of thread, other threads:[~2004-07-26 18:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-26  2:28 find a file and put it in a window Jasen
2004-07-26  4:57 ` Eli Zaretskii
     [not found] ` <mailman.1472.1090814571.1960.help-gnu-emacs@gnu.org>
2004-07-26  5:34   ` Jasen
2004-07-26 18:26     ` Eli Zaretskii
  -- strict thread matches above, loose matches on Subject: below --
2004-07-26  2:28 Jasen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.