From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Piotr Zielinski" Subject: Safer kill-line for org-mode Date: Sun, 27 Jan 2008 23:29:50 +0000 Message-ID: <3c12eb8d0801271529w74635486r40fc839a3ef89399@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JJGwm-0004Wi-6B for emacs-orgmode@gnu.org; Sun, 27 Jan 2008 18:29:56 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JJGwj-0004WC-QF for emacs-orgmode@gnu.org; Sun, 27 Jan 2008 18:29:54 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JJGwj-0004W9-Ig for emacs-orgmode@gnu.org; Sun, 27 Jan 2008 18:29:53 -0500 Received: from wa-out-1112.google.com ([209.85.146.182]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JJGwj-0005ry-7G for emacs-orgmode@gnu.org; Sun, 27 Jan 2008 18:29:53 -0500 Received: by wa-out-1112.google.com with SMTP id k34so3414635wah.10 for ; Sun, 27 Jan 2008 15:29:51 -0800 (PST) Content-Disposition: inline List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Hi, Read this to avoid losing your work. Standard kill-line deletes all text from the point to the end of the _visible_ line. It happened to me a few times that I pressed C-k to delete a few final words of a headline, but instead the whole (invisible) subtree was deleted. This kind of mistake is costly because it may go unnoticed for weeks, when you start wondering what happened to a sizeable part of your org file and have to go through rather old backups. Below is what I believe to be a safer version of kill-line: it deletes text only to the end of the real line, unless used at the beginning of the line, in which case it behaves as the standard kill-line. I haven't tested much yet, but it seems to be working ok. (defun kill-line-safe () (interactive) (if (bolp) (kill-line) (kill-region (point) (point-at-eol)))) (define-key global-map "\C-k" 'kill-line-safe) Piotr