General notes on Emacs Ada mode

build/Makefile

o.e.a: release, in use
o.e.a.stephe-1: dead
o.e.a.stephe-2 (from o.e.a with o.w.s-1, o.s_l.s-1): work
o.e.a.stephe-3 (from o.e.a.s-1): emacs module parser (very old)
o.e.a.stephe-4 (from o.e.a with o.w.s-2, o.s_l.s-2): available
o.e.a.stephe-5 (from o.e.a.s-2): libadalang backend
o.e.a.stephe-6 (from o.e.a.s-2): available

run test from emacs -Q using source:
(progn
  (setq eval-expression-debug-on-error nil)
  (package-initialize)
  (add-to-list 'exec-path "d:/apps/GNAT-GPL_2018/bin")
  (setenv "PATH" (mapconcat 'identity  exec-path  path-separator))
  (add-to-list 'load-path "c:/Projects/org.emacs.ada-mode")
  (add-to-list 'load-path "c:/Projects/org.emacs.ada-mode/build")
  ; (setq debug-on-error t)
  ; (setq debug-on-quit t)
  (setq default-directory "c:/Projects/org.emacs.ada-mode/build/")
  (setq ada-process-parse-exec (expand-file-name "../ada_mode_wisi_lalr_parse.exe"))
  (load "run-indent-test")
  ; (setq wisi-debug 1)
  (setq wisi-trace-action 2)
  (setq wisi-disable-face t)
  (find-file "../test/ada_mode-partial_parse.adb")
)

(dvc-state-multiple
'((xmtn . "/Projects/org.stephe_leake.makerules")
  (xmtn . "/Projects/org.stephe_leake.sal")
  (xmtn . "/Projects/org.stephe_leake.aunit_ext")
  (xmtn . "/Projects/org.wisitoken")
  (xgit . "/Projects/elpa") ;; for uniquify-files
  (xmtn . "/Projects/org.emacs.ada-mode/")))

(dvc-propagate-multiple
 '(("../org.stephe_leake.sal"  . "../org.stephe_leake.sal.stephe-1")
   ("../org.wisitoken"         . "../org.wisitoken.stephe-1")
   ("../org.emacs.ada-mode"    . "../org.emacs.ada-mode.stephe-2")))

(dvc-state-multiple
'((xmtn . "c:/Projects/org.stephe_leake.makerules")
  (xmtn . "c:/Projects/org.stephe_leake.sal.stephe-1")
  (xmtn . "c:/Projects/org.stephe_leake.aunit_ext")
  (xmtn . "c:/Projects/org.wisitoken.stephe-1")
  (xmtn . "c:/Projects/org.emacs.ada-mode.stephe-2")))

(dvc-propagate-multiple
 '(("../org.stephe_leake.sal.stephe-1" . "../org.stephe_leake.sal")
   ("../org.wisitoken.stephe-1"        . "../org.wisitoken")
   ("../org.emacs.ada-mode.stephe-2"   . "../org.emacs.ada-mode")))

 current work
delete emacs/lisp/prog-modes/ada*

speed up lalr compile
    decrease subprog size?

delete "(progn" in actions

change wisi-cache text property to wisi-navigate

wisi-face-mark-action does not specify a face, so it does not need to be removed
    just ignore that item in face-cache tree later
    delete wisi-face-remove-action.

rename "semantic checks" to "in-parse actions", others to "post-parse actions".

why is wisi-hanging specified in each use of expression instead of on expression itself?
    change it and see what breaks
    ada-indent-hanging-rel-exp not used consistently?
    either way, improve example in wisi.texi

in wisi-tests.el, delete call of syntax-propertize for emacs >= 25

major cleanup
    preparing for more emacs project work (project-menu?)
    use cl-defgeneric, not function vars
    assume wisi
    don't assume gnat
    minimize use, scope of env vars
        merge other stuff from project-env.el into project-menu.el
    set/unset _all_ global items required for proper functioning in ada-project-select, -deselect
        including xref
        or make them local somehow
    sort out recursive requires
        split out common stuff from ada-mode.el to ada-common.el or ada-base.el or wisi.el
        no file should require ada-mode
        same for gpr-mode


    bump major version?

    change ada-mode to derive-major-mode
        always put ada-mode-post-local-vars on hack-local-variables-hook; it will be run at the right time

java-ch19.wy TryStatement has optional statement-end
    need override on previous tokens

align bug
          Put_Line
        ("Width" & IHDR.Width'Image &
           " Height" & IHDR.Height'Image &
           " Bit_Depth" & IHDR.Bit_Depth'Image &
           " Color_Type" &
           (case IHDR.Color_Type is
            when Color_Type_Grayscale => "grayscale",
            when Color_Type_RGB => "RGB",
            when Color_Type_Palette => "Palette",
            when Color_Type_Grayscale_Alpha => "grayscale_alpha",
            when Color_Type_RGB_Alpha => "rgb_alpha"));
    => ada-align in case expression => unbalanced parens error

replace ada.wy with ada_annex_p.wy

if partial parse finds dangling 'end', expand parse region towards bob
    -> send extra text, list of start parse points; initially use last start point
    don't always start at beginning of extra; too far from edit point, too many corrections required
        likely to include dangling 'end'!

clean up elpa packages for ada-project, build/ada_mode_wisi_parse.el
    eliminate env-project.el
        used to store WISITOKEN, LIBADALANG
            only needed in compilation-environment?
                nope; used in ada_mode_wisi_parse.prj
                    which is parsed by ada-prj-*, not under compilation-environment
                        it could be
                        but that should be merged into ada-project, which could have its own environment

        also declares project-refresh, -select, -deselect
            used by project-menu, which is used by ada_mode_wisi_parse.el

Compilation-env includes PATH - reset in ada-refresh-prj-file

Adjust-indent loop on each token, handle 'end <keyword>'

Parse-begin on continuation line gives bad indent. Always start on start keyword at start of line.

put --recover-log in info

Eurocontrol/debbugs bugs
https://debbugs.gnu.org/cgi/pkgreport.cgi?package=emacs;include=subject:ada-mode
    1913 non-ascii in regexp (2009!?)
        ada-syntax-propertize assumes ASCII in character literals; wrong (ARM 3.5.2 Wide_Character, Wide_Wide_Character)
        ada-parent-name-regexp is wrong; only used in ada-set-ff-special-constructs
        ada-identifier-at-point is wrong; used in xref/navigation

    33744 indentation of subexpressions
        https://debbugs.gnu.org/cgi/bugreport.cgi?bug=33744
        need to identify subexpressions
        test/hanging.adb need more test cases
        waiting for money
            procedure Operator_Indentation is
            begin
              if B
                   or else C
                     > 2 -- indented relative to "or else"
              then
                null;
              end if;
            end Operator_Indentation;

    34029 multi-line trailing comments
        https://debbugs.gnu.org/cgi/bugreport.cgi?bug=34029
        fixed

    34043: 'Misc | Reset parser' throws an error
        (point-min) /= 0! fixed

    34045: contraint_error on open non-existent file
        gen_emacs_wisi_lr_text_rep_parse.adb:149
        fixed in wisi.el; don't parse empty buffer

    35124
        test/ada_mode-debbugs_35124.ads
        can't fix original bug (no '.' in name)
        error recovery tries 'insert begin', but that fails on '.'
            set matching_token to 'package' if name has a dot.
            change Use_Minimal_Complete_Actions to take Terminals, current_index
            o.e.a.s-2

    35143 partial parse vs RET
        fixed in devel, posted new code

    35144 which-func raises CONSTRAINT_ERROR
        don't get the error in master, but also don't get mode-line element
            something is resetting which-func-mode to nil
                apparently happens when which-func throws error or returns nil

    35924 wavefront compiler warns about 'new String' in descriptor
        need named string access type
        posted fix

    36102 ada-wisi-which-function slow
        trying min partial-parse size, before/after point; works

    36278 auto-casing no longer honors casing of the declaration
        it never did; you must create an exception. could automate that, make it file-local
        option to not auto-correct all uppercase; set ada-auto-case to 'not-upper-case

    36548 programmer_error in get_aug_token; virtual_terminal
        fixed in devel.

    36788 support function expressions returning aggregates directly
        ok for other aggregates, not for 'null record'
        fixed

need wisi user guide
    explain actions

    explain how to patch grammar

    wisi-anchored% - alias wisi-paren-anchored

elpa package include simple makefile to build ada, gpr parser from patched .wy

gpr_query needs to close some xref object to allow 'rm ./obj'?
    clean => rm: cannot remove 'obj/gpr_query.db': Device or resource busy
    would have to restart process after clean anyway, but that could be automated

    gpr_query.adb does:
        gnatcoll.xref.setup_db (Xref, ..., GNATCOLL.SQL.Sqlite.Setup (db_name.all), ...)
        could call free on Xref
        to avoid clean knowing anything about gpr_query requires gpr_query to close, reopen in every command
            way too slow.

indent bug:
                 (if GNAT.Regexp.Match (Value, Symbol_Regexp)
                  then Tree.Add_Nonterm
                    ((+token_keyword_non_grammar_ID, 0),
                    (1 => Tree.Add_Identifier (+KEYWORD_ID, New_Identifier ("keyword"), Tree.Byte_Region (Node))))
                  else Tree.Add_Nonterm

align region too large:
                case 0 =>
                  --  plain identifier
                  RHS.Tokens.Append
                    ((Label      => +"",
                      Identifier => +Get_Text (Data, Tree, Tree.Child (I, 1))));

separate partial-parse threshold for face

Insert context clause inhibit invalidate navigate

loop_statement motion_action include "exit"?

sort error messages in line order

c:/eurocontrol/query_display-flight_operations.adb
    errors cause huge slowdown in parse speed
        due to parallel parse, delete_dup?
        try bounded stack for main parse
        run under valgrind

    only errors are missing end labels
        lr1 parse face time:
        with all fixed,      0.175579163
        with errors present, 8.395040656

        1  8.282763405
        2  8.146287525
        3  8.083595595
        4  2.576497063
        5  1.448250382
        6  1.461459692
        7  1.437491198
        8  1.420267629
        9  0.160563880

        second ediff-buffers reliably hangs!
            external process communications bug
            update master, try -Q
            emacs 26 ok

    run with profile => recover takes 0% of time (sigh)

    add put (clock) at various places
    after recover at 15304:(PROCEDURE, (122273 . 122281)) Display_Profile line 2784
    takes 6.5 seconds to get to 20650:(END, (170186 . 170188)) Query_Display.Flight_Operations; line 3625

1. 2091:(BEGIN, (18446 . 18450))
   (subprogram_body, (18252 . 18440))
   1 parser, succeed 2, enqueue 2, check  2, cost:  0
   non-ignore solution is wrong, terminated immediately

2. 4143:(BEGIN, (33687 . 33691))
   (subprogram_specification, (33286 . 33350))
   1 parser, succeed 2, enqueue 2, check  2, cost:  0
   extra terminated 4245:(USE, (34365 . 34367))

3. 5177:(FUNCTION, (40478 . 40485))
   (subprogram_specification, (39991 . 40026))
   1 parser, succeed 1, enqueue 4, check  2, cost:  0
   nested inside 4

4. 5255:(BEGIN, (40951 . 40955)) Resume_Token_Goal 5259
   (subprogram_specification, (40699 . 40726))
   209: succeed 2, enqueue 2, check  2, cost:  0
   extra terminated 5275:(BEGIN, (41044 . 41048))

5. 5364:(BEGIN, (41705 . 41709)) Resume_Token_Goal 5368
   (subprogram_specification, (41435 . 41488))
   215: succeed 2, enqueue 2, check  2, cost:  0
   extra terminated 5802:(IDENTIFIER, (45635 . 45643))

6. 7439:(IDENTIFIER, (59232 . 59243)) Resume_Token_Goal 7443
   (subprogram_specification, (59021 . 59051))
   281: succeed 1, enqueue 4, check  2, cost:  0
   7442:(IDENTIFIER, (59256 . 59259))

7. 10700:(BEGIN, (82600 . 82604)) Resume_Token_Goal 10704
   (subprogram_specification, (82299 . 82324))
   340: succeed 2, enqueue 2, check  2, cost:  0
   encounters next error before terminate extra

8a. 627: 15304:(PROCEDURE, (122273 . 122281)) Resume_Token_Goal 15308
    (subprogram_specification, (40699 . 40726))
    627: succeed 1, enqueue 4, check  2, cost:  0
    no terminate needed

8b. 626: 15304:(PROCEDURE, (122273 . 122281)) Resume_Token_Goal 15308
    (subprogram_specification, (82299 . 82324))
    626: succeed 1, enqueue 4, check  2, cost:  0
    no terminate needed

9a. 957: 20650:(END, (170186 . 170188))
Action, expecting: BEGIN, ENTRY, FOR, FUNCTION, GENERIC, NOT, OVERRIDING, PACKAGE, PRAGMA, PROCEDURE, PROTECTED, SUBTYPE, TASK, TYPE, USE, IDENTIFIER, found 20650:(END, (170186 . 170188))
    957: succeed 1, enqueue 40, check  17, cost:  1
    error due to some previous bad recovery

9b. 956: 20650:(END, (170186 . 170188)) Resume_Token_Goal 20654
Action, expecting: BEGIN, ENTRY, FOR, FUNCTION, GENERIC, NOT, OVERRIDING, PACKAGE, PRAGMA, PROCEDURE, PROTECTED, SUBTYPE, TASK, TYPE, USE, IDENTIFIER, found 20650:(END, (170186 . 170188))
    956: succeed 1, enqueue 18, check  7, cost:  1
    error due to some previous bad recovery

10a. 957: 20655:(Wisi_EOI, (170222 . 170221)) Resume_Token_Goal 20659
Action, expecting: BEGIN, ENTRY, FOR, FUNCTION, GENERIC, NOT, OVERRIDING, PACKAGE, PRAGMA, PROCEDURE, PROTECTED, SUBTYPE, TASK, TYPE, USE, IDENTIFIER, found 20655:(Wisi_EOI, (170222 . 170221))
     error due to some previous bad recovery
     957: succeed 1, enqueue 215, check  49, cost:  2

10b. 956: 20655:(Wisi_EOI, (170222 . 170221)) Resume_Token_Goal 20659
Action, expecting: BEGIN, ENTRY, FOR, FUNCTION, GENERIC, NOT, OVERRIDING, PACKAGE, PRAGMA, PROCEDURE, PROTECTED, SUBTYPE, TASK, TYPE, USE, IDENTIFIER, found 20655:(Wisi_EOI, (170222 . 170221))
     error due to some previous bad recovery
     956: succeed 1, enqueue 126, check  23, cost:  1

test/lalr_parse_fail.adb
    lalr parse raises constraint_error in main parser
    lr1 no error.
    parser 0: aspect_clause
    parser 1: iteration_scheme
    both merged into state 6 in lalr, but iteration_sheme has no lookaheads!
    bug in lalr generator

ada-align groups preceding comment lines with declarations

run_ada_lr1_parse.exe hangs in free string if input file not found

package for Ludovic: elpa/archive/packages *.tar, archive-contents

stack has compilation_unit_list, next input is "end if;"
    only insert tokens whose minimal complete includes 'end if ;'
        requires another precomputed list; w.stephe-1
        one for each possible token sequence; just to "end ;", "end * ;"?
        current list is for wisi_eof

optimize Grow of SAL.Gen_Unbounded_Definite_Vectors?
    run-time parameter and/or generic parameter giving initial size
    output max size, accumulate in Emacs session

    go thru all uses
        wisitoken.syntax_tree.s.node_arrays

    similar for parse_stack?

enforce unix line endings
    run dos2unix in a mtn pre-commit hook?

time lex with no lex debug

rename parser actions to "parse", "post-parse"

show ada subprogram params as in elisp

ada.wy
    result_profile should not use name_opt, because it should not call wisi-propagate-name
        on the other hand, it doesn't really hurt


wisi-process-time-out is local to *-parse* buffer; setting from .adb has no effect

disable navigate commands if parse navigate fails

stefan complains he gets byte-compiler errors when compiling elpa after an ada-mode update.
    root cause is he doesn't do 'rm *.elc', and the byte-compiler doesn't set load-prefer-newer
    he'll try load-prefer-newer

elisp code has circular dependency
    see if load-prefer-newer finds it
    write dependency checker.
        in elisp so it can be added to batch-byte-compile

other misc fixes from stefan

possible Eurocontrol work
    gpr_query
        add local, append

    implement parser as Emacs module

    command line pretty-printer using Ada parser

    ada-indent-rel-exp; bug=33744
        needs sub-expression (ie term, factor) indentation rules
        estimated 10 hrs

    investigate libadalang
        estimated 40 hrs to get useful info

ada-process.el missing TICK_2 on debian o.e.a.s-5
    because generated by External
    should be ada-process-external.el!

use EXE_EXT consistently, delete Executable_Suffix in *.gpr

> When inserting a comment, the marker appears after the leading '-' &
> doesn't go away as the rest of the comment is typed (until DEL or
> RET).

Move defgeneric parse parameters to process, with default. Delete from wisitoken-grammar

move gnatcoll install instructions to wisi elpa package, for reference
from wisitoken-grammar-mode.

delete ada-mode-opentoken
    or rename to -wisitoken

use #'ignore, not nil, for function vars
    or convert to cl-generic

debug-on-error t should only throw error when there is a bug in the
    elisp code, not for a syntax error in user code (since that's expected).
    put errors on wisi--parser-errors lower down.

'wisi-compile-grammar' should be renamed 'wisi-compile-parse-table'

Decrease elisp parser startup time
    wisi-compile-grammar slow
        obarray is not written into elc; must be computed at load time
    wisi-bnf-generate write lambda from wisi-semantic-action into parse table for each action
    also other changes? eliminate wisi-compile-grammar/parse-table

do module interface

remove all code supporting emacs < 25
    syntax-propertize calls

use #'remove-hook

review eglot
    completion; maybe more not obvious from the LSP main page

first use of lr1 can time out because of load table time
    does not recover nicely
    longer timeout on first use?
        or just increase timeout

test/ada_mode-recover_redundant_solutions_1.adb
    recover finds two identical solutions
        one from Language_Fixes end keyword 1
        one from minimal complete actions
        delete the language_fixes case?

interactive indent requires [0 ada-indent] on block start keywords when following token is virtual from recovery
    normally get indent from next token, but that's virtual, and is not in token.first/last_indent_lines
        or something like that
        find a place to document this
            in wisi.texi user guide
                explain emacs wisi package
                parser actions
                section that explains indent-action syntax

        or fix it; for real comment, use indent from next token even if it's virtual

redundant solutions
    ada_mode-recover_redundant_solutions_1.adb

https://github.com/lapo-luchini/asn1js/blob/master/mirror_to_github.sh
    export, incremental update of git mirror works
    push my stuff to savannah
        also to github?

do module interface

gnat pro 2018
    AI12-0125 "@" shorthand  http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0125-3.txt
        target_name ::= @
        Name : target_name | ... ;
        My_Array(I) := @*2 + @/2;

    AI12-0127 delta_aggregates http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0127-1.txt?rev=1.25&raw=N
        aggregate ::= record_aggregate | extension_aggregate | array_aggregate | delta_aggregate
        delta_aggregate ::= record_delta_aggregate | array_delta_aggregate
        record_delta_aggregate ::=
          (*base_*expression with delta record_component_association_list)
        array_delta_aggregate ::=
          (*base_*expression with delta array_component_association_list)

        procedure Twelfth (D : in out Date) -- see 3.8 for type Date with Post => D = (D'Old with delta Day => 12);
        A1 : Vector := ((1.0, 2.0, 3.0) with delta Integer (Random * 3.0) => 14.2);

ada.wy:774: ;; FIXME: | digits_constraint
ada.wy:775: ;; FIXME: | delta_constraint
ada.wy:1015:;; FIXME: leaving out [renaming] [aspect_specification]
ada.wy:1245:      ;; FIXME: indentation of comment after 'is' (and 'with' in
ada.wy:1929: ;; allocator, FIXME: leaving out subpool_specification.


revert "allow everything to be empty"
    see if error handling is good enough

    or start over from annex P, see how many mods are actually required

option to stack/append xref results

Test indent when narrowed to subprogram

packrat
    need to override wisitoken.parse.put_errors for emacs process interface
        derive an Emacs_Parser type?

        or add abstract error_list, change wisi_runtime.put_errors to use that

        using Parser.Put_Errors for now

    langkit packrat is significantly faster than wisitoken lalr
        because of generated code, not table interpreter?
            try generated code for lalr
                lose error correction?
        use non-error-correcting packrat as primary parser, error-correcting lalr as fallback

    generate, compile packrat speed?
        ada_packrat_process_main.adb (31347 lines) compiles _way_ faster than ada_process_main.adb (13692 lines)


time with w32-pipe-read-delay 0

add missing features to gpr_query; see fixmes.
    option to run in background, from Makefiles

Contact ada cubesat lab, see if they will beta test indentation engine.

see if more tasks go faster or slower.

emacs track single parse-max, don't reparse for different action; just execute action.
    requires saving the syntax tree in the process
    lost if another buffer parse intervenes
        unless add per-buffer cache

make-subprogram-body should strip aspects.

clean up gpr-mode; delete 'we reuse ada' comments
    refactor ada auto-case into wisi, use in gpr

compute align in grammar actions
    align-list action on ':', '=>' etc

Grune 9.10.4 Incremental Parsing.
    Compare new lex to old lex, update syntax tree

support variable pitch fonts
    (put-text-property 118 120 'display '(space :width (10))))

Mark syntax error lines in margin.
    What does fly-check do?

add wisi-forward-anchor, use for comments after 'is', 'when' in record type

gpr-mode.el:263:  (set-syntax-table ada-mode-syntax-table);; FIXME: create gpr-mode-syntax-table
gpr-query.el:263:  ;; FIXME: implement ada-xref-full-path.
gpr-query.el:265:  ;; FIXME: implement append
gpr-query.el:583:  ;; FIXME: implement local-only, append
gpr-skel.el:114:;; FIXME: code below should be in skeleton.el
gpr-skel.el:202:	;; FIXME: hook for Ada case adjust
wisi.el:1145:		 ;; FIXME: ensure at beginning of error message line.

newline not in a word should not cause parse retry after parse fail

refactor {ada|gpr|java}-skel-expand
    (defun skel-expand
    use buffer-local skel-token-alist

Ada 2020 features:
    delta aggregates (partial aggregate notation)
    http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0127-1.txt?rev=1.10
    wait for wisi-2.0

    new syntax in AI12-061:
        http://www.adacore.com/developers/development-log/NF-17-P617-043-gnat

 benchmarks:
    update only in o.e.a

    build/Makefile
        comment out 'export Standard_Common_Build := Debug'
        make recursive-clean build_ada_executables

d:/Apps/GNAT-gpl_2016/gnatcoll-gpl-2016-src/src/sqlite/gnatcoll-xref.adb
    copied to c:/tmp/gnatcoll-xref.adb
    7252 lines, 29461 tokens, 254989 characters

wisi-generate
    $WISI_WISITOKEN/wisi-generate.exe --time ada.wy

    04 mar 2018
        o.e.a.s-2 12.919s
        o.e.a.s-4 24.398s, 24.625s

    12 Apr 2018
        o.e.a.s-4 16.136s

    23 May 2018
        11.967s, 12.035s

    25 Jul 2018
        trees in lr1_items search, -O3
        LALR elisp generate time: 3.290167687
        LALR re2c generate time: 3.309398246
        LR1 re2c generate time: 602.235431713

    26  Jul 2018
        don't loop on all token_ids; loop on set
        LALR elisp generate time: 0.445727505
        LALR re2c generate time: 0.450525800
        LR1 re2c generate time: 31.202567095

    1 Aug 2018 replace Constrain_Terminals with Minimal_Complete_Actions
        LALR elisp generate time: 0.472614643
        LALR re2c generate time: 0.480273867
        LR1 re2c generate time: 31.820868201

mckenzie recover
    ./run_ada_lr1_parse.exe test/ada_mode-recover_partial_02_lr1.adb Indent --debug_mode --enqueue_limit 120_000 --check_delta 20_000 --verbosity 0 1 0

    12 Jul 2019 ada-mode 6.1.1
        0: succeed 2, enqueue 110, check  14, cost:  2
        time 0.003358967

        1: fail; enqueue limit ( 120000 cost 11)
        1: fail, enqueue 120063, check  11824, max shared_token  64
        0: succeed 2, enqueue 73734, check  7599, cost:  8
        time 0.680450032

    o.e.a-m just_pushed_back_or_inlined expanded
        0.671804168, 0.673667911, 0.671176628

    "", drop token_index compare
        0.678247599, 0.670705783, 0.678376354

    o.e.a-m.s-4 config_heap.pre_add
        0: succeed 2, enqueue 110, check  14, cost:  2
        time 0.003585515

        0: fail; enqueue limit ( 120000 cost 10)
        1: succeed 2, enqueue 73734, check  7599, cost:  8
        time 0.665732656, 0.661565665, 0.660932083, 0.668397249 - not worth it

    o.e.a-m.s-4, o.w.s-2 binary search action_for
        0: succeed 2, enqueue 110, check  14, cost:  2
        time: 0.003279674

        0: fail; enqueue limit ( 120000 cost 11)
        1: succeed 2, enqueue 73734, check  7599, cost:  8
        time: 0.665491758

        after propagate:
        0.695314665, 0.691568300, 0.714005333

    binary search goto_for
        0.696081911, 0.727982272, 0.692549635 -- no slower, no faster; keep for clean

    sal.list in sal.unbounded_queue
        0.679426409, 0.703120410, 0.711440799

    use spark bounded_queue; no controlled
        0.703130227, 0.677916459, 0.674938851

    in bounded_queue, add suppress (all_checks), explicit check for full
        0.768971400, 0.677694819, 0.699692724, 0.680185725

    spark bounded_stack, suppress (all_checks)
        0.475089053, 0.471345331, 0.470334167 yes!

navigate, face, indent
    make -r benchmark
        uses gnatcoll-xref.adb

    27 Nov 2017 - compute actions in Ada
        1.377199 seconds 3 gcs 6560 responses 0.509915 wait
        1.523548 seconds 2 gcs 6560 responses 0.518090 wait

    12 Apr 2018 - syntax table
        navigate 1.411872 seconds 4 gcs 6560 responses 0.352224 wait
        face     1.507372 seconds 5 gcs 2145 responses 0.319860 wait
        indent   1.447788 seconds 1 gcs 7251 responses 0.350474 wait

    23 May 2018
        navigate 1.542892 seconds 4 gcs 6560 responses 0.473158 wait
        face     1.645698 seconds 4 gcs 2145 responses 0.452539 wait
        indent   1.603725 seconds 1 gcs 7251 responses 0.491922 wait

    2 Sep 2018
    using lalr
        navigate 0.985181 seconds 4 gcs 6568 responses 0.248143 wait
        face     1.119776 seconds 4 gcs 2145 responses 0.246759 wait
        indent   1.033525 seconds 1 gcs 7251 responses 0.251972 wait
    lr1:
        navigate 0.968994 seconds 4 gcs 6568 responses 0.231818 wait
        face     1.085459 seconds 4 gcs 2145 responses 0.219220 wait
        indent   1.020811 seconds 1 gcs 7251 responses 0.237752 wait

    12 Jul 2019 ada-mode 6.1.1
        navigate 1.383730 seconds 6 gcs 7431 responses 0.241632 wait
        face     1.490733 seconds 8 gcs 2151 responses 0.215659 wait
        indent   1.382439 seconds 3 gcs 7252 responses 0.241366 wait

 indent issues
http://langserver.org/
    open protocol for IDE/compiler communication

ada-indent-hanging-rel-exp
    see FIXME: in ada-wisi.el
    need input from ludovic

    more cases:

    if FTFX.Main_CASA_Result.Suspension.Status /= Previous_Suspension_Info.Status
      or FTFX.Main_CASA_Result.Suspension.Delay_Threshold_Exceeded_Reg
        /= Previous_Suspension_Info.Delay_Threshold_Exceeded_Reg
    wisi aligns "/=" with "or"

 wisi work

disable or use electric-indent-post-self-insert-function
    called during ada-indent-newline-indent
    on post-self-insert-hook
        use that for ada-mode capitalization

Smart edit - delete if/then/endif, leaving content

gpr_query does not see libraries?
    need clear example; libadalang mains vs langkit?
    compare to GPS, gnatinspect

change Emacs manual section on ada-mode to mention elpa

ada-goto-declaration-start
    fails on task declaration
        only a problem if misusing C-c C-b ada-make-subprogram-body to make a task body
        C-x C-e skeleton expand works fine

        ada-make-subprogram-body should throw an error if it's not on a
        _subprogram_ spec, and recommend C-c C-e in the error message.

        but also fails on
        task body TA is
        begin
           null;
        end TA;

        fix the latter, see if it fixes ada-make-subprogram-body
            if not, make it throw an error.

    fails on separate (P) procedure X;
        C-c C-e works

        but also fails on
        separate (P)
        procedure X;
        is
        begin
        end X;

        fix the latter, see if it fixes ada-make-subprogram-body
            if not, obsolete that.

add "show all overloads" in navigate
    leave out file, line, col from gpr-query id

fill comments:
    set `fill-paragraph-function' to `ada-fill-comment-paragraph'

    `ada-fill-comment-paragraph' doesn't respect the region

    fix errors in filling:
procedure Non_Comment           -- The following line will be removed on M-Q,
                                --
is                              --  * if it was an empty comment.

   E : String := (1 =>    -- The following line will stay when pressing M-Q,
                          --
                          --  * even though it was empty.
                    'A');


gnat-core support RTS choice
    with GNAT GPL 2014:
    foo.gpr contains:
       package Builder is
          for Default_Switches ("ada") use ("--RTS=sjlj");
       end Builder;

    'gnat list -v -P foo.gpr' returns the wrong system library.

    'gnat list -v --RTS=sjlj' returns the correct system library.

    add project variable 'rts'

Gpr_query
    check gnatinspect for new features

    grok --RTS
        may be already done in 2015:
            for Runtime ("ada") use "stm32f429i-disco-rtos";


completion
    (info "(elisp)Completion")
    http://emacswiki.org/emacs/CategoryCompletion
    autocomplete package

    examples:
        Ada.Text_IO.<tab> => Put, Put_line, Get, etc
            needs new query; all symbols that match prefix
            better as an ASIS query?

        what does GPS do?
            works on non-compiled, bad syntax code
            type 'with '; puts up a list of all packages in the project.
            type 'with Ada.'; list of all children of Ada
                requires scroll, <ret> to select
                while scrolling, puts up help text next to list

            type 'Put', puts up a list of all simple names in project matching that prefix
            type 'Put (', puts up a list of all params of all Puts (_not_ filtered by current context clause)

            does _not_ handle 'foo_io.put', where 'foo_io' is an instance of A.Tio.float_io.
                maybe it would if foo_io is:
                    a library package instantiation
                    a local instantiation, but was previously compiled

            find the GPS source code

    match GPS behavior
        get completion candidates from gpr_query
        all names in scope at point

    built-in pcomplete
        completion-at-point-functions

    http://elpa.gnu.org/packages/company.html
        including C++ parameters, class members

    MELPA package auto-complete
    https://github.com/auto-complete/auto-complete
    https://github.com/capitaomorte/yasnippet

c:/Archive/Emacs/slime-2.10.1.tar.gz

face actions in gpr grammar?

after ada-mode is fast enough:
    built-in ada-mode: (make-obsolete 'ada-mode "use later version from ELPA via `list-packages')

use cl-lib class/method for dispatching

emacs 25 compile.el supports HYPERLINK in compilation regexp; use for secondary ref?
    ada-gnat-compile.el ada-gnat-compilation-filter


implement packrat in fasttoken, generate elisp

skip blocks of text unless needed for current user command

    two grammars
        use elisp parser
            simplifies debugging, installation

        coarse grammar skips all non-block statements

        sets high level caches that are start/end points for detailed grammar

        invalidate both for any change; "end" can make a new block.

        define both in one .wy file?
            share keywords, tokens

        start with test language in .wy


    skip statements at lexer level?
         mark all tokens as level 1 or 2
         level 1: function begin end if loop etc
         parse level 2 on demand

if specify project file in gnat_stub_opts, gnat stub can't find it due to changed directory
    change to gnat_stub_gpr, manage directory
    or edit gnat_stub_opts, insert project dir?

skeleton refactor/cleanup
    see fixmes

move stuff out of ada-mode-keys.el
    ada-make-package-spec
        skel default to (ada-name-from-file-name (buffer-file-name))?

different casing for identifiers (uppercase) and attributes (mixed)

refactoring

    rename entity:
        use xref to rename all uses (with/without confirm)

    change parameter_result_profile
        make same change in all overrides
        offer to walk thru all uses

    promote primitive subprogram-local variable to type component

    move primitive from parent to child class

    extract subprogram
        from Eclipse
        highlight lines of source
        prompt for name
        it guesses parameter_result_profile

support for "Adadoc"?
    formatted comments that mention parameters; check that they are all mentioned, spelled correctly

support for "ElDoc"?
    display parameter list for current function

Add Ada parser to gnu global?

 debug hints, relevant files
https://debbugs.gnu.org/Developer.html
https://debbugs.gnu.org/server-control.html
https://debbugs.gnu.org/cgi/pkgreport.cgi?package=emacs;include=subject:ada-mode

gdb run_ada_parse
    in wisitoken-wisi_runtime.adb Indent_Action_0:
        break on 'if token.first_indent_line then' line 1050
        call wisitoken.syntax_trees.id (tree, nonterm)
        p data.descriptor.image ($)
        p i
        p data.descriptor.image (token.id)
        p token.line
        p token.col
        p pair
        p data.indents.elements.ea(token.line)

    in wisitoken-semantic_state.adb Reduce
        break on 'nonterm.paren_state := ' line 334
        p descriptor.image (nonterm.id)
        p i
        p descriptor.image (aug_token.id)
        p aug_token
        p nonterm

to change process executable for all current and future buffers:

    in any *.adb buffer:
    (setf (wisi-process--parser-exec-file wisi--parser)
      "c:/Projects/org.emacs.ada-mode.stephe-2/ada_mode_wisi_parse.exe")
    M-x wisi-kill-parser

    to undo:
      (setf (wisi-process--parser-exec-file wisi--parser)
        "ada_mode_wisi_parse.exe")
    M-x wisi-kill-parser

    if *-process.el has changed:
    in *-process.el: M-x eval-buffer
    in *.<lang> buffer:
    (wisi-kill-parser
    (setq wisi-process--alist nil)
    M-x <lang>-mode

Edebug displays

in wisi-process-parse--Reduce_Stack:
(setq edebug-eval-list
 '(tokens-1
   tok
   (aref token-table (aref tokens-1 i))
   (queue-head (wisi-process--parser-parse-stack wisi--parser))
   sexp
   ))

in wisi-parse-reduce:
(setq edebug-eval-list
 '(nonterm
   tok
   first
   ))

in wisi--indent-token-1:
(setq edebug-eval-list
 '((wisi-ind-indent wisi--indent)
   wisi-nterm
   i
   delta
   indent
   ))

in wisi-indent-action:
(setq edebug-eval-list
 '((wisi-ind-indent wisi--indent)
   wisi-nterm
   wisi-tokens
   deltas
   wisi-token-index
   tok
   token-delta
   comment-delta
   ))

wisi-indent-region:
(setq edebug-eval-list
 '((wisi-ind-indent wisi--indent)
   anchor-indent
   i
   indent
   new-indent
   ))

