d$ and c$ should not delete empty lines

Max Mikhanosha max at openchat.com
Sun Jul 10 15:52:06 CEST 2011


In vi/vim when you press c$ or d$ on an empty line, it does not delete
the line, but vimpulse.el does.

It makes it impossible to record keyboard macros that use c$ or d$
command, since you never know if line will be deleted or not (ie if
line has single space, it will not be deleted, otherwise it will).

Following patch fixes the problem, and makes it work like vim.

diff -r c8fad78272a5 -r 192808962006 elisp/vimpulse.el
--- a/elisp/vimpulse.el	Mon Jul 04 13:18:15 2011 -0400
+++ b/elisp/vimpulse.el	Sun Jul 10 09:45:30 2011 -0400
@@ -2854,7 +2854,12 @@
          (end (max from to)))
     (save-excursion
       (goto-char end)
-      (unless (eobp)
+      (unless (or (eobp)
+                  ;; do not extend the range on empty lines
+                  ;; this prevents c$  or d$ from deleting
+                  ;; the EOL character
+                  (and (= beg end)
+                       (eolp)))
         (setq end (1+ end)))
       (vimpulse-make-motion-range beg end 'inclusive))))
 



More information about the implementations-list mailing list