To follow along locally using Emacs 25;
git clone https://github.com/dgtized/brave-new-emacs.git
cd brave-new-emacs
emacs -q README.org &
- Ensure we are not using the default .emacs.d.
- Unnecessary for an actual configuration
- Type
C-c C-c
inBEGIN_SRC
block below to install - Press
F7
to start/resume presentation mode (q
to quit)
(setq user-emacs-directory (concat (getenv "PWD") "/"))
(setq package-user-dir (locate-user-emacs-file "elpa"))
(add-to-list 'load-path user-emacs-directory t)
;; From https://raw.github.com/eschulte/epresent/master/epresent.el
(require 'epresent)
(global-set-key (kbd "<f7>") 'epresent-run)
;; Disable prompting to evaluate babel blocks
(setq org-confirm-babel-evaluate nil)
- Epresent is prettier, and recommended
- org-tree-slide is less invasive, installed on
F8
;; From https://raw.github.com/takaxp/org-tree-slide/master/org-tree-slide.el
(require 'org-tree-slide)
(global-set-key (kbd "<f8>") 'org-tree-slide-mode)
(global-set-key (kbd "S-<f8>") 'org-tree-slide-skip-done-toggle)
- Binary is an emacs lisp interpreter
- Majority of functionality is written in elisp
- No difference between user code and distribution
Startup loads init files prior to giving control to user
- loadup.el system libraries
- Site or distribution
- User (
~/.emacs
,~/.emacs.el
or~/.emacs.d/init.el
)
- Defines how a user interacts with the editor syntax tables, derived modes, keybindings, menus
- Only one active at a time
Examples:
- org-mode
- emacs-lisp-mode
- eshell-mode
- minibuffer
As many as you want
Examples:
- column-number-mode
- visual-line-mode
- flyspell-mode
- transient-mark-mode
- show-paren-mode
- Global
- The top level binding
- Prefix
- Use prefix and dispatch to new map
- Minimap
- Temporary mode with different bindings
Try C-x C-h
or C-x a C-h
for binding help for prefix
Keymaps are inherited or unique
Keybinding | Description |
---|---|
C-x C-e | Eval previous expression |
C-M-x | Eval defun |
C-u C-M-x | Debug defun at point |
TAB | Org and Magit Toggle |
C-h m | Mode specific help |
C-h k | Key specific help |
C-h b | List all bindings |
C-h f | Function specific help |
C-c C-c | Org-mode DWIM at point |
- Hooks are callbacks to run a list of functions
add-hook
,remove-hook
,run-hooks
Examples:org-mode-hook
,prog-mode-hook
defadvice
for aspect oriented programmingaround
,before
,after
on any function- For extending existing functionality
- Stop asking yes or no, y or n suffice
- Find library source for any installed library
C-x C-j
to jump to dired for current file
(defalias 'yes-or-no-p 'y-or-n-p)
(define-key help-map (kbd "C-l") 'find-library)
(require 'dired-x)
A file or files containing elisp
- rot13
- decrypt rot13 library/mode
- ido
- minor mode extending minibuffer completion
- simple
- the basic editor commands
- isearch, linum, byte-compiler, interpeter, edebug, menu
Where to look for libraries and when to load
- Load
- Always executes
(load "/path/to/library")
- Provide
- Names a files code ‘foo
(provide 'foo)
- Require
- Conditionally load ‘foo from
load-path
(require 'foo)
- Autoload
- Requires ‘foo if ‘foo-func is used
(autoload 'foo-func 'foo)
- Automatically downloads emacs packages from an archive
- Updates installed packages
- Extends
load-path
and generates package autoloads - Builtin since Emacs 24
- Melpa
- Milkypostman’s Emacs Lisp Package Archive latest and bleeding edge
- Marmalade
- Spreadable Elisp versioned and recent
- ELPA
- Emacs Lisp Package Archive Hosted at GNU Savannah, FSF-GPL only
(require 'package)
(add-to-list
'package-archives
'("melpa" . "https://melpa.org/packages/"))
(package-initialize)
M-x package-list-packages
and install better-defaults
i | marks package for Install |
d | marks package for Deletion |
x | eXecutes pending |
U | mark Upgrades |
u | Unmark package |
h | Help |
Just copy your init.el file and start emacs
(defun ensure-packages (package-list)
"Ensures packages in list are installed locally"
(unless (file-exists-p package-user-dir)
(package-refresh-contents))
(dolist (package package-list)
(unless (package-installed-p package)
(package-install package))))
(ensure-packages '(better-defaults))
Keywords in package header
- Package-Requires
- package dependency list
- Version
- for specific versions
M-x package-install-from-file
not-in-load-path/github-browse-settings.el
Package is now installed in package-user-dir
For development try package-install-from-buffer
To run this automatically;
(package-install-file "not-in-load-path/github-browse-settings.el")
(require 'github-browse-settings)
Smart M-x
, or Ido for M-x
(ensure-packages '(smex))
(global-set-key (kbd "C-x C-m") 'smex)
(global-set-key (kbd "C-c C-m") 'smex-major-mode-commands)
(setq avy-background t
avy-style 'at-full)
Faster than a speeding mouse!
(ensure-packages '(avy))
(global-set-key (kbd "C-;") 'avy-goto-word-or-subword-1)
(global-set-key (kbd "C-M-;") 'avy-pop-mark)
magit is friends with git
(ensure-packages '(magit))
(global-set-key (kbd "C-x g") 'magit-status)
- magit-blame-mode
- Inline blame mode
- magit-file-log
- Show git log for file
projectile uses version control to define a project
Try C-c p C-h
to see all it provides
(ensure-packages '(projectile))
(projectile-global-mode)
Quickly navigate to function at point in elisp with xref
M-. | jump to function |
M-, | return to last point |
Eldoc is also builtin and shows function arguments in the minibuffer
(dolist (hook '(emacs-lisp-mode-hook ielm-mode-hook))
(add-hook hook 'turn-on-eldoc-mode))
Zenburn is a nice dark theme
(ensure-packages '(zenburn-theme))
(load-theme 'zenburn t)
Org can create links like so:
[[href][name]]
(global-set-key (kbd "C-c l") 'org-store-link)
C-c C-l
to link in org-mode, C-c C-o
to visit
Type C-c C-v t
to generate init.el
from this file.
At the terminal:
emacs -q -l init.el &
Use C-c ’ to edit BEGIN_SRC
blocks in their own major mode