1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 14:30:50 -08:00
Commit graph

10421 commits

Author SHA1 Message Date
Mattias Engdegård
8ad494fc76 Fix peephole optimiser bug for symbolp
* lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode):
Don't sink 'symbolp' past 'unbind'; it's unsafe.
2025-10-24 17:33:03 +02:00
Mattias Engdegård
0ccc246465 Move some constants into the peephole optimiser
* lisp/emacs-lisp/byte-opt.el (byte-tagref-ops, byte-conditional-ops)
(byte-after-unbind-ops, byte-compile-side-effect-and-error-free-ops)
(byte-compile-side-effect-free-ops):
Move into the constant pool...
* lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode): ...here,
bringing comments up to date.
2025-10-24 16:34:49 +02:00
Mattias Engdegård
c2b23a04c2 Sink calls to byte-compile-warning-enabled-p
* lisp/emacs-lisp/bytecomp.el (byte-compile--check-arity-bytecode)
(byte-compile-warn-about-unresolved-functions, byte-compile-form)
(byte-compile-free-vars-warn):
Delay checking whether a warning is enabled until we are about to emit
such a warning, since most warnings are enabled most of the time but
finding something to warn about is rare.
2025-10-23 17:53:10 +02:00
Stefan Monnier
287fb2fbad (custom-initialize-after-file): New function
Some global minor modes require initialization.  Those that are preloaded
currently abuse `custom-initialize-delay` for that, but it's suboptimal
and doesn't help those that aren't preloaded.
So introduce a new function to fill that need.
While at it, make `define-globalized-minor-mode` use it
automatically when useful.

* lisp/custom.el (custom-initialize-after-file-load): New function.
* lisp/tooltip.el (tooltip-mode):
* lisp/paren.el (show-paren-mode):
* lisp/rfn-eshadow.el (file-name-shadow-mode):
* lisp/epa-hook.el (auto-encryption-mode):
* lisp/minibuffer.el (minibuffer-regexp-mode, minibuffer-nonselected-mode):
* lisp/electric.el (electric-indent-mode): Use it instead of
`custom-initialize-delay` since the value does not depend on the
runtime context.
(electric-quote-mode): Don't use `custom-initialize-delay` since
the default value is nil anyway.

* lisp/emacs-lisp/easy-mmode.el (define-globalized-minor-mode):
Automatically add `:initialize` if needed.
* lisp/emacs-lisp/eldoc.el (global-eldoc-mode): Remove `:initialize`,
now provided automatically.

