branch: externals/denote commit c2049fa527db4b68a30d8229204c953c1fe4dcad Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
Fix how strings are sluggified in all scenaria Before a nil value for 'denote-allow-multi-word-keywords' would have the adverse effect of joining all the strings in the title field of the file name. The intent always was to do that only for multi-word keywords, not the title. --- denote.el | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/denote.el b/denote.el index 12abafb0ab..d07d7306c3 100644 --- a/denote.el +++ b/denote.el @@ -305,18 +305,26 @@ trailing hyphen." (defun denote--sluggify (str) "Make STR an appropriate slug for file names and related." + (downcase (denote--slug-hyphenate (denote--slug-no-punct str)))) + +(defun denote--sluggify-and-join (str) + "Sluggify STR while joining separate words." (downcase - (if denote-allow-multi-word-keywords - (denote--slug-hyphenate (denote--slug-no-punct str)) - (replace-regexp-in-string - "-" "" - (denote--slug-hyphenate (denote--slug-no-punct str)))))) + (replace-regexp-in-string + "-" "" + (denote--slug-hyphenate (denote--slug-no-punct str))))) (defun denote--sluggify-keywords (keywords) "Sluggify KEYWORDS." - (if (listp keywords) - (mapcar #'denote--sluggify keywords) - (denote--sluggify keywords))) + (cond + ((listp keywords) + (if denote-allow-multi-word-keywords + (mapcar #'denote--sluggify keywords) + (mapcar #'denote--sluggify-and-join keywords))) + (t + (if denote-allow-multi-word-keywords + (denote--sluggify keywords) + (denote--sluggify-and-join keywords))))) (defun denote--file-empty-p (file) "Return non-nil if FILE is empty."