Jim Porter [Thu, 26 Oct 2023 03:43:57 +0000 (20:43 -0700)]
Introduce 'let' using lexical binding in the Lisp Introduction
* doc/lispintro/emacs-lisp-intro.texi (Prevent confusion): Rework the
explanation to discuss how things work under lexical binding.
(How let Binds Variables): Describe the differences between lexical
and dynamic binding (including how to configure it).
(defvar): Mention that 'defvar' declares variables as always
dynamically-bound (bug#66756).
Eli Zaretskii [Sat, 6 Jan 2024 17:30:16 +0000 (19:30 +0200)]
Fix 'rmail-summary-by-thread'
* lisp/mail/rmailsum.el (rmail-summary-by-thread): Call
'rmail-new-summary' from the original buffer, not from
'rmail-buffer' to avoid failing the logic in 'rmail-new-summary'
that decides whether to pop up a new window. Reported by Andrea
Monaco <andrea.monaco@autistici.org>.
Eli Zaretskii [Sat, 6 Jan 2024 11:26:29 +0000 (13:26 +0200)]
Fix icons.el when icon does not exist as a file
* 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)
Eli Zaretskii [Sat, 6 Jan 2024 09:15:31 +0000 (11:15 +0200)]
; Improve documentation of 'buffer-match-p'
* doc/lispref/buffers.texi (Buffer List):
* doc/lispref/windows.texi (Choosing Window): Add caveats for
calling 'buffer-match-p' too early, when CONDITION is
'derived-mode' or 'major-mode'. (Bug#68081)
When 'isearch-wrap-pause' is 'no' or 'no-ding', let-bind 'isearch-cmds'
to avoid changing it by 'isearch-push-state' in 'isearch-repeat',
so that a later DEL (isearch-delete-char) doesn't stop at the
intermediate failing state (bug#68158).
Denis Zubarev [Sat, 11 Nov 2023 01:55:44 +0000 (04:55 +0300)]
Improve syntax highlighting for python-ts-mode
Fix fontification of strings inside of f-strings interpolation, e.g. for
f"beg {'nested'}" - 'nested' was not fontified as string. Do not
override the face of builtin functions (all, bytes etc.) with the
function call face. Add missing assignment expressions (:= *=).
Fontify built-ins (dict,list,etc.) as types when they are used in type
hints. Highlight union types (type1|type2). Highlight base class names
in the class definition. Fontify class patterns in case statements.
Highlight the second argument as a type in isinstance/issubclass call.
Highlight dotted decorator names.
* lisp/progmodes/python.el (python--treesit-keywords): Add compound
keyword "is not".
(python--treesit-builtin-types): New variable that stores all python
built-in types.
(python--treesit-type-regex): New variable. Regex matches if text is
either built-in type or text starts with capital letter.
(python--treesit-builtins): Extract built-in types to other variable.
(python--treesit-fontify-string): fix f-string interpolation. Enable
interpolation highlighting only if string-interpolation is presented
on the enabled levels of treesit-font-lock-feature-list.
(python--treesit-fontify-string-interpolation): Remove function.
(python--treesit-fontify-union-types): Fontify nested union types.
(python--treesit-fontify-union-types-strict): Fontify nested union
types, only if type identifier matches against
python--treesit-type-regex.
(python--treesit-fontify-dotted-decorator): Fontify all parts of
dotted decorator name.
(python--treesit-settings): Change/add rules. (Bug#67061)
* test/lisp/progmodes/python-tests.el
(python-ts-tests-with-temp-buffer): Function for setting up test
buffer.
(python-ts-mode-compound-keywords-face)
(python-ts-mode-named-assignement-face-1)
(python-ts-mode-assignement-face-2)
(python-ts-mode-nested-types-face-1)
(python-ts-mode-union-types-face-1)
(python-ts-mode-union-types-face-2)
(python-ts-mode-types-face-1)
(python-ts-mode-types-face-2)
(python-ts-mode-types-face-3)
(python-ts-mode-isinstance-type-face-1)
(python-ts-mode-isinstance-type-face-2)
(python-ts-mode-isinstance-type-face-3)
(python-ts-mode-superclass-type-face)
(python-ts-mode-class-patterns-face)
(python-ts-mode-dotted-decorator-face-1)
(python-ts-mode-dotted-decorator-face-2)
(python-ts-mode-builtin-call-face)
(python-ts-mode-interpolation-nested-string)
(python-ts-mode-disabled-string-interpolation)
(python-ts-mode-interpolation-doc-string): Add tests.
Jared Finder [Sat, 16 Dec 2023 20:10:03 +0000 (12:10 -0800)]
Fix mouse clicks on directory line in Dired
The option 'dired-kill-when-opening-new-dired-buffer' should be
also honored when clicking the mouse to kill prev buffer.
* lisp/dired.el (dired--make-directory-clickable): Call
'dired--find-possibly-alternative-file' instead of 'dired', in
the click callback. (Bug#67856)
Eli Zaretskii [Mon, 25 Dec 2023 12:59:26 +0000 (14:59 +0200)]
Fix 'split-root-window-right' and 'split-root-window-below'
* lisp/window.el (split-root-window-right)
(split-root-window-below): Fix the 'interactive' spec to avoid
misbehaving when invoked with no prefix argument. (Bug#67452)
Xiyue Deng [Sun, 24 Dec 2023 00:12:44 +0000 (16:12 -0800)]
Fix usage of `setq-default' and offer more suggestions
cd61af0 changed from default-major-mode to major-mode in the first
code sample but didn't change the rest. This patch fixes this and add
some explanations of why use `setq-default' instead of `setq'. In
addition, it gives background on suggesting using text-mode as default
mode and suggest other alternatives.
* doc/lispintro/emacs-lisp-intro.texi (Text and Auto-fill): Fix usage
of `setq-default' and offer more suggestions. (Bug#67848)
Yuan Fu [Sun, 24 Dec 2023 00:47:04 +0000 (16:47 -0800)]
Increment parser timestamp when narrowing changes (bug#67977)
When narrowing changes, parse reparses, so the timestamp should
definitely increment, just like in ts_record_changes.
Failing to increment this timestamp, outdated nodes would think they
are still up-to-date, and try to print their type name. Printing
their type name involves accessing the old parse tree, which is
already freed during the last reparse.
I also found that we don't increment timestamp when changing parser
ranges and fixed that as well.
Yuan Fu [Sun, 17 Dec 2023 01:15:04 +0000 (17:15 -0800)]
Correctly refontify changed region in tree-sitter modes (bug#66732)
We already have treesit--font-lock-notifier that should mark changed
regions to be refontified, but it's called too late in the redsiplay &
fontification pipeline. Here we add treesit--pre-redisplay that
forces reparse and calls notifier functions in
pre-redisplay-functions, which is early enough for the marking to take
effect.
Similarly, we force reparse in
syntax-propertize-extend-region-functions so syntax-ppss will have the
up-to-date syntax information when it scans the buffer text. We also
record the lowest start position of the affected regions, and make
sure next syntex-propertize starts from that position.
* lisp/treesit.el (treesit--pre-redisplay-tick):
(treesit--syntax-propertize-start): New variable.
(treesit--syntax-propertize-notifier):
(treesit--pre-redisplay):
(treesit--pre-syntax-ppss): New functions.
(treesit-major-mode-setup): Add hooks.
Denis Zubarev [Sat, 11 Nov 2023 22:42:42 +0000 (01:42 +0300)]
Fix treesit test (bug#67117)
* test/src/treesit-tests.el (treesit-search-subtree-forward-1):
(treesit-search-subtree-backward-1): Replace treesit--thing-at with
treesit-query-capture (treesit--thing-at isn't available in Emacs 29).
Stefan Kangas [Fri, 22 Dec 2023 21:36:37 +0000 (22:36 +0100)]
Recommend customizing eglot for python-base-mode
* doc/misc/eglot.texi (Project-specific configuration): Recommend
setting directory local variables for 'python-base-mode' instead of
'python-mode'. This makes any customizations effective also for
'python-ts-mode'.
Stefan Monnier [Thu, 21 Dec 2023 15:24:29 +0000 (10:24 -0500)]
doc/lispintro: Don't mention `set` (bug#67734)
* doc/lispintro/emacs-lisp-intro.texi (Using set): Delete.
(Using setq): Adjust accordingly.
(setq): Rename from "set & setq" and don't refer to `set` any more.
(Review): Don't mention `set` any more.
Denis Zubarev [Sat, 11 Nov 2023 22:42:42 +0000 (01:42 +0300)]
Fix an issue when searching subtree backward (bug#67117)
* src/treesit.c (treesit_traverse_child_helper):
Do not call treesit_traverse_sibling_helper when the named node is
required and the last child is the named node.
Otherwise treesit_traverse_sibling_helper will move cursor to the
previous sibling and last node will be skipped.
* test/src/treesit-tests.el (treesit-search-subtree-forward-1):
(treesit-search-subtree-backward-1):
Add tests.
Eli Zaretskii [Sat, 16 Dec 2023 13:33:02 +0000 (15:33 +0200)]
Fix shaping of Sinhala text
* lisp/language/sinhala.el (composition-function-table): Allow
U+200D U+0DCA as well as U+0DCA U+200D between consonants.
Suggested by Richard Wordingham <richard.wordingham@ntlworld.com>.
(Bug#67828)
Eli Zaretskii [Sat, 16 Dec 2023 11:25:58 +0000 (13:25 +0200)]
Fix opening directory trees from Filesets menu
In bug#976, the code was fixed, but the cautious condition in
the original author's code, which catered to invoking
'filelists-open' from the menu-bar menu, was omitted, which made
that invocation, which did work before, broken.
* lisp/filesets.el (filesets-get-filelist): Fix opening directory
trees from the Filesets menu-bar menu. (Bug#67658)
Niall Dooley [Fri, 24 Nov 2023 15:52:36 +0000 (16:52 +0100)]
Eglot: Add ruff-lsp as an alternative Python server
ruff-lsp [1] is an LSP server for Ruff [2], [3], a fast Python linter
and code formatter.
It supports surfacing Ruff diagnostics and providing Code Actions to
fix them, but is intended to be used alongside another Python LSP in
order to support features like navigation and autocompletion.
Dmitry Gutov [Tue, 12 Dec 2023 22:00:38 +0000 (00:00 +0200)]
js-ts-mode: Fix font-lock rules conflict
* lisp/progmodes/js.el (js--treesit-font-lock-settings): Move
'property' to after 'jsx'. Stop using predicate (bug#67684).
(js--treesit-property-not-function-p): Delete.
Noah Peart [Sun, 10 Dec 2023 22:58:31 +0000 (14:58 -0800)]
Add indentation rules for bracketless statements in js-ts-mode
* lisp/progmodes/js.el (js--treesit-indent-rules): Add indentation
rules to handle bracketless statements (bug#67758).
* test/lisp/progmodes/js-tests.el (js-ts-mode-test-indentation):
New test for js-ts-mode indentation.
* test/lisp/progmodes/js-resources/js-ts-indents.erts: New file
with indentation tests for js-ts-mode.
Yuan Fu [Mon, 11 Dec 2023 02:24:27 +0000 (18:24 -0800)]
Fix c-ts-mode bracketless indentation for BSD style (bug#66152)
* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--indent-styles): Make sure the BSD rules only apply to
opening bracket (compound_statement), then bracketless statements will
fallback to common rules.
* test/lisp/progmodes/c-ts-mode-resources/indent-bsd.erts: Copy the
bracketless test from indent.erts to here.
Yuan Fu [Mon, 11 Dec 2023 00:23:44 +0000 (16:23 -0800)]
Fix treesit-node-field-name and friends (bug#66674)
So turns out ts_node_field_name_for_child takes a named node index,
but we were passing it normal index that counts both named and
anonymous nodes. That's what makes the field name all wrong in
treesit explorer.
* doc/lispref/parsing.texi:
(Accessing Node Information): Update docstring.
* lisp/treesit.el (treesit-node-index): Add some unrelated comment.
(treesit-node-field-name): Get named node index rather than all node
index.
* src/treesit.c (Ftreesit_node_field_name_for_child): Update
docstring, use ts_node_named_child_count.
Yuan Fu [Sun, 10 Dec 2023 09:24:25 +0000 (01:24 -0800)]
Fix c-ts-mode indent heuristic (bug#67417)
This is a continuation of the first two patches for bug#67417. The
c-ts-mode--prev-line-match heuristic we added is too broad, so for now
we are just adding a very specific heuristic for the else case.
* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--prev-line-match): Remove function.
(c-ts-mode--else-heuristic): New function.
(c-ts-mode--indent-styles): Use c-ts-mode--else-heuristic.
nverno [Wed, 22 Nov 2023 00:33:04 +0000 (16:33 -0800)]
Fix c-ts-mode indentation (bug#67357)
1. In a compund_statement, we indent the first sibling against the
parent, and the rest siblings against their previous sibling. But
this strategy falls apart when the first sibling is not on its own
line. We should regard the first sibling that is on its own line as
the "first sibling"", and indent it against the parent.
2. In linux style, in a do-while statement, if the do-body is
bracket-less, the "while" keyword is indented to the same level as the
do-body. It should be indented to align with the "do" keyword
instead.
* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--no-prev-standalone-sibling): New function.
(c-ts-mode--indent-styles): Use
c-ts-mode--no-prev-standalone-sibling. Add while keyword indent rule.
* test/lisp/progmodes/c-ts-mode-resources/indent.erts: New tests.
Dmitry Gutov [Sat, 9 Dec 2023 17:04:55 +0000 (19:04 +0200)]
ruby-mode: Better detect regexp vs division (bug#67569)
* lisp/progmodes/ruby-mode.el (ruby-syntax-before-regexp-re):
Add grouping around methods from the whitelist.
(ruby-syntax-propertize): Also look for spaces around the slash.
Jared Finder [Sat, 9 Dec 2023 08:17:05 +0000 (10:17 +0200)]
Fix dragging mode line on text terminals with a mouse (bug#67457)
* lisp/xt-mouse.el (xterm-mouse-translate-1): Fix the 'event-kind'
property of mouse-movement symbols emitted by xt-mouse.
* lisp/term/linux.el (terminal-init-linux): Call 'gpm-mouse-mode'
to set up the terminal for the mouse, if needed.
Dmitry Gutov [Fri, 8 Dec 2023 02:12:21 +0000 (04:12 +0200)]
js-ts-mode: Highlight property shorthands in assignments
* lisp/progmodes/js.el (js--treesit-lhs-identifier-query): Match
property shorthands (which turn into variable reference).
(js--treesit-fontify-assignment-lhs): Use the matches.
Dmitry Gutov [Fri, 8 Dec 2023 01:58:18 +0000 (03:58 +0200)]
(js--treesit-font-lock-settings): Highlight parameters in function expression
* lisp/progmodes/js.el (js--treesit-font-lock-settings):
Highlight parameters in a function expression (the node type
'function'). Make the matcher for 'formal_parameters' independent
of the parent, that just created duplication.
Dmitry Gutov [Fri, 8 Dec 2023 01:48:45 +0000 (03:48 +0200)]
(js--treesit-font-lock-settings): Remove some duplicates
* lisp/progmodes/js.el (js--treesit-font-lock-settings):
Remove queries from 'function' that duplicate entries in
'definition' (one of them with a typo).
rust-ts-mode--comment-docstring: Fix/improve the previous change
* lisp/progmodes/rust-ts-mode.el
(rust-ts-mode--comment-docstring): Match also "inner" line docs.
Stop rebinding 'end' and use the argument's value in the
'treesit-fontify-with-override' call.
Eli Zaretskii [Sat, 2 Dec 2023 13:25:08 +0000 (15:25 +0200)]
Fix 'Info-goto-node-web' when NODE is given in various forms
* lisp/info.el (Info-goto-node-web): Support all forms of node
input, per 'Info-read-node-name's documentation, and extract
FILENAME from NODE if given there. Default NODE to "Top" if not
provided by the user. (Bug#67531)
(Info-url-for-node): Support browsing the "Top" node.