Commit graph

6778 commits

Author SHA1 Message Date
Andrea Corallo
7a161dc688 Merge remote-tracking branch 'savahnna/master' into HEAD 2020-07-26 09:40:02 +02:00
Andrea Corallo
6c108e44c9 * Add `comp-ensure-native-compiler' guarding entry points
* lisp/emacs-lisp/comp.el (comp-ensure-native-compiler): New function.
	(native-compile, batch-native-compile)
	(batch-byte-native-compile-for-bootstrap, native-compile-async):
	Make use of `comp-ensure-native-compiler'.
2020-07-26 09:36:09 +02:00
Mattias Engdegård
609cbd63c3 Optimise 3-arg +, - and *
Turn (+ a b c) into (+ (+ a b) c), and do the same for - and *.
The 2-arg operations have their own bytecode which results in a 1.5×
speed-up.  Furthermore, the transform enables other optimisations; for
example, (+ a 1 b) -> (+ (1+ a) b).

* lisp/emacs-lisp/byte-opt.el (byte-optimize-plus, byte-optimize-minus)
(byte-optimize-multiply): Transform (OP a b c) into (OP (OP a b) c).
2020-07-25 19:24:56 +02:00
João Távora
fcd43287b3 Don't needlessly request docs from ElDoc functions
Fixes: bug#42421

Do this conservatively for now: if the ElDoc helper buffer (as
returned by eldoc--doc-buffer) is visible and showing documentation
for the very same "situation" (as computed by the the new
eldoc--request-state helper), don't request that documentation from
sources again.

Before this change, not only was that request inefficient but if the
user invoked scroll-other-window to see more of the helper buffer,
that would eventually cause it to be reformatted and unexpectedly
recentered.

Later on, when a customizable list of documentation "sinks" is offered
to the user, say, something like eldoc-display-functions, this process
must be consolidated.  In those circumstances, as soon as one of those
sinks signals that it doesn't have up-to-date documentation for the
state computed by eldoc--request-state, documentation will have to be
requested anew from eldoc-documentation-functions via
eldoc--invoke-strategy.

* lisp/emacs-lisp/eldoc.el (eldoc--request-docs-p): Rework from
eglot-display-message-p.
(eldoc--last-request-state): New variable.
(eldoc--request-state): New helper.
(eldoc--handle-docs): Memorize state of request in doc buffer.
(eldoc-print-current-symbol-info): Pass a token to
eldoc--request-docs-p.
(Version): Bump to 1.6.0
2020-07-23 11:57:27 +01:00
Andrea Corallo
37e0dbc972 Merge remote-tracking branch 'savannah/master' into HEAD 2020-07-19 20:39:27 +01:00
João Távora
c77731e824 Fix ElDoc bugs around eldoc-echo-area-use-multiline-p.
If the value is 'truncate-sym-name-if-fit andthe single docstring
doesn't fit in the echo area even when the symbol name is elided, that
step shouldn't be attempted.  Also if the value is nil, really ensure
that only the first line is shown.

