emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/crux 3b377b4 054/112: Add smart kill line function


From: ELPA Syncer
Subject: [nongnu] elpa/crux 3b377b4 054/112: Add smart kill line function
Date: Wed, 11 Aug 2021 09:57:52 -0400 (EDT)

branch: elpa/crux
commit 3b377b4fdd23df35f72bcb1021800d41fdccf863
Author: Adam Hess <adamhess1991@gmail.com>
Commit: Bozhidar Batsov <bozhidar.batsov@gmail.com>

    Add smart kill line function
---
 README.md |  1 +
 crux.el   | 13 +++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/README.md b/README.md
index 0f45a6f..e763da5 100644
--- a/README.md
+++ b/README.md
@@ -43,6 +43,7 @@ individual commands to whatever keybindings you prefer.
 Command                                             | Suggested Keybinding(s)  
       | Description
 
----------------------------------------------------|---------------------------------|------------------------
 `crux-open-with`                                    | <kbd>C-c o</kbd>   | 
Open the currently visited file with an external program.
+`crux-smart-kill-line`                              | <kbd>C-k</kbd> or 
<kbd>Super-k</kbd> | First kill to end of line, then kill the whole line.
 `crux-smart-open-line-above`                        | <kbd>C-S-RET</kbd> or 
<kbd>Super-o</kbd> | Insert an empty line above the current line and indent it 
properly.
 `crux-smart-open-line`                              | <kbd>S-RET</kbd> or 
<kbd>M-o</kbd> | Insert an empty line and indent it properly (as in most IDEs).
 `crux-cleanup-buffer-or-region`                     | <kbd>C-c n</kbd> | Fix 
indentation in buffer and strip whitespace.
diff --git a/crux.el b/crux.el
index 3ed126d..8050cdf 100644
--- a/crux.el
+++ b/crux.el
@@ -180,6 +180,19 @@ With a prefix ARG open line above the current line."
       (move-end-of-line nil)
       (newline-and-indent))))
 
+(defun crux-smart-kill-line (arg)
+  "Kill to the end of the line and kill whole line on the next call"
+  (interactive "P")
+  (let ((orig-point (point)))
+    (move-end-of-line 1)
+    (if (= orig-point (point))
+        (crux-kill-whole-line)
+      (progn
+        (goto-char orig-point)
+        (kill-line))
+      )))
+
+
 (defun crux-top-join-line ()
   "Join the current line with the line beneath it."
   (interactive)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]