unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: wilnerthomas--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: thibaut.verron@gmail.com
Cc: help-gnu-emacs@gnu.org
Subject: Re: global-company-mode and company-mode
Date: Tue, 2 Aug 2022 13:15:30 +0200 (CEST)	[thread overview]
Message-ID: <N8TG80o--3-2@tutanota.com> (raw)
In-Reply-To: <48e6e2a9-7cb2-1899-47f7-188c49125f1b@gmail.com>


Aug 2, 2022, 11:09 by thibaut.verron@gmail.com:

> On 02/08/2022 12:26, wilnerthomas--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
>>
>> I do not understand how to enable `company-mode'.  Because there is (company-mode 1)
>> and `(add-hook 'after-init-hook 'global-company-mode)'.
>>
> What is the difference between the two.  
> (company-mode 1) only turns the mode on in the current buffer, (global-company-mode 1) turns it on in every existing buffer, and will turn it on in every future buffer (except for buffers not visiting a file and with the fundamental-mode).
>
> https://www.gnu.org/software/emacs/manual/html_node/elisp/Defining-Minor-Modes.html
>
>> Why 'after-init-hook is used, cannot there just be
>> (global-company-mode 1)?
>>
>
> I am not sure, but I suspect it is to make sure that all packages which might change the way company-mode works are already loaded at the time of activation.
>
> But then again, the main effect of (global-company-mode 1) at that point is to tell future buffers to activate company-mode, which would be after initialization anyway. Even the *scratch* buffer (usually the only editable buffer created at initialization) should be in fundamental-mode at the time of running of the hook, so it isn't affected by global-company-mode.
>
> So the two calls might not be strictly equivalent, but I believe that they would be indistinguishable in most use-cases.
>
>
>>
>> When using `add-hook', how would I disable `global-company-mode' later?
>>
>
> The hook is run only once, when starting emacs, so it doesn't matter in a running emacs.
> Just call (global-company-mode -1) to disable it later. Note that it should also disable company-mode in all buffers where the global setting was applied (and not overridden by a local (company-mode 1)). (I think, at least. I always end up confused by the semantics of disabling global vs local modes.)
>
Right.  Is there the command (global-company-mode -1) available?  What if I want to enable global-company-mode, would I use the hook?


  reply	other threads:[~2022-08-02 11:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-02 10:26 global-company-mode and company-mode wilnerthomas--- via Users list for the GNU Emacs text editor
2022-08-02 11:09 ` thibaut.verron
2022-08-02 11:15   ` wilnerthomas--- via Users list for the GNU Emacs text editor [this message]
2022-08-02 11:23     ` Dmitry Gutov
2022-08-02 11:41       ` Thibaut Verron

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=N8TG80o--3-2@tutanota.com \
    --to=help-gnu-emacs@gnu.org \
    --cc=thibaut.verron@gmail.com \
    --cc=wilnerthomas@tutanota.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).