Emacs: Difference between revisions

From wikinotes
No edit summary
 
No edit summary
Line 1: Line 1:
Emacs is another very powerful text editor. Contrary to vim, which was built for
Emacs is a text-editor that can be used in a GUI or a console.
text-editing alone (but has been hacked into doing other things), emacs is more of
an operating system. It uses LISP on the backend rather than vimscript. Though not modal
like vim by default, emacs has an '''evil-mode''' extension, which enables vim commands and
hotkeys within emacs.<br>
 
Personally, I'm considering making the change to emacs for two reasons:
* emacs-daemon allows you to share a single emacs session (using multiple files) with several separate client-windows. This make multi-monitor coding much more friendly.
* many of the most popular vim extensions have emacs counterparts
* more native shell, and other programs can run within emacs. (ex: w3m/mutt/irssi)


{{ TODO |
{{ TODO |
fix this page, it's yikesey }}
learn how to use emacs, then clean this up }}


= Install =
= Documentation =
<blockquote>
<blockquote>
== linux ==
{| class="wikitable"
{| class="wikitable"
|-
|-
!colspan=3| locations
| official docs || https://www.gnu.org/software/emacs/documentation.html
|-
|-
| <code>~/.emacs</code> || || main emacs config file
|}
</blockquote><!-- Documentation -->
 
= Locations =
<blockquote>
{| class="wikitable"
|-
|-
| <code>~/.emacs.d</code> || || emacs packages are installed here
| <code>~/.emacs</code> || main emacs config
|-
| <code>~/.emacs.d/</code> || emacs packages installed here
|}
|}
 
</blockquote><!-- Locations -->
<syntaxhighlight lang="bash">
sudo pacman -S emacs
</syntaxhighlight>
 
</blockquote><!-- install -->


= Tutorials =
= Tutorials =
Line 39: Line 31:
|}
|}
</blockquote><!-- tutorials -->
</blockquote><!-- tutorials -->
= Install =
<blockquote>
<syntaxhighlight lang="bash">
sudo pacman -S emacs
</syntaxhighlight>
</blockquote><!-- Install -->


= Terminology =
= Terminology =
Line 59: Line 58:


</blockquote><!-- Terminology -->
</blockquote><!-- Terminology -->
<br>
<br>


= Basics =
= Basics =
<blockquote>
<blockquote>
{|
{|
|-
|-
Line 72: Line 68:
|-
|-
|}
|}
</blockquote><!-- basics -->
</blockquote><!-- basics -->


Line 141: Line 135:
      (let ((uninstalled-pkgs (remove-if 'package-installed-p required-pkgs)))
      (let ((uninstalled-pkgs (remove-if 'package-installed-p required-pkgs)))
        (remove-if-not '(lambda (pkg) (y-or-n-p (format "Package %s is missing. Install it? " pkg))) uninstalled-pkgs)))
        (remove-if-not '(lambda (pkg) (y-or-n-p (format "Package %s is missing. Install it? " pkg))) uninstalled-pkgs)))
 
(when (> (length pkgs-to-install) 0)
(when (> (length pkgs-to-install) 0)
  (package-refresh-contents)
  (package-refresh-contents)

Revision as of 20:17, 19 September 2021

Emacs is a text-editor that can be used in a GUI or a console.

TODO:

learn how to use emacs, then clean this up

Documentation

official docs https://www.gnu.org/software/emacs/documentation.html

Locations

~/.emacs main emacs config
~/.emacs.d/ emacs packages installed here

Tutorials

vim to emacs https://blog.aaronbieber.com/2015/05/24/from-vim-to-emacs-in-fourteen-days.html

Install

sudo pacman -S emacs

Terminology

Terminology
emacs vim description
frame window A window to the WM. Contains splits.
window A clone of the current buffer. All properties are identical between all views of buffer EXCEPT for the cursor-point.
indirect-buffer split A totally independent copy of the current buffer. Text is shared/updated, but everything else is independent.

Basics

emacs basic usage
elisp

Minor Modes

emacs x-symbol alter display of characters by revel (like vim conceal)

Base Config

TODO:

get rid of this whole section once I have a real config

Package Manager

Manual Package Download
Provided that you have the package-archives variable (defined below) set up, you can search/download from the package-archives using:

<M-x>   package-list
<C-s>  <package-you-are-looking-for>


Automated Package Download
Automating package downloading from .emacs can be done with the following setup:

	;; Define Package Sources, Initialize Package Manager
	(setq package-archives '(("gnu"       .  "http://elpa.gnu.org/packages/")
	                         ("org"       .  "http://orgmode.org/elpa/")
	                         ("marmalade" .  "http://marmalade-repo.org/packages/")
	                         ("melpa"     .  "http://melpa.milkbox.net/packages/")
                           ;("melpa-stable" . "http://melpa-stable.milkbox.net/packages/")
									))
	(require 'package)
	(package-initialize)


	;; Define Packages to install
	(setq required-pkgs '(
								 evil
								 evil-tabs
								 evil-leader
								 evil-search-highlight-persist

								 airline-themes

								 neotree
								 projectile
								 grizzl

								 darktooth-theme
								 gruvbox-theme
							 ))


	;; Auto-Install Packages
	(require 'cl)

	(setq pkgs-to-install
	      (let ((uninstalled-pkgs (remove-if 'package-installed-p required-pkgs)))
	        (remove-if-not '(lambda (pkg) (y-or-n-p (format "Package %s is missing. Install it? " pkg))) uninstalled-pkgs)))

	(when (> (length pkgs-to-install) 0)
	  (package-refresh-contents)
	  (dolist (pkg pkgs-to-install)
	    (package-install pkg)))

Keybinding

	;; Evil-Mode Keybinding
	(define-key evil-normal-state-map (kbd "C-h") 'evil-window-left)


	;; Binding Multiple commands to a single Key-Sequence
	(define-key evil-insert-state-map (kbd "M-h") (lambda () (interactive)  (backward-char) (evil-normal-state)  ))

	;; Binding Key-Sequence to another Key-Sequence