all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Stefan Monnier" <monnier+gnu.emacs.help/news/@flint.cs.yale.edu>
Subject: Re: backward-delete-char-untabify-method
Date: 08 Jun 2003 16:46:15 -0400	[thread overview]
Message-ID: <5lbrx8e1rc.fsf@rum.cs.yale.edu> (raw)
In-Reply-To: 20030608190540.21c4890c.devnull@example.com

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


-- Stefan

  parent reply	other threads:[~2003-06-08 20:46 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 ` Stefan Monnier [this message]
2003-06-08 21:22   ` backward-delete-char-untabify-method Sam Halliday
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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5lbrx8e1rc.fsf@rum.cs.yale.edu \
    --to=monnier+gnu.emacs.help/news/@flint.cs.yale.edu \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.