[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/yaml f374a7f17e 013/124: indentation indicator bug fix
From: |
ELPA Syncer |
Subject: |
[elpa] externals/yaml f374a7f17e 013/124: indentation indicator bug fix |
Date: |
Fri, 29 Nov 2024 15:59:53 -0500 (EST) |
branch: externals/yaml
commit f374a7f17e1fa5ac45f8d85736093eb292f8b645
Author: Zachary Romero <zacromero@posteo.net>
Commit: Zachary Romero <zacromero@posteo.net>
indentation indicator bug fix
---
yaml.el | 58 +++++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 45 insertions(+), 13 deletions(-)
diff --git a/yaml.el b/yaml.el
index 24a8d7efe5..1779599b5b 100644
--- a/yaml.el
+++ b/yaml.el
@@ -184,6 +184,18 @@ This flag is intended for development purposes.")
"The state that the YAML parser is with regards to incoming events.")
(defvar yaml--root nil)
+(defun yaml--process-folded-text (text)
+ "Remvoe the header line for a folded match and return TEXT body properly
formatted with INDENTATION stripped."
+ (let* ((header-line (substring text 0 (string-match "\n" text)))
+ (text-body (substring text (1+ (string-match "\n" text)))))
+ text-body))
+
+(defun yaml--process-literal-text (text)
+ "Remvoe the header line for a folded match and return TEXT body properly
formatted with INDENTATION stripped."
+ (let* ((header-line (substring text 0 (string-match "\n" text)))
+ (text-body (substring text (1+ (string-match "\n" text)))))
+ text-body))
+
(defun yaml--resolve-scalar-tag (scalar)
(cond
;; tag:yaml.org,2002:null
@@ -355,7 +367,9 @@ This flag is intended for development purposes.")
(yaml--add-event (yaml--mapping-start-event t))))))
(defconst yaml--grammar-events-out
- '(("l-yaml-stream" . (lambda (text)
+ '(("c-b-block-header" . (lambda (text)
+ (message "TODO")))
+ ("l-yaml-stream" . (lambda (text)
(yaml--check-document-end)
(yaml--add-event (yaml--stream-end-event))))
("ns-yaml-version" . (lambda (text)
@@ -472,10 +486,11 @@ This flag is intended for development purposes.")
(replaced (substring replaced 1 (1- (length
replaced)))))
(yaml--add-event (yaml--scalar-event "double"
replaced)))))
("c-l+literal" . (lambda (text)
- ;; TODO
- (yaml--add-event (yaml--scalar-event "literal" text))))
+ (let* ((processed-text (yaml--process-literal-text text
indentation)))
+ (yaml--add-event (yaml--scalar-event "folded"
processed-text)))))
("c-l+folded" . (lambda (text)
- (yaml--add-event (yaml--scalar-event "folded" text))))
+ (let* ((processed-text (yaml--process-folded-text text
indentation)))
+ (yaml--add-event (yaml--scalar-event "folded"
processed-text)))))
("e-scalar" . (lambda (text)
(yaml--add-event (yaml--scalar-event "plain" ""))))
("c-ns-anchor-property" . (lambda (text)
@@ -540,11 +555,14 @@ This flag is intended for development purposes.")
(yaml--pop-state)
(if (not ,res-symbol)
nil
- (let ((res-type (cdr (assoc ,name yaml--grammar-resolution-rules))))
+ (let ((res-type (cdr (assoc ,name yaml--grammar-resolution-rules)))
+ (t-state (yaml-state-m (car yaml-states))))
(cond
((or (assoc ,name yaml--grammar-events-in)
(assoc ,name yaml--grammar-events-out))
- (list ,name (substring yaml--parsing-input beg
yaml--parsing-position) ,res-symbol))
+ (list ,name
+ (substring yaml--parsing-input beg yaml--parsing-position)
+ ,res-symbol))
((equal res-type 'list) (list ,name ,res-symbol))
((equal res-type 'literal) (substring yaml--parsing-input beg
yaml--parsing-position))
(t ,res-symbol))))))))
@@ -653,6 +671,22 @@ This flag is intended for development purposes.")
(setq states (cdr states)))))
res))
+(defun yaml--auto-detect (n)
+ "Detect the indentation given N."
+ (let* ((slice (yaml--slice yaml--parsing-position))
+ (match (string-match
+ "^.*\n\\(\\(?: *\n\\)*\\)\\( *\\)"
+ slice)))
+ (if (not match)
+ 1
+ (let ((pre (match-string 1 slice))
+ (m (- (length (match-string 2 slice)) n)))
+ (if (< m 1)
+ 1
+ (when (string-match (format "^.\\{%d\\}." m) pre)
+ (error "Spaces found after indent in auto-detect (5LLU)"))
+ m)))))
+
(defun yaml--auto-detect-indent (n)
"Detect the indentation given N."
(let* ((pos yaml--parsing-position)
@@ -815,7 +849,7 @@ value. It defaults to the symbol :false."
(error (format "parser finished before end of input %s/%s"
yaml--parsing-position
(length yaml--parsing-input))))
- (message "Parsed data: %s" res)
+ (message "Parsed data: %s" (pp-to-string res))
(yaml--walk-events res)
yaml--root)))
@@ -846,7 +880,7 @@ Rules for this function are defined by the yaml-spec JSON
file."
(yaml--any (when (yaml--parse-from-grammar 'ns-dec-digit)
(yaml--set m (yaml--ord (lambda () (yaml--match)))) t)
(when (yaml--empty)
- (yaml--set m (yaml--parse-from-grammar 'auto-detect))
t)))))
+ (yaml--set m (yaml--auto-detect m)) t)))))
((eq state 'ns-reserved-directive)
(let ()
@@ -941,11 +975,9 @@ Rules for this function are defined by the yaml-spec JSON
file."
((eq state 'c-l+literal)
(let ((n (nth 0 args)))
(yaml--frame "c-l+literal"
- (progn
- (message "c-l+literal: %s" (yaml--state-t))
- (yaml--all (yaml--chr ?\|)
- (yaml--parse-from-grammar 'c-b-block-header
(yaml--state-m) (yaml--state-t))
- (yaml--parse-from-grammar 'l-literal-content (+ n
(yaml--state-m)) (yaml--state-t)))))))
+ (yaml--all (yaml--chr ?\|)
+ (yaml--parse-from-grammar 'c-b-block-header (yaml--state-m)
(yaml--state-t))
+ (yaml--parse-from-grammar 'l-literal-content (+ n
(yaml--state-m)) (yaml--state-t))))))
((eq state 'c-single-quoted)
(let ((n (nth 0 args))
- [elpa] externals/yaml 7ef2e8ce5b 100/124: fix unit tests, (continued)
- [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, 2024/11/29
- [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 <=
- [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
- [elpa] externals/yaml 01ab8d1910 078/124: Merge pull request #30 from zkry/29-fix-list-encoding-indentation, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 9382bf5a3b 070/124: Merge pull request #25 from zkry/fix-lines-longer-than-80, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 34c300b085 075/124: Merge pull request #28 from tarsiiformes/nil, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 7f055d207c 057/124: Merge pull request #17 from conao3/plist-keyword, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml b0d95e7e81 066/124: Use `alist-get` to converting alist to hash table, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml c3988d10e2 098/124: store current indent level and use that for basis of block indent, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 94ea32ecb7 103/124: version bump, ELPA Syncer, 2024/11/29