emacs-devel
[Top][All Lists]
Advanced

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

Re: Various simple.el patches


From: Luc Teirlinck
Subject: Re: Various simple.el patches
Date: Sun, 18 May 2003 21:11:18 -0500 (CDT)

Kai Grossjohann wrote:

   Good :-)  Here is a proposed patch.  I'm not sure if I did it right.
   Somehow I get the feeling that using kill-line was not the right
   thing to do.

The use of kill-line does not bother me personally, but in terms of
the functionality there are two lines I would like to add to the code.
More precisely:

     ((< arg 0)
      (forward-visible-line 1)
      (kill-line arg)
      (unless (bobp) (forward-visible-line -1)))

The reasons for adding the last line are that it looks more intuitive
for point to move backward while killing backward, that this way there
is a differentiation between numeric arguments of 1 and -1, and most
importantly that one can do M--1 S-<backspace> C-x z z z z...

            (t
             (forward-visible-line 0)
             (if (eobp)
                 (signal 'end-of-buffer nil)
               (kill-line arg)))))

Because you call kill-line with an argument, there is, unlike for C-k,
no warning at the end of the buffer.  I have personally
default-indicate-empty-lines set to t, but with the default value of
nil, the warning at the end of the buffer is really essential while
killing invisible empty lines at the end of the buffer.  Otherwise,
one does not know when to stop.

With the two added lines the function becomes:

(defun kill-whole-line (&optional arg)
  "Kill current line.
With prefix arg, kill that many lines from point.
If arg is negative, kill backwards.
If arg is zero, kill current line but exclude the trailing newline."
  (interactive "P")
  (setq arg (prefix-numeric-value arg))
  (cond ((zerop arg)
         (kill-region (progn (forward-visible-line 0) (point))
                      (progn (end-of-visible-line) (point))))
        ((< arg 0)
         (forward-visible-line 1)
         (kill-line arg)
         (unless (bobp) (forward-visible-line -1)))
        (t
         (forward-visible-line 0)
         (if (eobp)
             (signal 'end-of-buffer nil)
           (kill-line arg)))))

Sincerely,

Luc.




reply via email to

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