From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: Re: How to delete all text from beginning of buffer to mark Date: Tue, 09 May 2017 04:04:36 +0200 Message-ID: References: <481f9e2a-475f-4fb6-bb6b-abba56a27c2f@googlegroups.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1494295530 25598 195.159.176.226 (9 May 2017 02:05:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 9 May 2017 02:05:30 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue May 09 04:05:24 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d7uWg-0006UZ-7J for geh-help-gnu-emacs@m.gmane.org; Tue, 09 May 2017 04:05:22 +0200 Original-Received: from localhost ([::1]:34577 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d7uWl-0004PS-HC for geh-help-gnu-emacs@m.gmane.org; Mon, 08 May 2017 22:05:27 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d7uW8-0004Na-Os for help-gnu-emacs@gnu.org; Mon, 08 May 2017 22:04:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d7uW5-00070k-Lf for help-gnu-emacs@gnu.org; Mon, 08 May 2017 22:04:48 -0400 Original-Received: from [195.159.176.226] (port=51824 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d7uW5-00070G-Ft for help-gnu-emacs@gnu.org; Mon, 08 May 2017 22:04:45 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1d7uVx-0005l5-Cb for help-gnu-emacs@gnu.org; Tue, 09 May 2017 04:04:37 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Original-Lines: 46 Original-X-Complaints-To: usenet@blaine.gmane.org Mail-Copies-To: never Cancel-Lock: sha1:qIW6peBc/+YqRM61beKnimst1RQ= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:112968 Archived-At: Yuri Khan wrote: >> What is the best way to basically delete all >> text before the cursor in the buffer? > > Ctrl+Shift+Home, Del. > > * 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