In a previous commit, the local-variable read-symbol-shorthands is
already read into the temporary buffer used for the autoload parsing
aerobatics, so all we needed to do in 'l-g--compute-prefixes' is
use 'read' to give 'read-symbol-shorthands' a chance to kick in.
* lisp/emacs-lisp/loaddefs-gen.el
(loaddefs-generate--compute-prefixes):
Add font locking to the shorthand prefix of a given printed symbol
name by checking if any of the shorthand prefixes in
read-symbol-shorthands are a prefix for that print name. Although
this does more string comparisons, it didn't prove to be any slower
than the existing approach, and is more correct.
This version is more accurate when highlighting files with many
overlapping shorthands. Given:
;; Local Variables:
;; read-symbol-shorthands: (("bc-" . "breadcrumb-")
;; ("aw-" . "ace-window-")
;; ("zorglub/" . "ace-window-")
;; ("he//" . "hyperdrive-entry--")
;; ("h//" . "hyperdrive--")
;; ("he/" . "hyperdrive-entry-")
;; ("h/" . "hyperdrive-"))
;; End:
The following are correct highlights on print names
'(zorglub/blerh ; hilits "zorglub/" reads to 'ace-window-blerh'
he/foo ; hilits "he/" reads to 'hyperdrive-entry-foo'
he//bar ; hilits "he//" reads to 'hyperdrive-entry--bar'
h/coiso ; hilits "h/" reads to 'hyperdrive-coiso'
h//thingy ; hilits "h//" reads to 'hyperdrive--thingy'
bc-yo ; hilits "bc-" reads to 'breadcrumb-yo'
aw-thingy ; hilits "aw-" reads to 'ace-window-thingy'
)
Co-authored-by: Jonas Bernoulli <jonas@bernoul.li>
Co-authored-by: Joseph Turner <joseph@ushin.org>
* lisp/emacs-lisp/shorthands.el (shorthands-font-lock-shorthands):
We used to print dynamic docstrings "manually" for two reasons:
- References should look like `(#$ . POS)` but `prin1` was unable
to print just `#$` for an sexp.
- `make-docfile` needed to find those docstrings and the object
to which they belonged.
The second point is moot now that we don't use `make-docfile` on
`.elc` files. So this patch lifts the first restriction,
using `print-number-table`.
The rest of the patch then simplifies and regularises the
bytecompiler's generation of dynamic docstrings, which can
now also easily be done for "inner" defvars and other places.
* src/print.c (print_preprocess, print_object): Handle strings in
`print-number-table`.
(Vprint_number_table): Improve docstring.
* lisp/emacs-lisp/bytecomp.el:
(byte-compile--list-with-n): New function.
(byte-compile--docstring-style-warn): Rename from
`byte-compile-docstring-style-warn` and change calling convention.
(byte-compile--\#$, byte-compile--docstrings): New vars.
(byte-compile-close-variables): Bind them.
(byte-compile--docstring): New function.
(byte-compile-from-buffer): Set `byte-compile--\#$`.
(byte-compile-output-file-form): Use `byte-compile--\#$` instead
of special casing specific forms.
(byte-compile--output-docform-recurse, byte-compile-output-docform):
Delete functions.
(byte-compile-file-form-autoload, byte-compile-file-form-defalias)
(byte-compile-file-form-defvar-function, byte-compile-lambda):
Use `byte-compile--docstring` and `byte-compile--list-with-n`.
(byte-compile--declare-var): Add optional `not-toplevel` arg.
(byte-compile-defvar): Add `toplevel` arg. Use `byte-compile--docstring`.
(byte-compile-file-form-defvar): Delegate to `byte-compile-defvar`.
(byte-compile--custom-declare-face): New function. Use it for
`custom-declare-face`.
(byte-compile-file-form-defmumble): Use `byte-compile-output-file-form`
* src/doc.c (Fdocumentation_stringp): New function.
(syms_of_doc): Defsubr it.
(store_function_docstring): Remove left-over code from when we
used DOC for the docstring of some Lisp files.
* lisp/cus-face.el (custom-declare-face): Accept dynamic docstrings.
* lisp/faces.el (face-documentation): Handle dynamic docstrings.
* lisp/help-fns.el (describe-face): Simplify accordingly.
Monitors are wider now than when these defaults were first set, and it
is useful to take better advantage of that, to fit text on fewer lines.
Yet, it has repeatedly been shown that overly long lines reduce
readability:
"A reasonable guideline would be 55 to 75 characters per line."[1]
We also don't want to disfavor narrow displays, like mobile phones; a
more promising direction here might be to automatically word wrap
docstrings and make their maximum width customizable. That might
require a new docstring format, however.
Bumping it by 7 characters, from 65 to 72, seems a reasonable compromise
for now. Consideration was given to increasing it to 70 or 75, but 72
happens to be a commonly recommended maximum line width elsewhere (see
Fortran 66, Python docstrings, commit message recommendations, etc.),
and we might as well do the same.
This change was discussed in:
https://lists.gnu.org/r/emacs-devel/2022-07/msg00217.html
[1] "Optimal Line Length in Reading — A Literature Review", Nanavati and
Bias, Visible Language, Vol. 39 No. 2 (2005).
https://journals.uc.edu/index.php/vl/article/view/5765
* lisp/emacs-lisp/lisp-mode.el (emacs-lisp-docstring-fill-column):
* .dir-locals.el (fill-column, emacs-lisp-docstring-fill-column):
Bump default to 72.
The obsolete lazy-loaded bytecode feature, enabled by
`byte-compile-dynamic`, slows down Lisp execution even when not in use
because every call to a bytecode function has to check that function
for laziness.
This change forces up-front loading of all lazy bytecode so that we
can remove all those checks. (Dynamically loaded doc strings are not
affected.)
There is no point in generating lazy bytecode any more so we stop
doing that; this simplifies the compiler. `byte-compile-dynamic` now
has no effect.
This is a fully compatible change; the few remaining users of
`byte-compile-dynamic` should not notice any difference.
* src/lread.c (bytecode_from_rev_list): Force eager loading of
lazy bytecode.
* src/bytecode.c (exec_byte_code): Remove lazy bytecode checks.
* src/eval.c (fetch_and_exec_byte_code, Ffetch_bytecode): Remove.
(funcall_lambda): Call exec_byte_code directly, avoiding checks.
* lisp/subr.el (fetch-bytecode): New definition, obsolete no-op.
* lisp/emacs-lisp/disass.el (disassemble-1):
* lisp/emacs-lisp/bytecomp.el (byte-compile-unfold-bcf):
Remove calls to fetch-bytecode.
(byte-compile-dynamic): Update doc string.
(byte-compile-close-variables, byte-compile-from-buffer)
(byte-compile-insert-header, byte-compile-output-file-form)
(byte-compile--output-docform-recurse, byte-compile-output-docform)
(byte-compile-file-form-defmumble):
Remove effects of byte-compile-dynamic.
* doc/lispref/compile.texi (Dynamic Loading): Remove node now that
the entire `byte-compile-dynamic` facility has been rendered inert.
* etc/NEWS: Announce changes.
* lisp/emacs-lisp/bytecomp.el (byte-compile--reify-function):
Use `macroexp-parse-body` and only handle closures.
(byte-compile): Clarify the control and data flow a bit.
* lisp/emacs-lisp/derived.el (define-derived-mode): Use a reference
to the mode symbol instead of the mode's "pretty" name in
the hook variable's docstring.
5bb5590dec Fix blunder in labeled_narrow_to_region
78ddb32fad Fix documentation of icon-elements
725a3f32f8 ; Fix typos in symbol names
6653ee66ca Improve two docstrings in ox-latex
7d869a0402 Doc fix in auth-source-read-char-choice
f149de223b Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/...
1f97a87879 Fix info-xref-tests
51f391998b Add @kindex in manuals for existing keybindings on 'C-x x...
While at it, this fixes a bug where a traced function was not
able to set `deactivate-mark`.
* lisp/emacs-lisp/trace.el (trace--insert): New function, extracted
from `trace-make-advice`. Output to stdout in batch mode.
(trace--entry-message): Rename from `trace-entry-message`.
Change calling convention. Do the insertion directly from here.
(trace--exit-message): Rename from `trace-exit-message`.
Change calling convention. Do the insertion directly from here.
(trace-make-advice, trace-values): Simplify accordingly.
* lisp/emacs-lisp/shortdoc.el (hash-table): Remove hash-table-size entry.
* doc/lispref/hash.texi (Other Hash):
* src/fns.c (Fhash_table_size): Make it clear that hash-table-size is
probably not worth using.
In addition to naming the advice function `symbol@name', set
the 'name' property to NAME.
* lisp/emacs-lisp/nadvice.el (define-advice): set the 'name'
property to NAME (requested in Bug#68114). Fixes Bug#68294.
* doc/lispref/functions.texi (Advising Named Functions): Document
that 'define-advice' installs the advice with the specified name.
This fixes bug#68200.
* lisp/emacs-lisp/bytecomp.el (byte-compile-output-docform):
Note that let-binding a buffer local variable leaves it buffer
local, hence to transfer the binding of
byte-compile-dynamic-docstrings to the output buffer, an
intermediate variable is needed. Implement this.
* lisp/emacs-lisp/package.el (package-menu--version-predicate): Ignore
any errors raised by 'version-to-list', thus falling back to the
default version list. (Bug#68317)
(cherry picked from commit eb913c7501)
* lisp/emacs-lisp/package.el (package-menu--version-predicate): Ignore
any errors raised by 'version-to-list', thus falling back to the
default version list. (Bug#68317)
Fix support for multiple maintainers in `describe-package` and
in `package-report-bug`.
* lisp/emacs-lisp/package.el (describe-package-1): There's no
`:maintainers:`, instead `:maintainer` can hold a list of maintainers.
(package-maintainers): Adapt to the possibility of having
multiple maintainers.
(package-report-bug): Don't burp if the package is not installed.
`ad-advice-remove' is already interactive, but it doesn't work with
new-style advice.
* lisp/emacs-lisp/nadvice.el (advice-remove): Make it
interactive (Bug#67926).
* doc/lispref/functions.texi (Advising Named Functions): Document that
'advice-remove' is now an interactive command.
* lisp/emacs-lisp/icons.el (icons--create): Handle the case when
ICON is a file that doesn't exists or is unreadable. Suggested by
David Ponce <da_vid@orange.fr>. (Bug#66846)
Reimplement `backtrace-on-redisplay-error` using `push_handler_bind`.
This moves the code from `signal_or_quit` to `xdisp.c` and
`debug-early.el`.
* lisp/emacs-lisp/debug-early.el (debug-early-backtrace):
Add `base` arg to strip "internal" frames.
(debug--early): New function, extracted from `debug-early`.
(debug-early, debug-early--handler): Use it.
(debug-early--muted): New function, extracted (translated) from
`signal_or_quit`; trim the buffer to a max of 10 backtraces.
* src/xdisp.c (funcall_with_backtraces): New function.
(dsafe_calln): Use it.
(syms_of_xdisp): Defsym `Qdebug_early__muted`.
* src/eval.c (redisplay_deep_handler): Delete var.
(init_eval, internal_condition_case_n): Don't set it any more.
(backtrace_yet): Delete var.
(signal_or_quit): Remove special case for `backtrace_on_redisplay_error`.
* src/keyboard.c (command_loop_1): Don't set `backtrace_yet` any more.
* src/lisp.h (backtrace_yet): Don't declare.
`macroexp--with-extended-form-stack` used manual push/pop so that upon
non-local exits the "deeper" value is kept, so the error handler gets
to know what was the deeper value, so as to be able to compute more
precise error locations.
Replace this with a `handler-bind` which catches that "deeper" value
more explicitly.
* lisp/emacs-lisp/bytecomp.el (bytecomp--displaying-warnings):
Use `handler-bind` to catch the value of `byte-compile-form-stack`
at the time of the error. Also consolidate the duplicated code.
* lisp/emacs-lisp/macroexp.el (macroexp--with-extended-form-stack):
Use a plain dynbound let-rebinding.
Move ad-hoc code meant to ease debugging of bootstrap (and batch mode)
to `top_level_2` so it doesn't pollute `signal_or_quit`.
* src/lisp.h (pop_handler, push_handler_bind): Declare.
* src/keyboard.c (top_level_2): Setup an error handler to call
`debug-early` when noninteractive.
* src/eval.c (pop_handler): Not static any more.
(signal_or_quit): Remove special case for noninteractive use.
(push_handler_bind): New function, extracted from `Fhandler_bind_1`.
(Fhandler_bind_1): Use it.
(syms_of_eval): Declare `Qdebug_early__handler`.
* lisp/emacs-lisp/debug-early.el (debug-early-backtrace): Weed out
frames below `debug-early`.
(debug-early--handler): New function.
* lisp/emacs-lisp/ert.el (ert--should-signal-hook): Delete function.
(ert--expand-should-1): Don't bind `signal-hook-function`.
(ert--test-execution-info): Remove `next-debugger` slot.
(ert--run-test-debugger): Adjust to new calling convention.
Pass the `:backtrace-base` info to the debugger.
(ert--run-test-internal): Use `handler-bind` rather than let-binding
`debugger` and `debug-on-error`.
* lisp/emacs-lisp/ert-x.el (ert-remote-temporary-file-directory): Don't
use `defconst` if it's not meant to stay constant (e.g. we let-bind it
in tramp-tests.el).
AFAIK, this provides the same semantics as Common Lisp's `handler-bind`,
modulo the differences about how error objects and conditions are
represented.
* lisp/subr.el (handler-bind): New macro.
* src/eval.c (pop_handler): New function.
(Fhandler_Bind_1): New function.
(signal_or_quit): Handle new handlertypes `HANDLER` and `SKIP_CONDITIONS`.
(find_handler_clause): Simplify.
(syms_of_eval): Defsubr `Fhandler_bind_1`.
* doc/lispref/control.texi (Handling Errors): Add `handler-bind`.
* test/src/eval-tests.el (eval-tests--handler-bind): New test.
* lisp/emacs-lisp/lisp-mode.el (lisp-font-lock-keywords):
Move 'handler-bind' from CL-only to generic Lisp.
(handler-bind): Remove indentation setting, it now lives in the macro
definition.
* lisp/emacs-lisp/comp.el (comp-delete-or-replace-file): Avoid
race condition by relying on 'rename-file' being an atomic
operation on Posix filesystems. (Bug#68083)
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
Avoid false positive when a variable contains a keybinding (for
example, "C-g"). (Bug#68002)
* test/lisp/emacs-lisp/checkdoc-tests.el
(checkdoc-docstring-avoid-false-positive-ok): New test.
The reason for warning about a missing footer line (";;; foo.el ends
here") is that package.el up until version 27.1 would refuse to
install a package without it. Emacs 27.1 or later will install such
packages, but will issue a warning, the purpose of which is to
encourage package authors not to break backwards-compatibility.
However, if the minimum required Emacs version for a package is 30.1,
we do not need to worry about compatibility with earlier versions of
Emacs -- the package author has already explicitly said that the
package will not work on earlier versions. For such packages, there
is no need to warn about a missing footer line.
In the future, this warning could be removed, but it is premature to
do that now. (See Bug#26490.) Thus, for packages that does not
specify a minimum version of Emacs, we continue to issue the warning.
We will also continue to warn for packages requiring Emacs 27 to 29,
since those versions will themselves warn if the footer is missing.
* lisp/emacs-lisp/package.el (package-buffer-info): Don't warn if the
footer line is missing for packages requiring Emacs 30.1 or later.