Subject: bug#67417: closed (Re: bug#67417: 29.1.50; c-ts-mode syntax issues with no brackets)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 11 Dec 2023 00:31:02 +0000

Your bug report

#67417: 29.1.50; c-ts-mode syntax issues with no brackets

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
67417: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=67417
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#67417: 29.1.50; c-ts-mode syntax issues with no brackets
From: Dmitry Gutov <[email-masked]>
To: Yuan Fu <[email-masked]>, Eli Zaretskii <[email-masked]>
Cc: [email-masked], [email-masked]
Date: Mon, 11 Dec 2023 02:29:47 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Version: 29.2

On 10/12/2023 11:29, Yuan Fu wrote:
> 
> 
> On 12/9/23 12:27 AM, Eli Zaretskii wrote:
>>> Date: Thu, 30 Nov 2023 23:58:14 -0800
>>> Cc: [email-masked]
>>> From: Yuan Fu <[email-masked]>
>>>
>>>> The rest of the nodes (if/while/do/for) don't result in parse errors
>>>> here, as long as the condition in parentheses is typed out correctly.
>>>>
>>>> I tried some additional clauses looking for "previous sibling",
>>>> checking whether it's for_statement, etc, which ends with "expression
>>>> statement", and that one is empty... but it a fair amount of code
>>>> which will likely miss other edge cases anyway. Or breaks when the
>>>> grammar changes.
>>> Yeah, for now we can match for the specific case where there's an else
>>> before a "}". That should reduce the chance of it matching other edge
>>> cases. I'll give it another look on this weekend.
>> Any progress here?
> I pushed a commit that changes the too-board heuristic to only match 
> "else before closing bracket". Hopefully this won't cause any false 
> matches.
> 
> I think we can close this. Dmitry, WDYT?

LGTM! (And closing.)

Arteen, let us know if you see any problems with the fixes that are now 
in the emacs-29 branch.

Subject: 29.1.50; c-ts-mode syntax issues with no brackets
From: Arteen Abrishami <[email-masked]>
To: [email-masked]
Date: Thu, 23 Nov 2023 12:55:31 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

This is specifically for the usage of `c-ts-mode` and is not a problem
in `c-mode`. Sometimes, when you type something like:

else
break

it won't indent the "break" until you type a semicolon. In this below
scenario, it does not indent the break at all, but `c-mode` does, and
switching from `c-mode` to `c-ts-mode` with correct indentation leaves
it fixed, but `c-ts-mode` cannot detect or fix it itself.

You can put it into a `.c` buffer all by itself and see:

```
unsigned
heap_pop(struct heapq * heap)
{
  if (heap->sz == 0)
    return -1;

  unsigned ret_val = heap->vals[0];
  heap->vals[0] = heap->vals[heap->len];
  heap->len -= 1;
  unsigned i = 0;
  unsigned lc;

  while ((lc = HEAPQ_L_CHILD(i)) < heap->len)
    {
      unsigned rc = HEAPQ_R_CHILD(i);
      /* no right child for our guy, special case */      
      if (rc == heap->len)
        {
          if (heap->vals[lc] < heap->vals[i])
            SWAP(heap->vals[lc], heap->vals[i]);
          break;
        }

      if (heap->vals[lc] < heap->vals[i])
        {
          SWAP(heap->vals[lc], heap->vals[i]);
          i = lc;
        }
      else if (heap->vals[rc] < heap->vals[i])
        {
          SWAP(heap->vals[rc], heap->vals[i]);
          i = rc;
        }
      else
      break;
      
    }
}
```

The very last break on the else without brackets around it will not indent.c

In GNU Emacs 29.1.50 (build 2, x86_64-apple-darwin23.0.0, NS
appkit-2487.00 Version 14.0 (Build 23A344)) of 2023-09-30 built on
Arteens-MacBook-Pro.local
Repository revision: 63ec6d998d42c970a825dca17743ece9c651d929
Repository branch: emacs-29
Windowing system distributor 'Apple', version 10.3.2487
System Description:  macOS 14.1.1

Configured using:
'configure --with-native-compilation=aot --without-pop
--with-tree-sitter --with-json 'CFLAGS=-O2 -pipe'
CPPFLAGS=-I/usr/local/opt/openjdk/bin:/usr/local/opt/openjdk/bin:/usr/local/opt/make/libexec/gnubin:/usr/local/opt/[email-masked]/libexec/bin:/usr/local/sbin:/Library/Frameworks/Python.framework/Versions/3.11/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Library/TeX/texbin'

Configured features:
ACL GIF GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP NOTIFY
KQUEUE NS PDUMPER PNG SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
TREE_SITTER XIM ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: C/*

Minor modes in effect:
  override-global-mode: t
  windmove-mode: t
  winner-mode: t
  delete-selection-mode: t
  global-auto-revert-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  hs-minor-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message yank-media puny rfc822 mml
mml-sec epa derived epg rfc6068 epg-config gnus-util
text-property-search mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils c++-ts-mode c-ts-mode c-ts-common treesit
misearch multi-isearch time-date comp comp-cstr warnings icons vc-git
diff-mode vc-dispatcher cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs hideshow dired-subtree
dired-hacks-utils dired dired-loaddefs dash edmacro kmacro
use-package-bind-key bind-key easy-mmode rx doom-themes-ext-org
doom-themes-ext-visual-bell face-remap doom-vibrant-theme doom-themes
doom-themes-base exec-path-from-shell cl-extra help-mode
use-package-ensure use-package-core windmove winner ring delsel
autorevert filenotify dired-sidebar-autoloads dired-subtree-autoloads
dired-hacks-utils-autoloads info dash-autoloads doom-themes-autoloads
exec-path-from-shell-autoloads expand-region-autoloads package
browse-url url url-proxy url-privacy url-expand url-methods url-history
url-cookie generate-lisp-file url-domsuf url-util mailcap url-handlers
url-parse auth-source cl-seq eieio eieio-core cl-macs password-cache
json subr-x map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs
cl-lib rmc iso-transl tooltip cconv eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/ns-win ns-win
ucs-normalize mule-util term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads kqueue cocoa ns lcms2
multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 240395 9962)
(symbols 48 13899 0)
(strings 32 41716 3048)
(string-bytes 1 1380541)
(vectors 16 26557)
(vector-slots 8 519687 16325)
(floats 8 260 374)
(intervals 56 5432 0)
(buffers 984 16))