From: Emanuel Berg <moasen@zoho.com>
To: help-gnu-emacs@gnu.org
Subject: Re: How to delete all text from beginning of buffer to mark
Date: Tue, 09 May 2017 04:04:36 +0200 [thread overview]
Message-ID: <yw.861sryrdjf.fsf@zoho.com> (raw)
In-Reply-To: CAP_d_8VPrjUApoky-n8-AatcQ0YikHTkXLCS0PyonOijV6tPYw@mail.gmail.com
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
next prev parent reply other threads:[~2017-05-09 2:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-08 14:14 How to delete all text from beginning of buffer to mark Angus Comber
2017-05-08 14:20 ` Loris Bennett
2017-05-08 15:21 ` tomas
2017-05-08 15:43 ` hector
2017-05-08 15:35 ` Teemu Likonen
2017-05-08 15:50 ` Yuri Khan
2017-05-09 2:04 ` Emanuel Berg [this message]
2017-05-09 2:20 ` iterating the kill ring (was: Re: How to delete all text from beginning of buffer to mark) Emanuel Berg
2017-05-09 3:07 ` How to delete all text from beginning of buffer to mark Kaushal Modi
2017-05-09 6:53 ` Emanuel Berg
2017-05-09 11:39 ` Magnus Therning
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=yw.861sryrdjf.fsf@zoho.com \
--to=moasen@zoho.com \
--cc=help-gnu-emacs@gnu.org \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).