Emacs: Difference between revisions

remove empty links, redundent links, and improper formatting
Warn about double-listing emacs-pgtk.
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{User:Layer-09/Sandbox/Infobox Emacs
{{application infobox
| title                  = GNU Emacs
  |name=GNU Emacs
| image                   = EmacsIcon.svg
  |image=EmacsIcon.svg
| paradigm                = Functional, meta, reflective
  |type=Text Editor
| family                  = Lisp
  |firstRelease=1985; 40 years ago
| designed_by            = Richard Stallman, Guy L. Steele, Jr.
  |license=[https://www.gnu.org/licenses/gpl.html GNU General Public License]
| developer              = [https://www.gnu.org/ GNU Project]
  |os=Cross-platform
| first_appeared          = 1985; 40 years ago
  |website=[https://www.gnu.org/software/emacs gnu.org/emacs]
| stable_release          = 30.1 / 23 February 2025
  |github=
| os                      = Cross-platform
}}
| license                 = [https://www.gnu.org/licenses/gpl.html GNU General Public License]
<strong>Emacs</strong> is a free and open-source text editor known for its exceptional extensibility and adaptability. It can be customized into anything from a simple editor to a full development environment or productivity tool. Emacs features built-in self-documentation, syntax-aware editing, and a vast ecosystem of community-developed packages.<ref>https://www.gnu.org/software/emacs/</ref>
| filename_extensions    = .el, .elc, .eln
| website                 = [https://www.gnu.org/software/emacs gnu.org/emacs]
}}<strong>Emacs</strong> is a free and open-source text editor known for its exceptional extensibility and adaptability. It can be customized into anything from a simple editor to a full development environment or productivity tool. Emacs features built-in self-documentation, syntax-aware editing, and a vast ecosystem of community-developed packages.<ref>https://www.gnu.org/software/emacs/</ref>


For an easier introduction, [https://doomemacs.org Doom Emacs] offers a pre-configured Emacs framework with modern defaults and features like IDE tools, note-taking, and task management.
For an easier introduction, [https://doomemacs.org Doom Emacs] offers a pre-configured Emacs framework with modern defaults and features like IDE tools, note-taking, and task management.
Line 23: Line 20:


To temporarily use Emacs in a shell environment without modifying your system configuration, you can run:
To temporarily use Emacs in a shell environment without modifying your system configuration, you can run:
<syntaxhighlight lang="console">
{{Commands|
<nowiki>
$ nix-shell -p emacs
$ nix-shell -p emacs
</syntaxhighlight>
</nowiki>
}}
This makes the Emacs editor available in your current shell. You can then launch Emacs by typing <code>emacs</code>.
This makes the Emacs editor available in your current shell. You can then launch Emacs by typing <code>emacs</code>.


Line 79: Line 78:
==== Installing Packages ====
==== Installing Packages ====
{{Note|Emacs, much like NixOS can rebuild and re-fetch all of its packages based on its initialization file alone, if one chooses to use an extension called "use-package". Such a configuration file can be version controlled and used in all compatible operating systems.}}
{{Note|Emacs, much like NixOS can rebuild and re-fetch all of its packages based on its initialization file alone, if one chooses to use an extension called "use-package". Such a configuration file can be version controlled and used in all compatible operating systems.}}
One can mix and match whether Emacs packages are installed by Nix or Emacs. This can be particularly useful for Emacs packages that need to be built, such as vterm. One way to install Emacs packages through Nix is by the following, replacing {{ic|emacsPgtkNativeComp}} with the variant in use:<syntaxhighlight lang="nix">
One can mix and match whether Emacs packages are installed by Nix or Emacs. This can be particularly useful for Emacs packages that need to be built, such as vterm. One way to install Emacs packages through Nix is by the following, replacing {{ic|emacs-pgtk}} with the variant in use:<syntaxhighlight lang="nix">
environment.systemPackages = with pkgs;
environment.systemPackages = with pkgs;
[ ...
[ ...
   ((emacsPackagesFor emacsPgtkNativeComp).emacsWithPackages (
   ((emacsPackagesFor emacs-pgtk).emacsWithPackages (
     epkgs: [ epkgs.vterm ]
     epkgs: [ epkgs.vterm ]
   ))
   ))
Line 90: Line 89:
# To make the packages available to emacsclient, one can do the following:
# To make the packages available to emacsclient, one can do the following:
services.emacs.package = with pkgs; (
services.emacs.package = with pkgs; (
   (emacsPackagesFor emacsPgtkNativeComp).emacsWithPackages (
   (emacsPackagesFor emacs-pgtk).emacsWithPackages (
     epkgs: [ epkgs.vterm ]
     epkgs: [ epkgs.vterm ]
   )
   )
Line 104: Line 103:




</syntaxhighlight>
</syntaxhighlight>Note that if the expression <code>(emacsPackagesFor emacs-pgtk)</code> is present, <code>emacs-pgtk</code> need not be listed separately in the list <code>environment.systemPackages</code>. Indeed, if one does that, <code>nixos-rebuild</code> will warn about link collisions when the configuration is rebuilt.


==== Tree-sitter ====
==== Tree-sitter ====
Line 206: Line 205:
   environment.systemPackages = with pkgs;
   environment.systemPackages = with pkgs;
     [ ...
     [ ...
       ((emacsPackagesFor emacsPgtkNativeComp).emacsWithPackages (epkgs: [  
       ((emacsPackagesFor emacs-pgtk).emacsWithPackages (epkgs: [  
           epkgs.vterm  
           epkgs.vterm  
           (callPackage ./lambda-line.nix {
           (callPackage ./lambda-line.nix {
Line 250: Line 249:
</nowiki>}}
</nowiki>}}


They are located at <code>pkgs/applications/editors/emacs/elisp-packages/manual-packages/</code> [https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/editors/emacs/elisp-packages/manual-packages] and a new pkg must be added under <code>pkgs/applications/editors/elisp-packages/manual-packages.nix</code> [https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/emacs/elisp-packages/manual-packages.nix]. Once the nixpkg is ready, it can be tested using the following command. This inserts the nixpkg into the load-path of Emacs.<syntaxhighlight lang="console">
They are located at <code>pkgs/applications/editors/emacs/elisp-packages/manual-packages/</code> [https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/editors/emacs/elisp-packages/manual-packages] and a new pkg must be added under <code>pkgs/applications/editors/elisp-packages/manual-packages.nix</code> [https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/emacs/elisp-packages/manual-packages.nix]. Once the nixpkg is ready, it can be tested using the following command. This inserts the nixpkg into the load-path of Emacs.
{{Commands|
<nowiki>
$ nix-shell -I nixpkgs=<path_to_nixpkgs_copy> -p "(emacsPackagesFor pkgs.emacs28).emacsWithPackages (epkgs: [ epkgs.<package> ])"
$ nix-shell -I nixpkgs=<path_to_nixpkgs_copy> -p "(emacsPackagesFor pkgs.emacs28).emacsWithPackages (epkgs: [ epkgs.<package> ])"
</syntaxhighlight>
</nowiki>
}}


==== Window Manager Integration ====
==== Window Manager Integration ====