[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is there any elisp functions to tell whether the cursor is in a comm
From: |
sunway |
Subject: |
Re: Is there any elisp functions to tell whether the cursor is in a comment block? |
Date: |
Sun, 13 Jul 2008 18:36:59 -0700 (PDT) |
User-agent: |
G2/1.0 |
I will recommend YAsnippet package to you [ code.google.com/p/
yasnippet ]
and
(add-hook 'c-mode-hook
'(lambda ()
(setq yas/buffer-local-condition
'(if (nth 8 (syntax-ppss (point)))
'(require-snippet-condition . force-in-
comment)
t))))
will do what you want.
On Jul 14, 1:55 am, Joe Bloggs <w...@cares.invalid> wrote:
> bojohan+n...@dd.chalmers.se (Johan Bockgård) writes:
> > sunway <sunwayfore...@gmail.com> writes:
>
> >> for example, if the cursor is in a normal c code block, I want 'if '
> >> to be expanded to 'if () {}', if it is in the comment block, I prefer
> >> 'if ' not be expanded.
>
> > ;; Non-nil when inside comment or string
> > (nth 8 (syntax-ppss (point)))
>
> > --
> > Johan Bockgård
>
> I want to do that too, how do I do a conditional abbrev?
> Currently I have:
>
> (define-abbrev c-mode-abbrev-table "for"
> "" 'c-style-for-loop)
> (define-abbrev c++-mode-abbrev-table "for"
> "" 'c-style-for-loop)
>
> how would I make it only expand in uncommented code?
- Is there any elisp functions to tell whether the cursor is in a comment block?, sunway, 2008/07/13
- Re: Is there any elisp functions to tell whether the cursor is in a comment block?, Johan Bockgård, 2008/07/13
- Re: Is there any elisp functions to tell whether the cursor is in a comment block?,
sunway <=
- Re: Is there any elisp functions to tell whether the cursor is in a comment block?, Joe Bloggs, 2008/07/14
- Re: Is there any elisp functions to tell whether the cursor is in a comment block?, Lennart Borgman (gmail), 2008/07/14
- Message not available
- Re: Is there any elisp functions to tell whether the cursor is in a comment block?, Joe Bloggs, 2008/07/14
- Re: Is there any elisp functions to tell whether the cursor is in a comment block?, Lennart Borgman (gmail), 2008/07/14
- RE: Is there any elisp functions to tell whether the cursor is in a comment block?, Drew Adams, 2008/07/14
- Re: Is there any elisp functions to tell whether the cursor is in a comment block?, Lennart Borgman (gmail), 2008/07/14
- RE: Is there any elisp functions to tell whether the cursor is in a comment block?, Drew Adams, 2008/07/15
- Message not available
- Re: Is there any elisp functions to tell whether the cursor is in a comment block?, David Kastrup, 2008/07/15
- Re: Is there any elisp functions to tell whether the cursor is in a comment block?, Eli Zaretskii, 2008/07/20
- Re: Is there any elisp functions to tell whether the cursor is in a comment block?, Tom Tromey, 2008/07/14