emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Safer kill-line for org-mode
@ 2008-01-27 23:29 Piotr Zielinski
  2008-01-28  5:32 ` Carsten Dominik
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Piotr Zielinski @ 2008-01-27 23:29 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Safer kill-line for org-mode
  2008-01-27 23:29 Safer kill-line for org-mode Piotr Zielinski
@ 2008-01-28  5:32 ` Carsten Dominik
  2008-01-28  8:17 ` Detlef Steuer
  2008-01-31 17:30 ` Carsten Dominik
  2 siblings, 0 replies; 4+ messages in thread
From: Carsten Dominik @ 2008-01-28  5:32 UTC (permalink / raw)
  To: Piotr Zielinski; +Cc: emacs-orgmode

Hi Piotr,

I do like that a lot.  An extension might be to even keep the tags in  
headlines.

- Carsten

On Jan 28, 2008, at 12:29 AM, Piotr Zielinski wrote:

> 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
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Safer kill-line for org-mode
  2008-01-27 23:29 Safer kill-line for org-mode Piotr Zielinski
  2008-01-28  5:32 ` Carsten Dominik
@ 2008-01-28  8:17 ` Detlef Steuer
  2008-01-31 17:30 ` Carsten Dominik
  2 siblings, 0 replies; 4+ messages in thread
From: Detlef Steuer @ 2008-01-28  8:17 UTC (permalink / raw)
  To: emacs-orgmode

On Sun, 27 Jan 2008 23:29:50 +0000
"Piotr Zielinski" <piotr.zielinski@gmail.com> wrote:

> 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


Yeah. Felt the pain this weekend! Looks like a great addition.
Thx

Detlef


> 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
> 
> 
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Safer kill-line for org-mode
  2008-01-27 23:29 Safer kill-line for org-mode Piotr Zielinski
  2008-01-28  5:32 ` Carsten Dominik
  2008-01-28  8:17 ` Detlef Steuer
@ 2008-01-31 17:30 ` Carsten Dominik
  2 siblings, 0 replies; 4+ messages in thread
From: Carsten Dominik @ 2008-01-31 17:30 UTC (permalink / raw)
  To: Piotr Zielinski; +Cc: emacs-orgmode

I will have an extended version of this function in 5.20.

Thanks!

- Carsten

On Jan 28, 2008, at 12:29 AM, Piotr Zielinski wrote:

> 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
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-01-31 18:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-27 23:29 Safer kill-line for org-mode Piotr Zielinski
2008-01-28  5:32 ` Carsten Dominik
2008-01-28  8:17 ` Detlef Steuer
2008-01-31 17:30 ` Carsten Dominik

Code repositories for project(s) associated with this public inbox

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

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).