[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 5036f23 87/90: Make counsel-el work with "C-M-n" and "C-M-
From: |
Oleh Krehel |
Subject: |
[elpa] master 5036f23 87/90: Make counsel-el work with "C-M-n" and "C-M-p" |
Date: |
Tue, 30 Jun 2015 07:29:38 +0000 |
branch: master
commit 5036f23055436acb171e9cfb1b5ad5ad3578ed76
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Make counsel-el work with "C-M-n" and "C-M-p"
* counsel.el (counsel-el): Use the whole obarray if no initial input is
given. Filter out only function when appropriate.
(counsel-completion-beg): New defvar.
(counsel-completion-end): New defvar.
(counsel--el-action): New defun.
* ivy.el (ivy--reset-state): Set `ivy--full-length' to nil.
---
counsel.el | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
ivy.el | 1 +
2 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/counsel.el b/counsel.el
index c2d67d6..acc4ca5 100644
--- a/counsel.el
+++ b/counsel.el
@@ -38,8 +38,61 @@
(defun counsel-el ()
"Elisp completion at point."
(interactive)
- (counsel--generic
- (lambda (str) (all-completions str obarray))))
+ (let* ((bnd (unless (and (looking-at ")")
+ (eq (char-before) ?\())
+ (bounds-of-thing-at-point
+ 'symbol)))
+ (str (if bnd
+ (buffer-substring-no-properties
+ (car bnd)
+ (cdr bnd))
+ ""))
+ (ivy-height 7)
+ (funp (eq (char-before (car bnd)) ?\())
+ symbol-names)
+ (if bnd
+ (progn
+ (setq counsel-completion-beg
+ (move-marker (make-marker) (car bnd)))
+ (setq counsel-completion-end
+ (move-marker (make-marker) (cdr bnd))))
+ (setq counsel-completion-beg nil)
+ (setq counsel-completion-end nil))
+ (if (string= str "")
+ (mapatoms
+ (lambda (x)
+ (when (symbolp x)
+ (push (symbol-name x) symbol-names))))
+ (setq symbol-names
+ (all-completions str obarray
+ (and funp
+ (lambda (x)
+ (or (functionp x)
+ (macrop x)
+ (special-form-p x)))))))
+ (ivy-read "Symbol name: " symbol-names
+ :predicate (and funp #'functionp)
+ :initial-input str
+ :action #'counsel--el-action)))
+
+(defvar counsel-completion-beg nil
+ "Completion bounds start.")
+
+(defvar counsel-completion-end nil
+ "Completion bounds end.")
+
+(defun counsel--el-action (symbol)
+ "Insert SYMBOL, erasing the previous one."
+ (when (stringp symbol)
+ (when counsel-completion-beg
+ (delete-region
+ counsel-completion-beg
+ counsel-completion-end))
+ (setq counsel-completion-beg
+ (move-marker (make-marker) (point)))
+ (insert symbol)
+ (setq counsel-completion-end
+ (move-marker (make-marker) (point)))))
(defvar counsel-describe-map
(let ((map (make-sparse-keymap)))
diff --git a/ivy.el b/ivy.el
index 12b1ad2..f64782c 100644
--- a/ivy.el
+++ b/ivy.el
@@ -815,6 +815,7 @@ This is useful for recursive `ivy-read'."
(setq ivy--subexps 0)
(setq ivy--regexp-quote 'regexp-quote)
(setq ivy--old-text "")
+ (setq ivy--full-length nil)
(setq ivy-text "")
(setq ivy-calling nil)
(let (coll sort-fn)
- [elpa] master b12e30c 77/90: Fix last commit being incompatible with older Emacs, (continued)
- [elpa] master b12e30c 77/90: Fix last commit being incompatible with older Emacs, Oleh Krehel, 2015/06/30
- [elpa] master 337a1d0 73/90: ivy.el (ivy-initial-inputs-alist): Add some Org commands, Oleh Krehel, 2015/06/30
- [elpa] master d921875 79/90: counsel.el (counsel-load-theme): New command, Oleh Krehel, 2015/06/30
- [elpa] master 017e007 78/90: counsel.el (counsel-M-x): Avoid compilation warning, Oleh Krehel, 2015/06/30
- [elpa] master 64b76c3 81/90: Fixup compilation warnings related to smex, Oleh Krehel, 2015/06/30
- [elpa] master 225e5aa 82/90: Allow to recursively match history with "C-r", Oleh Krehel, 2015/06/30
- [elpa] master dcd0c50 80/90: counsel.el (counsel-unicode-char): Use action-style call, Oleh Krehel, 2015/06/30
- [elpa] master a287f39 84/90: counsel.el (counsel-git-grep-history): New defvar, Oleh Krehel, 2015/06/30
- [elpa] master e072e96 83/90: swiper.el (swiper-history): New defvar, Oleh Krehel, 2015/06/30
- [elpa] master be80798 86/90: Fix the initial input bug introduced with "C-r", Oleh Krehel, 2015/06/30
- [elpa] master 5036f23 87/90: Make counsel-el work with "C-M-n" and "C-M-p",
Oleh Krehel <=
- [elpa] master c33bb2d 88/90: ivy-hydra.el (hydra-ivy): Bind "C-o" to be a toggle, Oleh Krehel, 2015/06/30
- [elpa] master e953099 89/90: Make counsel-locate use a process, Oleh Krehel, 2015/06/30
- [elpa] master e503688 85/90: counsel.el (counsel-find-file): Use `file-name-history', Oleh Krehel, 2015/06/30
- [elpa] master 55e0188 90/90: Merge commit 'e9530990914c1d81889269b4a8365b8003625557' from swiper, Oleh Krehel, 2015/06/30