aboutsummaryrefslogtreecommitdiff
path: root/Emacs
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2020-08-09 17:23:15 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2020-08-09 17:23:15 +0100
commit2fd2149b599c26403f6ef2acea3e072aa759fb16 (patch)
tree68c7f1a08939e1e021ddd26f44e24a0bb2e8fdb1 /Emacs
parent6b289457fb6cc55ff812e5293fa0a12d9935005a (diff)
downloaddotfiles-2fd2149b599c26403f6ef2acea3e072aa759fb16.tar.gz
dotfiles-2fd2149b599c26403f6ef2acea3e072aa759fb16.tar.bz2
dotfiles-2fd2149b599c26403f6ef2acea3e072aa759fb16.zip
+delete a sentence in auto fill
Basically adds the functionality necessary to delete sentences in auto fill mode, where it may not be possible with simple vim motions and where Emacs functions kill the paragraph.
Diffstat (limited to 'Emacs')
-rw-r--r--Emacs/.config/emacs/config.org34
1 files changed, 34 insertions, 0 deletions
diff --git a/Emacs/.config/emacs/config.org b/Emacs/.config/emacs/config.org
index fa419c4..1eed583 100644
--- a/Emacs/.config/emacs/config.org
+++ b/Emacs/.config/emacs/config.org
@@ -763,6 +763,40 @@ Auto fill mode is nice for most text modes, 80 char limit is great.
#+BEGIN_SRC emacs-lisp
(add-hook 'text-mode-hook #'auto-fill-mode)
#+END_SRC
+** Delete a sentence in auto fill
+In long lines via truncate lines, deleting till the end of the
+sentence was easy via vim motions. However, the same action is
+difficult with auto-fill-mode where sentences are separated through
+(potentially several) newlines which makes vim motions
+difficult. Thus, I propose some form of functionality which allows you
+to:
+
+- Find the next closest period denoting the end of the sentence
+- Delete the region between the point of invocation and the found period
+
+This essentially does the same task as vim motion based deletion, but
+can handle the newlines. To not trample on the toes of any package,
+I'll set it to "M-d" (kill-word), the most inoffensive binding
+possible which is still mnemonic.
+
+First, the function. I'll use search-forward (from zap* lib) to find
+the period. Then auto-fill to make it look nice.
+#+BEGIN_SRC emacs-lisp
+(defun +text/delete-till-sentence ()
+ "Delete all text from current point to the next closest period."
+ (interactive)
+ (set-mark-command nil)
+ (search-forward ". ")
+ (kill-region (region-beginning) (region-end))
+ (fill-paragraph))
+#+END_SRC
+
+Now, the binding
+#+BEGIN_SRC emacs-lisp
+(general-def
+ :states '(normal insert)
+ (kbd "M-d") #'+text/delete-till-sentence)
+#+END_SRC
* Org
** Org default with evil
Setup for org mode, currently basically nothing. Has evil-org for