all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Peter Michaux" <petermichaux@gmail.com>
To: "Niels Giesen" <niels.giesen@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Trouble using snippet.el with abbrev tables
Date: Wed, 6 Feb 2008 21:56:44 -0800	[thread overview]
Message-ID: <3cbaf1c80802062156pde267bw1ba94eb8cf9af1b1@mail.gmail.com> (raw)
In-Reply-To: <87fxw7yztp.fsf@gmail.com>

On Feb 5, 2008 11:21 AM, Niels Giesen <niels.giesen@gmail.com> wrote:
> "Peter Michaux" <petermichaux@gmail.com> writes:

> > I'm new to Emacs and having trouble getting snippet.el working.
> >
> > http://www.kazmier.com/computer/snippet.el

>
> (autoload 'javascript-mode "javascript" nil t)
> (add-to-list 'auto-mode-alist '("\\.js\\'" . javascript-mode))
> (require 'snippet)
>
> (add-hook 'javascript-mode-hook
>           (lambda ()
>             (abbrev-mode 1)
>             (unless (boundp 'javascript-mode-abbrev-table)
>               (define-abbrev-table 'javascript-mode-abbrev-table ())
>               (snippet-with-abbrev-table
>                javascript-mode-abbrev-table
>                ("for" .  "for $${element} in $${sequence}:")
>                ("im"  .  "import $$")
>                ("if"  .  "if $${True}:")
>                ("wh"  .  "while $${True}:")))
>             (setq local-abbrev-table javascript-mode-abbrev-table)))

I tried the above. It threw errors at first because the last two
instances of javascript-mode-abbrev-table seem to need quoting. When I
quote those I still don't get the desired snippet behavior when I type
"for" and then space. I tired many simpler combinations also that
didn't involve the unless statement. No luck either. Does the above
code really work for you?

I can get snippets working with python mode.

I have a python-snippets.el file with the following

; -------------------------------------------------
 (snippet-with-abbrev-table 'python-mode-abbrev-table
    ("for" .  "for $${element} in $${sequence}:")
    ("im"  .  "import $$")
    ("if"  .  "if $${True}:")
    ("wh"  .  "while $${True}:")
 )
 (provide 'python-snippets)
; --------------------------------------------------

and then in my .emacs file I have just the following because the
python mode file defines the abbrev table

; -------------------------------------------------
(add-hook 'python-mode-hook
        (lambda ()
          (abbrev-mode 1)
          (require 'snippet)
          (require 'python-snippets)
        )
)
; -------------------------------------------------

Any ideas why the JavaScript version doesn't work?

Thanks,
Peter




  reply	other threads:[~2008-02-07  5:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.6981.1202176026.18990.help-gnu-emacs@gnu.org>
2008-02-05 19:21 ` Trouble using snippet.el with abbrev tables Niels Giesen
2008-02-07  5:56   ` Peter Michaux [this message]
     [not found]   ` <mailman.7103.1202389882.18990.help-gnu-emacs@gnu.org>
2008-02-08  7:57     ` Niels Giesen
2008-02-05  1:09 Peter Michaux

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

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

  git send-email \
    --in-reply-to=3cbaf1c80802062156pde267bw1ba94eb8cf9af1b1@mail.gmail.com \
    --to=petermichaux@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=niels.giesen@gmail.com \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.