From: "Shug Boabby" <Shug.Boabby@gmail.com>
Subject: undo custom delete
Date: 4 Oct 2005 09:03:49 -0700 [thread overview]
Message-ID: <1128441829.624442.144850@o13g2000cwo.googlegroups.com> (raw)
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
;;;;;;;;;;;;;;;;;;;;;;;
next reply other threads:[~2005-10-04 16:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-04 16:03 Shug Boabby [this message]
2005-10-04 17:29 ` undo custom delete rgb
2005-10-05 9:08 ` Shug Boabby
2005-10-05 14:23 ` rgb
2005-10-05 14:36 ` Shug Boabby
2005-10-05 15:17 ` Johan Bockgård
2005-10-05 16:47 ` Shug Boabby
2005-10-05 17:49 ` Johan Bockgård
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1128441829.624442.144850@o13g2000cwo.googlegroups.com \
--to=shug.boabby@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).