help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: How to delete all text from beginning of buffer to mark


From: Emanuel Berg
Subject: Re: How to delete all text from beginning of buffer to mark
Date: Tue, 09 May 2017 04:04:36 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Yuri Khan wrote:

>> What is the best way to basically delete all
>> text before the cursor in the buffer?
>
> Ctrl+Shift+Home, Del. <ducks>
>
> * Nitpicker’s corner: This works if you are
> in a GUI frame and have transient-mark-mode
> and delete-selection-mode enabled.

I agree the *best* way to do this is to use
shortcuts. Tho not the particular ones
suggested here :)

Here is an Elisp function for the OP.
Tho shortcuts are better, because they are as
fast and in the long run generalizable, so in
the long (short) run it is much more beneficial
to acquire them for all kinds of editing.

However it can be interesting to discuss
a function:

    (defun delete-to-point ()
      (interactive)
      (let ((start 1)
            (end   (point)))
        (delete-region start end) ))

Things to note: at the beginning of the buffer,
point is 1 (not 0).

Also, there is a difference between deleting
and killing. In general, I suppose it is wiser
to kill because then the kill ring holds it
(check out `kill-region').

Won't that fill up the kill ring with stuff you
won't need? Yes, but once you learn how to
iterate the kill ring back and forth, that
doesn't matter.

-- 
underground experts united
http://user.it.uu.se/~embe8573




reply via email to

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