Skip to content

Commit

Permalink
Add function to get properties from handlers as hash
Browse files Browse the repository at this point in the history
  • Loading branch information
10sr committed Jan 7, 2019
1 parent 09687a3 commit 7160112
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions editorconfig-core-handle.el
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
;; e.g. (("root" . "true"))
(top-prop nil)

;; TODO: Define struct for section
;; Alist of properties
;; Key: Section name
;; Value: Alist of properties for each section name
Expand Down Expand Up @@ -105,6 +106,25 @@ If HANDLE is nil return nil."
(car prop)
(file-name-directory (editorconfig-core-handle-path handle))))
(editorconfig-core-handle-prop handle)))))
(make-obsolete 'editorconfig-core-handle-get-properties
'editorconfig-core-handle-get-properties-hash
"0.7.15")


(defun editorconfig-core-handle-get-properties-hash (handle file)
"Return hash of properties from HANDLE for FILE.
If HANDLE is nil return nil."
(when handle
(let ((hash (make-hash-table)))
(dolist (prop (editorconfig-core-handle-prop handle))
(when (editorconfig-core-handle--fnmatch-p file
(car prop)
(file-name-directory (editorconfig-core-handle-path
handle)))
(cl-loop for (key . value) in (cdr prop)
(puthash (intern key) value hash))))
hash)))

(defun editorconfig-core-handle--fnmatch-p (name pattern dir)
"Return non-nil if NAME match PATTERN.
Expand Down

0 comments on commit 7160112

Please sign in to comment.