From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Niels Giesen Newsgroups: gmane.emacs.help Subject: Re: Trouble using snippet.el with abbrev tables Date: Fri, 08 Feb 2008 08:57:52 +0100 Organization: www.tudelft.nl Message-ID: <87hcgjzxq7.fsf@gmail.com> References: <87fxw7yztp.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1202460048 30127 80.91.229.12 (8 Feb 2008 08:40:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 8 Feb 2008 08:40:48 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Feb 08 09:41:09 2008 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 1JNOnA-0003E6-C6 for geh-help-gnu-emacs@m.gmane.org; Fri, 08 Feb 2008 09:41:04 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JNOmh-0001dR-Mt for geh-help-gnu-emacs@m.gmane.org; Fri, 08 Feb 2008 03:40:35 -0500 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!feeder.news-service.com!feed.xsnews.nl!border-1.ams.xsnews.nl!tudelft.nl!binfeed2.tudelft.nl!news2.tudelft.nl!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) Cancel-Lock: sha1:nIXBkbAq5aMZZze9U4kECGCRmZs= Original-X-Complaints-To: sysadmin@tudelft.nl Original-Lines: 107 Original-NNTP-Posting-Host: 167pc207.sshunet.nl (145.97.207.167) Original-NNTP-Posting-Date: Fri, 08 Feb 2008 08:55:42 +0100 Original-X-Trace: 9ff1a47ac0afe34c46a0225002 Original-Xref: shelby.stanford.edu gnu.emacs.help:155944 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:51321 Archived-At: NOTE: This mail was sent outside the group for some reason, so I am (re)posting it here, so that other people can benefit. By the way, Peter replied that this solved the problem he had with snippets in javascript-mode. Peter, there were indeed some flaws in that code. Should've checked with emacs -Q. Well, I have trimmed my .emacs down to the following bare minimum, which really works for me (my emacs version is "GNU Emacs 22.1.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of 2007-11-06 on terranova, modified by Ubuntu"): ;;this is where my snippet.el and javascript.el reside (add-to-list 'load-path "~/.emacs.d/nxml/related") (autoload 'javascript-mode "javascript" nil t) (add-to-list 'auto-mode-alist '("\\.js\\'" . javascript-mode)) (require 'snippet) ;; Apparently the abbrev-table *should* be bound, for ;; snippet-with-abbrev-table not to blurb: (define-abbrev-table 'javascript-mode-abbrev-table ()) ;; Yup, here was a quote missing (snippet-with-abbrev-table 'javascript-mode-abbrev-table ("for" . "for $${element} in $${sequence}:") ("im" . "import $$") ("if" . "if $${True}:") ("wh" . "while $${True}:")) (add-hook 'javascript-mode-hook (lambda () (abbrev-mode 1) ;; Here really should NOT be a quote: (setq local-abbrev-table javascript-mode-abbrev-table))) Perhaps something in python-mode sets the correct abbrev-table already. By the way, what strange dialect of JavaScript is that ;) ? - Show quoted text - > On Feb 5, 2008 11:21 AM, Niels Giesen wrote: >> "Peter Michaux" 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 -- http://niels.kicks-ass.org