Juri Linkov [Wed, 23 Nov 2022 08:50:23 +0000 (10:50 +0200)]
* lisp/outline.el: 'S-<down-mouse-1>' on buffer buttons cycles all outlines.
(outline--create-button-icons, outline--insert-button): Bind 'S-<mouse-1>' to
'outline-cycle-buffer' as it's already done for buttons on the margins.
Ignore 'S-<down-mouse-1>'. Don't hard-code 'help-echo' since it should be
customizable by the ':help-echo' keyword in 'define-icon'.
Juri Linkov [Wed, 23 Nov 2022 08:38:28 +0000 (10:38 +0200)]
* lisp/progmodes/xref.el: Support outline-minor-mode (bug#49731)
(xref--xref-buffer-mode): Set buffer-local variables outline-minor-mode-cycle,
outline-minor-mode-use-buttons, outline-search-function, outline-level
as settings for enabling outline-minor-mode in xref output buffers where
outline headings are xref groups, and their lines can be hidden by
outline commands.
Randy Taylor [Sun, 20 Nov 2022 03:30:13 +0000 (22:30 -0500)]
Utilize new font-lock faces for more tree-sitter modes (Bug#59397)
* lisp/progmodes/java-ts-mode.el (java-ts-mode--font-lock-settings):
Use font-lock-number-face.
(java-ts-mode): Alphabetize features.
* lisp/progmodes/js.el (js--treesit-operators): Define operators.
(js--treesit-font-lock-settings): Use bracket, delimiter,
escape-sequence, property, number, and operator font-lock faces.
(js-ts-mode): Add them to the feature list and alphabetize.
* lisp/progmodes/json-ts-mode.el (json-ts-mode--font-lock-settings):
Use bracket, delimiter, escape-sequence, and number faces. Remove
unused features.
(json-ts-mode): Add them to the feature list and alphabetize.
* lisp/progmodes/sh-script.el (sh-mode--treesit-settings): Use
bracket, delimiter, number, misc-punctuation, and operator font-lock
faces.
(sh-mode--treesit-operators): Remove ; and ;; from list.
(bash-ts-mode): Add them to the feature list and alphabetize.
* lisp/progmodes/ts-mode.el (ts-mode--operators): Define operators.
(ts-mode--font-lock-settings): Use escape-sequence, number, and
operator font-lock faces.
(ts-mode): Add them to the feature list and alphabetize.
Yuan Fu [Tue, 22 Nov 2022 20:01:53 +0000 (12:01 -0800)]
Fix treesit-update-ranges
* lisp/treesit.el (treesit--clip-ranges): New function.
(treesit-update-ranges): Now clips the range within (point-min)
and (point-max), so the new range we use are not out-of-range.
Eli Zaretskii [Tue, 22 Nov 2022 18:22:41 +0000 (20:22 +0200)]
Fix 'treesit-max-buffer-size' and its use
* lisp/treesit.el (treesit-max-buffer-size): Avoid overflow in
computing buffer-size limit. Account for 32-but systems built
"--with-wide-int". Extend doc string.
(treesit-ready-p): Compare the limit with the size of the buffer
in bytes, not in characters.
* src/treesit.c (treesit_check_buffer_size): Measure buffer size
in bytes.
Po Lu [Tue, 22 Nov 2022 12:57:47 +0000 (20:57 +0800)]
Adjust x_display_set_last_user_time for Xlib sign-extension
* src/xterm.c (x_display_set_last_user_time): Adjust for Xlib
sign extending fields in client messages to 64 bit long, which
then break x_display_set_last_user_time after 24 days, as Time
is unsigned long for historical reasons. (bug#59480)
Ihor Radchenko [Tue, 22 Nov 2022 01:21:17 +0000 (09:21 +0800)]
Improve the doc string of 'string-collate-lessp'
* src/fns.c (Fstring_collate_lessp): Clarify that
IGNORE-CASE argument might be ignored when the operating
system does not implement string collation for the
specified locale. (Bug#59275)
Yuan Fu [Tue, 22 Nov 2022 08:49:04 +0000 (00:49 -0800)]
Separate tree-sitter and non-tree-sitter variant of sh-mode
Now there are three modes, sh-base-mode, sh-mode, bash-ts-mode.
The change I made: change sh-mode to sh-base-mode, remove docstring.
Below the new sh-base-mode, create a new definition for sh-mode, paste
the dostring, add setup for font-lock-defaults. Below sh-mode, add
bash-ts-mode.
* lisp/progmodes/sh-script.el (sh-mode): Moves all setup into
sh-base-mode, except for the setup for font-lock-defaults and the
docstring.
(sh-base-mode): New mode.
(bash-ts-mode): New mode.
F. Jason Park [Tue, 22 Nov 2022 04:53:25 +0000 (20:53 -0800)]
; Fix ERC test failure following recent typo fix
* test/lisp/erc/erc-scenarios-base-compat-rename-bouncer.el: Replace
expected buffer content in test assertion.
* test/lisp/erc/resources/erc-scenarios-common.el: Replace expected
buffer content in test assertion. See also 40539c7587dc474b424cff732973fe8958eadf14 "; Fix typos".
Stefan Kangas [Tue, 22 Nov 2022 01:38:41 +0000 (02:38 +0100)]
Refresh menus in gnus.texi
Fixes problem reported by Po Lu <luangruo@yahoo.com>.
* doc/misc/gnus.texi (Top, Starting Up, Article Treatment)
(The Gnus Diary Library, Searching, nnmairix): Refresh menus.
Yuan Fu [Mon, 21 Nov 2022 20:07:20 +0000 (12:07 -0800)]
; Minor fix in c-ts-mode fontification
* lisp/progmodes/c-ts-mode.el (c-ts-mode--font-lock-settings): use
override. Include the outer call_expression.
(c-ts-mode--fontify-defun): Use the override given to it rather than
hard-code. Add missing space.
Yuan Fu [Mon, 21 Nov 2022 19:26:46 +0000 (11:26 -0800)]
Allow major modes to tweak tree-sitter fontification
treesit--font-lock-query-expand-range allows a major mode to fix
fontification problems temporarily before the parser can be fixed.
* lisp/treesit.el (treesit--font-lock-query-expand-range): New variable.
(treesit-font-lock-fontify-region): Use the new variable.
* lisp/textmodes/css-mode.el (css-ts-mode): Use the new variable.
Yuan Fu [Mon, 21 Nov 2022 18:52:55 +0000 (10:52 -0800)]
Further tweak tree-sitter fontification heuristics
So it turns out the slowness observed in bug#59415 is not due to the
size, but the strangely tall tree. Adjust the heuristic to DTRT:
don't enable the heuristic by default or when buffer is large, enable
when query is abnormally slow. We could do some clever thing that
calibrates a base reading for the query time instead of using a
hard-coded value, but it doesn't seem necessary.
* lisp/treesit.el (treesit--font-lock-fast-mode): New variable.
(treesit-font-lock-fontify-region): Don't activate heuristic by
default (reasons in comments). Measure the query time and activate
the fast mode if query time is long.
Stefan Kangas [Mon, 21 Nov 2022 14:18:54 +0000 (15:18 +0100)]
; Doc fixes: remove references to missing symbols
* lisp/allout.el (allout-process-exposed): Don't refer to missing
value 'flat-indented'.
* lisp/help.el (resize-temp-buffer-window): Don't refer to missing
function 'preserve-window-size'.
* lisp/pcomplete.el (pcomplete-stub): Don't refer to missing
function 'pcomplete-filename'.
Stefan Kangas [Mon, 21 Nov 2022 10:20:01 +0000 (11:20 +0100)]
Make instructions for updating ancient filesets obsolete
* lisp/filesets.el (filesets-update-pre010505): Make update
information for filesets older than 2001 obsolete. Note that this
dates back to before filesets.el was even added to Emacs.
Yuan Fu [Mon, 21 Nov 2022 04:29:53 +0000 (20:29 -0800)]
Fix tree-sitter fontification heuristic
Previously applied heuristic 2 sometimes invalidates heuristic 1, add
a guard so it doesn't.
The new function is just for clearity of the code and has nothing to
do with the change itself.
* lisp/treesit.el (treesit--node-length): New function
(treesit-font-lock-fontify-region): Use the new function. Only do
heuristic 2 when the node is large.
Juri Linkov [Mon, 21 Nov 2022 07:56:06 +0000 (09:56 +0200)]
* lisp/outline.el (outline-search-function): New variable (bug#53981).
(outline-font-lock-keywords, outline-font-lock-face)
(outline-minor-mode-highlight-buffer, outline-next-preface)
(outline-next-heading, outline-previous-heading)
(outline-back-to-heading, outline-on-heading-p, outline-demote)
(outline-map-region, outline-next-visible-heading)
(outline-hide-sublevels, outline-up-heading): Use outline-search-function
when it's non-nil as an alternative to searching outline-regexp.
(outline-search-level, outline-search-text-property): New functions.
* lisp/apropos.el (apropos-mode): Set outline-search-function
instead of unreliable outline-regexp.
(apropos-print): Add text property outline-level.
* lisp/emacs-lisp/shortdoc.el (shortdoc-display-group):
Add text property outline-level on text separate from final newlines.
(shortdoc-display-group): Add a narrow newline to not show
text properties of the final line when the outline is hidden.
(shortdoc--display-function): Add text property outline-level.
(shortdoc-mode): Set buffer-local outline-search-function and outline-level.
Po Lu [Mon, 21 Nov 2022 05:17:48 +0000 (13:17 +0800)]
Avoid usage of intern_c_string in treesit.c
* src/treesit.c (Ftreesit_pattern_expand): Use DEFSYM'd symbols
when the naming makes sense.
(syms_of_treesit): Add new defsyms QCanchor, QCequal, QCmatch.
Yuan Fu [Mon, 21 Nov 2022 00:56:33 +0000 (16:56 -0800)]
Limit recursion level for tree-sitter imenu functions
Generating imenu index doesn't require going down to the bottom of the
tree (defun's are usually top-level). Add limit so we don't go too
far down on very large buffers.
Yuan Fu [Mon, 21 Nov 2022 00:37:19 +0000 (16:37 -0800)]
Improve tree-sitter fontification on large buffers
* lisp/treesit.el (treesit--children-covering-range)
(treesit--children-covering-range-recurse): New functions. They are
not currently used but could be useful in the future, so I left them
in place.
(treesit-font-lock-fontify-region):
* lisp/treesit.el (treesit-font-lock-fontify-region): Use the result
of treesit-node-on instead of the root node.
Avoid native compiler setting user-init-file to warnings.el (bug#59358)
* src/lread.c (maybe_swap_for_eln): Use a delayed warning
instead of `display-warning' to avoid a recursive call to
Fload while loading the init file that sets `user-init-file'
to a bogus value.
Juri Linkov [Sun, 20 Nov 2022 18:10:45 +0000 (20:10 +0200)]
Rename 'elisp-eval-buffer' to 'elisp-eval-region-or-buffer' (bug#59350)
* lisp/progmodes/elisp-mode.el (elisp-eval-region-or-buffer):
Rename recently added command 'elisp-eval-buffer' to support active region.
(emacs-lisp-mode-map, lisp-interaction-mode-map): Rebind 'C-c C-e'
from elisp-eval-buffer to elisp-eval-region-or-buffer.
Po Lu [Sun, 20 Nov 2022 13:01:10 +0000 (21:01 +0800)]
Coalesce duplicate scroll valuator handling code
Also, write more commentary.
* src/xterm.c (xi_populate_scroll_valuator): New function.
Describe the meaning of each field in xi_scroll_valuator_t.
(xi_populate_device_from_info, xi_handle_new_classes): Factor
out duplicate code to that function.
Eli Zaretskii [Sun, 20 Nov 2022 11:10:08 +0000 (13:10 +0200)]
Advise against using too-high GC thresholds
* doc/lispref/internals.texi (Garbage Collection):
* src/alloc.c (syms_of_alloc) <gc-cons-threshold>
<gc-cons-percentage>: Advise against enlarging the GC thresholds
more than needed and for prolonged periods of time.
Yuan Fu [Sun, 20 Nov 2022 00:56:42 +0000 (16:56 -0800)]
Separate native and tree-sitter variant of js-mode
* lisp/progmodes/js.el (js-base-mode): New mode.
(js-mode): Return to before tree-sitter setup is added, change to
inherit from js-base-mode.
(js-ts-mode): New mode. Now it doesn't use any cc-mode feature,
meaning it looses comment filling.
Yuan Fu [Sun, 20 Nov 2022 00:09:08 +0000 (16:09 -0800)]
Split python-mode into native and tree-sitter variant
* lisp/progmodes/python.el (python-base-mode): New virtual mode that
contains most of the setup.
(python-mode): Change to inherit from python-base-mode.
(python-ts-mode): New mode that sets up tree-sitter.
Yuan Fu [Sat, 19 Nov 2022 23:27:07 +0000 (15:27 -0800)]
Expand css-ts-mode and merge it into css-mode
* lisp/progmodes/css-ts-mode.el: Deleted.
* lisp/textmodes/css-mode.el (css--treesit-indent-rules)
(css--treesit-settings): New variables.
(css--treesit-imenu-1)
(css--treesit-imenu): New functions.
* lisp/textmodes/css-mode.el (css-base-mode): New mode inherited by
both css-mode and css-ts-mode.
(css-ts-mode): New mode.
(css-mode): Inherit from css-base-mode, and move some setup to
css-base-mode.
Eli Zaretskii [Sat, 19 Nov 2022 19:34:07 +0000 (21:34 +0200)]
Fix encoding and display of messages sent by server to emacsclient
* lisp/server.el (server-start): Use 'locale-coding-system' to
encode messages sent back to the client.
* lib-src/emacsclient.c (main): Print '-error' messages via
'message', not directly via 'fprintf'. This shows the error on
MS-Windows when the client is invoked as 'emacsclientw', since
stderr goes to the bit bucket in that case.
Gregory Heytings [Sat, 19 Nov 2022 15:46:46 +0000 (15:46 +0000)]
Fix global face scaling bug due to rounding.
* lisp/face-remap.el (global-text-scale-adjust): Try again if the face
height should have changed but did not actually change. Update the
docstring to clarify the difference with 'text-scale-adjust'.
(global-text-scale-adjust--increment-factor): New internal variable.
Fixes bug#59122.
(text-scale-adjust): Update the docstring to clarify the difference
with 'global-text-scale-adjust'.