[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
undo custom delete
From: |
Shug Boabby |
Subject: |
undo custom delete |
Date: |
4 Oct 2005 09:03:49 -0700 |
User-agent: |
G2/0.2 |
Hi everyone,
I have used a very neat custom backspace key for a while now, which
will hungry delete back to the current level of indentation. I found it
on the emacs mailing list some time ago (Stefan Monnier originally
wrote it).
However I have had a little bit of trouble with it when it comes to
undo... normally if you type a word in emacs and then delete it, one
letter at a time (using the normal delete command), one utterance of
"C-x u" will return the whole word. However, with this custom command,
the letters are returned one at a time.
Could somebody please have a look at this code and suggest an
improvement to allow undo to work correctly? Or perhaps there is a list
of such commands with this property that undo needs to know about...
which I cannot find.
thanks,
Shug
;;;;;;;;;;;;;;;;;;;;;;;
;; Fancy delete key
;; This function was written by Stefan Monnier
(defun fancy-backspace ()
"Delete space backward to prev level of indentation."
(interactive)
(if (or (bolp) (save-excursion (skip-chars-backward " \t") (not
(bolp))))
;; If we're not inside indentation, behave as usual.
(call-interactively 'backward-delete-char-untabify)
;; We're inside indentation.
(let* ((col (current-column))
(destcol
(save-excursion
;; Skip previous lines that are more indented than us.
(while (and (not (bobp))
(zerop (forward-line -1))
(skip-chars-forward " \t")
(>= (current-column) col)))
(current-column))))
(delete-region (point)(progn(move-to-column destcol) (point))))))
(global-set-key "\C-?" 'fancy-backspace)
;; note: C, lisp and a few other modes need this defined locally
;;;;;;;;;;;;;;;;;;;;;;;
- undo custom delete,
Shug Boabby <=
- Re: undo custom delete, rgb, 2005/10/04
- Re: undo custom delete, Shug Boabby, 2005/10/05
- Re: undo custom delete, rgb, 2005/10/05
- Re: undo custom delete, Shug Boabby, 2005/10/05
- Re: undo custom delete, Johan Bockgård, 2005/10/05
- Re: undo custom delete, Shug Boabby, 2005/10/05
- Re: undo custom delete, Johan Bockgård, 2005/10/05