unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Andreas Politz <politza@fh-trier.de>
To: help-gnu-emacs@gnu.org
Subject: Re: manipulating abbreviation mode hooks
Date: Mon, 10 May 2010 11:34:19 +0200	[thread overview]
Message-ID: <87zl083xt0.fsf@fh-trier.de> (raw)
In-Reply-To: mailman.16.1273455544.17813.help-gnu-emacs@gnu.org

Suvayu Ali <fatkasuvayu+linux@gmail.com> 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


       reply	other threads:[~2010-05-10  9:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.16.1273455544.17813.help-gnu-emacs@gnu.org>
2010-05-10  9:34 ` Andreas Politz [this message]
2010-05-10  1:38 manipulating abbreviation mode hooks Suvayu Ali
2010-05-16 12:29 ` Suvayu Ali

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87zl083xt0.fsf@fh-trier.de \
    --to=politza@fh-trier.de \
    --cc=help-gnu-emacs@gnu.org \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).