-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Enable xref-js2 in js-ts-mode #850
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea — I think a different formulation is needed, though (see comments), so let me have a think.
lisp/init-javascript.el
Outdated
(add-hook 'js-mode-hook 'sanityinc/enable-xref-js2)) | ||
(define-key js-ts-mode-map (kbd "M-.") nil) | ||
(add-hook 'js-mode-hook 'sanityinc/enable-xref-js2) | ||
(add-hook 'js-ts-mode-hook 'sanityinc/enable-xref-js2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
js-mode-hook is actually run in js-ts-mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, actually both js-mode and js-ts-mode inherit from js-base-mode in Emacs >= 29
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, sorry, I had been tinkering with the code locally and my mind was thinking of js-base-mode
.
lisp/init-javascript.el
Outdated
@@ -57,7 +57,10 @@ | |||
(add-hook 'xref-backend-functions #'xref-js2-xref-backend nil t)) | |||
(with-eval-after-load 'js | |||
(define-key js-mode-map (kbd "M-.") nil) | |||
(add-hook 'js-mode-hook 'sanityinc/enable-xref-js2)) | |||
(define-key js-ts-mode-map (kbd "M-.") nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would break in Emacs < 29 so a different formulation would be needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the reminder, I have fixed this problem, please take a look.
I pushed my version of this change in |
He doesn't fix the problem, because (defvar js-ts-mode-map (copy-keymap js-mode-map)
"Keymap used in `js-ts-mode'.") I think this could work: (let ((base-mode (if (fboundp 'js-base-mode) 'js-base-mode 'js-mode)))
(with-eval-after-load 'js
(add-hook (derived-mode-hook-name base-mode) 'sanityinc/enable-xref-js2)
(define-key js-mode-map (kbd "M-.") nil)
+ (define-key js-ts-mode-map (kbd "M-.") nil)
)) But there is another good news. In the emacs master branch, the commit |
Thanks. I committed a further fix here anyway. |
No description provided.