GNU bug report logs - #60463
29.0.60; c-ts-mode: M-x align doesn't work

Previous Next

Package: emacs;

Reported by: Mohammed Sadiq <sadiq <at> sadiqpk.org>

Date: Sun, 1 Jan 2023 10:21:02 UTC

Severity: normal

Found in version 29.0.60

Done: Yuan Fu <casouri <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 60463 in the body.
You can then email your comments to 60463 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#60463; Package emacs. (Sun, 01 Jan 2023 10:21:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Mohammed Sadiq <sadiq <at> sadiqpk.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 01 Jan 2023 10:21:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Mohammed Sadiq <sadiq <at> sadiqpk.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.60; c-ts-mode: M-x align doesn't work
Date: Sun, 01 Jan 2023 15:50:48 +0530
M-x align doesn't align function arguments or struct members, which
works fine in c-mode.

Say for example, if I mark the region around '(' and ')' and do M-x
align for the following code:

int
main (int argc,
      char *argv[])
{
}


I should get the following (see the change of spacing between 'int' and 
'argc'):

int
main (int   argc,
      char *argv[])
{
}


Modifying align-c++-modes to include c-ts-mode should be enough to fix 
this.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60463; Package emacs. (Mon, 02 Jan 2023 22:45:02 GMT) Full text and rfc822 format available.

Message #8 received at 60463 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Mohammed Sadiq <sadiq <at> sadiqpk.org>
Cc: 60463 <at> debbugs.gnu.org
Subject: Re: bug#60463: 29.0.60; c-ts-mode: M-x align doesn't work
Date: Mon, 2 Jan 2023 14:44:45 -0800
Mohammed Sadiq <sadiq <at> sadiqpk.org> writes:

> M-x align doesn't align function arguments or struct members, which
> works fine in c-mode.
>
> Say for example, if I mark the region around '(' and ')' and do M-x
> align for the following code:
>
> int
> main (int argc,
>       char *argv[])
> {
> }
>
>
> I should get the following (see the change of spacing between 'int'
> and 'argc'):
>
> int
> main (int   argc,
>       char *argv[])
> {
> }
>
>
> Modifying align-c++-modes to include c-ts-mode should be enough to fix
> this.

Could you go me a favor and look up where is align-c++-modes defined? Or
just paste the value of it, if it is programmatically defined. Thanks
:-)

Yuan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60463; Package emacs. (Tue, 03 Jan 2023 09:06:01 GMT) Full text and rfc822 format available.

Message #11 received at 60463 <at> debbugs.gnu.org (full text, mbox):

From: Mohammed Sadiq <sadiq <at> sadiqpk.org>
To: Yuan Fu <casouri <at> gmail.com>
Cc: 60463 <at> debbugs.gnu.org
Subject: Re: bug#60463: 29.0.60; c-ts-mode: M-x align doesn't work
Date: Tue, 03 Jan 2023 14:35:15 +0530
>> 
>> Modifying align-c++-modes to include c-ts-mode should be enough to fix
>> this.
> 
> Could you go me a favor and look up where is align-c++-modes defined? 
> Or
> just paste the value of it, if it is programmatically defined. Thanks
> :-)


It's defined in lisp/align.el

Hint: You can do: git grep "align-c++-modes"

There might be other files too where adding c-ts-mode might be helpful.
A rough match would be something like 'git grep "[( ]c-mode[) ]"' (the
noise is too high, but files like lisp/progmodes/gud.el looks like a
positive candidate)


cheers,
Mohammed Sadiq




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60463; Package emacs. (Tue, 03 Jan 2023 11:20:02 GMT) Full text and rfc822 format available.

Message #14 received at 60463 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Mohammed Sadiq <sadiq <at> sadiqpk.org>, Yuan Fu <casouri <at> gmail.com>
Cc: 60463 <at> debbugs.gnu.org
Subject: Re: bug#60463: 29.0.60; c-ts-mode: M-x align doesn't work
Date: Tue, 3 Jan 2023 11:19:09 +0000
Mohammed Sadiq <sadiq <at> sadiqpk.org> writes:

> Hint: You can do: git grep "align-c++-modes"

I like `C-x p g' or `M-x rgrep'.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60463; Package emacs. (Tue, 03 Jan 2023 12:54:02 GMT) Full text and rfc822 format available.

