Stefan Kangas [Fri, 2 Feb 2024 11:28:54 +0000 (12:28 +0100)]
Increase `emacs-lisp-docstring-fill-column` to 72
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
Sacha Chua [Fri, 26 Jan 2024 13:54:03 +0000 (08:54 -0500)]
shr: Correct SVG attribute case
* lisp/net/shr.el (shr-correct-attribute-case): New constant.
(shr-correct-dom-case): New function to correct SVG attribute case.
(shr-tag-svg): Correct SVG attribute cases before using them.
Eshel Yaron [Sat, 3 Feb 2024 15:06:02 +0000 (16:06 +0100)]
Support sorting bookmark completions by last modified
* lisp/bookmark.el (bookmark-sort-by-last-modified-time): New fun.
(bookmark-completing-read): Provide it as a sorting option via
'minibuffer-completions-sort-orders'.
Po Lu [Thu, 1 Feb 2024 08:16:09 +0000 (16:16 +0800)]
Prevent continuation from affecting tab width in/after line prefix
* src/dispextern.h (struct it) <wrap_prefix_width>: New field,
synchronized with current_x when producing glyphs for wrap
prefixes, and subtracted from it->current_x when computing tab
widths.
* src/term.c (produce_glyphs): Set wrap_prefix_width.
* src/xdisp.c (start_display, display_min_width, move_it_to)
(move_it_vertically_backward, move_it_by_lines)
(window_text_pixel_size, display_tab_bar_line)
(display_tool_bar_line, redisplay_internal, redisplay_window)
(try_window_id, insert_left_trunc_glyphs)
(extend_face_to_end_of_line, display_line)
(Fmove_point_visually): Set or clear wrap_prefix_width as
appropriate.
(gui_produce_glyphs): Set or clear it->wrap_prefix_width. When
computing the base position of a tab character, do not subtract
the continuation line width if a line prefix is the current
iterator method. Subtract the wrap_prefix_width otherwise, in
order that the width of the tab is computed free of influence
from the wrap prefix.
Eshel Yaron [Fri, 2 Feb 2024 12:33:43 +0000 (13:33 +0100)]
; Fix updating completion preview after deletion at eob
* lisp/completion-preview.el (completion-preview--show): Use the
actual overlay position, instead of its 'completion-preview-end'
property, in case the overlay has moved (e.g. when called after a
deletion command).
This fixes an issue where 'completion-preview-next-candidate' would
fail to take into account the part of the symbol that follows
point (the suffix) when point is at the middle of a symbol, as well as
a similar issue in 'completion-preview--show' that would manifest with
slow 'completion-at-point-functions'.
* lisp/completion-preview.el (completion-preview-next-candidate)
(completion-preview--show): Use recorded 'completion-preview-end'
position instead of current point.
* test/lisp/completion-preview-tests.el (completion-preview-mid-symbol-cycle):
New test.
Bytecode engine fast-path streamlining of plain symbols
* src/bytecode.c (exec_byte_code):
Only use fast-path optimisations for calls and dynamic variable
reference and setting where the symbol is plain, which is much faster.
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.
Allow equal user-defined hash table tests with different names
Hash tables using different user-defined tests defined identically
sometimes ended up using the wrong test (bug#68668).
* src/fns.c (get_hash_table_user_test): Take test name into account
when matching the test object.
* test/src/fns-tests.el (fns--define-hash-table-test): New.
Po Lu [Wed, 31 Jan 2024 06:34:19 +0000 (14:34 +0800)]
Don't hang when display objects are displaced by line or wrap-prefixes
This fixes a hang that would frequently rear its ugly head while
displaying messages in the `telega.el' instant messenger client,
which inserts images approaching the width of the window with
line and wrap prefixes.
* src/xdisp.c (move_it_in_display_line_to): If a line or wrap
prefix is set in place, do not generate continuation lines until
a minimum of one glyph has been produced outside that prefix.
(move_it_to): Remove the previous workaround that could not
recover from errors caused by display strings.
(display_line): Synchronize with move_it_in_display_line_to;
remove old workaround that only provided for oversized wrap
prefixes comprising `space' display objects.
Suppose the block comment is covered by a local parser. When we
indent line 3, treesit--indent-1 will try to get the local parser at
the BOL, and it'll get the local parser. But it shouldn't use the
local parser to indent this line, it should use the host parser of
that local parser instead.
So now, if treesit--indent-1 gets a local parser, but the local
parser's root node's start coincides with BOL, treesit--indent-1 will
use the host parser to indent this line.
We also need to make treesit--update-ranges-local to save the host
parser along with the local parser, and make
treesit-local-parsers-at/on extract and return the host parser.
I also switch the two cases in the cond form in treesit--indent-1:
(null (treesit-parser-list)) and (car local-parsers), (car
local-parsers) now takes precedence.
* lisp/treesit.el (treesit-local-parsers-at):
(treesit-local-parsers-on): Add WITH-HOST parameter.
(treesit--update-ranges-local): Save the host parser to the local
overlay.
(treesit--indent-1): If the root node of the local parser is at BOL,
use the host parser instead.
Stefan Monnier [Mon, 29 Jan 2024 23:56:19 +0000 (18:56 -0500)]
(byte-compile): Try and make it a bit more readable
* 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.
Po Lu [Mon, 29 Jan 2024 07:45:47 +0000 (15:45 +0800)]
Don't open a new line for long defuns being inserted at column 0
* lisp/vc/log-edit.el (log-edit--insert-filled-defuns): Don't
open a new line for long defuns at column 0.
* test/lisp/vc/log-edit-tests.el
(log-edit-fill-entry-space-substitution): Adjust expected
results to match change.
(log-edit-fill-entry-initial-wrapping): New test.
Po Lu [Mon, 29 Jan 2024 02:54:49 +0000 (10:54 +0800)]
Prevent filling from mangling ChangeLog defun lists
* lisp/vc/log-edit.el (log-edit-fill-entry): Replace space
characters within defun lists with NBSPs for the duration of
`fill-region''s execution, so that they are never considered
break points.
* test/lisp/vc/log-edit-tests.el
(log-edit-fill-entry-space-substitution): New test.
Jim Porter [Sun, 28 Jan 2024 23:49:03 +0000 (15:49 -0800)]
In Eshell, allow an escaped newline at the end of a command
Normally, "echo<RET>" runs the command "echo". Likewise,
"echo\<RET><RET>" should too: we escape the first newline, and then
the second one is unescaped and should send the command input to
Eshell. Previously, you had to press RET a third time, but now it
works as expected.
* lisp/eshell/esh-arg.el (eshell-looking-at-backslash-return): Make
obsolete.
(eshell-parse-backslash): A backslash sequence is only incomplete if
there's nothing at all after it.
* test/lisp/eshell/esh-arg-tests.el (esh-arg-test/escape/newline)
(esh-arg-test/escape-quoted/newline): Remove inaccurate comment;
escaped newlines are always special.
(esh-arg-test/escape/trailing-newline): New test.
* lisp/xt-mouse.el (xterm-mouse--same-button-p): New function.
(xterm-mouse--read-event-sequence): Use it to obey
`mouse-wheel-*-event` variables.
* lisp/mwheel.el (mouse-wheel-obey-old-style-wheel-buttons):
Update docstring.
Paul Eggert [Sun, 28 Jan 2024 08:15:38 +0000 (00:15 -0800)]
Rename TAG_PTR to TAG_PTR_INITIALLY
* src/lisp.h (TAG_PTR_INITIALLY): Rename from TAG_PTR, since calls
can be used only as initializers, and the convention elsewhere in
lisp.c is to give these macros names ending in ‘_INITIALLY’.
This should help avoid confusion such as we recently experienced
in make_lisp_symbol_internal. All uses changed.
Paul Eggert [Sun, 28 Jan 2024 08:15:38 +0000 (00:15 -0800)]
Fix C conformance issue in LISPSYM_INITIALLY
* src/lisp.h (LISPSYM_INITIALLY): Remove unnecessary cast to char *.
The C standard allows but does not require support for casts to
pointers in constant expressions in static initializers.
Eli Zaretskii [Sun, 28 Jan 2024 08:19:48 +0000 (10:19 +0200)]
Fix "emacs -nw" on MS-Windows
* src/w32term.c (w32_flip_buffers_if_dirty): Do nothing if F is
not a GUI frame. This avoids rare crashes in "emacs -nw".
* src/w32console.c (initialize_w32_display): Set the
ENABLE_EXTENDED_FLAGS bit in 'prev_console_mode'.
Jim Porter [Thu, 25 Jan 2024 02:32:00 +0000 (18:32 -0800)]
Fix command replacement with the Eshell builtin versions of "sudo" and "doas"
This is particularly important when the inner command to execute is an
alias. Aliases throw 'eshell-replace-command' too, so we want to do
this in two phases: first, replace the "sudo"/"doas" with a
let-binding of 'default-directory', and then later, let the alias code
do its own replacement (bug#68074).
* lisp/eshell/em-tramp.el (eshell/sudo, eshell/doas): Use
'eshell-replace-command' to wrap the inner command.
* test/lisp/eshell/em-tramp-tests.el (mock-eshell-named-command):
Remove.
(em-tramp-test/sudo-basic, em-tramp-test/sudo-user)
(em-tramp-test/doas-basic, em-tramp-test/doas-user): Catch
'eshell-replace-command'.
Support a local repo as URL in 'treesit-language-source-alist'
Sometimes people may need to bisect to find specific revision
in a grammar library's repo. In this case they'd want to point
the URL to the local repo to avoid cloning it on every rebuild.
So add support for a directory instead of URL in
'treesit-language-source-alist'.
* lisp/treesit.el (treesit--install-language-grammar-1): Test
if URL is a local directory. Then if it is, avoid cloning the
repo and removing the path on success.
(treesit--git-clone-repo): Factor out the code for cloning to
a separate function.
(treesit--git-checkout-branch): A helper to checkout the
revision for cases where we didn't clone the repo but want it
to point the revision. (Bug#68579)
Manuel Giraud [Sat, 27 Jan 2024 16:23:06 +0000 (17:23 +0100)]
Enable marking tagged with ls -F
Bug#68637
* lisp/image/image-dired-dired.el (image-dired-mark-tagged-files):
Enable marking tagged for executable and symlink images when
'dired-listing-switches' includes -F.
Eli Zaretskii [Sat, 27 Jan 2024 17:11:22 +0000 (19:11 +0200)]
Allow users to opt out of following Windows Dark mode
* src/w32fns.c (globals_of_w32fns) <w32-follow-system-dark-mode>:
New variable.
(w32_applytheme): Disable application of Dark mode if
'w32-follow-system-dark-mode' is nil.
Daniel Brooks [Sun, 5 Nov 2023 08:03:37 +0000 (01:03 -0700)]
Calc parses fractions written using U+2044 FRACTION SLASH
Fractions of the form 123⁄456 are handled as if written 123:456. Note
in particular the difference in behavior from U+2215 DIVISION SLASH
and U+002F SOLIDUS, which result in division rather than a rational
fraction.
* lisp/calc/calc-aent.el (math-read-replacement-list): Substitute a
colon for any fraction slash. (Bug#66944)
* test/lisp/calc/calc-tests.el (calc-frac-input): Test various
fraction types.
Revert DOHASH to the fast (field-caching) implementation but with
an assertion to detect misuses. Add DOHASH_SAFE for use in
code that must tolerate arbitrary mutation of the table being
iterated through.
* src/lisp.h (DOHASH): Go back to fast design that only allows
restricted mutation, but with a checking assertion.
(DOHASH_SAFE): New macro that tolerates arbitrary mutation while being
much simpler (and acceptably fast).
* src/fns.c (Fmaphash):
* src/comp.c (compile_function, Fcomp__compile_ctxt_to_file):
Use DOHASH_SAFE.
Mekeor Melire [Mon, 4 Dec 2023 15:37:37 +0000 (16:37 +0100)]
Add option Info-url-alist
* lisp/info.el (Info-url-alist): New option mapping manuals
to URLs.
(Info-url-for-node): Use it.
* test/lisp/info-tests.el (test-info-urls): Add more tests.
In particular, 'Info-url-for-node' should error when
manual-name is not handled in 'Info-url-alist'.
* etc/NEWS: Announce the change. (Bug#67615)
It is now possible to avoid extending
'completion-at-point-functions' in Text mode and its descendants.
* lisp/textmodes/text-mode.el
(text-mode-meta-tab-ispell-complete-word): Rename to...
(text-mode-ispell-word-completion): ...this. Extend with another
option 'completion-at-point'.
(text-mode): Only extend 'completion-at-point-functions' when
'text-mode-ispell-word-completion' is 'completion-at-point'.
(Bug#67527)
* etc/NEWS: Update the entry about 'M-TAB' in Text mode.
Eli Zaretskii [Sat, 27 Jan 2024 09:44:54 +0000 (11:44 +0200)]
Minor fix in 'describe-language-environment'
* lisp/international/mule-cmds.el (describe-language-environment):
Use 'current-language-environment' as DEFAULT in the prompt.
Patch by Thierry Volpiatto <thievol@posteo.net>. (Bug#68602)
Eli Zaretskii [Sat, 27 Jan 2024 08:52:47 +0000 (10:52 +0200)]
Improve 'refill-mode' in Org buffers
* lisp/textmodes/refill.el (refill-fill-paragraph-at): Use
'fill-forward-paragraph' instead of 'forward/backward-paragraph',
so that modes could customize the behavior. (Bug#68418)
Eli Zaretskii [Sat, 27 Jan 2024 08:38:14 +0000 (10:38 +0200)]
; Minor improvements in 'visual-wrap-prefix-mode'
* lisp/visual-wrap.el (visual-wrap-extra-indent): Add :version.
(visual-wrap-fill-context-prefix): Doc fix.
* lisp/menu-bar.el (menu-bar-line-wrapping-menu): Move the menu to
a better place, improve the help-echo text.
* etc/NEWS:
* doc/emacs/basic.texi (Continuation Lines): Improve documentation
and indexing of 'visual-wrap-prefix-mode'.
Eli Zaretskii [Sat, 27 Jan 2024 08:11:32 +0000 (10:11 +0200)]
Fix description of when "\xNNN" is considered a unibyte character
* doc/lispref/objects.texi (Non-ASCII in Strings): More accurate
description of when a hexadecimal escape sequence yields a unibyte
character. (Bug#68751)