all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ole Laursen <olau@hardworking.dk>
Subject: Re: how to delete a line without putting them into yanking?
Date: Thu, 09 Sep 2004 22:28:27 +0200	[thread overview]
Message-ID: <87fz5rfaqc.fsf@bach.composers> (raw)
In-Reply-To: mailman.2064.1094701218.1998.help-gnu-emacs@gnu.org

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/

  parent reply	other threads:[~2004-09-09 20:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-09  1:43 how to delete a line without putting them into yanking? Rokia
2004-09-09  1:55 ` maddog
2004-09-09  2:17 ` emacs Fan
     [not found] ` <mailman.2061.1094696629.1998.help-gnu-emacs@gnu.org>
2004-09-09  2:42   ` Rokia
2004-09-09  3:03   ` Rokia
2004-09-09  3:34     ` emacs Fan
     [not found]     ` <mailman.2064.1094701218.1998.help-gnu-emacs@gnu.org>
2004-09-09  6:08       ` Rokia
2004-09-09 20:28       ` Ole Laursen [this message]
2004-09-10  8:54         ` Rokia
2004-09-10 13:04           ` J. David Boyd
2004-09-10 14:51           ` Mathias Dahl
2004-09-10 15:14           ` Michael Slass
2004-09-10 15:06         ` emacs Fan
2004-09-09  4:07 ` Eli Zaretskii
2004-09-09  4:30   ` emacs Fan
     [not found]   ` <mailman.2075.1094704580.1998.help-gnu-emacs@gnu.org>
2004-09-09  6:10     ` Rokia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fz5rfaqc.fsf@bach.composers \
    --to=olau@hardworking.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.