/[emacs]/emacs/lisp/simple.el
ViewVC logotype

Diff of /emacs/lisp/simple.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.607 by kai, Wed May 28 20:07:09 2003 UTC revision 1.608 by teirllm, Thu May 29 23:29:29 2003 UTC
# Line 2210  even beep.)" Line 2210  even beep.)"
2210    
2211  (defun kill-whole-line (&optional arg)  (defun kill-whole-line (&optional arg)
2212    "Kill current line.    "Kill current line.
2213  With prefix arg, kill that many lines from point.  With prefix arg, kill that many lines starting from the current line.
2214  If arg is negative, kill backwards.  If arg is negative, kill backward.  Also kill the preceding newline.
2215    \(This is meant to make C-x z work well with negative arguments.\)
2216  If arg is zero, kill current line but exclude the trailing newline."  If arg is zero, kill current line but exclude the trailing newline."
2217    (interactive "P")    (interactive "P")
2218    (setq arg (prefix-numeric-value arg))    (setq arg (prefix-numeric-value arg))
2219      (if (and (> arg 0) (eobp) (save-excursion (forward-visible-line 0) (eobp)))
2220          (signal 'end-of-buffer nil))
2221      (if (and (< arg 0) (bobp) (save-excursion (end-of-visible-line) (bobp)))
2222          (signal 'beginning-of-buffer nil))
2223      (unless (eq last-command 'kill-region)
2224        (kill-new "")
2225        (setq last-command 'kill-region))
2226    (cond ((zerop arg)    (cond ((zerop arg)
2227           (kill-region (point) (progn (forward-visible-line 0) (point)))           ;; We need to kill in two steps, because the previous command
2228             ;; could have been a kill command, in which case the text
2229             ;; before point needs to be prepended to the current kill
2230             ;; ring entry and the text after point appended.  Also, we
2231             ;; need to use save-excursion to avoid copying the same text
2232             ;; twice to the kill ring in read-only buffers.
2233             (save-excursion
2234               (kill-region (point) (progn (forward-visible-line 0) (point))))
2235           (kill-region (point) (progn (end-of-visible-line) (point))))           (kill-region (point) (progn (end-of-visible-line) (point))))
2236          ((< arg 0)          ((< arg 0)
2237           (kill-line 1)           (save-excursion
2238           (kill-line (1+ arg))             (kill-region (point) (progn (end-of-visible-line) (point))))
2239           (unless (bobp) (forward-visible-line -1)))           (kill-region (point)
2240                          (progn (forward-visible-line (1+ arg))
2241                                 (unless (bobp) (backward-char))
2242                                 (point))))
2243          (t          (t
2244           (kill-line 0)           (save-excursion
2245           (if (eobp)             (kill-region (point) (progn (forward-visible-line 0) (point))))
2246               (signal 'end-of-buffer nil)           (kill-region (point)
2247             (kill-line arg)))))                        (progn (forward-visible-line arg) (point))))))
2248    
2249  (defun forward-visible-line (arg)  (defun forward-visible-line (arg)
2250    "Move forward by ARG lines, ignoring currently invisible newlines only.    "Move forward by ARG lines, ignoring currently invisible newlines only.

Legend:
Removed from v.1.607  
changed lines
  Added in v.1.608

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26