From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: nobrowser@gmail.com Newsgroups: gmane.emacs.help Subject: Re: abbrevs, skeletons, and comments Date: Sat, 02 Jun 2007 21:44:09 -0700 Organization: http://groups.google.com Message-ID: <1180845849.865552.185180@h2g2000hsg.googlegroups.com> References: <1180794889.290796.147660@m36g2000hse.googlegroups.com> <87odjxvhyn.fsf@lion.rapttech.com.au> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: sea.gmane.org 1180849262 1585 80.91.229.12 (3 Jun 2007 05:41:02 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 3 Jun 2007 05:41:02 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jun 03 07:41:01 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Huipn-00025g-Al for geh-help-gnu-emacs@m.gmane.org; Sun, 03 Jun 2007 07:40:59 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Huipm-0001G8-R7 for geh-help-gnu-emacs@m.gmane.org; Sun, 03 Jun 2007 01:40:58 -0400 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!postnews.google.com!h2g2000hsg.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 34 Original-NNTP-Posting-Host: 74.97.128.161 Original-X-Trace: posting.google.com 1180845850 4446 127.0.0.1 (3 Jun 2007 04:44:10 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Sun, 3 Jun 2007 04:44:10 +0000 (UTC) In-Reply-To: <87odjxvhyn.fsf@lion.rapttech.com.au> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.3) Gecko/20070310 Iceweasel/2.0.0.3 (Debian-2.0.0.3-1),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: h2g2000hsg.googlegroups.com; posting-host=74.97.128.161; posting-account=YFHMlw0AAAAi2Uh6TQSJVnQoj9NpSiGG Original-Xref: shelby.stanford.edu gnu.emacs.help:149046 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:44634 Archived-At: Tim X wrote: > nobrowser@gmail.com writes: > > > In a module I'm writing, I'd like to bind abbrevs to code skeletons, > > similar to what is done e.g. by sml-mode. But expanding the abbrevs > > makes no sense when the point is inside a comment (or a string > > literal). So I'd like to conditionally stop expansion. The main > > opportunity for that seems to be pre-abbrev-expand-hook, but there are > > only two ways it can stop an expansion: 1, throw an error, 2, change > > the abbrev bindings (either by making changes in the current table or > > by swapping in a whole new table). 1 is unacceptable - how many errors > > before user gets mad and disables abbrevs altogether? 2, how to undo > > the changes when the point leaves the comment or string? > > > > maybe use an error handler that catches that specific error and ignores it? > Well, there's no point where I get control, that's the problem. Abbrev expansion can be triggered just by the user typing a space or period, if they have Abbrev minor mode on. I see a way to do what I want. It involves hooking both pre-abbrev- expand-hook and post-command-hook. I can restore the abbrev bindings in the latter. But I am afraid what this could do to Emacs speed or even stability. What I've decided on so far is I won't do anything by default (so users who avoid Abbrev minor mode are not penalized) and have a customize flag that turns on the above solution. Other suggestions still welcome.