* lisp/emacs-lisp/eldoc.el (eldoc--handle-docs): Rework
'truncate-sym-name-if-fit case of eldoc-echo-area-use-multiline-p.
2020-07-19 00:59:14 +01:00
João Távora
4a7ecaaee0 ; Reword bits of ElDoc internal documentation
* lisp/emacs-lisp/eldoc.el (eldoc--invoke-strategy): Rewrite docstring.
(eldoc--invoke-strategy): Fix formatting and rewrite comments
2020-07-19 00:59:14 +01:00
Lars Ingebrigtsen
ba12555fda Fix NOT-CURRENT behaviour in text-property-search-backward
* lisp/emacs-lisp/text-property-search.el
(text-property-search-backward): Fix inconsistent behaviour of
S-TAB in eww (and other callers that use the NOT-CURRENT
behaviour) when there are adjacent elements
(bug#39239).
2020-07-17 18:44:49 +02:00
Andrea Corallo
907618b3b5 Merge remote-tracking branch 'savahnna/master' into HEAD 2020-07-15 23:13:59 +02:00
Tassilo Horn
85eaa8373b ;Fix eldoc regression bug#42365 2020-07-15 18:58:57 +02:00
Andrea Corallo
4c46f8bac0 * Add a simple major mode for coloring LIMPLE in the log buffer
* lisp/emacs-lisp/comp.el (comp-limple-lock-keywords): New const.
	(comp-limple-mode): New major mode.
	(comp-log-to-buffer): Enable `comp-limple-mode' in the log buffer.
2020-07-15 09:34:16 +02:00
Basil L. Contovounesios
36e6019034 Consistently stylize eldoc as ElDoc in more prose
This fixes new occurrences of "Eldoc" since emacs-27.

* doc/lispref/modes.texi (Major Mode Conventions):
* etc/NEWS:
* lisp/descr-text.el (describe-char-eldoc):
* lisp/emacs-lisp/eldoc.el (eldoc-echo-area-use-multiline-p)
(eldoc-prefer-doc-buffer, eldoc--documentation-strategy-defcustom):
Consistently capitalize eldoc as ElDoc rather than Eldoc in
documentation and commentary.
2020-07-14 13:49:34 +01:00
Andrea Corallo
5be335e6b5 Merge remote-tracking branch 'savahnna/master' into HEAD 2020-07-13 15:13:46 +02:00
Andrea Corallo
eb091c8647 * Rename comp-propagate' into fw-prop'
* lisp/emacs-lisp/comp.el (comp-passes): Rename `comp-propagate'
	-> `comp-fwprop'.
	(comp-fwprop-prologue): Rename from `comp-propagate-prologue'.
	(comp-fwprop-insn): Rename from `comp-fwprop-insn'.
	(comp-propagate*): Rename from `comp-propagate*' and update.
	(comp-fwprop): Rename from `comp-propagate' and update.
2020-07-13 14:44:29 +02:00
Andrea Corallo
36c289ec8b * Clean-up now unnecessary backward propagation in comp.el
* lisp/emacs-lisp/comp.el (comp-passes): Invoke 'comp-propagate'
	instead of 'comp-propagate-alloc'.
	(comp-mvar): Remove unnecessary `array-idx' slot.
	(comp-propagate-prologue): Remove.
	(comp-propagate-prologue): Remove `backward' parameter and
	backward propagation logic.
	(comp-propagate1): Remove and move logic into `comp-propagate'.
	(comp-propagate-alloc): Remove pass.
2020-07-13 14:40:07 +02:00
James N. V. Cash
7a712578ed Fix a typo in eldoc.el
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions): Fix a
typo.  (Bug#42310)

Copyright-paperwork-exempt: yes
2020-07-12 17:10:32 +03:00
João Távora
45d7db6d22 Sort out ElDoc backward compatibility of eldoc-documentation-function
As explained previously, we can't simply make
eldoc-documentation-function an variable alias for
eldoc-documentation-strategy, because ElDoc is pre-loaded in Emacs <
28, where it holds at least one buffer-local binding.  So if eldoc.el
is loaded in those versions, we do the variable alias binding in
reverse.  We do this using a macro
eldoc--documentation-strategy-defcustom to at load time in which
direction to make the variable alias.

* lisp/emacs-lisp/eldoc.el
(eldoc--documentation-strategy-defcustom): Helper macro.
(eldoc-documentation-strategy, eldoc-documentation-function): Use it.
(Version): Bump to 1.5.0
2020-07-12 14:24:05 +01:00
João Távora
1198b03e55 Fix placement of Eldoc docs during eval-expression (bug#42309)
* lisp/emacs-lisp/eldoc.el (eldoc--handle-docs): Rework.
2020-07-10 21:23:33 +01:00
João Távora
c2599632b0 Revert "Fix Eldoc problem when loading on Emacs 26.3"
This reverts commit 9ade7ea7b7.

* lisp/emacs-lisp/eldoc.el (Version): Bump to 1.4.0
2020-07-10 18:12:10 +01:00
João Távora
62725e87f2 Fix byte compilation warning in Eldoc
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-function): Pass nil as
second argument.
2020-07-10 08:13:15 +01:00
João Távora
9ade7ea7b7 Fix Eldoc problem when loading on Emacs 26.3
When defining the obsolete variable alias for old
eldoc-documentation-function (which now points to the newer
eldoc-documentation-strategy), one gets the error "don't know how to
make a localized vareiable an alias".  I'm not sure, but I suspect
this is because Eldoc is preloaded in Emacs 26.3 and the
eldoc-documentation-function variable is already set locally by some
Elisp buffer.

Uninterning the symbol shortly before defining the alias seems to fix
it.

* lisp/emacs-lisp/eldoc.el (eldoc-documentation-function):
Unintern on load.
(Version): Bump to 1.3.0
2020-07-10 01:47:33 +01:00
João Távora
59f563680d Unbreak M-x eldoc
The command should always invoke Eldoc when called interactively,
instead of going through the usual checks, which are performed to
avoid interference with other commands.

* lisp/emacs-lisp/eldoc.el (eldoc-print-current-symbol-info): Rework.
(Version): Bump to 1.2.0
2020-07-09 18:07:22 +01:00
João Távora
ffb99d8490 Prevent infloop in Eldoc message truncation algorithm
The truncation algorithm still has a long way to go for very narrow
frame sizes.  It should become a generic mechanism that would allows
one to truncate a string so that fits in N possibly truncated screen
lines of a full-width window.

* lisp/emacs-lisp/eldoc.el (eldoc-handle-docs): Tweak
2020-07-09 18:07:22 +01:00
Andrea Corallo
5f13016ced Merge remote-tracking branch 'savannah/master' into wip2 2020-07-09 16:42:16 +01:00
Andrea Corallo
9aaca828fc * Add `comp-disabled-passes'
* lisp/emacs-lisp/comp.el (comp-disabled-passes): New special
	variable.
	(native-compile): Make use of `comp-disabled-passes'.
2020-07-09 16:23:34 +01:00
Andrea Corallo
b4de6baa7b * Optimize pure functions defined by the compilation environment
* lisp/emacs-lisp/comp.el (comp-apply-in-env): New macro.
	(comp-function-call-maybe-remove): Update to make use of
	`comp-apply-in-env'.
2020-07-09 16:22:48 +01:00
Andrea Corallo
7622740e29 * Introduce a new pass ipa-pure
Add a simple pass to infer pure functions not explicitly declared as
such.  Use this information only during compilation (speed 3) to
optimize out function calls whe possible.
2020-07-09 16:22:48 +01:00
Andrea Corallo
5688739c5b * Add `comp-call-op-p'
* lisp/emacs-lisp/comp.el (comp-call-op-p): New predicate.
	(comp-limple-insn-call-p): Make use of.
2020-07-09 16:22:48 +01:00
Andrea Corallo
3db6ace804 * Define `comp-symbol-func-to-fun'
* lisp/emacs-lisp/comp.el (comp-symbol-func-to-fun): New function.
	(comp-func-in-unit): Make use of the `comp-symbol-func-to-fun'.
2020-07-09 16:22:48 +01:00
Andrea Corallo
0b81044e7e * Clean-up some const folding logic and add `comp-function-pure-p'
* lisp/emacs-lisp/comp.el (comp-function-pure-p): New predicate.
	(comp-function-call-maybe-remove): Update to use the
	`comp-function-pure-p'.
2020-07-08 17:26:51 +01:00
João Távora
384fa10958 Improve Eldoc docstrings
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-strategy): Improve
docstring.
(eldoc--make-callback): Improve docstring.
(eldoc--invoke-strategy): New helper function.
(eldoc-print-current-symbol-info): Call eldoc--invoke-strategy.
(eldoc-documentation-functions): Improve docstring.
2020-07-08 11:25:33 +01:00
João Távora
fbc0bc6bef Change version scheme of two Eldoc obsolete specs
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-function)
(eldoc-message): Obsolete spec uses eldoc-1.1.0.
2020-07-08 11:25:33 +01:00
João Távora
bba3bea247 Adjust Eldoc documentation after Eli's review
* etc/NEWS (Eldoc): Adjust paragraphs.

