diff --git a/admin/notes/tree-sitter/treesit_record_change b/admin/notes/tree-sitter/treesit_record_change new file mode 100644 index 00000000000..bb0f9edc353 --- /dev/null +++ b/admin/notes/tree-sitter/treesit_record_change @@ -0,0 +1,50 @@ +NOTES ON TREESIT_RECORD_CHANGE + +It is vital that Emacs informs tree-sitter of every change made to the +buffer, lest tree-sitter's parse tree would be corrupted/out of sync. + +All buffer changes in Emacs are made through functions in insdel.c +(and casefiddle.c), I augmented functions in those files with calls to +treesit_record_change. Below is a manifest of all the relavent +functions in insdel.c as of Emacs 29: + +Function Calls +---------------------------------------------------------------------- +copy_text (*1) +insert insert_1_both +insert_and_inherit insert_1_both +insert_char insert +insert_string insert +insert_before_markers insert_1_both +insert_before_markers_and_inherit insert_1_both +insert_1_both treesit_record_change +insert_from_string insert_from_string_1 +insert_from_string_before_markers insert_from_string_1 +insert_from_string_1 treesit_record_change +insert_from_gap_1 treesit_record_change +insert_from_gap insert_from_gap_1 +insert_from_buffer treesit_record_change +insert_from_buffer_1 (used by insert_from_buffer) (*2) +replace_range treesit_record_change +replace_range_2 (caller needs to call treesit_r_c) +del_range del_range_1 +del_range_1 del_range_2 +del_range_byte del_range_2 +del_range_both del_range_2 +del_range_2 treesit_record_change + +(*1) This functions is used only to copy from string to string when +used outside of insdel.c, and when used inside insdel.c, the caller +calls treesit_record_change. + +(*2) This function is a static function, and insert_from_buffer is its +only caller. So it should be fine to call treesit_record_change in +insert_from_buffer but not insert_from_buffer_1. I also left a +reminder comment. + + +As for casefiddle.c, do_casify_unibyte_region and +do_casify_multibyte_region modifies buffer, but they are static +functions and are called by casify_region, which calls +treesit_record_change. Other higher-level functions calls +casify_region to do the work. \ No newline at end of file diff --git a/doc/emacs/basic.texi b/doc/emacs/basic.texi index d8a354ff42d..a271cb65bdc 100644 --- a/doc/emacs/basic.texi +++ b/doc/emacs/basic.texi @@ -890,17 +890,37 @@ subsequent @kbd{z} repeats it once again. @findex describe-repeat-maps @vindex repeat-exit-key @vindex repeat-exit-timeout - Also you can activate @code{repeat-mode} that temporarily enables a -transient mode with short keys after a limited number of commands. -Currently supported shorter key sequences are @kbd{C-x u u} instead of -@kbd{C-x u C-x u} to undo many changes, @kbd{C-x o o} instead of -@kbd{C-x o C-x o} to switch several windows, @kbd{C-x @{ @{ @} @} ^ ^ -v v} to resize the selected window interactively, @kbd{M-g n n p p} to -navigate @code{next-error} matches, @kbd{C-x ] ] [ [} to navigate -through pages, and other keys listed by @code{describe-repeat-maps}. -Any other key exits transient mode and then is executed normally. The -user option @code{repeat-exit-key} defines an additional key to exit -this transient mode. Also it's possible to break the repetition chain -automatically after some idle time by customizing the user option + You can also activate @code{repeat-mode} which allows repeating +commands bound to sequences of two or more keys by typing a single +character. For example, after typing @w{@kbd{C-x u}} (@code{undo}, +@pxref{Undo}) to undo the most recent edits, you can undo many more +edits by typing @w{@kbd{u u u@dots{}}}. Similarly, type @w{@kbd{C-x o +o o@dots{}}} instead of @w{@kbd{C-x o C-x o C-x o@dots{}}} to switch +to the window several windows away. This works by entering a +transient repeating mode after you type the full key sequence that +invokes the command; the single-key shortcuts are shown in the echo +area. + +Only some commands support repetition in @code{repeat-mode}; type +@w{@kbd{M-x describe-repeat-maps @key{RET}}} to see which ones. + +The single-character shortcuts enabled by the transient repeating mode +do not need to be identical: for example, after typing @w{@kbd{C-x +@{}}, either @kbd{@{} or @kbd{@}} or @kbd{^} or @kbd{v}, or any series +that mixes these characters in any order, will resize the selected +window in respective ways. Similarly, after @w{@kbd{M-g n}} or +@kbd{M-g p}, typing any sequence of @kbd{n} and/or @kbd{p} in any mix +will repeat @code{next-error} and @code{previous-error} to navigate in +a @file{*compilation*} or @file{*grep*} buffer (@pxref{Compilation +Mode}). + +Typing any key other than those defined to repeat the previous command +exits the transient repeating mode, and then the key you typed is +executed normally. You can also define a key which will exit the +transient repeating mode @emph{without} executing the key which caused +the exit. To this end, customize the user option +@code{repeat-exit-key} to name a key; one natural value is @key{RET}. +Finally, it's possible to break the repetition chain automatically +after some amount of idle time: customize the user option @code{repeat-exit-timeout} to specify the idle time in seconds after -which this transient mode will be turned off. +which this transient repetition mode will be turned off automatically. diff --git a/doc/emacs/building.texi b/doc/emacs/building.texi index 98f67ddd9d9..3f6a418de1a 100644 --- a/doc/emacs/building.texi +++ b/doc/emacs/building.texi @@ -961,9 +961,7 @@ the fringe of a source buffer to set a breakpoint there. @vindex gud-gdb-command-name To run GDB using just the GUD interaction buffer interface, without these additional features, use @kbd{M-x gud-gdb} (@pxref{Starting -GUD}). You must use this if you want to debug multiple programs -within one Emacs session, as that is currently unsupported by @kbd{M-x -gdb}. +GUD}). Internally, @kbd{M-x gdb} informs GDB that its screen size is unlimited; for correct operation, you must not change GDB's screen @@ -1051,9 +1049,9 @@ to restore only when @code{gdb-show-main} is non-@code{nil}. You may also specify additional GDB-related buffers to display, either in the same frame or a different one. Select the buffers you want by typing @kbd{M-x gdb-display-@var{buffertype}-buffer} or -@kbd{M-x gdb-frame-@var{buffertype}-buffer}, where @var{buffertype} -is the relevant buffer type, such as @samp{breakpoints}. You can do -the same with the menu bar, with the @samp{GDB-Windows} and +@kbd{M-x gdb-frame-@var{buffertype}-buffer}, where @var{buffertype} is +the relevant buffer type, such as @samp{breakpoints} or @samp{io}. +You can do the same from the menu bar, with the @samp{GDB-Windows} and @samp{GDB-Frames} sub-menus of the @samp{GUD} menu. @vindex gdb-max-source-window-count @@ -1273,10 +1271,14 @@ non-@code{nil} value. @node Other GDB Buffers @subsubsection Other GDB Buffers +Other buffers provided by @kbd{M-x gdb} whose display you can +optionally request include: + @table @asis +@findex gdb-display-locals-buffer @item Locals Buffer This buffer displays the values of local variables of the current -frame for simple data types (@pxref{Frame Info, Frame Info, +stack frame for simple data types (@pxref{Frame Info, Frame Info, Information on a frame, gdb, The GNU debugger}). Press @key{RET} or click @kbd{mouse-2} on the value if you want to edit it. @@ -1286,20 +1288,35 @@ you can examine the value of the local variable at point by typing GDB, use @key{RET} or @kbd{mouse-2} on the type description (@samp{[struct/union]} or @samp{[array]}). @xref{Watch Expressions}. -@item Registers Buffer -@findex toggle-gdb-all-registers -This buffer displays the values held by the registers -(@pxref{Registers,,, gdb, The GNU debugger}). Press @key{RET} or -click @kbd{mouse-2} on a register if you want to edit its value. With -GDB 6.4 or later, recently changed register values display with -@code{font-lock-warning-face}. +To display the Locals buffer, type @kbd{M-x gdb-display-locals-buffer}. +@findex gdb-display-io-buffer +@item I/O Buffer +If the program you are debugging uses standard input and output +streams for interaction with the user, or emits a significant amount +of output to its standard output, you may wish to separate its I/O +from interaction with GDB. Use the command @w{@kbd{M-x +gdb-display-io-buffer}} to show a window with a buffer to which Emacs +redirects the input and output from the program you are debugging. + +@findex gdb-display-registers-buffer +@item Registers Buffer +This buffer displays the values held by the registers +(@pxref{Registers,,, gdb, The GNU debugger}). Request the display of +this buffer with the command @kbd{M-x gdb-display-registers-buffer}. +Press @key{RET} or click @kbd{mouse-2} on a register if you want to +edit its value. With GDB 6.4 or later, recently changed register +values display with @code{font-lock-warning-face}. + +@findex gdb-display-disassembly-buffer @item Assembler Buffer The assembler buffer displays the current frame as machine code. An arrow points to the current instruction, and you can set and remove breakpoints as in a source buffer. Breakpoint icons also appear in -the fringe or margin. +the fringe or margin. To request the display of this buffer, use +@kbd{M-x gdb-display-disassembly-buffer}. +@findex gdb-display-memory-buffer @item Memory Buffer The memory buffer lets you examine sections of program memory (@pxref{Memory, Memory, Examining memory, gdb, The GNU debugger}). @@ -1307,7 +1324,8 @@ Click @kbd{mouse-1} on the appropriate part of the header line to change the starting address or number of data items that the buffer displays. Alternatively, use @kbd{S} or @kbd{N} respectively. Click @kbd{mouse-3} on the header line to select the display format or unit -size for these data items. +size for these data items. Use @w{@kbd{M-x +gdb-display-memory-buffer}} to request display of this buffer. @end table When @code{gdb-many-windows} is non-@code{nil}, the locals buffer diff --git a/etc/NEWS.29 b/etc/NEWS.29 index fb211f9b7d0..e3cbeb84d30 100644 --- a/etc/NEWS.29 +++ b/etc/NEWS.29 @@ -563,6 +563,20 @@ The variable 'font-lock-support-mode' is occasionally useful for debugging purposes. It is now a regular variable (instead of a user option) and can be set to nil to disable Just-in-time Lock mode. ++++ +** The 'utf-8-auto' coding-system now produces BOM on encoding. +This is actually a bugfix, since this is how 'utf-8-auto' was +documented from day one; it just didn't behave according to +documentation. It turns out some Lisp programs were using this +coding-system on the wrong assumption that the "auto" part means some +automagic handling of the end-of-line (EOL) format conversion; those +program will now start to fail, because BOM signature in UTF-8 encoded +text is rarely expected. That is the reason we mention this bugfix +here. + +In general, this coding-system should probably never be used for +encoding, only for decoding. + * Changes in Emacs 29.1 @@ -1339,6 +1353,18 @@ dragged. Customize this option to limit the number of entries in the menu "Edit → Paste from Kill Menu". The default is 60. +--- +** New user option 'copy-region-blink-predicate'. +By default, when copying a region with 'kill-ring-save', Emacs only +blinks point and mark when the region is not denoted visually, that +is, when either the region is inactive, or the 'region' face is +indistinguishable from the 'default' face. + +Users who would rather enable blinking unconditionally can now set +this user option to 'always'. To disable blinking unconditionally, +either set this option to 'ignore', or set 'copy-region-blink-delay' +to 0. + +++ ** Performing a pinch gesture on a touchpad now increases the text scale. diff --git a/lisp/bindings.el b/lisp/bindings.el index 99189d2e570..c77b64c05da 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el @@ -1011,7 +1011,7 @@ if `inhibit-field-text-motion' is non-nil." ;; no idea whereas to bind it. Any suggestion welcome. -stef ;; (define-key ctl-x-map "U" 'undo-only) (defvar-keymap undo-repeat-map - :doc "Keymap to repeat undo key sequences \\`C-x u u'. Used in `repeat-mode'." + :doc "Keymap to repeat `undo' commands. Used in `repeat-mode'." :repeat t "u" #'undo) @@ -1108,7 +1108,7 @@ if `inhibit-field-text-motion' is non-nil." (define-key ctl-x-map "`" 'next-error) (defvar-keymap next-error-repeat-map - :doc "Keymap to repeat `next-error' key sequences. Used in `repeat-mode'." + :doc "Keymap to repeat `next-error' and `previous-error'. Used in `repeat-mode'." :repeat t "n" #'next-error "M-n" #'next-error @@ -1470,7 +1470,7 @@ if `inhibit-field-text-motion' is non-nil." (define-key ctl-x-map "]" 'forward-page) (defvar-keymap page-navigation-repeat-map - :doc "Keymap to repeat page navigation key sequences. Used in `repeat-mode'." + :doc "Keymap to repeat `forward-page' and `backward-page'. Used in `repeat-mode'." :repeat t "]" #'forward-page "[" #'backward-page) diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index bacc105a214..367f59e8785 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -182,6 +182,7 @@ to a package-local -loaddefs.el file.") ;; CL (put 'defconstant 'doc-string-elt 3) (put 'defparameter 'doc-string-elt 3) +(put 'defstruct 'doc-string-elt 2) (defvar lisp-doc-string-elt-property 'doc-string-elt "The symbol property that holds the docstring position info.") diff --git a/lisp/faces.el b/lisp/faces.el index 3323eab205a..4933b495a6c 100644 --- a/lisp/faces.el +++ b/lisp/faces.el @@ -304,7 +304,16 @@ If the optional argument FRAME is given, report on face FACE in that frame. If FRAME is t, report on the defaults for face FACE (for new frames). If FRAME is omitted or nil, use the selected frame." (let ((attrs - (delq :inherit (mapcar 'car face-attribute-name-alist))) + ;; The _value_ of :inherit teaches us nothing about how FACE + ;; looks compared to the default face. Instead, we will ask + ;; `face-attribute' to take inheritance into account when + ;; examining other attributes. + (delq :inherit + ;; A difference in extension past EOL only matters when + ;; relevant attributes (such as :background) also + ;; differ from the default; otherwise this difference + ;; is a false positive. + (delq :extend (mapcar 'car face-attribute-name-alist)))) (differs nil)) (while (and attrs (not differs)) (let* ((attr (pop attrs)) diff --git a/lisp/keymap.el b/lisp/keymap.el index de90b03ba64..201a49cef8c 100644 --- a/lisp/keymap.el +++ b/lisp/keymap.el @@ -290,26 +290,26 @@ See `kbd' for a descripion of KEYS." res))) (defun key-valid-p (keys) - "Say whether KEYS is a valid key. -A key is a string consisting of one or more key strokes. -The key strokes are separated by single space characters. + "Return non-nil if KEYS, a string, is a valid key sequence. +KEYS should be a string consisting of one or more key strokes, +with a single space character separating one key stroke from another. Each key stroke is either a single character, or the name of an -event, surrounded by angle brackets. In addition, any key stroke -may be preceded by one or more modifier keys. Finally, a limited -number of characters have a special shorthand syntax. +event, surrounded by angle brackets . In addition, any +key stroke may be preceded by one or more modifier keys. Finally, +a limited number of characters have a special shorthand syntax. -Here's some example key sequences. +Here are some example of valid key sequences. \"f\" (the key `f') - \"S o m\" (a three key sequence of the keys `S', `o' and `m') - \"C-c o\" (a two key sequence of the keys `c' with the control modifier - and then the key `o') - \"H-\" (the key named \"left\" with the hyper modifier) + \"S o m\" (a three-key sequence of the keys `S', `o' and `m') + \"C-c o\" (a two-key sequence: the key `c' with the control modifier + followed by the key `o') + \"H-\" (the function key named \"left\" with the hyper modifier) \"M-RET\" (the \"return\" key with a meta modifier) \"C-M-\" (the \"space\" key with both the control and meta modifiers) -These are the characters that have shorthand syntax: +These are the characters that have special shorthand syntax: NUL, RET, TAB, LFD, ESC, SPC, DEL. Modifiers have to be specified in this order: @@ -358,7 +358,7 @@ which is This function creates a `keyboard-translate-table' if necessary and then modifies one entry in it. -Both KEY and TO are strings that satisfy `key-valid-p'." +Both KEY and TO should be specified by strings that satisfy `key-valid-p'." (declare (compiler-macro (lambda (form) (keymap--compile-check from to) form))) (keymap--check from) @@ -369,7 +369,7 @@ Both KEY and TO are strings that satisfy `key-valid-p'." (aset keyboard-translate-table (key-parse from) (key-parse to))) (defun keymap-lookup (keymap key &optional accept-default no-remap position) - "Return the binding for command KEY. + "Return the binding for command KEY in KEYMAP. KEY is a string that satisfies `key-valid-p'. If KEYMAP is nil, look up in the current keymaps. If non-nil, it @@ -391,15 +391,15 @@ in the current keymaps. However, if the optional third argument NO-REMAP is non-nil, `keymap-lookup' returns the unmapped command. -If KEY is a key sequence initiated with the mouse, the used keymaps -will depend on the clicked mouse position with regard to the buffer -and possible local keymaps on strings. +If KEY is a mouse gesture, the keymaps used depend on the clicked +mouse position with regards to the buffer, and local keymaps, if any, +on display and overlay strings. If the optional argument POSITION is non-nil, it specifies a mouse position as returned by `event-start' and `event-end', and the lookup occurs in the keymaps associated with it instead of KEY. It can also be a number or marker, in which case the keymap properties at the -specified buffer position instead of point are used." +specified buffer position are used instead of point." (declare (compiler-macro (lambda (form) (keymap--compile-check key) form))) (keymap--check key) (when (and keymap position) @@ -475,7 +475,7 @@ If MESSAGE (and interactively), message the result." (defun define-keymap (&rest definitions) "Create a new keymap and define KEY/DEFINITION pairs as key bindings. -The new keymap is returned. +Return the new keymap. Options can be given as keywords before the KEY/DEFINITION pairs. Available keywords are: diff --git a/lisp/progmodes/c-ts-common.el b/lisp/progmodes/c-ts-common.el index c13b01aae5c..8729cae4ba7 100644 --- a/lisp/progmodes/c-ts-common.el +++ b/lisp/progmodes/c-ts-common.el @@ -194,7 +194,8 @@ comment." (when end-marker (goto-char end-marker) (delete-region (point) (+ end-len (point))) - (insert (make-string end-len ?\s)))))) + (insert (make-string end-len ?\s))) + (goto-char orig-point)))) (defun c-ts-common-comment-setup () "Set up local variables for C-like comment. @@ -280,7 +281,7 @@ special handling from our bracket-counting indent algorithm. This can be nil, meaning such special handling is not needed.") -(defun c-ts-common-statement-offset (node parent &rest _) +(defun c-ts-common-statement-offset (node parent bol &rest _) "This anchor is used for children of a statement inside a block. This function basically counts the number of block nodes (i.e., @@ -292,18 +293,21 @@ To support GNU style, on each block level, this function also checks whether the opening bracket { is on its own line, if so, it adds an extra level, except for the top-level. -PARENT is NODE's parent." +PARENT is NODE's parent, BOL is the beginning of non-whitespace +characters on the current line." (let ((level 0)) + ;; If NODE is a opening/closing bracket on its own line, take off + ;; one level because the code below assumes NODE is a statement + ;; _inside_ a {} block. + (when (and node + (or (string-match-p c-ts-common-indent-block-type-regexp + (treesit-node-type node)) + (save-excursion (goto-char bol) (looking-at-p "}")))) + (cl-decf level)) ;; If point is on an empty line, NODE would be nil, but we pretend ;; there is a statement node. (when (null node) (setq node t)) - ;; If NODE is a opening bracket on its own line, take off one - ;; level because the code below assumes NODE is a statement - ;; _inside_ a {} block. - (when (string-match-p c-ts-common-indent-block-type-regexp - (treesit-node-type node)) - (cl-decf level)) ;; Go up the tree and compute indent level. (while (if (eq node t) (setq node parent) @@ -321,9 +325,9 @@ PARENT is NODE's parent." (treesit-node-parent node)))) ;; Case (2). (and parent-type - (or (string-match-p - c-ts-common-indent-block-type-regexp - parent-type)))) + (string-match-p + c-ts-common-indent-block-type-regexp + parent-type))) nil) ;; Add a level. ((looking-back (rx bol (* whitespace)) @@ -350,13 +354,6 @@ the bracket in the body." (1+ level) level))) -(defun c-ts-mode--close-bracket-offset (node parent &rest _) - "Offset for the closing bracket, NODE. -It's basically one level less that the statements in the block. -PARENT is NODE's parent." - (- (c-ts-common-statement-offset node parent) - (symbol-value c-ts-common-indent-offset))) - (provide 'c-ts-common) ;;; c-ts-common.el ends here diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 884fe6c3f15..586849e9a3d 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -100,12 +100,11 @@ the value of SYM in `c-ts-mode' and `c++-ts-mode' buffers to VAL." (setq-local treesit-simple-indent-rules (treesit--indent-rules-optimize (c-ts-mode--get-indent-style - (if (eq major-mode 'c-ts-mode) 'c 'cpp)))))) + (if (derived-mode-p 'c-ts-mode) 'c 'cpp)))))) res) (let ((buffer (car buffers))) (with-current-buffer buffer - ;; FIXME: Should we use `derived-mode-p' here? - (if (or (eq major-mode 'c-ts-mode) (eq major-mode 'c++-ts-mode)) + (if (derived-mode-p 'c-ts-mode 'c++-ts-mode) (loop (append res (list buffer)) (cdr buffers)) (loop res (cdr buffers)))))))) @@ -134,24 +133,33 @@ MODE is either `c' or `cpp'." (alist-get c-ts-mode-indent-style (c-ts-mode--indent-styles mode))))) `((,mode ,@style)))) -(defun c-ts-mode-set-style () - "Set the indent style of C/C++ modes globally. +(defun c-ts-mode--prompt-for-style () + "Prompt for a indent style and return the symbol for it." + (let ((mode (if (derived-mode-p 'c-ts-mode) 'c 'c++))) + (intern + (completing-read + "Style: " + (mapcar #'car (c-ts-mode--indent-styles mode)) + nil t nil nil "gnu")))) + +(defun c-ts-mode-set-style (style) + "Set the indent style of C/C++ modes globally to STYLE. This changes the current indent style of every C/C++ buffer and the default C/C++ indent style in this Emacs session." - (interactive) - ;; FIXME: Should we use `derived-mode-p' here? - (or (eq major-mode 'c-ts-mode) (eq major-mode 'c++-ts-mode) - (error "Buffer %s is not a c-ts-mode (c-ts-mode-set-style)" - (buffer-name))) - (c-ts-mode--indent-style-setter - 'c-ts-mode-indent-style - ;; NOTE: We can probably use the interactive form for this. - (intern - (completing-read - "Select style: " - (mapcar #'car (c-ts-mode--indent-styles (if (eq major-mode 'c-ts-mode) 'c 'cpp))) - nil t nil nil "gnu")))) + (interactive (list (c-ts-mode--prompt-for-style))) + (c-ts-mode--indent-style-setter 'c-ts-mode-indent-style style)) + +(defun c-ts-mode-set-local-style (style) + "Set the C/C++ indent style of the current buffer to STYLE." + (interactive (list (c-ts-mode--prompt-for-style))) + (if (not (derived-mode-p 'c-ts-mode 'c++-ts-mode)) + (user-error "The current buffer is not in `c-ts-mode' nor `c++-ts-mode'") + (setq-local c-ts-mode-indent-style style) + (setq treesit-simple-indent-rules + (treesit--indent-rules-optimize + (c-ts-mode--get-indent-style + (if (derived-mode-p 'c-ts-mode) 'c 'cpp)))))) ;;; Syntax table @@ -254,12 +262,16 @@ MODE is either `c' or `cpp'." ;; int[5] a = { 0, 0, 0, 0 }; ((parent-is "initializer_list") parent-bol c-ts-mode-indent-offset) + ;; Statement in enum. ((parent-is "enumerator_list") point-min c-ts-common-statement-offset) + ;; Statement in struct and union. ((parent-is "field_declaration_list") point-min c-ts-common-statement-offset) - ;; {} blocks. - ((node-is "}") point-min c-ts-mode--close-bracket-offset) + ;; Statement in {} blocks. ((parent-is "compound_statement") point-min c-ts-common-statement-offset) + ;; Closing bracket. + ((node-is "}") point-min c-ts-common-statement-offset) + ;; Opening bracket. ((node-is "compound_statement") point-min c-ts-common-statement-offset) ,@(when (eq mode 'cpp) @@ -824,6 +836,8 @@ in your configuration." (c-ts-mode--get-indent-style 'c)) ;; Font-lock. (setq-local treesit-font-lock-settings (c-ts-mode--font-lock-settings 'c)) + ;; Navigation. + (setq-local treesit-defun-tactic 'top-level) (treesit-major-mode-setup))) ;;;###autoload diff --git a/lisp/progmodes/hideshow.el b/lisp/progmodes/hideshow.el index c160e6ad1df..b878986d7a4 100644 --- a/lisp/progmodes/hideshow.el +++ b/lisp/progmodes/hideshow.el @@ -256,10 +256,14 @@ This has effect only if `search-invisible' is set to `open'." (defvar hs-special-modes-alist (mapcar #'purecopy '((c-mode "{" "}" "/[*/]" nil nil) + (c-ts-mode "{" "}" "/[*/]" nil nil) (c++-mode "{" "}" "/[*/]" nil nil) + (c++-ts-mode "{" "}" "/[*/]" nil nil) (bibtex-mode ("@\\S(*\\(\\s(\\)" 1)) (java-mode "{" "}" "/[*/]" nil nil) + (java-ts-mode "{" "}" "/[*/]" nil nil) (js-mode "{" "}" "/[*/]" nil) + (js-ts-mode "{" "}" "/[*/]" nil) (mhtml-mode "{\\|<[^/>]*?" "}\\|]*[^/]>" "