From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "rgb" Newsgroups: gmane.emacs.help Subject: Re: undo custom delete Date: 5 Oct 2005 07:23:18 -0700 Organization: http://groups.google.com Message-ID: <1128522198.322768.196970@o13g2000cwo.googlegroups.com> References: <1128441829.624442.144850@o13g2000cwo.googlegroups.com> <1128446941.952911.272060@g49g2000cwa.googlegroups.com> <1128503329.733223.304600@g14g2000cwa.googlegroups.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: sea.gmane.org 1128522650 21442 80.91.229.6 (5 Oct 2005 14:30:50 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 5 Oct 2005 14:30:50 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 05 16:30:42 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1ENAI5-0002xt-00 for ; Wed, 05 Oct 2005 16:30:42 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ENAF2-0002ok-Id for geh-help-gnu-emacs@m.gmane.org; Wed, 05 Oct 2005 10:27:32 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!o13g2000cwo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 25 Original-NNTP-Posting-Host: 198.74.20.118 Original-X-Trace: posting.google.com 1128522203 25905 127.0.0.1 (5 Oct 2005 14:23:23 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 5 Oct 2005 14:23:23 +0000 (UTC) In-Reply-To: <1128503329.733223.304600@g14g2000cwa.googlegroups.com> User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe) X-HTTP-Via: 1.0 bucket.wellsfargo.com:80 (squid/2.5.STABLE5) Complaints-To: groups-abuse@google.com Injection-Info: o13g2000cwo.googlegroups.com; posting-host=198.74.20.118; posting-account=C7LM4w0AAAD23IRuMuUUJVCLQTuHhTK8 Original-Xref: shelby.stanford.edu gnu.emacs.help:134364 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:29939 Archived-At: > but this does raise another question... is there a way to undo deletion > of a complete word in the same way that undo would undo the typing of a > complete word? surely it must be do-able, the logic being something > recursive like "if (last action was delete char) and (char not > whitespace), then (undo last action) and (repeat this loop), else > (break)". The only possibility is to change how undo elements appear on buffer-undo-list. Since undoing an insert involves deleting the inserted character the undo list doesn't record what character was inserted. Only when you delete something does the original content need to be saved so it can be re-inserted during undo. So a special-undo could not tell when to stop undoing unless it looked at the buffer contents at the point where undo list says delete something. Hmm, so it could tell... Anyway... Undo normally undoes elements on the list until it reaches a undo-boundary element. A nil. You could create a pre command hook or remap word constituent characters to an intermediate function. Either way the function would decide if it wanted to remove the car of buffer-undo-list (if it's an undo-boundary element (nil)). This has the effect of making the next action belong to the previous group of keystrokes and all will be undone at once.