From 1527e1cc0ff2e9aa7c6751ed164d3534923691bc Mon Sep 17 00:00:00 2001 From: tastytea Date: Mon, 23 Dec 2019 03:52:07 +0100 Subject: [PATCH] Emacs: Solve company-yasnippet tab-interference. --- init/programming/common.el | 7 ++++--- init/text/common.el | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/init/programming/common.el b/init/programming/common.el index 5a2c560..49642d6 100644 --- a/init/programming/common.el +++ b/init/programming/common.el @@ -1,6 +1,6 @@ ;;; common.el --- Common programming settings. -*- lexical-binding: t; -*- -;; Time-stamp: <2019-12-01T06:11:27+00:00> +;; Time-stamp: <2019-12-23T02:50:34+00:00> ;;; Commentary: @@ -70,8 +70,9 @@ (:map company-active-map ("" . nil) ; Disable completion on return. ("RET" . nil) ; https://emacs.stackexchange.com/a/13290 - ("" . company-complete-selection) ; Make tab work in lists. - ("TAB" . company-complete-selection)) + ("" . company-complete-selection) ; Make tab work in lists (GUI). + ("TAB" . company-complete-selection) ; Same in terminals. + ) :hook (after-init . global-company-mode) diff --git a/init/text/common.el b/init/text/common.el index 401afd6..2d05cd5 100644 --- a/init/text/common.el +++ b/init/text/common.el @@ -1,6 +1,6 @@ ;;; common.el --- Common settings for text files. -*- lexical-binding: t; -*- -;; Time-stamp: <2019-12-18T23:44:03+00:00> +;; Time-stamp: <2019-12-23T02:48:05+00:00> ;;; Commentary: @@ -113,11 +113,26 @@ ;; A template system. (use-package yasnippet + :after (company) + :defines (company-candidates) :functions (yas-reload-all yas-expand-snippet) :config + (defun my/tab-yas-or-company () + "Complete with company if possible, jump to next field otherwise." + (interactive) + (if company-candidates + (company-complete-selection) + (yas-next-field))) + (yas-reload-all) + :bind + (:map yas-keymap + ("" . my/tab-yas-or-company) + ("TAB" . my/tab-yas-or-company) + ) + :hook (prog-mode . yas-minor-mode) )