Function: editorconfig-core-get-properties-hash

editorconfig-core-get-properties-hash is a byte-compiled function defined in editorconfig-core.el.gz.

Signature

(editorconfig-core-get-properties-hash &optional FILE CONFNAME)

Documentation

Get EditorConfig properties for FILE.

If FILE is not given, use currently visiting file. Give CONFNAME for basename of config file other than .editorconfig.

This function is almost same as editorconfig-core-get-properties, but returns hash object instead.

Source Code

;; Defined in /usr/src/emacs/lisp/editorconfig-core.el.gz
(defun editorconfig-core-get-properties-hash (&optional file confname)
  "Get EditorConfig properties for FILE.
If FILE is not given, use currently visiting file.
Give CONFNAME for basename of config file other than .editorconfig.

This function is almost same as `editorconfig-core-get-properties', but returns
hash object instead."
  (setq file
        (expand-file-name (or file
                              buffer-file-name
                              (error "FILE is not given and `buffer-file-name' is nil"))))
  (setq confname (or confname ".editorconfig"))
  (let ((result (make-hash-table)))
    (dolist (handle (editorconfig-core--get-handles (file-name-directory file)
                                                    confname))
      (editorconfig-core--hash-merge result
                                     (editorconfig-core-handle-get-properties-hash handle
                                                                                   file)))

    ;; Downcase known boolean values
    ;; FIXME: Why not do that in `editorconfig-core-handle--parse-file'?
    (dolist (key '( end_of_line indent_style indent_size insert_final_newline
                    trim_trailing_whitespace charset))
      (when-let* ((val (gethash key result)))
        (puthash key (downcase val) result)))

    result))