Commit graph

8199 commits

Author SHA1 Message Date
Lars Ingebrigtsen
773d4104a5 Further fixes for cl--generic-describe and (function ...)
* lisp/emacs-lisp/cl-generic.el (cl--generic-describe): Fix the #'
problem for defmethods, too (bug#54628).
2022-04-04 12:48:47 +02:00
Mattias Engdegård
f4833c88bb Rewrite string-greaterp and string> using string-lessp
Since string-lessp has its own byte-op, using it is much faster than
calling string-greaterp even with the need to bind a temporary
variable.

* lisp/emacs-lisp/byte-opt.el (byte-optimize-string-greaterp): New.
(string-greaterp, string>): Set byte-optimizer.
2022-04-04 09:49:31 +02:00
Philipp Stephani
3c6524140b ; * lisp/emacs-lisp/cl-macs.el (cl-struct-slot-value): Fix typo. 2022-04-03 17:51:04 +02:00
Lars Ingebrigtsen
5e429e21d9 Have global minor modes say so in the doc string
* lisp/emacs-lisp/easy-mmode.el (easy-mmode--arg-docstring): Allow
saying whether it's a global minor mode or not.
(easy-mmode--mode-docstring): Use it.
(define-minor-mode): Pass in the data.
2022-04-03 14:08:04 +02:00
Lars Ingebrigtsen
781c43de3d Fix bootstrap errors after previous easy-mmode change
* lisp/subr.el (ensure-empty-lines, string-lines): Moved from
subr-x so that they can be used in early bootstrap files.

* lisp/emacs-lisp/easy-mmode.el (easy-mmode--mode-docstring):
Don't use string-empty-p because of bootstrap issues.
2022-04-02 16:53:24 +02:00
Lars Ingebrigtsen
ec464789df Put the define-minor-mode boilerplate at the end of the doc strings
* lisp/emacs-lisp/easy-mmode.el (easy-mmode--mode-docstring): Put
the boilerplate at the end of the doc string.
2022-04-02 15:55:38 +02:00
Lars Ingebrigtsen
338f5667f4 Further tweaks to cl--generic-describe
* lisp/emacs-lisp/cl-generic.el (cl--generic-describe): Further
tweak the look of the implementation output.
2022-04-02 15:19:15 +02:00
Stefan Monnier
6cb6886840 cl-generic: Rework obsolescence checks for defmethod
* lisp/emacs-lisp/cl-generic.el (cl-defgeneric): Silence obsolescence
warnings in the included methods.
(cl-defmethod): Reuse standard obsolescence checks.

* lisp/emacs-lisp/seq.el (seq-contains): Remove redundant
`with-suppressed-warnings`.
2022-04-01 10:02:32 -04:00
Stefan Monnier
ff067408e4 OClosure: Add support for defmethod dispatch
* lisp/emacs-lisp/oclosure.el (oclosure--class): Add slot `allparents`.
(oclosure--class-make): Add corresponding arg `allparents`.
(oclosure, oclosure--build-class): Pass the new arg to the constructor.
(oclosure--define): Make the predicate function understand subtyping.

* lisp/emacs-lisp/cl-preloaded.el (cl--class-allparents): Move from
`cl-generic.el`.

* lisp/emacs-lisp/cl-generic.el (cl--generic-class-parents): Move to
`cl-preloaded.el` and rename to `cl--class-allparents`.
Adjust all callers.
(cl--generic-oclosure-tag, cl-generic--oclosure-specializers): New functions.
(cl-generic-generalizers) <oclosure-struct>: New generalizer.

* test/lisp/emacs-lisp/oclosure-tests.el (oclosure-test-gen):
New generic function.
(oclosure-test): Add test for dispatch on oclosure types.
2022-04-01 08:54:55 -04:00
Lars Ingebrigtsen
af0ea35ea0 Tweak how functions are formatted in Implementation in *Help*
* lisp/emacs-lisp/cl-generic.el (cl--generic-describe): Include
the function name in the implementations (bug#54628).  This
clarifies what we're talking about here, and avoids getting
(function ...) translated into #'...
2022-03-31 13:38:33 +02:00
Stefan Monnier
6f973faa91 cl-generic: Use OClosures for cl--generic-isnot-nnm-p
Rewrite the handling of `cl-no-next-method` to get rid of the hideous
hack used in `cl--generic-isnot-nnm-p` and also to try and move
some of the cost to the construction of the effective method rather
than its invocation.  This speeds up method calls measurably when
there's a `cl-call-next-method` in the body.

* lisp/loadup.el ("emacs-lisp/oclosure"): Load.

* lisp/emacs-lisp/oclosure.el (oclosure-define): Remove workaround now
that we're preloaded.

* lisp/emacs-lisp/cl-generic.el (cl--generic-method): Rename `uses-cnm`
to `call-con` to reflect it's not a boolean any more.
(cl-defmethod): Adjust to the new name and new values.
(cl-generic-define-method): Adjust to the new name.
(cl--generic-lambda): Use the new `curried` calling convention.
(cl--generic-no-next-method-function): Delete function.
(cl--generic-nnm): New type.
(cl-generic-call-method): Rewrite to support the various
calling conventions.
(cl--generic-nnm-sample, cl--generic-cnm-sample): Delete consts.
(cl--generic-isnot-nnm-p): Rewrite using `oclosure-type`.
(cl--generic-method-info): Add support for new calling convention.
2022-03-30 17:08:28 -04:00
Stefan Monnier
b12ad270eb EIEIO tests: Fix failure when eieio-core.el is interpreted
* lisp/emacs-lisp/eieio-core.el (eieio--validate-slot-value)
(eieio--slot-name-index): Use the `cl--class` accessor functions.
2022-03-30 17:08:28 -04:00
Stefan Monnier
2b5ea36ce9 * lisp/emacs-lisp/oclosure.el (oclosure--define): Autoload 2022-03-29 03:23:38 -04:00
Po Lu
55932a65ed Temporarily fix the oclosure bootstrap
* lisp/emacs-lisp/oclosure.el (oclosure-define): Load oclosure
from source if `oclosure--define' is not defined during byte
compilation.
2022-03-29 13:58:40 +08:00
Stefan Monnier
52d5771e0a Add OClosures, a cross between functions and structs
We here just add the new type.  It is not fully self-contained.
It requires cooperation from `cconv.el` on the one hand, and it
hijacks the docstring info to hold the type of OClosure objects.
This does imply that OClosures can't have docstrings, tho this
limitation will be lifted in subsequent patches.

* lisp/emacs-lisp/oclosure.el: New file.
* test/lisp/emacs-lisp/oclosure-tests.el: New file.
* doc/lispref/functions.texi (OClosures): New section.

* src/eval.c (Ffunction): Accept symbols instead of strings for docstrings.
* src/doc.c (store_function_docstring): Avoid overwriting an OClosure type.
* lisp/emacs-lisp/cconv.el (cconv--convert-function): Tweak ordering of
captured variables.
(cconv-convert): Add case for `oclosure--fix-type`.
2022-03-28 10:53:14 -04:00
Lars Ingebrigtsen
3e7257c3ed Improve pp-last-sexp ergonomics
* lisp/emacs-lisp/pp.el (pp-last-sexp): Ignore ,@?
before a sexp, because eval-ing that will always lead to an error
(bug#54537).
2022-03-25 16:44:30 +01:00
Augusto Stoffel
45978f97be Handle invisible text in Eldoc when calculating size
Co-authored-by: João Távora <joaotavora@gmail.com>

* lisp/emacs-lisp/eldoc.el (eldoc--echo-area-substring,
eldoc-display-in-echo-area):  Take invisible text into consideration
when counting lines to crop an echo-area message.
(Version): Bump.
2022-03-24 15:06:05 +00:00
Lars Ingebrigtsen
fd5fe11211 Don't break autoload generation of `left-margin' isn't zero
* lisp/emacs-lisp/autoload.el (make-directory-autoloads): Fix
autoload generation breakage is left-margin isn't zero (bug#54491).
2022-03-21 19:15:55 +01:00
Lars Ingebrigtsen
71b8f1fc63 Make `command-modes' work for (native-compiled) subrs, too
* lisp/emacs-lisp/comp.el (comp-func): Add a command-modes slot.
(comp-spill-lap-function, comp-intern-func-in-ctxt): Fill it.
(comp-emit-for-top-level, comp-emit-lambda-for-top-level): Use it.

* src/alloc.c (mark_object): Mark the command_modes slot.

* src/comp.c (make_subr): Add a command_modes parameter.
(Fcomp__register_lambda): Use it.
(Fcomp__register_subr): Ditto.

* src/data.c (Fcommand_modes): Output the command_modes data for subrs
(bug#54437).

* src/lisp.h (GCALIGNED_STRUCT): Add a command_modes slot.

* src/pdumper.c (dump_subr): Update hash.
(dump_subr): Dump the command_modes slot.
2022-03-19 15:11:37 +01:00
Stefan Monnier
ab8a34ce8a * lisp/emacs-lisp/bytecomp.el (byte-compile-make-closure): Minor optimization 2022-03-18 16:07:42 -04:00
Stefan Monnier
06ea82e4e3 Remove some early-bootstrap dependencies for advice
The dependencies between `advice`, cl-generic`, `bytecomp`, `cl-lib`,
`simple`, `help`, ... were becoming unmanageable.
Break the reliance on `advice` (which includes making sure the
compiler is not needed during the early bootstrap).

* lisp/simple.el (pre-redisplay-function): Set without using `add-function`.

* lisp/loadup.el (advice, simple): Move to after `cl-generic`.

* lisp/help.el (command-error-function): Set without using `add-function`.
(help-command-error-confusable-suggestions): Explicitly call
`command-error-default-function` instead.

* lisp/emacs-lisp/cl-macs.el (pcase--mutually-exclusive-p): Don't
optimize during early-bootstrap.

* lisp/emacs-lisp/cl-generic.el (cl--generic-lambda): Tiny simplification.
(cl-defmethod): Label the obsolescence warning as it should.
(cl--generic-compiler): New variable.
(cl--generic-get-dispatcher): Use it.
(cl--generic-prefill-dispatchers): Make freshly made dispatchers.
2022-03-17 19:07:59 -04:00
Stefan Monnier
693484d36b * lisp/emacs-lisp/cl-generic.el (cl-defgeneric): Warn suspicious args 2022-03-17 10:07:35 -04:00
Stefan Monnier
81bcad03e9 (seq-contains-p): Refine the non-nil returned value
* lisp/emacs-lisp/seq.el (seq-contains-p): Like `cl-some` return the
value returned by the test function rather than t.
2022-03-17 09:54:41 -04:00
Lars Ingebrigtsen
06488ded6b Make `?' work again in read-multiple-choice
* lisp/emacs-lisp/rmc.el (read-multiple-choice): Make the `?' key
work again to show the help text.
2022-03-17 12:55:39 +01:00
Felician Nemeth
6bbd1cc5c9 Format long help texts better in read-multiple-choice
* lisp/emacs-lisp/rmc.el (rmc--show-help): Format long help texts
better (bug#54430).
2022-03-17 12:55:39 +01:00
Alan Mackenzie
31a2428d6f Strip positions from symbols before the eval in eval-{when,and}-compile.
This fixes bug #54079.

* lisp/emacs-lisp/bytecomp.el (byte-compile-initial-macro-environment): Change
the position of 'byte-run-strip-symbol-positions' in the eval-when-compile
entry.  Add a call to `byte-run-strip-symbol-positions' in the
eval-and-compile entry.
2022-03-16 19:23:24 +00:00
Stefan Monnier
5d33f81542 * lisp/emacs-lisp/cl-macs.el (cl-defstruct): Simplify Edebug spec 2022-03-14 09:28:18 -04:00
Philipp Stephani
f3df7916b2 Make Edebug specification for 'cl-defstruct' more lenient.
For example, 'xref-item' uses the list form of ':noinline'.

* lisp/emacs-lisp/cl-macs.el (cl-defstruct): Accept ':noinline' and
':named' with an argument.
* test/lisp/emacs-lisp/cl-macs-tests.el (cl-defstruct/edebug): New
unit test.
2022-03-14 10:59:03 +01:00
Lars Ingebrigtsen
510f1f2e72 Really fix find-func for defgeneric
* lisp/emacs-lisp/find-func.el (find-function-regexp): Really add
defgeneric.
2022-03-13 21:15:35 +01:00
Lars Ingebrigtsen
525c01c43a Make vtable sorting stable
* lisp/emacs-lisp/vtable.el (vtable--sort): Make the sorting
stable.
2022-03-13 21:13:49 +01:00
Lars Ingebrigtsen
466a7e44d7 Add cl-defgeneric to find-func, too
* lisp/emacs-lisp/find-func.el (find-function-regexp): Add
cl-defgeneric, too (bug#54343).
2022-03-13 15:17:24 +01:00
Lars Ingebrigtsen
84f59f7585 Make find-function-regexp also find cl-defun/defmethod
* lisp/emacs-lisp/find-func.el (find-function-regexp): Also find
cl-defun and cl-defmethod (bug#54343).
2022-03-12 18:53:36 +01:00
Lars Ingebrigtsen
2353893bd0 Fix regression in vtable-goto-object
* lisp/emacs-lisp/vtable.el (vtable-goto-object): Fix moving to
the object.
2022-03-09 17:37:47 +01:00
Stefan Monnier
8f11fb114c (cl-macro-list): Simplify by unifying the variants
* lisp/emacs-lisp/cl-macs.el (cl-macro-list): Add the &whole and the
dotted tail cases from `cl-macro-list1`.
(cl-macro-list1, cl-define-compiler-macro-list): Delete edebug elem specs.
(cl-destructuring-bind, cl-define-compiler-macro): Use `cl-macro-list`
instead, now that it covers all the cases we need.
2022-03-07 22:27:48 -05:00
Stefan Monnier
d67ca6739c * lisp/emacs-lisp/seq.el (seq-concatenate): Accept non-sequencep sequences 2022-03-07 09:59:43 -05:00
Alan Mackenzie
68cdb95019 Restore call to byte-run-strip-symbol-positions in byte-compile-out
Also increment a loop counter.  This should fix bug #54248.

* lisp/emacs-lisp/byte-run.el (byte-run--strip-vector/record): increment the
loop counter 'i' in the main loop.

* lisp/emacs-lisp/bytecomp.el (byte-compile-out): call
byte-run-strip-symbol-positions on operands which are one-element lists.
2022-03-06 13:37:30 +00:00
Stefan Kangas
200627c255 Merge from origin/emacs-28
0090318c61 * lib-src/seccomp-filter.c (main): Use faccessat2 only if ...
3bb01a499b Fix regression in derived-mode-init-mode-variables
2022-03-06 06:32:23 +01:00
Stefan Monnier
6ad223fa9f trace.el: Preserve the line structure
Print newlines appearing inside values (i.e. inside strings) as \n
rather than actual newlines so as to avoid messing up the main
structure of the trace buffer.

* lisp/emacs-lisp/trace.el (trace-entry-message)
(trace-exit-message, trace--read-args): Quote newlines
2022-03-04 12:18:41 -05:00
Lars Ingebrigtsen
3bb01a499b Fix regression in derived-mode-init-mode-variables
* lisp/emacs-lisp/derived.el (derived-mode-init-mode-variables):
Fix regression caused by lexical-binding derived.el (bug#54240).
2022-03-04 16:19:54 +01:00
Philipp Stephani
aeb25f9d3d Teach Edebug about the special '&whole' syntax for compiler macros.
* lisp/emacs-lisp/cl-macs.el (cl-define-compiler-macro-list): New
Edebug element specification.
(cl-define-compiler-macro): Use it.

* test/lisp/emacs-lisp/cl-macs-tests.el
(cl-define-compiler-macro/edebug): New unit test.
2022-03-03 19:57:00 +01:00
Mattias Engdegård
cb0aad2dbe Clean up byte-compile-arglist-warn
* lisp/emacs-lisp/bytecomp.el (byte-compile-arglist-warn):
Remove unnecessary sort (only need min and max).  Reduce mutation.
2022-02-28 12:16:54 +01:00
Alan Mackenzie
6092ee1c3f Amend byte-run-strip-symbol-positions so that an unexec build builds
This fixes bug #54098.

* lisp/emacs-lisp/byte-run.el (byte-run--strip-list)
(byte-run--strip-vector/record): New functions.  These alter a list or
vector/record structure only where a symbol with position gets replaced by a
bare symbol.
(byte-run-strip-symbol-positions): Reformulate to use the two new functions.
(function-put): No longer strip positions from the second and third arguments.

* lisp/emacs-lisp/bytecomp.el (byte-compile-out): Remove the senseless
"stripping" of putative symbol positions from OPERAND, which is nil or a
number.
2022-02-24 17:30:39 +00:00
Lars Ingebrigtsen
c6465d65fa Don't signal an error on re-builder startup with rx syntax
* lisp/emacs-lisp/re-builder.el (reb-initialize-buffer): Make
startup with rx syntax not signal an error (bug#54107).
2022-02-22 14:43:35 +01:00
Stefan Kangas
bee54495e9 Merge from origin/emacs-28
666e40a109 Fix 'display-line-numbers-mode' in hide-show buffers
68d134cf0f Don't check whether a deleted window is deletable (Bug#54028)
b38223a844 A friendlier error message from image-mode in an empty buffer
b7a651ba37 Update to Org 9.5.2-17-gea6b74
3a8c3f7abd ; Don't reference obsolete variables in edebug.el
2022-02-22 06:30:59 +01:00
Lars Ingebrigtsen
de003cb2b5 Improve vtable :keymap handling
* lisp/emacs-lisp/vtable.el (vtable-map, vtable--make-keymap):
Don't alter keymaps passed in, and respect parent keymaps.
2022-02-21 19:19:55 +01:00
Raffael Stocker
3a8c3f7abd ; Don't reference obsolete variables in edebug.el
* lisp/emacs-lisp/edebug.el (edebug-mode, edebug-eval-mode):
Don't reference obsolete variables in the doc strings.
(Bug#54070)
2022-02-20 17:50:45 +02:00
Lars Ingebrigtsen
d710b84225 Make string-pixel-width about 40% faster
* lisp/emacs-lisp/subr-x.el (string-pixel-width): Speed up.
2022-02-20 16:14:05 +01:00
Stefan Monnier
f262a6af36 (macroexp-warn-and-return): Fix bug#53618
* lisp/emacs-lisp/macroexp.el (macroexp-warn-and-return):
Reorder arguments to preserve compatibility with that of Emacs-28.
(macroexp--unfold-lambda, macroexp--expand-all):
* lisp/emacs-lisp/pcase.el (pcase-compile-patterns, pcase--u1):
* lisp/emacs-lisp/gv.el (gv-ref):
* lisp/emacs-lisp/eieio.el (defclass):
* lisp/emacs-lisp/eieio-core.el (eieio-oref, eieio-oref-default)
(eieio-oset-default):
* lisp/emacs-lisp/easy-mmode.el (define-minor-mode):
* lisp/emacs-lisp/cl-macs.el (cl-symbol-macrolet, cl-defstruct):
* lisp/emacs-lisp/cl-generic.el (cl-defmethod):
* lisp/emacs-lisp/byte-run.el (defmacro, defun):
* lisp/emacs-lisp/bindat.el (bindat--type): Adjust accordingly.
2022-02-19 14:20:02 -05:00
Lars Ingebrigtsen
d98b6fbba2 Add column sorting order indicators to vtable
* lisp/emacs-lisp/vtable.el (vtable--indicator): New function.
(vtable--insert-header-line): Use it to display sorting order
indicators.
2022-02-19 14:21:19 +01:00
Lars Ingebrigtsen
babfb064c4 Make string-pixel-width slightly speedier
* lisp/emacs-lisp/subr-x.el (string-pixel-width): Speed up
string-pixel-width in the zero-length string case.
2022-02-19 14:21:19 +01:00