branch: externals/counsel commit aebf7b50221ea33074b62b0679512d2868dcfb2f Merge: e65cfaf9cf e9c0fb953d Author: Basil L. Contovounesios <conto...@tcd.ie> Commit: Basil L. Contovounesios <conto...@tcd.ie>
Merge branch 'master' into externals/counsel --- counsel.el | 81 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/counsel.el b/counsel.el index 329968976f..bd1c1b5bb3 100644 --- a/counsel.el +++ b/counsel.el @@ -354,13 +354,12 @@ Update the minibuffer with the amount of lines collected every ;;** `counsel-company' (defvar company-candidates) -(defvar company-common) -(defvar company-prefix) (declare-function company-abort "ext:company") (declare-function company-complete "ext:company") (declare-function company-mode "ext:company") (declare-function company-call-backend "ext:company") (declare-function company--clean-string "ext:company") +(declare-function company--continue "ext:company") ;;;###autoload (defun counsel-company () @@ -369,25 +368,15 @@ Update the minibuffer with the amount of lines collected every (company-mode 1) (unless company-candidates (company-complete)) - (let ((len (cond ((let (l) - (and company-common - (string= company-common - (buffer-substring - (- (point) (setq l (length company-common))) - (point))) - l))) - (company-prefix - (length company-prefix))))) - (when len - (setq ivy-completion-beg (- (point) len)) - (setq ivy-completion-end (point)) - (ivy-read "Candidate: " company-candidates - :action #'ivy-completion-in-region-action - :caller 'counsel-company)))) + (company--continue) + (when company-candidates + (ivy-read "Candidate: " company-candidates + :action 'company-finish + :caller 'counsel-company))) (ivy-configure 'counsel-company :display-transformer-fn #'counsel--company-display-transformer - :unwind-fn #'company-abort) + :unwind-fn (lambda() (unless ivy-exit (company-abort)))) (defun counsel--company-display-transformer (s) (concat s (let ((annot (company-call-backend 'annotation s))) @@ -1305,6 +1294,9 @@ Like `locate-dominating-file', but DIR defaults to "\0" t))) +(defvar counsel-git-history nil + "History for `counsel-git'.") + ;;;###autoload (defun counsel-git (&optional initial-input) "Find file in the current Git repository. @@ -1315,6 +1307,7 @@ INITIAL-INPUT can be given as the initial minibuffer input." (ivy-read "Find file: " (counsel-git-cands default-directory) :initial-input initial-input :action #'counsel-git-action + :history 'counsel-git-history :caller 'counsel-git))) (ivy-configure 'counsel-git @@ -4499,24 +4492,27 @@ mark, as per \\[universal-argument] \\[yank]." "Like `yank-pop', but insert the kill corresponding to S. Signal a `buffer-read-only' error if called from a read-only buffer position." - (with-ivy-window - (barf-if-buffer-read-only) - (setq yank-window-start (window-start)) - (unless (eq last-command 'yank) - ;; Avoid unexpected deletions with `yank-handler' properties. - (setq yank-undo-function nil)) - (condition-case nil - (let (;; Deceive `yank-pop'. - (last-command 'yank) - ;; Avoid unexpected additions to `kill-ring'. - interprogram-paste-function) - (yank-pop (counsel--yank-pop-position s))) - (error - ;; Support strings not present in the kill ring. - (insert s))) - (when (funcall (if counsel-yank-pop-after-point #'> #'<) - (point) (mark t)) - (exchange-point-and-mark t)))) + (when (and (eq major-mode 'vterm-mode) + (fboundp 'vterm-insert)) + (let ((inhibit-read-only t)) + (vterm-insert s))) + (barf-if-buffer-read-only) + (setq yank-window-start (window-start)) + (unless (eq last-command 'yank) + ;; Avoid unexpected deletions with `yank-handler' properties. + (setq yank-undo-function nil)) + (condition-case nil + (let (;; Deceive `yank-pop'. + (last-command 'yank) + ;; Avoid unexpected additions to `kill-ring'. + interprogram-paste-function) + (yank-pop (counsel--yank-pop-position s))) + (error + ;; Support strings not present in the kill ring. + (insert s))) + (when (funcall (if counsel-yank-pop-after-point #'> #'<) + (point) (mark t)) + (exchange-point-and-mark t))) (defun counsel-yank-pop-action-remove (s) "Remove all occurrences of S from the kill ring." @@ -4696,6 +4692,7 @@ S will be of the form \"[register]: content\"." (defvar imenu-auto-rescan-maxout) (declare-function imenu--subalist-p "imenu") (declare-function imenu--make-index-alist "imenu") +(declare-function python-imenu-create-flat-index "python") (defun counsel--imenu-candidates () (require 'imenu) @@ -4705,9 +4702,12 @@ S will be of the form \"[register]: content\"." imenu-auto-rescan-maxout)) (items (imenu--make-index-alist t)) (items (delete (assoc "*Rescan*" items) items)) - (items (if (eq major-mode 'emacs-lisp-mode) - (counsel-imenu-categorize-functions items) - items))) + (items (cond ((eq major-mode 'emacs-lisp-mode) + (counsel-imenu-categorize-functions items)) + ((eq major-mode 'python-mode) + (python-imenu-create-flat-index)) + (t + items)))) (counsel-imenu-get-candidates-from items))) (defun counsel-imenu-get-candidates-from (alist &optional prefix) @@ -4747,8 +4747,7 @@ PREFIX is used to create the key." items))) (defun counsel-imenu-action (x) - (with-ivy-window - (imenu (cdr x)))) + (imenu (cdr x))) (defvar counsel-imenu-history nil "History for `counsel-imenu'.")