[Top][All Lists]

[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: Thu, 22 May 2003 22:52:45 -0500 (CDT)

The following version of kill-whole-line should work OK with the
kill-ring, including read-only buffers, and with invisible text.
It implements the version I referred to previously as "version2", but
other types of behavior could be implemented in a similar way, should
they be deemed more desirable.

Invisible text will work OK if you apply the patch to simple.el which
I sent yesterday and avoid using lists with two or more elements as
invisibility properties.  If you do the latter, the invisibility
related machinery of simple.el will malfunction.  This is a problem
unrelated to kill-whole-line, which can easily be solved by using a
corrected version of line-move-invisible, either the one I sent today,
or one from the C code, as Stefan suggested.

===File ~/newkwlversion2.el=================================
(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))
  (if (and (> arg 0) (eobp) (save-excursion (forward-visible-line 0) (eobp)))
      (signal 'end-of-buffer nil))
  (if (and (< arg 0) (bobp) (save-excursion (end-of-visible-line) (bobp)))
      (signal 'beginning-of-buffer nil))
  (unless (eq last-command 'kill-region)
    (kill-new "")
    (setq last-command 'kill-region))
  (cond ((zerop arg)
           (kill-region (point) (progn (forward-visible-line 0) (point))))
         (kill-region (point) (progn (end-of-visible-line) (point))))
        ((< arg 0)
           (kill-region (point) (progn (end-of-visible-line) (point))))
         (kill-region (point)
                      (progn (forward-visible-line (1+ arg))
                             (unless (bobp) (backward-char))
           (kill-region (point) (progn (forward-visible-line 0) (point))))
         (kill-region (point)
                      (progn (forward-visible-line arg) (point))))))


reply via email to

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