Message #17 received at 60463 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: sadiq <at> sadiqpk.org, 60463 <at> debbugs.gnu.org, casouri <at> gmail.com
Subject: Re: bug#60463: 29.0.60; c-ts-mode: M-x align doesn't work
Date: Tue, 03 Jan 2023 14:53:38 +0200
> Cc: 60463 <at> debbugs.gnu.org
> From: Stefan Kangas <stefankangas <at> gmail.com>
> Date: Tue, 3 Jan 2023 11:19:09 +0000
> 
> Mohammed Sadiq <sadiq <at> sadiqpk.org> writes:
> 
> > Hint: You can do: git grep "align-c++-modes"
> 
> I like `C-x p g' or `M-x rgrep'.

You are kidding, right?  I expected to hear you like M-. instead
(after "M-x xref-etags-mode RET").  That's the right tool in Emacs to
look for an identifier's definition.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60463; Package emacs. (Tue, 03 Jan 2023 15:54:02 GMT) Full text and rfc822 format available.

Message #20 received at 60463 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: sadiq <at> sadiqpk.org, 60463 <at> debbugs.gnu.org, casouri <at> gmail.com
Subject: Re: bug#60463: 29.0.60; c-ts-mode: M-x align doesn't work
Date: Tue, 3 Jan 2023 15:53:48 +0000
Eli Zaretskii <eliz <at> gnu.org> writes:

> I expected to hear you like M-. instead (after "M-x xref-etags-mode
> RET").  That's the right tool in Emacs to look for an identifier's
> definition.

I use that too, of course.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60463; Package emacs. (Sun, 08 Jan 2023 00:57:02 GMT) Full text and rfc822 format available.

Message #23 received at 60463 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Mohammed Sadiq <sadiq <at> sadiqpk.org>
Cc: 60463-done <at> debbugs.gnu.org, 60463 <at> debbugs.gnu.org
Subject: Re: bug#60463: 29.0.60; c-ts-mode: M-x align doesn't work
Date: Sat, 7 Jan 2023 16:55:59 -0800
Mohammed Sadiq <sadiq <at> sadiqpk.org> writes:

>>> Modifying align-c++-modes to include c-ts-mode should be enough to
>>> fix
>>> this.
>> Could you go me a favor and look up where is align-c++-modes
>> defined? Or
>> just paste the value of it, if it is programmatically defined. Thanks
>> :-)
>
>
> It's defined in lisp/align.el
>
> Hint: You can do: git grep "align-c++-modes"
>
> There might be other files too where adding c-ts-mode might be helpful.
> A rough match would be something like 'git grep "[( ]c-mode[) ]"' (the
> noise is too high, but files like lisp/progmodes/gud.el looks like a
> positive candidate)

Thanks, no wonder why I can’t find it in cc-xxx.el files :-)

I added ts- modes to both align and gud.

Yuan




Reply sent to Yuan Fu <casouri <at> gmail.com>:
You have taken responsibility. (Sun, 08 Jan 2023 00:57:02 GMT) Full text and rfc822 format available.

