From beac22d87f16ad576d25e334b0869b09dd0e922f Mon Sep 17 00:00:00 2001 From: TLINDEN Date: Tue, 17 May 2016 19:11:06 +0200 Subject: [PATCH] final tests ok, some tweaks to the docs --- README.md | 19 ++++++++++++++----- viking-mode.el | 21 ++++++++++++--------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index ac8184e..c28620e 100644 --- a/README.md +++ b/README.md @@ -17,14 +17,13 @@ shortly. The default key binding is C-d, but you may also bind it to C-k or whatever you wish. -If you press C-d the first time, the word at point will be deleted. -If you press it again, the remainder of the line from point will be -deleted. If pressed again, the whole line, then the paragraph and -finally the whole buffer will be deleted. +If you press C-d the first time, the word at point will be deleted +(but if there's no word at point but whitespaces or an empty line, +they will be deleted instead, which is the same as M-SPC). Like: - [keep pressing ctrl] C-d - word + [keep pressing ctrl] C-d - word | spc C-d C-d - line remainder C-d C-d C-d - line C-d C-d C-d C-d - paragraph @@ -33,6 +32,11 @@ Like: However, this only works when pressing the key in a row. If you do something else in between, it starts from scratch (i.e. delete word). +By default viking-mode is greedy: after applying a kill function it +looks if point ends up alone on an empty line or inside whitespaces. +In such a case, those will be deleted as well. The greedy behavior may +be turned off however. + # Install To use, save viking-mode.el to a directory in your load-path. @@ -58,6 +62,11 @@ it into berserk mode by setting 'viking-really-delete to t: (setq viking-really-delete t) +To turn off greedy deleting of whitespace remainders, set +'viking-greedy-kill to nil: + + (setq viking-greedy-kill nil) + You can change the default key binding by: (define-key viking-mode-map (kbd "C-k") 'viking-kill-thing-at-point) diff --git a/viking-mode.el b/viking-mode.el index a61a145..c80d064 100644 --- a/viking-mode.el +++ b/viking-mode.el @@ -19,7 +19,7 @@ ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 ;; USA -;; Version: 0.03.TEST +;; Version: 0.03 ;; Author: T.v.Dein ;; Keywords: kill delete ;; URL: https://github.com/tlinden/viking-mode @@ -36,8 +36,8 @@ ;; whatever you wish. ;; If you press C-d the first time, the word at point will be deleted -;; (but if there's no word at point but whitespaces or an empty line), -;; they will be deleted instead, which is the same as M-SPC. +;; (but if there's no word at point but whitespaces or an empty line, +;; they will be deleted instead, which is the same as M-SPC). ;; If you press C-d again, the remainder of the line from point will ;; be deleted. If pressed again, the whole line, then the paragraph @@ -166,7 +166,7 @@ ;;; Code: ;;;; Consts -(defconst viking-mode-version "0.02" "Viking Mode version.") +(defconst viking-mode-version "0.03" "Viking Mode version.") (defgroup viking-mode nil "Kill first, ask later - an emacs mode for killing things quickly" @@ -292,13 +292,16 @@ should be a point-moving function." (message "word right of point deleted"))) (defun viking--kill-space() + ;; FIXME: might be better to implement this myself + ;; so that all space+newlines will be deleted but + ;; the last one, which is sometimes better... "Kill space around point, including newline(s)." (interactive) - (let ((beg (save-excursion (skip-chars-backward " \t\r\n") (point))) - (end (save-excursion (skip-chars-forward " \t\r\n") (point)))) - (viking--blink-region beg end)) - (just-one-space -1) - (message "spaces cleared")) + (let ((beg (save-excursion (skip-chars-backward " \t\r\n") (point))) + (end (save-excursion (skip-chars-forward " \t\r\n") (point)))) + (viking--blink-region beg end)) + (just-one-space -1) + (message "spaces cleared")) ;;;;; Public interactive kill functions