all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#60463: 29.0.60; c-ts-mode: M-x align doesn't work
@ 2023-01-01 10:20 Mohammed Sadiq
  2023-01-02 22:44 ` Yuan Fu
  2023-01-08  0:55 ` Yuan Fu
  0 siblings, 2 replies; 9+ messages in thread
From: Mohammed Sadiq @ 2023-01-01 10:20 UTC (permalink / raw)
  To: 60463

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.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#60463: 29.0.60; c-ts-mode: M-x align doesn't work
  2023-01-01 10:20 bug#60463: 29.0.60; c-ts-mode: M-x align doesn't work Mohammed Sadiq
@ 2023-01-02 22:44 ` Yuan Fu
  2023-01-03  9:05   ` Mohammed Sadiq
  2023-01-19  9:22   ` Mohammed Sadiq
  2023-01-08  0:55 ` Yuan Fu
  1 sibling, 2 replies; 9+ messages in thread
From: Yuan Fu @ 2023-01-02 22:44 UTC (permalink / raw)
  To: Mohammed Sadiq; +Cc: 60463


Mohammed Sadiq <sadiq@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





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#60463: 29.0.60; c-ts-mode: M-x align doesn't work
  2023-01-02 22:44 ` Yuan Fu
@ 2023-01-03  9:05   ` Mohammed Sadiq
  2023-01-03 11:19     ` Stefan Kangas
  2023-01-19  9:22   ` Mohammed Sadiq
  1 sibling, 1 reply; 9+ messages in thread
From: Mohammed Sadiq @ 2023-01-03  9:05 UTC (permalink / raw)
  To: Yuan Fu; +Cc: 60463


>> 
>> 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





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#60463: 29.0.60; c-ts-mode: M-x align doesn't work
  2023-01-03  9:05   ` Mohammed Sadiq
@ 2023-01-03 11:19     ` Stefan Kangas
  2023-01-03 12:53       ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Kangas @ 2023-01-03 11:19 UTC (permalink / raw)
  To: Mohammed Sadiq, Yuan Fu; +Cc: 60463

Mohammed Sadiq <sadiq@sadiqpk.org> writes:

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

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





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#60463: 29.0.60; c-ts-mode: M-x align doesn't work
  2023-01-03 11:19     ` Stefan Kangas
@ 2023-01-03 12:53       ` Eli Zaretskii
  2023-01-03 15:53         ` Stefan Kangas
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2023-01-03 12:53 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: sadiq, 60463, casouri

> Cc: 60463@debbugs.gnu.org
> From: Stefan Kangas <stefankangas@gmail.com>
> Date: Tue, 3 Jan 2023 11:19:09 +0000
> 
> Mohammed Sadiq <sadiq@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.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#60463: 29.0.60; c-ts-mode: M-x align doesn't work
  2023-01-03 12:53       ` Eli Zaretskii
@ 2023-01-03 15:53         ` Stefan Kangas
  0 siblings, 0 replies; 9+ messages in thread
From: Stefan Kangas @ 2023-01-03 15:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: sadiq, 60463, casouri

Eli Zaretskii <eliz@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.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#60463: 29.0.60; c-ts-mode: M-x align doesn't work
  2023-01-01 10:20 bug#60463: 29.0.60; c-ts-mode: M-x align doesn't work Mohammed Sadiq
  2023-01-02 22:44 ` Yuan Fu
@ 2023-01-08  0:55 ` Yuan Fu
  1 sibling, 0 replies; 9+ messages in thread
From: Yuan Fu @ 2023-01-08  0:55 UTC (permalink / raw)
  To: Mohammed Sadiq; +Cc: 60463-done, 60463


Mohammed Sadiq <sadiq@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





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#60463: 29.0.60; c-ts-mode: M-x align doesn't work
  2023-01-02 22:44 ` Yuan Fu
  2023-01-03  9:05   ` Mohammed Sadiq
@ 2023-01-19  9:22   ` Mohammed Sadiq
  2023-01-22  8:46     ` Mohammed Sadiq
  1 sibling, 1 reply; 9+ messages in thread
From: Mohammed Sadiq @ 2023-01-19  9:22 UTC (permalink / raw)
  To: 60463

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





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#60463: 29.0.60; c-ts-mode: M-x align doesn't work
  2023-01-19  9:22   ` Mohammed Sadiq
@ 2023-01-22  8:46     ` Mohammed Sadiq
  0 siblings, 0 replies; 9+ messages in thread
From: Mohammed Sadiq @ 2023-01-22  8:46 UTC (permalink / raw)
  To: 60463

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





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-01-22  8:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-01 10:20 bug#60463: 29.0.60; c-ts-mode: M-x align doesn't work Mohammed Sadiq
2023-01-02 22:44 ` Yuan Fu
2023-01-03  9:05   ` Mohammed Sadiq
2023-01-03 11:19     ` Stefan Kangas
2023-01-03 12:53       ` Eli Zaretskii
2023-01-03 15:53         ` Stefan Kangas
2023-01-19  9:22   ` Mohammed Sadiq
2023-01-22  8:46     ` Mohammed Sadiq
2023-01-08  0:55 ` Yuan Fu

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.