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.
Drew
  • 75,699
  • 9
  • 109
  • 225
B. Pillet
  • 41
  • 3

1 Answers1

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"
B. Pillet
  • 41
  • 3