[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master f265a6b 102/135: Fixed error reporting
From: |
Ian Dunn |
Subject: |
[elpa] master f265a6b 102/135: Fixed error reporting |
Date: |
Mon, 17 Feb 2020 10:53:01 -0500 (EST) |
branch: master
commit f265a6b2e8a6c004d5f796efeb00bc3823e97d95
Author: Ian Dunn <address@hidden>
Commit: Ian Dunn <address@hidden>
Fixed error reporting
* org-edna.el (org-edna--syntax-error): Take the error position as an
argument.
(org-edna--print-syntax-error): Update contents of error-plist.
(org-edna--convert-form): Add the position to the returned forms.
(org-edna--normalize-sexp-form): Pass that position to error functions.
---
org-edna.el | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/org-edna.el b/org-edna.el
index cfd6d16..947d8f6 100644
--- a/org-edna.el
+++ b/org-edna.el
@@ -70,20 +70,19 @@ properties used during actions or conditions."
;; 2. Edna sexp form; this is the intermediary form, and form used in
org-edna-form
;; 3. Lisp form; a form that can be evaluated by Emacs
-(defmacro org-edna--syntax-error (msg form error-form)
+(defmacro org-edna--syntax-error (msg form error-pos)
"Signal an Edna syntax error.
MSG will be reported to the user and should describe the error.
FORM is the form that generated the error.
-ERROR-FORM is the sub-form in FORM at which the error occurred."
- `(signal 'invalid-read-syntax (list :msg ,msg :form ,form :error-form
,error-form)))
+ERROR-POS is the positiong in MSG at which the error occurred."
+ `(signal 'invalid-read-syntax (list :msg ,msg :form ,form :error-pos
,error-pos)))
(defun org-edna--print-syntax-error (error-plist)
"Prints the syntax error from ERROR-PLIST."
(let* ((msg (plist-get error-plist :msg))
(form (plist-get error-plist :form))
- (error-form (plist-get error-plist :error-form))
- (pos (string-match-p (symbol-name (car error-form)) form)))
+ (pos (plist-get error-plist :error-pos)))
(message
"Org Edna Syntax Error: %s\n%s\n%s"
msg form (concat (make-string pos ?\ ) "^"))))
@@ -192,7 +191,7 @@ siblings todo!(TODO) => ((siblings) (todo! TODO))"
final-form)
(while (< pos (length string))
(pcase-let* ((`(,form ,new-pos) (org-edna-parse-string-form string pos)))
- (setq final-form (append final-form (list form)))
+ (setq final-form (append final-form (list (cons form pos))))
(setq pos new-pos)))
(cons final-form pos)))
@@ -212,7 +211,7 @@ the remainder of FORM after the current scope was parsed."
final-form
need-break)
(while (and remaining-form (not need-break))
- (let ((current-form (pop remaining-form)))
+ (pcase-let* ((`(,current-form . ,error-pos) (pop remaining-form)))
(pcase (car current-form)
('if
;; Check the car of each r*-form for the expected
@@ -228,7 +227,7 @@ the remainder of FORM after the current scope was parsed."
(unless (equal (car-safe r-form) '(then))
(org-edna--syntax-error
"Malformed if-construct; expected then terminator"
- from-string current-form))
+ from-string (cdr (car-safe r-form))))
(setq cond-form temp-form
remaining-form (cdr r-form)))
(pcase-let* ((`(,temp-form ,r-form)
@@ -238,7 +237,7 @@ the remainder of FORM after the current scope was parsed."
(unless (member (car-safe r-form) '((else) (endif)))
(org-edna--syntax-error
"Malformed if-construct; expected else or endif
terminator"
- from-string current-form))
+ from-string (cdr (car-safe r-form))))
(setq have-else (equal (car r-form) '(else))
then-form temp-form
remaining-form (cdr r-form)))
@@ -249,7 +248,7 @@ the remainder of FORM after the current scope was parsed."
from-string)))
(unless (equal (car-safe r-form) '(endif))
(org-edna--syntax-error "Malformed if-construct;
expected endif terminator"
- from-string current-form))
+ from-string (cdr (car-safe
r-form))))
(setq else-form temp-form
remaining-form (cdr r-form))))
(push `(if ,cond-form ,then-form ,else-form) final-form)))
@@ -263,7 +262,7 @@ the remainder of FORM after the current scope was parsed."
(pcase-let* ((`(,type . ,func) (org-edna--function-for-key (car
current-form))))
(unless (and type func)
(org-edna--syntax-error "Unrecognized Form"
- from-string current-form))
+ from-string error-pos))
(pcase type
('finder
(unless (memq state '(finder consideration))
@@ -272,17 +271,17 @@ the remainder of FORM after the current scope was parsed."
('action
(unless (eq action-or-condition 'action)
(org-edna--syntax-error "Actions aren't allowed in this
context"
- from-string current-form)))
+ from-string error-pos)))
('condition
(unless (eq action-or-condition 'condition)
(org-edna--syntax-error "Conditions aren't allowed in this
context"
- from-string current-form))))
+ from-string error-pos))))
;; Update state
(setq state type)
(if need-break ;; changing state
;; Keep current-form on remaining-form so we have it for the
;; next scope, since we didn't process it here.
- (setq remaining-form (cons current-form remaining-form))
+ (setq remaining-form (cons (cons current-form error-pos)
remaining-form))
(push current-form final-form)))))))
(when (and (eq state 'finder)
(eq action-or-condition 'condition))
- [elpa] master 03bafb0 061/135: Documented delete-property! action, (continued)
- [elpa] master 03bafb0 061/135: Documented delete-property! action, Ian Dunn, 2020/02/17
- [elpa] master 4c26cc8 041/135: Added copyright and licensing information to all files, Ian Dunn, 2020/02/17
- [elpa] master 390ee68 067/135: Fixed ancestors example, Ian Dunn, 2020/02/17
- [elpa] master 3b3625f 064/135: Cleaned up package header and added various docstrings, Ian Dunn, 2020/02/17
- [elpa] master a71c519 068/135: Added docstrings to some finders, Ian Dunn, 2020/02/17
- [elpa] master 3ff308b 055/135: Updated to new syntax, Ian Dunn, 2020/02/17
- [elpa] master 7618794 066/135: Added in-buffer settings and new sections to Documentation, Ian Dunn, 2020/02/17
- [elpa] master 9a6ba17 071/135: Fixed up documentation, Ian Dunn, 2020/02/17
- [elpa] master d493232 077/135: Added support for interactive editing of blockers and triggers, Ian Dunn, 2020/02/17
- [elpa] master 0aa0bf8 082/135: Don't present variables for keyword completion, Ian Dunn, 2020/02/17
- [elpa] master f265a6b 102/135: Fixed error reporting,
Ian Dunn <=
- [elpa] master 9a38d60 050/135: Fixed chain-find and planning actions, Ian Dunn, 2020/02/17
- [elpa] master 836feb4 062/135: Fixed actions and documentation, Ian Dunn, 2020/02/17
- [elpa] master 24a0228 059/135: Added tests for actions, Ian Dunn, 2020/02/17
- [elpa] master 0b0cb67 063/135: Use org source blocks instead of example blocks in documentation, Ian Dunn, 2020/02/17
- [elpa] master e6f88e7 069/135: Silenced byte-compiler, Ian Dunn, 2020/02/17
- [elpa] master ef302af 070/135: Added more docstrings, Ian Dunn, 2020/02/17
- [elpa] master 00abd93 073/135: Fixed tests copyright string, Ian Dunn, 2020/02/17
- [elpa] master c442e77 076/135: Only require subr-x during compilation, Ian Dunn, 2020/02/17
- [elpa] master 311e980 065/135: Compile targets before running tests, Ian Dunn, 2020/02/17
- [elpa] master 9d26430 072/135: Fixed copyright strings., Ian Dunn, 2020/02/17