]> code.delx.au - gnu-emacs-elpa/commitdiff
ivy.el (ivy-kill-line): Add and bind to "C-k"
authorOleh Krehel <ohwoeowho@gmail.com>
Fri, 19 Jun 2015 09:07:07 +0000 (11:07 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Fri, 19 Jun 2015 09:07:07 +0000 (11:07 +0200)
The only difference to `kill-line' is that it will kill the whole input
when at the end of the minibuffer. In that case, the regular `kill-line'
was extending into the second line of the minibuffer, which is
unacceptable.

ivy.el

diff --git a/ivy.el b/ivy.el
index 4facc63995508fdb1723ec07f468a517c633cc06..377fed3a20dfb556dc19f40169b28c84df269cab 100644 (file)
--- a/ivy.el
+++ b/ivy.el
@@ -124,6 +124,7 @@ Only \"./\" and \"../\" apply here. They appear in reverse order."
     (define-key map (kbd "M-j") 'ivy-yank-word)
     (define-key map (kbd "M-i") 'ivy-insert-current)
     (define-key map (kbd "C-o") 'hydra-ivy/body)
+    (define-key map (kbd "C-k") 'ivy-kill-line)
     map)
   "Keymap used in the minibuffer.")
 (autoload 'hydra-ivy/body "ivy-hydra" "" t)
@@ -589,6 +590,13 @@ On error (read-only), call `ivy-on-del-error-function'."
   (unless (= (point) (line-end-position))
     (kill-word arg)))
 
+(defun ivy-kill-line ()
+  "Forward to `kill-line'."
+  (interactive)
+  (if (eolp)
+      (kill-region (minibuffer-prompt-end) (point))
+    (kill-line)))
+
 (defun ivy-backward-kill-word ()
   "Forward to `backward-kill-word'."
   (interactive)