From: Sam Halliday <devnull@example.com>
Subject: Re: backward-delete-char-untabify-method
Date: Sun, 8 Jun 2003 22:22:13 +0100 [thread overview]
Message-ID: <20030608222213.4c8cfb4b.devnull@example.com> (raw)
In-Reply-To: 5lbrx8e1rc.fsf@rum.cs.yale.edu
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 ?
:-D
> > 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.
cheers,
Sam
next prev parent reply other threads:[~2003-06-08 21:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-08 18:05 backward-delete-char-untabify-method Sam Halliday
2003-06-08 19:54 ` backward-delete-char-untabify-method Kai Großjohann
2003-06-08 20:46 ` backward-delete-char-untabify-method Stefan Monnier
2003-06-08 21:22 ` Sam Halliday [this message]
2003-06-08 21:37 ` backward-delete-char-untabify-method Sam Halliday
2003-06-08 22:24 ` backward-delete-char-untabify-method Stefan Monnier
2003-06-08 23:16 ` backward-delete-char-untabify-method Sam Halliday
2003-06-09 9:34 ` backward-delete-char-untabify-method Kai Großjohann
2003-06-09 9:50 ` backward-delete-char-untabify-method Sam Halliday
2003-06-09 9:35 ` backward-delete-char-untabify-method Kai Großjohann
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=20030608222213.4c8cfb4b.devnull@example.com \
--to=devnull@example.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).