]> code.delx.au - gnu-emacs-elpa/commitdiff
counsel.el (counsel-unicode-char): Add own history
authorOleh Krehel <ohwoeowho@gmail.com>
Wed, 9 Sep 2015 13:21:43 +0000 (15:21 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Wed, 9 Sep 2015 13:21:43 +0000 (15:21 +0200)
Also make "C-M-n", "C-M-p", and `ivy-resume' work properly.

counsel.el

index a4b47d9429ed4b5699d59d7173071fc9e12eebfb..7d2745a0eba570ad0032609d67d3ceb1d4192b4f 100644 (file)
   (require 'info-look)
   (info-lookup 'symbol symbol mode))
 
+(defvar counsel-unicode-char-history nil
+  "History for `counsel-unicode-char'.")
+
 ;;;###autoload
 (defun counsel-unicode-char ()
   "Insert a Unicode character at point."
   (interactive)
   (let ((minibuffer-allow-text-properties t))
+    (setq counsel-completion-beg (point))
+    (setq counsel-completion-end (point))
     (ivy-read "Unicode name: "
               (mapcar (lambda (x)
                         (propertize
                          'result (cdr x)))
                       (ucs-names))
               :action (lambda (char)
-                        (insert-char (get-text-property 0 'result char))))))
+                        (with-ivy-window
+                          (delete-region counsel-completion-beg counsel-completion-end)
+                          (setq counsel-completion-beg (point))
+                          (insert-char (get-text-property 0 'result char))
+                          (setq counsel-completion-end (point))))
+              :history 'counsel-unicode-char-history)))
 
 (declare-function cider-sync-request:complete "ext:cider-client")
 ;;;###autoload