unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* undo custom delete
@ 2005-10-04 16:03 Shug Boabby
  2005-10-04 17:29 ` rgb
  0 siblings, 1 reply; 8+ messages in thread
From: Shug Boabby @ 2005-10-04 16:03 UTC (permalink / 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
;;;;;;;;;;;;;;;;;;;;;;;

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

end of thread, other threads:[~2005-10-05 17:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-04 16:03 undo custom delete Shug Boabby
2005-10-04 17:29 ` 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

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