emacs-elpa-diffs
[Top][All Lists]
Advanced

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]