emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/company 534273d 1/6: Change default bindings to use C-n


From: ELPA Syncer
Subject: [elpa] externals/company 534273d 1/6: Change default bindings to use C-n/C-p
Date: Thu, 6 May 2021 19:57:09 -0400 (EDT)

branch: externals/company
commit 534273d2312a6aec57accc09828b18ef276a9d4a
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    Change default bindings to use C-n/C-p
    
    This seems to be a more popular scheme, among starter kits as well as end 
users
    (if one judges by configuration snippets posted in various forums).
    
    Should also work around WM misbehavior like described in
    
https://stackoverflow.com/questions/51585036/check-bindings-in-company-active-map?noredirect=1&lq=1
    and
    
https://github.com/company-mode/company-mode/issues/1086#issuecomment-818698244.
---
 NEWS.md    | 14 ++++++++++++++
 company.el | 29 +++++++++++++++++++++++++----
 2 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/NEWS.md b/NEWS.md
index 6242374..4aa7ebc 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,20 @@
 
 ## Next
 
+* Default key bindings have changed, moving `company-select-next` and
+  `company-select-previous` from `M-n` and `M-p` to `C-n` and `C-p`. The
+  previous bindings still work, but show a warning and will be disabled soon. 
To
+  undo that change in your local configuration, do:
+
+```el
+(with-eval-after-load 'company
+  (dolist (map (list company-active-map company-search-map))
+    (define-key map (kbd "C-n") nil)
+    (define-key map (kbd "C-p") nil)
+    (define-key map (kbd "M-n") 'company-select-next)
+    (define-key map (kbd "M-p") 'company-select-previous)))
+```
+
 * `company-idle-delay` default reduced to 0.2 (seconds).
 * The minimum required version of Emacs is now 25.1.
 * Added support for icons
diff --git a/company.el b/company.el
index 44390b3..2c3d2dc 100644
--- a/company.el
+++ b/company.el
@@ -689,8 +689,10 @@ asynchronous call into synchronous.")
   (let ((keymap (make-sparse-keymap)))
     (define-key keymap "\e\e\e" 'company-abort)
     (define-key keymap "\C-g" 'company-abort)
-    (define-key keymap (kbd "M-n") 'company-select-next)
-    (define-key keymap (kbd "M-p") 'company-select-previous)
+    (define-key keymap (kbd "M-n") 'company--select-next-and-warn)
+    (define-key keymap (kbd "M-p") 'company--select-previous-and-warn)
+    (define-key keymap (kbd "C-n") 'company-select-next)
+    (define-key keymap (kbd "C-p") 'company-select-previous)
     (define-key keymap (kbd "<down>") 'company-select-next-or-abort)
     (define-key keymap (kbd "<up>") 'company-select-previous-or-abort)
     (define-key keymap [remap scroll-up-command] 'company-next-page)
@@ -717,6 +719,23 @@ asynchronous call into synchronous.")
 
 (defvar company--disabled-backends nil)
 
+(defun company--select-next-and-warn (&optional arg)
+  (interactive "p")
+  (company--warn-changed-binding)
+  (company-select-next arg))
+
+(defun company--select-previous-and-warn (&optional arg)
+  (interactive "p")
+  (company--warn-changed-binding)
+  (company-select-previous arg))
+
+(defun company--warn-changed-binding ()
+  (interactive)
+  (run-with-idle-timer
+   0.01 nil
+   (lambda ()
+     (message "Warning: default bindings are being changed to C-n and C-p"))))
+
 (defun company-init-backend (backend)
   (and (symbolp backend)
        (not (fboundp backend))
@@ -2177,8 +2196,10 @@ each one wraps a part of the input string."
       (define-key keymap (char-to-string meta-prefix-char) meta-map)
       (define-key keymap [escape] meta-map))
     (define-key keymap (vector meta-prefix-char t) 'company-search-other-char)
-    (define-key keymap (kbd "M-n") 'company-select-next)
-    (define-key keymap (kbd "M-p") 'company-select-previous)
+    (define-key keymap (kbd "C-n") 'company-select-next)
+    (define-key keymap (kbd "C-p") 'company-select-previous)
+    (define-key keymap (kbd "M-n") 'company--select-next-and-warn)
+    (define-key keymap (kbd "M-p") 'company--select-previous-and-warn)
     (define-key keymap (kbd "<down>") 'company-select-next-or-abort)
     (define-key keymap (kbd "<up>") 'company-select-previous-or-abort)
     (define-key keymap "\e\e\e" 'company-search-other-char)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]