[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 9fb6072 116/173: Reimplement -electric-do using a pre-comm
From: |
Dmitry Gutov |
Subject: |
[elpa] master 9fb6072 116/173: Reimplement -electric-do using a pre-command-hook |
Date: |
Thu, 23 Jun 2016 00:28:43 +0000 (UTC) |
branch: master
commit 9fb6072f6df1d572a8d92801caef662af667a8af
Author: Clément Pit--Claudel <address@hidden>
Commit: Clément Pit--Claudel <address@hidden>
Reimplement -electric-do using a pre-command-hook
This fixes #439 and #454, and will hopefully make #310 easier.
---
company.el | 33 ++++++++++++++++++---------------
1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/company.el b/company.el
index 78aa92b..399cd31 100644
--- a/company.el
+++ b/company.el
@@ -1565,6 +1565,7 @@ from the rest of the backends in the group, if any, will
be left at the end."
(and (symbolp command) (get command 'company-keep)))
(defun company-pre-command ()
+ (company--electric-restore-window-configuration)
(unless (company-keep this-command)
(condition-case-unless-debug err
(when company-candidates
@@ -2115,28 +2116,30 @@ character, stripping the modifiers. That character
must be a digit."
(insert string)))
(current-buffer)))
+(defvar company--electric-saved-window-configuration nil)
+
(defvar company--electric-commands
'(scroll-other-window scroll-other-window-down mwheel-scroll)
"List of Commands that won't break out of electric commands.")
+(defun company--electric-restore-window-configuration ()
+ "Restore window configuration (after electric commands)."
+ (when (and company--electric-saved-window-configuration
+ (not (memq this-command company--electric-commands)))
+ (set-window-configuration company--electric-saved-window-configuration)
+ (setq company--electric-saved-window-configuration nil)))
+
(defmacro company--electric-do (&rest body)
(declare (indent 0) (debug t))
`(when (company-manual-begin)
- (save-window-excursion
- (let ((height (window-height))
- (row (company--row))
- cmd)
- ,@body
- (and (< (window-height) height)
- (< (- (window-height) row 2) company-tooltip-limit)
- (recenter (- (window-height) row 2)))
- (while (memq (setq cmd (key-binding (read-key-sequence-vector nil)))
- company--electric-commands)
- (condition-case err
- (call-interactively cmd)
- ((beginning-of-buffer end-of-buffer)
- (message (error-message-string err)))))
- (company--unread-last-input)))))
+ (cl-assert (null company--electric-saved-window-configuration))
+ (setq company--electric-saved-window-configuration
(current-window-configuration))
+ (let ((height (window-height))
+ (row (company--row)))
+ ,@body
+ (and (< (window-height) height)
+ (< (- (window-height) row 2) company-tooltip-limit)
+ (recenter (- (window-height) row 2))))))
(defun company--unread-last-input ()
(when last-input-event
- [elpa] master 3ec9d5d 145/173: Add Julia keywords, (continued)
- [elpa] master 3ec9d5d 145/173: Add Julia keywords, Dmitry Gutov, 2016/06/22
- [elpa] master 900ae0d 096/173: Add support for company-face, Dmitry Gutov, 2016/06/22
- [elpa] master 1221739 122/173: Improve the description of cons prefix, Dmitry Gutov, 2016/06/22
- [elpa] master ac7f816 134/173: Merge pull request #466 from tarsius/patch-1, Dmitry Gutov, 2016/06/22
- [elpa] master 9e844d1 124/173: Merge pull request #459 from fbergroth/prefix-length-var, Dmitry Gutov, 2016/06/22
- [elpa] master 31780fb 114/173: Revert "company-cancel: Call frontends' 'hide before 'post-completion", Dmitry Gutov, 2016/06/22
- [elpa] master a7e4408 152/173: Merge pull request #491 from akirakyle/patch-1, Dmitry Gutov, 2016/06/22
- [elpa] master 2dd1f6a 112/173: company-cancel: Call frontends' 'hide before 'post-completion, Dmitry Gutov, 2016/06/22
- [elpa] master dc4927b 158/173: Allow company-dabbrev-ignore-buffers to be a function, Dmitry Gutov, 2016/06/22
- [elpa] master 3f1afc6 171/173: Revert "Remove the [return] binding (#530)", Dmitry Gutov, 2016/06/22
- [elpa] master 9fb6072 116/173: Reimplement -electric-do using a pre-command-hook,
Dmitry Gutov <=
- [elpa] master c845c43 097/173: Revert "Add support for company-face", Dmitry Gutov, 2016/06/22
- [elpa] master e477eaf 107/173: Bump copyright years, Dmitry Gutov, 2016/06/22
- [elpa] master 7a05d1c 115/173: company-cancel: Call pre/post-completion at the end, Dmitry Gutov, 2016/06/22
- [elpa] master cd69d7b 119/173: Add company-semantic-begin-after-member-access, Dmitry Gutov, 2016/06/22
- [elpa] master 724e6dd 136/173: Delete the cache when async completion aborts, Dmitry Gutov, 2016/06/22
- [elpa] master e251568 137/173: Update test for the latest change, Dmitry Gutov, 2016/06/22
- [elpa] master 7afffbc 068/173: Spell "backend" and "frontend" without hyphens, Dmitry Gutov, 2016/06/22
- [elpa] master 5565541 126/173: Option to have tempo expand tags after completion., Dmitry Gutov, 2016/06/22
- [elpa] master ec9f6c7 127/173: Moved company-tempo-insert call to post-completion, Dmitry Gutov, 2016/06/22
- [elpa] master bdf6b22 138/173: Fix #474 by filtering dabbrev completions at the end, Dmitry Gutov, 2016/06/22