[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] scratch/editorconfig-cc 9cee9bb143 225/351: Get alist result fr
From: |
Stefan Monnier |
Subject: |
[nongnu] scratch/editorconfig-cc 9cee9bb143 225/351: Get alist result from hash result |
Date: |
Thu, 13 Jun 2024 18:38:56 -0400 (EDT) |
branch: scratch/editorconfig-cc
commit 9cee9bb1431fa72be67484a8c405b4670d42c244
Author: 10sr <8.slashes@gmail.com>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
Get alist result from hash result
---
editorconfig-core.el | 78 +++++-----------------------------------------------
1 file changed, 7 insertions(+), 71 deletions(-)
diff --git a/editorconfig-core.el b/editorconfig-core.el
index a49841aca3..3988cfe94a 100644
--- a/editorconfig-core.el
+++ b/editorconfig-core.el
@@ -74,28 +74,6 @@
"0.7.14"
"EditorConfig core version.")
-(defun editorconfig-core--remove-duplicate (alist)
- "Remove duplicated keys in ALIST.
-
-If same keys are found in ALIST multiple times, the latter ones take
precedence.
-For example, when ALIST is
-
- '((a 1) (b 2) (c 3) (b 4))
-
-then the result will be
-
- '((a 1) (b 4) (c 3)) ."
- (let ((result ()))
- (dolist (e alist)
- (let ((pair (assoc (car e)
- result)))
- (if pair
- (setcdr pair
- (cdr e))
- (setq result
- `(,@result ,e)))))
- result))
-
(defun editorconfig-core--get-handles (dir confname &optional result)
"Get list of EditorConfig handlers for DIR from CONFNAME.
@@ -135,55 +113,13 @@ If need to specify config format version, give
CONFVERSION.
This functions returns alist of properties. Each element will look like
'(KEY . VALUE) ."
- (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 (editorconfig-core--remove-duplicate
- (apply 'append
- (mapcar (lambda (handle)
- (apply 'append
-
(editorconfig-core-handle-get-properties handle
-
file)))
- (editorconfig-core--get-handles
(file-name-directory file)
- confname))))))
- (dolist (key '("end_of_line" "indent_style" "indent_size"
- "insert_final_newline" "trim_trailing_whitespace"
"charset"))
- (let ((pair (assoc key
- result)))
- (when pair
- (setcdr pair
- (downcase (cdr pair))))))
-
- ;; Add indent_size property
- (let ((p-indent-size (assoc "indent_size" result))
- (p-indent-style (assoc "indent_style" result)))
- (when (and (not p-indent-size)
- (string= (cdr p-indent-style) "tab")
- ;; If VERSION < 0.9.0, indent_size should have no default
value
- (version<= "0.9.0"
- confversion))
- (setq result
- `(,@result ("indent_size" . "tab")))))
- ;; Add tab_width property
- (let ((p-indent-size (assoc "indent_size" result))
- (p-tab-width (assoc "tab_width" result)))
- (when (and p-indent-size
- (not p-tab-width)
- (not (string= (cdr p-indent-size) "tab")))
- (setq result
- `(,@result ("tab_width" . ,(cdr p-indent-size))))))
- ;; Update indent-size property
- (let ((p-indent-size (assoc "indent_size" result))
- (p-tab-width (assoc "tab_width" result)))
- (when (and p-indent-size
- p-tab-width
- (string= (cdr p-indent-size) "tab"))
- (setcdr p-indent-size (cdr p-tab-width))))
-
+ (let ((hash (editorconfig-core-get-properties-hash file confname
confversion))
+ (result nil))
+ (maphash (lambda (key value)
+ (add-to-list 'result
+ (cons (symbol-name key)
+ value)))
+ hash)
result))
(defun editorconfig-core--hash-merge (into update)
- [nongnu] scratch/editorconfig-cc 0072bcc14f 207/351: Update texi for hook name change, (continued)
- [nongnu] scratch/editorconfig-cc 0072bcc14f 207/351: Update texi for hook name change, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc a365955dca 202/351: Use file_type_ext for test fixtures, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 60b39fadfb 209/351: Add variable -hack-properties-functions, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc f1b83aacd2 214/351: Fix hack-properties-functions example, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 10467ed9df 221/351: Use Markdown's code spans instead of Emacs style `' (#186), Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 658bfb9bd8 213/351: Fix README and texi, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc e24803269d 212/351: Update document, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 6929cad23b 223/351: Update get-properties-hash, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc cdbd60a8a6 234/351: M-x checkdoc, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 0bbf63616a 231/351: Stop using cl-defclass, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 9cee9bb143 225/351: Get alist result from hash result,
Stefan Monnier <=
- [nongnu] scratch/editorconfig-cc 516ebfefa3 232/351: Remove useless spaces, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 50ed9cf1a7 235/351: Update year, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc ae8028cf3d 233/351: Add struct docstring, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc d5473b369e 236/351: Remove comment, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 023a221d87 239/351: Add fixes for package-lint, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 8271234c27 241/351: Use -*- lexical-binding: t -*-, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 876e476ded 238/351: Update README, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc c6d823b8a7 242/351: Separate tool functions, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 882e7f5fa0 249/351: Use API to get version info (#193), Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc ace446e357 261/351: Bump version to v0.8.1, Stefan Monnier, 2024/06/13