2

I want to generate very simple filenames from complex strings during a org-capture. For instance the string

"Une idée nouvelle pour calculer $\\int_0^{\\infty} e^{-t^2} \\dd t$"

Should be reduced to une_idee_nouvelle_pour_calculer_int_0_infty_e_-t_2_dd_t.org or something equivalent.

Should I use replace-regexp-in-string with appropriate regexp (that I have trouble building) or is there a more canonical way ?

Non comprehensive specification list :

  • remove spaces (replace with underscore)
  • only alphanumeric ascii characters (no symbols, no other unicode...), the rest is deleted
  • (if possible) intelligent replacement "Å" -> "A"
  • (if possible but seems hard) trim obvious gibberish from parts with way too many characters removed.
1

1 Answer 1

2

I found a melpa package which does just that and properly : unidecode

(unidecode-sanitize "Une idée nouvelle pour calculer $\\int_0^{\\infty} e^{t^2} \\dd t$")


"une-idee-nouvelle-pour-calculer-int0infty-et2-dd-t"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.