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

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

[elpa] externals/wisi 08a90d2dbf: * wisi-process-parse.el: Improve updat


From: Stephen Leake
Subject: [elpa] externals/wisi 08a90d2dbf: * wisi-process-parse.el: Improve updating fringe error marks
Date: Mon, 11 Jul 2022 22:24:40 -0400 (EDT)

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

    * wisi-process-parse.el: Improve updating fringe error marks
    
    * README: Version 4.0.beta.
    
    * wisi-fringe.el: Add verbosity.
    
    * wisi-run-indent-test.el (test-left-fringe-mark): New.
    
    * wisi-tests.el: Delete.
    
    * wisi.el: Bump version to 4.0.beta1.
    (wisi--run-parse): Don't call wisi-fringe-display-errors here.
    
    * wisi.texi: Version 4.0.beta.
---
 README                  |   2 +-
 wisi-fringe.el          |  14 +++++-
 wisi-process-parse.el   |  20 ++++++--
 wisi-run-indent-test.el |  21 ++++++++-
 wisi-tests.el           | 119 ------------------------------------------------
 wisi.el                 |   8 +---
 wisi.texi               |   6 +--
 7 files changed, 54 insertions(+), 136 deletions(-)

diff --git a/README b/README
index 5898d91ee8..4375ad58c4 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Emacs wisi package 3.1.2
+Emacs wisi package 4.0.beta
 
 The wisi package provides utilities for using generalized
 error-correcting LR parsers (in external processes) to do indentation,
