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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/wisi 364da46 20/35: Update ada-mode to version 5.2.2, w


From: Stefan Monnier
Subject: [elpa] externals/wisi 364da46 20/35: Update ada-mode to version 5.2.2, wisi to version 1.1.5
Date: Sat, 28 Nov 2020 14:47:53 -0500 (EST)

branch: externals/wisi
commit 364da46bb8d2173436e1229f9632bd70cd7f9658
Author: Stephen Leake <stephen_leake@stephe-leake.org>
Commit: Stephen Leake <stephen_leake@stephe-leake.org>

    Update ada-mode to version 5.2.2, wisi to version 1.1.5
---
 NEWS            |  15 ++++++
 README          |  13 ++----
 wisi-compile.el |  13 ++----
 wisi-parse.el   |   2 -
 wisi.el         | 142 +++++++++++++++++++++++++++++++++++++-------------------
 5 files changed, 115 insertions(+), 70 deletions(-)

diff --git a/NEWS b/NEWS
index 06470ae..bd9be26 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,21 @@ Please send wisi bug reports to bug-gnu-emacs@gnu.org, with
 'wisi' in the subject. If possible, use M-x report-emacs-bug.
 
 
+* wisi 1.1.5
+9 Jul 2017
+
+** wisi-indent-fallback allows setting the indent engine to use when
+   the wisi engine fails.
+
+** wisi-comment-indent now uses comment-column for comments following
+   code on the same line.
+
+** wisi-forward-statement-keyword tolerates end of buffer, and uses
+   either cache-next or cache-end.
+
+** forward-sexp-function is set to wisi-forward-sexp, which handles
+   parens, strings, and statements.
+
 * wisi 1.1.4
 31 Oct 2016
 
diff --git a/README b/README
index 82ee858..8e6fa68 100644
--- a/README
+++ b/README
@@ -1,14 +1,7 @@
-Emacs wisi package 1.1.4
+Emacs wisi package 1.1.5
 
 The wisi package provides utilities for using generalized LALR parsers
-to do indentation and navigation. See ada-mode for an example of its
-use.
+to do indentation, fontification, and navigation. See ada-mode for an
+example of its use.
 
-It is provided as a Gnu ELPA package; to install the package, add to
-~./emacs:
 
-(package-initialize)
-
-then invoke M-x list-packages, install wisi.
-
-(end of file)
diff --git a/wisi-compile.el b/wisi-compile.el
index 5c788e7..420621a 100644
--- a/wisi-compile.el
+++ b/wisi-compile.el
@@ -1,6 +1,6 @@
 ;; wisi-compile.el --- Grammar compiler for the wisi parser, integrating Wisi 
OpenToken output.  -*- lexical-binding:t -*-
 ;;
-;; Copyright (C) 2012, 2013, 2015, 2016 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2013, 2015-2017 Free Software Foundation, Inc.
 ;;
 ;; Author: Stephen Leake <stephen_leake@member.fsf.org>
 ;;