* lisp/emacs-lisp/eldoc.el (eldoc-prefer-doc-buffer): Adjust
docstring.
(eldoc--enthusiasm-curbing-timer, eldoc-documentation-strategy)
(eldoc-documentation-functions): Adjust docstring.
(eldoc--handle-docs): Adjust comments.
(eldoc--documentation-compose-1): New helper.
(eldoc-documentation-compose)
(eldoc-documentation-compose-eagerly): Use it.
(eldoc-print-current-symbol-info): Adjust comments.
2020-07-08 11:25:33 +01:00
João Távora
1203626f47 Make more parts of Emacs use new Eldoc capabilities
Elisp-mode was doing a lot of work that can now be delegated to Eldoc.
Flymake uses the new Eldoc functionality, too, installing a global
documentation function that may report on diagnostics under point.

CEDET's grammar.el was left as the only user of an Eldoc-internal
function.  That function was moved to grammar.el.  That file is still,
somewhat reprehensibly, using an internal function of elisp-mode.el,
but this was left unchanged.

In other situations, eldoc-documentation-functions is used or
recommended.

The only other places where the obsolete eldoc-documentation-function
is still used is in libraries which are presumably meant to remain
compatible with previous Emacs versions.

* lisp/progmodes/elisp-mode.el (elisp-eldoc-funcall)
(elisp-eldoc-var-docstring): New functions.
(emacs-lisp-mode): Put two elements in
eldoc-documentation-functions.

