emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <nicholas.dokos@hp.com>
To: =?utf-8?Q?S=C3=A9bastien_Vauban?= <wxhgmqzgwmuf@spammotel.com>
Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org
Subject: Re: Re: [babel] How to kill two birds with one stone?
Date: Fri, 25 Feb 2011 17:44:43 -0500	[thread overview]
Message-ID: <4851.1298673883@alphaville.usa.hp.com> (raw)
In-Reply-To: Message from =?utf-8?Q?S=C3=A9bastien_Vauban?= <wxhgmqzgwmuf@spammotel.com> of "Fri\, 25 Feb 2011 15\:27\:29 +0100." <80y654nq9a.fsf@somewhere.org>

Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> wrote:

> ... 
> * List all files in dir (version of Seb)
> 
> My code was a bit more complex... because I need to be able to correctly take
> care of filenames containing spaces inside them (I'm on Windows, I never do
> such a thing, but there are well spaces on the files I wanna graph).
> 
> #+srcname: graph-files-seb
> #+begin_src sh :results vector :var dir=graph-dir
>   find $dir -type f -print |\
>   while read -r name
>   do
>       echo "\"${name##*/}\""
>   done
> #+end_src
> 
> #+results: graph-files-seb
> | dan   |         |
> | eric  |         |
> | other |         |
> | "seb  | vauban" |
> 

I suspect that this is a losing battle: spaces in filenames are legal,
they are common on Windows systems, but they are a PITA. The main reason
is that a *lot* of tools (particularly Unix tools of a certain age)
assume that spaces in filenames will not occur and break in mysterious
and unexpected ways when presented with a directory structure that
contains such.

There are various workarounds (the most important of which, practically speaking,
is the idiom

   find ... -print0 | xargs -0 ....

which causes ``find'' to use a null byte as a separator and ``xargs'' to
search for same in order to split the list into its constituent
components - null bytes being illegal in filenames), and there is a
long, fairly exhaustive discusssion of such matters in David Wheeler's
enlightening essay:

   http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html

but none of these would help in this case, because the culprit here
turns out to be org-table-convert-region:

,----
| org-table-convert-region is an interactive Lisp function in
| `org-table.el'.
| 
| (org-table-convert-region BEG0 END0 &optional SEPARATOR)
| 
| Convert region to a table.
| The region goes from BEG0 to END0, but these borders will be moved
| slightly, to make sure a beginning of line in the first line is included.
| 
| SEPARATOR specifies the field separator in the lines.  It can have the
| following values:
| 
| '(4)     Use the comma as a field separator
| '(16)    Use a TAB as field separator
| integer  When a number, use that many spaces as field separator
| nil      When nil, the command tries to be smart and figure out the
|          separator in the following way:
|          - when each line contains a TAB, assume TAB-separated material
|          - when each line contains a comma, assume CSV material
|          - else, assume one or more SPACE characters as separator.
| 
`----

It is called with a nil separator so it uses its "smart" mode and counts
one or more whitespace characters as the separator (I wonder
what would happen with a filename that contains a comma :-)

In any case, the region has the filenames one per line, so if
org-table-convert-region could parse a newline-separated list (and if
there was a way to specify the newline separator from higher levels)
everything would be hunky dory; there might be a way to specify the
separator using dynamic scoping, but org-table-convert-region would
require some changes to take advantage of it.

Nick

  reply	other threads:[~2011-02-25 22:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-04 16:00 [babel] How to kill two birds with one stone? Sébastien Vauban
2011-02-04 17:43 ` Dan Davison
2011-02-04 22:23   ` Sébastien Vauban
2011-02-06 16:51   ` Sébastien Vauban
2011-02-20  8:57     ` Eric Schulte
2011-02-25 14:27       ` Sébastien Vauban
2011-02-25 22:44         ` Nick Dokos [this message]
2011-02-25 22:55           ` Nick Dokos
2011-02-28 13:59           ` Sébastien Vauban
2011-02-26  0:24         ` Eric Schulte
2011-02-26  9:56           ` Closing #+results: with #+end declaration? Bastien
2011-02-27 20:00             ` Eric Schulte
2011-02-28 13:54               ` Sébastien Vauban
2011-03-03 11:11               ` Bastien
2011-02-28 15:16       ` [babel] How to kill two birds with one stone? Sébastien Vauban

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4851.1298673883@alphaville.usa.hp.com \
    --to=nicholas.dokos@hp.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=wxhgmqzgwmuf@spammotel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).