From: Marcin Borkowski <mbork@mbork.pl>
To: Yuri Khan <yuri.v.khan@gmail.com>
Cc: Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>
Subject: Re: How to convert an arbitrary string into a filename
Date: Wed, 26 Apr 2023 20:32:32 +0200 [thread overview]
Message-ID: <87r0s68pfj.fsf@mbork.pl> (raw)
In-Reply-To: <CAP_d_8WZNv7KmkUFYw=u2Qp8We4wvu+F3wie0Fn4e4H-Gb27xw@mail.gmail.com>
On 2023-04-26, at 07:42, Yuri Khan <yuri.v.khan@gmail.com> wrote:
> On Wed, 26 Apr 2023 at 10:56, Marcin Borkowski <mbork@mbork.pl> wrote:
>
>> given an arbitrary string, say "Hello, world!!!", I want to have
>> a filename with all the runs of weird characters (that is,
>> non-alphanumeric ones) converted to dashes (say, "Hello-world"). Is
>> there a function for that in Emacs already or should I write my own?
>
> It looks like you want to generate file names for blog posts or
> articles so that URLs look pretty. While a useful goal, the mechanic
Nice try;-), but no, my use case is different.
> you ask for is lossy, so multiple titles could map into the same file
> name, which, in the worst case, could lead to data loss, or require
> disambiguation of some kind.
I am well aware of that - I don't care about lossiness, and I have ways
to combat ambiguity (the "slug" would only be one of several parts of
the filename).
> (Also, depending on how wide your audience is and what your
> implementation’s definition of alphanumeric is, it might turn titles
> written in non-Latin-based scripts into an empty string, and fixing
> that might be moderately easy for some scripts (e.g. Greek, Cyrillic)
> and hard for others (e.g. CJK).)
My audience is exactly one person, so again - not a problem. (Though
I /will/ blog about it at some point, and then it's possible that
someone might have to adapt the code.)
Best,
--
Marcin Borkowski
http://mbork.pl
next prev parent reply other threads:[~2023-04-26 18:32 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-26 3:55 How to convert an arbitrary string into a filename Marcin Borkowski
2023-04-26 4:03 ` Platon Pronko
2023-04-26 4:42 ` Marcin Borkowski
2023-04-26 5:39 ` Platon Pronko
2023-04-26 18:32 ` Marcin Borkowski
2023-04-26 5:42 ` Yuri Khan
2023-04-26 18:32 ` Marcin Borkowski [this message]
2023-04-26 10:08 ` Jean Louis
2023-04-26 12:30 ` Jean Louis
2023-04-26 13:07 ` Eli Zaretskii
2023-04-27 4:52 ` Jean Louis
2023-04-27 5:53 ` Eli Zaretskii
2023-04-27 8:06 ` Platon Pronko
2023-04-26 18:30 ` Marcin Borkowski
2023-04-26 21:29 ` Emanuel Berg
2023-04-27 6:51 ` Marcin Borkowski
2023-04-26 21:32 ` Emanuel Berg
2023-04-27 6:49 ` Marcin Borkowski
2023-04-29 6:20 ` James Thomas
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=87r0s68pfj.fsf@mbork.pl \
--to=mbork@mbork.pl \
--cc=help-gnu-emacs@gnu.org \
--cc=yuri.v.khan@gmail.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 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.