Commit graph

6587 commits

Author SHA1 Message Date
Stefan Monnier
30914167fd * lisp/emacs-lisp/macroexp.el (macroexp-if): Fix typo 2021-01-27 18:53:58 -05:00
Stefan Monnier
d93bca0197 * lisp/emacs-lisp/pcase.el (pcase--split-pred): Handle memq pred.
Improve handling of the `member` tests generated from (or 'a 'b 'c).
This will expand

    (pcase EXP ((and (or 1 2 3) (guard (FOO))) EXP1) (1 EXP2) (6 EXP3))

to

    (cond ((memql '(3 2 1) EXP)
           (cond ((FOO) EXP1) ((eql EXP 1) EXP2)))
          ((eql EXP 6) EXP3))

rather than to

    (cond ((memql '(3 2 1) EXP)
           (cond ((FOO) EXP1) ((eql EXP 1) EXP2) ((eql EXP 6) EXP3)))
          ((eql EXP 1) EXP2)
          ((eql EXP 6) EXP3))
2021-01-27 18:51:09 -05:00
Stefan Monnier
d168110a32 * lisp/emacs-lisp/macroexp.el (macroexp--expand-all): Perform β-reduction
Also, in `funcall` macroexpand the function before checking to see if
we can remove the `funcall`.

(macroexp-if): Trim trailing `nil` in the generated code while we're at it.
2021-01-27 18:47:28 -05:00
Lars Ingebrigtsen
a10c74fbea Fontify special forms and macros the same
* lisp/emacs-lisp/lisp-mode.el (lisp--el-match-keyword): Handle
special forms and macros the same way (bug#43265).  This makes
things like (setq a '(if a b)) be fontified correctly (i.e., not
fontified as a keyword).
2021-01-25 07:44:29 +01:00
Lars Ingebrigtsen
9503f8d96c Rewrite lisp--el-funcall-position-p to be inverse of the -not function
* lisp/emacs-lisp/lisp-mode.el (lisp--el-funcall-position-p):
Rename and rewrite to return the inverse value.  Non-inverted
predicate functions are easier to reason about.
(lisp--el-non-funcall-position-p): Make obsolete.
2021-01-24 23:25:52 +01:00
Lars Ingebrigtsen
196be2bf12 Fix macro fontification in `condition-case' handler bodies
* lisp/emacs-lisp/lisp-mode.el (lisp--el-non-funcall-position-p):
Fontify macros in the BODY of HANDLERS in `condition-case'
correctly (bug#43265).
2021-01-24 21:43:25 +01:00
Lars Ingebrigtsen
8f28a1b9da Tweak `condition-case' keyword highlights
* lisp/emacs-lisp/lisp-mode.el (lisp--el-non-funcall-position-p):
Tweak `condition-case' position check to skip the VAR form.
2021-01-24 21:31:09 +01:00
Stefan Monnier
1559cc445a Fix missing file&line info in "Unknown defun property" warnings
* lisp/emacs-lisp/byte-run.el (defmacro, defun): Use
`macroexp--warn-and-return` rather than `message`.

* lisp/emacs-lisp/macroexp.el: Fix `macroexp--compiling-p`.
(macroexp--warn-and-return): Don't try and detect repetition on forms
like `nil`.
(macroexp-macroexpand): Don't forget to bind `macroexpand-all-environment`.
2021-01-23 16:04:36 -05:00
Stefan Monnier
b41b4add7b Fix spurious "Lexical argument shadows the dynamic variable" due to inlining
Before this patch doing:

    rm lisp/calendar/calendar.elc
    make lisp/calendar/cal-hebrew.elc

would spew out lots of spurious such warnings about a `date` argument,
pointing to code which has no `date` argument in sight.  This was
because that code had calls to inlinable functions (taking a `date`
argument) defined in `calendar.el`, and while `date` is a normal
lexical var at the site of those functions' definitions, it was
declared as dynbound at the call site.

* lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand):
Don't impose our local context onto the inlined function.

* test/lisp/emacs-lisp/bytecomp-tests.el: Add matching test.
2021-01-21 13:15:05 -05:00
Stefan Monnier
b9511362f5 * lisp/emacs-lisp/bytecomp.el (byte-compile--declare-var): Fix warning
Make sure the "declared after first use" is under the control of
the `lexical` option.
2021-01-20 20:17:11 -05:00
Lars Ingebrigtsen
61b716bd30 checkdoc-spellcheck-documentation-flag doc string improvement
* lisp/emacs-lisp/checkdoc.el
(checkdoc-spellcheck-documentation-flag): Mention
`ispell-kill-ispell' (bug#6221).
2021-01-20 22:15:38 +01:00
Lars Ingebrigtsen
1a6ed932d9 Revert "Always send Lisp words to checkdoc-ispell-init"
This reverts commit 93141d5813.

This would make checkdoc words be used in other flyspell
buffers.
2021-01-20 22:11:38 +01:00
Lars Ingebrigtsen
93141d5813 Always send Lisp words to checkdoc-ispell-init
* lisp/emacs-lisp/checkdoc.el (checkdoc-ispell-init): Always send
the Lisp words to the process (bug#6221).  This allows an existing
ispell process to be correctly initialised.
2021-01-20 22:01:08 +01:00
Juri Linkov
5065698c81 Move the ‘declare’ form before the interactive spec in 10 functions.
* lisp/emacs-lisp/package.el (package-menu-hide-package):
* lisp/font-lock.el (font-lock-debug-fontify):
* lisp/image.el (image-jpeg-p):
* lisp/mail/flow-fill.el (fill-flowed-test):
* lisp/mh-e/mh-speed.el (mh-speed-toggle, mh-speed-view):
* lisp/progmodes/project.el (project-async-shell-command)
(project-shell-command, project-compile):
* lisp/progmodes/sh-script.el (sh-assignment):
Fix special forms to follow in this order: docstring, declare, interactive.
2021-01-20 21:19:23 +02:00
Stefan Monnier
0d3635536d * lisp/emacs-lisp/subr-x.el (named-let): New macro 2021-01-20 14:13:15 -05:00
Stefan Monnier
66439d31ad * lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode): Add 2 new opts
This introduces two new optimizations.  They're designed for code like

    (while
        (let (...)
          (if ... (progn blabla t) (progn blabla nil)))
      ...)

and they allow the elimination of the test internal to `while` since
we can immediately know when we return `t` or `nil` what the result
of the test will be.

`cl-labels` tends to generate this kind of code when it applies the
tail-call optimization.
2021-01-20 14:13:15 -05:00
Stefan Monnier
4dfebf25c7 * lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode): Move some opts.
This moves two optimizations from the final pass to the main loop.
Both may enable further optimizations (and the second can be applied
repeatedly but "from the end", so the loop in the final pass only gets
to apply it once).
2021-01-20 14:13:15 -05:00
Stefan Monnier
09bfb12edc * lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode): Re-indent 2021-01-20 14:13:15 -05:00
Stefan Monnier
25e1b73294 * lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): Use pcase 2021-01-16 14:21:57 -05:00
Stefan Monnier
0ab56a4e93 * lisp/emacs-lisp/pcase.el: Add support for not to pred
(pcase--split-pred, pcase--funcall): Adjust for `not`.
(pcase--get-macroexpander): New function.
(pcase--edebug-match-macro, pcase--make-docstring)
(pcase--macroexpand): Use it.

* lisp/emacs-lisp/radix-tree.el (radix-tree-leaf): Use it!

* doc/lispref/control.texi (The @code{pcase} macro): Document it.

* lisp/emacs-lisp/ert.el (ert--explain-equal-rec): Remove redundant test.
2021-01-16 14:21:57 -05:00
Glenn Morris
0a26f47915 * lisp/emacs-lisp/seq.el (seq-concatenate): Unautoload (merge fix).
gitmerge-skip-regexp does not handle line breaks.
2021-01-15 09:38:20 +00:00
Glenn Morris
c83590b121 Merge from origin/emacs-27
488204cdc6 (origin/emacs-27) Remove one of recently added warnings ab...
55bc1560ac Fix assertion failure in window_box_height (Bug#45737)
27743e9e70 Fix cl-concatenate inlining
32a3758c84 Fix infloop in 'pixel-scroll-mode'
74d18957b8 Fix inhibiting the default.el loading in user init file
2021-01-14 07:50:28 -08:00
Stefan Monnier
d8936322f4 * lisp/emacs-lisp/eieio-base.el: Silence warnings in last change
(eieio-persistent-make-instance): Quote the `eieio-named` class name.
(eieio-named): Move before `eieio-persistent`.
2021-01-11 16:44:39 -05:00
Eric Ludlam
002f9dc091 eieio-base.el:
(eieio-persistent-make-instance): Save the backward compatible 'name'
of objects saved in the file, and if the newly loaded class inherits
from 'eieio-named', restore the name of the object.
Author: Eric Ludlam <zappo@gnu.org>
2021-01-11 16:20:57 -05:00
Basil L. Contovounesios
25dadca0d1
Hyperlink symbol names without word syntax in Help
* lisp/emacs-lisp/lisp-mode.el (lisp-el-font-lock-keywords-2)
(lisp-cl-font-lock-keywords-2): Allow single-character symbol names.
* lisp/help-mode.el (help-xref-symbol-regexp): Also match symbol
names starting with symbol syntax (bug#6601, bug#24309).
* test/lisp/help-mode-tests.el (help-mode-tests-xref-button): Test
hyperlink creation for function names without symbol syntax.
2021-01-10 13:37:38 +00:00
Daniel Martín
e62f71988f Minor shortdoc link improvements
* lisp/emacs-lisp/shortdoc.el (shortdoc--display-function): Use
describe-function as a fallback link when a function is not documented
in any Info manual.  Also make the link respond to mouse-1, like the
rest of *Help* links, and add a proper help-echo property.
* lisp/help-fns.el (help-fns--mention-shortdoc-groups): Same link
improvement as described before, this time for the shortdoc groups
(bug#45750).
2021-01-10 13:45:44 +01:00
Stefan Monnier
981d5eaba8 * lisp/emacs-lisp/cl-macs.el (cl--self-tco): Fix build of gnus-agent.el
Don't burp on "naked" variable let bindings.
2021-01-09 11:35:53 -05:00
Eli Zaretskii
fe7263803c Fix cl-concatenate use in macros
* lisp/emacs-lisp/cl-macs.el (inline): Remove cl-concatenate.
(Bug#45610)
2021-01-09 14:12:14 +02:00
Eli Zaretskii
27743e9e70 Fix cl-concatenate inlining
* lisp/emacs-lisp/seq.el (seq-concatenate): Auto-load it.  Do not
merge to master.  (Bug#45610)
2021-01-09 14:07:13 +02:00
Stefan Monnier
29c7f8c915 * lisp/emacs-lisp/cl-macs.el: Optimize self-calls in tail position
Implement a limited form of tail-call optimization for the special
case of recursive functions defined with `cl-labels`.  Only self-recursion
is optimized, no attempt is made to handle more complex cases such a mutual
recursion.

The main benefit is to reduce the use of the stack, tho in my limited
tests, this can also improve performance (about half of the way to
a hand-written `while` loop).

(cl--self-tco): New function.
(cl-labels): Use it.

* lisp/subr.el (letrec): Optimize single-binding corner case.

* test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs--labels): Add tests
to check that TCO is working.
2021-01-08 19:59:31 -05:00
Stefan Monnier
3b9dad88e0 * lisp/subr.el (letrec): Optimize some non-recursive bindings
* lisp/emacs-lisp/macroexp.el (macroexp--fgrep): Look inside bytecode
objects as well.

* test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs--labels):
* test/lisp/subr-tests.el (subr--tests-letrec): New tests.
2021-01-08 18:44:13 -05:00
Stefan Monnier
9d3d6f8500 * lisp/emacs-lisp/cl-generic.el (cl--generic-lambda): Fix last change 2021-01-08 18:28:47 -05:00
Stefan Monnier
768a352793 * lisp/emacs-lisp/macroexp.el (macroexp--fgrep): Rename from pcase--fgrep
* lisp/emacs-lisp/cl-generic.el (cl--generic-fgrep): Delete.
(cl--generic-lambda): Use `macroexp--pacse` instead.

* lisp/emacs-lisp/pcase.el (pcase--fgrep): Rename to `macroexp--fgrep`.
2021-01-08 17:57:26 -05:00
Michael Heerdegen
96bbbaec5c Fix obsolete variable warnings about class names
* lisp/emacs-lisp/eieio-core.el (eieio-defclass-autoload): Try to make
the wording of the warning about the obsoleted variable less confusing.
* lisp/emacs-lisp/bytecomp.el (byte-compile-check-variable): Don't
warn for lexical variables (Bug#39169).  Fix spurious `or'.
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp/warn-obsolete-variable-bound\.el): New test.
* test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variable-bound.el:
New file.
2021-01-06 10:51:28 +01:00
Stefan Monnier
cf672c6671 * lisp/emacs-lisp/package.el (package-activate-all): Another tweak
`package-quickstart.el` files presume `package-activated-list`
is a bound variable, so make sure this is the case even when `package.el` is
not yet loaded.
2021-01-05 21:26:03 -05:00
Stefan Monnier
7d7bfbf034 * lisp/emacs-lisp/autoload.el: Improve last change
It turns out there were other places that used `custom-initialize-delay`
on autoloaded variables and used various hacks to make it work with
`autoload.el`.  The new code makes those hacks unneeded.
Also, there's no point trying to "optimize" those rare cases anyway,
so I simplified the `autoload.el` code for those cases.

(make-autoload): For non-trivial cases,
just include the whole `defcustom` instead of trying to mimic it.

* lisp/mail/rmail.el (rmail-spool-directory): Remove hacks.
* lisp/info.el (Info-default-directory-list): Remove `progn` hack.

* lisp/custom.el (custom-declare-variable)
(custom-handle-all-keywords): Don't use pseudo-group `nil`.
2021-01-05 17:57:15 -05:00
Stefan Monnier
9973019764 * lisp/emacs-lisp/package.el: Load package-quickstart without package.el
Speed up startup when `package-quickstart` is in use by making it possible
to load the quickstart file without having to load `package.el` at all.

(package-user-dir, package-directory-list, package-quickstart-file):
Preload those variables.
(package--get-activatable-pkg): New fun, extracted from `package-activate`.
(package-activate): Use it.
(package--activate-all): New function, extracted from
`package-activate-all`.
(package-activate-all): Use it and make the function preloaded.
(package--archives-initialize): New function.
(package-install): Use it.
(list-packages): Avoid `switch-to-buffer`.
(package-get-descriptor): New function.

* lisp/startup.el (command-line): Simplify the code now that
package-user-dir and package-directory-list are preloaded.

* lisp/emacs-lisp/autoload.el (make-autoload): Add support for
`:initialize #'custom-initialize-delay` in `defcustom`.
2021-01-05 12:28:37 -05:00
Stefan Monnier
32c6732d16 * lisp/emacs-lisp/byte-run.el (make-obsolete): Make when mandatory
(define-obsolete-function-alias, make-obsolete-variable)
(define-obsolete-variable-alias): Adjust similarly.
2021-01-03 15:43:31 -05:00
Paul Eggert
50f3949119 Merge from origin/emacs-27
33d159c36f Fix copyright years by hand
2021-01-01 01:28:16 -08:00
Paul Eggert
ba05d005e5 Update copyright year to 2021
Run "TZ=UTC0 admin/update-copyright".
2021-01-01 01:13:56 -08:00
Paul Eggert
33d159c36f Fix copyright years by hand
These are dates that admin/update-copyright did not update.
2021-01-01 00:33:28 -08:00
Paul Eggert
8c1fe1e5ef Update copyright year to 2021
Run "TZ=UTC0 admin/update-copyright $(git ls-files)".
2021-01-01 00:32:32 -08:00
Stefan Kangas
72b8430fea Add lexical-binding cookie to autoload files
* build-aux/update-subdirs:
* lisp/emacs-lisp/autoload.el (autoload-rubric): Add lexical-binding
cookie to generated files (bug#44854).
2020-12-31 06:35:49 +01:00
Stefan Kangas
dd662fc972 Fix some over-wide docstrings
* lisp/cedet/semantic/analyze/refs.el
(semantic-analyze-refs-proto)
(semantic-analyze-refs-impl):
* lisp/cedet/semantic/symref.el
(semantic-symref-hit-to-tag-via-buffer):
* lisp/emacs-lisp/chart.el (chart-axis-draw):
* lisp/emacs-lisp/cl-macs.el (cl-defstruct, cl-loop):
* lisp/emacs-lisp/eieio-core.el (eieio--add-new-slot):
* lisp/eshell/em-unix.el (eshell/info):
* lisp/gnus/deuglify.el (gnus-outlook-rearrange-article):
* lisp/gnus/gnus-agent.el (gnus-agent-read-article-number):
* lisp/gnus/gnus-util.el (gnus-put-overlay-excluding-newlines)
(gnus-put-text-property-excluding-newlines):
* lisp/gnus/message.el (message-sort-headers):
* lisp/gnus/nntp.el (nntp-with-open-group)
(nntp-with-open-group-function):
* lisp/gnus/nnvirtual.el (nnvirtual-create-mapping):
* lisp/mail/feedmail.el (feedmail-fiddle-list-of-fiddle-plexes)
(feedmail-queue-reminder, feedmail-mail-send-hook-splitter):
* lisp/net/dictionary.el (dictionary-do-matching):
* lisp/obsolete/longlines.el (longlines-auto-wrap):
* lisp/org/ob-sql.el (org-babel-sql-dbstring-vertica):
* lisp/org/ol-bbdb.el (org-bbdb-date-list):
* lisp/progmodes/cc-cmds.el (c-mark-function):
* lisp/progmodes/cperl-mode.el (cperl-add-tags-recurse)
(cperl-add-tags-recurse-noxs-fullpath)
(cperl-add-tags-recurse-noxs):
* lisp/progmodes/etags.el (tags-search):
* lisp/progmodes/verilog-mode.el (verilog-delete-auto-buffer)
(verilog-auto-re-search-do, verilog-expand-vector-internal):
* lisp/textmodes/reftex-parse.el (reftex-init-section-numbers):
* lisp/textmodes/reftex-toc.el
(reftex-toc-load-all-files-for-promotion):
* lisp/textmodes/sgml-mode.el (html-mode):
* lisp/textmodes/table.el (table--transcoord-cache-to-table)
(table--transcoord-table-to-cache, table--remove-eol-spaces)
(table--region-in-cell-p, table-goto-bottom-right-corner)
(table-split-cell-horizontally):
* lisp/url/url-handlers.el (url-insert):
* lisp/vc/ediff-util.el (ediff-inferior-compare-regions): Fix doc
strings to not exceed 80-column limits.  (Bug#44858)
2020-12-30 12:44:19 +01:00
Lars Ingebrigtsen
dc771b6c40 Also count symbol plists in memory-report
* lisp/emacs-lisp/memory-report.el (memory-report--symbol-plist):
New function.
(memory-report): Use it.
2020-12-30 08:29:06 +01:00
Stefan Kangas
6b8bb47ac0 Fill some auto-generated docstrings
* lisp/emacs-lisp/easy-mmode.el (define-minor-mode)
(define-globalized-minor-mode): Fill auto-generated documentation
strings.  (Bug#44858)
* lisp/subr.el (internal--fill-string-single-line)
(internal--format-docstring-line): New functions.
2020-12-28 06:26:52 +01:00
Stefan Kangas
0ebea8ffbf Make byte-compiler warn about wide docstrings
* lisp/emacs-lisp/bytecomp.el (byte-compile--wide-docstring-p):
(byte-compile-docstring-length-warn): New defuns.
(byte-compile-docstring-max-column): New defcustom.
(byte-compile--wide-docstring-substitution-len): New variable.
(byte-compile-warning-types, byte-compile-warnings): New value
'docstrings'.
(byte-compile-file-form-autoload, byte-compile-file-form-defvar):
(byte-compile-file-form-defvar-function, byte-compile-lambda):
(byte-compile-defvar, byte-compile-file-form-defalias): Warn about too
wide docstrings.  (Bug#44858)

* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-warn-wide-docstring/defconst)
(bytecomp-warn-wide-docstring/defvar): New tests.
(bytecomp--define-warning-file-test): New macro.
(bytecomp/warn-wide-docstring-autoload\.el)
(bytecomp/warn-wide-docstring-custom-declare-variable\.el)
(bytecomp/warn-wide-docstring-defalias\.el)
(bytecomp/warn-wide-docstring-defconst\.el)
(bytecomp/warn-wide-docstring-define-abbrev-table\.el)
(bytecomp/warn-wide-docstring-define-obsolete-function-alias\.el)
(bytecomp/warn-wide-docstring-define-obsolete-variable-alias\.el)
(bytecomp/warn-wide-docstring-defun\.el)
(bytecomp/warn-wide-docstring-defvar\.el)
(bytecomp/warn-wide-docstring-defvaralias\.el)
(bytecomp/warn-wide-docstring-ignore-fill-column\.el)
(bytecomp/warn-wide-docstring-ignore-override\.el)
(bytecomp/warn-wide-docstring-ignore\.el)
(bytecomp/warn-wide-docstring-multiline-first\.el)
(bytecomp/warn-wide-docstring-multiline\.el): New tests.
* test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-autoload.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-custom-declare-variable.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-defalias.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-defconst.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-define-abbrev-table.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-define-obsolete-function-alias.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-define-obsolete-variable-alias.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-defun.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-defvar.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-defvaralias.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-ignore-fill-column.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-ignore-override.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-ignore.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-multiline-first.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-multiline.el:
New files.
2020-12-28 06:26:52 +01:00
Tim Landscheidt
8914fb2227 Do not output two spaces for non-autoloaded ieieo constructor functions
* lisp/emacs-lisp/eieio-opt.el (eieio-help-constructor): Amend
format to avoid two spaces for non-autoloaded object constructor
functions (bug#45454).

Copyright-paperwork-exempt: yes
2020-12-28 00:40:15 +01:00
Stefan Monnier
8d5a6c9ef5 * lisp/emacs-lisp/package.el (package-archives): Add NonGNU ELPA 2020-12-27 17:32:01 -05:00
Basil L. Contovounesios
df882c9701 ; Fix recent shortdoc.el and fns.c additions
* lisp/emacs-lisp/shortdoc.el (list): Fix typos.
* src/fns.c (Flength_equal): Fix docstring.
2020-12-27 13:14:30 +00:00