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

From: Mohammed Sadiq <[email-masked]>
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