Function: editorconfig-core-handle--fnmatch-p

editorconfig-core-handle--fnmatch-p is a byte-compiled function defined in editorconfig-core-handle.el.gz.

Signature

(editorconfig-core-handle--fnmatch-p NAME PATTERN)

Documentation

Return non-nil if NAME match PATTERN.

If pattern has slash, pattern should be relative to DIR.

This function is a fnmatch with a few modification for EditorConfig usage.

Source Code

;; Defined in /usr/src/emacs/lisp/editorconfig-core-handle.el.gz
(defun editorconfig-core-handle--fnmatch-p (name pattern)
  "Return non-nil if NAME match PATTERN.
If pattern has slash, pattern should be relative to DIR.

This function is a fnmatch with a few modification for EditorConfig usage."
  (if (string-match-p "/" pattern)
      (let ((pattern (replace-regexp-in-string "\\`/" "" pattern)))
        (editorconfig-fnmatch-p name pattern))
    ;; The match is not "anchored" so it can be either in the current dir or
    ;; in a subdir.  Contrary to Zsh patterns, editorconfig's `**/foo' does
    ;; not match `foo', so we need to split the problem into two matches.
    (or (editorconfig-fnmatch-p name pattern)
        (editorconfig-fnmatch-p name (concat "**/" pattern)))))