From a37287524c951413954393ad72b74b1d70354c09 Mon Sep 17 00:00:00 2001 From: Kat Huang Date: Mon, 31 Jul 2023 18:34:38 -0600 Subject: [PATCH] [Emacs] treesit-auto copy hooks WIP --- dotfiles/emacs.d/README.org | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/dotfiles/emacs.d/README.org b/dotfiles/emacs.d/README.org index d8c08c39..2507d042 100644 --- a/dotfiles/emacs.d/README.org +++ b/dotfiles/emacs.d/README.org @@ -1576,15 +1576,26 @@ out how to detect that a buffer is a man mode buffer. (setq treesit-auto-install t) (global-treesit-auto-mode +1) - (defun treesit-auto-for-each (fn) - (cl-loop for recipe in treesit-auto-recipe-list - do - (let ((from (treesit-auto-recipe-remap recipe)) + (defun treesit-auto-for-each (fn) + (cl-loop for recipe in treesit-auto-recipe-list + do + (let ((from (treesit-auto-recipe-remap recipe)) (to (treesit-auto-recipe-ts-mode recipe))) - (funcall fn from to)))) + (funcall fn from to)))) - (defun treesit-auto-get-mode-hook-symbol (mode) - (intern (concat (symbol-name mode) "-mode-hook"))) + ;; (treesit-auto-for-each + ;; (lambda (from to) + ;; (letrec ((to-hook (treesit-auto-get-mode-hook-symbol to)) + ;; (from-hook (treesit-auto-get-mode-hook-symbol from)) + ;; (set-exp (list 'setq to-hook from-hook))) + ;; (message (format "%s" set-exp)) + ;; (when (boundp from-hook) + ;; (eval result))))) + + (defun treesit-auto-get-mode-hook-symbol (mode) + (intern (concat (symbol-name mode) "-hook"))) + + (treesit-auto-get-mode-hook-symbol 'python-mode) (defun treesit-auto-copy-all-lsp-languages () (cl-loop for recipe in treesit-auto-recipe-list @@ -1603,10 +1614,10 @@ out how to detect that a buffer is a man mode buffer. (defun treesit-auto-copy-lsp-client-languages (from to) (cl-loop for client in (hash-table-values lsp-clients) do - (let ((major-modes (lsp--client-major-modes client))) + (let ((major-modes (lsp--client-major-modes client))) (when (memq from major-modes) (setf (lsp--client-major-modes client) - (append major-modes (list to))))))) + (append major-modes (list to))))))) (use-package lsp-mode :config