* lisp/emacs-lisp/eldoc.el (eldoc--eval-expression-setup): Setup
new Elisp eldoc-documentation-functions.

* lisp/progmodes/flymake.el (flymake-mode): Use
flymake-eldoc-function.
(flymake-eldoc-function): New function.
(Package-Requires): Require eldoc 1.1.0

* lisp/descr-text.el (describe-char-eldoc): Recommend
eldoc-documentation-functions.

* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Recommend eldoc-documentation-functions

* lisp/progmodes/octave.el (inferior-octave-mode): Use
eldoc-documentation-functions.

* lisp/cedet/semantic/grammar.el (semantic--docstring-format-sym-doc):
New function.
(semantic-grammar-eldoc-get-macro-docstring): Adjust.
2020-07-08 11:25:33 +01:00
João Távora
a9bd506004 * lisp/emacs-lisp/eldoc.el (Version): Bump to 1.1.0 2020-07-08 11:25:33 +01:00
João Távora
22cae4f509 New M-x eldoc for on-demand and interactive documentation requests
The function eldoc is just an alias for
eldoc-print-current-symbol-info, which is made interactive.

* lisp/emacs-lisp/eldoc.el (eldoc-print-current-symbol-info): Now an
interactive function.
(eldoc): Alias to eldoc-print-current-symbol-info.
2020-07-08 11:25:33 +01:00
João Távora
a7a53f0d79 Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.

Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user.  When more
asynchronous sources are involved, this is hard to do or even breaks
down.

Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards.  This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.

Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message.  This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.

Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol".  Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.

The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs.  Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.

The manual and NEWS are updated to mention the new Eldoc features.

* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions.  Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.

* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.

* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.

* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.

* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.

* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.

(eldoc-print-current-symbol-info): Rework with cl-labels.

* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.

* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.

* etc/NEWS: Mention eldoc-documentation-strategy.
2020-07-08 11:25:33 +01:00
Andrea Corallo
3d43d45755 Merge remote-tracking branch 'savannah/master' into HEAD 2020-07-07 20:44:39 +01:00
Mattias Engdegård
df3ece9d2e Optimise assoc and rassoc with symbol key to assq and rassq
This is the same transformation made for member to memq.

* lisp/emacs-lisp/byte-opt.el (byte-optimize-assoc): New function.
(assoc, rassoc): Set the byte-optimizer property.
2020-07-07 17:55:20 +02:00
Stefan Monnier
6b80ff3c46 * lisp/emacs-lisp/cl-macs.el (cl-deftype-satisfies): Add keyword 2020-07-06 18:04:54 -04:00
Mattias Engdegård
3f990c3ccc Simplify byte-code optimisation of pure functions
Most pure functions need no explicit optimisation; we can do away with
almost all uses of byte-optimize-predicate (now renamed to
byte-optimize-constant-args, since it is not just for predicates).
Also remove some superfluous arity warnings.

