[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/yaml af49540f53 107/124: Use cl-defun &key to allow eld
From: |
ELPA Syncer |
Subject: |
[elpa] externals/yaml af49540f53 107/124: Use cl-defun &key to allow eldoc argument hints to work better |
Date: |
Fri, 29 Nov 2024 16:00:09 -0500 (EST) |
branch: externals/yaml
commit af49540f53fd2af61f90d73545504532f69b5c0b
Author: Kisaragi Hiu <mail@kisaragi-hiu.com>
Commit: Kisaragi Hiu <mail@kisaragi-hiu.com>
Use cl-defun &key to allow eldoc argument hints to work better
---
yaml.el | 105 +++++++++++++++++++++++++++++++++++-----------------------------
1 file changed, 57 insertions(+), 48 deletions(-)
diff --git a/yaml.el b/yaml.el
index 0c17aca32c..6708effbd8 100644
--- a/yaml.el
+++ b/yaml.el
@@ -1028,7 +1028,13 @@ then check EXPR at the current position."
(not ,ok-symbol)
,ok-symbol))))
-(defun yaml--initialize-parsing-state (args)
+(cl-defun yaml--initialize-parsing-state
+ (&key (null-object :null)
+ (false-object :false)
+ object-type
+ object-key-type
+ sequence-type
+ string-values)
"Initialize state required for parsing according to plist ARGS."
(setq yaml--cache nil)
(setq yaml--object-stack nil)
@@ -1036,51 +1042,48 @@ then check EXPR at the current position."
(setq yaml--root nil)
(setq yaml--anchor-mappings (make-hash-table :test 'equal))
(setq yaml--resolve-aliases nil)
- (setq yaml--parsing-null-object
- (if (plist-member args :null-object)
- (plist-get args :null-object)
- :null))
- (setq yaml--parsing-false-object
- (if (plist-member args :false-object)
- (plist-get args :false-object)
- :false))
- (let ((object-type (plist-get args :object-type))
- (object-key-type (plist-get args :object-key-type))
- (sequence-type (plist-get args :sequence-type))
- (string-values (plist-get args :string-values)))
- (cond
- ((or (not object-type)
- (equal object-type 'hash-table))
- (setq yaml--parsing-object-type 'hash-table))
- ((equal 'alist object-type)
- (setq yaml--parsing-object-type 'alist))
- ((equal 'plist object-type)
- (setq yaml--parsing-object-type 'plist))
- (t (error "Invalid object-type. Must be hash-table, alist, or plist")))
- (cond
- ((or (not object-key-type)
- (equal 'symbol object-key-type))
- (if (equal 'plist yaml--parsing-object-type)
- (setq yaml--parsing-object-key-type 'keyword)
- (setq yaml--parsing-object-key-type 'symbol)))
- ((equal 'string object-key-type)
- (setq yaml--parsing-object-key-type 'string))
- ((equal 'keyword object-key-type)
- (setq yaml--parsing-object-key-type 'keyword))
- (t (error "Invalid object-key-type. Must be string, keyword, or
symbol")))
- (cond
- ((or (not sequence-type)
- (equal sequence-type 'array))
- (setq yaml--parsing-sequence-type 'array))
- ((equal 'list sequence-type)
- (setq yaml--parsing-sequence-type 'list))
- (t (error "Invalid sequence-type. sequence-type must be list or array")))
- (if string-values
- (setq yaml--string-values t)
- (setq yaml--string-values nil))))
-
-(defun yaml-parse-string (string &rest args)
- "Parse the YAML value in STRING. Keyword ARGS are as follows:
+ (setq yaml--parsing-null-object null-object)
+ (setq yaml--parsing-false-object false-object)
+ (cond
+ ((or (not object-type)
+ (equal object-type 'hash-table))
+ (setq yaml--parsing-object-type 'hash-table))
+ ((equal 'alist object-type)
+ (setq yaml--parsing-object-type 'alist))
+ ((equal 'plist object-type)
+ (setq yaml--parsing-object-type 'plist))
+ (t (error "Invalid object-type. Must be hash-table, alist, or plist")))
+ (cond
+ ((or (not object-key-type)
+ (equal 'symbol object-key-type))
+ (if (equal 'plist yaml--parsing-object-type)
+ (setq yaml--parsing-object-key-type 'keyword)
+ (setq yaml--parsing-object-key-type 'symbol)))
+ ((equal 'string object-key-type)
+ (setq yaml--parsing-object-key-type 'string))
+ ((equal 'keyword object-key-type)
+ (setq yaml--parsing-object-key-type 'keyword))
+ (t (error "Invalid object-key-type. Must be string, keyword, or symbol")))
+ (cond
+ ((or (not sequence-type)
+ (equal sequence-type 'array))
+ (setq yaml--parsing-sequence-type 'array))
+ ((equal 'list sequence-type)
+ (setq yaml--parsing-sequence-type 'list))
+ (t (error "Invalid sequence-type. sequence-type must be list or array")))
+ (if string-values
+ (setq yaml--string-values t)
+ (setq yaml--string-values nil)))
+
+(cl-defun yaml-parse-string (string
+ &key
+ (null-object :null)
+ (false-object :false)
+ object-type
+ object-key-type
+ sequence-type
+ string-values)
+ "Parse the YAML value in STRING.
OBJECT-TYPE specifies the Lisp object to use for representing
key-value YAML mappings. Possible values for OBJECT-TYPE are
@@ -1101,7 +1104,13 @@ It defaults to the symbol `:null'.
FALSE-OBJECT contains the object used to represent the false
value. It defaults to the symbol `:false'."
- (yaml--initialize-parsing-state args)
+ (yaml--initialize-parsing-state
+ :null-object null-object
+ :false-object false-object
+ :object-type object-type
+ :object-key-type object-key-type
+ :sequence-type sequence-type
+ :string-values string-values)
(let ((res (yaml--parse string
(yaml--top))))
(when (< yaml--parsing-position (length yaml--parsing-input))
@@ -1121,7 +1130,7 @@ value. It defaults to the symbol `:false'."
(defun yaml-parse-tree (string)
"Parse the YAML value in STRING and return its parse tree."
- (yaml--initialize-parsing-state nil)
+ (yaml--initialize-parsing-state)
(let* ((yaml--parsing-store-position t)
(res (yaml--parse string
(yaml--top))))
- [elpa] externals/yaml 84b88c9ed1 073/124: Merge pull request #27 from zkry/fix-empty-single-quote-string, (continued)
- [elpa] externals/yaml 84b88c9ed1 073/124: Merge pull request #27 from zkry/fix-empty-single-quote-string, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml b6091cc080 077/124: add unit test case, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml cb1cc42bd1 093/124: Merge pull request #36 from zkry/fix-string-values-state-bug, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 39f8412bec 079/124: Fix encoding deeply nested lists, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 25f35c80e4 035/124: Replace string-trim-right with replace-regexp-in-string, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 1304802f9f 069/124: Reduce the max line length to be under 80 characters., ELPA Syncer, 2024/11/29
- [elpa] externals/yaml f8803066ae 085/124: Merge pull request #33 from zkry/add-position-information-to-parse-tree, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 7ef2e8ce5b 100/124: fix unit tests, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 368452c534 064/124: Add test case for issue, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml d82bfb523e 059/124: fix testcases, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml af49540f53 107/124: Use cl-defun &key to allow eldoc argument hints to work better,
ELPA Syncer <=
- [elpa] externals/yaml 01a12f2345 118/124: Merge pull request #50 from rdrg109/master, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml fe08b8f530 120/124: Merge pull request #52 from zkry/51-fix-failing-test, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml a19fbf948a 112/124: Merge pull request #46 from zkry/45-fix-char-escape, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 7f09102db0 115/124: Remove leading new-lines for yaml-encode, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 276596561a 032/124: Fix explicit document end on ns-plain, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml c215bf7a33 083/124: add function for generating parse with metadata strings, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml f374a7f17e 013/124: indentation indicator bug fix, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml d8ac09e8ca 053/124: Merge pull request #11 from zkry/fix-encoding-nil-false-arrays, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml bdfaa8ce55 101/124: Merge pull request #40 from zkry/fix-block-indent-detection, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 69654c291f 090/124: Fix string values state bug, ELPA Syncer, 2024/11/29