fixed the other issue in #2: when deleting whitespace, continue with kill-word, as a side-effect, the order of kill funcs to be called is now customizable

This commit is contained in:
git@daemon.de
2016-05-25 14:16:42 +02:00
parent 233d45bf4f
commit d80c032657

View File

@@ -210,7 +210,12 @@ deleted after the kill function, if any. Uses 'just-one-space."
mark is set." mark is set."
:group 'viking-mode) :group 'viking-mode)
(defcustom viking-kill-funcs (list 'viking-kill-word 'viking-kill-line-from-point 'viking-kill-line 'viking-kill-paragraph 'viking-kill-buffer)
"The actual kill functions being called in a row starting with the first entry"
:group 'viking-mode)
;; internal copy
(defvar viking--current-killf ())
;;;; Functions ;;;; Functions
@@ -260,6 +265,7 @@ should be a point-moving function."
(looking-at "[[:space:]]+") (looking-at "[[:space:]]+")
(eq (point) (line-end-position)))) (eq (point) (line-end-position))))
;;;;; kill/delete wrappers ;;;;; kill/delete wrappers
(defun viking--kill-region (beg end) (defun viking--kill-region (beg end)
@@ -335,6 +341,17 @@ should be a point-moving function."
(message "region deleted")) (message "region deleted"))
(defun viking--killw (count)
"execute kill function from the list of kill functions in
'viking--current-killf, reset it to the contents of
'viking-kill-funcs if COUNT is 1 (thus the command key has been
pressed the first time in a row"
(if (eq count 1) ; start from scratch
(setq viking--current-killf viking-kill-funcs))
(if viking--current-killf ; only call killer if not done killing
(funcall (pop viking--current-killf))))
;;;;; Public interactive kill functions ;;;;; Public interactive kill functions
(defun viking-kill-word () (defun viking-kill-word ()
@@ -345,11 +362,14 @@ If 'viking-greedy-kill is t, clean up spaces and newlines afterwards."
(viking-kill-region) ;; region-kill can only happen on first C-d invokation (viking-kill-region) ;; region-kill can only happen on first C-d invokation
;; else normal processing ;; else normal processing
(if (viking--point-is-in-space) (if (viking--point-is-in-space)
(viking--kill-space) (progn
(viking--kill-space)
;; reset kill func list:
(setq viking--current-killf viking-kill-funcs))
(progn (progn
(if (or (eq (point) (line-beginning-position)) (if (or (eq (point) (line-beginning-position))
(looking-back "[ \t]")) (memq (preceding-char) '(?\t ?\ )))
(viking--kill-word-right) (viking--kill-word-right)
(viking--kill-word-at-point) (viking--kill-word-at-point)
) )
@@ -413,20 +433,14 @@ If 'viking-greedy-kill is t, clean up spaces and newlines afterwards."
;;;;; Primary key binding function ;;;;; Primary key binding function
(defun viking-kill-thing-at-point() (defun viking-kill-thing-at-point()
"Delete thing at point. Checks how many times the "Delete thing at point. Checks how many times the
calling key has been pressed and runs the appropriate calling key has been pressed and runs the appropriate
kill function then." kill function then."
(interactive) (interactive)
(let* ((key-times (viking-last-key-repeats))) (viking--killw (viking-last-key-repeats)))
(cond
((eq key-times 5) (viking-kill-buffer))
((eq key-times 4) (viking-kill-paragraph))
((eq key-times 3) (viking-kill-line))
((eq key-times 2) (viking-kill-line-from-point))
((eq key-times 1) (viking-kill-word))
)
))
;;;; Interface ;;;; Interface
;;;###autoload ;;;###autoload