commit 5e8c62ffcae473b89e268e0081d4041fb19abef7 (HEAD, refs/remotes/origin/master) Author: Stefan Kangas Date: Wed Nov 23 05:43:19 2022 +0100 ; Fix typos diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi index cb0d9c50da..b0fef2b5b6 100644 --- a/doc/misc/gnus.texi +++ b/doc/misc/gnus.texi @@ -26539,7 +26539,7 @@ Store custom flags and keywords letter. @end defvar -@defun gnus-registry-mark-article +@defun gnus-registry-set-article-mark Call this function to mark an article with a custom registry mark. It will offer the available marks for completion. @end defun diff --git a/etc/NEWS.24 b/etc/NEWS.24 index fab8a39b0e..8ef479ac0a 100644 --- a/etc/NEWS.24 +++ b/etc/NEWS.24 @@ -951,7 +951,7 @@ Also the following files used by the now obsolete otodo-mode.el: *** the old version of todo-mode.el (renamed to otodo-mode.el). -*** xesam.el (owing to the cancelation of the XESAM project). +*** xesam.el (owing to the cancellation of the XESAM project). *** yow.el; use fortune.el or cookie1.el instead. diff --git a/lib-src/ChangeLog.1 b/lib-src/ChangeLog.1 index 1a9767661a..0829f50a56 100644 --- a/lib-src/ChangeLog.1 +++ b/lib-src/ChangeLog.1 @@ -5643,7 +5643,7 @@ 1998-04-06 Andreas Schwab Silence -Wimplicit: - * movemail.c: Move cancelations up. Include if + * movemail.c: Move cancellations up. Include if available. * fakemail.c (_XOPEN_SOURCE): Define for declaration of cuserid. (parse_header): Explicitly declare return type. diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el index 10bd4bc688..762cc8eb4f 100644 --- a/lisp/emacs-lisp/pcase.el +++ b/lisp/emacs-lisp/pcase.el @@ -395,7 +395,7 @@ pcase-compile-patterns (push (setq prev (list case)) seen)) ;; Put a counter in the cdr just so that not ;; all branches look identical (to avoid things - ;; like `macroexp--if' optimizing them too + ;; like `macroexp-if' optimizing them too ;; optimistically). (let ((ph (cons 'pcase--placeholder (setq phcounter (1+ phcounter))))) diff --git a/lisp/gnus/ChangeLog.3 b/lisp/gnus/ChangeLog.3 index a1ad22fd62..c55d6225e3 100644 --- a/lisp/gnus/ChangeLog.3 +++ b/lisp/gnus/ChangeLog.3 @@ -1109,7 +1109,7 @@ * gnus-icalendar.el (gnus-icalendar-event:sync-to-org) (gnus-icalendar-event:inline-org-buttons): Allow for appointment - cancelations to be synced to org if the original appt has an org + cancellations to be synced to org if the original appt has an org outline. 2013-11-13 Jan Tatarik diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el index 814d21823d..75ea34e135 100644 --- a/lisp/gnus/gnus-art.el +++ b/lisp/gnus/gnus-art.el @@ -89,8 +89,8 @@ gnus-article-washing :group 'gnus-article) (defgroup gnus-article-emphasis nil - "Fontisizing articles." - :link '(custom-manual "(gnus)Article Fontisizing") + "Fontifying articles." + :link '(custom-manual "(gnus)Article Fontifying") :group 'gnus-article) (defgroup gnus-article-saving nil @@ -2008,9 +2008,9 @@ article-hide-boring-headers (gnus-article-hide-header "reply-to"))))) ((eq elem 'date) (let ((date (with-current-buffer gnus-original-article-buffer - ;; If date in `gnus-article-buffer' is localized - ;; (`gnus-treat-date-user-defined'), - ;; `days-between' might fail. + ;; If date in `gnus-article-buffer' is localized + ;; (`gnus-article-date-headers'), + ;; `days-between' might fail. (message-fetch-field "date")))) (when (and date (< (days-between (current-time-string) date) diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el index ceeb184854..cf5ca628cf 100644 --- a/lisp/gnus/gnus-registry.el +++ b/lisp/gnus/gnus-registry.el @@ -119,7 +119,7 @@ gnus-registry-marks "List of registry marks and their options. -`gnus-registry-mark-article' will offer symbols from this list +`gnus-registry-set-article-mark' will offer symbols from this list for completion. Each entry must have a character to be useful for summary mode diff --git a/lisp/gnus/gnus-search.el b/lisp/gnus/gnus-search.el index 7941496be6..142070e466 100644 --- a/lisp/gnus/gnus-search.el +++ b/lisp/gnus/gnus-search.el @@ -48,7 +48,7 @@ ;; The general flow is: ;; 1. The user calls one of `gnus-group-make-search-group' or -;; `gnus-group-make-permanent-search-group' (or a few other entry +;; `gnus-group-read-ephemeral-search-group' (or a few other entry ;; points). These functions prompt for a search query, and collect ;; the groups to search, then create an nnselect group, setting an ;; 'nnselect-specs group parameter where 'nnselect-function is diff --git a/lisp/gnus/gnus-topic.el b/lisp/gnus/gnus-topic.el index 13263dddc9..1acbe0bc93 100644 --- a/lisp/gnus/gnus-topic.el +++ b/lisp/gnus/gnus-topic.el @@ -427,7 +427,7 @@ gnus-topic-enter-dribble (defun gnus-group-prepare-topics (level &optional predicate lowest regexp list-topic topic-level) "List all newsgroups with unread articles of level LEVEL or lower. -Use the `gnus-group-topics' to sort the groups. +Use the `gnus-group-prepare-topics' to sort the groups. If PREDICATE is a function, list groups that the function returns non-nil; if it is t, list groups that have no unread articles. If LOWEST is non-nil, list all newsgroups of level LOWEST or higher." diff --git a/lisp/gnus/gnus-uu.el b/lisp/gnus/gnus-uu.el index 9cafc78ab8..654cc1cc51 100644 --- a/lisp/gnus/gnus-uu.el +++ b/lisp/gnus/gnus-uu.el @@ -1622,7 +1622,7 @@ gnus-uu-unshar-article state)) ;; `gnus-uu-choose-action' chooses what action to perform given the name -;; and `gnus-uu-file-action-list'. Returns either nil if no action is +;; and FILE-ACTION-LIST. Return either nil if no action is ;; found, or the name of the command to run if such a rule is found. (defun gnus-uu-choose-action (file-name file-action-list &optional no-ignore) (let ((action-list (copy-sequence file-action-list)) diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index e0677ff6be..5589908764 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -7520,7 +7520,7 @@ message-is-yours-p ;;;###autoload (defun message-cancel-news (&optional arg) "Cancel an article you posted. -If ARG, allow editing of the cancelation message." +If ARG, allow editing of the cancellation message." (interactive "P") (unless (message-news-p) (error "This is not a news article; canceling is impossible")) diff --git a/lisp/jsonrpc.el b/lisp/jsonrpc.el index 1387fa3692..90833e1c1d 100644 --- a/lisp/jsonrpc.el +++ b/lisp/jsonrpc.el @@ -308,7 +308,7 @@ jsonrpc-request (setq canceled t)) `(canceled ,cancel-on-input-retval)) (t (while t (accept-process-output nil 30))))) - ;; In normal operation, cancelation is handled by the + ;; In normal operation, cancellation is handled by the ;; timeout function and response filter, but we still have ;; to protect against user-quit (C-g) or the ;; `cancel-on-input' case. diff --git a/lisp/progmodes/antlr-mode.el b/lisp/progmodes/antlr-mode.el index 1aee1107e6..b722790334 100644 --- a/lisp/progmodes/antlr-mode.el +++ b/lisp/progmodes/antlr-mode.el @@ -169,7 +169,7 @@ antlr-action-visibility (defcustom antlr-indent-comment 'tab "Non-nil, if the indentation should touch lines in block comments. If nil, no continuation line of a block comment is changed. If t, they -are changed according to `c-indentation-line'. When not nil and not t, +are changed according to `c-indent-line'. When not nil and not t, they are only changed by \\[antlr-indent-command]." :type '(radio (const :tag "No" nil) (const :tag "Always" t) diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 7e6dd43175..086166c822 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -4017,7 +4017,7 @@ c-append-to-state-cache (t from)))))) (defun c-remove-stale-state-cache (start-point here pps-point) - ;; Remove stale entries from the `c-cache-state', i.e. those which will + ;; Remove stale entries from the `c-state-cache', i.e. those which will ;; not be in it when it is amended for position HERE. This may involve ;; replacing a CONS element for a brace pair containing HERE with its car. ;; Additionally, the "outermost" open-brace entry before HERE will be @@ -10103,7 +10103,7 @@ c-forward-decl-or-cast-1 ;; Specifically it is nil, or a three element list (A B C) where C is t ;; when context is '<> and the "identifier" is a found type, B is t when a ;; `c-typedef-kwds' ("typedef") is present, and A is t when some other - ;; `c-typedef-declkwds' (e.g. class, struct, enum) specifier is present. + ;; `c-typedef-decl-kwds' (e.g. class, struct, enum) specifier is present. ;; I.e., (some of) the declared identifier(s) are types. ;; ;; The third element of the return value is non-nil when the declaration @@ -15518,7 +15518,7 @@ c-get-offset (defun c-get-syntactic-indentation (langelems) ;; Calculate the syntactic indentation from a syntactic description - ;; as returned by `c-guess-syntax'. + ;; as returned by `c-guess-basic-syntax'. ;; ;; Note that topmost-intro always has an anchor position at bol, for ;; historical reasons. It's often used together with other symbols diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index 561aa0f7e5..47e05438ea 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el @@ -1440,7 +1440,7 @@ c-non-after-{}-ops-re (c-lang-defconst c-overloadable-operators "List of the operators that are overloadable, in their \"identifier -form\". See also `c-op-identifier-prefix'." +form\". See also `c-opt-op-identifier-prefix'." t nil c++ '("new" "delete" ;; Can be followed by "[]" but we ignore that. "+" "-" "*" "/" "%" @@ -2526,7 +2526,7 @@ c-defun-type-name-decl-kwds (c-lang-const c-brace-list-decl-kwds))) (c-lang-defconst c-defun-type-name-decl-key - ;; Regexp matching a keyword in `c-defun-name-decl-kwds'. + ;; Regexp matching a keyword in `c-defun-type-name-decl-kwds'. t (c-make-keywords-re t (c-lang-const c-defun-type-name-decl-kwds))) (c-lang-defvar c-defun-type-name-decl-key (c-lang-const c-defun-type-name-decl-key)) @@ -2620,7 +2620,7 @@ c-equals-nontype-decl-kwds (c-lang-defconst c-equals-nontype-decl-key ;; An unadorned regular expression which matches any member of - ;; `c-equals-decl-kwds', or nil if such don't exist in the current language. + ;; `c-equals-nontype-decl-kwds', or nil if such don't exist in the current language. t (when (c-lang-const c-equals-nontype-decl-kwds) (c-make-keywords-re nil (c-lang-const c-equals-nontype-decl-kwds)))) (c-lang-defvar c-equals-nontype-decl-key @@ -4486,7 +4486,7 @@ c-make-init-lang-vars-fun (error (if current-var (message - "Eval error in the `c-lang-defvar' or `c-lang-setver' for `%s' (source eval): %S" + "Eval error in the `c-lang-defvar' or `c-lang-setvar' for `%s' (source eval): %S" current-var err) (signal (car err) (cdr err))))))) )) diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index 5a610253e0..99067e4761 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el @@ -1391,7 +1391,7 @@ c-restore-string-fences (defvar c-bc-changed-stringiness nil) ;; Non-nil when, in a before-change function, the deletion of a range of text ;; will change the "stringiness" of the subsequent text. Only used when -;; `c-multiline-sting-start-char' is a non-nil value which isn't a character. +;; `c-multiline-string-start-char' is a non-nil value which isn't a character. (defun c-remove-string-fences (&optional here) ;; The character after HERE (default point) is either a string delimiter or @@ -1713,7 +1713,7 @@ c-after-change-escape-NL-in-string ;; ;; This function is called exclusively as an after-change function via ;; `c-before-font-lock-functions'. In C++ Mode, it should come before - ;; `c-after-change-unmark-raw-strings' in that lang variable. + ;; `c-after-change-unmark-ml-strings' in that lang variable. (let (lit-start ; Don't calculate this till we have to. lim) (when diff --git a/lisp/progmodes/idlwave.el b/lisp/progmodes/idlwave.el index 81f74dc1fa..cd2fc7c707 100644 --- a/lisp/progmodes/idlwave.el +++ b/lisp/progmodes/idlwave.el @@ -266,7 +266,7 @@ idlwave-hang-indent-regexp :type 'regexp) (defcustom idlwave-use-last-hang-indent nil - "If non-nil then use last match on line for `idlwave-indent-regexp'." + "If non-nil then use last match on line for `idlwave-hang-indent-regexp'." :group 'idlwave-code-formatting :type 'boolean) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 3a919c8cf2..18594a3e23 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -578,7 +578,7 @@ python--font-lock-f-strings ;; FIXME: This will fail to properly highlight strings appearing ;; within the {...} of an f-string. ;; We could presumably fix it by running - ;; `font-lock-fontify-syntactically-region' (as is done in + ;; `font-lock-default-fontify-syntactically-region' (as is done in ;; `sm-c--cpp-fontify-syntactically', for example) after removing ;; the `face' property, but I'm not sure it's worth the effort and ;; the risks. diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 4b46e5a1fb..734252ee66 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -1795,7 +1795,7 @@ css-ts-mode \\{css-mode-map}" (when (treesit-ready-p 'css) - ;; Borrowed from `css-native-mode'. + ;; Borrowed from `css-mode'. (add-hook 'completion-at-point-functions #'css-completion-at-point nil 'local) (setq-local fill-paragraph-function #'css-fill-paragraph) diff --git a/lisp/treesit.el b/lisp/treesit.el index 8fb6de7378..419a705dbf 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -610,7 +610,7 @@ treesit-font-lock-rules For each QUERY, a :language keyword and a :feature keyword are required. Each query's :feature is a symbol summarizing what the query fontifies. It is used to allow users to enable/disable -certain features. See `treesit-font-lock-kind-list' for more. +certain features. See `treesit-font-lock-feature-list' for more. Other keywords include: KEYWORD VALUE DESCRIPTION diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index fa3d58f770..328d33040d 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1561,7 +1561,7 @@ vc--read-lines (insert-file-contents file) (split-string (buffer-string) "\n" t))) -;; Subroutine for `vc-git-ignore' and `vc-hg-ignore'. +;; Subroutine for `vc-default-ignore'. (defun vc--add-line (string file) "Add STRING as a line to FILE." (with-current-buffer (find-file-noselect file) diff --git a/src/treesit.c b/src/treesit.c index 4a7c401956..21e1f866f7 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -295,7 +295,7 @@ #define ts_tree_root_node fn_ts_tree_root_node a node. But since we can just retrieve a new node, it shouldn't be a limitation. - - I didn't expose setting timeout and cancelation flag for a + - I didn't expose setting timeout and cancellation flag for a parser, mainly because I don't think they are really necessary in Emacs's use cases. @@ -891,7 +891,7 @@ treesit_ensure_parsed (Lisp_Object parser) when 1) language is not set (impossible in Emacs because the user has to supply a language to create a parser), 2) parse canceled due to timeout (impossible because we don't set a timeout), 3) - parse canceled due to cancelation flag (impossible because we + parse canceled due to cancellation flag (impossible because we don't set the flag). (See comments for ts_parser_parse in tree_sitter/api.h.) */ if (new_tree == NULL) diff --git a/test/lisp/erc/resources/base/netid/bouncer/barnet-drop.eld b/test/lisp/erc/resources/base/netid/bouncer/barnet-drop.eld index 2c3d297b9c..686a47f68a 100644 --- a/test/lisp/erc/resources/base/netid/bouncer/barnet-drop.eld +++ b/test/lisp/erc/resources/base/netid/bouncer/barnet-drop.eld @@ -36,6 +36,6 @@ (0.1 ":joe!~u@awyxgybtkx7uq.irc PRIVMSG #chan :mike: Why, will shall break it; will, and nothing else.") (0.1 ":mike!~u@awyxgybtkx7uq.irc PRIVMSG #chan :joe: Yes, a dozen; and as many to the vantage, as would store the world they played for.") (0.05 ":joe!~u@awyxgybtkx7uq.irc PRIVMSG #chan :mike: As he regards his aged father's life.") - (0.05 ":mike!~u@awyxgybtkx7uq.irc PRIVMSG #chan :joe: It is a rupture that you may easily heal; and the cure of it not only saves your brother, but keeps you from dishonour in doing it.")) + (0.05 ":mike!~u@awyxgybtkx7uq.irc PRIVMSG #chan :joe: It is a rupture that you may easily heal; and the cure of it not only saves your brother, but keeps you from dishonor in doing it.")) ((drop 0 DROP)) diff --git a/test/lisp/erc/resources/base/netid/bouncer/barnet.eld b/test/lisp/erc/resources/base/netid/bouncer/barnet.eld index abfcc6ed48..d0fe3af8ea 100644 --- a/test/lisp/erc/resources/base/netid/bouncer/barnet.eld +++ b/test/lisp/erc/resources/base/netid/bouncer/barnet.eld @@ -36,6 +36,6 @@ (0.1 ":joe!~u@awyxgybtkx7uq.irc PRIVMSG #chan :mike: Why, will shall break it; will, and nothing else.") (0.1 ":mike!~u@awyxgybtkx7uq.irc PRIVMSG #chan :joe: Yes, a dozen; and as many to the vantage, as would store the world they played for.") (0.05 ":joe!~u@awyxgybtkx7uq.irc PRIVMSG #chan :mike: As he regards his aged father's life.") - (0.05 ":mike!~u@awyxgybtkx7uq.irc PRIVMSG #chan :joe: It is a rupture that you may easily heal; and the cure of it not only saves your brother, but keeps you from dishonour in doing it.")) + (0.05 ":mike!~u@awyxgybtkx7uq.irc PRIVMSG #chan :joe: It is a rupture that you may easily heal; and the cure of it not only saves your brother, but keeps you from dishonor in doing it.")) ((linger 1 LINGER)) diff --git a/test/lisp/erc/resources/erc-d/resources/dynamic-barnet.eld b/test/lisp/erc/resources/erc-d/resources/dynamic-barnet.eld index 36b1cc2308..4994e9c550 100644 --- a/test/lisp/erc/resources/erc-d/resources/dynamic-barnet.eld +++ b/test/lisp/erc/resources/erc-d/resources/dynamic-barnet.eld @@ -30,4 +30,4 @@ (0 ":irc.barnet.org 329 tester #chan 1620805269") (0.1 ":joe!~u@awyxgybtkx7uq.irc PRIVMSG #chan :mike: Yes, a dozen; and as many to the vantage, as would store the world they played for.") (0.05 ":mike!~u@awyxgybtkx7uq.irc PRIVMSG #chan :joe: As he regards his aged father's life.") - (0.05 ":joe!~u@awyxgybtkx7uq.irc PRIVMSG #chan :mike: It is a rupture that you may easily heal; and the cure of it not only saves your brother, but keeps you from dishonour in doing it.")) + (0.05 ":joe!~u@awyxgybtkx7uq.irc PRIVMSG #chan :mike: It is a rupture that you may easily heal; and the cure of it not only saves your brother, but keeps you from dishonor in doing it.")) diff --git a/test/lisp/erc/resources/erc-d/resources/dynamic-foonet.eld b/test/lisp/erc/resources/erc-d/resources/dynamic-foonet.eld index 5dbea50f86..a47998e7d3 100644 --- a/test/lisp/erc/resources/erc-d/resources/dynamic-foonet.eld +++ b/test/lisp/erc/resources/erc-d/resources/dynamic-foonet.eld @@ -29,4 +29,4 @@ (0 ":irc.foonet.org 329 tester #chan 1620805269") (0.1 ":alice!~u@awyxgybtkx7uq.irc PRIVMSG #chan :bob: Yes, a dozen; and as many to the vantage, as would store the world they played for.") (0.05 ":bob!~u@awyxgybtkx7uq.irc PRIVMSG #chan :alice: As he regards his aged father's life.") - (0.05 ":alice!~u@awyxgybtkx7uq.irc PRIVMSG #chan :bob: It is a rupture that you may easily heal; and the cure of it not only saves your brother, but keeps you from dishonour in doing it.")) + (0.05 ":alice!~u@awyxgybtkx7uq.irc PRIVMSG #chan :bob: It is a rupture that you may easily heal; and the cure of it not only saves your brother, but keeps you from dishonor in doing it.")) diff --git a/test/lisp/vc/vc-tests.el b/test/lisp/vc/vc-tests.el index 13248a3650..c54fe144b7 100644 --- a/test/lisp/vc/vc-tests.el +++ b/test/lisp/vc/vc-tests.el @@ -122,7 +122,7 @@ vc-test--cleanup-hook Don't set it globally, the functions should be let-bound.") (defun vc-test--revision-granularity-function (backend) - "Run the `vc-revision-granularity' backend function." + "Run the `revision-granularity' backend function." (vc-call-backend backend 'revision-granularity)) (defun vc-test--create-repo-function (backend) commit 17ed39cc8da1681bffc67907d3a76ef3d75917fd Author: Yuan Fu Date: Tue Nov 22 19:57:44 2022 -0800 ; Remove obsolete use of inhibit-point-motion-hooks * lisp/treesit.el (treesit-font-lock-fontify-region): Remove it. diff --git a/lisp/treesit.el b/lisp/treesit.el index 3ea6fae4df..8fb6de7378 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -900,8 +900,7 @@ treesit-font-lock-fontify-region sub-node query (max (- start delta-start) (point-min)) (min (+ end delta-end) (point-max)))) - (end-time (current-time)) - (inhibit-point-motion-hooks t)) + (end-time (current-time))) ;; If for any query the query time is strangely long, ;; switch to fast mode (see comments above). (when (> (time-to-seconds (time-subtract end-time start-time)) commit d2ab1c4a9af205bbeeaf5a0b6333797c18e43f86 Author: Yuan Fu Date: Tue Nov 22 18:47:47 2022 -0800 Tweak python-ts-mode fontification (bug#59470) * lisp/progmodes/python.el (python--treesit-settings): Only fontify the @ and the identifier of a decorator, not the argument list (if there is any). diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index af59b8e146..3a919c8cf2 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1113,7 +1113,9 @@ python--treesit-settings :feature 'decorator :language 'python - '((decorator) @font-lock-type-face) + '((decorator "@" @font-lock-type-face) + (decorator (call function: (identifier) @font-lock-type-face)) + (decorator (identifier) @font-lock-type-face)) :feature 'type :language 'python commit 0ed313642227afdeccf48057eea458edca9d2962 Author: Randy Taylor Date: Sat Nov 19 22:30:13 2022 -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. diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index e78f1b4c6e..ee2934f53c 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -134,8 +134,7 @@ java-ts-mode--font-lock-settings :feature 'constant `(((identifier) @font-lock-constant-face (:match "^[A-Z_][A-Z_\\d]*$" @font-lock-constant-face)) - (true) @font-lock-constant-face - (false) @font-lock-constant-face) + [(true) (false)] @font-lock-constant-face) :language 'java :override t :feature 'keyword @@ -163,8 +162,12 @@ java-ts-mode--font-lock-settings :override t :feature 'literal `((null_literal) @font-lock-constant-face - (decimal_floating_point_literal) @font-lock-constant-face - (hex_floating_point_literal) @font-lock-constant-face) + (binary_integer_literal) @font-lock-number-face + (decimal_integer_literal) @font-lock-number-face + (hex_integer_literal) @font-lock-number-face + (octal_integer_literal) @font-lock-number-face + (decimal_floating_point_literal) @font-lock-number-face + (hex_floating_point_literal) @font-lock-number-face) :language 'java :override t :feature 'type @@ -314,8 +317,8 @@ java-ts-mode ;; Font-lock. (setq-local treesit-font-lock-settings java-ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list - '((comment keyword constant string) - (type definition expression literal annotation) + '((comment constant keyword string) + (annotation definition expression literal type) (bracket delimiter operator))) ;; Imenu. diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 51d105b9d7..da05b7b364 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3465,6 +3465,13 @@ js--treesit-keywords "typeof" "var" "void" "while" "with" "yield") "JavaScript keywords for tree-sitter font-locking.") +(defvar js--treesit-operators + '("=" "+=" "-=" "*=" "/=" "%=" "**=" "<<=" ">>=" ">>>=" "&=" "^=" + "|=" "&&=" "||=" "??=" "==" "!=" "===" "!==" ">" ">=" "<" "<=" "+" + "-" "*" "/" "%" "++" "--" "**" "&" "|" "^" "~" "<<" ">>" ">>>" + "&&" "||" "!") + "JavaScript operators for tree-sitter font-locking.") + (defvar js--treesit-font-lock-settings (treesit-font-lock-rules @@ -3479,8 +3486,7 @@ js--treesit-font-lock-settings `(((identifier) @font-lock-constant-face (:match "^[A-Z_][A-Z_\\d]*$" @font-lock-constant-face)) - [(true) (false) (null)] @font-lock-constant-face - (number) @font-lock-constant-face) + [(true) (false) (null)] @font-lock-constant-face) :language 'javascript :override t @@ -3557,21 +3563,6 @@ js--treesit-font-lock-settings (member_expression property: (property_identifier) @font-lock-variable-name-face)])) - :language 'javascript - :override t - :feature 'property - `((pair key: (property_identifier) @font-lock-variable-name-face) - - (pair value: (identifier) @font-lock-variable-name-face) - - (pair - key: (property_identifier) @font-lock-function-name-face - value: [(function) (arrow_function)]) - - ((shorthand_property_identifier) @font-lock-variable-name-face) - - ((shorthand_property_identifier_pattern) @font-lock-variable-name-face)) - :language 'javascript :override t :feature 'pattern @@ -3596,7 +3587,42 @@ js--treesit-font-lock-settings (jsx_attribute (property_identifier) - @font-lock-constant-face))) + @font-lock-constant-face)) + + :language 'javascript + :feature 'number + `((number) @font-lock-number-face + ((identifier) @font-lock-number-face + (:match "^\\(:?NaN\\|Infinity\\)$" @font-lock-number-face))) + + :language 'javascript + :feature 'operator + `([,@js--treesit-operators] @font-lock-operator-face + (ternary_expression ["?" ":"] @font-lock-operator-face)) + + :language 'javascript + :feature 'bracket + '((["(" ")" "[" "]" "{" "}"]) @font-lock-bracket-face) + + :language 'javascript + :feature 'delimiter + '((["," "." ";" ":"]) @font-lock-delimiter-face) + + :language 'javascript + :feature 'escape-sequence + :override t + '((escape_sequence) @font-lock-escape-face) + + :language 'javascript + :override t + :feature 'property + `((property_identifier) @font-lock-property-face + + (pair value: (identifier) @font-lock-variable-name-face) + + ((shorthand_property_identifier) @font-lock-property-face) + + ((shorthand_property_identifier_pattern) @font-lock-property-face))) "Tree-sitter font-lock settings.") (defun js--fontify-template-string (node override start end &rest _) @@ -3846,9 +3872,10 @@ js-ts-mode ;; Fontification. (setq-local treesit-font-lock-settings js--treesit-font-lock-settings) (setq-local treesit-font-lock-feature-list - '((comment declaration) - (string keyword identifier expression constant) - (property pattern jsx ))) + '(( comment declaration) + ( constant expression identifier keyword number string) + ( bracket delimiter escape-sequence jsx operator + pattern property))) ;; Imenu (setq-local imenu-create-index-function #'js--treesit-imenu) diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index 4ea285bd43..101e873cf6 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el @@ -74,26 +74,28 @@ json-ts--indent-rules (defvar json-ts-mode--font-lock-settings (treesit-font-lock-rules :language 'json - :feature 'comment - :override t - '((comment) @font-lock-comment-face) + :feature 'bracket + '((["[" "]" "{" "}"]) @font-lock-bracket-face) :language 'json - :feature 'string - :override t - '((escape_sequence) @font-lock-constant-face - (string) @font-lock-string-face) + :feature 'constant + '([(null) (true) (false)] @font-lock-constant-face) + :language 'json + :feature 'delimiter + '((["," ":"]) @font-lock-delimiter-face) :language 'json :feature 'number - :override t - '((number) @font-lock-constant-face) + '((number) @font-lock-number-face) :language 'json - :feature 'constant + :feature 'string + '((string) @font-lock-string-face) + :language 'json + :feature 'escape-sequence :override t - '([(null) (true) (false)] @font-lock-constant-face) + '((escape_sequence) @font-lock-escape-face) :language 'json - :feature 'pair + :feature 'error :override t - `((pair key: (_) @font-lock-variable-name-face))) + '((ERROR) @font-lock-warning-face)) "Font-lock settings for JSON.") (defun json-ts-mode--imenu-1 (node) @@ -154,7 +156,9 @@ json-ts-mode ;; Font-lock. (setq-local treesit-font-lock-settings json-ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list - '((comment string number) (constant pair) ())) + '((constant number string) + (escape-sequence) + (bracket delimiter error))) ;; Imenu. (setq-local imenu-create-index-function #'json-ts-mode--imenu) diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 7fe31802c4..067aef8669 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1608,9 +1608,10 @@ bash-ts-mode "Major mode for editing Bash shell scripts." (when (treesit-ready-p 'bash) (setq-local treesit-font-lock-feature-list - '((comment function string heredoc) - (variable keyword command declaration-command) - (constant operator builtin-variable))) + '(( comment function heredoc string) + ( command declaration-command keyword number variable) + ( bracket builtin-variable constant delimiter + misc-punctuation operator))) (setq-local treesit-font-lock-settings sh-mode--treesit-settings) (treesit-major-mode-setup))) @@ -3216,8 +3217,7 @@ sh-shellcheck-flymake ;;; Tree-sitter font-lock (defvar sh-mode--treesit-operators - '("|" "|&" "||" "&&" ">" ">>" "<" "<<" "<<-" "<<<" "==" "!=" ";" - ";;" ";&" ";;&") + '("|" "|&" "||" "&&" ">" ">>" "<" "<<" "<<-" "<<<" "==" "!=" ";&" ";;&") "A list of `sh-mode' operators to fontify.") (defvar sh-mode--treesit-keywords @@ -3312,7 +3312,7 @@ sh-mode--treesit-settings :feature 'operator :language 'bash - `([ ,@sh-mode--treesit-operators ] @font-lock-builtin-face) + `([,@sh-mode--treesit-operators] @font-lock-operator-face) :feature 'builtin-variable :language 'bash @@ -3322,7 +3322,24 @@ sh-mode--treesit-settings `(seq bol (or ,@builtin-vars) eol))) - @font-lock-builtin-face)))) + @font-lock-builtin-face))) + + :feature 'number + :language 'bash + `(((word) @font-lock-number-face + (:match "^[0-9]+$" @font-lock-number-face))) + + :feature 'bracket + :language 'bash + '((["(" ")" "((" "))" "[" "]" "[[" "]]" "{" "}"]) @font-lock-bracket-face) + + :feature 'delimiter + :language 'bash + '(([";" ";;"]) @font-lock-delimiter-face) + + :feature 'misc-punctuation + :language 'bash + '((["$"]) @font-lock-misc-punctuation-face)) "Tree-sitter font-lock settings for `sh-mode'.") (provide 'sh-script) diff --git a/lisp/progmodes/ts-mode.el b/lisp/progmodes/ts-mode.el index a91eba6501..436b198f59 100644 --- a/lisp/progmodes/ts-mode.el +++ b/lisp/progmodes/ts-mode.el @@ -101,6 +101,13 @@ ts-mode--keywords "while" "with" "yield") "TypeScript keywords for tree-sitter font-locking.") +(defvar ts-mode--operators + '("=" "+=" "-=" "*=" "/=" "%=" "**=" "<<=" ">>=" ">>>=" "&=" "^=" + "|=" "&&=" "||=" "??=" "==" "!=" "===" "!==" ">" ">=" "<" "<=" "+" + "-" "*" "/" "%" "++" "--" "**" "&" "|" "^" "~" "<<" ">>" ">>>" + "&&" "||" "!" "?.") + "TypeScript operators for tree-sitter font-locking.") + (defvar ts-mode--font-lock-settings (treesit-font-lock-rules :language 'tsx @@ -114,8 +121,7 @@ ts-mode--font-lock-settings `(((identifier) @font-lock-constant-face (:match "^[A-Z_][A-Z_\\d]*$" @font-lock-constant-face)) - [(true) (false) (null)] @font-lock-constant-face - (number) @font-lock-constant-face) + [(true) (false) (null)] @font-lock-constant-face) :language 'tsx :override t @@ -207,25 +213,6 @@ ts-mode--font-lock-settings (member_expression property: (property_identifier) @font-lock-function-name-face)])) - :language 'tsx - :override t - :feature 'property - `((pair key: (property_identifier) @font-lock-property-face) - - (pair value: (identifier) @font-lock-variable-name-face) - - (pair - key: (property_identifier) @font-lock-property-face - value: [(function) (arrow_function)]) - - (property_signature - name: (property_identifier) @font-lock-property-face) - - ((shorthand_property_identifier) @font-lock-property-face) - - ((shorthand_property_identifier_pattern) - @font-lock-variable-name-face)) - :language 'tsx :override t :feature 'pattern @@ -250,13 +237,42 @@ ts-mode--font-lock-settings @font-lock-function-name-face) (jsx_attribute (property_identifier) @font-lock-constant-face)) + + :language 'tsx + :feature 'number + `((number) @font-lock-number-face + ((identifier) @font-lock-number-face + (:match "^\\(:?NaN\\|Infinity\\)$" @font-lock-number-face))) + + :language 'tsx + :feature 'operator + `([,@ts-mode--operators] @font-lock-operator-face + (ternary_expression ["?" ":"] @font-lock-operator-face)) + :language 'tsx :feature 'bracket '((["(" ")" "[" "]" "{" "}"]) @font-lock-bracket-face) :language 'tsx :feature 'delimiter - '((["," ":" ";"]) @font-lock-delimiter-face)) + '((["," "." ";" ":"]) @font-lock-delimiter-face) + + :language 'tsx + :feature 'escape-sequence + :override t + '((escape_sequence) @font-lock-escape-face) + + :language 'tsx + :override t + :feature 'property + `(((property_identifier) @font-lock-property-face) + + (pair value: (identifier) @font-lock-variable-name-face) + + ((shorthand_property_identifier) @font-lock-property-face) + + ((shorthand_property_identifier_pattern) + @font-lock-property-face))) "Tree-sitter font-lock settings.") ;;;###autoload @@ -303,8 +319,8 @@ ts-mode (setq-local treesit-font-lock-settings ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list '((comment declaration) - (string keyword identifier expression constant) - (property pattern jsx bracket delimiter))) + (constant expression identifier keyword number string) + (bracket delimiter jsx pattern property))) ;; Imenu. (setq-local imenu-create-index-function #'js--treesit-imenu) commit efe599df3127bea4c6251ce20513945fdd947c26 Author: Dmitry Gutov Date: Wed Nov 23 04:16:23 2022 +0200 Add a way to override project name for project-vc backend * lisp/progmodes/project.el (project-vc-name): New user option. (project-name): Override for VC project backend (bug#48747). diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 751e240a56..c7b2c386cc 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -395,6 +395,15 @@ project-vc-include-untracked :version "29.1" :safe #'booleanp) +(defcustom project-vc-name nil + "When non-nil, the name of the current VC project. + +The best way to change the value a VC project reports as its +name, is by setting this in .dir-locals.el." + :type 'string + :version "29.1" + :safe #'stringp) + ;; FIXME: Using the current approach, major modes are supposed to set ;; this variable to a buffer-local value. So we don't have access to ;; the "external roots" of language A from buffers of language B, which @@ -694,6 +703,10 @@ project-buffers (push buf bufs))) (nreverse bufs))) +(cl-defmethod project-name ((_project (head vc))) + (or project-vc-name + (cl-call-next-method))) + ;;; Project commands commit c69858b3f0ab32ed9287043c120949ec47dc54d4 Author: Yuan Fu Date: Tue Nov 22 17:29:26 2022 -0800 ; * lisp/treesit.el (treesit-ready-p): Guard against empty buffers. diff --git a/lisp/treesit.el b/lisp/treesit.el index 6042b7e6c9..3ea6fae4df 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1602,7 +1602,8 @@ treesit-ready-p (when (not (treesit-available-p)) (setq msg "tree-sitter library is not compiled with Emacs") (throw 'term nil)) - (when (> (position-bytes (1- (point-max))) treesit-max-buffer-size) + (when (> (position-bytes (max (point-min) (1- (point-max)))) + treesit-max-buffer-size) (setq msg "buffer larger than `treesit-max-buffer-size'") (throw 'term nil)) (dolist (lang language-list) commit 057901f55ad12ebbc9cf092dd6ad0f02539849f9 Author: Yuan Fu Date: Tue Nov 22 12:01:53 2022 -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. diff --git a/lisp/treesit.el b/lisp/treesit.el index 88f94b8dec..6042b7e6c9 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -460,6 +460,15 @@ treesit--merge-ranges (push range result))) (nreverse result))) +(defun treesit--clip-ranges (ranges start end) + "Clip RANGES in between START and END. +RANGES is a list of ranges of the form (BEG . END). Ranges +outside of the region between START and END are thrown away, and +those inside are kept." + (cl-loop for range in ranges + if (<= start (car range) (cdr range) end) + collect range)) + (defun treesit-update-ranges (&optional beg end) "Update the ranges for each language in the current buffer. If BEG and END are non-nil, only update parser ranges in that @@ -480,8 +489,10 @@ treesit-update-ranges (old-ranges (treesit-parser-included-ranges parser)) (new-ranges (treesit-query-range host-lang query beg end)) - (set-ranges (treesit--merge-ranges - old-ranges new-ranges beg end))) + (set-ranges (treesit--clip-ranges + (treesit--merge-ranges + old-ranges new-ranges beg end) + (point-min) (point-max)))) (dolist (parser (treesit-parser-list)) (when (eq (treesit-parser-language parser) language) commit 2fa6ccab01b80ee3fcc78fe35a0061cc11983e1c Author: Yuan Fu Date: Tue Nov 22 12:01:19 2022 -0800 ; Fix treesit--children-covering-range * lisp/treesit.el (treesit--children-covering-range): Handle the case when NODE doesn't have children, and when CHILD is nil. diff --git a/lisp/treesit.el b/lisp/treesit.el index 75e859f13f..88f94b8dec 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -793,12 +793,14 @@ treesit--set-nonsticky (defun treesit--children-covering-range (node start end) "Return a list of children of NODE covering a range. The range is between START and END." - (let* ((child (treesit-node-first-child-for-pos node start)) - (result (list child))) - (while (and (< (treesit-node-end child) end) - (setq child (treesit-node-next-sibling child))) - (push child result)) - (nreverse result))) + (if-let* ((child (treesit-node-first-child-for-pos node start)) + (result (list child))) + (progn + (while (and child (< (treesit-node-end child) end) + (setq child (treesit-node-next-sibling child))) + (push child result)) + (nreverse result)) + (list node))) (defun treesit--children-covering-range-recurse (node start end threshold) "Return a list of children of NODE covering a range. commit 95d783f27c6a585d7c1f55293fd3de6a0422c795 Author: Yuan Fu Date: Tue Nov 22 11:18:52 2022 -0800 ; * src/casefiddle.c (casify_region): Stylistic change. diff --git a/src/casefiddle.c b/src/casefiddle.c index 52dacf2702..e8ae2e276f 100644 --- a/src/casefiddle.c +++ b/src/casefiddle.c @@ -559,7 +559,8 @@ casify_region (enum case_action flag, Lisp_Object b, Lisp_Object e) update_compositions (start, end, CHECK_ALL); } #ifdef HAVE_TREE_SITTER - treesit_record_change (start_byte, old_end_byte, CHAR_TO_BYTE (orig_end + added)); + treesit_record_change (start_byte, old_end_byte, + CHAR_TO_BYTE (orig_end + added)); #endif return orig_end + added; commit 1f39da3098a2a4cec9985e6db934ed14b7b522b7 Author: Stephen Leake Date: Tue Nov 22 11:43:22 2022 -0800 * lisp/progmodes/eglot.el (eglot--connect): Use project-name As discussed in bug#48747. diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index bbd902c1c7..e057b12e0e 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -1181,7 +1181,9 @@ eglot--connect "Connect to MANAGED-MODES, LANGUAGE-ID, PROJECT, CLASS and CONTACT. This docstring appeases checkdoc, that's all." (let* ((default-directory (project-root project)) - (nickname (file-name-base (directory-file-name default-directory))) + (nickname (if (fboundp 'project-name) + (project-name project) + (file-name-base (directory-file-name default-directory)))) (readable-name (format "EGLOT (%s/%s)" nickname managed-modes)) autostart-inferior-process server-info commit 361297c6f4be54d4699c588937d7ceb142ba99d7 Author: Stephen Leake Date: Tue Nov 22 10:55:59 2022 -0800 * lisp/progmodes/project.el (project-name): New diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 63510e9050..751e240a56 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -251,6 +251,11 @@ project-external-roots headers search path, load path, class path, and so on." nil) +(cl-defgeneric project-name (project) + "A human-readable name for the project. +Nominally unique, but not enforced." + (file-name-base (directory-file-name (project-root project)))) + (cl-defgeneric project-ignores (_project _dir) "Return the list of glob patterns to ignore inside DIR. Patterns can match both regular files and directories. commit 368d2531bec84c2e75b2fd2f32bb59fc2e7ee520 Author: Eli Zaretskii Date: Tue Nov 22 20:22:41 2022 +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. diff --git a/lisp/treesit.el b/lisp/treesit.el index 10c6b09322..75e859f13f 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -98,10 +98,16 @@ treesit (defcustom treesit-max-buffer-size (let ((mb (* 1024 1024))) ;; 40MB for 64-bit systems, 15 for 32-bit. - (if (> most-positive-fixnum (* 4 1024 mb)) - (* 40 mb) - (* 15 mb))) - "Maximum buffer size for enabling tree-sitter parsing (in bytes)." + (if (or (< most-positive-fixnum (* 2.0 1024 mb)) + ;; 32-bit system with wide ints. + (string-match-p "--with-wide-int" system-configuration-options)) + (* 15 mb) + (* 40 mb))) + "Maximum buffer size (in bytes) for enabling tree-sitter parsing. + +A typical tree-sitter parser needs 10 times as much memory as the +buffer it parses. Also, the tree-sitter library has a hard limit +of max unsigned 32-bit value for byte offsets into buffer text." :type 'integer :version "29.1") @@ -1583,7 +1589,7 @@ treesit-ready-p (when (not (treesit-available-p)) (setq msg "tree-sitter library is not compiled with Emacs") (throw 'term nil)) - (when (> (buffer-size) treesit-max-buffer-size) + (when (> (position-bytes (1- (point-max))) treesit-max-buffer-size) (setq msg "buffer larger than `treesit-max-buffer-size'") (throw 'term nil)) (dolist (lang language-list) diff --git a/src/treesit.c b/src/treesit.c index 835b07c931..4a7c401956 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -840,11 +840,11 @@ treesit_ensure_position_synced (Lisp_Object parser) static void treesit_check_buffer_size (struct buffer *buffer) { - ptrdiff_t buffer_size = (BUF_Z (buffer) - BUF_BEG (buffer)); - if (buffer_size > UINT32_MAX) + ptrdiff_t buffer_size_bytes = (BUF_Z_BYTE (buffer) - BUF_BEG_BYTE (buffer)); + if (buffer_size_bytes > UINT32_MAX) xsignal2 (Qtreesit_buffer_too_large, build_pure_c_string ("Buffer size cannot be larger than 4GB"), - make_fixnum (buffer_size)); + make_fixnum (buffer_size_bytes)); } static Lisp_Object treesit_make_ranges (const TSRange *, uint32_t, struct buffer *); commit fa567684fa276511ea981cd208f99b67c521d8aa Author: Eli Zaretskii Date: Tue Nov 22 18:56:08 2022 +0200 ; Fix comparisons in treesit.c * src/treesit.c (Ftreesit_parser_add_notifier) (Ftreesit_parser_remove_notifier): Fix comparison with Lisp objects. (Bug#59483) diff --git a/src/treesit.c b/src/treesit.c index 463e2458a6..835b07c931 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -1535,7 +1535,7 @@ DEFUN ("treesit-parser-add-notifier", Ftreesit_parser_add_notifier, CHECK_SYMBOL (function); Lisp_Object functions = XTS_PARSER (parser)->after_change_functions; - if (!Fmemq (function, functions)) + if (NILP (Fmemq (function, functions))) XTS_PARSER (parser)->after_change_functions = Fcons (function, functions); return Qnil; } @@ -1555,7 +1555,7 @@ DEFUN ("treesit-parser-remove-notifier", Ftreesit_parser_remove_notifier, CHECK_SYMBOL (function); Lisp_Object functions = XTS_PARSER (parser)->after_change_functions; - if (Fmemq (function, functions)) + if (!NILP (Fmemq (function, functions))) XTS_PARSER (parser)->after_change_functions = Fdelq (function, functions); return Qnil; } commit 4b6e152e349b024936bafc485cb7e16ca14d31ca Author: Robert Pluim Date: Tue Nov 22 16:44:56 2022 +0100 Add '\lll' for VERY MUCH LESS-THAN to TeX input method * lisp/leim/quail/latin-ltx.el (latin-ltx--define-rules): Add '\lll' translation for U+22D8. (Bug#59476) diff --git a/lisp/leim/quail/latin-ltx.el b/lisp/leim/quail/latin-ltx.el index 1dfeb79c17..f7655d2efc 100644 --- a/lisp/leim/quail/latin-ltx.el +++ b/lisp/leim/quail/latin-ltx.el @@ -483,6 +483,7 @@ ("\\rhd" ?▷) ("\\ll" ?≪) ("\\llcorner" ?⌞) + ("\\lll" ?⋘) ("\\lnapprox" ?⋦) ("\\lneq" ?≨) ("\\lneqq" ?≨) commit 350918e7be82fca046911073b360518173169255 Author: Po Lu Date: Tue Nov 22 20:57:47 2022 +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) diff --git a/src/xterm.c b/src/xterm.c index 154f404e6b..732fbf462c 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -7749,6 +7749,11 @@ x_display_set_last_user_time (struct x_display_info *dpyinfo, Time time, old_time = dpyinfo->last_user_time; #endif + /* Time can be sign extended if retrieved from a client message. + Make sure it is always 32 bits, or systems with 64-bit longs + will crash after 24 days of X server uptime. (bug#59480) */ + time &= X_ULONG_MAX; + #ifdef ENABLE_CHECKING eassert (time <= X_ULONG_MAX); #endif commit 7c090ebf6b3fa065063906f9f8c9da7477fa7818 Author: Ihor Radchenko Date: Tue Nov 22 09:21:17 2022 +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) diff --git a/src/fns.c b/src/fns.c index 035fa12935..e337c0958d 100644 --- a/src/fns.c +++ b/src/fns.c @@ -596,8 +596,9 @@ DEFUN ("string-collate-lessp", Fstring_collate_lessp, Sstring_collate_lessp, 2, bind `w32-collate-ignore-punctuation' to a non-nil value, since the codeset part of the locale cannot be \"UTF-8\" on MS-Windows. -If your system does not support a locale environment, this function -behaves like `string-lessp'. */) +Some operating systems do not implement correct collation (in specific +locale environments or at all). Then, this functions falls back to +case-sensitive `string-lessp' and IGNORE-CASE argument is ignored. */) (Lisp_Object s1, Lisp_Object s2, Lisp_Object locale, Lisp_Object ignore_case) { #if defined __STDC_ISO_10646__ || defined WINDOWSNT commit 110769d039f1e5d12b948fade23563b3e540cff3 Author: Sam James Date: Mon Nov 21 22:01:37 2022 +0000 Fix tree-sitter build using non-bash /bin/sh (bug#59460) * configure.ac: Don't use '==' in comparisons. Copyright-paperwork-exempt: yes. diff --git a/configure.ac b/configure.ac index 187a43dc3e..cc4e59ee5a 100644 --- a/configure.ac +++ b/configure.ac @@ -3243,7 +3243,7 @@ AC_DEFUN AC_CHECK_FUNCS([ts_set_allocator]) CFLAGS=$OLD_CFLAGS LIBS=$OLD_LIBS - if test "$ac_cv_func_ts_set_allocator" == yes; then + if test "$ac_cv_func_ts_set_allocator" = yes; then AC_DEFINE(HAVE_TREE_SITTER, 1, [Define if using tree-sitter.]) else AC_MSG_ERROR([Tree-sitter library exists but its version is too old]); commit 60fac8a5e02983e3bf3103dbeb9af5214aa8f694 Author: Po Lu Date: Tue Nov 22 19:43:14 2022 +0800 Avoid potentially expensive XFlush and fix ordering * src/xterm.c (x_raise_frame): Don't call XFlush without a request being made. (x_lower_frame): Fix ordering wrt to xwidget view lowering. diff --git a/src/xterm.c b/src/xterm.c index af652a0d85..154f404e6b 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -27517,9 +27517,14 @@ frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y) x_raise_frame (struct frame *f) { block_input (); + if (FRAME_VISIBLE_P (f)) - XRaiseWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f)); - XFlush (FRAME_X_DISPLAY (f)); + { + XRaiseWindow (FRAME_X_DISPLAY (f), + FRAME_OUTER_WINDOW (f)); + XFlush (FRAME_X_DISPLAY (f)); + } + unblock_input (); } @@ -27567,8 +27572,6 @@ x_lower_frame (struct frame *f) XLowerWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f)); - XFlush (FRAME_X_DISPLAY (f)); - #ifdef HAVE_XWIDGETS /* Make sure any X windows owned by xwidget views of the parent still display below the lowered frame. */ @@ -27576,6 +27579,8 @@ x_lower_frame (struct frame *f) if (FRAME_PARENT_FRAME (f)) lower_frame_xwidget_views (FRAME_PARENT_FRAME (f)); #endif + + XFlush (FRAME_X_DISPLAY (f)); } static void commit eb02528b707a1b89bc9b46ac6c6c9e48a3b54a4c Author: Mattias Engdegård Date: Tue Nov 22 11:06:41 2022 +0100 ; Fix warnings in builds without tree-sitter diff --git a/test/src/treesit-tests.el b/test/src/treesit-tests.el index 59264722ba..80fde408cd 100644 --- a/test/src/treesit-tests.el +++ b/test/src/treesit-tests.el @@ -22,6 +22,39 @@ (require 'ert) (require 'treesit) +(declare-function treesit-language-available-p "treesit.c") + +(declare-function treesit-parser-root-node "treesit.c") +(declare-function treesit-parser-set-included-ranges "treesit.c") +(declare-function treesit-parser-included-ranges "treesit.c") + +(declare-function treesit-parser-create "treesit.c") +(declare-function treesit-parser-delete "treesit.c") +(declare-function treesit-parser-list "treesit.c") +(declare-function treesit-parser-buffer "treesit.c") +(declare-function treesit-parser-language "treesit.c") + +(declare-function treesit-query-expand "treesit.c") +(declare-function treesit-query-compile "treesit.c") +(declare-function treesit-query-capture "treesit.c") + +(declare-function treesit-node-type "treesit.c") +(declare-function treesit-node-start "treesit.c") +(declare-function treesit-node-end "treesit.c") +(declare-function treesit-node-string "treesit.c") +(declare-function treesit-node-parent "treesit.c") +(declare-function treesit-node-child "treesit.c") +(declare-function treesit-node-check "treesit.c") +(declare-function treesit-node-field-name-for-child "treesit.c") +(declare-function treesit-node-child-count "treesit.c") +(declare-function treesit-node-child-by-field-name "treesit.c") +(declare-function treesit-node-next-sibling "treesit.c") +(declare-function treesit-node-prev-sibling "treesit.c") +(declare-function treesit-node-first-child-for-pos "treesit.c") +(declare-function treesit-node-descendant-for-range "treesit.c") +(declare-function treesit-node-eq "treesit.c") + + (ert-deftest treesit-basic-parsing () "Test basic parsing routines." (skip-unless (treesit-language-available-p 'json)) @@ -127,7 +160,7 @@ treesit-query-api "Tests for query API." (skip-unless (treesit-language-available-p 'json)) (with-temp-buffer - (let (parser root-node pattern doc-node object-node pair-node) + (let (parser root-node) (progn (insert "[1,2,{\"name\": \"Bob\"},3]") (setq parser (treesit-parser-create 'json)) @@ -178,13 +211,12 @@ treesit-narrow "Tests if narrowing works." (skip-unless (treesit-language-available-p 'json)) (with-temp-buffer - (let (parser root-node pattern doc-node object-node pair-node) + (let (parser) (progn (insert "xxx[1,{\"name\": \"Bob\"},2,3]xxx") (narrow-to-region (+ (point-min) 3) (- (point-max) 3)) (setq parser (treesit-parser-create 'json)) - (setq root-node (treesit-parser-root-node - parser))) + (treesit-parser-root-node parser)) ;; This test is from the basic test. (should (equal @@ -236,13 +268,13 @@ treesit-cross-boundary visible_end.)" (skip-unless (treesit-language-available-p 'json)) (with-temp-buffer - (let (parser root-node pattern doc-node object-node pair-node) + (let (parser) (progn (insert "xxx[1,{\"name\": \"Bob\"},2,3]xxx") (narrow-to-region (+ (point-min) 3) (- (point-max) 3)) (setq parser (treesit-parser-create 'json)) ;; Now visible_beg/end = visible boundary. - (setq root-node (treesit-parser-root-node parser))) + (treesit-parser-root-node parser)) ;; Now parser knows the content of the visible region. (widen) ;; Now visible_beg/end don't change, but visible region expanded. @@ -315,12 +347,11 @@ treesit-range "Tests if range works." (skip-unless (treesit-language-available-p 'json)) (with-temp-buffer - (let (parser root-node pattern doc-node object-node pair-node) + (let (parser) (progn (insert "[[1],oooxxx[1,2,3],xxx[1,2]]") (setq parser (treesit-parser-create 'json)) - (setq root-node (treesit-parser-root-node - parser))) + (treesit-parser-root-node parser)) (should (eq (treesit-parser-included-ranges parser) nil)) @@ -371,10 +402,10 @@ treesit-multi-lang (treesit-language-available-p 'css) (treesit-language-available-p 'javascript))) (with-temp-buffer - (let (html css js html-range css-range js-range) + (let (css js css-range js-range) (progn (insert "") - (setq html (treesit-parser-create 'html)) + (treesit-parser-create 'html) (setq css (treesit-parser-create 'css)) (setq js (treesit-parser-create 'javascript))) ;; JavaScript. @@ -411,19 +442,19 @@ treesit-parser-supplemental 'json)) "(document (array (number) (number) (object (pair key: (string (string_content)) value: (string (string_content)))) (number)))")) (with-temp-buffer - (let (parser root-node doc-node object-node pair-node) + (let (parser root-node) (progn (insert "[1,2,{\"name\": \"Bob\"},3]") (setq parser (treesit-parser-create 'json)) (setq root-node (treesit-parser-root-node parser)) - (setq doc-node (treesit-node-child root-node 0))) + (treesit-node-child root-node 0)) ))) (ert-deftest treesit-node-supplemental () "Supplemental node functions." (skip-unless (treesit-language-available-p 'json)) - (let (parser root-node doc-node array-node) + (let (parser root-node doc-node) (progn (insert "[1,2,{\"name\": \"Bob\"},3]") (setq parser (treesit-parser-create 'json)) @@ -473,12 +504,11 @@ treesit-node-supplemental (ert-deftest treesit-node-at () "Test `treesit-node-at'." (skip-unless (treesit-language-available-p 'json)) - (let (parser root-node) + (let (parser) (progn (insert "[1, 2, 3,4] ") (setq parser (treesit-parser-create 'json)) - (setq root-node (treesit-parser-root-node - parser))) + (treesit-parser-root-node parser)) ;; Point at ",", should return ",". (goto-char (point-min)) (search-forward "1") commit 1161c96cc9cd4383d39611c018c48f15bb9367e5 Author: Yuan Fu Date: Tue Nov 22 00:49:04 2022 -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. diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 54f005508c..7fe31802c4 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1469,57 +1469,12 @@ sh-after-hack-local-variables (defvar sh-mode--treesit-settings) ;;;###autoload -(define-derived-mode sh-mode prog-mode "Shell-script" - "Major mode for editing shell scripts. -This mode works for many shells, since they all have roughly the same syntax, -as far as commands, arguments, variables, pipes, comments etc. are concerned. -Unless the file's magic number indicates the shell, your usual shell is -assumed. Since filenames rarely give a clue, they are not further analyzed. - -This mode adapts to the variations between shells (see `sh-set-shell') by -means of an inheritance based feature lookup (see `sh-feature'). This -mechanism applies to all variables (including skeletons) that pertain to -shell-specific features. Shell script files can use the `sh-shell' local -variable to indicate the shell variant to be used for the file. - -The default style of this mode is that of Rosenblatt's Korn shell book. -The syntax of the statements varies with the shell being used. The -following commands are available, based on the current shell's syntax: -\\ -\\[sh-case] case statement -\\[sh-for] for loop -\\[sh-function] function definition -\\[sh-if] if statement -\\[sh-indexed-loop] indexed loop from 1 to n -\\[sh-while-getopts] while getopts loop -\\[sh-repeat] repeat loop -\\[sh-select] select loop -\\[sh-until] until loop -\\[sh-while] while loop - -For sh and rc shells indentation commands are: -\\[smie-config-show-indent] Show the rules controlling this line's indentation. -\\[smie-config-set-indent] Change the rules controlling this line's indentation. -\\[smie-config-guess] Try to tweak the indentation rules so the -buffer indents as it currently is indented. - - -\\[backward-delete-char-untabify] Delete backward one position, even if it was a tab. -\\[sh-end-of-command] Go to end of successive commands. -\\[sh-beginning-of-command] Go to beginning of successive commands. -\\[sh-set-shell] Set this buffer's shell, and maybe its magic number. -\\[sh-execute-region] Have optional header and region be executed in a subshell. - -`sh-electric-here-document-mode' controls whether insertion of two -unquoted < insert a here document. You can control this behavior by -modifying `sh-mode-hook'. +(define-derived-mode sh-base-mode prog-mode "Shell-script" + "Generic major mode for editing shell scripts. -If you generally program a shell different from your login shell you can -set `sh-shell-file' accordingly. If your shell's file name doesn't correctly -indicate what shell it is use `sh-alias-alist' to translate. - -If your shell gives error messages with line numbers, you can use \\[executable-interpret] -with your script for an edit-interpret-debug cycle." +This is a generic major mode intended to be inherited by concrete +implementations. Currently there are two: `sh-mode' and +`bash-ts-mode'." (make-local-variable 'sh-shell-file) (make-local-variable 'sh-shell) @@ -1583,31 +1538,82 @@ sh-mode nil nil) (add-hook 'flymake-diagnostic-functions #'sh-shellcheck-flymake nil t) (add-hook 'hack-local-variables-hook - #'sh-after-hack-local-variables nil t) + #'sh-after-hack-local-variables nil t)) - (cond - ;; Tree-sitter. If the shell is bash, we can enable tree-sitter. - ((treesit-ready-p sh-shell) +;;;###autoload +(define-derived-mode sh-mode sh-base-mode "Shell-script" + "Major mode for editing shell scripts. +This mode works for many shells, since they all have roughly the same syntax, +as far as commands, arguments, variables, pipes, comments etc. are concerned. +Unless the file's magic number indicates the shell, your usual shell is +assumed. Since filenames rarely give a clue, they are not further analyzed. + +This mode adapts to the variations between shells (see `sh-set-shell') by +means of an inheritance based feature lookup (see `sh-feature'). This +mechanism applies to all variables (including skeletons) that pertain to +shell-specific features. Shell script files can use the `sh-shell' local +variable to indicate the shell variant to be used for the file. + +The default style of this mode is that of Rosenblatt's Korn shell book. +The syntax of the statements varies with the shell being used. The +following commands are available, based on the current shell's syntax: +\\ +\\[sh-case] case statement +\\[sh-for] for loop +\\[sh-function] function definition +\\[sh-if] if statement +\\[sh-indexed-loop] indexed loop from 1 to n +\\[sh-while-getopts] while getopts loop +\\[sh-repeat] repeat loop +\\[sh-select] select loop +\\[sh-until] until loop +\\[sh-while] while loop + +For sh and rc shells indentation commands are: +\\[smie-config-show-indent] Show the rules controlling this line's indentation. +\\[smie-config-set-indent] Change the rules controlling this line's indentation. +\\[smie-config-guess] Try to tweak the indentation rules so the +buffer indents as it currently is indented. + + +\\[backward-delete-char-untabify] Delete backward one position, even if it was a tab. +\\[sh-end-of-command] Go to end of successive commands. +\\[sh-beginning-of-command] Go to beginning of successive commands. +\\[sh-set-shell] Set this buffer's shell, and maybe its magic number. +\\[sh-execute-region] Have optional header and region be executed in a subshell. + +`sh-electric-here-document-mode' controls whether insertion of two +unquoted < insert a here document. You can control this behavior by +modifying `sh-mode-hook'. + +If you generally program a shell different from your login shell you can +set `sh-shell-file' accordingly. If your shell's file name doesn't correctly +indicate what shell it is use `sh-alias-alist' to translate. + +If your shell gives error messages with line numbers, you can use \\[executable-interpret] +with your script for an edit-interpret-debug cycle." + (setq font-lock-defaults + `((sh-font-lock-keywords + sh-font-lock-keywords-1 sh-font-lock-keywords-2) + nil nil + ((?/ . "w") (?~ . "w") (?. . "w") (?- . "w") (?_ . "w")) nil + (font-lock-syntactic-face-function + . ,#'sh-font-lock-syntactic-face-function)))) + +;;;###autoload +(defalias 'shell-script-mode 'sh-mode) + +;;;###autoload +(define-derived-mode bash-ts-mode sh-base-mode "Bash" + "Major mode for editing Bash shell scripts." + (when (treesit-ready-p 'bash) (setq-local treesit-font-lock-feature-list '((comment function string heredoc) (variable keyword command declaration-command) (constant operator builtin-variable))) (setq-local treesit-font-lock-settings sh-mode--treesit-settings) - (treesit-major-mode-setup)) - ;; Elisp. - (t - (setq font-lock-defaults - `((sh-font-lock-keywords - sh-font-lock-keywords-1 sh-font-lock-keywords-2) - nil nil - ((?/ . "w") (?~ . "w") (?. . "w") (?- . "w") (?_ . "w")) nil - (font-lock-syntactic-face-function - . ,#'sh-font-lock-syntactic-face-function)))))) - -;;;###autoload -(defalias 'shell-script-mode 'sh-mode) - + (treesit-major-mode-setup))) (defun sh-font-lock-keywords (&optional keywords) "Function to get simple fontification based on `sh-font-lock-keywords'. commit e494ca4f4dc0cf609b5ce444b44261b4b4b521f9 Author: Yuan Fu Date: Tue Nov 22 00:35:11 2022 -0800 Fix treesit_record_change in casify_region This fixes bug#59455. * src/casefiddle.c: Always record changes. diff --git a/src/casefiddle.c b/src/casefiddle.c index de2325ebf3..52dacf2702 100644 --- a/src/casefiddle.c +++ b/src/casefiddle.c @@ -557,10 +557,10 @@ casify_region (enum case_action flag, Lisp_Object b, Lisp_Object e) { signal_after_change (start, end - start - added, end - start); update_compositions (start, end, CHECK_ALL); + } #ifdef HAVE_TREE_SITTER - treesit_record_change (start_byte, old_end_byte, CHAR_TO_BYTE (end)); + treesit_record_change (start_byte, old_end_byte, CHAR_TO_BYTE (orig_end + added)); #endif - } return orig_end + added; } commit d6d4adf3bd8d2cfbc441095315dfc0bd3f5c1784 Author: Theodor Thornhill Date: Mon Nov 21 13:12:03 2022 +0100 Tweak faces in Java and TypeScript * lisp/progmodes/java-ts-mode.el (java-ts-mode--operators): Remove @ as an operator. (java-ts-mode--font-lock-settings): Use constant-face for @ to match rest of the annotation. Add bracket, delimiter and use some of the new faces. (java-ts-mode--imenu): Clean up the implementation a little. (java-ts-mode): Refer to the new features. * lisp/progmodes/ts-mode.el (ts-mode--font-lock-settings, ts-mode): Add in bracket and delimiter'. diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index ee8ac31f67..e78f1b4c6e 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -116,18 +116,14 @@ java-ts-mode--keywords "C keywords for tree-sitter font-locking.") (defvar java-ts-mode--operators - '("@" "+" ":" "++" "-" "--" "&" "&&" "|" "||" - "!=" "==" "*" "/" "%" "<" "<=" ">" ">=" "=" - "-=" "+=" "*=" "/=" "%=" "->" "^" "^=" "&=" - "|=" "~" ">>" ">>>" "<<" "::" "?") + '("+" ":" "++" "-" "--" "&" "&&" "|" "||" "=" + "!=" "==" "*" "/" "%" "<" "<=" ">" ">=" + "-=" "+=" "*=" "/=" "%=" "->" "^" "^=" + "|=" "~" ">>" ">>>" "<<" "::" "?" "&=") "C operators for tree-sitter font-locking.") (defvar java-ts-mode--font-lock-settings (treesit-font-lock-rules - :language 'java - :override t - :feature 'basic - '((identifier) @font-lock-variable-name-face) :language 'java :override t :feature 'comment @@ -149,7 +145,8 @@ java-ts-mode--font-lock-settings :language 'java :override t :feature 'operator - `([,@java-ts-mode--operators] @font-lock-builtin-face) + `([,@java-ts-mode--operators] @font-lock-operator-face + "@" @font-lock-constant-face) :language 'java :override t :feature 'annotation @@ -191,6 +188,8 @@ java-ts-mode--font-lock-settings (method_reference (identifier) @font-lock-type-face) + (scoped_identifier (identifier) @font-lock-variable-name-face) + ((scoped_identifier name: (identifier) @font-lock-type-face) (:match "^[A-Z]" @font-lock-type-face)) @@ -206,6 +205,12 @@ java-ts-mode--font-lock-settings `((method_declaration name: (identifier) @font-lock-function-name-face) + (variable_declarator + name: (identifier) @font-lock-variable-name-face) + + (element_value_pair + key: (identifier) @font-lock-property-face) + (formal_parameter name: (identifier) @font-lock-variable-name-face) @@ -220,7 +225,15 @@ java-ts-mode--font-lock-settings (method_invocation name: (identifier) @font-lock-function-name-face) - (argument_list (identifier) @font-lock-variable-name-face))) + (argument_list (identifier) @font-lock-variable-name-face)) + + :language 'java + :feature 'bracket + '((["(" ")" "[" "]" "{" "}"]) @font-lock-bracket-face) + + :language 'java + :feature 'delimiter + '((["," ":" ";"]) @font-lock-delimiter-face)) "Tree-sitter font-lock settings.") (defun java-ts-mode--imenu-1 (node) @@ -248,33 +261,27 @@ java-ts-mode--imenu-1 (defun java-ts-mode--imenu () "Return Imenu alist for the current buffer." (let* ((node (treesit-buffer-root-node)) - (class-tree - `("Class" . ,(java-ts-mode--imenu-1 - (treesit-induce-sparse-tree - node "^class_declaration$" nil 1000)))) - (interface-tree - `("Interface" . ,(java-ts-mode--imenu-1 - (treesit-induce-sparse-tree - node "^interface_declaration$" nil 1000)))) - (enum-tree - `("Enum" . ,(java-ts-mode--imenu-1 - (treesit-induce-sparse-tree - node "^enum_declaration$" nil 1000)))) - (record-tree - `("Record" . ,(java-ts-mode--imenu-1 - (treesit-induce-sparse-tree - node "^record_declaration$" nil 1000)))) - (method-tree - `("Method" . ,(java-ts-mode--imenu-1 - (treesit-induce-sparse-tree - node "^method_declaration$" nil 1000))))) - (cl-remove-if - #'null - `(,(when (cdr class-tree) class-tree) - ,(when (cdr interface-tree) interface-tree) - ,(when (cdr enum-tree) enum-tree) - ,(when (cdr record-tree) record-tree) - ,(when (cdr method-tree) method-tree))))) + (class-tree (treesit-induce-sparse-tree + node "^class_declaration$" nil 1000)) + (interface-tree (treesit-induce-sparse-tree + node "^interface_declaration$" nil 1000)) + (enum-tree (treesit-induce-sparse-tree + node "^enum_declaration$" nil 1000)) + (record-tree (treesit-induce-sparse-tree + node "^record_declaration$" nil 1000)) + (method-tree (treesit-induce-sparse-tree + node "^method_declaration$" nil 1000)) + (class-index (java-ts-mode--imenu-1 class-tree)) + (interface-index (java-ts-mode--imenu-1 interface-tree)) + (enum-index (java-ts-mode--imenu-1 enum-tree)) + (record-index (java-ts-mode--imenu-1 record-tree)) + (method-index (java-ts-mode--imenu-1 method-tree))) + (append + (when class-index `(("Class" . ,class-index))) + (when interface-index `(("Interface" . ,interface-index))) + (when enum-index `(("Enum" . ,enum-index))) + (when record-index `(("Record" . ,record-index))) + (when method-index `(("Method" . ,method-index)))))) ;;;###autoload (define-derived-mode java-ts-mode prog-mode "Java" @@ -307,9 +314,9 @@ java-ts-mode ;; Font-lock. (setq-local treesit-font-lock-settings java-ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list - '((basic comment keyword constant string operator) + '((comment keyword constant string) (type definition expression literal annotation) - ())) + (bracket delimiter operator))) ;; Imenu. (setq-local imenu-create-index-function #'java-ts-mode--imenu) diff --git a/lisp/progmodes/ts-mode.el b/lisp/progmodes/ts-mode.el index 01719a89ee..a91eba6501 100644 --- a/lisp/progmodes/ts-mode.el +++ b/lisp/progmodes/ts-mode.el @@ -210,18 +210,18 @@ ts-mode--font-lock-settings :language 'tsx :override t :feature 'property - `((pair key: (property_identifier) @font-lock-variable-name-face) + `((pair key: (property_identifier) @font-lock-property-face) (pair value: (identifier) @font-lock-variable-name-face) (pair - key: (property_identifier) @font-lock-function-name-face + key: (property_identifier) @font-lock-property-face value: [(function) (arrow_function)]) (property_signature - name: (property_identifier) @font-lock-variable-name-face) + name: (property_identifier) @font-lock-property-face) - ((shorthand_property_identifier) @font-lock-variable-name-face) + ((shorthand_property_identifier) @font-lock-property-face) ((shorthand_property_identifier_pattern) @font-lock-variable-name-face)) @@ -230,7 +230,7 @@ ts-mode--font-lock-settings :override t :feature 'pattern `((pair_pattern - key: (property_identifier) @font-lock-variable-name-face) + key: (property_identifier) @font-lock-property-face) (array_pattern (identifier) @font-lock-variable-name-face)) @@ -249,7 +249,14 @@ ts-mode--font-lock-settings [(nested_identifier (identifier)) (identifier)] @font-lock-function-name-face) - (jsx_attribute (property_identifier) @font-lock-constant-face))) + (jsx_attribute (property_identifier) @font-lock-constant-face)) + :language 'tsx + :feature 'bracket + '((["(" ")" "[" "]" "{" "}"]) @font-lock-bracket-face) + + :language 'tsx + :feature 'delimiter + '((["," ":" ";"]) @font-lock-delimiter-face)) "Tree-sitter font-lock settings.") ;;;###autoload @@ -297,7 +304,7 @@ ts-mode (setq-local treesit-font-lock-feature-list '((comment declaration) (string keyword identifier expression constant) - (property pattern jsx))) + (property pattern jsx bracket delimiter))) ;; Imenu. (setq-local imenu-create-index-function #'js--treesit-imenu) commit 6e078380512675aabd45ed752f60ebe424efd89d Author: Yuan Fu Date: Mon Nov 21 23:06:43 2022 -0800 treesit-font-lock-recompute-features now has two modes of operation 1. Set activation of each feature (changes every feature) 2. Add/remove features (only change those explicitly configured by ADD-LIST and REMOVE-LIST) This is useful for enabling/disabling certain features for all modes (without resetting others) by calling this function in prog-mode-hook * lisp/treesit.el (treesit-font-lock-recompute-features): See above description. diff --git a/lisp/treesit.el b/lisp/treesit.el index 015f780078..10c6b09322 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -694,16 +694,23 @@ treesit--font-lock-verbose "If non-nil, print debug messages when fontifying.") (defun treesit-font-lock-recompute-features (&optional add-list remove-list) - "Enable/disable font-lock settings according to decoration level. + "Enable/disable font-lock features. -First compute the enabled features according to -`treesit-font-lock-feature-list' and `font-lock-maximum-decoration', -then, if ADD-LIST or REMOVE-LIST are not omitted, further add and -remove features accordingly. +Enable each feature in ADD-LIST, disable each feature in +REMOVE-LIST. + +If both ADD-LIST and REMOVE-LIST are omitted, recompute each +feature according to `treesit-font-lock-feature-list' and +`font-lock-maximum-decoration'. Let N be the value of +`font-lock-maximum-decoration', features in the first Nth sublist +of `treesit-font-lock-feature-list' are enabled, and the rest +features are disabled. If `font-lock-maximum-decoration' is t, +all features in `treesit-font-lock-feature-list' are enabled, and +the rest are disabled. ADD-LIST and REMOVE-LIST are each a list of feature symbols. The same feature symbol cannot appear in both lists; the function -signals the `treesit-font-lock-error' error if so." +signals the `treesit-font-lock-error' error if that happens." (when-let ((intersection (cl-intersection add-list remove-list))) (signal 'treesit-font-lock-error (list "ADD-LIST and REMOVE-LIST contain the same feature" @@ -717,13 +724,23 @@ treesit-font-lock-recompute-features (>= level (1+ idx))) append features)) (features (cl-set-difference (cl-union base-features add-list) - remove-list))) + remove-list)) + ;; If additive non-nil, we are configuring on top of the + ;; existing configuration, if nil, we are resetting + ;; everything according to `treesit-font-lock-feature-list'. + (additive (or add-list remove-list))) (cl-loop for idx = 0 then (1+ idx) for setting in treesit-font-lock-settings for feature = (nth 2 setting) + for current-value = (nth 1 setting) ;; Set the ENABLE flag for the setting. do (setf (nth 1 (nth idx treesit-font-lock-settings)) - (if (memq feature features) t nil))))) + (cond + ((not additive) + (if (memq feature features) t nil)) + ((memq feature add-list) t) + ((memq feature remove-list) nil) + (t current-value)))))) (defun treesit-fontify-with-override (start end face override) "Apply FACE to the region between START and END. commit cb60342c0184fa8ef9462c9926e93dceff959f49 Author: Yuan Fu Date: Mon Nov 21 22:37:36 2022 -0800 Tweak c-ts-mode fontification New features: function and variable, which consistently fontify all occurrences of functions and variables, respectively. Remove expression feature, as its purpose is fulfilled by function, variable, and property combined. Fix declaration feature, remove unnecessary rule from label feature. * lisp/progmodes/c-ts-mode.el (c-ts-mode--font-lock-settings): See above description. (c-ts-mode--fontify-variable): New function. (c-ts-mode--base-mode): Add & remove features. diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 6eaf200182..3555eb23d1 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -269,7 +269,7 @@ c-ts-mode--font-lock-settings :feature 'definition ;; Highlights identifiers in declarations. `((declaration - declarator: (_) @font-lock-variable-name-face) + declarator: (_) @c-ts-mode--fontify-declarator) (field_declaration declarator: (_) @c-ts-mode--fontify-declarator) @@ -295,21 +295,21 @@ c-ts-mode--font-lock-settings (identifier) @font-lock-variable-name-face)) (assignment_expression left: (subscript_expression - (identifier) @font-lock-variable-name-face))) + (identifier) @font-lock-variable-name-face)) + (init_declarator declarator: (_) @c-ts-mode--fontify-declarator)) :language mode - :feature 'expression + :feature 'function '((call_expression - function: (identifier) @font-lock-function-name-face) - (field_expression - argument: (identifier) @font-lock-variable-name-face) - (pointer_expression - (identifier) @font-lock-variable-name-face)) + function: (identifier) @font-lock-function-name-face)) + + :language mode + :feature 'variable + '((identifier) @c-ts-mode--fontify-variable) :language mode :feature 'label - '((expression_statement (identifier) @font-lock-variable-name-face) - (labeled_statement + '((labeled_statement label: (statement_identifier) @font-lock-constant-face)) :language mode @@ -367,6 +367,19 @@ c-ts-mode--fontify-declarator (_ 'font-lock-variable-name-face)) override)))) +(defun c-ts-mode--fontify-variable (node override start end &rest _) + "Fontify an identifier node. +Fontify it if NODE is not a function identifier. For NODE, +OVERRIDE, START, END, and ARGS, see `treesit-font-lock-rules'." + (when (not (equal (treesit-node-type + (treesit-node-parent node)) + "call_expression")) + (treesit-fontify-with-override + (max (treesit-node-start node) start) + (min (treesit-node-end node) end) + 'font-lock-variable-name-face + override))) + (defun c-ts-mode--fontify-defun (node override start end &rest _) "Correctly fontify the DEFUN macro. For NODE, OVERRIDE, START, and END, see @@ -497,8 +510,8 @@ c-ts-mode--base-mode (setq-local treesit-font-lock-feature-list '(( comment constant keyword literal preprocessor string) ( assignment definition label property type) - ( bracket delimiter error escape-sequence expression - operator)))) + ( delimiter error escape-sequence function + operator variable bracket)))) ;;;###autoload (define-derived-mode c-ts-mode c-ts-mode--base-mode "C" commit c7202e7f4aedee607f26727de52b85819bf64dab Author: Yuan Fu Date: Mon Nov 21 22:33:10 2022 -0800 ; Fix docstrings in treesit.el * lisp/treesit.el (treesit--explorer--nodes-to-highlight) (treesit--explorer-draw-node): Fix docstrings. diff --git a/lisp/treesit.el b/lisp/treesit.el index 24387c287a..015f780078 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1765,10 +1765,11 @@ treesit-explore-mode (defun treesit--explorer--nodes-to-highlight (language) "Return nodes for LANGUAGE covered in region. -This function tries to return the largest node possible. So it -will return a single large node rather than a bunch of small -nodes. If it end up returning multiple small nodes, it only -returns the first and last node, and omits the ones in between." +This function tries to return the largest node possible. If the +region covers exactly one node, that node is returned (in a +list). If the region covers more than one node, two nodes are +returned: the very first one in the region and the very last one +in the region." (let* ((beg (region-beginning)) (end (region-end)) (node (treesit-node-on beg end language)) @@ -1887,13 +1888,10 @@ treesit--explorer-highlight-node (defun treesit--explorer-draw-node (node) "Draw the syntax tree of NODE. -If NODE and NODE-HIGHLIGHT are the same node, highlight it. -When this function is called, point should be at an empty line, -when appropriate indent in front of point. When this function -returns, it leaves point at the end of the last line of NODE. - -Return the start position of NODE-HIGHLIGHT in the buffer, if any." +When this function is called, point should be at the position +where the node should start. When this function returns, it +leaves point at the end of the last line of NODE." (let* ((type (treesit-node-type node)) (field-name (treesit-node-field-name node)) (children (treesit-node-children node)) commit 74892eefc8dd5b442a1859c7d28422778b79ce3c Author: Yuan Fu Date: Mon Nov 21 22:32:51 2022 -0800 * lisp/treesit.el (treesit-max-buffer-size): Enlarge value. diff --git a/lisp/treesit.el b/lisp/treesit.el index 0dcd16d89a..24387c287a 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -95,7 +95,12 @@ treesit :group 'tools :version "29.1") -(defcustom treesit-max-buffer-size (* 4 1024 1024) +(defcustom treesit-max-buffer-size + (let ((mb (* 1024 1024))) + ;; 40MB for 64-bit systems, 15 for 32-bit. + (if (> most-positive-fixnum (* 4 1024 mb)) + (* 40 mb) + (* 15 mb))) "Maximum buffer size for enabling tree-sitter parsing (in bytes)." :type 'integer :version "29.1")