branch: externals/wisi
commit abbb0c283ba47be9095694406b6de46399d04701
Author: Stephen Leake <[email protected]>
Commit: Stephen Leake <[email protected]>
Release wisi 1.1.4, ada-mode 5.2.1
---
NEWS | 6 ++++++
README | 2 +-
wisi.el | 28 ++++++++++++++++------------
3 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/NEWS b/NEWS
index 4a9f690..06470ae 100644
--- a/NEWS
+++ b/NEWS
@@ -7,7 +7,13 @@ Please send wisi bug reports to [email protected], with
'wisi' in the subject. If possible, use M-x report-emacs-bug.
+* wisi 1.1.4
+31 Oct 2016
+
+** wisi-validate-cache takes optional error-on-fail arg.
+
* wisi 1.1.3
+26 Jul 2016
** improve use of quotes in doc strings.
diff --git a/README b/README
index 3c27c32..82ee858 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Emacs wisi package 1.1.3
+Emacs wisi package 1.1.4
The wisi package provides utilities for using generalized LALR parsers
to do indentation and navigation. See ada-mode for an example of its
diff --git a/wisi.el b/wisi.el
index 7b7f55e..5a3569a 100644
--- a/wisi.el
+++ b/wisi.el
@@ -7,9 +7,9 @@
;; Keywords: parser
;; indentation
;; navigation
-;; Version: 1.1.3
+;; Version: 1.1.4
;; package-requires: ((cl-lib "0.4") (emacs "24.2"))
-;; URL: http://stephe-leake.org/emacs/ada-mode/emacs-ada-mode.html
+;; URL: http://www.nongnu.org/ada-mode/wisi/wisi.html
;;
;; This file is part of GNU Emacs.
;;
@@ -680,7 +680,7 @@ If accessing cache at a marker for a token as set by
`wisi-cache-tokens', POS mu
(defvar wisi-post-parse-succeed-hook nil
"Hook run after parse succeeds.")
-(defun wisi-validate-cache (pos)
+(defun wisi-validate-cache (pos &optional error-on-fail)
"Ensure cached data is valid at least up to POS in current buffer."
(let ((msg (when (> wisi-debug 0) (format "wisi: parsing %s:%d ..."
(buffer-name) (line-number-at-pos pos)))))
;; If wisi-cache-max = pos, then there is no cache at pos; need parse
@@ -722,14 +722,18 @@ If accessing cache at a marker for a token as set by
`wisi-cache-tokens', POS mu
))
(if wisi-parse-error-msg
;; error
- (when (> wisi-debug 0)
+ (cond
+ ((> wisi-debug 0)
(message "%s error" msg)
(wisi-goto-error)
- (error wisi-parse-error-msg))
+ (error wisi-parse-error-msg)))
;; no msg; success
(when (> wisi-debug 0)
(message "%s done" msg)))
- )))
+ )
+ (when (and error-on-fail (not (>= wisi-cache-max pos)))
+ (error "parse failed"))
+ ))
(defun wisi-fontify-region (_begin end)
"For `jit-lock-functions'."
@@ -1265,7 +1269,7 @@ If LIMIT (a buffer position) is reached, throw an error."
"If not at a cached token, move forward to next
cache. Otherwise move to cache-next, or next cache if nil.
Return cache found."
- (wisi-validate-cache (point-max)) ;; ensure there is a next cache to move to
+ (wisi-validate-cache (point-max) t) ;; ensure there is a next cache to move
to
(let ((cache (wisi-get-cache (point))))
(if cache
(let ((next (wisi-cache-next cache)))
@@ -1281,7 +1285,7 @@ Return cache found."
(defun wisi-backward-statement-keyword ()
"If not at a cached token, move backward to prev
cache. Otherwise move to cache-prev, or prev cache if nil."
- (wisi-validate-cache (point))
+ (wisi-validate-cache (point) t)
(let ((cache (wisi-get-cache (point))))
(if cache
(let ((prev (wisi-cache-prev cache)))
@@ -1331,7 +1335,7 @@ Return start cache."
"Move point to token at start of statement point is in or after.
Return start cache."
(interactive)
- (wisi-validate-cache (point))
+ (wisi-validate-cache (point) t)
(let ((cache (wisi-get-cache (point))))
(unless cache
(setq cache (wisi-backward-cache)))
@@ -1340,7 +1344,7 @@ Return start cache."
(defun wisi-goto-statement-end ()
"Move point to token at end of statement point is in or before."
(interactive)
- (wisi-validate-cache (point))
+ (wisi-validate-cache (point) t)
(let ((cache (or (wisi-get-cache (point))
(wisi-forward-cache))))
(when (wisi-cache-end cache)
@@ -1409,7 +1413,7 @@ of CACHE with class statement-start or block-start."
(defun wisi-indent-statement ()
"Indent region given by `wisi-goto-start' on cache at or before point, then
wisi-cache-end."
- (wisi-validate-cache (point))
+ (wisi-validate-cache (point) t)
(save-excursion
(let ((cache (or (wisi-get-cache (point))
@@ -1493,7 +1497,7 @@ correct. Must leave point at indentation of current
line.")
(interactive)
(syntax-propertize (point-max))
(wisi-invalidate-cache)
- (wisi-validate-cache (point-max)))
+ (wisi-validate-cache (point-max)) t)
(defun wisi-lex-buffer ()
(interactive)