From 9ed566d6fe257ddf1bdc82f96c18807c445754b2 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Tue, 17 Nov 2020 15:03:05 +0100 Subject: [PATCH] SLY: Bind TAB and M-TAB to "indent and complete". --- .emacs.d/lisp/init-lisp.el | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.emacs.d/lisp/init-lisp.el b/.emacs.d/lisp/init-lisp.el index 0770bceb..e849779b 100644 --- a/.emacs.d/lisp/init-lisp.el +++ b/.emacs.d/lisp/init-lisp.el @@ -288,6 +288,13 @@ returns a string." (ansi-color-apply str)) (add-hook 'sly-mrepl-output-filter-functions 'ambrevar/sly-colorize-buffer) + (defun ambrevar/indent-and-helm-company (arg) + "Indent then call `helm-company'. +Good substitute for `sly-mrepl-indent-and-complete-symbol'." + (interactive "P") + (indent-for-tab-command arg) + (helm-company)) + (setq sly-command-switch-to-existing-lisp 'always) (add-hook 'sly-mrepl-hook #'ambrevar/init-lispy) (add-hook 'sly-mrepl-hook #'rainbow-delimiters-mode) @@ -296,14 +303,14 @@ returns a string." ;; (add-to-list 'completion-styles 'backend) (when (require 'helm-sly nil 'noerror) ;; (add-hook 'sly-mrepl-hook #'helm-sly-disable-internal-completion) - ;; TODO: The above hangs Emacs 27, why? + ;; REVIEW: Company completion has the benefit of having annotations. (when (require 'helm-company nil :noerror) (add-hook 'lisp-mode-hook #'company-mode) - (define-key lisp-mode-map (kbd "") 'helm-company) - (define-key lisp-mode-map (kbd "M-") 'helm-company) + (define-key lisp-mode-map (kbd "") 'ambrevar/indent-and-helm-company) + (define-key lisp-mode-map (kbd "M-") 'ambrevar/indent-and-helm-company) (defun ambrevar/sly-set-keys () - (define-key sly-mrepl-mode-map (kbd "") 'helm-company) - (define-key sly-mrepl-mode-map (kbd "M-") 'helm-company)) + (define-key sly-mrepl-mode-map (kbd "") 'ambrevar/indent-and-helm-company) + (define-key sly-mrepl-mode-map (kbd "M-") 'ambrevar/indent-and-helm-company)) (add-hook 'sly-mrepl-hook #'ambrevar/sly-set-keys) (add-hook 'sly-mrepl-hook #'company-mode))))