help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to convert an arbitrary string into a filename


From: Marcin Borkowski
Subject: Re: How to convert an arbitrary string into a filename
Date: Thu, 27 Apr 2023 08:51:50 +0200
User-agent: mu4e 1.1.0; emacs 30.0.50

On 2023-04-26, at 23:29, Emanuel Berg <incal@dataswamp.org> wrote:

> Marcin Borkowski 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?
>
> There are functions to do this to strings, what comes to mind
> is `replace-regexp-in-string', but what difference do you mean
> there are between filenames and strings that look like filenames?

Not sure if I wrote anything like that...

> To me it would be enough downcase all chars, convert chars
> with various decorations to their ASCII base equivalents (e.g.
> our Swedish å, ä, and ö to a, a, and o - not that one should
> use non-English for filenames so a bad example, but sometimes
> English has such chars as well), then use the dash char as the
> word delimiter, and after that probably just drop remaining
> non-alphanumerics.

Yeah, more or less.  (Actually, I'm a bit on the fence about downcasing,
and I agree with the rest.)

Best,

-- 
Marcin Borkowski
http://mbork.pl



reply via email to

[Prev in Thread] Current Thread [Next in Thread]