The conversion to `lexical-binding` introduced a regression because
`bovine/c.el` relied on inspecting the local variable `lse` in one of
its callers.
(semantic-bovinate-stream): Bind `lse` dynamically, because of
`semantic-parse-region-c-mode`.
(semantic-bovinate-nonterminal-check-map): Rename from
`semantic-bovinate-nonterminal-check-obarray` to hold some other kind
of table.
(semantic-bovinate-nonterminal-check): Use a hash-table instead of an obarray.
* lisp/cedet/semantic/bovine/c.el (semantic-parse-region-c-mode):
Declare use of `lse` via dynamic scoping.
Stefan Monnier [Mon, 8 Mar 2021 00:00:47 +0000 (19:00 -0500)]
* lisp/emacs-lisp/bytecomp.el: Warn about unprefixed vars in `boundp`
(byte-compile--check-prefixed-var): New fun,
extracted from `byte-compile--declare-var`.
(byte-compile--declare-var): Use it.
(byte-compile-maybe-guarded): Use it as well.
Juri Linkov [Sun, 7 Mar 2021 18:52:39 +0000 (20:52 +0200)]
Remove outline-cycle-minor-mode and outline-cycle-highlight-minor-mode
* lisp/outline.el (outline-font-lock-keywords): Use OVERRIDE or
LAXMATCH depending on outline-minor-mode-highlight in outline-minor-mode.
(outline-minor-mode-cycle, outline-minor-mode-highlight): Promote
defvar to defcustom.
(outline-minor-mode-highlight-buffer): Don't override existing faces.
(outline-cycle-minor-mode, outline-cycle-highlight-minor-mode):
Remove minor modes.
* etc/compilation.txt:
* etc/grep.txt: Enable outline-minor-mode-cycle and
outline-minor-mode-highlight with outline-minor-mode.
https://lists.gnu.org/archive/html/emacs-devel/2021-03/msg00144.html
* lisp/subr.el (string-replace): Signal an error with data that is a
list, and whose contents are consistent with other uses of
wrong-length-argument.
* test/lisp/subr-tests.el (string-replace): Test for this.
(subr-test-define-prefix-command): Pacify byte-compiler warnings.
Stefan Monnier [Sun, 7 Mar 2021 06:58:16 +0000 (01:58 -0500)]
* lisp/cedet/semantic/wisent: Use lexical-binding
* lisp/cedet/semantic/wisent/comp.el: lexical-binding.
(wisent-defcontext): Make sure the vars are also dynbound in the files
that `require` us.
(wisent-state-actions, wisent-automaton-lisp-form): Use `obarray-make`.
(wisent--compile-grammar): Rename from `wisent-compile-grammar`.
(wisent-compile-grammar): Redefine as an obsolete function.
(wisent-automaton-lisp-form): Avoid variable `state`.
* lisp/cedet/semantic/grammar.el: Use lexical-binding.
(semantic-grammar-require-form): New var.
(semantic-grammar-header): Use it to provide new element `require-form`.
(semantic-grammar-header-template): Use it.
* lisp/cedet/semantic/wisent.el (wisent-compiled-grammar): New macro.
* lisp/cedet/semantic/wisent/grammar.el (wisent-grammar-parsetable-builder):
Use it in the generated code instead of the `wisent-compile-grammar` function.
(wisent-grammar-mode): Set `semantic-grammar-require-form` so
the generated ELisp files require `semantic/wisent` rather than
`semantic/bovine`.
* lisp/cedet/semantic/wisent/wisent.el: Use lexical-binding.
* lisp/cedet/semantic/wisent/java-tags.el: Use lexical-binding.
* lisp/cedet/semantic/wisent/python.el: Use lexical-binding.
* lisp/cedet/semantic/wisent/javascript.el: Use lexical-binding.
(semantic-ctxt-current-symbol): Remove unused var `symlist`.
* admin/grammars/python.wy (wisent-python-EXPANDING-block):
Declare dynbound var.
Stefan Monnier [Sun, 7 Mar 2021 03:33:19 +0000 (22:33 -0500)]
* lisp/cedet/semantic/bovine/*.el: Use lexical-binding
* lisp/cedet/semantic/bovine/c.el: Use lexical-binding.
(semantic-lex-cpp-define): Remove unused var `name`.
(semantic-c-do-lex-if): Remove unused var `pt`.
(semantic-analyze-tag-references): Remove unused var `refs`.
(semantic-c-dereference-namespace): Remove unused vars `tmp` and
`usingname`.
(semantic-c-dereference-namespace-alias): Remove unused var `newtype`.
(semantic-c-check-type-namespace-using): Remove unused vars `tmp` and
`shortname`.
(semanticdb-find-table-for-include): Remove unused var `prefix`.
(semantic-default-c-setup, semantic-c-describe-environment):
Use `derived-mode-p`.
* lisp/cedet/semantic/bovine/debug.el: Use lexical-binding.
* lisp/cedet/semantic/bovine/make.el: Use lexical-binding.
* lisp/cedet/semantic/bovine/scm.el: Use lexical-binding.
* lisp/cedet/semantic/lex.el (define-lex-analyzer): Define the var (and
the function) in a single step.
Glenn Morris [Sat, 6 Mar 2021 19:09:19 +0000 (11:09 -0800)]
Don't pass implicit flags to sub-makes
* Makefile.in (info_misc, uninstall, texi_misc):
Don't pass any implicit make flags to sub-makes.
Ref https://lists.gnu.org/r/help-make/2021-03/msg00007.html
This replaces most json-encode-* functions with similar
json--print-* counterparts that insert into the current buffer
instead of returning a string (bug#46761).
Some unused but useful json-encode-* functions are kept for backward
compatibility and as a public API, and the rest are deprecated.
* etc/NEWS: Announce obsoletions.
* lisp/json.el: Document organization of library. Make subsection
headings more consistent.
(json--encoding-current-indentation): Rename...
(json--print-indentation-prefix): ...to this, to reflect new use.
(json--encode-stringlike, json--encode-alist): Rename...
(json--print-stringlike, json--print-alist): ...to these,
respectively, and encode argument into current buffer instead. All
callers changed.
(json--print-string, json--print-unordered-map, json--print-array)
(json--print): New functions.
(json-encode-string, json-encode-plist, json-encode-array)
(json-encode): Use them, respectively.
(json-encode-number, json-encode-hash-table): Mark as obsolete
aliases of json-encode.
(json-encode-key, json-encode-list): Mark as obsolete in preference
for json-encode.
(json--print-indentation-depth, json--print-keyval-separator): New
variables.
(json--with-output-to-string): New macro.
(json--print-indentation, json--print-keyword, json--print-key)
(json--print-pair, json--print-map, json--print-list): New
functions.
(json--with-indentation): Use json--print-indentation-depth to avoid
unnecessary string allocation.
(json-encoding-default-indentation, json-pretty-print-max-secs):
Clarify docstrings.
(json--escape, json--long-string-threshold, json--string-buffer):
Remove; no longer used.
* lisp/progmodes/js.el (js--js-encode-value): Replace
json-encode-string and json-encode-number with json-encode.
(js-eval-defun): Use json--print-list to avoid
json-encode-list->insert roundtrip.
* test/lisp/json-tests.el (test-json-encode-number)
(test-json-encode-hash-table, test-json-encode-hash-table-pretty)
(test-json-encode-hash-table-lisp-style)
(test-json-encode-hash-table-sort, test-json-encode-list): Replace
uses of obsolete functions with the equivalent use of json-encode.
(test-json-encode-key): Suppress obsoletion warnings.
(test-json-encode-string): Check that text properties are stripped.
Stefan Monnier [Sat, 6 Mar 2021 18:03:12 +0000 (13:03 -0500)]
* lisp/emulation/: Use lexical-binding
* lisp/emulation/cua-base.el: Use lexical-binding.
Remove redundant `:group` arguments.
(cua-mode): Don't use `:require` since the autoload on `define-minor-mode`
takes care of loading the mode when custom-setting it.
* lisp/emulation/cua-gmrk.el: Use lexical-binding.
(cua--copy-rectangle-to-global-mark): Remove unused var `src-buf`.
* lisp/emulation/edt-mapper.el: Use lexical-binding.
* lisp/emulation/edt.el: Use lexical-binding.
Remove redundant `:group` arguments.
(edt-with-position): Allow `top`, `left`, and `far` to be left unused
in `body`.
* lisp/emulation/keypad.el: Use lexical-binding.
* lisp/emulation/viper-cmd.el: Move `provide` to the end.
(viper-read-string-with-history): Strength reduce `eval` to `symbol-value`.
* lisp/emulation/viper-ex.el: Use lexical-binding.
Remove redundant `:group` arguments.
Move `provide` to the end.
* lisp/emulation/viper-init.el: Use lexical-binding.
* lisp/emulation/viper-keym.el (viper-toggle-key): Use `dolist`.
(viper-insert-diehard-map): Use `string`.
(viper-modify-major-mode): Use `alist-get` and `setf`.
* lisp/emulation/viper-macs.el (viper-ex-work-buf):
Move `provide` to the end.
(viper-record-kbd-macro): Strength reduce `eval` to `symbol-value`.
(viper-describe-kbd-macros): Return value is not significant.
(viper-keyseq-is-a-possible-macro): Use `seq-some`.
(viper-common-seq-prefix): Use `seq-every-p`.
* lisp/emulation/viper-mous.el: Use lexical-binding.
Remove redundant `:group` arguments.
Move `provide` to the end.
(viper-remember-current-frame): Accept arbitrary ignored args.
(viper-parse-mouse-key): Strength reduce `eval` to `symbol-value`.
Remove unused var `key-spec`.
(viper-bind-mouse-search-key, viper-bind-mouse-insert-key):
Apply de Morgan.
* lisp/emulation/viper-util.el: Move `provide` to the end.
(viper-move-marker-locally, viper-push-onto-ring, viper-save-setting):
Strength reduce `eval` to `symbol-value`.
(viper-event-vector-p, viper-char-symbol-sequence-p, viper-char-array-p):
Use `seq-every-p`.
* lisp/emulation/viper.el (viper-non-hook-settings): Eta-reduce use of
`viper-remember-current-frame`.
(test-map-elt): Test array key that is within bounds but not fixnum.
(test-map-put!): Use map--plist-p. Remove redundant tests.
(test-map-put-alist-new-key): Don't modify list literal.
(test-map-put-testfn-alist, test-map-put-return-value): Silence
obsoletion warnings.
(test-map-delete): Check for OBOE on arrays.
(test-map-delete-return-value): Remove test made redundant by
test-map-delete.
(test-map-nested-elt, test-map-into): Test plists too.
Alan Mackenzie [Sat, 6 Mar 2021 15:22:25 +0000 (15:22 +0000)]
CC Mode: Fix calculation of c-parse-state when there're macros with braces
This fixes bug #46951.
* lisp/progmodes/cc-engine.el (c-append-lower-brace-pair-to-state-cache):
Ensure the starting point for backward scanning is not within a macro which
doesn't contain HERE.
* lisp/cedet/semantic/tag.el (semantic-tag-make-plist): Define
before its first use to pacify some recent "may not be defined at
runtime" warnings after turning on lexical-binding.
Remove mention of using defun- and defvar- as prefixes
* doc/lispref/tips.texi (Coding Conventions): Remove mention of
using defun- and defvar- as prefixes, as this is something that we
rarely do in Emacs (bug#46899).
* doc/misc/modus-themes.org: Add new version of the manual, with
changes to markup and references to the latest state of the project.
* etc/themes/modus-vivendi-theme.el:
* etc/themes/modus-operandi-theme.el: Provide updated version of each
theme, which expands the contents of 'modus-themes.el' (bug#45068).
* etc/themes/modus-themes.el: Add new supportive file. This is where
theme data, functions, and face definitions are defined.
* lisp/cedet/semantic/bovine.el: Use lexical-binding.
(semantic-lambda): Silence warnings if the `vals` arg is not used.
* lisp/cedet/semantic/grammar-wy.el: Re-generate.
* lisp/cedet/semantic/bovine/grammar.el: Use lexical-binding.
(bovine-grammar-expand-action): Silence warnings if some of the
`vals`, `start`, or `end` args is not used.
(bovine--make-parser-1): Use lexical-binding in the generated files.
* lisp/cedet/semantic/wisent/grammar.el: Use lexical-binding.
(wisent--make-parser-1): Use lexical-binding in the generated files.
Stefan Monnier [Sat, 6 Mar 2021 00:56:31 +0000 (19:56 -0500)]
Bindat: new macro-expansion based data layout language
Thorough redesign of the Bindat system, which makes it possible
to define new Bindat type forms, define recursive types, control
the values returned when unpacking, freely mix arbitrary computations
with type definitions, as well as support for arbitrary sized
integers.
This also reverts the recent addition of the `bindat-spec` macro and
the support for 64bit integers in the old Bindat language since that
is now considered obsolete anyway.
* doc/lispref/processes.texi (Bindat Types): Rename from `Bindat Spec`
and rewrite for the new sublanguage.
(Bindat Functions): Adjust to the new terminology.
(Bindat Computed Types): New node.
* lisp/emacs-lisp/bindat.el (bindat--type): New type.
(bindat--unpack-u64, bindat--unpack-u64r): Delete functions.
(bindat--unpack-item, bindat--pack-item, bindat--fixed-length-alist):
Revert addition of support for 64bit integers.
(bindat--unpack-group, bindat--length-group, bindat--pack-group):
Handle the new `bindat--type` values.
(bindat-spec): Revert addition of this macro.
(bindat--unpack-uint, bindat--unpack-uintr, bindat--pack-uint)
(bindat--pack-uintr): New functions.
(bindat-type, bindat-defmacro, bindat--pcase): New macros.
(bindat-type): New Edebug elem.
(bindat--type): New generic function.
(bindat--primitives): New constant.
(bindat--macroenv, bindat--op): New vars.
(bindat--make-docstring, bindat--fun, bindat--makefun, bindat--toplevel):
New functions.
* test/lisp/emacs-lisp/bindat-tests.el: Use `bindat-type`.
(ip): New Bindat type.
(header-bindat-spec, data-bindat-spec, packet-bindat-spec): Adjust to
new `bindat-type` macro.
(bindat-test-unpack): Simplify now that the order of fields is preserved.
(bindat-test--int-websocket-type, bindat-test--LEB128): New consts.
(bindat-test--pack-val, bindat-test--sint, bindat-test--recursive):
New tests.
Stefan Monnier [Fri, 5 Mar 2021 18:31:16 +0000 (13:31 -0500)]
* lisp/emacs-lisp/bindat.el: Minor refactoring
(bindat--unpack-str, bindat--unpack-strz, bindat--unpack-bits):
New functions, extracted from `bindat--unpack-item`.
(bindat--unpack-item): Use them.
(bindat--align): New function.
(bindat--unpack-group, bindat--length-group, bindat--pack-group): Use it.
(bindat-get-field): Allow integers to index both lists (as returned by
`repeat`) and vectors (as returned by `vec`).
(bindat--pack-str, bindat--pack-bits): New functions, extracted from
`bindat--pack-item`.
(bindat--pack-item): Use them.
* test/lisp/emacs-lisp/bindat-tests.el (struct-bindat): Place the fields
in the order in which they appear in the structs.
Stephen Berman [Fri, 5 Mar 2021 13:08:17 +0000 (14:08 +0100)]
Restrict the version guesser to top-level headings
* lisp/help-fns.el (help-fns--first-release): Restrict the version
guesser to top-level section -- looking in all headings leads to
false positives (bug#46889).
* lisp/custom.el (require-theme): Open-code 'require' error, because
binding load-path can prevent other libraries from loading on error,
such as debug.el, which gives a misleading error. (Bug#45068)
Mauro Aranda [Thu, 4 Mar 2021 11:34:58 +0000 (08:34 -0300)]
Make checkdoc work with qualified methods
* lisp/emacs-lisp/checkdoc.el (checkdoc--next-docstring): Handle
cl-defmethod in a case of its own. Check for the presence of
qualifiers, and skip them accordingly until the docstring.
* test/lisp/emacs-lisp/checkdoc-tests.el (checkdoc-cl-defmethod-qualified-ok)
(checkdoc-cl-defmethod-with-extra-qualifier-ok)
(checkdoc-cl-defmethod-with-extra-and-nil-args-ok): Add tests for the fix.
* lisp/custom.el (require-theme): Refashion after 'require', as a
function for loading only named features. Do not call
load-theme (bug#45068).
* etc/NEWS: Update its announcement accordingly.
* doc/lispref/customize.texi (Custom Themes): Document it.
* etc/themes/modus-operandi-theme.el:
* etc/themes/modus-vivendi-theme.el: Remove redundant calls to
'provide'.
* test/lisp/custom-tests.el (custom-tests--with-temp-dir): New
macro.
(custom-theme--load-path): Use it.
(custom-tests-require-theme): New test.
Mauro Aranda [Thu, 4 Mar 2021 13:13:26 +0000 (10:13 -0300)]
Remove duplicated tests in checkdoc-tests.el
* test/lisp/emacs-lisp/checkdoc-tests.el (checkdoc-cl-defmethod-ok)
(checkdoc-cl-defmethod-with-types-ok, checkdoc-cl-defun-with-key-ok)
(checkdoc-cl-defun-with-allow-other-keys-ok)
(checkdoc-cl-defun-with-default-optional-value-ok)
(checkdoc-cl-defun-with-destructuring-ok): This tests were duplicated,
so keep one copy of them. Checked by diffing two files with the
suspected tests, and supported by the fact that running occur with the
regexp "^(ert-deftest" reported 14 matches, while the tests being run
were 8.
Juri Linkov [Wed, 3 Mar 2021 19:12:13 +0000 (21:12 +0200)]
New mode outline-cycle-minor-mode with Orgmode-like TAB cycling on headings
* lisp/outline.el (outline-mode-cycle-map): New keymap from outline-mode-map.
(outline-mode-map): Inherit from outline-mode-cycle-map.
(outline-font-lock-keywords): Append keymap and face depending on
'outline-minor-mode-cycle' and 'outline-minor-mode-highlight'.
(outline-minor-mode-cycle, outline-minor-mode-highlight): New variables.
(outline-minor-mode-highlight-buffer): New function.
(outline-minor-mode): Handle 'outline-minor-mode-cycle' and
'outline-minor-mode-highlight'.
(outline-cycle-minor-mode, outline-cycle-highlight-minor-mode):
New minor modes (bug#45147).
Alan Mackenzie [Tue, 2 Mar 2021 20:31:36 +0000 (20:31 +0000)]
CC Mode: Fix analysis of brace lists, particularly in C++ Mode
Fix some alignment functionality in cc-align.el.
* lisp/progmodes/cc-align.el (c-lineup-arglist-intro-after-paren): Align the
next line under the previous entry rather than one to the right of the paren.
(c-lineup-2nd-brace-entry-in-arglist): Take the anchor point from the
brace-list-entry element, not the brace-list-intro one.
* lisp/progmodes/cc-engine.el (c-looking-at-decl-block): Use
c-looking-at-statement-block to test whether "struct A {" begins a brace list
or a struct declaration.
(c-looking-at-or-maybe-in-bracelist): Several detailed amendments, correctly
to recognize brace lists.
(c-looking-at-statement-block): No longer search for commas, as they are not
reliable indicators of a brace list. Search now for a restricted set of
keywords, since some can appear in brace lists in C++ mode.
* lisp/progmodes/cc-langs.el (c-stmt-block-only-keywords)
(c-stmt-block-only-keywords-regexp): New lang consts/vars.
(c-pre-id-bracelist-kwds): New lang const.
(c-pre-id-bracelist-key): Derive now from the above.
(c-pre-brace-non-bracelist-key): New lang const/var.
Pip Cet [Sun, 28 Feb 2021 19:43:09 +0000 (19:43 +0000)]
Compile closures that modify their bound vars correctly (Bug#46834)
* lisp/emacs-lisp/bytecomp.el (byte-compile--reify-function): Don't
move let bindings into the lambda. Don't reverse list of
bindings. (byte-compile): Evaluate the return value if it was
previously reified.
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-reify-function):
Add tests.
Stefan Monnier [Tue, 2 Mar 2021 04:57:34 +0000 (23:57 -0500)]
* lisp/emacs-lisp/pcase.el: Bind all the vars in `or` patterns
Improve the handling of `or` patterns where not all sub-patterns bind the
same set of variables. This used to be "unsupported" and behaved in
somewhat unpredictable ways.
* doc/lispref/control.texi (pcase Macro): Adjust accordingly.
Also remove the warning about "at least two" sub patterns.
These work fine, AFAICT, and if not we should fix it.
* test/lisp/emacs-lisp/pcase-tests.el (pcase-tests-or-vars): New test.
Stefan Monnier [Mon, 1 Mar 2021 20:35:51 +0000 (15:35 -0500)]
* lisp/emacs-lisp/pcase.el: Fix bug#46786
Revert commit a218c9861573b5ec4979ff2662f5c0343397e3ff, but in order
to avoid the spurious warnings that this commit tried to squash,
keep track of the vars used during the match so as to add
corresponding annotations to explicitly silence the spurious warnings.
To do this, we change the VARS used in `pcase-u` (and throughout
the pcase code): they used to hold elements of the form (NAME . VAL)
and now they hold elements of the form (NAME VAL . USED).
(pcase--expand): Bind all vars instead of only those found via fgrep.
(pcase-codegen): Silence "unused var" warnings for those vars that have
already been referenced during the match itself.
(pcase--funcall, pcase--eval): Record the vars that are used.
(pcase--u1): Record the vars that are used via non-linear patterns.
Fix incorrect variable scoping in `let*`, `for` and `foreach`.
Fix loop variable value in `foreach` (should be element, not tail).
Fix function quoting, as in ('cons x y) -- didn't work at all.
Reported by Stephan Neuhaus.
* lisp/calc/calc-prog.el (math-define-exp, math-handle-foreach):
* test/lisp/calc/calc-tests.el: (var-g, test1, test2, test3, test4)
(test5, test6, test7, calc-defmath): Test various defmath forms.
* doc/misc/calc.texi: Remove references to the old Calc representation
of big integers, outdated references to fixnums, an any text and
examples that only made sense at the time.
* etc/NEWS: Document new function.
* lisp/custom.el (require-theme): Add function.
This follows from the discussion on bug#45068 where it became apparent
that there was no equivalent mechanism to 'require' that read through
the 'custom-theme-load-path'.
Alan Mackenzie [Mon, 1 Mar 2021 19:23:01 +0000 (19:23 +0000)]
CC Mode: Amend C-M-a/e to handle lambda function in C++ arglist
* lisp/progmodes/cc-cmds.el (c-where-wrt-brace-construct): Reformulate latter
part such that the least enclosing braces and parentheses are used when
determining containment in such. c-beginning-of-decl-1 has been superseded
by list movement and syntactic whitespace movement.
(c-backward-to-nth-BOF-{): Work on least enclosing parens rather than parens
at any level when moving back to an opening brace.
(c-forward-to-nth-EOF-\;-or-}): Work on least enclosing parens, as above.
Move the correction of point when in a "function trailer" to after the main
loop, correcting a minor bug.