From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.help Subject: Re: company-mode help Date: Mon, 20 Apr 2009 21:38:26 +0000 Message-ID: <20090420213825.GA3965@muc.de> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1240263550 13937 80.91.229.12 (20 Apr 2009 21:39:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 20 Apr 2009 21:39:10 +0000 (UTC) Cc: help-gnu-emacs@gnu.org, Richard Riley To: Nikolaj Schumacher Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Apr 20 23:40:29 2009 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 1Lw1Dy-0007rH-Ug for geh-help-gnu-emacs@m.gmane.org; Mon, 20 Apr 2009 23:40:23 +0200 Original-Received: from localhost ([127.0.0.1]:52808 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lw1CZ-0007hn-UB for geh-help-gnu-emacs@m.gmane.org; Mon, 20 Apr 2009 17:38:56 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lw1CF-0007gi-QA for help-gnu-emacs@gnu.org; Mon, 20 Apr 2009 17:38:35 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lw1CB-0007ev-Bi for help-gnu-emacs@gnu.org; Mon, 20 Apr 2009 17:38:35 -0400 Original-Received: from [199.232.76.173] (port=58022 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lw1CB-0007es-51 for help-gnu-emacs@gnu.org; Mon, 20 Apr 2009 17:38:31 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:3121 helo=mail.muc.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lw1CA-0001LX-MP for help-gnu-emacs@gnu.org; Mon, 20 Apr 2009 17:38:30 -0400 Original-Received: (qmail 80936 invoked by uid 3782); 20 Apr 2009 21:38:27 -0000 Original-Received: from acm.muc.de (pD9E5161C.dip.t-dialin.net [217.229.22.28]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Mon, 20 Apr 2009 23:38:25 +0200 Original-Received: (qmail 4790 invoked by uid 1000); 20 Apr 2009 21:38:26 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.9i X-Delivery-Agent: TMDA/1.1.5 (Fettercairn) X-Primary-Address: acm@muc.de X-detected-operating-system: by monty-python.gnu.org: FreeBSD 4.6-4.9 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:63910 Archived-At: 'ten Abend, Nikolaj! On Sun, Apr 19, 2009 at 02:07:05PM +0200, Nikolaj Schumacher wrote: > Richard Riley 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: Please note, WORKAROUND!!! > (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) Please don't put this last into C or (especially) C++ mode. > is bound to `c-electric-lt-gt', and as well as triggering electric indentation, does essential things wrt C++ templates. It would probably cause screw-ups, particularly as < would still be bound to `c-electric-lt-gt'. OK, I know it's only meant as a temporary thing. But couldn't you do it as a defadvice around `c-electric-lt-gt'? > > I'll figure out a more universal solution. ;-) > regards, > Nikolaj Schumacher -- Alan Mackenzie (Nuremberg, Germany).