Notification sent to Mohammed Sadiq <sadiq <at> sadiqpk.org>:
bug acknowledged by developer. (Sun, 08 Jan 2023 00:57:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60463; Package emacs. (Thu, 19 Jan 2023 09:23:02 GMT) Full text and rfc822 format available.

Message #31 received at 60463 <at> debbugs.gnu.org (full text, mbox):

From: Mohammed Sadiq <sadiq <at> sadiqpk.org>
To: 60463 <at> debbugs.gnu.org
Subject: Re: bug#60463: 29.0.60; c-ts-mode: M-x align doesn't work
Date: Thu, 19 Jan 2023 14:52:33 +0530
This now seems to work perfectly in interactive use.

Though align.el has a defun call `(c-guess-basic-syntax)` which
seems to break elisp scripts, it may have to be adapted to work
with c-ts-mode. Since we don't have to guess the syntax of the
buffer, may be we can hardcode the syntax for the buffer
depending on the ts-mode used.

I hope it won't be hard to do so

cheers,
Mohammed Sadiq




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60463; Package emacs. (Sun, 22 Jan 2023 08:47:02 GMT) Full text and rfc822 format available.

Message #34 received at 60463 <at> debbugs.gnu.org (full text, mbox):

From: Mohammed Sadiq <sadiq <at> sadiqpk.org>
To: 60463 <at> debbugs.gnu.org
Subject: Re: bug#60463: 29.0.60; c-ts-mode: M-x align doesn't work
Date: Sun, 22 Jan 2023 14:16:31 +0530
Minimal example to reproduce the said issue (save to test.el):

(let ((buffer (generate-new-buffer "temp.c")))
  (with-current-buffer buffer
    (c-ts-mode)
    (insert "int main (int argc,\nchar *argv[])")
    (align (point-min) (point-max))))

Execute the file with:
emacs -Q -batch -l test.el

Error log:
Error: wrong-type-argument (stringp nil)
  mapbacktrace(#f(compiled-function (evald func args flags) #<bytecode 
0x1a9892714fae86ab>))
  debug-early-backtrace()
  debug-early(error (wrong-type-argument stringp nil))
  looking-at(nil)
  c-guess-basic-syntax()
  #f(compiled-function () #<bytecode -0x4fad04c1216d689>)()
  align-region(1 34 "^\\s-*[{}]?\\s-*$" ((lisp-second-arg (regexp . 
"\\(^\\s-+[^( \11\n]\\|(\\(\\S-+\\)\\s-+\\)\\S-+\\(\\s-+\\)") (group . 
3) (modes . align-lisp-modes) (run-if . #f(compiled-function () 
#<bytecode 0x81a7eb0ffdc1>))) (lisp-alist-dot (regexp . 
"\\(\\s-*\\)\\.\\(\\s-*\\)") (group 1 2) (modes . align-lisp-modes)) 
(open-comment (regexp . #f(compiled-function (end reverse) #<bytecode 
-0x13267ef2968538a5>)) (modes . align-open-comment-modes)) 
(c-macro-definition (regexp . "^\\s-*#\\s-*define\\s-+\\S-+\\(\\s-+\\)") 
(modes . align-c++-modes)) (c-variable-declaration (regexp . 
"[*&0-9A-Za-z_]>?[][&*]*\\(\\s-+[*&]*\\)[A-Za-z_][][0-9A-Za-z:_]*\\s-*\\(\\()\\|=[^=\n].*\\|(.*)\\|\\(\\[.*\\]\\)*\\)\\s-*[;,]\\|)\\s-*$\\)") 
(group . 1) (modes . align-c++-modes) (justify . t) (valid . 
#f(compiled-function () #<bytecode -0x4fad04c1216d689>))) (c-assignment 
(regexp . "[^-=!^&*+<>/| 
\11\n]\\(\\s-*[-=!^&*+<>/|]*\\)=\\(\\s-*\\)\\([^= \11\n]\\|$\\)") (group 
1 2) (modes . align-c++-modes) (justify . t) (tab-stop)) 
(perl-assignment (regexp . "[^=!^&*+<>/| 
\11\n-]\\(\\s-*\\)=[~>]?\\(\\s-*\\)\\([^>= \11\n]\\|$\\)") (group 1 2) 
(modes . align-perl-modes) (tab-stop)) (python-assignment (regexp . 
"[^=!<> \11\n]\\(\\s-*\\)=\\(\\s-*\\)\\([^>= \11\n]\\|$\\)") (group 1 2) 
(modes quote (python-mode)) (tab-stop)) (make-assignment (regexp . 
"^\\s-*\\w+\\(\\s-*\\):?=\\(\\s-*\\)\\([^\11\n \\]\\|$\\)") (group 1 2) 
(modes quote (makefile-mode)) (tab-stop)) (c-comma-delimiter (regexp . 
",\\(\\s-*\\)[^/ \11\n]") (repeat . t) (modes . align-c++-modes) (run-if 
. #f(compiled-function () #<bytecode 0x81a7eb0ffdc1>))) 
(basic-comma-delimiter (regexp . ",\\(\\s-*\\)[^# \11\n]") (repeat . t) 
(modes append align-perl-modes '(python-mode)) (run-if . 
#f(compiled-function () #<bytecode 0x81a7eb0ffdc1>))) (c++-comment 
(regexp . "\\(\\s-*\\)\\(//.*\\|/\\*.*\\*/\\s-*\\)$") (modes . 
align-c++-modes) (column . comment-column) (valid . #f(compiled-function 
() #<bytecode 0x1bf81a64bd88fae1>))) (c-chain-logic (regexp . 
"\\(\\s-*\\)\\(&&\\|||\\|\\<and\\>\\|\\<or\\>\\)") (modes . 
align-c++-modes) (valid . #f(compiled-function () #<bytecode 
-0xb23a5ce0f1f5466>))) (perl-chain-logic (regexp . 
"\\(\\s-*\\)\\(&&\\|||\\|\\<and\\>\\|\\<or\\>\\)") (modes . 
align-perl-modes) (valid . #f(compiled-function () #<bytecode 
0x11a8c45291e76f7c>))) (python-chain-logic (regexp . 
"\\(\\s-*\\)\\(\\<and\\>\\|\\<or\\>\\)") (modes quote (python-mode)) 
(valid . #f(compiled-function () #<bytecode -0xb23a5ce0cced366>))) 
(c-macro-line-continuation (regexp . "\\(\\s-*\\)\\\\$") (modes . 
align-c++-modes) (column . c-backslash-column)) (basic-line-continuation 
(regexp . "\\(\\s-*\\)\\\\$") (modes quote (python-mode makefile-mode))) 
(tex-record-separator (regexp . #f(compiled-function (end reverse) 
#<bytecode 0xd4975ad92ca8cb1>)) (group 1 2) (modes . align-tex-modes) 
(repeat . t)) (tex-tabbing-separator (regexp . #f(compiled-function (end 
reverse) #<bytecode 0xd4975a5d4908a71>)) (group 1 2) (modes . 
align-tex-modes) (repeat . t) (run-if . #f(compiled-function () 
#<bytecode 0xa75a925f89192>))) (tex-record-break (regexp . 
"\\(\\s-*\\)\\\\\\\\") (modes . align-tex-modes)) (text-column (regexp . 
"\\(^\\|\\S-\\)\\([ \11]+\\)\\(\\S-\\|$\\)") (group . 2) (modes . 
align-text-modes) (repeat . t) (run-if . #f(compiled-function () 
#<bytecode -0xd0330bf7d0074c6>))) (text-dollar-figure (regexp . 
"\\$?\\(\\s-+[0-9]+\\)\\.") (modes . align-text-modes) (justify . t) 
(run-if . #f(compiled-function () #<bytecode 0xac8febf118136>))) 
(css-declaration (regexp . "^\\s-*\\(?:\\w-?\\)+:\\(\\s-*\\).*;") (group 
1) (modes quote (css-mode html-mode)))) ((exc-dq-string (regexp . 
"\"\\([^\"\n]+\\)\"") (repeat . t) (modes . align-dq-string-modes)) 
(exc-sq-string (regexp . "'\\([^'\n]+\\)'") (repeat . t) (modes . 
align-sq-string-modes)) (exc-open-comment (regexp . #f(compiled-function 
(end reverse) #<bytecode -0x13267ef2968538a5>)) (modes . 
align-open-comment-modes)) (exc-c-comment (regexp . "/\\*\\(.+\\)\\*/") 
(repeat . t) (modes . align-c++-modes)) (exc-c-func-params (regexp . 
"(\\([^)\n]+\\))") (repeat . t) (modes . align-c++-modes)) (exc-c-macro 
(regexp . "^\\s-*#\\s-*\\(if\\w*\\|endif\\)\\(.*\\)$") (group . 2) 
(modes . align-c++-modes))))
  align(1 34)
  (save-current-buffer (set-buffer buffer) (c-ts-mode) (insert "int main 
(int argc,\nchar *argv[])") (align (point-min) (point-max)))
  (let ((buffer (generate-new-buffer "temp.c"))) (save-current-buffer 
(set-buffer buffer) (c-ts-mode) (insert "int main (int argc,\nchar 
*argv[])") (align (point-min) (point-max))))
  eval-buffer(#<buffer  *load*> nil "/home/sadiq/test.el" nil t)
  load-with-code-conversion("/home/sadiq/test.el" "/home/sadiq/test.el" 
nil t)
  load("/home/sadiq/test.el" nil t)
  command-line-1(("-l" "test.el"))
  command-line()
  normal-top-level()
Wrong type argument: stringp, nil




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 19 Feb 2023 12:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 38 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.