[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/yaml 73fde9d8fb 110/124: Merge pull request #44 from ki
From: |
ELPA Syncer |
Subject: |
[elpa] externals/yaml 73fde9d8fb 110/124: Merge pull request #44 from kisaragi-hiu/eldoc-hints |
Date: |
Fri, 29 Nov 2024 16:00:09 -0500 (EST) |
branch: externals/yaml
commit 73fde9d8fbbaf2596449285df9eb412ae9dd74d9
Merge: 3381a5d2f7 af49540f53
Author: Zachary Romero <zacromero@posteo.net>
Commit: GitHub <noreply@github.com>
Merge pull request #44 from kisaragi-hiu/eldoc-hints
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 4a2d73e328..6262ca2406 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 e32ef2f5e5 092/124: add note to yaml-parse-string-with-pos function, (continued)
- [elpa] externals/yaml e32ef2f5e5 092/124: add note to yaml-parse-string-with-pos function, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml c56d47254d 091/124: add unit test, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 69c699a15a 071/124: Minor code formatting fixes, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 1f15c0b33a 062/124: Merge pull request #20 from j-shilling/fix-encoding-symbols, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml adb3e52a21 081/124: Merge pull request #32 from zkry/fix-encoding-deeply-nested-lists, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 2500074ebf 097/124: Merge pull request #39 from zkry/fix-obob-for-storing-position, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml f9fbe392e3 065/124: Merge pull request #22 from zkry/fix-escape-char-literals, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml fdc65922c9 099/124: fix zero-column indent problems; add more unit tests, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml c81f87f0fd 080/124: fix unit test, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 7783d802b0 102/124: Don't remove all properties, just yaml-n, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 73fde9d8fb 110/124: Merge pull request #44 from kisaragi-hiu/eldoc-hints,
ELPA Syncer <=
- [elpa] externals/yaml e787dd06c6 106/124: Merge pull request #42 from kisaragi-hiu/bring-docstring-up-to-date, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 5af0cd7c55 122/124: Fix octal/hex parsing (#54), ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 4a3243a2be 108/124: yaml--the-end: fix incorrect regexp, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 3381a5d2f7 109/124: Merge pull request #43 from kisaragi-hiu/fix/regexp-missing-escape, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 70c4fcead9 124/124: bump version, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 37a6b80ee3 121/124: Update declared version to match tag, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 604774d385 117/124: Add documentation on running tests, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 7c4b2ec9a5 116/124: Merge pull request #49 from zkry/48-encode-remove-leading-newlines, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 708dd886a2 001/124: Initial commit, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 8771e68930 004/124: Got key-value working, ELPA Syncer, 2024/11/29