diff --git a/wisi-fringe.el b/wisi-fringe.el
index c7b1715334..54146a577e 100644
--- a/wisi-fringe.el
+++ b/wisi-fringe.el
@@ -88,6 +88,10 @@
   (save-excursion
     (goto-char (point-min))
     (forward-line (1- line))
+
+    (when (< 1 wisi-debug)
+      (wisi-parse-log-message wisi-parser-shared (format 
"wisi-fringe--put-left line %d" line)))
+
     (let* ((endpos (line-end-position))
           (ov (make-overlay endpos (1+ endpos)))
           (bmp 'wisi-fringe--double-exclaim-bmp))
@@ -125,7 +129,7 @@ The buffer containing POSITIONS must be current, and the 
window
 displaying that buffer must be current."
   ;; We don't recompute fringe display on scroll, because the user
   ;; will probably have edited the code by then, triggering a new
-  ;; parse.
+  ;; parse. FIXME: use flymake.
   (wisi-fringe-clean)
   (when positions
     (let (scaled-posns
@@ -134,6 +138,14 @@ displaying that buffer must be current."
          (window-pos-first (window-start))
          (window-pos-last  (window-end))
          (window-line-first (line-number-at-pos (window-start) t)))
+
+      (when (< 1 wisi-debug)
+       (wisi-parse-log-message wisi-parser-shared
+                               (format "wisi-fringe-display-errors %d %d %d"
+                                       (length positions)
+                                       window-pos-first
+                                       window-pos-last)))
+
       (dolist (pos positions)
        (let* ((line (line-number-at-pos (max (point-min) (min (point-max) 
pos)) t))
               (scaled-pos (wisi-fringe--scale line buffer-lines 
window-line-first window-lines)))
diff --git a/wisi-process-parse.el b/wisi-process-parse.el
index cf6ee963ab..d00e6762fb 100644
--- a/wisi-process-parse.el
+++ b/wisi-process-parse.el
@@ -59,6 +59,7 @@ Must match emacs_wisi_common_parse.ads Protocol_Version.")
   end-pos                 ;; last character position parsed
   language-action-table   ;; array of function pointers, each taking an sexp 
sent by the process
   query-result            ;; holds result of wisi-process-parse--Query
+  update-fringe           ;; non-nil if wpp--handle-messages should run 
wisi-fringe-display-errors
   )
 
 (cl-defmethod wisi-parser-transaction-log-buffer-name ((parser 
wisi-process--parser))
@@ -340,10 +341,11 @@ complete."
   ;; characters, this is hit by
   ;; ada_mode-conditional_expressions.adb.
   (let ((changes
-        ;; wisi--changes is in reverse time order.
-        (if wisi--changes
-            (prin1-to-string (nreverse wisi--changes))
-          "()")))
+        (unless full
+          ;; wisi--changes is in reverse time order.
+          (if wisi--changes
+              (prin1-to-string (nreverse wisi--changes))
+            (error "wpp--send-incremental-parse with nil wisi--changes")))))
     (when (> (length changes) 9999)
       (setq full t))
 
@@ -1075,6 +1077,16 @@ Source buffer is current."
          (setf (wisi-process--parser-response-count parser) response-count)
          (setf (wisi-process--parser-busy parser) nil)
          (set-buffer source-buffer)
+
+         (when (wisi-process--parser-update-fringe parser)
+           (setf (wisi-process--parser-update-fringe parser) nil)
+           (wisi-fringe-display-errors
+            (append
+             (seq-map (lambda (err) (wisi--lexer-error-pos err))
+                      (wisi-parser-local-lexer-errors wisi-parser-local))
+             (seq-map (lambda (err) (wisi--parse-error-pos err))
+                      (wisi-parser-local-parse-errors wisi-parser-local)))))
+
          (when (< 1 wisi-debug)
            (wisi-parse-log-message parser (format "parse--handle-messages in 
%s done" source-buffer)))
          )
diff --git a/wisi-run-indent-test.el b/wisi-run-indent-test.el
index b4a82ddaca..3aea39bbde 100644
--- a/wisi-run-indent-test.el
+++ b/wisi-run-indent-test.el
@@ -17,7 +17,6 @@
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
-(require 'wisi-tests)
 (require 'wisi-prj)
 (require 'wisi-process-parse)
 
@@ -101,6 +100,26 @@ FACE may be a list."
     (test-face token face)
     ))
 
+(defun test-left-fringe-mark (search-string present)
+  "Search for SEARCH-STRING; if PRESENT is non-nil, assert that
+left fringe mark is present on that line.  Otherwise, assert it
+is not present."
+  (save-excursion
+    (when (test-in-comment-p)
+      (beginning-of-line); forward-comment doesn't move if inside a comment!
+      (forward-comment (point-max)))
+    (search-forward search-string)
+    (let* ((mark (overlays-in (line-end-position) (1+ (line-end-position)))))
+      (cond
+       (present
+       (unless mark
+         (error "expecting left fringe mark line %d" (line-number-at-pos))))
+
+       ((not present)
+       (when mark
+         (error "expecting no left fringe mark line %d" (line-number-at-pos))))
+       ))))
+
 (defun test-cache-class (token class)
   "Test if TOKEN in next code line has wisi-cache with class CLASS."
   (save-excursion
diff --git a/wisi-tests.el b/wisi-tests.el
deleted file mode 100644
index 97f0eaba8e..0000000000
--- a/wisi-tests.el
+++ /dev/null
@@ -1,119 +0,0 @@
-;;; wisi-tests.el --- Common utils for wisi tests -*- lexical-binding:t -*-
-;;
-;; Copyright (C) 2012 - 2020  Free Software Foundation, Inc.
-;;
-;; Author: Stephen Leake <stephen_leake@stephe-leake.org>
-;; Maintainer: Stephen Leake <stephen_leake@stephe-leake.org>
-;;
-;; This file is part of GNU Emacs.
-;;
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-;;
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-;;
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-;;
-
-(require 'cl-lib)
-(require 'wisi)
-
-(defvar wisi-test-parser 'process
-  "Set to ’process to test external process parser.")
-
-(defvar test-syntax-table
-  (let ((table (make-syntax-table)))
-    ;; make-syntax-table sets all alphanumeric to w, etc; so we only
-    ;; have to add test-specific things.
-
-    ;; operator symbols
-    (modify-syntax-entry ?&  "." table)
-    (modify-syntax-entry ?*  "." table)
-    (modify-syntax-entry ?+  "." table)
-    (modify-syntax-entry ?-  "." table)
-    (modify-syntax-entry ?/  "." table)
-    (modify-syntax-entry ?<  "." table)
-    (modify-syntax-entry ?=  "." table)
-    (modify-syntax-entry ?>  "." table)
-    (modify-syntax-entry ?|  "." table)
-
-    ;; \f and \n end a comment - see test-syntax-propertize for comment start
-    (modify-syntax-entry ?\f  ">   " table)
-    (modify-syntax-entry ?\n  ">   " table)
-    table
-    ))
-
-(defun test-syntax-propertize (start end)
-  "Assign `syntax-table' properties in accessible part of buffer."
-  ;; (info "(elisp)Syntax Properties")
-  (let ((modified (buffer-modified-p))
-       (buffer-undo-list t)
-       (inhibit-read-only t)
-       (inhibit-point-motion-hooks t)
-       (inhibit-modification-hooks t))
-    (goto-char start)
-    (while (re-search-forward
-            "\\(--\\)"; 1: comment start
-           end t)
-      ;; The help for syntax-propertize-extend-region-functions
-      ;; implies that 'start end' will always include whole lines, in
-      ;; which case we don't need
-      ;; syntax-propertize-extend-region-functions
-      (cond
-       ((match-beginning 1)
-       (put-text-property
-        (match-beginning 1) (match-end 1) 'syntax-table '(11 . nil)))
-       ))
-    (unless modified
-      (restore-buffer-modified-p nil))))
-
-(defun wisi-tests-setup (grammar-name)
-  ;; grammar-elisp file must be on load-path
-  ;; use Ada style comments in source
-  (set-syntax-table test-syntax-table)
-  (set (make-local-variable 'syntax-propertize-function) 
'test-syntax-propertize)
-  (syntax-ppss-flush-cache (point-min));; force re-evaluate with hook.
-
-  (cl-ecase wisi-test-parser
-    (process
-     (require 'wisi-process-parse)
-     (require (intern (concat grammar-name "-process"))) ;; generated by 
wisi-generate
-     (require (intern grammar-name)) ;; declares parser cl-defstruct
-     (add-to-list 'exec-path default-directory)
-     (wisi-setup
-      :indent-calculate nil
-      :post-indent-fail nil
-      :parser
-      (wisi-process-parse-get
-       (funcall
-       (intern-soft (concat "make-" grammar-name "-wisi-parser"))
-       :label grammar-name
-       :exec-file (concat grammar-name "_wisi_parse.exe")
-       :face-table (symbol-value (intern-soft (concat grammar-name 
"-process-face-table")))
-       :token-table (symbol-value (intern-soft (concat grammar-name 
"-process-token-table")))
-       )))
-     )
-    )
-
-  ;; Not clear why this is not being done automatically
-  (syntax-propertize (point-max))
-  )
-
-;;; Initialization
-
-;; Default includes mtn, among others, which is broken in Emacs 22.2
-(setq vc-handled-backends '(CVS))
-
-(setq eval-expression-debug-on-error nil)
-
-;; ’package-initialize’ is not here; it must be run as part of one of the
-;; -l or --eval command line options
-
-(provide 'wisi-tests)
-;; end of file
diff --git a/wisi.el b/wisi.el
index 5d8cc29ad4..ca3469e622 100644
--- a/wisi.el
+++ b/wisi.el
@@ -7,7 +7,7 @@
 ;; Keywords: parser
 ;;  indentation
 ;;  navigation
-;; Version: 4.0.beta
+;; Version: 4.0.beta1
 ;; package-requires: ((emacs "25.3") (seq "2.20"))
 ;; URL: http://stephe-leake.org/ada/wisitoken.html
 ;;
@@ -928,12 +928,6 @@ Run the parser first if needed."
         (signal (car err) (cdr err)))
        )
 
-      (unless partial-parse-p
-       (wisi-fringe-display-errors
-        (append
-         (seq-map (lambda (err) (wisi--lexer-error-pos err)) 
(wisi-parser-local-lexer-errors wisi-parser-local))
-         (seq-map (lambda (err) (wisi--parse-error-pos err)) 
(wisi-parser-local-parse-errors wisi-parser-local)))))
-
       (when (> wisi-debug 2)
        (if (or (wisi-parser-local-lexer-errors wisi-parser-local)
                (wisi-parser-local-parse-errors wisi-parser-local))
diff --git a/wisi.texi b/wisi.texi
index 0f2408d4cf..9e88cf5642 100644
--- a/wisi.texi
+++ b/wisi.texi
@@ -2,7 +2,7 @@
 @settitle Wisi
 
 @copying
-Copyright @copyright{} 1999 - 2021  Free Software Foundation, Inc.
+Copyright @copyright{} 1999 - 2022  Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -25,7 +25,7 @@ developing GNU and promoting software freedom.''
 
 @titlepage
 @sp 10
-@title Wisi Version 3.1.2
+@title Wisi Version 4.0.beta
 @page
 @vskip 0pt plus 1filll
 @insertcopying
@@ -37,7 +37,7 @@ developing GNU and promoting software freedom.''
 @node Top
 @top Top
 
-Wisi Version 3.1.2
+Wisi Version 4.0.beta
 @end ifnottex
 
 @menu



reply via email to

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