[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: backward-delete-char-untabify-method

From: Sam Halliday
Subject: Re: backward-delete-char-untabify-method
Date: Sun, 8 Jun 2003 22:22:13 +0100

Stefan Monnier wrote:
> Sam Halliday wrote:
> > line 1
> >   line 2
> >     line 3
> >       A
> > when the cursor is at `A', if i press BACKSPACE, the cursor will go
> > to the beginning of the line, but i would prefer it to go to the
> > same indentation as "line 3", another BACKSPACE bringing me to "line
> > 2" and requiring a third to bring me to the beginning of the line.
> > i.e. I would prefer a `delete back one level of indentation' option.
> Sounds like a cool idea.

> > could somebody please tell me if is this possible?
> Is that a troll ?

> > and how to set it up (or where to look)?
> I think you'll have to make it from scratch (and a few other
> ingredients).(defun sam-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))))))

wooah woah; im very new to elisp (and by exposure only) so you'll have
to be patient here... but from checking this out very quickly (one
indenting example)... it seems to do exactly what i am after!! thank you
very much Stefan :-D

i of course renamed the function to something more appropriate; i
figured `backward-delete-char-tablevel' was best.

thank you again!! i recommend this function to go into Emacs... its only
a small function and i am surprised nobody has ever requested it before.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]