Commit f8c5d840938c

Vincent Demeester <vincent@sbr.pm>
2016-08-25 18:05:56
Add some ivy customizations
- make sure ivy-hydra is installed - add a alternate implementation of ivy-yank-word Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent afde7d1
Changed files (1)
.emacs.d
.emacs.d/emacs.org
@@ -2389,6 +2389,8 @@
     :diminish ivy-mode
     :bind (("C-c C-r" . ivy-resume))
     :config
+    (use-package ivy-hydra
+      :ensure t)
     (ido-mode -1)
     ;; Enable ivy
     (ivy-mode 1)
@@ -2414,6 +2416,29 @@
     )
 #+END_SRC
 
+Add a small customization to ivy-yank word.
+
+#+BEGIN_SRC emacs-lisp
+  ;; version of ivy-yank-word to yank from start of word
+  (defun bjm/ivy-yank-whole-word ()
+    "Pull next word from buffer into search string."
+    (interactive)
+    (let (amend)
+      (with-ivy-window
+        ;;move to last word boundary
+        (re-search-backward "\\b")
+        (let ((pt (point))
+              (le (line-end-position)))
+          (forward-word 1)
+          (if (> (point) le)
+              (goto-char pt)
+            (setq amend (buffer-substring-no-properties pt (point))))))
+      (when amend
+        (insert (replace-regexp-in-string " +" " " amend)))))
+
+  ;; bind it to M-j
+  (define-key ivy-minibuffer-map (kbd "M-j") 'bjm/ivy-yank-whole-word)
+#+END_SRC
 
 #+BEGIN_SRC emacs-lisp
   (use-package swiper