Emacs with Company Mode - Detailed Review

Developer Tools

Emacs with Company Mode - Detailed Review Contents
    Add a header to begin generating the table of contents

    Emacs with Company Mode - Product Overview



    Emacs with Company Mode

    Company Mode is a powerful text completion framework designed to enhance the coding and editing experience within the GNU Emacs environment.

    Primary Function

    Company Mode is a modular text completion system that automates the process of suggesting and completing text based on the context of what you are typing. It retrieves, manipulates, and displays completion candidates, making it easier to write code and other text efficiently.

    Target Audience

    The primary target audience for Emacs with Company Mode includes developers, programmers, and users who frequently work with text editors, particularly those who use GNU Emacs. It is beneficial for anyone looking to streamline their coding and writing processes with intelligent auto-completion features.

    Key Features



    Installation and Activation

    Company Mode can be installed via Emacs package archives using the command `M-x package-install RET company RET`. To activate it, use the command `M-x company-mode`, which toggles the mode on and off. For persistent activation across sessions, add `(global-company-mode)` to your Emacs configuration file.

    Auto-Completion

    Once activated, Company Mode auto-starts suggesting completion candidates based on the characters you type. You can manually initiate completion with `M-x company-complete` and navigate through candidates using `C-n` and `C-p` key bindings.

    Customization

    Company Mode is highly customizable. You can configure key bindings, backend providers, and various settings through the Emacs customization interface or by modifying your configuration file. For example, you can set the number of characters required before candidates are displayed or define specific major modes where Company Mode should be enabled.

    Backend Configuration

    Company Mode supports multiple backends, which are functions that provide completion candidates. These backends can be configured and ordered to optimize performance. You can add or remove backends using the `company-backends` list.

    Additional Commands

    Company Mode includes several convenience commands, such as displaying documentation for the selected candidate (`company-show-doc-buffer`), showing the definition of the selected candidate (`company-show-location`), and inserting the common part of all completion candidates (`company-complete-common`).

    Integration with Other Tools

    Company Mode can be integrated with other Emacs packages, such as Helm, to provide additional functionality like using Helm for completion candidates when needed. Overall, Emacs with Company Mode is a versatile and powerful tool that significantly enhances the productivity of developers and writers by providing intelligent and customizable text completion features.

    Emacs with Company Mode - User Interface and Experience



    User Interface of Emacs with Company Mode

    The user interface of Emacs with Company Mode is designed to enhance the coding experience by providing autosuggestions and autocompletions, making it a valuable tool in the Developer Tools category.



    Activation and Indicators

    To activate Company Mode, you can use the command M-x company-mode, which toggles the mode on and off. Once activated, the mode line in Emacs will display an indicator ‘company’ to show that Company Mode is enabled.



    Autosuggestions and Autocompletions

    Company Mode auto-starts suggesting completion candidates as you type. These candidates are retrieved and displayed based on the characters you enter and the default or customized configurations. By default, suggestions appear after typing a few characters, but you can adjust this behavior. For instance, you can set company-minimum-prefix-length to 1 to show suggestions after entering just one character.



    Customization

    Company Mode is highly customizable, allowing you to fine-tune its behavior to suit your needs. You can use the customization interface by running M-x customize-group RET company or by modifying settings in your Emacs configuration file. Key settings include company-idle-delay to control the delay before suggestions appear, and company-selection-wrap-around to enable wrapping around the list of suggestions.



    Key Bindings and Navigation

    The mode comes with predefined key bindings for selecting and inserting completion candidates. You can use C-n and C-p to select the next or previous candidate, respectively. Additionally, you can customize key bindings to make the interface more intuitive. For example, you can use the tab key to cycle through suggestions by configuring company-tng-configure-default.



    Manual Initiation and Additional Commands

    If you prefer manual initiation of completion, you can use the command M-x company-complete. Other useful commands include company-show-doc-buffer to display documentation for the selected candidate and company-show-location to show the definition of the selected candidate.



    Ease of Use

    Company Mode is designed to be user-friendly, especially after some initial customization. By setting up the mode to show suggestions immediately and using familiar key bindings like the tab key, you can significantly reduce typing and improve productivity. The ability to customize the delay, the minimum prefix length, and the navigation keys makes it adaptable to different user preferences.



    Overall User Experience

    The overall user experience with Company Mode in Emacs is positive, particularly for developers who value autosuggestions and autocompletions. The mode integrates seamlessly with various major modes in Emacs, and its customization options ensure that it can be tailored to individual workflows. This makes it an effective tool for reducing typing errors and enhancing coding efficiency.



    Conclusion

    In summary, Company Mode in Emacs offers a streamlined and customizable interface for autosuggestions and autocompletions, making it a valuable addition to any developer’s toolkit.

    Emacs with Company Mode - Key Features and Functionality



    Emacs with Company Mode

    Company Mode is a powerful text and code completion framework that offers several key features and functionalities, making it a valuable tool for developers.

    Installation and Activation

    To use Company Mode, you need to install the package via Emacs’s package manager. You can do this by running the command `M-x package-install RET company RET`. Once installed, you can activate Company Mode by executing `M-x company-mode`. To enable it globally for all future sessions, add `(global-company-mode)` to your Emacs configuration file.

    Completion Mechanism

    Company Mode auto-starts suggesting completion candidates as you type. The candidates are retrieved and displayed based on the typed characters and the default configurations. You can manually initiate completion using `M-x company-complete`.

    Key Bindings and Navigation

    Company Mode comes with predefined key bindings for navigating and selecting completion candidates:
    • `C-n` and `C-p` to select the next or previous candidate.
    • `` or `` to complete the selected candidate or the common part of all candidates.
    • `C-s` and `C-r` to search through the completions.
    • `M-(digit)` to quickly complete with one of the first 10 candidates.
    • `` to display the documentation for the selected candidate, and `C-w` to see its source.


    Customization

    You can customize various aspects of Company Mode, such as:
    • Enabling or disabling it in specific major modes by setting `company-global-modes`.
    • Changing the list of enabled back-ends using `M-x customize-variable RET company-backends`.
    • Assigning custom key bindings to Company commands using `define-key`.


    Back-ends

    Company Mode supports multiple pluggable back-ends, including:
    • `Clang` for C/C code
    • `Ispell` for spell checking
    • `CMake` for CMake projects
    • `BBDB` for email addresses
    • `Yasnippet` for snippet completion
    • `Dabbrev` for dynamic abbreviations
    • `Etags` and `Gtags` for tag-based completion
    • `Files` for file names
    • `Keywords` for keyword completion
    • `CAPF` for compatibility with standard completion-at-point-functions.


    Documentation and Source Display

    You can display the documentation or source of the selected completion candidate using specific commands:
    • `company-show-doc-buffer` to display the documentation.
    • `company-show-location` to display the definition of the selected candidate.


    AI Integration

    While Company Mode itself does not integrate AI directly, it is part of the broader Emacs ecosystem where AI can be integrated through other packages. For example, you could use other Emacs packages that leverage AI models, such as `org-ai` for text generation using models like ChatGPT, but this is not a feature of Company Mode itself.

    Conclusion

    In summary, Company Mode enhances Emacs with a flexible and customizable completion framework, making it easier to write code and text efficiently, but it does not include AI-driven features inherently.

    Emacs with Company Mode - Performance and Accuracy



    Performance

    Company Mode is generally well-regarded for its performance, especially when properly configured. Here are some factors that influence its performance:



    Configuration of Auto-Start Behavior

    The company-minimum-prefix-length and company-idle-delay settings can significantly impact performance. Setting company-idle-delay to a low value or even 0 can make Company react immediately to typed input, which can be beneficial for quick completions but may impact performance if not managed well.



    Backend Configuration

    The order and efficiency of the backends in the company-backends list can affect performance. Ensuring that fast and relevant backends are loaded first can improve responsiveness. For example, keeping the “capf” backend (which integrates with Emacs’ default completion facility) at the top is recommended.



    Customization

    Adjusting settings such as company-tooltip-limit and company-show-numbers can also impact performance. For instance, setting company-tooltip-limit to a lower number can reduce the computational load of displaying many candidates.



    Accuracy

    Company Mode’s accuracy is largely dependent on its backends and how well they are configured:



    Backend Quality

    The accuracy of completions depends on the quality and relevance of the backends used. For example, using backends like jedi for Python or clang for C/C can provide highly accurate completions because these backends are specialized for their respective languages.



    Context Awareness

    Company Mode can be configured to be context-aware, meaning it can adjust its behavior based on the current editing context. For instance, the company-in-string-or-comment predicate can be used to adjust the company-idle-delay based on whether the cursor is in a string or comment.



    Limitations and Areas for Improvement



    Backend Compatibility

    Ensuring that all backends are properly loaded and configured can sometimes be challenging. For example, some backends may not be very fast or may have specific requirements (like jedi or clang needing appropriate autoloads registered).



    User Configuration

    While Company Mode offers extensive customization options, this can also be a source of complexity. Users need to carefully configure settings like company-idle-delay and company-minimum-prefix-length to balance responsiveness and resource usage.



    Integration with Other Tools

    When used in conjunction with other tools like lsp-mode, there can be additional performance considerations. For instance, ensuring that lsp-mode is properly configured and optimized (e.g., using native JSON serialization, adjusting gc-cons-threshold, and disabling unnecessary logging) is crucial for maintaining overall performance.

    In summary, Company Mode in Emacs can offer excellent performance and accuracy when configured correctly. However, it requires careful setup and management of its backends and settings to ensure optimal behavior. By understanding and tweaking these configurations, users can significantly enhance their development experience.

    Emacs with Company Mode - Pricing and Plans



    The Pricing Structure for Emacs with Company Mode

    The pricing structure for Emacs with Company Mode does not involve any specific tiers or plans, as it is an open-source package and does not require any monetary payment.



    Key Points

    • Free and Open-Source: Company Mode is a free and open-source package available for GNU Emacs. It can be installed and used without any cost.
    • Installation: Users can install Company Mode using the Emacs package manager by running the command `M-x package-install RET company RET`.
    • Customization and Usage: The package offers extensive customization options and can be configured to suit various user needs, including different major modes and backend configurations.
    • No Subscription or Licensing Fees: There are no subscription fees, licensing costs, or different pricing tiers associated with using Company Mode.


    Conclusion

    In summary, Company Mode for Emacs is entirely free to use, with no associated costs or different pricing plans.

    Emacs with Company Mode - Integration and Compatibility



    Company Mode Overview

    Company Mode integrates seamlessly with a variety of tools and maintains a high level of compatibility across different platforms and devices, making it a versatile and powerful completion framework.

    Integration with Other Tools

    Company Mode is highly modular and supports integration with numerous backends, each providing completion capabilities for different contexts and languages. For example:

    Supported Backends

    • It includes backends for Elisp, Clang, Semantic, Eclim, Ropemacs, Ispell, CMake, BBDB, Yasnippet, dabbrev, etags, gtags, and files, among others.
    • The CAPF backend acts as a bridge to the standard `completion-at-point-functions` facility, allowing it to work with any major mode that defines a proper completion function.
    • Users can also write their own backends to integrate with specific tools or languages, such as the example of a backend for ycmd, a completion server for languages like C/C /Objective-C and Python.


    Customization and Configuration

    Company Mode allows extensive customization to fit various workflows. Users can configure which backends to use in different major modes, adjust the delay before completion candidates are displayed, and set triggers for inserting the selected candidate. This customization can be done through the Emacs customization interface or by modifying the configuration file directly.

    Platform and Device Compatibility

    Since Company Mode is an Emacs package, it inherits Emacs’s cross-platform compatibility. Emacs itself runs on a wide range of operating systems, including Windows, macOS, and various Linux distributions. This means that Company Mode can be used on any platform that supports Emacs, without any specific compatibility issues.

    Usage Across Different Devices

    Given that Emacs is a text-based editor, Company Mode does not have device-specific requirements. It works equally well on desktops, laptops, and even on devices with smaller screens, as long as Emacs can run on the device. The text-based nature of Emacs and Company Mode ensures that the user experience remains consistent across different devices.

    Conclusion

    In summary, Company Mode’s modular design, extensive customization options, and the cross-platform nature of Emacs make it highly compatible and integrable with various tools and platforms, ensuring a consistent and powerful completion experience regardless of the device or operating system used.

    Emacs with Company Mode - Customer Support and Resources



    Installation and Activation

    To get started, you can install Company Mode using the Emacs package manager by executing the command `M-x package-install RET company RET`. Once installed, you can activate Company Mode globally by adding `(global-company-mode)` to your Emacs configuration file.

    Customization

    Company Mode is highly customizable. You can adjust various settings to suit your preferences. For example, you can change the `company-idle-delay` to control when completion candidates are displayed, or set `company-insertion-on-trigger` to specify how completions are inserted. You can also customize the mode through the `M-x customize-group RET company` interface, which lists all available options for user customization.

    Manual Triggering

    If you prefer to trigger completions manually, you can set up key bindings. For instance, you can use `M-TAB` (or `C-M-i`) as a manual trigger by adding the following to your configuration: “`emacs (global-set-key (kbd “M-TAB”) #’company-complete) “` Additionally, you can configure `TAB` to complete without losing the ability to manually indent: “`emacs (global-set-key (kbd “TAB”) #’company-indent-or-complete-common) “`

    Documentation Integration

    Company Mode integrates well with other documentation facilities, such as CIDER for Clojure development. You can display documentation and arglists for completion candidates by pressing `F1` (the default `company-show-doc-buffer` key binding). To always show docstrings and other metadata without an extra key press, you can customize the `company-auto-update-doc` variable: “`emacs (custom-set-variables ‘(company-auto-update-doc t)) “`

    Backends and Extensions

    Company Mode supports extension via backends, which provide completion lists in various contexts. You can add custom backends to the `company-backends` list to integrate different completion sources. For example: “`emacs (add-to-list ‘company-backends ‘company-sample-backend) “`

    Resources

    • User Manual: The official Company Mode user manual provides detailed instructions for setup, usage, and customization.
    • CIDER Documentation: For users of CIDER, the CIDER documentation offers specific guidance on integrating Company Mode with CIDER.
    • Community and Forums: While not explicitly mentioned in the resources, the broader Emacs community and forums (like the Emacs Stack Exchange or Emacs subreddit) are valuable resources for troubleshooting and learning more about Company Mode.
    By leveraging these resources and customization options, you can optimize Company Mode to enhance your coding experience in Emacs.

    Emacs with Company Mode - Pros and Cons



    Advantages of Emacs with Company Mode



    Flexible and Extensive Completion Capabilities

    Company Mode offers a wide range of pluggable back-ends, such as Clang, Ispell, CMake, Yasnippet, Dabbrev, Etags, Gtags, and more. This flexibility allows it to support various programming languages and editing tasks, making it highly versatile for different development needs.



    Integration with Emacs’ Native Completion

    The CAPF back-end integrates seamlessly with Emacs’ standard completion-at-point-functions facility, ensuring compatibility with most major modes and enhancing the overall completion experience.



    Customizable Configuration

    Users can configure Company Mode to suit their preferences, including setting the idle delay, echo delay, tooltip limit, and the order of back-ends. This customization helps in optimizing performance and user experience.



    Efficient Performance

    Company Mode is optimized for performance, allowing for fast and responsive completion suggestions. Settings such as company-idle-delay and company-echo-delay can be adjusted to ensure quick feedback without impacting Emacs’ responsiveness.



    Support for Snippets and Templates

    Company Mode supports snippet and template expansion through back-ends like company-yasnippet, which enhances productivity by providing quick access to frequently used code snippets and templates.



    Advanced Completion Features

    Features like visual numbering of candidates, support for double-width/CJK characters, and buffer text of different sizes improve the usability and readability of the completion popup.



    Disadvantages of Emacs with Company Mode



    Configuration Complexity

    While Company Mode is highly customizable, this can also be a drawback. Setting up the optimal configuration, especially for beginners, can be time-consuming and may require some trial and error to get right.



    Backend Order Dependency

    The order of back-ends in the company-backends list can significantly affect performance and functionality. Some back-ends, like company-yasnippet, need to be placed carefully to avoid blocking other back-ends or causing delays.



    Dependency on Additional Packages

    Some back-ends, such as company-jedi for Python or company-clang for C/C , require additional packages to be loaded or autoloads to be registered, which can add to the setup complexity.



    Learning Curve

    Emacs itself has a steep learning curve, and adding Company Mode to the mix can increase this challenge. Users need to familiarize themselves with Emacs keybindings and commands, as well as the specific features and configurations of Company Mode.



    Potential for Sluggish Performance

    If not configured correctly, Company Mode can impact Emacs’ responsiveness. However, this can usually be mitigated by adjusting settings such as the idle delay and ensuring that back-ends are loaded efficiently.

    In summary, Emacs with Company Mode offers a powerful and flexible completion framework that can significantly enhance developer productivity, but it requires careful configuration and a bit of learning to fully leverage its capabilities.

    Emacs with Company Mode - Comparison with Competitors



    Emacs with Company Mode

    Emacs, combined with Company Mode, offers a highly extensible and customizable text editing experience. Here are some key features:
    • Extensibility: Company Mode is a generic auto-completion framework that supports pluggable backends and frontends, making it highly flexible and adaptable to various programming languages.
    • Language Support: Company Mode has specific backends like `company-jedi` for Python, which leverages the Jedi library for auto-completion. It also integrates well with Language Server Protocol (LSP) modes, providing comprehensive completion data.
    • Customization: Emacs itself is renowned for its customization capabilities, including easy package installation, theming, and keybinding adjustments. This allows developers to tailor their editing environment to their preferences.


    Alternatives and Comparisons



    Vim

    Vim is another highly customizable and powerful text editor. Here’s how it compares:
    • Flexibility: Like Emacs, Vim is extremely flexible and supports a wide range of plugins and customizations. It is known for its lightweight yet powerful nature, making it suitable for both simple configuration file edits and complex coding tasks.
    • Syntax Highlighting and Completion: Vim offers out-of-the-box syntax highlighting for many languages and supports code completion through various plugins, although it may not be as integrated with AI-driven tools as Company Mode in Emacs.


    Atom

    Atom is a modern text editor that also offers a high degree of customization:
    • Customization: Atom has thousands of packages that extend its functionality, similar to Emacs’ packages. It is highly customizable, both in terms of appearance and functionality, making it appealing to both technical and non-technical users.
    • AI-Driven Tools: While Atom does not have a built-in AI-driven completion framework like Company Mode, it can be extended with various packages to achieve similar functionality.


    Geany

    Geany is a lightweight IDE that, although less feature-rich than Emacs or Vim, offers a more streamlined experience:
    • Lightweight: Geany is small and fast, making it suitable for older hardware or resource-constrained environments. It supports plugins to expand its capabilities but is generally less complex than Emacs or Vim.
    • Completion: Geany does not have the same level of AI-driven auto-completion as Company Mode but can still provide basic completion features through its plugins.


    Other Considerations

    • LSP Integration: Both Emacs with Company Mode and Vim can integrate with LSP servers to provide advanced auto-completion and code analysis features. However, Company Mode’s integration with LSP is particularly seamless, offering as-you-type auto-completion stacked on top of Emacs’ general completion infrastructure.
    • User Interface: Emacs and Vim have steeper learning curves due to their unique keybindings and commands, whereas Atom and Geany might be more intuitive for new users. However, the customization options in Emacs and Vim can make them highly efficient once mastered.
    In summary, Emacs with Company Mode stands out for its extensibility, comprehensive language support, and seamless integration with AI-driven tools like LSP servers. While alternatives like Vim, Atom, and Geany offer their own strengths, they may not match the depth of customization and AI-driven features available in the Emacs and Company Mode combination.

    Emacs with Company Mode - Frequently Asked Questions



    How do I install Company Mode in Emacs?

    To install Company Mode in Emacs, you need to use the package manager. Open Emacs and execute the command `M-x package-install RET company RET`. This will install the Company package from the Emacs package archives.

    How do I activate Company Mode in Emacs?

    To activate Company Mode, use the command `M-x company-mode`. This command toggles the mode on and off. When activated, the mode line will indicate its presence with an indicator ‘`company`’.

    How can I enable Company Mode automatically on startup?

    To have Company Mode enabled automatically for all future sessions, add the line `(global-company-mode)` to your Emacs configuration file (usually `~/.emacs` or `~/.emacs.d/init.el`).

    How do I customize the behavior of Company Mode?

    Company Mode is highly customizable. You can configure it using either the customization interface or by editing your configuration file. To use the customization interface, run `M-x customize-group RET company`. This will display all available options for customization. Alternatively, you can set variables directly in your configuration file, such as changing `company-idle-delay` or `company-global-modes`.

    How do I select and insert completion candidates in Company Mode?

    To select the next or previous completion candidate, use the key bindings `C-n` and `C-p`, respectively. To insert the selected candidate, use the command `company-complete-selection`. You can also insert the common part of all completion candidates with `company-complete-common`.

    How can I configure Company Mode to start suggesting candidates after a specific number of characters?

    You can configure the number of characters that need to be typed before Company Mode starts suggesting candidates by setting the `company-minimum-prefix-length` variable. For example, to start suggesting candidates after 2 characters, you would add `(setq company-minimum-prefix-length 2)` to your configuration file.

    How do I enable or disable Company Mode for specific major modes?

    To enable or disable Company Mode for specific major modes, you can set the `company-global-modes` variable. For example, to enable Company Mode only in certain modes, you can use: “`emacs (setq company-global-modes ‘(python-mode java-mode)) “` To disable it in certain modes, use: “`emacs (setq company-global-modes ‘(not erc-mode message-mode eshell-mode)) “` Setting it to `nil` will disable global Company Mode.

    How can I assign custom key bindings in Company Mode?

    You can assign custom key bindings by modifying the `company-active-map`. For example, to bind the TAB key to `company-complete-common-or-cycle`, you can add the following to your configuration file: “`emacs (with-eval-after-load ‘company (define-key company-active-map (kbd “TAB”) #’company-complete-common-or-cycle)) “` This allows you to customize the key bindings to better suit your workflow.

    How do I display documentation or the definition of a selected candidate in Company Mode?

    To display the documentation for the selected candidate, use the command `M-x company-show-doc-buffer`. For the definition, use `M-x company-show-location`. These commands can be bound to keys for easier access.

    How can I cancel the current Company Mode activity?

    To cancel the current Company Mode activity, use the command `M-x company-abort`. This can also be bound to a key for quick access.

    Emacs with Company Mode - Conclusion and Recommendation



    Final Assessment of Emacs with Company Mode

    Emacs with Company Mode is a powerful and versatile text completion framework that can significantly enhance the development experience for programmers and writers. Here’s a detailed assessment of its benefits and who would most benefit from using it.

    Key Features and Benefits

    • Modular Completion Framework: Company Mode is highly modular, allowing users to configure multiple backends to provide completion candidates. This includes support for various programming languages and tools like LSP (Language Server Protocol), Jedi for Python, and Clang for C/C .
    • Customizable Backends: Users can easily add or remove backends to suit their specific needs. This flexibility ensures that the completion system can be optimized for different projects and languages.
    • Performance Optimization: Company Mode includes several settings to tweak performance, such as adjusting the idle delay, echo delay, and tooltip limits. This allows users to balance responsiveness with the need for quick completions.
    • Integration with Other Tools: It integrates well with other Emacs packages like Yasnippet and can be configured to work seamlessly with various major modes (e.g., `c-mode`, `emacs-lisp-mode`, `text-mode`).


    Who Would Benefit Most

    • Programmers: Developers working in various programming languages will find Company Mode particularly useful due to its support for language-specific backends and integration with language servers. It helps in reducing typing time and provides context-aware completions.
    • Emacs Users: Anyone already using Emacs as their primary editor will appreciate the seamless integration of Company Mode. It enhances the existing Emacs ecosystem by providing a robust completion framework.
    • Writers and Editors: While primarily aimed at programmers, Company Mode can also be beneficial for writers and editors who need auto-completion for repetitive text or specific terminology.


    Overall Recommendation

    Company Mode is an excellent addition to the Emacs editor for anyone seeking advanced auto-completion features. Here are some key points to consider:
    • Ease of Use: While it requires some configuration, the payoff in terms of productivity is significant. The documentation and community support are extensive, making it easier for new users to set up and customize.
    • Flexibility: The ability to mix and match different backends and configure them according to specific needs makes Company Mode highly adaptable to various workflows.
    • Performance: With the right settings, Company Mode can be very responsive, ensuring that it does not impact the overall performance of Emacs.
    In summary, Emacs with Company Mode is a powerful tool that can significantly enhance the productivity of developers and writers by providing a highly customizable and efficient auto-completion system. It is particularly recommended for those already familiar with Emacs or looking to leverage its extensive capabilities.

    Scroll to Top