@@ -128,7 +128,8 @@ It returns nil; it is called for the semantic side-effects 
only."
     (fset action-symbol
          `(lambda ($nterm wisi-tokens)
             ,form
-            nil))))
+            nil))
+    (byte-compile action-symbol)))
 
 (defun wisi-compile-grammar (grammar)
   "Compile the LALR(1) GRAMMAR; return the automaton for wisi-parse.
@@ -190,16 +191,10 @@ names have the format nonterm:index."
   ;;
   ;; FIXME: eliminate use of semantic-lex-* in *-wy.el. Similarly
   ;; requires decoupling from OpenToken
-  ;;
-  ;; FIXME: can eliminate obarray? We don't need the obarray to
-  ;; avoid garbage collection of the symbols; they are all referenced in the 
compiled grammar.
-  ;; But each semantic action function has to be defined (and byte-compiled?) 
somewhere?
-  ;;     currently actions are _not_ byte-compiled; wisi-compile-grammar is 
run at load time
-  ;;     need 'eval-when-compile' to byte-compile them?
-  ;;     can't byte-compile obarray?
 
   (let ((defs (nth 1 grammar))
        (symbol-obarray (make-vector 13 0));; for parse actions
+        (byte-compile-warnings '(not free-vars)) ;; for "wisi-test-success" in 
test/wisi/*
        def nonterm rhs-list rule
        semantic-action index)
 
diff --git a/wisi-parse.el b/wisi-parse.el
old mode 100644
new mode 100755
index a16a81d..0076fe5
--- a/wisi-parse.el
+++ b/wisi-parse.el
@@ -112,8 +112,6 @@ point at which that max was spawned.")
   symbol, `text' is the token string, `start . end' is the range
   in the buffer."
 
-  ;; FIXME: (aref automaton 3) is the obarray storing the semantic actions;
-  ;; not used here (see related FIXME in wisi-compile)
   (let* ((actions (aref automaton 0))
         (gotos   (aref automaton 1))
         (parser-states ;; vector of parallel parser states
diff --git a/wisi.el b/wisi.el
old mode 100644
new mode 100755
index 5a3569a..139ff98
--- a/wisi.el
+++ b/wisi.el
@@ -1,13 +1,13 @@
 ;;; wisi.el --- Utilities for implementing an indentation/navigation engine 
using a generalized LALR parser -*- lexical-binding:t -*-
 ;;
-;; Copyright (C) 2012 - 2016  Free Software Foundation, Inc.
+;; Copyright (C) 2012 - 2017  Free Software Foundation, Inc.
 ;;
 ;; Author: Stephen Leake <stephen_leake@member.fsf.org>
 ;; Maintainer: Stephen Leake <stephen_leake@member.fsf.org>
 ;; Keywords: parser
 ;;  indentation
 ;;  navigation
-;; Version: 1.1.4
+;; Version: 1.1.5
 ;; package-requires: ((cl-lib "0.4") (emacs "24.2"))
 ;; URL: http://www.nongnu.org/ada-mode/wisi/wisi.html
 ;;
@@ -742,9 +742,10 @@ If accessing cache at a marker for a token as set by 
`wisi-cache-tokens', POS mu
 
 (defun wisi-get-containing-cache (cache)
   "Return cache from (wisi-cache-containing CACHE)."
-  (let ((containing (wisi-cache-containing cache)))
-    (and containing
-        (wisi-get-cache (1- containing)))))
+  (when cache
+    (let ((containing (wisi-cache-containing cache)))
+      (and containing
+          (wisi-get-cache (1- containing))))))
 
 (defun wisi-cache-region (cache)
   "Return region designated by cache.
@@ -1267,20 +1268,23 @@ If LIMIT (a buffer position) is reached, throw an 
error."
 
 (defun wisi-forward-statement-keyword ()
   "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) t) ;; ensure there is a next cache to move 
to
-  (let ((cache (wisi-get-cache (point))))
-    (if cache
-       (let ((next (wisi-cache-next cache)))
-         (if next
-             (goto-char (1- next))
-           (wisi-forward-token)
-           (wisi-forward-cache)))
-      (wisi-forward-cache))
-    )
-  (wisi-get-cache (point))
-  )
+cache. Otherwise move to cache-next, or cache-end, or next cache
+if both nil.  Return cache found."
+  (unless (eobp)
+    (wisi-validate-cache (point-max) t) ;; ensure there is a next cache to 
move to
+    (let ((cache (wisi-get-cache (point))))
+      (if (and cache
+              (not (eq (wisi-cache-class cache) 'statement-end)))
+         (let ((next (or (wisi-cache-next cache)
+                         (wisi-cache-end cache))))
+           (if next
+               (goto-char (1- next))
+             (wisi-forward-token)
+             (wisi-forward-cache)))
+       (wisi-forward-cache))
+      )
+    (wisi-get-cache (point))
+    ))
 
 (defun wisi-backward-statement-keyword ()
   "If not at a cached token, move backward to prev
@@ -1295,6 +1299,34 @@ cache. Otherwise move to cache-prev, or prev cache if 
nil."
       (wisi-backward-cache))
   ))
 
+(defun wisi-forward-sexp (&optional arg)
+  "For `forward-sexp-function'."
+  (interactive "^p")
+  (or arg (setq arg 1))
+  (cond
+   ((and (> arg 0) (= 4 (syntax-class (syntax-after (point)))))  ;; on open 
paren
+    (let ((forward-sexp-function nil))
+      (forward-sexp arg)))
+
+   ((and (< arg 0) (= 5 (syntax-class (syntax-after (1- (point)))))) ;; after 
close paren
+    (let ((forward-sexp-function nil))
+      (forward-sexp arg)))
+
+   ((and (> arg 0) (= 7 (syntax-class (syntax-after (point)))))  ;; on (open) 
string quote
+    (let ((forward-sexp-function nil))
+      (forward-sexp arg)))
+
+   ((and (< arg 0) (= 7 (syntax-class (syntax-after (1- (point)))))) ;; after 
(close) string quote
+    (let ((forward-sexp-function nil))
+      (forward-sexp arg)))
+
+   (t
+    (dotimes (_i (abs arg))
+      (if (> arg 0)
+         (wisi-forward-statement-keyword)
+       (wisi-backward-statement-keyword))))
+   ))
+
 (defun wisi-goto-containing (cache &optional error)
   "Move point to containing token for CACHE, return cache at that point.
 If ERROR, throw error when CACHE has no container; else return nil."
@@ -1360,7 +1392,7 @@ Return start cache."
   (wisi-get-cache (point)))
 
 (defun wisi-prev-statement-cache (cache)
-  "Move point to CACHE-next, return cache; error if nil."
+  "Move point to CACHE-prev, return cache; error if nil."
   (when (not (markerp (wisi-cache-prev cache)))
     (error "no prev statement cache"))
   (goto-char (1- (wisi-cache-prev cache)))
@@ -1371,27 +1403,33 @@ Return start cache."
 (defun wisi-comment-indent ()
   "For `comment-indent-function'. Indent single line comment to
 the comment on the previous line."
+  ;; Called from `comment-indent', either to insert a new comment, or
+  ;; to indent the first line of an existing one.  In either case, the
+  ;; comment may be after code on the same line.  For an existing
+  ;; comment, point is at the start of the starting delimiter.
   (or
    (save-excursion
-     (forward-comment -1)
-     (when (looking-at comment-start)
-       ;; There is a preceding comment line.
-       (current-column)))
-
-   ;; Probably called from `comment-indent'; either to insert a new
-   ;; comment, or to indent the first line of an existing one.  In
-   ;; either case, the comment may be after code on the same line.
+     ;; Check for a preceding comment line; fail if comment follows code.
+     (when (forward-comment -1)
+       ;; For the case:
+       ;;
+       ;; code;-- comment
+       ;;
+       ;; point is on '--', and 'forward-comment' does not move point,
+       ;; returns nil.
+       (when (looking-at comment-start)
+         (current-column))))
+
    (save-excursion
-     (let ((start-col (current-column)))
-       (back-to-indentation)
-       (if (looking-at comment-start)
-          ;; An existing comment alone on a line. Return nil, so
-          ;; `comment-indent' will call `indent-according-to-mode'
-          nil
-
-        ;; A comment after code on the same line; point was at the
-        ;; comment start, so assume it is already correct.
-        start-col)))
+     (back-to-indentation)
+     (if (looking-at comment-start)
+         ;; An existing comment, no code preceding comment, and
+         ;; no comment on preceding line. Return nil, so
+         ;; `comment-indent' will call `indent-according-to-mode'
+         nil
+
+       ;; A comment after code on the same line.
+       comment-column))
    ))
 
 (defun wisi-indent-current (offset)
@@ -1446,6 +1484,17 @@ correct. Must leave point at indentation of current 
line.")
 (defvar-local wisi-indent-failed nil
   "Non-nil when wisi-indent-line fails due to parse failing; cleared when 
indent succeeds.")
 
+(defvar-local wisi-indent-fallback 'wisi-indent-fallback-default
+  "Function to compute indent for current line when wisi parse fails.")
+
+(defun wisi-indent-fallback-default ()
+  ;; no indent info at point. Assume user is
+  ;; editing; indent to previous line, fix it
+  ;; after parse succeeds
+  (forward-line -1);; safe at bob
+  (back-to-indentation)
+  (current-column))
+
 (defun wisi-indent-line ()
   "Indent current line using the wisi indentation engine."
   (interactive)
@@ -1460,15 +1509,9 @@ correct. Must leave point at indentation of current 
line.")
        (wisi-validate-cache (line-end-position))) ;; include at lease the 
first token on this line
 
       (if (> (point) wisi-cache-max)
-         ;; parse failed
          (progn
-           ;; no indent info at point. Assume user is
-           ;; editing; indent to previous line, fix it
-           ;; after parse succeeds
-           (setq wisi-indent-failed t)
-           (forward-line -1);; safe at bob
-           (back-to-indentation)
-           (setq indent (current-column)))
+             (setq wisi-indent-failed t)
+             (setq indent (funcall wisi-indent-fallback)))
 
        ;; parse succeeded
        (when wisi-indent-failed
@@ -1566,8 +1609,10 @@ correct. Must leave point at indentation of current 
line.")
   (setq wisi-keyword-table keyword-table)
   (setq wisi-parse-table parse-table)
 
-  (setq wisi-indent-calculate-functions indent-calculate)
+  ;; file local variables may have added opentoken, gnatprep
+  (setq wisi-indent-calculate-functions (append 
wisi-indent-calculate-functions indent-calculate))
   (set (make-local-variable 'indent-line-function) 'wisi-indent-line)
+  (set (make-local-variable 'forward-sexp-function) #'wisi-forward-sexp)
 
   (setq wisi-post-parse-fail-hook post-parse-fail)
   (setq wisi-indent-failed nil)
@@ -1575,8 +1620,7 @@ correct. Must leave point at indentation of current 
line.")
   (add-hook 'before-change-functions 'wisi-before-change nil t)
   (add-hook 'after-change-functions 'wisi-after-change nil t)
 
-  (when (functionp 'jit-lock-register)
-      (jit-lock-register 'wisi-fontify-region))
+  (jit-lock-register 'wisi-fontify-region)
 
   ;; see comments on "lexer" above re syntax-propertize
   (syntax-propertize (point-max))



reply via email to

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