* Parsing and unparsing of strings according to a format
@ 2002-09-05 15:51 Kai Großjohann
0 siblings, 0 replies; only message in thread
From: Kai Großjohann @ 2002-09-05 15:51 UTC (permalink / raw)
In Tramp, I'm operating a lot on filenames. A typical filename might
look like this:
/method:user@host:/path/to/file
For generating this, I use the format-spec function from Gnus which
groks percent-escapes. So I have a format string like so:
/%m:%u@%h:%p
Of course, %m stands for the method and so on. I also have a
home-grown regular expression with parentheses to parse the structure.
Is there a library that will help me with this? So I specify the
filename syntax and the library gives me two functions, one function
that takes method, user, host, path and gives me a string, and
another function that takes a string and gives me method, user, host,
path.
Another filename format is
/[method/user@host]/path/to/file
where the square brackets are part of the filename syntax. The
library should allow me to easily specify which of the two syntaxes I
want (and allow other syntaxes, as well), and then produce a parsing
and an unparsing function.
As a final complication, some of the components of the filename are
optional. For example, the "user@" part is optional. Also, the
"method:" part is optional. And the path can be the empty string.
(In the alternate syntax, it's "method/" instead of "method:".)
So, I specify what the filename looks like and then I have a parsing
function such that
(filename-parse "/grossjoh@schulz:/tmp")
returns a structure where method=nil, user="grossjoh", host="schulz",
path="/tmp". And I have an unparsing function such that
(filename-unparse nil "grossjoh" "schulz" "/tmp")
returns "/grossjoh@schulz:/tmp".
At least for the unparsing part, it seems that something like
mode-line-format ought to do the trick. But is there a function with
the necessary functionality?
And what about parsing?
tia,
kai
--
A large number of young women don't trust men with beards. (BFBS Radio)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-09-05 15:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-05 15:51 Parsing and unparsing of strings according to a format Kai Großjohann
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.