[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: company-mode help
From: |
Richard Riley |
Subject: |
Re: company-mode help |
Date: |
Sun, 19 Apr 2009 15:09:21 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux) |
Nikolaj Schumacher <me@nschum.de> writes:
> Richard Riley <rileyrgdev@googlemail.com> wrote:
>
>> Could someone help me with company-mode please. I cant find much
>> documentation on how to use it and am not sure if "(company-mode)" is
>> sufficient. I understand I can call "company-mode" at any time, but is
>> there no "global-company-mode" type thing or utility function to turn it
>> on for common programme language types?
>
> I've added a global-company-mode in 0.4.1.
>
>> too), but do I have to do something special for it to complete structure
>> members in C/C++?
>
> The reason for this is that the structure member (after the -> or .) is
> considered a new symbol by Emacs, making it shorter than
> `company-minimum-prefix-length'.
>
>
> For 0.4.1, a workaround could be an electric command:
>
> (defun company-electric-dot ()
> "Insert a dot and start completion, unless in a string or comment."
> (interactive)
> (insert-char ?. 1)
> (unless (company-in-string-or-comment)
> (company-auto-begin)))
>
> (defun company-electric-greater-than ()
> "Insert a dot and start completion, unless in a string or comment."
> (interactive)
> (insert-char ?> 1)
> (and (eq (char-before (1- (point))) ?-)
> (not (company-in-string-or-comment))
> (company-auto-begin)))
>
> (define-key c-mode-base-map "." 'company-electric-dot)
> (define-key c-mode-base-map ">" 'company-electric-greater-than)
> (define-key c++-mode-map ">" 'company-electric-greater-than)
>
>
> I'll figure out a more universal solution.
>
> regards,
> Nikolaj Schumacher
>
>
Wonderful, thanks.
--