[elpa] externals/company 4f3a74b 1/5: `company-select-mouse': per-frontend interface
branch: externals/company commit 4f3a74ba4f79e3c0fd78541e670d6b97ea934a09 Author: Nikita Bloshchanevich Commit: Nikita Bloshchanevich `company-select-mouse': per-frontend interface `company-select-mouse' now delegates to `company-call-frontends' with `select-mouse'. If at least one frontend reports success (returns t), the candidate is considered selected. This allows other, `company-pseudo-tooltip-overlay'-like frontends (e.g. `company-box') to support mouse-selection. To implement this, refactor `company-call-frontends' to return t if at least one frontend did the same. The mouse event is passed trough the `company-mouse-event' global, which is `let'-bound in `company-select-mouse'. Fixes #1044. --- company.el | 82 +++--- 1 file changed, 46 insertions(+), 36 deletions(-) diff --git a/company.el b/company.el index 1bffc7a..ac38996 100644 --- a/company.el +++ b/company.el @@ -1188,11 +1188,14 @@ can retrieve meta-data for them." (string-match-p "\\`company-" (symbol-name this-command))) (defun company-call-frontends (command) - (dolist (frontend company-frontends) -(condition-case-unless-debug err -(funcall frontend command) - (error (error "Company: frontend %s error \"%s\" on command %s" -frontend (error-message-string err) command) + (let (success) +(dolist (frontend company-frontends) + (condition-case-unless-debug err + (when (funcall frontend command) +(setq success t)) +(error (error "Company: frontend %s error \"%s\" on command %s" + frontend (error-message-string err) command +success)) (defun company-set-selection (selection &optional force-update) "Set SELECTION for company candidates. @@ -2151,31 +2154,19 @@ With ARG, move by that many elements." (defun company--event-col-row (event) (company--posn-col-row (event-start event))) +(defvar company-mouse-event nil + "Holds the mouse event from `company-select-mouse'. +For use in the `select-mouse' frontend action. `let'-bound.") + (defun company-select-mouse (event) "Select the candidate picked by the mouse." (interactive "e") - (let ((event-col-row (company--event-col-row event)) -(ovl-row (company--row)) -(ovl-height (and company-pseudo-tooltip-overlay - (min (overlay-get company-pseudo-tooltip-overlay - 'company-height) - company-candidates-length -(if (and ovl-height - (company--inside-tooltip-p event-col-row ovl-row ovl-height)) -(progn - (company-set-selection (+ (cdr event-col-row) -(1- company-tooltip-offset) -(if (and (eq company-tooltip-offset-display 'lines) - (not (zerop company-tooltip-offset))) --1 0) -(- ovl-row) -(if (< ovl-height 0) -(- 1 ovl-height) - 0))) - t) - (company-abort) - (company--unread-this-command-keys) - nil))) + (or (let ((company-mouse-event event)) +(company-call-frontends 'select-mouse)) + (progn +(company-abort) +(company--unread-this-command-keys) +nil))) (defun company-complete-mouse (event) "Insert the candidate picked by the mouse." @@ -3066,14 +3057,14 @@ Returns a negative number if the tooltip should be displayed above point." (pre-command (company-pseudo-tooltip-hide-temporarily)) (post-command (unless (when (overlayp company-pseudo-tooltip-overlay) - (let* ((ov company-pseudo-tooltip-overlay) - (old-height (overlay-get ov 'company-height)) - (new-height (company--pseudo-tooltip-height))) -(and - (>= (* old-height new-height) 0) - (>= (abs old-height) (abs new-height)) - (equal (company-pseudo-tooltip-guard) -(overlay-get ov 'company-guard) + (let* ((ov company-pseudo-tooltip-overlay) + (old-height (overlay-get ov 'company-height)) + (new-height (company--pseudo-tooltip-height))) + (and + (>= (* old-height new-height) 0) + (>= (abs old-height) (abs new-height)) + (equal (company-pseudo-tooltip-guard) + (overlay-get ov 'company-guard) ;; Redraw needed. (company-pseudo-tooltip-show-at-point (point) (length company-prefix)) (overlay-put company-pseudo-tooltip-overlay @@ -3083,7 +3074,26 @@ Re
[elpa] externals/company b728bd6 4/5: Merge pull request #1045 from nbfalcon/feature/company-select-mouse-per-frontend
branch: externals/company commit b728bd657da6e0fe15c3d755e559b8079fa425dc Merge: 123b604 5564a15 Author: Dmitry Gutov Commit: GitHub Merge pull request #1045 from nbfalcon/feature/company-select-mouse-per-frontend `company-select-mouse': per-frontend interface --- NEWS.md| 1 + company.el | 79 ++ 2 files changed, 44 insertions(+), 36 deletions(-) diff --git a/NEWS.md b/NEWS.md index 38ef038..4b5c254 100644 --- a/NEWS.md +++ b/NEWS.md @@ -27,6 +27,7 @@ ## 2020-07-26 (0.9.13) +* `company-select-mouse` is now a frontend action. * `company-clang`: error handling is more permissive. * `company-tng` stops disabling `post-completion` in backends ([#946](https://github.com/company-mode/company-mode/pull/946)). Instead, diff --git a/company.el b/company.el index 34721b1..ec0745c 100644 --- a/company.el +++ b/company.el @@ -1188,11 +1188,11 @@ can retrieve meta-data for them." (string-match-p "\\`company-" (symbol-name this-command))) (defun company-call-frontends (command) - (dolist (frontend company-frontends) -(condition-case-unless-debug err -(funcall frontend command) - (error (error "Company: frontend %s error \"%s\" on command %s" -frontend (error-message-string err) command) + (cl-loop for frontend in company-frontends collect + (condition-case-unless-debug err + (funcall frontend command) + (error (error "Company: frontend %s error \"%s\" on command %s" + frontend (error-message-string err) command) (defun company-set-selection (selection &optional force-update) "Set SELECTION for company candidates. @@ -2151,31 +2151,19 @@ With ARG, move by that many elements." (defun company--event-col-row (event) (company--posn-col-row (event-start event))) +(defvar company-mouse-event nil + "Holds the mouse event from `company-select-mouse'. +For use in the `select-mouse' frontend action. `let'-bound.") + (defun company-select-mouse (event) "Select the candidate picked by the mouse." (interactive "e") - (let ((event-col-row (company--event-col-row event)) -(ovl-row (company--row)) -(ovl-height (and company-pseudo-tooltip-overlay - (min (overlay-get company-pseudo-tooltip-overlay - 'company-height) - company-candidates-length -(if (and ovl-height - (company--inside-tooltip-p event-col-row ovl-row ovl-height)) -(progn - (company-set-selection (+ (cdr event-col-row) -(1- company-tooltip-offset) -(if (and (eq company-tooltip-offset-display 'lines) - (not (zerop company-tooltip-offset))) --1 0) -(- ovl-row) -(if (< ovl-height 0) -(- 1 ovl-height) - 0))) - t) - (company-abort) - (company--unread-this-command-keys) - nil))) + (or (let ((company-mouse-event event)) +(cl-position-if #'identity (company-call-frontends 'select-mouse))) + (progn +(company-abort) +(company--unread-this-command-keys) +nil))) (defun company-complete-mouse (event) "Insert the candidate picked by the mouse." @@ -3066,14 +3054,14 @@ Returns a negative number if the tooltip should be displayed above point." (pre-command (company-pseudo-tooltip-hide-temporarily)) (post-command (unless (when (overlayp company-pseudo-tooltip-overlay) - (let* ((ov company-pseudo-tooltip-overlay) - (old-height (overlay-get ov 'company-height)) - (new-height (company--pseudo-tooltip-height))) -(and - (>= (* old-height new-height) 0) - (>= (abs old-height) (abs new-height)) - (equal (company-pseudo-tooltip-guard) -(overlay-get ov 'company-guard) + (let* ((ov company-pseudo-tooltip-overlay) + (old-height (overlay-get ov 'company-height)) + (new-height (company--pseudo-tooltip-height))) + (and + (>= (* old-height new-height) 0) + (>= (abs old-height) (abs new-height)) + (equal (company-pseudo-tooltip-guard) + (overlay-get ov 'company-guard) ;; Redraw needed. (company-pseudo-tooltip-show-at-point (point) (length company-prefix)) (overlay-put company-pseudo-tooltip-overlay @@ -3083,7 +3071,26 @@ Returns a negative number if the tooltip should be displayed above point." (hide (company-pse
[elpa] externals/company updated (123b604 -> c5c3b67)
elpasync pushed a change to branch externals/company. from 123b604 Merge branch 'master' of https://github.com/company-mode/company-mode into externals/company new 4f3a74b `company-select-mouse': per-frontend interface new 15767b8 Add NEWS entry new 5564a15 Refactor: `company-call-frontends': return a list new b728bd6 Merge pull request #1045 from nbfalcon/feature/company-select-mouse-per-frontend new c5c3b67 Minor touches Summary of changes: NEWS.md| 2 ++ company.el | 79 ++ 2 files changed, 45 insertions(+), 36 deletions(-)
[elpa] externals/company 15767b8 2/5: Add NEWS entry
branch: externals/company commit 15767b85bc46383e2ffd6329fb3b6b8da486bad7 Author: Nikita Bloshchanevich Commit: Nikita Bloshchanevich Add NEWS entry --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index 38ef038..4b5c254 100644 --- a/NEWS.md +++ b/NEWS.md @@ -27,6 +27,7 @@ ## 2020-07-26 (0.9.13) +* `company-select-mouse` is now a frontend action. * `company-clang`: error handling is more permissive. * `company-tng` stops disabling `post-completion` in backends ([#946](https://github.com/company-mode/company-mode/pull/946)). Instead,
[elpa] externals/company 5564a15 3/5: Refactor: `company-call-frontends': return a list
branch: externals/company commit 5564a15e5bfc48de53db85d406eac5a3f7646f8e Author: Nikita Bloshchanevich Commit: Nikita Bloshchanevich Refactor: `company-call-frontends': return a list `company-call-frontends' now returns a list of frontend return values and `company-set-selection' checks its return value for a truthy value using `cl-position' `identity'. --- company.el | 15 ++- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/company.el b/company.el index ac38996..6b00fec 100644 --- a/company.el +++ b/company.el @@ -1188,14 +1188,11 @@ can retrieve meta-data for them." (string-match-p "\\`company-" (symbol-name this-command))) (defun company-call-frontends (command) - (let (success) -(dolist (frontend company-frontends) - (condition-case-unless-debug err - (when (funcall frontend command) -(setq success t)) -(error (error "Company: frontend %s error \"%s\" on command %s" - frontend (error-message-string err) command -success)) + (cl-loop for frontend in company-frontends collect + (condition-case-unless-debug err + (funcall frontend command) + (error (error "Company: frontend %s error \"%s\" on command %s" + frontend (error-message-string err) command) (defun company-set-selection (selection &optional force-update) "Set SELECTION for company candidates. @@ -2162,7 +2159,7 @@ For use in the `select-mouse' frontend action. `let'-bound.") "Select the candidate picked by the mouse." (interactive "e") (or (let ((company-mouse-event event)) -(company-call-frontends 'select-mouse)) +(cl-position-if #'identity (company-call-frontends 'select-mouse))) (progn (company-abort) (company--unread-this-command-keys)
[elpa] externals/company c5c3b67 5/5: Minor touches
branch: externals/company commit c5c3b679a8362f74c9bd5d7cf6c122d5da535cd5 Author: Dmitry Gutov Commit: Dmitry Gutov Minor touches --- NEWS.md| 3 ++- company.el | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 4b5c254..7801b22 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,8 @@ ## Next +* `company-select-mouse` is a new frontend action + ([#1045](https://github.com/company-mode/company-mode/pull/1045)). * `company-gtags` on remote hosts is improved ([#1037](https://github.com/company-mode/company-mode/pull/1037)). * New commands `company-select-first` and `company-select-last`. @@ -27,7 +29,6 @@ ## 2020-07-26 (0.9.13) -* `company-select-mouse` is now a frontend action. * `company-clang`: error handling is more permissive. * `company-tng` stops disabling `post-completion` in backends ([#946](https://github.com/company-mode/company-mode/pull/946)). Instead, diff --git a/company.el b/company.el index ec0745c..37ccac8 100644 --- a/company.el +++ b/company.el @@ -2159,7 +2159,7 @@ For use in the `select-mouse' frontend action. `let'-bound.") "Select the candidate picked by the mouse." (interactive "e") (or (let ((company-mouse-event event)) -(cl-position-if #'identity (company-call-frontends 'select-mouse))) +(cl-some #'identity (company-call-frontends 'select-mouse))) (progn (company-abort) (company--unread-this-command-keys)