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 CONFVERSION)

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. If need to specify config format version, give CONFVERSION.

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 confversion)
  "Get EditorConfig properties for FILE.
If FILE is not given, use currently visiting file.
Give CONFNAME for basename of config file other than .editorconfig.
If need to specify config format version, give CONFVERSION.

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"))
  (setq confversion (or confversion "0.12.0"))
  (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)))

    ;; Add indent_size property
    ;; FIXME: Why?  Which part of the spec requires that?
    ;;(let ((v-indent-size (gethash 'indent_size result))
    ;;      (v-indent-style (gethash 'indent_style result)))
    ;;  (when (and (not v-indent-size)
    ;;             (string= v-indent-style "tab")
    ;;             ;; If VERSION < 0.9.0, indent_size should have no default value
    ;;             (version<= "0.9.0"
    ;;                        confversion))
    ;;    (puthash 'indent_size
    ;;             "tab"
    ;;             result)))
    ;; Add tab_width property
    ;; FIXME: Why?  Which part of the spec requires that?
    ;;(let ((v-indent-size (gethash 'indent_size result))
    ;;      (v-tab-width (gethash 'tab_width result)))
    ;;  (when (and v-indent-size
    ;;             (not v-tab-width)
    ;;             (not (string= v-indent-size "tab")))
    ;;    (puthash 'tab_width v-indent-size result)))
    ;; Update indent-size property
    ;; FIXME: Why?  Which part of the spec requires that?
    ;;(let ((v-indent-size (gethash 'indent_size result))
    ;;      (v-tab-width (gethash 'tab_width result)))
    ;;  (when (and v-indent-size
    ;;             v-tab-width
    ;;             (string= v-indent-size "tab"))
    ;;    (puthash 'indent_size v-tab-width result)))

    result))