Commit graph

32 commits

Author SHA1 Message Date
Yuan Fu
3101c5031e
Fix undefined variable in previous commit (bug#73900)
I somehow thought allow-auto-fill is a global variable that's
used by cc.  But it's not.  It's just a function param used by
c-indent-new-comment-line.

* lisp/progmodes/c-ts-common.el:
(c-ts-common-comment-indent-new-line): Remove reference to
allow-auto-fill.
2024-10-30 18:18:50 -07:00
Yuan Fu
e6a8492fab
Fix c-ts-common-comment-indent-new-line (bug#73900)
* lisp/progmodes/c-ts-common.el:
(c-ts-common-comment-indent-new-line): Delete trailing
whitespace before inserting newline.  The insert-line-break
function is the same as in c-indent-new-comment-line.
2024-10-30 18:18:06 -07:00
Yuan Fu
cd9a215ef0
; Minor fix in c-ts-common--fill-block-comment
* lisp/progmodes/c-ts-common.el:
(c-ts-common--fill-block-comment): Checking for end-mask done is
equivalent to checking end-marker, so the original code doesn't have a
bug.
2024-08-06 22:00:01 -07:00
Damien Cassou
292fcd2009
Fix c-ts-common filling function (bug#71760)
* lisp/progmodes/c-ts-common.el (c-ts-common--fill-block-comment): If
masking hasn't been done, don't unmask.
2024-08-03 20:03:32 -07:00
Paul Eggert
3dcac22dd4 Spelling fixes 2024-06-04 22:16:28 -07:00
Vincenzo Pupillo
1ea398e8f1
Make comment-indent-new-line conform better to CC Mode (bug#71225)
* lisp/progmodes/c-ts-common.el: (c-ts-common-comment-indent-new-line):
Single line comment and block comment now behave more like the
c-indent-new-comment-line.
2024-06-02 10:08:05 +02:00
Yuan Fu
53333132e4
Fix c-ts-common--fill-paragraph for C
This should fix the failing filling test for c-ts-mode.

* lisp/progmodes/c-ts-common.el (c-ts-common--fill-paragraph): Don't
go back to indentation.
2024-04-26 19:56:26 -07:00
Yuan Fu
c8c319e0b0
Make c-ts-common-comment-indent-new-line work for rust doc comment
* lisp/progmodes/c-ts-common.el (c-ts-common-comment-indent-new-line):
Support //! comment directives.
2024-04-23 22:55:36 -07:00
Yuan Fu
67ef1d54e7
Make c-ts-common--fill-paragraph work for rust line comment
* lisp/progmodes/c-ts-common.el (c-ts-common--fill-paragraph): Back to
BOL before checking for //.
2024-04-23 22:55:36 -07:00
Yuan Fu
6ae835c924
; Add some comments to c-ts-common-comment-indent-new-line
* lisp/progmodes/c-ts-common.el:
(c-ts-common-comment-indent-new-line): Add comments.
2024-04-22 21:56:22 -07:00
Vincenzo Pupillo
1f443c277a
Cover more c-ts-common-comment-indent-new-line (bug#70520)
* lisp/progmodes/c-ts-common.el:
(c-ts-common-comment-indent-new-line): Handles the case of comments in a
comment block that begin with whitespaces.
2024-04-22 21:56:22 -07:00
Yuan Fu
4d9629b087
Cover more cases in c-ts-common-comment-indent-new-line
* lisp/progmodes/c-ts-common.el:
(c-ts-common-comment-indent-new-line): Handle the case for ///, which
is used by rust.
2024-04-21 23:58:46 -07:00
Yuan Fu
ecf15513ea
Make c-ts-common-comment-indent-new-line work for more cases
* lisp/progmodes/c-ts-common.el:
(c-ts-common-comment-indent-new-line): Handle the case where user
types M-j in the middle of a line; and when the line starts with /**.
2024-04-21 21:41:00 -07:00
Yuan Fu
81391ae3f5
Add tree-sitter comment-indent-new-line (bug#70074)
* lisp/progmodes/c-ts-common.el:
(c-ts-common-comment-indent-new-line): New function.
(c-ts-common-comment-setup): Setup comment-line-break-function and
comment-multi-line.
2024-04-21 21:25:19 -07:00
Eli Zaretskii
5769a10530 ; Fix doc strings of some treesit-related functions
* lisp/treesit.el (treesit-defun-tactic)
(treesit-defun-name-function, treesit-thing-at-point)
(treesit-defun-at-point):
* lisp/progmodes/c-ts-common.el (c-ts-common-statement-offset):
* lisp/progmodes/c-ts-mode.el (c-ts-mode-toggle-comment-style)
(c-ts-mode-indent-style, c-ts-mode-emacs-sources-support)
(c-ts-mode--syntax-propertize, c-ts-mode--anchor-prev-sibling)
(c-ts-mode--standalone-parent-skip-preproc)
(c-ts-mode--standalone-grandparent, c-ts-mode--else-heuristic)
(c-ts-mode--declarator-identifier)
(c-ts-mode--fontify-declarator, c-ts-mode--fontify-variable)
(c-ts-mode--defun-valid-p)
(c-ts-mode--defun-for-class-in-imenu-p)
(c-ts-mode--defun-skipper, c-ts-mode--emacs-defun-p)
(c-ts-mode--emacs-defun-at-point)
(c-ts-mode--emacs-current-defun-name, c-ts-mode--reverse-ranges)
(c-ts-mode, c++-ts-mode, c-or-c++-ts-mode): Doc fixes.
2024-03-23 11:50:55 +02:00
Stefan Kangas
9364c28959 ; Fix typos in symbol names 2024-01-21 15:28:06 +01:00
Po Lu
8e1c56ae46 ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
Stefan Kangas
5f923ff1a6 ; Fix typos 2023-12-03 23:31:30 +01:00
Stefan Kangas
9aab258b80 Add missing builtin package declarations
* lisp/finder.el (finder--builtins-alist): Add new package
directories 'leim' and 'obsolete' as part of the 'emacs' package.
Add new package directory 'use-package' as part of the
'use-package' package.
* lisp/net/eudc-capf.el:
* lisp/net/eudcb-ecomplete.el:
* lisp/net/eudcb-macos-contacts.el:
* lisp/net/eudcb-mailabbrev.el: Declare library as part of the
'eudc' package.
* lisp/mail/ietf-drums-date.el: Declare library as part of the
'ietf-drums' package.
* lisp/image/image-dired-dired.el:
* lisp/image/image-dired-external.el:
* lisp/image/image-dired-tags.el:
* lisp/image/image-dired-util.el: Declare library as part of the
'image-dired' package.
* lisp/emacs-lisp/oclosure.el:
* lisp/keymap.el:
* lisp/progmodes/c-ts-common.el: Declare library as part of the
'emacs' package.  (Bug#62751)

(cherry picked from commit 94b1de2774)
2023-09-18 01:55:28 +02:00
Yuan Fu
f856468e45
Only fill the current paragraph in c-ts-common--fill-block-comment
* lisp/progmodes/c-ts-common.el:
(c-ts-common--fill-block-comment): Shrink the filled region to the
paragraph at point.
2023-03-21 22:50:03 -07:00
Daniel Martín
497018dd5c
; Fix typos in docstrings in c-ts-common.el
* lisp/progmodes/c-ts-common.el:
(c-ts-common-statement-offset): Fix typo.
2023-02-24 20:50:04 -08:00
Yuan Fu
d25f24fe57
Fix c-ts-common-statement-offset and c-ts-common--node-is
* lisp/progmodes/c-ts-common.el:
(c-ts-common--node-is): Guard against case where the node has no field
name.
(c-ts-common-statement-offset): Do indent a level if the "if" in the
"else if" is on an independent line.
2023-02-24 19:51:43 -08:00
Daniel Martín
79fead1709 ; Fix a typo in a doc string in c-ts-common.el (bug#61736). 2023-02-23 19:50:52 +02:00
Yuan Fu
87d39a30b1
Fix c-ts-mode indentation
Sign, ok, there's another edge case: else if statements.  Because
"else if" is usually implemented as just another if statement nested
in the else branch, this creates additional levels that indentation
needs to ignore.

I converted c-ts-common-indent-block-type-regexp +
c-ts-common-indent-bracketless-type-regexp into a new, more flexible
variable, c-ts-common-indent-type-regexp-alist, to avoid adding yet
more variables in order to recognize else and if statements.

* lisp/progmodes/c-ts-common.el:
(c-ts-common-indent-type-regexp-alist): New variable.
(c-ts-common-indent-block-type-regexp)
(c-ts-common-indent-bracketless-type-regexp): Remove variables.
(c-ts-common--node-is): New function.
(c-ts-common-statement-offset): Use the new variable, and add the
"else if" special case.  Also merge the code of
c-ts-mode--fix-bracketless-indent, because now the code is much more
succinct.
(c-ts-mode--fix-bracketless-indent): Merge into
c-ts-common-statement-offset.

* lisp/progmodes/c-ts-mode.el:
(c-ts-base-mode): Setup c-ts-common-indent-type-regexp-alist.

* test/lisp/progmodes/c-ts-mode-resources/indent.erts: New test.
2023-02-06 18:29:38 -08:00
Eli Zaretskii
97533e73ad ; * lisp/progmodes/c-ts-common.el (treesit-node-prev-sibling): Declare. 2023-02-06 18:34:39 +02:00
Theodor Thornhill
5a6dfab1e4 Use c-ts-common-statement-offset in java-ts-mode (bug#61142)
* lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Add new
matchers to enable c-ts-common machinery.
(java-ts-mode): Add regexps.
* lisp/progmodes/c-ts-common.el (c-ts-common-statement-offset): Fix
typo in documentation and use the new if statement helpers.
(c-ts-common-if-statement-regexp): New defvar.
(c-ts-common-nestable-if-statement-p): New defvar.
(c-ts-common--fix-nestable-if-statement): New helper.
* test/lisp/progmodes/c-ts-mode-resources/indent.erts: Add test for
complicated bracket matching indentation.
* lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Add indent
rules for bracketless statements.
2023-02-06 07:43:37 +01:00
Yuan Fu
a2b77c79dc
Use c-ts-common-statement-offset for closing brackets too
Merge c-ts-mode--close-bracket-offset into
c-ts-common-statement-offset.

* lisp/progmodes/c-ts-common.el:
(c-ts-common-statement-offset): Handle closing brackets too.
(c-ts-mode--close-bracket-offset): Remove function.
* lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Use
c-ts-common-statement-offset for closing brackets.
2023-02-02 18:28:08 -08:00
Yuan Fu
74e715cb72
; Go back to original point when filling comments in c-ts-mode
* lisp/progmodes/c-ts-common.el:
(c-ts-common--fill-block-comment): Go to original point.
2023-02-02 17:39:08 -08:00
Yuan Fu
b8009bbf2d
; Fix error where we pass t to treesit-node-type in c-ts-common.el
* lisp/progmodes/c-ts-common.el:
(c-ts-common-statement-offset): Move the form that sets node to t
down, also add a check for node’s nullness.
2023-02-02 17:39:08 -08:00
Eli Zaretskii
dda4baa58b ; Fix build and startup without tree-sitter
* lisp/treesit.el (treesit--font-lock-level-setter): Don't loop
over all the buffers if tree-sitter is not built-in, or else
initialization of defcustom will fail.  (Bug#61155)
* lisp/progmodes/rust-ts-mode.el (treesit-node-parent):
* lisp/progmodes/c-ts-common.el (treesit-node-parent): Declare, to
* avoid byte-compilation warnings.
2023-01-30 14:22:19 +02:00
Yuan Fu
a3003492ac
Move c-ts-mode--statement-offset to c-ts-common.el
Now it can be used by other C-like languages.

* lisp/progmodes/c-ts-common.el (c-ts-common-indent-offset):
(c-ts-common-indent-block-type-regexp):
(c-ts-common-indent-bracketless-type-regexp): New variables.
(c-ts-common-statement-offset):
(c-ts-mode--fix-bracketless-indent):
(c-ts-mode--close-bracket-offset): New functions.

* lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Change
c-ts-mode--statement-offset to c-ts-common-statement-offset.
The (parent-is "if_statement") rules are now handled by (node-is
"compound_statement").

(c-ts-mode--statement-offset-post-processr):
(c-ts-mode--statement-offset):
(c-ts-mode--fix-bracketless-indent): Move to c-ts-common.el.

(c-ts-base-mode): Setup c-ts-common stuff.

* test/lisp/progmodes/c-ts-mode-resources/indent.erts: Make the test
more challenging.
2023-01-29 00:12:56 -08:00
Theodor Thornhill
6adc193ad6 Move c-like common utils into own library (bug#60961)
* lisp/progmodes/c-ts-common.el: New file.
* lisp/progmodes/c-ts-mode.el (treesit-induce-sparse-tree): Remove
unused declaration.
(c-ts-mode--indent-styles): Refer to the new library.
(c-ts-mode--looking-at-star,
c-ts-mode--comment-start-after-first-star,
c-ts-mode--comment-2nd-line-matcher,
c-ts-mode--comment-2nd-line-anchor, c-ts-mode--comment-regexp,
c-ts-mode--fill-paragraph, c-ts-mode--fill-block-comment): Move to
c-ts-common and expose as public.
(c-ts-mode-comment-setup): Move to c-ts-common.
* lisp/progmodes/csharp-mode.el (c-ts-common): Require new library.
(csharp-ts-mode--indent-rules): Refer to the new symbols.
(csharp-ts-mode): Use new function.
* lisp/progmodes/java-ts-mode.el (c-ts-common): Require new library.
(java-ts-mode--indent-rules): Refer to the new symbols.
(java-ts-mode): Use new function.
* lisp/progmodes/js.el (c-ts-common): Require new library.
(js--treesit-indent-rules): Refer to the new symbols.
(js-ts-mode): Use new function.
* lisp/progmodes/rust-ts-mode.el (c-ts-common): Require new library.
(rust-ts-mode--indent-rules): Refer to the new symbols.
(rust-ts-mode): Use new function.
* lisp/progmodes/typescript-ts-mode.el (c-ts-common): Require new
library.
(typescript-ts-mode--indent-rules): Refer to the new symbols.
(typescript-ts-base-mode): Use new function.
2023-01-21 21:38:27 +01:00