From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Politz Newsgroups: gmane.emacs.help Subject: Re: manipulating abbreviation mode hooks Date: Mon, 10 May 2010 11:34:19 +0200 Organization: FH-Trier Message-ID: <87zl083xt0.fsf@fh-trier.de> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1291824265 4398 80.91.229.12 (8 Dec 2010 16:04:25 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 8 Dec 2010 16:04:25 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Dec 08 17:04:21 2010 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.69) (envelope-from ) id 1PQMV8-0000Cs-W3 for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 17:04:19 +0100 Original-Received: from localhost ([127.0.0.1]:51595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQMV8-00061m-BL for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 11:04:18 -0500 Original-Path: usenet.stanford.edu!newsserver.news.garr.it!kanaga.switch.ch!switch.ch!news.belwue.de!news.uni-kl.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 38 Original-NNTP-Posting-Host: 143-93-54-11.arno.fh-trier.de Original-X-Trace: news.uni-kl.de 1273484059 21112 143.93.54.11 (10 May 2010 09:34:19 GMT) Original-X-Complaints-To: usenet@news.uni-kl.de Original-NNTP-Posting-Date: Mon, 10 May 2010 09:34:19 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:EQyDcKFPD0AlVu9e5QzFCJ7YTlI= Cache-Post-Path: arno.fh-trier.de!unknown@dslb-084-059-114-205.pools.arcor-ip.net X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) Original-Xref: usenet.stanford.edu gnu.emacs.help:178098 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:75578 Archived-At: Suvayu Ali writes: [...] > > But when I put the following in my ~/.emacs, I get no such behaviour. > >> (defun my-shell-script-mode-abbrev-expand-function () >> (if (not (save-excursion >> (forward-line 0) >> (eq (char-after) ?#))) >> (funcall 'expand-abbrev) >> (let ((local-abbrev-table text-mode-abbrev-table)) >> (funcall 'expand-abbrev)))) >> >> (add-hook 'shell-script-mode-hook >> '(lambda () >> (add-hook 'abbrev-expand-functions >> 'my-shell-script-mode-abbrev-expand-function >> nil t))) > > > Once this is solved, my second question is how do I implement this for > c++-mode? I can't figure out how to match to `//' or a `/* ... */' > block. I'm a newbie in lisp, so a little guidance would be very > appreciated. :) > > TIA shell-script-mode is an alias for sh-mode, the hook is called sh-mode-hook. Anyway, I think it's easier to define the :enable-function property on your abbrev table. (abbrev-table-put your-abbrev-table :enable-function (lambda nil (not (nth 4 (syntax-ppss))))) -ap