My notes for Java Mode Tamed : see https://stackoverflow.com/questions/tagged/cc-mode : see https://stackoverflow.com/questions/tagged/emacs+java : see https://emacs.stackexchange.com/questions/tagged/cc-mode : see https://emacs.stackexchange.com/questions/tagged/java !!+ Keyword (or whatever they call it) `yield` for switch expressions is going unfaced. : see https://openjdk.org/jeps/361 ?+ Can I simply tell the underlying Java Mode about it? !!+ Function variable declarations go unfaced. / E.g. the declaration of `b` in `beans.forEach( b -> count(b) )` \ + Report the regression. \ : see @ `^*\+ Repair fontification of text blocks\.$` @ ~/work/Java/Emacs/notes.brec \ ' Repair of misfaced type references. \\ pending OS upgrade !!+ Annotated variable declarations go unfaced. : e.g. `command` @ `Descriptor` @ non-fractal ~/work/Breccia/parser/plain/SimpleCommandPoint.java \ + Run a pre-release branch to deal with upcoming Emacs changes, viz. those appearing \ in the pre-release versions, before they hit users on the next release. \ : privately see email:2022-2-12 \ : cf. https://www.gnu.org/savannah-checkouts/gnu/emacs/emacs.html#Releases \ - Else JMT Mode is apt to break on their release, and lie broken till I happen to upgrade. \ ?+ Where can I promptly learn of new pre-releases and releases? Is there a schedule? + Make my label declarations bold. / Like a block statement keyword, as always it marks a block. + Allow distinct faces for label declaration and reference. + Start to ask for changes to CC Mode that would obviate the need of advice and monkey patches. ∵ ‘If you are writing code for release, for others to use, try to avoid including advice in it. If the function you want to advise has no hook to do the job, please talk with the Emacs developers about adding a suitable hook.’ : see https://www.gnu.org/software/emacs/manual/html_node/elisp/Advising-Named-Functions.html + Deal correctly with upper case package names. / For instance in `import Breccia.XML.translator.BrecciaXCursor`. : see ~/code/WP3/wayic/Web/imager/bin/waycast-web-image : see `Package name occuring elsewhere$` @ ~/work/Java/Emacs/jmt-mode.el method | let the user declare each during initialization / Package names `Breccia` and `Breccia.Web` for instance. | for each package segment matched, search backward to get its full name - Slower, perhaps. - Applying this method if chosen, yet acknowledging the other in a comment. | recode using an anchored highlighter - Harder to code, disrupts the present code. ━━━━━━━━━━━━━━━━━━ `assert` keyword ────────────────── - Apropos Java Mode’s omission of Java’s `assert` keyword. - JMT Mode’s workaround: - JMT Mode fontifies the keyword itself. - Also it corrects misfaced method calls, the only instance seen being one in which a method is called from within an `assert` statement. - Maybe this misfacing too would be corrected if the keyword were properly faced in the first instance. / Both bits of code refer to these notes. - Further, these repairs of underlying Java Mode variables were tested: (let* ((pattern c-simple-stmt-key) (pattern-beg "\\(\\(?:")) (if (not (string-prefix-p (concat pattern-beg "break\\|") pattern)) (jmt-message "(jmt-mode): Patch failed to apply, `c-simple-stmt-key`") (setq pattern (substring pattern (length pattern-beg)) pattern (concat pattern-beg "assert\\|" pattern)) (jmt-set-for-buffer 'c-simple-stmt-key pattern))) (let* ((pattern c-regular-keywords-regexp) (pattern-beg "\\(\\(?:")) (if (not (string-prefix-p (concat pattern-beg "@interface\\|") pattern)) (jmt-message "(jmt-mode): Patch failed to apply, `c-regular-keywords-regexp`") (setq pattern (substring pattern (length pattern-beg)) pattern (concat pattern-beg "assert\\|" pattern)) (jmt-set-for-buffer 'c-regular-keywords-regexp pattern))) - Tested as part of in-buffer initialization. - But the repair to `c-regular-keywords-regexp` comes too late to affect the value which Java Mode uses to initialize *c-lang-const* `c-basic-matchers-before`, which in turn appears in `font-lock-keywords`. - Neither of these seems feasible to repair after the fact. - The resulting `font-lock-keywords` contains unfamiliar forms, which might be inaccessible to me. - And `c-basic-matchers-before` is entirely inaccessible, my attempts to access it via `c-lang-const` resulting in inexplicable errors. - Maybe putting that code into one of CC Mode’s early-run hooks would work. / But now I have spent too much time working around what could more easily be redressed by a bug report to CC Mode. ━━━━━━ Bugs ────── ! ‘c-invalidate-sws-region-after: Args out of range: 1, 1631’ - Seen while pasting then editing a multi-line `/* … */` comment. / 2021-4 ! ‘Args out of range’ error in `c-remove-stale-state-cache-backwards`. / see `/usr/share/emacs/29.3/lisp/progmodes/cc-engine.el` / c-remove-stale-state-cache-backwards: Args out of range: 1, 2935Error during redisplay: (jit-lock-function 2789) signaled (args-out-of-range 1 2935) Error during redisplay: (jit-lock-function 1912) signaled (args-out-of-range 1 2935) - Seen while editing within the brace delimiters of a Java conditional, 2020-11-6. : see ~/work/Breccia/Web/imager/ImageMould.java - Directly after the changes of revisions 200c0eb0 and 8ff45cd6. - Inspections of those changes and the changed code reveal no apparent fault. - Function `c-remove-stale-state-cache-backwards` has a single caller in `c-parse-state-1`. / see `/usr/share/emacs/29.3/lisp/progmodes/cc-engine.el` - Much later, a similar error while cutting (killing) a field declaration complete with an API description, near the end of the buffer. : see ~/work/Breccia/parser/plain/BrecciaCursor.java /** The leading characters of the next head, up to the first non-space character (20), inclusive. * It is null at parse state `DocumentEnd`. * *
Beware of it swapping with `head` as reading progresses.
*/ private StringBuilder headSuccessor = new StringBuilder( /*initial capacity*/400 ); / 2020-12-12, when debug-on-error happened to be enabled. Package `app-editors/emacs-26.3-r1:26`. Debugger entered--Lisp error: (args-out-of-range 965 1403) c-state-balance-parens-backwards(1208 1208 1403) c-remove-stale-state-cache-backwards(1208) c-parse-state-1() c-parse-state() c-syntactic-skip-backward("^;{}" 440 t) c-fl-decl-start(1439) c-change-expand-fl-region(1077 1077 331) #f(compiled-function (fn) #