[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to delete a line without putting them into yanking?
From: |
Ole Laursen |
Subject: |
Re: how to delete a line without putting them into yanking? |
Date: |
Thu, 09 Sep 2004 22:28:27 +0200 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
emacs Fan <emacsNT@gmail.com> writes:
[...]
> 3. write a lisp function to delete the path line, not kill it.
Here's one. Just put in your Emacs file and bind it to some key with
something alongs:
(global-set-key (kbd "C-c d") 'delete-line)
;; for some reason Emacs lacks delete-line, implementing it with the
;; source from kill-line is, however, trivial
(defun delete-line (&optional arg)
"Delete the rest of the current line; if no nonblanks there, delete
thru newline. With prefix argument, delete that many lines from point.
Negative arguments delete lines backward.
When calling from a program, nil means \"no arg\", a number counts as
a prefix arg.
To delete a whole line, when point is not at the beginning, type \
\\[beginning-of-line] \\[delete-line] \\[delete-line].
If `kill-whole-line' is non-nil, then this command deletes the whole line
including its terminating newline, when used at the beginning of a line
with no argument. As a consequence, you can always delete a whole line
by typing \\[beginning-of-line] \\[delete-line]."
(interactive "P")
(delete-region (point)
;; It is better to move point to the other end of the
;; delete before deleting. That way, in a read-only
;; buffer, point moves across the text that is to be
;; delete. The choice has no effect on undo now that
;; undo records the value of point from before the
;; command was run.
(progn
(if arg
(forward-visible-line (prefix-numeric-value arg))
(if (eobp)
(signal 'end-of-buffer nil))
(if (or (looking-at "[ \t]*$") (and kill-whole-line (bolp)))
(forward-visible-line 1)
(end-of-visible-line)))
(point))))
--
Ole Laursen
http://www.cs.aau.dk/~olau/
- how to delete a line without putting them into yanking?, Rokia, 2004/09/08
- Message not available
- Re: how to delete a line without putting them into yanking?, Rokia, 2004/09/08
- Message not available
- Re: how to delete a line without putting them into yanking?,
Ole Laursen <=
- Re: how to delete a line without putting them into yanking?, Rokia, 2004/09/10
- Re: how to delete a line without putting them into yanking?, Mathias Dahl, 2004/09/10
- Re: how to delete a line without putting them into yanking?, Michael Slass, 2004/09/10
- Re: how to delete a line without putting them into yanking?, J. David Boyd, 2004/09/10
- Re: how to delete a line without putting them into yanking?, emacs Fan, 2004/09/10
Re: how to delete a line without putting them into yanking?, Eli Zaretskii, 2004/09/09