From 09a23c377b19d6ab10d1a269e97f6087c59b77ea Mon Sep 17 00:00:00 2001 From: Jethro Kuan Date: Fri, 6 Mar 2020 01:47:22 +0800 Subject: [PATCH] (fix): remove nonspacing marks from slugs (#230) Linux and macOS use different Unicode normalization conventions in filenames --- org-roam.el | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/org-roam.el b/org-roam.el index 96628bf..e577b27 100644 --- a/org-roam.el +++ b/org-roam.el @@ -562,13 +562,18 @@ specified via the #+ROAM_ALIAS property." (defun org-roam--title-to-slug (title) "Convert TITLE to a filename-suitable slug." - (cl-flet ((replace (title pair) - (replace-regexp-in-string (car pair) (cdr pair) title))) + (cl-flet* ((nonspacing-mark-p (char) + (eq 'Mn (get-char-code-property char 'general-category))) + (strip-nonspacing-marks (s) + (apply #'string (seq-remove #'nonspacing-mark-p + (ucs-normalize-NFD-string s)))) + (replace (title pair) + (replace-regexp-in-string (car pair) (cdr pair) title))) (let* ((pairs `(("[^[:alnum:][:digit:]]" . "_") ;; convert anything not alphanumeric ("__*" . "_") ;; remove sequential underscores ("^_" . "") ;; remove starting underscore ("_$" . ""))) ;; remove ending underscore - (slug (-reduce-from #'replace title pairs))) + (slug (-reduce-from #'replace (strip-nonspacing-marks title) pairs))) (s-downcase slug)))) ;;;; Org-roam capture