* doc/lispref/customize.texi (Variable Definitions):
* doc/lispref/modes.texi (Defining Minor Modes): Document and Suggest
`custom-initialize-after-file-load` instead of `custom-initialize-delay`.
2025-10-22 17:12:10 -04:00
Stefan Monnier
698a584e92 (define-globalized-minor-mode): Remove MODE-mode-name hack (bug#79624)
Stop trying to detect when a globalized mode enabled its
minor mode "too early".  This reverts the core of commit 876daebc85
since the problem it tried to circumvent has been made almost impossible
by commit 17e26cf57e.

* lisp/emacs-lisp/easy-mmode.el (define-globalized-minor-mode):
Remove the `MODE-mode-name` variable, don't remember in which major
mode we enabled the minor mode, and don't disable the minor mode
before (re)enabling it.
2025-10-21 15:35:36 -04:00
Eshel Yaron
9f35d1653f
; elisp-scope.el: Fix error during widget args analysis
* lisp/emacs-lisp/elisp-scope.el (elisp-scope--match-spec-to-arg):
Simplify and fix handling of empty list.

* test/lisp/progmodes/elisp-mode-resources/semantic-highlighting.el:
Add test.
2025-10-21 16:18:24 +02:00
Eshel Yaron
93dcc342a5
; Simplify symbol role ':help' functions.
* lisp/progmodes/elisp-mode.el
(elisp--annotate-symbol-with-help-echo): Take SYM argument
instead of DEF.  Apply ':help' function partially with SYM
instead of calling it.

* lisp/emacs-lisp/elisp-scope.el: Adapt ':help' functions.
2025-10-21 16:18:23 +02:00
Eshel Yaron
bb54174c21
; Fix semantic highlighting in presence of shorthands
So far, 'scope-elisp-analyze-form' would disable
'read-symbol-shorthands' while reading a source form in
order to obtain the "original" length of symbols and pass
that length to the callback called for each analyzed symbol.
However, 'scope-elisp-analyze-form' could report an
incorrect length when a symbol was written with redundant
escaping (e.g. 'f\oo').  Moreover, disabling
'read-symbol-shorthands' breaks macro-expansion during
analysis, because macros may expect "expanded" symbols,
without shorthands.

In this commit we address these issues by leaving
'scope-elisp-analyze-form' enabled (so we get expended
symbols for macro-expansion) and recovering the original
length lazily in the callback, if needed, by going to the
beginning of the symbol and searching forward for its end.

* lisp/emacs-lisp/elisp-scope.el (elisp-scope--report):
Replace LEN argument with SYM, the analyzed symbol itself.
Adapt all callers.
(elisp-scope-analyze-form): Cease let-binding
'read-symbol-shorthands' to nil while reading.  Wrap
analysis in 'save-excursion' when reading from current
buffer.  Update docstring.
* lisp/progmodes/elisp-mode.el (elisp-local-references)
(elisp-fontify-symbol): Obtain symbol length from buffer.

* test/lisp/progmodes/elisp-mode-resources/semantic-highlighting.el:
Add test that incorporates 'read-symbol-shorthands'.
* test/lisp/progmodes/elisp-mode-tests.el (elisp-test-font-lock):
Set up 'read-symbol-shorthands' in test file.
2025-10-21 16:12:11 +02:00
Mattias Engdegård
bcc88bc5c2 Use 'any' and 'all' to simplify parts of the byte-compiler
* lisp/emacs-lisp/byte-opt.el (byte-opt--nary-comparison)
(byte-optimize-constant-args, byte-optimize-member)
(byte-optimize-append):
* lisp/emacs-lisp/bytecomp.el (byte-compile-warnings)
(byte-compile-out-toplevel):
* lisp/emacs-lisp/cconv.el (cconv-convert):
Replace various hand-written 'any' and 'all' expressions with
calls to the new functions, for readability and speed.
2025-10-21 13:20:04 +02:00
Mattias Engdegård
4a39e46d9c * lisp/emacs-lisp/shortdoc.el: Add take-while, drop-while, any, all. 2025-10-21 13:19:08 +02:00
Mattias Engdegård
3179f3aba0 ; * lisp/emacs-lisp/rx.el (rx--foldl): Replace with 'all' and 'any'. 2025-10-20 12:55:19 +02:00
Stefan Monnier
4ec24ce2a1 (eval-and-compile): Preserve the surrounding lexical context
Implement a better fix for bug#79634.

* lisp/emacs-lisp/byte-run.el (eval-and-compile):
* lisp/emacs-lisp/bytecomp.el (byte-compile-initial-macro-environment)
<eval-and-compile>: Preserve the surrounding lexical context (the part
available during macroexpansion, i.e. which vars are dynbound).

* lisp/emacs-lisp/rx.el (<pcase> rx): Remove workaround.

* test/lisp/emacs-lisp/macroexp-tests.el
(macroexp--dynbound-eval-and-compile): New test.
2025-10-18 17:45:07 -04:00
Alan Mackenzie
97b960ec6d Fix coding error in byte-run--strip-vector/record
* lisp/emacs-lisp/byte-run.el (byte-run--strip-vector/record):
Replace a symbol with position by its bare symbol, rather
than returning it unchanged.
2025-10-18 17:08:02 +00:00
Lin Sun
1eeadd1f14 Remove directory of deleted package from `load-path'
* lisp/emacs-lisp/package.el (package--delete-directory): Remove
the directory of the to-be-deleted package `load-path'.  Doc
fix.  (Bug#79597)
2025-10-18 12:10:58 +03:00
Stefan Monnier
ce7f2b93bb lisp/emacs-lisp/rx.el (<pcase> rx): Workaround for bug#79634 2025-10-17 15:53:18 -04:00
Sean Whitton
ba8752cae9 Replace recent fix for vc-auto-revert-mode autoload problem
* lisp/emacs-lisp/easy-mmode.el (define-globalized-minor-mode):
Wrap references to MODE-variable in bound-and-true-p.
* lisp/vc/vc-hooks.el (auto-revert-mode): Restore to compilation
declaration only.
2025-10-17 15:06:11 +01:00
Eshel Yaron
888a910bc9
; elisp-scope.el: Standardize copyright notice.
Suggested by Arash Esbati <arash@gnu.org>.
2025-10-16 19:21:09 +02:00
Eshel Yaron
cb4d9efbd4
; elisp-scope.el: Rename some private symbols as such
Also add a few missing docstrings.

* lisp/emacs-lisp/elisp-scope.el (elisp-scope-symbol-role-p)
(elisp-scope-read-symbol-role, elisp-scope-special-variables)
(elisp-scope-let, elisp-scope-let*): Add docstring.
(elisp-scope-counter, elisp-scope-callback)
(elisp-scope-current-let-alist-form, elisp-scope-local-new)
(elisp-scope-sym-pos, elisp-scope-sym-bare)
(elisp-scope-report, elisp-scope-special-variable-p)
(elisp-scope-let-1, elisp-scope-variable)
(elisp-scope-binding, elisp-scope-symbol): Rename, replace
'elisp-scope-' prefix with 'elisp-scope--' to indicate that
these are private.  Update all references.
2025-10-15 21:41:22 +02:00
Stefan Monnier
8c19b71660 (rx): Remove the rx--pcase-expand middle man
* lisp/emacs-lisp/rx.el (rx): Remove the `rx--pcase-expand` middle man,
now that `loaddefs-gen.el` expands the `pcase-defmacro` for us.
2025-10-14 11:58:08 -04:00
Stefan Monnier
171c7fd6df (define-minor-mode): Update global-minor-modes if init-value is non-nil
When a global minor mode is enabled by init-value rather than by
calling the major mode function, we failed to register it in
`global-minor-modes` (bug#79518).

* lisp/emacs-lisp/easy-mmode.el (define-minor-mode): Register
ourselves in `global-minor-modes` at top-level for global modes
with a non-nil init-value.
Also in the `modefun`, simply the code with `not` and `add-to-list`
and consolidate the local/global paths to update `*-minor-modes`.

* lisp/simple.el (global-minor-modes): Move to...
* lisp/subr.el (global-minor-modes): ...here so it's defined early enough
for `auto-compression-mode` to register itself.
2025-10-14 11:47:05 -04:00
Sean Whitton
7e38562bcd ; Fix recently introduced uses of "ELisp". 2025-10-13 16:37:40 +01:00
Eli Zaretskii
00b92cd932 ; Improve documentation of semantic highlighting
* lisp/progmodes/elisp-mode.el (elisp)
(elisp-fontify-semantically, elisp-symbol-at-mouse)
(elisp-free-variable, elisp-special-variable-declaration)
(elisp-condition, elisp-major-mode-name, elisp-face)
(elisp-symbol-role, elisp-symbol-role-definition)
(elisp-function, elisp-non-local-exit, elisp-unknown-call)
(elisp-macro, elisp-special-form, elisp-throw-tag)
(elisp-feature, elisp-rx, elisp-theme, elisp-binding-variable)
(elisp-bound-variable, elisp-shadowing-variable)
(elisp-shadowed-variable, elisp-variable-at-point)
(elisp-warning-type, elisp-function-property-declaration)
(elisp-thing, elisp-slot, elisp-widget-type, elisp-type)
(elisp-group, elisp-nnoo-backend, elisp-ampersand)
(elisp-constant, elisp-defun, elisp-defmacro, elisp-defvar)
(elisp-defface, elisp-icon, elisp-deficon, elisp-oclosure)
(elisp-defoclosure, elisp-coding, elisp-defcoding)
(elisp-charset, elisp-defcharset, elisp-completion-category)
(elisp-completion-category-definition, elisp-add-help-echo)
(elisp-fontify-symbol-precedence-function): Add :version tags.

* lisp/emacs-lisp/elisp-scope.el: Fix references to meta-syntactic
variables in the commentary.
(elisp-scope-describe-symbol-role, coding, defcoding, charset)
(defcharset): Doc fixes.
(elisp-scope-safe-macros): Add :version tag.  Doc fix.

* doc/emacs/display.texi (Semantic Font Lock): Fix punctuation and
wording, improve cross-references and indexing.
2025-10-13 11:32:23 +03:00
Eshel Yaron
0816864231
Merge branch 'feature/elisp-fontify-semantically' 2025-10-12 17:12:48 +02:00
Eshel Yaron
07505fd6c5
; elisp-scope.el: Improve customization group name handling.
* lisp/emacs-lisp/elisp-scope.el (elisp-scope-quoted-group):
Delete it.
(define-minor-mode, define-derived-mode): Simplify analyzers.
2025-10-12 17:09:36 +02:00
Eshel Yaron
8186705752
; elisp-scope.el: Improve widget-type handling.
Use argument specs to analyze complex widget types.

* lisp/emacs-lisp/elisp-scope.el (elisp-scope-widget-type)
(elisp-scope-widget-type-1)
(elisp-scope-widget-type-keyword-arguments)
(elisp-scope-widget-type-arguments)
(elisp-scope-widget-type-arguments-1): Delete, no longer used.
(custom-declare-variable, define-widget): Simplify analyzers.
(elisp-scope--match-spec-to-arg): Add new 'list', 'and', and
'plist-and-then' parametric specs, and add 'widget-type' as a
new recursive spec.

* test/lisp/progmodes/elisp-mode-resources/semantic-highlighting.el
Add test.
2025-10-12 17:02:11 +02:00
Eshel Yaron
73feb431b3
; elisp-mode.el: Improve consistency among face names.
Rename a couple of faces to solidify the convention that the
face name 'elisp-foo' implies "references to foo", not "foo
definitions".  For definitions we use 'elisp-deffoo' if foo is
only one word, or 'elisp-bar-baz-definition' otherwise.

* lisp/progmodes/elisp-mode.el (elisp-function-reference):
Rename to 'elisp-function'.
(elisp-macro-call): Rename to 'elisp-macro'.
(elisp-non-local-exit):
(elisp-unknown-call):
(elisp-special-form):
* lisp/emacs-lisp/elisp-scope.el:
* test/lisp/progmodes/elisp-mode-resources/semantic-highlighting.el:
Update references to renamed faces.
2025-10-12 10:33:58 +02:00
Eshel Yaron
026f3bbd8d
; elisp-scope.el: Clean up symbol role definitions.
* lisp/progmodes/elisp-mode.el (elisp-fontify-semantically):
Fix typo in doc string.
(elisp--annotate-symbol-with-help-echo): Accept plain string
as value of ':help' symbol role property.
* lisp/emacs-lisp/elisp-scope.el: Remove unused symbol role
properties from all defined symbol roles.  Use plain strings
for ':help' instead of wrapping them with 'cl-constantly'.
Cease 'require'ing 'cl-lib', no longer needed in runtime.
(elisp-scope-define-symbol-role): Update doc string.
2025-10-12 10:17:00 +02:00
Eshel Yaron
0d7fc4516c
Document 'elisp-fontify-semantically' in the Emacs manual
* doc/emacs/display.texi (Semantic Font Lock): New node.
* doc/emacs/emacs.texi: Update menu.
* etc/NEWS: Update relevant entry.
* lisp/emacs-lisp/elisp-scope.el: Expand commentary.
* doc/misc/elisp-semantic-highlighting.org: Delete it.
2025-10-11 14:25:45 +02:00
Eshel Yaron
e7df895c2e
; (elisp-scope-if-let): Fix case where bindings entry is a symbol
* lisp/emacs-lisp/elisp-scope.el (elisp-scope-if-let): Fix
handling of a plain symbol as one the bindings in an
'if-let*' form, as in (if-let* (foo) 'bar).

* test/lisp/progmodes/elisp-mode-resources/semantic-highlighting.el:
Test it.
2025-10-08 18:18:56 +02:00
Eshel Yaron
240bf0679c
; * lisp/emacs-lisp/elisp-scope.el (if-let*): Add comment. 2025-10-08 15:47:27 +02:00
Sean Whitton
43cbdfb698 define-globalized-minor-mode: Fix multiple globalized modes
* lisp/emacs-lisp/easy-mmode.el (define-globalized-minor-mode):
Suppress MODE-set-explicitly function when enabling the mode
ourselves.
2025-10-08 11:38:49 +01:00
Sean Whitton
c510608cb2 ; define-globalized-minor-mode: Slightly simplify control flow. 2025-10-08 11:38:48 +01:00
Eshel Yaron
61caa91875
; elisp-scope.el: Fix 'wrong-type-argument' in local function analyzers
* lisp/emacs-lisp/elisp-scope.el
(elisp-scope--local-function-analyzer): New function.
(elisp-scope-flet, elisp-scope-labels)
(elisp-scope-named-let): Use it.
(elisp-scope-cl-macrolet): Check that argument is
'symbol-with-pos-p' before calling 'symbol-with-pos-pos'.
2025-10-08 00:13:34 +02:00
Eshel Yaron
94d314d756
; elisp-scope.el: Fix handling of 'if-let' and friends
* lisp/emacs-lisp/elisp-scope.el (elisp-scope-if-let): New
function, used to analyze 'if-let*' forms.
2025-10-07 23:48:38 +02:00
Sean Whitton
c95b33da9c Merge from origin/emacs-30
cd400326b2 ; Improve documentation of 'string-glyph-split'
2025-10-07 18:04:20 +01:00
Sean Whitton
7f925b06ac defvar-keymap: New ':prefix t' abbreviation
* lisp/keymap.el (defvar-keymap): New ':prefix t' abbreviation.
* lisp/emacs-lisp/helper.el (Helper-help-map):
* lisp/vc/pcvs.el (cvs-mode-diff-map):
* lisp/vc/vc-hooks.el (vc-prefix-map):
* lisp/vcursor.el (vcursor-map): Use it.
* doc/lispref/keymaps.texi (Creating Keymaps):
* etc/NEWS: Document it.
2025-10-06 18:34:18 +01:00
Eshel Yaron
fddc5f664e
; Rename 'elisp-scope--local' to 'elisp-scope-local-bindings'
We make this variable "public" since it's part of the interface that we
expose to custom analyzers.
2025-10-06 16:57:32 +02:00
Eshel Yaron
8dccb56662
; Drop 'elisp-scope-local-functions'
* lisp/emacs-lisp/elisp-scope.el
(elisp-scope-local-functions): Remove it, superseded by
'elisp-scope-local-definitions'.
(elisp-scope-sharpquote, elisp-scope-1): Update accordingly.
(elisp-scope-analyze-form): Fix typo in docstring.
2025-10-06 12:38:28 +02:00
Eshel Yaron
177658f068
; elisp-scope.el: Drop special-form special handling
* lisp/emacs-lisp/elisp-scope.el (elisp-scope-1): All
special-forms should have an associated analyzer, so drop
fallback handling for unknown special-forms.
2025-10-06 11:02:55 +02:00
Eshel Yaron
81c5399012
; Test semantic highlighting with 'cl-macrolet' and 'cl-flet' 2025-10-06 11:00:03 +02:00
Eshel Yaron
ec7b376dd4
elisp-scope.el: Unify and generalize local function/macro handling
* lisp/emacs-lisp/elisp-scope.el
(elisp-scope-local-definitions): New variable.  Replaces...
(elisp-scope-flet-alist, elisp-scope-macrolet-alist): these.
Removed, no longer used.
(elisp-scope-1, elisp-scope--handle-quoted): Update.
(elisp-scope-with-local-definition): New macro.
(elisp-scope-flet, elisp-scope-labels, elisp-scope-named-let)
(elisp-scope-cl-macrolet): Use it.
2025-10-06 10:54:21 +02:00
Eshel Yaron
dfb10509a4
; elisp-scope.el: Thread output spec though more macro analyzers
* lisp/emacs-lisp/elisp-scope.el (elisp-scope-flet)
(elisp-scope-labels, elisp-scope-cl-macrolet): Add argument
'outspec' and pass it down to 'elisp-scope-n'.
2025-10-06 10:32:59 +02:00
Eshel Yaron
7fc85f8dec
; elisp-scope.el: Recognize special variable declarations
* lisp/emacs-lisp/elisp-scope.el
(special-variable-declaration): New symbol role.
(defvar): Update analyzer to distinguish between
declarations and definitions.
(defconst): Add a separate analyzer.
* lisp/progmodes/elisp-mode.el
(elisp-special-variable-declaration): New face.
2025-10-06 10:27:09 +02:00
Eli Zaretskii
cd400326b2 ; Improve documentation of 'string-glyph-split'
* doc/lispref/display.texi (Size of Displayed Text):
* lisp/emacs-lisp/subr-x.el (string-glyph-split): Document a
caveat (bug#79576).
2025-10-05 11:04:34 +03:00
Eshel Yaron
3c645f3e62
; (elisp-scope-define-special-form-analyzer): Fix typo. 2025-10-03 21:19:51 +02:00
Eshel Yaron
f8b8b9edc8
; (elisp-scope-describe-symbol-role): Minor clean up. 2025-10-03 19:49:15 +02:00
Eshel Yaron
f269531255
; elisp-scope.el: Support hooking into `describe-symbol-backends'.
* lisp/emacs-lisp/elisp-scope.el
(elisp-scope-add-symbol-roles-to-describe-symbol): New
autoloaded function intended for user configs, hooks
`elisp-scope-describe-symbol-role' into `describe-symbol'.
2025-10-03 19:47:27 +02:00
Eshel Yaron
efa5b73044
; (elisp-scope-1): Add a "TODO". 2025-10-03 19:15:21 +02:00
Eshel Yaron
90e65c2abe
; (elisp-scope-gen-id-alist): Remove, unused. 2025-10-03 19:15:15 +02:00
Eshel Yaron
c412bd83ff
; elisp-scope.el: Fix 'custom-declare-face' analyzer. 2025-10-03 19:11:26 +02:00