* lisp/emacs-lisp/byte-opt.el (byte-optimize-identity, byte-optimize-memq)
(byte-optimize-nth, byte-optimize-nthcdr):
Remove arity warnings and simplify.
* lisp/emacs-lisp/byte-opt.el (<, >, <=, >=, not, null, consp, listp)
(symbolp, stringp, string<, string-lessp, proper-list-p, logand)
(logior, logxor, lognot, car, cdr, car-safe, cdr-safe):
Remove superfluous byte-optimizer property.
(byte-optimize-predicate): Rename to byte-optimize-constant-args.
All uses changed.
2020-07-06 18:08:06 +02:00
Mattias Engdegård
fb63a64d21 Mark more functions pure (bug#42147)
Extend the list of 'pure' functions to many predicates and numerical
functions that we are reasonably confident will give portable results.
Also include various list and array accessors, because our use of purity
in the byte compiler isn't affected by the mutability of arguments.

* lisp/emacs-lisp/byte-opt.el: Update example in comment.
(pure-fns): Add many functions.
(byte-optimize-form-code-walker) Don't signal errors during evaluation
of calls to pure functions with constant arguments at compile time,
since such calls are not necessarily reachable.
2020-07-06 12:54:17 +02:00
Mattias Engdegård
c10293e168 Relax portable number check in byte compiler (bug#42147)
With bignums, the set of representable integers is no longer
platform-dependent, and since we use nothing but IEEE754 64-bit
floats, all numbers are now portable.  Take advantage of this fact
to simplify constant-folding in the byte compiler, allowing it to
be applied more widely.

* lisp/emacs-lisp/byte-opt.el (byte-opt--portable-max)
(byte-opt--portable-min, byte-opt--portable-numberp): Remove.
(byte-opt--arith-reduce, byte-optimize-minus, byte-optimize-1+)
(byte-optimize-1-): Simplify: any number will do, and if N is a
number, then so are -N, N+1 and N-1.
2020-07-05 16:56:32 +02:00
Andrea Corallo
2593bbee51 * Relax constant folding rules
* lisp/emacs-lisp/comp.el (comp-function-optimizable-p): No need to
check for operands or result to be fixnums.
2020-07-04 15:55:48 +01:00
Andrea Corallo
b0f683ec16 * Fix missing tail recursion elimination
* lisp/emacs-lisp/comp.el (comp-tco-func): Fix tail recursion
	elimination given now functions in LIMPLE are expressed with
	the C name.
2020-07-02 22:55:42 +02:00
Andrea Corallo
8f81859497 Rework `comp-c-func-name' arguments
* lisp/emacs-lisp/comp.el (comp-c-func-name): Add FIRST argument
	to ignore the compiler context and return the first name.

	* lisp/emacs-lisp/disass.el (disassemble-internal): Update the
	`comp-c-func-name' call.
2020-07-02 22:39:39 +02:00
Andrea Corallo
b67e156041 * Add to possibility to write per pass specific tests
* lisp/emacs-lisp/comp.el (comp-post-pass-hooks): New special
	variable.
	(native-compile): Run what is registered in
	`comp-post-pass-hooks'.
2020-07-02 22:39:32 +02:00
Andrea Corallo
4681f33071 Fix lambda-list relocation class
Lambda-lists must stay in the same relocation class of the object
referenced by code to respect uninterned symbols.

	* lisp/emacs-lisp/comp.el (comp-prepare-args-for-top-level): Break
	the original function in a generic specializing for
	dynamic/lexical functions.  When allocating the lambda-list for
	dynamic functions do that in the default relocation class.
	(comp-emit-for-top-level): Make use of the new
	`comp-prepare-args-for-top-level'.
	(comp-emit-lambda-for-top-level): Likewise.
2020-06-30 21:30:35 +02:00
Andrea Corallo
0ce4bf3ede * Do not skip native compilation for leim subfolder during boostrap
* lisp/emacs-lisp/comp.el (comp-bootstrap-black-list): Remove
	"^leim/".
2020-06-28 21:23:45 +01:00
Andrea Corallo
0eedb5af0b Merge remote-tracking branch 'savannah/master' into HEAD 2020-06-27 21:42:16 +01:00