From 8482f26d5147113fb67b6b8d20505c69424d30aa Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 22 Jul 2019 23:51:39 +0200 Subject: [PATCH] Move cc modes smartparen functions to config/default --- modules/config/default/config.el | 19 ++++++++++++++++++- modules/lang/cc/autoload.el | 17 ----------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/modules/config/default/config.el b/modules/config/default/config.el index 0198a0701..7ac5f3645 100644 --- a/modules/config/default/config.el +++ b/modules/config/default/config.el @@ -106,10 +106,27 @@ ;; intelligently. The result isn't very intelligent (causes redundant ;; characters), so just do it ourselves. (define-key! c++-mode-map "<" nil ">" nil) + + (defun +default-cc-sp-point-is-template-p (id action context) + "Return t if point is in the right place for C++ angle-brackets." + (and (sp-in-code-p id action context) + (cond ((eq action 'insert) + (sp-point-after-word-p id action context)) + ((eq action 'autoskip) + (/= (char-before) 32))))) + + (defun +default-cc-sp-point-after-include-p (id action context) + "Return t if point is in an #include." + (and (sp-in-code-p id action context) + (save-excursion + (goto-char (line-beginning-position)) + (looking-at-p "[ ]*#include[^<]+")))) + ;; ...and leave it to smartparens (sp-local-pair '(c++-mode objc-mode) "<" ">" - :when '(+cc-sp-point-is-template-p +cc-sp-point-after-include-p) + :when '(+default-cc-sp-point-is-template-p + +default-cc-sp-point-after-include-p) :post-handlers '(("| " "SPC"))) (sp-local-pair '(c-mode c++-mode objc-mode java-mode) diff --git a/modules/lang/cc/autoload.el b/modules/lang/cc/autoload.el index 4daf46a24..a3542bd2a 100644 --- a/modules/lang/cc/autoload.el +++ b/modules/lang/cc/autoload.el @@ -7,23 +7,6 @@ ;; ;; Library -;;;###autoload -(defun +cc-sp-point-is-template-p (id action context) - "Return t if point is in the right place for C++ angle-brackets." - (and (sp-in-code-p id action context) - (cond ((eq action 'insert) - (sp-point-after-word-p id action context)) - ((eq action 'autoskip) - (/= (char-before) 32))))) - -;;;###autoload -(defun +cc-sp-point-after-include-p (id action context) - "Return t if point is in an #include." - (and (sp-in-code-p id action context) - (save-excursion - (goto-char (line-beginning-position)) - (looking-at-p "[ ]*#include[^<]+")))) - ;;;###autoload (defun +cc-c++-lineup-inclass (langelem) "Indent inclass lines one level further than access modifier keywords."