Function: denote-sluggify-and-apply-rules

denote-sluggify-and-apply-rules is a byte-compiled function defined in denote.el.

Signature

(denote-sluggify-and-apply-rules COMPONENT STR)

Documentation

Make STR an appropriate slug for file name COMPONENT.

Apply the function specified in denote-file-name-slug-function to COMPONENT which is one of identifier, title, signature, keyword. If the resulting string still contains consecutive -, _, =, or @, they are replaced by a single occurence of the character, if necessary according to COMPONENT. If COMPONENT is keyword, remove underscores from STR as they are used as the keywords separator in file names.

Also enforce the rules of the file-naming scheme.

Aliases

denote-sluggify

Source Code

;; Defined in ~/.emacs.d/elpa/denote-4.2.3/denote.el
(defun denote-sluggify-and-apply-rules (component str)
  "Make STR an appropriate slug for file name COMPONENT.

Apply the function specified in `denote-file-name-slug-function' to
COMPONENT which is one of `identifier', `title', `signature', `keyword'.
If the resulting string still contains consecutive -, _, =, or @, they
are replaced by a single occurence of the character, if necessary
according to COMPONENT.  If COMPONENT is `keyword', remove underscores
from STR as they are used as the keywords separator in file names.

Also enforce the rules of the file-naming scheme."
  (let* ((slug-function (alist-get component denote-file-name-slug-functions))
         (str-slug (pcase component
                     ('title (funcall (or slug-function #'denote-sluggify-title) str))
                     ('keyword (replace-regexp-in-string
                                "_" ""
                                (funcall (or slug-function #'denote-sluggify-keyword) str)))
                     ('identifier (denote--valid-identifier (funcall (or slug-function #'identity) str)))
                     ('signature (funcall (or slug-function #'denote-sluggify-signature) str)))))
    (thread-first
      (denote--remove-dot-characters str-slug)
      (denote--replace-consecutive-token-characters component)
      (denote--trim-right-token-characters component))))