String hashing improvements (spread and performance)
Fix gaps in hashing coverage in the middle and end of even fairly short
strings. E.g., `outline-1`, `outline-2` etc all hashed to the exact
same value but with the patch, there are no collisions among the ~160000
symbols in the Emacs tree.
This change also improves average hashing speed by using fewer mixing
operations.
* src/fns.c (hash_string):
Use unit stride for fairly short strings, while retaining the cap of 8
samples for long ones.
Always hash the last word to ensure that the end of the string is
covered. For strings shorter than a word, use fewer loads and a single
reduction step.
Eshel Yaron [Wed, 14 Feb 2024 12:51:29 +0000 (13:51 +0100)]
Improve prompting 'customize-toggle-option'
* lisp/cus-edit.el (customize-option-history): New variable.
(custom-variable-prompt): Use it.
(customize-read-boolean-option): New function.
(customize-toggle-option): Use it.
Stefan Monnier [Wed, 14 Feb 2024 01:35:05 +0000 (20:35 -0500)]
hideif.el: Minor cleanup
* lisp/progmodes/hideif.el: Prefer #' to quote function names.
(hif-eval): Use `lexical-binding`.
(hif-ifx-regexp): Don't use `defconst` since `bovine/c.el` let-binds it.
(hif--intern-safe): Rename from `intern-safe` to fix this
namespace violation.
(hif-strtok): Adjust accordingly.
Steven Allen [Sat, 10 Feb 2024 18:05:11 +0000 (10:05 -0800)]
Respect :lisp-dir whilst scanning for VC package dependencies
* lisp/emacs-lisp/package-vc.el (package-vc--unpack-1):
Scan 'lisp-dir', if set, for lisp files instead of scanning the root
package directory. (Bug#69019)
Jim Porter [Tue, 13 Feb 2024 20:27:38 +0000 (12:27 -0800)]
; Compute the list of symbols for 'eshell-eval-using-options' once
* lisp/eshell/esh-opt.el (eshell--get-option-symbols): New function...
(eshell-eval-using-options): ... use it.
(eshell--do-opts, eshell--process-args): Take OPTION-SYMS.
* test/lisp/eshell/esh-opt-tests.el (esh-opt-test/process-args):
(esh-opt-test/process-args-parse-leading-options-only):
(esh-opt-test/process-args-external): Pass OPTION-SYMS in.
Eli Zaretskii [Tue, 13 Feb 2024 19:59:03 +0000 (21:59 +0200)]
Fix left-over from renaming 'comp-*' functions
* lisp/progmodes/elisp-mode.el (comp--write-bytecode-file): Call
this instead of 'comp-write-bytecode-file', its old name.
Reported by Arthur Miller <arthur.miller@live.com>.
Paul Eggert [Tue, 13 Feb 2024 17:54:51 +0000 (09:54 -0800)]
XSYMBOL eassume speedups
* src/lisp.h (XSYMBOL_WITH_POS_SYM, XSYMBOL): Help the compiler by using
eassume instead of eassert for XSYMBOL postconditions likely to be
useful for optimization later. With gcc 13.2 -O2 x86-64 this improved
speed on my usual “compile all .el files” benchmark by 0.7% and shrank
the text size of Emacs by 0.09%.
Paul Eggert [Tue, 13 Feb 2024 17:54:51 +0000 (09:54 -0800)]
Remove SYMBOL_WITH_POS_{POS,SYM}
* src/fns.c (internal_equal): Turn comment into eassert
that !symbols_with_pos_enabled.
(sxhash_obj): Simplify case of symbol with pos (when enabled).
* src/lisp.h (XSYMBOL_WITH_POS_SYM, XSYMBOL_WITH_POS_POS)
(maybe_remove_pos_from_symbol): New inline functions.
(SYMBOL_WITH_POS_SYM, SYMBOL_WITH_POS_POS): Remove.
All uses replaced by the new functions. This avoids some
double-checking in the source code, simplifies the code overall,
and avoids the need for "Type checking is done in the following
macro" comments to explain unusual code.
Paul Eggert [Tue, 13 Feb 2024 17:54:51 +0000 (09:54 -0800)]
Remove lisp_h_XCONS etc
When configured with --enable-checking and compiled with gcc -O0,
these macros evaluated arguments multiple times, which made it too
easy to mistakenly write code that behaves differently when debugging.
This patch does not affect performance in normal builds.
In --enable-checking builds with gcc -O0 it slows down my usual
benchmark (remove all '*.elc’ files and then 'make') by 4.4%.
I hope that’s good enough; if not I can complicate the macros to
tune better for debugging builds.
* src/lisp.h (lisp_h_SET_SYMBOL_VAL, lisp_h_SYMBOL_VAL)
(lisp_h_XCONS): Remove, moving each definiens to the corresponding
inline function. All uses removed.
Paul Eggert [Tue, 13 Feb 2024 17:54:51 +0000 (09:54 -0800)]
Remove lisp_h_PSEUDOVECTORP etc
* src/lisp.h (lisp_h_PSEUDOVECTORP, lisp_h_EQ, lisp_h_SYMBOLP):
Refactor by removing these macros, moving each definiens to its only
use. Now that we have symbols with position so that there is no longer
a non-lisp_h_* macro counterpart if DEFINE_KEY_OPS_AS_MACROS, there’s
no need to separate these definiens from their inline function bodies.
Paul Eggert [Tue, 13 Feb 2024 17:54:51 +0000 (09:54 -0800)]
Remove BASE2_EQ
* src/lisp.h (lisp_h_BASE2_EQ, BASE2_EQ): Remove. All uses
removed. BASE2_EQ was present only for minor optimization and
with current gcc -O2, BASE2_EQ does not affect performance, so
it’s not worth the hassle.
Paul Eggert [Tue, 13 Feb 2024 17:54:51 +0000 (09:54 -0800)]
Simplify and speed up EQ again
* src/lisp.h (lisp_h_BASE2_EQ, lisp_h_EQ): Simplify and refactor.
On x86-64 with GCC 3.2 this shrinks temacs text by 0.055% and
after removing all *.elc files speeds up 'make' by 1.0%.
Paul Eggert [Tue, 13 Feb 2024 17:54:50 +0000 (09:54 -0800)]
Simplify and speed up EQ
* src/lisp.h (lisp_h_BASE2_EQ, lisp_h_EQ):
Simplify by testing symbols_with_pos_enabled first.
On x86-64 with GCC 13.2 this shrinks temacs text by 1.5%
and after removing all *.elc files speeds up 'make' by 1.2%.
Juri Linkov [Tue, 13 Feb 2024 17:02:21 +0000 (19:02 +0200)]
More changes for treesitter support of outline-minor-mode (bug#68824)
* lisp/treesit.el (treesit-outline-level): Set NAMED arg of
'treesit-node-at' to t. Don't set IGNORE-MISSING arg of
'treesit-node-match-p' to t.
* lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode):
Add "singleton_method" to 'treesit-thing-settings'.
Set 'treesit-outline-predicate'. Kill local variables
'outline-regexp' and 'outline-level'.
Michael Albinus [Tue, 13 Feb 2024 16:12:34 +0000 (17:12 +0100)]
Add docstring for Tramp test macros
* test/lisp/net/tramp-tests.el (tramp--test-set-ert-test-documentation):
New defun.
(tramp--test-deftest-with-stat, tramp--test-deftest-with-perl)
(tramp--test-deftest-with-ls): Use it to define docstring.
Eshel Yaron [Wed, 14 Feb 2024 08:04:19 +0000 (09:04 +0100)]
Remove filesets.el and associated documentation
This library has some nice ideas, but it was never properly
integrated into (GNU) Emacs. We have better and more coherent
solutions these days, so its presence in tree burdens overall
maintenance with little benefit.
Eshel Yaron [Tue, 13 Feb 2024 20:56:53 +0000 (21:56 +0100)]
; Improve 'minibuffer-force-complete-and-exit'
* lisp/minibuffer.el (minibuffer-force-complete-and-exit): Use
base size as determined by 'completion-all-sorted-completions',
instead of the beginning of current completion field (from
'completion-boundaries'). Those can differ when
'partial-completion' picks up part of the previous fields. For
example, in file name completion with input "emacs/lisp/pr/xr",
we want to replace also the last field "pr" when completing to
"emacs/lisp/progmodes/xref.el".
* doc/lispref/elisp.texi (Top): Add new menu item "Outline Minor Mode"
after "Imenu".
* doc/lispref/modes.texi (Modes): Add new menu item "Outline Minor Mode"
after "Imenu".
(Major Mode Conventions): Mention "Outline Minor Mode" with @pxref.
(Outline Minor Mode): New node.
* doc/lispref/parsing.texi (Tree-sitter Major Modes): Mention
'treesit-outline-predicate' with @pxref.
* lisp/treesit.el (treesit-outline-predicate): New buffer-local variable.
(treesit-outline-predicate--from-imenu): New internal function.
(treesit-outline-search, treesit-outline-level): New functions.
(treesit-major-mode-setup): Set up treesit-outline-predicate,
outline-search-function and outline-level.
* lisp/progmodes/c-ts-mode.el (c-ts-mode--outline-predicate):
New internal function.
(c-ts-base-mode): Set 'treesit-outline-predicate' to
'c-ts-mode--outline-predicate'.
* lisp/progmodes/heex-ts-mode.el (heex-ts-mode): Kill inherited
local variables 'outline-heading-end-regexp', 'outline-regexp',
'outline-level'.
* lisp/progmodes/lua-ts-mode.el (lua-ts-mode): Remove 'outline-regexp'.
Suggested by john muhl <jm@pub.pink>.
* lisp/textmodes/html-ts-mode.el (html-ts-mode): Kill inherited
local variables 'outline-heading-end-regexp', 'outline-regexp',
'outline-level'.
Make minibuf-tests independent of obarray hash order
* test/src/minibuf-tests.el (minibuf-tests--set-equal): New.
(minibuf-tests--all-completions)
(minibuf-tests--all-completions-pred)
(minibuf-tests--all-completions-regexp): Use it.
Eshel Yaron [Mon, 12 Feb 2024 17:38:36 +0000 (18:38 +0100)]
Support bookmarking 'project-find-regexp' results buffer
* lisp/progmodes/project.el (xref-backend-apropos)
(xref-backend-context, xref-backend-restore): New methods.
(project-find-regexp, project-or-external-find-regexp): Use
'xref-make-fetcher' instead of a bespoke fetcher function to
facilitate bookmarking the results buffer.
* lisp/progmodes/xref.el (xref-bookmark-make-record): Use
strings for 'format-spec' specifications.
(xref-bookmark-jump): Autoload it.
(xref-show-xrefs): Make DISPLAY-ACTION argument optional.
(xref-make-fetcher): Autoload, and make BUFFER and POINT
arguments optional, default to the current buffer and point.
Stefan Monnier [Mon, 12 Feb 2024 03:00:44 +0000 (22:00 -0500)]
(pcase): New `_` syntax in pred/app functions
The current syntax for functions in `app` and `pred` patterns
allows a shorthand (F ARGS) where the object being matched is
added as an extra last argument. This is nice for things like
(pred (< 5)) but sometimes the object needs to be at
another position.
Until now you had to use (pred (lambda (x) (memq x my-list)))
or (pred (pcase--flip memq my-list)) in those cases.
So, introduce a new shorthand where `_` can be used to indicate
where the object should be passed: (pred (memq _ my-list))
* lisp/emacs-lisp/pcase.el (pcase--split-pred): Document new syntax
for pred/app functions.
(pcase--funcall): Support new syntax.
(pcase--flip): Declare obsolete.
(pcase--u1, \`): Use `_` instead.
(pcase--split-pred): Adjust accordingly.
* doc/lispref/control.texi (pcase Macro): Document new syntax
for pred/app functions.
Stefan Monnier [Sun, 11 Feb 2024 23:13:27 +0000 (18:13 -0500)]
(cl--generic-describe): Fix regression introduced by fix to bug#54628
Since that fix, we made other changes (put arg names in allcaps)
which also happen to fix bug#54628, so we can remove the original fix
which was suboptimal when the type includes quotes.
* lisp/emacs-lisp/cl-generic.el (cl--generic-describe):
Don't rebind `print-quoted` to nil.
* test/lisp/emacs-lisp/cl-generic-tests.el
(cl-generic-tests--print-quoted): New test.
Stefan Monnier [Sun, 11 Feb 2024 22:43:37 +0000 (17:43 -0500)]
(pcase): Add buttons to the macros' defs in the docstring of `pcase`
* lisp/emacs-lisp/pcase.el (pcase--find-macro-def-regexp): New var.
(find-function-regexp-alist): Add entry for `pcase-macro`s.
(help-fns--signature): Move declaration to where we know it is valid.
(pcase--make-docstring): Add buttons to jump to the definition
of Pcase macros.
* lisp/emacs-lisp/compat.el: Add stub file with minimal definitions,
so that core packages, that haven't been installed from ELPA, can make
use of the public API and use more recent function signatures.
* lisp/progmodes/python.el (compat): Remove 'noerror flag, because
Compat can now be required without the real package being available.
* doc/lispref/package.texi (Forwards-Compatibility): Mention Compat
and link to the manual.
* etc/NEWS: Document change. (Bug#66554)
Eli Zaretskii [Sun, 11 Feb 2024 13:21:14 +0000 (15:21 +0200)]
Fix 'min-width' display property in 'buffer-text-pixel-size'
* src/xdisp.c (display_min_width): Don't return without doing
anything when called from the move_it_* functions. This is needed
to have functions that simulate display layout handle the
min-width display property correctly. (Bug#68374)
Mekeor Melire [Fri, 9 Feb 2024 22:30:52 +0000 (23:30 +0100)]
In Info-url-alist, add .html extension to %e format-sequence
* lisp/info.el (Info-url-for-node): Implement the change. (Bug#68970)
(Info-url-alist): Document the change.
* test/lisp/info-tests.el (test-info-urls): Adjust tests to account for
the change and add a test for the "Top" node.
* src/xdisp.c (get_glyph_string_clip_rects, remember_mouse_glyph)
(expose_area, expose_window, gui_intersect_rectangles): Cast
width or height fields in Emacs_Rectangles to int before summing
with or subtracting them from their coordinate fields, as they
are unsigned outside X, and the sign of the coordinates is thus
not preserved.
Eric Abrahamsen [Sat, 10 Feb 2024 18:33:51 +0000 (10:33 -0800)]
Fix behavior of gnus-summary-very-wide-reply with prefix arg
* lisp/gnus/gnus-msg.el (gnus-summary-very-wide-reply): If a prefix
argument has been given, the value of YANK will be a list containing the
current article number. This should not be used to retrieve a number of
work articles; that should be derived from the value of the
current-prefix-arg (or marked articles).
* doc/misc/gnus.texi: The interplay of prefix arg and marked articles is
complex; attempt to clarify.
Juri Linkov [Sat, 10 Feb 2024 17:56:39 +0000 (19:56 +0200)]
* lisp/buff-menu.el: Force other-window commands to use other window.
(Buffer-menu-other-window, Buffer-menu-switch-other-window):
Let-bind 'display-buffer-overriding-action' to
'(nil (inhibit-same-window . t))' that will force the buffer
to be displayed in another window in any case (bug#68978).
The menu item "Outlines" toggles 'outline-minor-mode' when one
of outline-search-function/outline-regexp/outline-level is defined
in the current buffer.
Michael Albinus [Sat, 10 Feb 2024 08:50:12 +0000 (09:50 +0100)]
Fix warning in tramp-register-archive-autoload-file-name-handler
* lisp/net/tramp-archive.el
(tramp-register-archive-autoload-file-name-handler): Do not use
read syntax #' for `tramp-archive-file-name-handler', it isn't
autoloaded.
Eshel Yaron [Sun, 11 Feb 2024 15:18:48 +0000 (16:18 +0100)]
Use buffer local value of 'history-add-new-input' in minibuffer
Avoid let-binding 'history-add-new-input', since that affects all nested
recursive minibuffers, and instead use a buffer-local setting in the
appropriate minibuffer.
* doc/lispref/minibuf.texi (Minibuffer History): Update.
* lisp/emacs-lisp/crm.el (completing-read-multiple): Use
'history-add-new-input' instead of manually removing raw input from
minibuffer history.
* lisp/isearch.el (isearch-edit-string)
* lisp/replace.el (query-replace-read-from)
(query-replace-read-to, read-regexp)
* lisp/simple.el (read-from-kill-ring): Set 'history-add-new-input'
locally in the minibuffer, instead of let-binding it.
* src/minibuf.c (read_minibuf): Use 'history-add-new-input' local value.
Eshel Yaron [Sat, 10 Feb 2024 16:30:27 +0000 (17:30 +0100)]
; Fix 'thing-at-point' edge case involving overlapping matches
* lisp/thingatpt.el (thing-at-point-looking-at): When finding a match
that ends before point, continue searching from the beginning of that
match, not its end, in case the match we're looking is overlapping with
this one.
* test/lisp/thingatpt-tests.el
(thing-at-point-looking-at-overlapping-matches): New test.
Mekeor Melire [Wed, 7 Feb 2024 22:00:08 +0000 (23:00 +0100)]
Add option gnus-mode-line-logo
* lisp/gnus/gnus.el (gnus-mode-line-logo): New option specifying
whether and which logo will be displayed in the mode-line.
* etc/NEWS: Announce the change.
Jim Porter [Thu, 8 Feb 2024 01:58:31 +0000 (17:58 -0800)]
Put the list of built-in Eshell commands in its own manual node
* doc/misc/eshell.texi (Built-ins): Fix capitalization of node to be
more consistent with the rest of the manual. Fix a cross reference.
List child nodes.
(List of Built-ins): New section and node.
(Defining New Built-ins): Make this a node. Fix capitalization.
* lisp/net/tramp-sh.el (tramp-actions-before-shell)
(tramp-actions-copy-out-of-band):
Use `tramp-security-key-pin-regexp'.
* lisp/net/tramp.el (tramp-security-key-pin-regexp): New defcustom.
(tramp-action-otp-password, tramp-read-passwd): Trim password prompt.
(tramp-action-show-and-confirm-message): Expand for PIN requests.
Problem reported by Collin Funk (Bug#68996).
* GNUmakefile (.): New macro.
(help): Use ‘$.’ instead of ‘$ ’.
* cross/verbose.mk.android, src/verbose.mk.in (.): New macro.
(AM_V_AR, AM_V_CC, AM_V_CXX, AM_V_CCLD, AM_V_CXXLD, AM_V_GEN):
Use ‘$.’ instead of ‘$ ’.
* lib-src/Makefile.in (install): Use ‘$.’ instead of ‘$ ’.
Liu Hui [Thu, 18 Jan 2024 04:00:00 +0000 (12:00 +0800)]
Respect the delimiter of completer in Python shell completion
* lisp/progmodes/python.el: (python-shell-completion-setup-code): Fix
the completion code of IPython. Change the return value to JSON string
and ...
(python-shell-completion-get-completions): ... simplify parsing.
(inferior-python-mode): Update docstring.
(python-shell-readline-completer-delims): New variable indicating the
word delimiters of readline completer.
(python-shell-completion-native-setup): Set the completer delimiter.
(python-shell-completion-native-get-completions): Convert output string
to completions properly.
(python-shell--get-multiline-input)
(python-shell--extra-completion-context)
(python-shell-completion-extra-context): New functions.
(python-shell-completion-at-point): Send text beginning from the line
start if the completion backend does not need word splitting. Remove
the detection of import statement because it is not needed anymore.
Create proper completion table based on completions returned from
different backends.
* test/lisp/progmodes/python-tests.el (python-tests--completion-module)
(python-tests--completion-parameters)
(python-tests--completion-extra-context): New helper functions.
(python-shell-completion-at-point-jedi-completer)
(python-shell-completion-at-point-ipython): New tests. (bug#68559)
Eshel Yaron [Fri, 9 Feb 2024 10:15:24 +0000 (11:15 +0100)]
Remove minibuffer up-to-one-word completion
Deprecate 'minibuffer-complete-word', and cease binding 'SPC' during
minibuffer completion altogether.
* lisp/minibuffer.el (minibuffer-complete-word): Turn it into an
obsolete alias of 'minibuffer-complete'.
(minibuffer-confirm-exit-commands): Remove 'minibuffer-complete-word'.
(completion--try-word-completion): Drop it.
(minibuffer-local-completion-map): Cease binding 'SPC'.
(minibuffer-local-filename-completion-map)
(completion-pcm-complete-word-inserts-delimiters): Deprecate.
(completion-pcm--string->pattern, completing-read-default): Simplify.