From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Sam Halliday Newsgroups: gmane.emacs.help Subject: Re: backward-delete-char-untabify-method Date: Sun, 8 Jun 2003 22:22:13 +0100 Organization: blueyonder (post doesn't reflect views of blueyonder) Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <20030608222213.4c8cfb4b.devnull@example.com> References: <20030608190540.21c4890c.devnull@example.com> <5lbrx8e1rc.fsf@rum.cs.yale.edu> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1055107456 27427 80.91.224.249 (8 Jun 2003 21:24:16 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 8 Jun 2003 21:24:16 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Sun Jun 08 23:24:14 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19P7eA-000787-00 for ; Sun, 08 Jun 2003 23:24:14 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19P7fS-0002uX-VY for gnu-help-gnu-emacs@m.gmane.org; Sun, 08 Jun 2003 17:25:34 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!cyclone.bc.net!snoopy.risq.qc.ca!chi1.webusenet.com!news.webusenet.com!peer02.cox.net!peer01.cox.net!cox.net!news-hub.cableinet.net!blueyonder!internal-news-hub.cableinet.net!news-binary.blueyonder.co.uk.POSTED!53ab2750!not-for-mail Original-Newsgroups: gnu.emacs.help X-Newsreader: GNU/Linux Sylpheed Claws 0.9.0 Original-Lines: 52 Original-NNTP-Posting-Host: 82.41.203.107 Original-X-Complaints-To: abuse@blueyonder.co.uk Original-X-Trace: news-binary.blueyonder.co.uk 1055107333 82.41.203.107 (Sun, 08 Jun 2003 21:22:13 GMT) Original-NNTP-Posting-Date: Sun, 08 Jun 2003 21:22:13 GMT Original-Xref: shelby.stanford.edu gnu.emacs.help:114300 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:10794 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:10794 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