Re: [Orgmode] Safer kill-line for org-mode

2008-01-31 Thread Carsten Dominik

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




___
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


[Orgmode] Safer kill-line for org-mode

2008-01-27 Thread Piotr Zielinski
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