use elp (emacs lisp profiler)?
    (with-current-buffer (find-file-noselect "~/src/xdisp.c")
      (elp-instrument-function 'c-beginning-of-defun)
      (goto-char (point-max))
      (condition-case nil
          (while (beginning-of-defun) nil)
        (error nil))
      (elp-results))

(progn (profiler-start 'cpu) (time-it 'wisi-parse-buffer 10) (profiler-report) (profiler-stop))
    B - profiler-report-render-reversed-calltree shows low-level time hogs

attach gud-gdb to running emacs: attach <process id>
    source emacs/src/.gdbinit
    xbacktrace shows lisp backtrace

"kill -USR2 <emacspid>" which should also drop you into the (elisp?) debugger.

(browse-url "c:/Projects/arm_info/org.adaic.arm_form/build/html/arm2012/RM-P.html")
(info "(aarm2012)Annex P" "*info Annex P*")
http://www.ada-auth.org/standards/
(info "(elisp)Parser State" "*info syntax-ppss*")
"c:/home/stephe/Backup/eBooks/Dick Grune/Parsing.pdf" [dickgrune]

http://savannah.gnu.org/projects/emacs/

http://git.savannah.gnu.org/cgit/emacs.git/tree/README?h=elpa
http://elpa.gnu.org/

https://www.dropbox.com/sh/7jr3vbv9tm1zod0/jPuvfrJAe8
    w32 builds of cutting-edge emacs branches, pretests

ftp://alpha.gnu.org/gnu/emacs/pretest/
    untar with cygwin
    in mys32 under emacs:
        cd /c/Projects/emacs/emacs-24.3.9x
        ./configure --prefix=/mingw32
        make
        # don't make install, just run from the build dir

 access to ada-france:

anonymous (read only) access:
    mtn --db ~/monotone-dbs/ada-france.db --key '' pull www.ada-france.org "org.emacs.*"

read/write access requires a public key:
    send output of 'mtn pubkey' to Ludovic Brenta
    <ludovic@ludovic-brenta.org> or Stephe Leake
    <stephen_leake@stephe-leake.org>

    add it to monotone db via 'mtn read'
    add it to /etc/monotone/write-permissions
    /etc/init.d/monotone restart

    mtn --db ~/monotone-dbs/ada-france.db sync "mtn://www.ada-france.org?org.emacs.*"

 git config for elpa checkout
in ~/.gitconfig:
    # 15 Feb 2016: ELPA has an object that fails this check; only need
    # to disable (set to false) when pull a full repository (that includes that
    # object)
        fsckObjects = false

[core]
	repositoryformatversion = 0
	filemode = false # don't set exec bits
	bare = false
	logallrefupdates = true
	ignorecase = true
[remote "origin"]
	fetch = +refs/heads/master:refs/remotes/origin/master
	push  = +refs/heads/master
	url = stephen_leake@git.sv.gnu.org:/srv/git/emacs/elpa.git
[branch "master"]
	remote = origin
	merge = refs/heads/master

 package install notes
libadalang etc with gnat pro 18.2
    install gnat 18.2
    reinstall gnatcoll 18.2 (needed for gpr-query anyway)
        ./configure --prefix=/usr/gnat/pro_18.2

    git clone libadalang
        see libadalang/install-lal-and-deps.sh
        cd libadalang
        git checkout 18.2
        virtualenv lal-venv
        . lal-venv/bin/activate
        pip install -r REQUIREMENTS.dev
        cd lal-venv/lal-venv/src/langkit/
        git checkout 18.2

        ada/manage.py --enable-static --disable-shared make
            # or --enable-static --enable-shared?
        ada/manage.py --enable-static --disable-shared install /usr/gnat/pro_18.2

        # for Emacs use of lal gpr files: (setenv "LIBRARY_TYPE" "static")

    git clone https://github.com/AdaCore/libadalang-tools.git
        git checkout 18.2

 mini-release to Ludovic
run all tests

bump version (elpa releases don't have to be consecutive)

Makefile build-elpa install-elpa elpa-zip
    # install-elpa verifies all required files are included and byte-compile successfully.

 release process
do wisitoken release ../org.wisitoken/build/release_process.text

(dvc-status ".")

# uninstall elpa packages before change version
build/Makefile uninstall-elpa

check for ELPA patches by others
    (dvc-status "/Projects/elpa")
        revert local changes in ada, wisi, ada-ref-main; commit in uniquify
    (dvc-pull "/Projects/elpa")
    (dvc-sync-review "/Projects/elpa")
        update
        clean, quit sync
    cd c:/Projects/elpa
    git log -2 -- packages/wisi
    git log -2 -- packages/ada-mode
    git log -2 -- packages/ada-ref-man
    git log -2 -- packages/uniquify-files
    if changes:
        (dvc-log "/Projects/elpa/packages/<dir>/<file>")
        apply changes to current

check emacs buglist
    http://debbugs.gnu.org/cgi/pkgreport.cgi?package=ada-mode
    to update a bug: nnn@debbugs.gnu.org

check for latest Emacs release
    http://ftp.gnu.org/gnu/emacs/windows/

run all tests without elpa:
    build/Makefile elisp

    Windows current Emacs, current gnat
    Windows Emacs 25.3, current gnat

compare:
    build stuff to compare with previous release in elpa:
        build/Makefile pub

    (list-packages)
        install previous ada-mode, wisi, ada-ref-man from public ELPA for diffs
        change versions in compares below to match installed versions.

    (ediff-directories "~/.emacs.d/elpa/wisi-2.1.1" "/Projects/elpa/packages/wisi" nil)
        NEWS-wisi.text
            copyright date
            add release date
            add new features

    (ediff-directories "~/.emacs.d/elpa/ada-mode-6.1.1" "/Projects/elpa/packages/ada-mode" nil)
        NEWS-ada-mode.text
            add release date
            add new features

    (ediff-directories "~/.emacs.d/elpa/ada-ref-man-2012.5" "/Projects/elpa/packages/ada-ref-man" nil)
        /Projects/org.adaic.arm_form/NEWS
            add release date, new features

bump versions
    Gnu ELPA requires single digits between dots in versions

    bump if _any_ changes other than autoloads, so ELPA package handler knows to update
        bump third digit for bug fixes, minor features
        bump second digit for major features
            - GPS indentation engine add/delete
            - partial parse
            - delete elisp lexer
        bump first digit for really major or user-incompatible changes
            - 5 use parser
            - 6 compute indentation in grammar actions, external parser with error correction

    wisi.el
        Version:

    wisi.texi
        @title
        @node top

    README-wisi
        first line

    build.sh
        GPR_PROJECT_PATH wisi version

    ada-mode.el
        Version:
        package-requires wisi version
        ada-mode-version

    ada-mode.texi
        @title
        @node top

    README-ada-mode
        first line

    ada-ref-man.el
        Version:

    build/Makefile
        run uninstall-elpa with old values before changing!
        ADA_MODE_VERSION
        ADA_REF_MAN_VERSION
        WISI_VERSION
        WISITOKEN_GENERATE := ~/.emacs.d/elpa/wisi-i.j.k/

    d:/Web/savannah/ada-mode/index.html
        find-replace ada-mode i.j.k
        wisi version does not appear
        _not_ WisiToken (done in wisitoken release)

    _not_ d:/Web/stephe-leake/ada/wisitoken.html - done in wisitoken release

    ~/Web/Makefile
        ADA_MODE_VERSION
        _not_ WISITOKEN_ZIP_VERSION

verify other metadata
    ada-mode.el
    ada-ref-man.el
    wisi.el

prep for elpa tests:
    build/Makefile byte-compile-clean pub
    # pushes to elpa workspace, builds archive

Check copyright on files in published in elpa
    c:/Projects/elpa/GNUMakefile check_copyrights
    change to FSF

Emacs 25.3, current gnat
    ~/bin/emacs-25.sh
    (add-to-list 'package-archives (cons "test" "/Projects/elpa/archive/packages"))
    build/Makefile install-elpa
    (gpr-query-kill-all-sessions)
    (list-processes)
    # 'd' = kill; gpr_mode_wisi_parse.exe, ada_mode_lr1_wisi_parse.exe
    cd ~/.emacs.d/elpa/ada-mode-6.2.0; ./build.sh
    cd ~/.emacs.d/elpa/wisi-2.2.0; ./build-wisitoken-bnf-generate.sh

    restart Emacs to set load-path

    build/Makefile compile-ada-test autoloads test-clean
    build/Makefile test TEST_DIR=elpa

    build/Makefile uninstall-elpa
    (gpr-query-kill-all-sessions)
    build/Makefile recursive-clean clean # if changing compilers

sync for Debian check bogus execute permissions:
    current Emacs for dvc
    # dvc-state-multiple above
    # not elpa; commit elpa on Debian for file permissions
    $ mtn_sync_ada_france.sh
    (dvc-sync-review ".")

Debian stable has elpa checkout
    ~/bin/mtn_sync_ada_france.sh
    (dvc-sync-review ".")

    if new machine, install gnat CE 2018, gnatcoll
        http://libre.adacore.com
        ada-mode.texi

    (dvc-pull "/Projects/elpa")
    (dvc-sync-review "/Projects/elpa")

    /Projects/org.emacs.ada-mode/build/Makefile
        # no ARM_INFO on Debian
        docs pub-ada pub-wisi clean-elpa build-elpa uninstall-elpa
        install-elpa
            # byte-compile errors, warnings show in *compile-log*

    check for bogus execute permissions in elpa
        $ cd /Projects/elpa/
        $ ls -R -l packages/ada-mode | grep -- -rwx
        $ ls -R -l packages/wisi | grep -- -rwx
        $ chmod -x *.el *.adb
        # keep execute on *.sh

    commit elpa:
    (dvc-state-one "/Projects/elpa")
        add, stage, commit ada-mode, wisi

    (dvc-push "/Projects/elpa")
    (dvc-sync-review "/Projects/elpa")

    # dvc-state-multiple above
    $ mtn_sync_ada_france.sh
    (dvc-sync-review ".")

On Windows
$ mtn_sync_ada_france.sh
(dvc-sync-review ".")

delete changes in elpa:
    $ cd /Projects/elpa/
    $ git checkout .

update elpa, commit elpa/ada-ref-man (not done on Debian)
    (dvc-pull "/Projects/elpa")
    (dvc-sync-review "/Projects/elpa")

    build/Makefile pub-ada-ref-man

    (dvc-state-one "/Projects/elpa")
        add, stage, commit

    (dvc-push "/Projects/elpa")
    (dvc-sync-review "/Projects/elpa")

    # 24 hrs for web repository to update

after Gnu ELPA updated, test install from GNU ELPA
    5.1.8 crashed emacs for me
    see 'build/Makefile install-elpa' above for details
    also wisitoken-grammar-mode

(dvc-state-one ".")
build/Makefile tag

~/bin/mtn_sync_ada_france.sh

build/Makefile zip

in cygwin console for gpg prompts:
    cd /Projects/org.emacs.ada-mode/build/
    ls *.tar*
    rm <old>.tar*
    gpg -b *.tar.bz2

    scp *.tar.* stephen_leake@dl.sv.nongnu.org:/releases/ada-mode/

~/Web/Makefile
    # no 'sync' here; all on savannah via cvs, scp
    ada-mode

commit savannah
    if emacs cvs-examine fails, do 'cvs status' in shell to see real error message (probably IP address confusion)
        # see projects.text "conflicting keys for savannah"
        $ cd /d/Web/savannah/ada-mode
        $ cvs status
        # edit ~/.ssh/known_hosts, delete offending one, repeat 'cvs status'
    (cvs-examine "d:/Web/savannah/ada-mode" nil)
    mark all 'm'
    commit   'c'
    edit commit message "release version i.j.k"
    C-c C-c

    takes ~ 10 min for http://www.nongnu.org/ada-mode/ to reflect cvs commit

post on emacs-ada-mode mailing list, c.l.a newsgroup:

-------------------
Gnu Emacs Ada mode 6.1.1 released.
-------------------
Gnu Emacs Ada mode 6.1.1 is now available in GNU ELPA. This is a minor
feature and bug fix release; partial file parsing is now supported for
`which-function-mode', and error correction is improved. See the NEWS
files in ~/.emacs.d/elpa/ada-mode-6.1.1 and wisi-2.1.1, or at
http://www.nongnu.org/ada-mode/, for more details.

The process parser requires a manual compile step, after the normal
list-packages installation:

cd ~/.emacs.d/elpa/ada-mode-6.1.1
./build.sh

This requires AdaCore gnatcoll packages which you may not have
installed; see ada-mode.info Installation for help in installing them.
--------------------

mark fixed bugs
    add to NEWS-ada-mode.text or NEWS-wisi.text when closed.
    confirm with submitter.
    http://debbugs.gnu.org/cgi/pkgreport.cgi?package=ada-mode
    http://debbugs.gnu.org/Developer.html
    email to nnn@debugs.gnu.org giving ada-mode version containing fix
    email to nnn-close@debbugs.gnu.org
    subject: 'closed by ada-mode version i.j.k'
    don't include Version: header; that's an Emacs version
    debbugs updates ada-mode summary page within half an hour; no emails

check https://www.emacswiki.org/emacs/AdaMode
    https://www.emacswiki.org/emacs/StephenLeake

-- end of file
