Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M-j in /** foo */ comment blocks is broken. Reasonbly easy to fix #150

Open
joaotavora opened this issue Aug 11, 2021 · 3 comments
Open

Comments

@joaotavora
Copy link

joaotavora commented Aug 11, 2021

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
@zzantares
Copy link

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

@josteink
Copy link
Member

Wow. Has this been lying around since August? 😨

That c-based fix looks doable. Let me fix that up for you.

@josteink
Copy link
Member

josteink commented Nov 30, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants