From 6ea507296a7e8bd55df8961793b02cf54d0f3c72 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Sat, 16 Dec 2023 17:15:04 -0800 Subject: [PATCH 01/18] 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. * lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode): Remove notifier. (ruby-ts--parser-after-change): Remove notifier function. --- lisp/progmodes/ruby-ts-mode.el | 12 ------ lisp/treesit.el | 72 +++++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 13 deletions(-) diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index c146b80542e..a30131aad89 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -1135,20 +1135,8 @@ leading double colon is not added." (treesit-major-mode-setup) - (treesit-parser-add-notifier (car (treesit-parser-list)) - #'ruby-ts--parser-after-change) - (setq-local syntax-propertize-function #'ruby-ts--syntax-propertize)) -(defun ruby-ts--parser-after-change (ranges parser) - ;; Make sure we re-syntax-propertize the full node that is being - ;; edited. This is most pertinent to multi-line complex nodes such - ;; as heredocs. - (when ranges - (with-current-buffer (treesit-parser-buffer parser) - (syntax-ppss-flush-cache (cl-loop for r in ranges - minimize (car r)))))) - (if (treesit-ready-p 'ruby) ;; Copied from ruby-mode.el. (add-to-list 'auto-mode-alist diff --git a/lisp/treesit.el b/lisp/treesit.el index 8a07f5023a9..2ef4e382cf3 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1088,6 +1088,72 @@ parser notifying of the change." (with-silent-modifications (put-text-property (car range) (cdr range) 'fontified nil))))) +(defvar-local treesit--syntax-propertize-start nil + "If non-nil, next `syntax-propertize' should start at this position. + +When tree-sitter parser reparses, it calls +`treesit--syntax-propertize-notifier' with the affected region, +and that function sets this variable to the start of the affected +region.") + +(defun treesit--syntax-propertize-notifier (ranges parser) + "Sets `treesit--syntax-propertize-start' to the smallest start. +Specifically, the smallest start position among all the ranges in +RANGES for PARSER." + (with-current-buffer (treesit-parser-buffer parser) + (when-let* ((range-starts (mapcar #'car ranges)) + (min-range-start + (seq-reduce + #'min (cdr range-starts) (car range-starts)))) + (if (null treesit--syntax-propertize-start) + (setq treesit--syntax-propertize-start min-range-start) + (setq treesit--syntax-propertize-start + (min treesit--syntax-propertize-start min-range-start)))))) + +(defvar-local treesit--pre-redisplay-tick nil + "The last `buffer-chars-modified-tick' that we've processed. +Because `pre-redisplay-functions' could be called multiple times +during a single command loop, we use this variable to debounce +calls to `treesit--pre-redisplay'.") + +(defun treesit--pre-redisplay (&rest _) + "Force reparse and consequently run all notifiers. + +One of the notifiers is `treesit--font-lock-notifier', which will +mark the region whose syntax has changed to \"need to refontify\". + +For example, when the user types the final slash of a C block +comment /* xxx */, not only do we need to fontify the slash, but +also the whole block comment, which previously wasn't fontified +as comment due to incomplete parse tree." + (unless (eq treesit--pre-redisplay-tick (buffer-chars-modified-tick)) + ;; `treesit-update-ranges' will force the host language's parser to + ;; reparse and set correct ranges for embedded parsers. Then + ;; `treesit-parser-root-node' will force those parsers to reparse. + (treesit-update-ranges) + ;; Force repase on _all_ the parsers might not be necessary, but + ;; this is probably the most robust way. + (dolist (parser (treesit-parser-list)) + (treesit-parser-root-node parser)) + (setq treesit--pre-redisplay-tick (buffer-chars-modified-tick)))) + +(defun treesit--pre-syntax-ppss (start end) + "Force reparse and consequently run all notifiers. + +Similar to font-lock, we want to update the `syntax' text +property before `syntax-ppss' starts working on the text. We +also want to extend the to-be-propertized region to include the +whole region affected by the last reparse. + +START and END mark the current to-be-propertized region." + (treesit--pre-redisplay) + (let ((new-start treesit--syntax-propertize-start)) + (if (and new-start (< new-start start)) + (progn + (setq treesit--syntax-propertize-start nil) + (cons new-start end)) + nil))) + ;;; Indent (define-error 'treesit-indent-error @@ -2392,7 +2458,11 @@ before calling this function." (treesit-font-lock-recompute-features) (dolist (parser (treesit-parser-list)) (treesit-parser-add-notifier - parser #'treesit--font-lock-notifier))) + parser #'treesit--font-lock-notifier)) + (add-hook 'pre-redisplay-functions #'treesit--pre-redisplay 0 t)) + ;; Syntax + (add-hook 'syntax-propertize-extend-region-functions + #'treesit--pre-syntax-ppss 0 t) ;; Indent. (when treesit-simple-indent-rules (setq-local treesit-simple-indent-rules From da2e440462b643427de94433f5e8d0e1330c7450 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Sun, 24 Dec 2023 03:58:49 +0200 Subject: [PATCH 02/18] ruby-ts-mode: Fix an out-of-bounds error with heredoc at eob * lisp/progmodes/ruby-ts-mode.el (ruby-ts--syntax-propertize): Fix an out-of-bounds error with heredoc at eob. --- lisp/progmodes/ruby-ts-mode.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index a30131aad89..843f468e2a1 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -1063,8 +1063,9 @@ leading double colon is not added." ('heredoc (put-text-property (treesit-node-start node) (1+ (treesit-node-start node)) 'syntax-table (string-to-syntax "\"")) - (put-text-property (treesit-node-end node) (1+ (treesit-node-end node)) - 'syntax-table (string-to-syntax "\""))) + (when (< (treesit-node-end node) (point-max)) + (put-text-property (treesit-node-end node) (1+ (treesit-node-end node)) + 'syntax-table (string-to-syntax "\"")))) ('percent ;; FIXME: Put the first one on the first paren in both %Q{} and %(). ;; That would stop electric-pair-mode from pairing, though. Hmm. From 9cfa498e0ab4876e38f46b4ee9e26804512fd666 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Sun, 24 Dec 2023 04:07:15 +0200 Subject: [PATCH 03/18] treesit-major-mode-setup: Use 'treesit--syntax-propertize-notifier' * lisp/treesit.el (treesit-major-mode-setup): Make sure 'treesit--syntax-propertize-notifier' is used (bug#66732) --- lisp/treesit.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lisp/treesit.el b/lisp/treesit.el index 2ef4e382cf3..eed53bc2b99 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -2461,6 +2461,9 @@ before calling this function." parser #'treesit--font-lock-notifier)) (add-hook 'pre-redisplay-functions #'treesit--pre-redisplay 0 t)) ;; Syntax + (dolist (parser (treesit-parser-list)) + (treesit-parser-add-notifier + parser #'treesit--syntax-propertize-notifier)) (add-hook 'syntax-propertize-extend-region-functions #'treesit--pre-syntax-ppss 0 t) ;; Indent. From 8ae42c825e1e058d3c736837a023bdc2617b85a2 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Sun, 24 Dec 2023 04:22:34 +0200 Subject: [PATCH 04/18] ruby-ts-mode: Fix indentation for string_array closer * lisp/progmodes/ruby-ts-mode.el (ruby-ts--indent-rules): Fix indentation for string_array closer. --- lisp/progmodes/ruby-ts-mode.el | 5 +++-- test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 843f468e2a1..fc704c5c86a 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -753,8 +753,9 @@ a statement container is a node that matches ((match "}" "hash") ruby-ts--parent-call-or-bol 0) ((parent-is "hash") ruby-ts--parent-call-or-bol ruby-indent-level) - ((match "]" "array") ruby-ts--parent-call-or-bol 0) - ((parent-is "array") ruby-ts--parent-call-or-bol ruby-indent-level) + ((match "]" "^array") ruby-ts--parent-call-or-bol 0) + ((parent-is "^array") ruby-ts--parent-call-or-bol ruby-indent-level) + ((match ")" "string_array") ruby-ts--parent-call-or-bol 0) ((parent-is "pair") ruby-ts--parent-call-or-bol 0) diff --git a/test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb b/test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb index 4be532a5e9d..8e372de6e45 100644 --- a/test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb +++ b/test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb @@ -85,6 +85,10 @@ foo(foo, bar: foo(foo, :bar => tee) +foo = %w[ + asd +] + # Local Variables: # mode: ruby-ts # ruby-after-operator-indent: t From 683c7c96871cc374b0e00f5084e43a70fc3ec36a Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Sat, 23 Dec 2023 16:47:04 -0800 Subject: [PATCH 05/18] 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. * src/treesit.c (treesit_sync_visible_region): (Ftreesit_parser_set_included_ranges): Increment timestamp. * src/treesit.h (Lisp_TS_Parser): Add some comments. --- src/treesit.c | 6 +++++- src/treesit.h | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/treesit.c b/src/treesit.c index 93ed97212d7..879405e551a 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -931,7 +931,10 @@ treesit_sync_visible_region (Lisp_Object parser) this function is called), we need to reparse. */ if (visible_beg != BUF_BEGV_BYTE (buffer) || visible_end != BUF_ZV_BYTE (buffer)) - XTS_PARSER (parser)->need_reparse = true; + { + XTS_PARSER (parser)->need_reparse = true; + XTS_PARSER (parser)->timestamp++; + } /* Before we parse or set ranges, catch up with the narrowing situation. We change visible_beg and visible_end to match @@ -1671,6 +1674,7 @@ buffer. */) ranges); XTS_PARSER (parser)->need_reparse = true; + XTS_PARSER (parser)->timestamp++; return Qnil; } diff --git a/src/treesit.h b/src/treesit.h index 5382bc58817..3d59262b53a 100644 --- a/src/treesit.h +++ b/src/treesit.h @@ -53,7 +53,9 @@ struct Lisp_TS_Parser /* Re-parsing an unchanged buffer is not free for tree-sitter, so we only make it re-parse when need_reparse == true. That usually means some change is made in the buffer. But others could set - this field to true to force tree-sitter to re-parse. */ + this field to true to force tree-sitter to re-parse. When you + set this to true, you should _always_ also increment + timestamp. */ bool need_reparse; /* These two positions record the buffer byte position (1-based) of the "visible region" that tree-sitter sees. Before re-parse, we From 2701da0eee54d85f79104c7a91610bf591159a51 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Sat, 23 Dec 2023 15:49:32 -0800 Subject: [PATCH 06/18] Fix python-ts-mode triple quote syntax (bug#67262) * lisp/progmodes/python.el (python--treesit-syntax-propertize): New function. (python-ts-mode): Activate python--treesit-syntax-propertize. --- lisp/progmodes/python.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 7c5c20608bd..d7250148fad 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1228,6 +1228,21 @@ For NODE, OVERRIDE, START, END, and ARGS, see (treesit-node-start node) (treesit-node-end node) 'font-lock-variable-use-face override start end))) +(defun python--treesit-syntax-propertize (start end) + "Propertize triple-quote strings between START and END." + (save-excursion + (goto-char start) + (while (re-search-forward (rx (or "\"\"\"" "'''")) end t) + (let ((node (treesit-node-at (point)))) + ;; The triple quotes surround a non-empty string. + (when (equal (treesit-node-type node) "string_content") + (let ((start (treesit-node-start node)) + (end (treesit-node-end node))) + (put-text-property (1- start) start + 'syntax-table (string-to-syntax "|")) + (put-text-property end (min (1+ end) (point-max)) + 'syntax-table (string-to-syntax "|")))))))) + ;;; Indentation @@ -6729,6 +6744,8 @@ implementations: `python-mode' and `python-ts-mode'." #'python--treesit-defun-name) (treesit-major-mode-setup) + (setq-local syntax-propertize-function #'python--treesit-syntax-propertize) + (python-skeleton-add-menu-items) (when python-indent-guess-indent-offset From ceacf75395834c452b43932c19df7e3202a16094 Mon Sep 17 00:00:00 2001 From: Xiyue Deng Date: Sat, 23 Dec 2023 16:12:44 -0800 Subject: [PATCH 07/18] 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) --- doc/lispintro/emacs-lisp-intro.texi | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/doc/lispintro/emacs-lisp-intro.texi b/doc/lispintro/emacs-lisp-intro.texi index 4a0e8dfa1fc..26a405361de 100644 --- a/doc/lispintro/emacs-lisp-intro.texi +++ b/doc/lispintro/emacs-lisp-intro.texi @@ -16892,8 +16892,12 @@ remember to look here to remind myself. @node Text and Auto-fill @section Text and Auto Fill Mode -Now we come to the part that turns on Text mode and -Auto Fill mode. +Now we come to the part that turns on Text mode and Auto Fill +mode.@footnote{This section suggests settings that are more suitable +for writers. For programmers, the default mode will be set to the +corresponding prog-mode automatically based on the type of the file. +And it's perfectly fine if you want to keep the fundamental mode as +the default mode.} @smallexample @group @@ -16945,15 +16949,19 @@ Here is the line again; how does it work? @cindex Text Mode turned on @smallexample -(setq major-mode 'text-mode) +(setq-default major-mode 'text-mode) @end smallexample @noindent This line is a short, but complete Emacs Lisp expression. -We are already familiar with @code{setq}. It sets the following -variable, @code{major-mode}, to the subsequent value, which is -@code{text-mode}. The single-quote before @code{text-mode} tells +We are already familiar with @code{setq}. We use a similar macro +@code{setq-default} to set the following variable, +@code{major-mode}@footnote{We use @code{setq-default} because +@code{text-mode} is buffer local. If we use @code{setq} it will only +apply to the current buffer, and using @code{setq-default} will also +apply this to newly created buffers.}, to the subsequent value, which +is @code{text-mode}. The single-quote before @code{text-mode} tells Emacs to deal directly with the @code{text-mode} symbol, not with whatever it might stand for. @xref{setq, , Setting the Value of a Variable}, for a reminder of how @code{setq} works. The main point From 03dc914fd37735f9f768519bf5bf86913d5c9dbe Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 24 Dec 2023 10:46:04 +0200 Subject: [PATCH 08/18] ; Fix footnotes in ELisp Intro manual --- doc/lispintro/emacs-lisp-intro.texi | 35 ++++++++++++++++------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/doc/lispintro/emacs-lisp-intro.texi b/doc/lispintro/emacs-lisp-intro.texi index 26a405361de..673e1f0cfdf 100644 --- a/doc/lispintro/emacs-lisp-intro.texi +++ b/doc/lispintro/emacs-lisp-intro.texi @@ -16893,11 +16893,13 @@ remember to look here to remind myself. @section Text and Auto Fill Mode Now we come to the part that turns on Text mode and Auto Fill -mode.@footnote{This section suggests settings that are more suitable -for writers. For programmers, the default mode will be set to the -corresponding prog-mode automatically based on the type of the file. -And it's perfectly fine if you want to keep the fundamental mode as -the default mode.} +mode@footnote{ +This section suggests settings that are more suitable for writers. +For programmers, the default mode will be set to the corresponding +prog-mode automatically based on the type of the file. And it's +perfectly fine if you want to keep the fundamental mode as the default +mode. +}. @smallexample @group @@ -16957,17 +16959,18 @@ This line is a short, but complete Emacs Lisp expression. We are already familiar with @code{setq}. We use a similar macro @code{setq-default} to set the following variable, -@code{major-mode}@footnote{We use @code{setq-default} because -@code{text-mode} is buffer local. If we use @code{setq} it will only -apply to the current buffer, and using @code{setq-default} will also -apply this to newly created buffers.}, to the subsequent value, which -is @code{text-mode}. The single-quote before @code{text-mode} tells -Emacs to deal directly with the @code{text-mode} symbol, not with -whatever it might stand for. @xref{setq, , Setting the Value of -a Variable}, for a reminder of how @code{setq} works. The main point -is that there is no difference between the procedure you use to set -a value in your @file{.emacs} file and the procedure you use anywhere -else in Emacs. +@code{major-mode}@footnote{ +We use @code{setq-default} here because @code{text-mode} is +buffer-local. If we use @code{setq}, it will only apply to the +current buffer, whereas using @code{setq-default} will also apply to +newly created buffers. This is not recommended for programmers. +}, to the subsequent value, which is @code{text-mode}. The +single-quote before @code{text-mode} tells Emacs to deal directly with +the @code{text-mode} symbol, not with whatever it might stand for. +@xref{setq, , Setting the Value of a Variable}, for a reminder of how +@code{setq} works. The main point is that there is no difference +between the procedure you use to set a value in your @file{.emacs} +file and the procedure you use anywhere else in Emacs. @need 800 Here is the next line: From eb19984c4dbba3c5237a679167fd8583bdb6ad70 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sun, 24 Dec 2023 14:57:49 +0100 Subject: [PATCH 09/18] Mark icalendar.el as maintained by emacs-devel * lisp/calendar/icalendar.el: Mark emacs-devel as the maintainer. Ref: https://debbugs.gnu.org/34315#152 --- lisp/calendar/icalendar.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el index e51251d6d9f..aadf3887a10 100644 --- a/lisp/calendar/icalendar.el +++ b/lisp/calendar/icalendar.el @@ -3,6 +3,7 @@ ;; Copyright (C) 2002-2023 Free Software Foundation, Inc. ;; Author: Ulf Jasper +;; Maintainer: emacs-devel@gnu.org ;; Created: August 2002 ;; Keywords: calendar ;; Human-Keywords: calendar, diary, iCalendar, vCalendar From be8a7155b48198b08bbc4844b2ce60c127405fb7 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 25 Dec 2023 14:59:26 +0200 Subject: [PATCH 10/18] 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) --- lisp/window.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/window.el b/lisp/window.el index 35de790d85e..2c001d4112f 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -5723,7 +5723,8 @@ The current window configuration is retained in the top window, the lower window takes up the whole width of the frame. SIZE is handled as in `split-window-below', and interactively is the prefix numeric argument." - (interactive "p") + (interactive `(,(when current-prefix-arg + (prefix-numeric-value current-prefix-arg)))) (split-window-below size (frame-root-window))) (defun split-window-right (&optional size window-to-split) @@ -5763,7 +5764,8 @@ The current window configuration is retained within the left window, and a new window is created on the right, taking up the whole height of the frame. SIZE is treated as by `split-window-right' and interactively, is the prefix numeric argument." - (interactive "p") + (interactive `(,(when current-prefix-arg + (prefix-numeric-value current-prefix-arg)))) (split-window-right size (frame-root-window))) ;;; Balancing windows. From fcbb00448998cdfffcf7455192bfebf98ef27a1e Mon Sep 17 00:00:00 2001 From: Jared Finder Date: Sat, 16 Dec 2023 12:10:03 -0800 Subject: [PATCH 11/18] 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) --- lisp/dired.el | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lisp/dired.el b/lisp/dired.el index cc548baf080..998de06ee63 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -1941,9 +1941,18 @@ mouse-2: visit this file in other window" keymap ,(let* ((current-dir dir) (click (lambda () (interactive) - (if (assoc current-dir dired-subdir-alist) - (dired-goto-subdir current-dir) - (dired current-dir))))) + (cond + ((assoc current-dir dired-subdir-alist) + (dired-goto-subdir current-dir)) + ;; If there is a wildcard character in the directory, don't + ;; use the alternate file machinery which tries to keep only + ;; one dired buffer open at once. + ;; + ;; FIXME: Is this code path reachable? + ((insert-directory-wildcard-in-dir-p current-dir) + (dired current-dir)) + (t + (dired--find-possibly-alternative-file current-dir)))))) (define-keymap "" click "" 'mouse-face From 627142219683441a907f9a96239fdb188202e129 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 25 Dec 2023 15:07:21 +0200 Subject: [PATCH 12/18] ; * lisp/dired.el (dired--make-directory-clickable): Reformat comment. --- lisp/dired.el | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lisp/dired.el b/lisp/dired.el index 998de06ee63..de96a3d9dd7 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -1944,15 +1944,19 @@ mouse-2: visit this file in other window" (cond ((assoc current-dir dired-subdir-alist) (dired-goto-subdir current-dir)) - ;; If there is a wildcard character in the directory, don't - ;; use the alternate file machinery which tries to keep only - ;; one dired buffer open at once. + ;; If there is a wildcard chars + ;; in the directory name, don't + ;; use the alternate file machinery + ;; which tries to keep only one + ;; dired buffer open at once. ;; ;; FIXME: Is this code path reachable? - ((insert-directory-wildcard-in-dir-p current-dir) + ((insert-directory-wildcard-in-dir-p + current-dir) (dired current-dir)) (t - (dired--find-possibly-alternative-file current-dir)))))) + (dired--find-possibly-alternative-file + current-dir)))))) (define-keymap "" click "" 'mouse-face From 9afba605bbc3db354476dddeffacfa036259c101 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 25 Dec 2023 16:04:18 +0100 Subject: [PATCH 13/18] Explain status "r" in `epa-list-keys` * lisp/epa.el (epa-list-keys): Add revoked status to description. Suggested by CHENG Gao . --- lisp/epa.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/epa.el b/lisp/epa.el index 8126584e4fb..b8af2a960f0 100644 --- a/lisp/epa.el +++ b/lisp/epa.el @@ -384,7 +384,7 @@ DOC is documentation text to insert at the start." (epa--list-keys name nil "The letters at the start of a line have these meanings. e expired key. n never trust. m trust marginally. u trust ultimately. -f trust fully (keys you have signed, usually). +f trust fully (keys you have signed, usually). r revoked key. q trust status questionable. - trust status unspecified. See GPG documentation for more explanation. \n")) From c86b039dffc23354ae898f358eadbe5b58e67aa3 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 26 Dec 2023 14:49:50 +0200 Subject: [PATCH 14/18] ; * etc/DEBUG: Improve advice for debugging native-compilation (bug#67900). --- etc/DEBUG | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/etc/DEBUG b/etc/DEBUG index d24e0e6ce00..290c01faf3e 100644 --- a/etc/DEBUG +++ b/etc/DEBUG @@ -605,7 +605,17 @@ recommend to follow the procedure below to try to identify the cause: . Reduce the problematic .el file to the minimum by bisection, and try identifying the function that causes the problem. - . Reduce the problematic function to the minimal code that still + . Try natively compiling the problematic file with + 'native-comp-speed' set to 1 or even zero. If doing that solves + the problem, you can use + + (declare (speed 1)) + + at the beginning of the body of suspected function(s) to change + native-comp-speed only for those functions -- this could help you + identify the function(s) which cause(s) the problem. + + . Reduce the problematic function(s) to the minimal code that still reproduces the problem. . Study the problem's artifacts, like Lisp or C backtraces, to try From ccf46acefd2272afa18832cd6dd4d35b0803e70a Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 26 Dec 2023 14:51:37 +0200 Subject: [PATCH 15/18] ; Fix last change. --- etc/DEBUG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/DEBUG b/etc/DEBUG index 290c01faf3e..f66a8d5d588 100644 --- a/etc/DEBUG +++ b/etc/DEBUG @@ -612,7 +612,7 @@ recommend to follow the procedure below to try to identify the cause: (declare (speed 1)) at the beginning of the body of suspected function(s) to change - native-comp-speed only for those functions -- this could help you + 'native-comp-speed' only for those functions -- this could help you identify the function(s) which cause(s) the problem. . Reduce the problematic function(s) to the minimal code that still From 44517037aed6caada1d18bc6e39cc52413df6f84 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Tue, 26 Dec 2023 22:09:57 +0100 Subject: [PATCH 16/18] ; Fix typo --- doc/lispref/control.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi index 90b1358b3cd..7308115f47f 100644 --- a/doc/lispref/control.texi +++ b/doc/lispref/control.texi @@ -728,7 +728,7 @@ has over @code{cl-case} ;; symbol ('success (message "Done!")) ('would-block (message "Sorry, can't do it now")) - ('read-only (message "The shmliblick is read-only")) + ('read-only (message "The schmilblick is read-only")) ('access-denied (message "You do not have the needed rights")) @end group @group From fa0bb88302b5d9e02190f60cf50ce8a85e849cdf Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 28 Dec 2023 21:46:59 +0200 Subject: [PATCH 17/18] ; * src/buffer.c (syms_of_buffer) : Doc fix (bug#68088). --- src/buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index db362ffe7b0..6b2cfa93926 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -5346,8 +5346,8 @@ visual lines rather than logical lines. See the documentation of Qstringp, doc: /* Name of default directory of current buffer. It should be an absolute directory name; on GNU and Unix systems, -these names start with `/' or `~' and end with `/'. -To interactively change the default directory, use command `cd'. */); +these names start with "/" or "~" and end with "/". +To interactively change the default directory, use the command `cd'. */); DEFVAR_PER_BUFFER ("auto-fill-function", &BVAR (current_buffer, auto_fill_function), Qnil, From 530315287254da2e6b0767ad343fa55f79be8536 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Fri, 29 Dec 2023 19:52:07 -0800 Subject: [PATCH 18/18] Revert "Fix treesit-node-field-name and friends (bug#66674)" This reverts commit 9874561f39e62c1c9fada6c2e013f93d9ea65729. See bug#67990. Basically our original code is correct, the error is in libtree-sitter, which only manifests in certain cases. https://github.com/tree-sitter/tree-sitter/pull/2104 --- doc/lispref/parsing.texi | 4 ++-- lisp/treesit.el | 3 +-- src/treesit.c | 7 ++++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi index 34eb2826a21..353585f79c7 100644 --- a/doc/lispref/parsing.texi +++ b/doc/lispref/parsing.texi @@ -1015,8 +1015,8 @@ This function returns the field name of the @var{n}'th child of @var{node}. It returns @code{nil} if there is no @var{n}'th child, or the @var{n}'th child doesn't have a field name. -Note that @var{n} counts named nodes only, and @var{n} can be -negative, e.g., @minus{}1 represents the last child. +Note that @var{n} counts both named and anonymous children, and +@var{n} can be negative, e.g., @minus{}1 represents the last child. @end defun @defun treesit-node-child-count node &optional named diff --git a/lisp/treesit.el b/lisp/treesit.el index eed53bc2b99..264b95dc3a3 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -360,7 +360,6 @@ If NAMED is non-nil, collect named child only." "Return the index of NODE in its parent. If NAMED is non-nil, count named child only." (let ((count 0)) - ;; TODO: Use next-sibling as it's more efficient. (while (setq node (treesit-node-prev-sibling node named)) (cl-incf count)) count)) @@ -368,7 +367,7 @@ If NAMED is non-nil, count named child only." (defun treesit-node-field-name (node) "Return the field name of NODE as a child of its parent." (when-let ((parent (treesit-node-parent node)) - (idx (treesit-node-index node t))) + (idx (treesit-node-index node))) (treesit-node-field-name-for-child parent idx))) ;;; Query API supplement diff --git a/src/treesit.c b/src/treesit.c index 879405e551a..d9b981c1eae 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -2019,8 +2019,9 @@ DEFUN ("treesit-node-field-name-for-child", Return nil if there's no Nth child, or if it has no field. If NODE is nil, return nil. -Note that N counts named nodes only. Also, N could be negative, e.g., --1 represents the last child. */) +N counts all children, i.e., named ones and anonymous ones. + +N could be negative, e.g., -1 represents the last child. */) (Lisp_Object node, Lisp_Object n) { if (NILP (node)) @@ -2034,7 +2035,7 @@ Note that N counts named nodes only. Also, N could be negative, e.g., /* Process negative index. */ if (idx < 0) - idx = ts_node_named_child_count (treesit_node) + idx; + idx = ts_node_child_count (treesit_node) + idx; if (idx < 0) return Qnil; if (idx > UINT32_MAX)