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

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

Re: [elisp] Look for function that create safe file name from string...


From: Pascal J. Bourguignon
Subject: Re: [elisp] Look for function that create safe file name from string...
Date: Mon, 09 Jul 2012 21:50:22 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

Oleksandr Gavenko <gavenkoa@gmail.com> writes:

> I decide store my message after sending it to mail/news.
>
> As file name I use date and message header.
>
> But message header may contain danger symbol. One of errors I get when '/'
> char present in file name...
>
> So I look for function that safely escape string to get file name in portable
> for Emacs way...

(defun alphanumericp (ch)
  (find ch "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"))
                                                                
    
(defun clean-filename (name)
  (remove-if-not (lambda (ch) (or (alphanumericp ch) (find ch "-_.")))
                 (substitute ?- 32 name)))

(clean-filename "Subject: Re: [elisp] Look for function that create
safe file name from string...")
--> 
"Subject-Re-elisp-Look-for-function-that-createsafe-file-name-from-string..."


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


reply via email to

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