typescript.el
typescript.el copied to clipboard
M-j in /** foo */ comment blocks is broken. Reasonbly easy to fix
To reproduce:
emacs -Q -L /path/to/typescript.el -l typescript-mode ~/tmp/something.ts
In something.ts
, this exists:
/**
* foo <cursor here>
*/
Pressing M-j
begets:
/**
* foo */
/**
*/
In #41 (sorry, not #42) , a reasonable suggestion is to rebind M-j
to c-indent-new-comment-line
, but that requires this patch to typescript.el
:
diff -u --label /home/capitaomorte/.emacs.d/elpa/typescript-mode-20201002.1109/typescript-mode.el --label \#\<buffer\ typescript-mode.el\> /home/capitaomorte/.emacs.d/elpa/typescript-mode-20201002.1109/typescript-mode.el /tmp/buffer-content-NJt1TY
--- /home/capitaomorte/.emacs.d/elpa/typescript-mode-20201002.1109/typescript-mode.el
+++ #<buffer typescript-mode.el>
@@ -2945,6 +2945,7 @@
c-paragraph-start "$"
c-paragraph-separate "$"
c-block-comment-prefix "* "
+ c-block-comment-ender-regexp "\\*/"
c-line-comment-starter "//"
c-comment-start-regexp "/[*/]\\|\\s!"
comment-start-skip "\\(//+\\|/\\*+\\)\\s *")
Diff finished. Wed Aug 11 12:13:38 2021
Until this gets fixed, here's another workaround which doesn't require patching the library:
(defun my-custom-auto-fill ()
"Break the line and continue with comment if there's any."
(when (> (current-column) fill-column)
(c-indent-new-comment-line)))
(add-hook 'typescript-mode-hook
(lambda ()
(setq-local auto-fill-function 'my-custom-auto-fill)))
it's not pretty though ...
Wow. Has this been lying around since August? :fearful:
That c-based fix looks doable. Let me fix that up for you.
Should work with c-indent-new-comment-line
with the code in current master now.
So now at least key rebinding should be an option.