branch: externals/company
commit 3f5907886d2ec38bb168b72e74e405cb2fae331f
Author: Dmitry Gutov <[email protected]>
Commit: Dmitry Gutov <[email protected]>
Change company-show-doc-buffer and company-show-location's bindings
The new combinations seem proven by their use in Corfu, and after the
current
ones are later removed the important binding `C-h` won't be shadowed
anymore.
Also:
* Hardcode a few commands that are invoked without removing the active map.
* Add corresponding fix to company-childframe-frontend, so that it doesn't
call poshandler in an unrelated window.
Resolves #1402
---
NEWS.md | 3 +++
company-childframe.el | 4 +++-
company.el | 29 ++++++++++++++++++++++++-----
3 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/NEWS.md b/NEWS.md
index dd33445e0b..8af89966e2 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,9 @@
# Next
+* Default key bindings have been changed, moving `company-show-doc-buffer` and
+ `company-show-location` to `M-h` and `M-g` (from `C-h` and `C-w`)
+ ([#1537](https://github.com/company-mode/company-mode/issues/1537)).
* Search mode input is displayed at the bottom of the popup
([#1535](https://github.com/company-mode/company-mode/pull/1535)).
* New built-in frontend using "real graphical" widget for the popup
diff --git a/company-childframe.el b/company-childframe.el
index b6de364d88..6a45c125e7 100644
--- a/company-childframe.el
+++ b/company-childframe.el
@@ -184,7 +184,9 @@ For COMMAND refer to `company-frontends'."
(hide
(company-childframe-hide))
(post-command
- (company-childframe-show))
+ (when (equal (window-buffer (selected-window))
+ (current-buffer))
+ (company-childframe-show)))
(select-mouse
(company-childframe--select-mouse))))
diff --git a/company.el b/company.el
index 45efcdc3d8..32b977c27c 100644
--- a/company.el
+++ b/company.el
@@ -910,9 +910,11 @@ asynchronous call into synchronous.")
(define-key keymap [tab] 'company-complete-common-or-cycle)
(define-key keymap (kbd "TAB") 'company-complete-common-or-cycle)
(define-key keymap [backtab] 'company-cycle-backward)
- (define-key keymap (kbd "<f1>") 'company-show-doc-buffer)
- (define-key keymap (kbd "C-h") 'company-show-doc-buffer)
- (define-key keymap "\C-w" 'company-show-location)
+ (define-key keymap (kbd "<f1>") 'company--show-doc-buffer-and-warn)
+ (define-key keymap (kbd "C-h") 'company--show-doc-buffer-and-warn)
+ (define-key keymap (kbd "M-h") 'company-show-doc-buffer)
+ (define-key keymap (kbd "C-w") 'company--show-location-and-warn)
+ (define-key keymap (kbd "M-g") 'company-show-location)
(define-key keymap "\C-s" 'company-search-candidates)
(define-key keymap "\C-\M-s" 'company-filter-candidates)
(company-keymap--bind-quick-access keymap)
@@ -926,7 +928,7 @@ asynchronous call into synchronous.")
(run-with-idle-timer
0.01 nil
(lambda ()
- (message "Warning: default bindings are being changed to C-n and C-p"))))
+ (message "Warning: default bindings are being changed to M-h and M-g"))))
(defun company-init-backend (backend)
(and (symbolp backend)
@@ -2659,7 +2661,12 @@ For more details see `company-insertion-on-trigger' and
(cancel-timer company-timer)
(setq company-timer nil))
(company-echo-cancel t)
- (company-uninstall-map))
+ (unless (memq this-original-command
+ '(describe-key
+ describe-key-briefly
+ describe-map
+ describe-bindings))
+ (company-uninstall-map)))
(defun company-post-command ()
(when (and company-candidates
@@ -3540,6 +3547,12 @@ automatically show the documentation buffer for each
selection."
(company--show-doc-buffer)))
(put 'company-show-doc-buffer 'company-keep t)
+(defun company--show-doc-buffer-and-warn (&optional toggle-auto-update)
+ (interactive "P")
+ (company--warn-changed-binding)
+ (company-show-doc-buffer toggle-auto-update))
+(put 'company--show-doc-buffer-and-warn 'company-keep t)
+
(defun company-show-location ()
"Temporarily display a buffer showing the selected candidate in context."
(interactive)
@@ -3561,6 +3574,12 @@ automatically show the documentation buffer for each
selection."
(set-window-start nil (point)))))))
(put 'company-show-location 'company-keep t)
+(defun company--show-location-and-warn ()
+ (interactive)
+ (company--warn-changed-binding)
+ (company-show-location))
+(put 'company--show-location-and-warn 'company-keep t)
+
;;; package functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar-local company-callback nil)