* Newlines in file names
@ 2012-12-10 19:47 Whitfield Diffie
2012-12-11 14:02 ` Doug Lewan
0 siblings, 1 reply; 5+ messages in thread
From: Whitfield Diffie @ 2012-12-10 19:47 UTC (permalink / raw)
To: help-gnu-emacs
Question: How do you translate a filename containing a newline to one containing
a \n without getting a \\n.
Problem: Create a directory ``test''.
In the directory create a file with (call-process "touch" nil
nil nil "Icon\n").
This file's name has five characters of which the last is a
newline. (Such files
appear in some downloads.)
This directory now appears as
/Users/diffie/test:
total used in directory 0 available 327738716
drwxr-xr-x 3 diffie staff 102 Dec 10 11:04 .
drwxr-xr-x 25 diffie staff 850 Dec 10 11:03 ..
-rw-r--r-- 1 diffie staff 0 Dec 9 10:01 Icon
Place the cursor on the line with the Icon file and type
<esc>: (file-exists-p (dired get filename))
The response is ``nil''.
Make the buffer writable with <ctrl-x><ctrl-q> and edit the
name by hand to ``Icon\n''. Type
<esc>: (file-exists-p (dired-get-filename))
The response is now ``t''.
Type g to revert the buffer and the name returns to being ``Icon''.
Place the cursor on the line with the Icon file again and type
M+x
The entire file line disappears leaving only . and .. in the
directory.
Type g to revert the buffer and the line reappears but the file
has not become executable.
Edit the filename as before and repeat the attempt to make it
executable.
Now the file line becomes
-rwxr-xr-x 1 diffie staff 0 Dec 9 10:01 Icon
The file has become executable but its name has returned to being
``Icon'', lacks the newline character.
Objective: Repair dired so that filenames containing newlines are displayed
with \n in place of newline characters (and \r in place of carriage
returns).
I have tried setting print-escape-newlines to t and recoding
filename with buffer-file-coding-system, file-name-coding-system,
and default-file-name-coding-system, without success.
Whit
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: Newlines in file names
2012-12-10 19:47 Newlines in file names Whitfield Diffie
@ 2012-12-11 14:02 ` Doug Lewan
2012-12-11 15:19 ` Whitfield Diffie
0 siblings, 1 reply; 5+ messages in thread
From: Doug Lewan @ 2012-12-11 14:02 UTC (permalink / raw)
To: Whitfield Diffie, help-gnu-emacs@gnu.org
What version of emacs are you using?
I don't have such problems in version 24, but I do remember dired using a regular expression that wouldn't match such uncommon names in earlier versions.
,Douglas
Douglas Lewan
Shubert Ticketing
(201) 489-8600 ext 224
When I do good, I feel good. When I do bad, I feel bad and that's my religion. - Abraham Lincoln
> -----Original Message-----
> From: help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org
> [mailto:help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org] On
> Behalf Of Whitfield Diffie
> Sent: Monday, 2012 December 10 14:48
> To: help-gnu-emacs@gnu.org
> Subject: Newlines in file names
>
> Question: How do you translate a filename containing a newline to one
> containing
> a \n without getting a \\n.
>
> Problem: Create a directory ``test''.
>
> In the directory create a file with (call-process "touch" nil
> nil nil "Icon\n").
> This file's name has five characters of which the last is a
> newline. (Such files
> appear in some downloads.)
>
> This directory now appears as
>
> /Users/diffie/test:
> total used in directory 0 available 327738716
> drwxr-xr-x 3 diffie staff 102 Dec 10 11:04 .
> drwxr-xr-x 25 diffie staff 850 Dec 10 11:03 ..
> -rw-r--r-- 1 diffie staff 0 Dec 9 10:01 Icon
>
> Place the cursor on the line with the Icon file and type
>
> <esc>: (file-exists-p (dired get filename))
>
> The response is ``nil''.
>
> Make the buffer writable with <ctrl-x><ctrl-q> and edit the
> name by hand to ``Icon\n''. Type
>
> <esc>: (file-exists-p (dired-get-filename))
>
> The response is now ``t''.
>
> Type g to revert the buffer and the name returns to being
> ``Icon''.
>
> Place the cursor on the line with the Icon file again and type
>
> M+x
>
> The entire file line disappears leaving only . and .. in the
> directory.
>
> Type g to revert the buffer and the line reappears but the
> file
> has not become executable.
>
> Edit the filename as before and repeat the attempt to make it
> executable.
>
> Now the file line becomes
>
> -rwxr-xr-x 1 diffie staff 0 Dec 9 10:01 Icon
>
> The file has become executable but its name has returned to
> being
> ``Icon'', lacks the newline character.
>
> Objective: Repair dired so that filenames containing newlines are
> displayed
> with \n in place of newline characters (and \r in place of
> carriage
> returns).
>
> I have tried setting print-escape-newlines to t and recoding
> filename with buffer-file-coding-system, file-name-coding-
> system,
> and default-file-name-coding-system, without success.
>
>
> Whit
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Newlines in file names
2012-12-11 14:02 ` Doug Lewan
@ 2012-12-11 15:19 ` Whitfield Diffie
2012-12-11 16:34 ` Doug Lewan
0 siblings, 1 reply; 5+ messages in thread
From: Whitfield Diffie @ 2012-12-11 15:19 UTC (permalink / raw)
To: Doug Lewan; +Cc: help-gnu-emacs@gnu.org
> What version of emacs are you using?
22.1.2. I apologize for not including that; it hit me that I
hadn't just after I had sent the message.
> I don't have such problems in version 24, but I do remember dired using a regular expression that wouldn't match such uncommon names in earlier versions.
I think you mean a string used in a dired-string-replace-match in
dired-get-filename to remove quotes that come in from ls. That filter
solves some bad filenames bit I didn't succeed in diddling it to solve
the newline problem.
Whit
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: Newlines in file names
2012-12-11 15:19 ` Whitfield Diffie
@ 2012-12-11 16:34 ` Doug Lewan
0 siblings, 0 replies; 5+ messages in thread
From: Doug Lewan @ 2012-12-11 16:34 UTC (permalink / raw)
To: Whitfield Diffie; +Cc: help-gnu-emacs@gnu.org
> -----Original Message-----
> From: whitfielddiffie@gmail.com [mailto:whitfielddiffie@gmail.com] On
> Behalf Of Whitfield Diffie
> Sent: Tuesday, 2012 December 11 10:19
> To: Doug Lewan
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Newlines in file names
>
> > What version of emacs are you using?
>
> 22.1.2. I apologize for not including that; it hit me that I
> hadn't just after I had sent the message.
>
> > I don't have such problems in version 24, but I do remember dired
> using a regular expression that wouldn't match such uncommon names in
> earlier versions.
>
> I think you mean a string used in a dired-string-replace-match in
> dired-get-filename to remove quotes that come in from ls. That filter
> solves some bad filenames bit I didn't succeed in diddling it to solve
> the newline problem.
That's probably what I meant.
I remember having problems exactly with filenames that ended with newline. I also remember dealing with them by hand every time. Enough to annoy. Infrequent enough not to program against. Yuck.
>
>
> Whit
,Douglas
Douglas Lewan
Shubert Ticketing
(201) 489-8600 ext 224
When I do good, I feel good. When I do bad, I feel bad and that's my religion. - Abraham Lincoln
^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <mailman.14995.1355169707.855.help-gnu-emacs@gnu.org>]
end of thread, other threads:[~2012-12-11 16:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-10 19:47 Newlines in file names Whitfield Diffie
2012-12-11 14:02 ` Doug Lewan
2012-12-11 15:19 ` Whitfield Diffie
2012-12-11 16:34 ` Doug Lewan
[not found] <mailman.14995.1355169707.855.help-gnu-emacs@gnu.org>
2012-12-10 22:53 ` Barry Margolin
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).