all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann)
Subject: Parsing and unparsing of strings according to a format
Date: Thu, 05 Sep 2002 17:51:49 +0200	[thread overview]
Message-ID: <vafn0qwtox6.fsf@lucy.cs.uni-dortmund.de> (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)

                 reply	other threads:[~2002-09-05 15:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

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

  git send-email \
    --in-reply-to=vafn0qwtox6.fsf@lucy.cs.uni-dortmund.de \
    --to=kai.grossjohann@cs.uni-dortmund.de \
    /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 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.