- My Emacs Setup & Tutorial
- 1.1. Basics
- 1.2. Major packages I use
- 1.2.1. How to install packages
- 1.2.2. Auto Completion
- 1.2.3. Key chords
- 1.2.4. Nyan mode
- 1.2.5. AucTeX
- 1.2.6. Suggestions/Expansions/Matching in commands
- 1.2.7. Suggestions and Fuzzy Matching in Minibuffer
- 1.2.8. Code snippets
- 1.2.9. Undo Tree
- 1.2.10. Recent file list
- 1.2.11. Spellcheck
- 1.2.12. Code
- 1.2.13. Git
- 1.2.14. Terminal
- 1.2.15. Org
- 1.2.16. View Possible keybindings:
- 1.2.17. GoTo
- 1.2.18. Multiple cursors
- 1.2.19. File & Directory Navigator
- 1.2.20. Project management
- 1.2.21. Outline of file/project
- 1.3. Misc Tips & Tricks
- 1.4. My init
-
Window = host for buffer;
-
Frame = what is normally called a window in the OS;
-
Modeline = status bar;
-
Minibuffer + Echo area = input/output strip at the bottom (under the modeline);
-
Kill = cut (for text), close (for buffers);
-
Yank = paste;
-
Save in the kill ring = copy;
-
Font locking = syntax highlight;
-
Mark = select;
-
Point = cursor;
-
Fill = wrap (e.g. column fill = what is normally called "wrap text");
-
init file = the dotfile for configurations;
-
Major mode = the syntax/filetype you're using (e.g. Python mode, C++ mode, Markdown mode);
-
Minor mode = other sets of preferences added;
-
Help items = apropos (e.g. apropos for function )
-
C
= ctrl key; -
M
= meta key (Alt by default)
- hook = dependency. For example, if a command is preceded by
(add-hook 'org-mode-hook (command))
, it is evaluated only iforg-mode
is enabled; - values to variables are given with
(setq variable value)
or(setq-default variable default-value)
; - other functions/commands are called with
quote
or'
, e.g.(global-set-key (key-which-calls) 'this-function)
;
- From terminal:
emacs -q
= start without the init file;
Command | Shortcut | Remarks/Examples |
Quit | C-x C-c | |
Cancel Command | C-g | |
Forward 1 char | C-f | |
Back 1 char | C-b | |
End of line | C-e | |
Beginning of line | C-a | |
Down 1 line | C-n | |
Up 1 line | C-p | |
Forward 1 word | M-f | |
Back 1 word | M-b | |
Beginning of buffer | M-< | |
End of buffer | M-> | |
Beginning of sentence |
M-a |
|
End of sentence | M-e | |
Page up | M-v | |
Page down | C-v | |
Forward delete 1 char |
C-d |
|
Back delete 1 char | DEL | |
Forward delete 1 word |
M-d |
|
Start/stop selection | C-SPC | |
Copy | M-w | |
Cut | C-w | |
Paste | C-y | |
Undo | C-/ or C-x u | |
Open/create file | C-x C-f | |
Save | C-s C-s | |
Save all open | C-x s | |
View open Buffers | C-x C-b | |
Go to buffer | C-x b | |
Forward search |
C-s |
C-s for next, RET to choose, C-g to cancel, C-r to go back |
Reverse search |
C-r |
C-r for next, RET to choose, C-g to cancel, C-s to go fwd |
Find & Replace | M-% | |
Cancel all commands |
ESC ESC ESC |
C-g cancels only the prev command |
Keep only 1 window | C-x 1 | |
Horizontal split | C-x 2 | |
Vertical split | C-x 3 | |
Go to other window | C-x o | |
General help | C-h ? | |
Keybinding help |
C-h k |
then press key to see the command for it (if any) |
Function help | C-h f | |
Put cursor to previous position |
C-u C-SPC or C-x C-x |
|
Access command | M-x | |
Numeric prefix |
C-u NUMBER COMMAND |
C-u 10 * writes 10 stars, C-u 10 M-d deletes forward 10 words |
General prefs (apropos) |
M-x customize |
TAB to navigate links/buttons |
Toggle comments |
M-; |
select region, then M-; |
Select all | C-x h | |
Put current line to top/middle/center of screen |
C-l (lowercase L) |
once = current line in the middle, twice = top, thrice = bottom |
C-M-p C-M-n |
Go to open paren Go to closing paren |
|
C-M-@ | Mark inside of parens | Calls the function 'mark-sexp |
- The
init
file is~/.emacs
; - Packages and their preferences are in
~/.emacs.d/
init
file configs:
- Package repo(s):
(require 'package) ;; call the package for packages
(add-to-list 'package-archives '("melpa" . "https://melpa.milkbox.net/packages")) ;; best
(package-initialize) ;; auto refresh and load packages
Custom packages (not from MELPA or other officially loaded repos)
(add-to-list 'load-path "~/path/to/my/package/")
- Interface:
(when (window-system)
(tool-bar-mode -1) ;; hide toolbar
(scroll-bar-mode -1) ;; hide scrollbar
(set-frame-size (selected-frame) 100 60) ;; in px
(set-frame-font "Input Mono Narrow-12") ;; default font
(global-visual-line-mode t) ;; wrap text to words at the end of the window (def chars)
(global-hl-line-mode t) ;; highlight current line
(global-font-lock-mode t) ;; syntax highlight wherever
(blink-cursor-mode 0) ;; disabled. put (blink-cursor-blinks NN) for NN blinks.
;; def 10, 0 or negative = forever
(column-number-mode) ;; view column number in modeline
(setq-default line-spacing 3) ;; increase line height
(show-paren-mode 1) ;; highlight matching parentheses
(save-place-mode) ;; remember point position when saving file
(setq-default tab-width 4)
(setq-default indent-tabs-mode nil) ;; convert tabs to spaces
- Other tweaks:
(delete-selection-mode 1) ;; when writing over selection, to replace
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(getenv "PATH") ;; customize $PATH, if needed
(setenv "PATH"
(concat
"/my/custom/path" ":"
(getenv "PATH")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq debug-on-error t) ;; open a buffer with errors if appeared
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(global-set-key (kbd "C-abc") 'this-function) ;; pressing C-a bc calls 'this-function
(global-unset-key (kbd "C-a")) ;; deactivates the command on C-a
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'major-mode-hook 'minor-mode-hook) ;; always enable that minor mode in that major mode
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq-default indicate-empty-lines t) ;; show where buffer ends in the fringe (left gutter)
- Mode specific tweaks:
(add-hook 'major-mode-hook
(lambda ()
(define-key major-mode-map (kbd "C-a") 'function)))
;; defines C-a only in that major-mode
When M-x customize
, it creates in the init
file groups of
customizations under
(custom-set-variables
(stuff))
DO NOT, EVER change those manually (they will be reset or conflict).
If you want to change something from there, remember the variable or
function name and M-x customize-variable
or M-x customize-group
.
M-x customize-theme
. RET to select it temporarily, RET + C-x C-s to
set it permanently.
- one by one
M-x package-install
-> choose ->RET
; - Many & Browse list:
M-x package-list-packages
-> view list, search;- When on the line of the package, press
I
to mark for installation; - If there are updates (view minibuffer messages), go to them and press
U
to mark for update; - If you want to uninstall, go to it and press
D
to mark for deletion; - Finally, press
X
to execute all markings.
- When on the line of the package, press
Auto Complete
or Company
. Can't decide.
Configs:
(require 'auto-complete)
(require 'company)
Then M-x customize-group RET company
and edit prefs.
For keybindings, example:
(global-set-key (kbd "C-x") 'some-company-function) ;;for global config
(add-hook 'company-mode-hook
(lambda ()
(define-key company-mode-map (kbd "C-x") 'some-company-function)))
;; for local config, only when company is enabled
For shortcuts based on 2 keys pressed simultaneously or fast one after the other.
However, the shortest delay is 0.05s and apparently, I type too fast…
…
Not available in MELPA, must be loaded separately.
Best package for LaTeX.
For optimal config with Skim & synctex:
;; AucTeX settings
(setq TeX-PDF-mode t)
(setq TeX-fold-mode 1)
(add-hook 'LaTeX-mode-hook
(lambda ()
(push
'("latexmk" "latexmk -pdf %s" TeX-run-TeX nil t
:help "Run latexmk on file")
TeX-command-list)))
(add-hook 'TeX-mode-hook '(lambda () (setq TeX-command-default "latexmk")))
(setq TeX-view-program-selection '((output-pdf "PDF Viewer")))
(setq TeX-view-program-list
'(("PDF Viewer" "/Applications/Skim.app/Contents/SharedSupport/displayline -b -g %n %o %b")))
(getenv "PATH")
(setenv "PATH"
(concat
"/Library/TeX/texbin" ":" "usr/local/bin" ":"
(getenv "PATH")))
(setq LaTeX-includegraphics-read-file 'LaTeX-includegraphics-read-file-relative)
Helm
.
My config:
(require 'helm)
(require 'helm-config)
;; The default "C-x c" is quite close to "C-x C-c", which quits Emacs.
;; Changed to "C-c h". Note: We must set "C-c h" globally, because we
;; cannot change `helm-command-prefix-key' once `helm-config' is loaded.
(global-set-key (kbd "C-c h") 'helm-command-prefix)
(global-unset-key (kbd "C-x c"))
(global-set-key (kbd "M-x") 'helm-M-x) ; This was not present in the suggested extended config
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action) ; rebind tab to run persistent action
(define-key helm-map (kbd "C-i") 'helm-execute-persistent-action) ; make TAB works in terminal
(define-key helm-map (kbd "C-z") 'helm-select-action) ; list actions using C-z
;; C-o jumps to the other sources (from history/emacs commands)
(when (executable-find "curl")
(setq helm-google-suggest-use-curl-p t))
(setq helm-split-window-in-side-p t ; open helm buffer inside current window, not occupy whole other window
helm-move-to-line-cycle-in-source t ; move to end or beginning of source when reaching top or bottom of source.
helm-ff-search-library-in-sexp t ; search for library in `require' and `declare-function' sexp.
helm-scroll-amount 8 ; scroll 8 lines other window using M-<next>/M-<prior>
helm-ff-file-name-history-use-recentf t)
(helm-mode 1)
IDO
.
My config:
(require 'ido)
(ido-mode t)
(setq ido-everywhere t)
(setq ido-enable-flex-matching t) ;; for fuzzy search
Yasnippet
. If necessary, download additional snippets (e.g. yasnippet-latex).
My config:
(require 'yasnippet)
(yas-global-mode 1)
With diff and branches as in git.
See Sacha Chua's config.
Recentf
My config:
(require 'recentf)
(setq recentf-max-saved-items 200
recentf-max-menu-items 15)
(recentf-mode)
(global-set-key (kbd "C-c rec") 'recentf-open-files) ;; view list of recently used files
Flyspell, Aspell, Ispell
.
Not so sure about the config. Check my init
for everything "spell".
The main idea:
- Emacs uses
Ispell
by default; - You may want to use
aspell
(it has more and updated dictionaries), so download that (possibly make, make install); - Point
Ispell
to useaspell
:
'(ispell-program-name "/usr/local/bin/aspell")
- Use
Flyspell
for "spellcheck on the fly". It basically provides an interface to access spelling capabilities.
Useful keybindings:
C-.
= cycle autocorrect of word at point (view minibuffer for options that are cycled). If you are not at a misspelled word, it acts on the first misspell (from the beginning of the file);C-c $
= open contextual menu with suggestions or save ("learn") option.C-c $ sa
will take you directly to the "Save word" option.
Pro Tip: this post gives a method of correcting spelling errors and at the same time, adding an automatic expansion whenever that error reappears. So it will have autocorrect for that misspelling. It is based on built-in minor modes, abbrev
and ispell
.
Code:
(define-key ctl-x-map "\C-i"
#'endless/ispell-word-then-abbrev)
(defun endless/simple-get-word ()
(car-safe (save-excursion (ispell-get-word nil))))
(defun endless/ispell-word-then-abbrev (p)
"Call `ispell-word', then create an abbrev for it.
With prefix P, create local abbrev. Otherwise it will
be global.
If there's nothing wrong with the word at point, keep
looking for a typo until the beginning of buffer. You can
skip typos you don't want to fix with `SPC', and you can
abort completely with `C-g'."
(interactive "P")
(let (bef aft)
(save-excursion
(while (if (setq bef (endless/simple-get-word))
;; Word was corrected or used quit.
(if (ispell-word nil 'quiet)
nil ; End the loop.
;; Also end if we reach `bob'.
(not (bobp)))
;; If there's no word at point, keep looking
;; until `bob'.
(not (bobp)))
(backward-word)
(backward-char))
(setq aft (endless/simple-get-word)))
(if (and aft bef (not (equal aft bef)))
(let ((aft (downcase aft))
(bef (downcase bef)))
(define-abbrev
(if p local-abbrev-table global-abbrev-table)
bef aft)
(message "\"%s\" now expands to \"%s\" %sally"
bef aft (if p "loc" "glob")))
(user-error "No typo at or before point"))))
(setq save-abbrevs 'silently)
(setq-default abbrev-mode t)
More smart approaches on spell-checking here.
"IDEs":
- Python:
Elpy
; - Haskell:
Intero
.
Syntax and style: Flymake
.
RTFM.
3 types:
M-x ansi-term
;M-x shell
;M-x term
.
Org mode is life.
RTFM.
Pro Tips:
- Reference a specific line in current buffer:
[[file:::lineno]]
. Example[[file:::25]]
puts a hyperlink to line 25 of current buffer. To reference a line from another file:[[file:/path/to/file::lineno]]
. To link to first occurrence ofword
in a file:[[file:/path/to/file::word]]
. - Point on link ->
C-c C-o
opens the location (in a separate buffer). - More on support for external/internal links in Org here;
- Document outline, most "native" solution:
M-x occur RET ^*+SPC RET
.
WhichKey
.
Press a generic command key (C-c
or C-x
), wait 1 sec and see all possible
commands in the minibuffer.
Avy
(newer) or AceJump
(older).
Functions: goto-char, goto-2chars, goto-line, goto-word…
Multiple cursors
.
Check this.
Dired
. Built in.
Tweak to show icons for filetypes and folders: Install package all-the-icons
and all-the-icons-dired
.
Then:
(use-package all-the-icons)
(require 'all-the-icons-dired)
(add-hook 'dired-by-name-mode-hook 'all-the-icons-dired-mode)
(add-hook 'dired-mode-hook 'all-the-icons-dired-mode)
Org
, LaTeX
, Markdown
and other modes have their own outliner.
For general use: Speedbar (built in), Sr-Speedbar = Speedbar in the same frame, NeoTree à la NerdTree (vim).
- Check my
init
file; - (book): Mickey Petersen - Mastering Emacs;
follow-mode
: open a file in 2 buffers for continuous view:gist
package (in MELPA). Documentation;- Sacha Chua's init & explanations;
- Xah;
- Emacs for writers. Also, this clip;
- Emacs vs Scrivener?;
- C'est la Z (for programmers and beginners);
- Further documentation and APIs: Dash is a good "start". See here;
- Ligatures for Fira Mono font: setup.
- Rainbow parentheses:
(setq user-full-name "Adrian Manea")
(setq user-mail-address "[email protected]")
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.milkbox.net/packages/"))
(package-initialize)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ===GLOBAL & INTERFACE TWEAKS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(set-frame-font "Input Mono Narrow 12")
(when (window-system)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(set-frame-size (selected-frame) 100 64))
(when (memq window-system '(mac ns)) ;; for bash shell as in macOS
(exec-path-from-shell-initialize))
(global-visual-line-mode t)
(global-hl-line-mode t)
(global-font-lock-mode t)
(blink-cursor-mode 0)
(column-number-mode)
(delete-selection-mode 1)
;; make the fringe stand out from the background
(setq solarized-distinct-fringe-background t)
;; don't use italic in solarized
(setq solarized-italic nil)
;; solarized use less bold
;; (setq solarized-use-less-bold t)
(ivy-mode 1)
(setq-default indicate-empty-lines t)
(prefer-coding-system 'utf-8)
(when (display-graphic-p)
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)))
(set-face-attribute 'show-paren-match nil :weight 'extra-bold)
(setq-default tab-width 4)
(setq-default indent-tabs-mode nil) ;; convert tabs to spaces
(save-place-mode)
(set-face-italic-p 'italic nil)
(setq default-abbrev-mode t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ===PACKAGE & PATH CALL
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'yasnippet)
(yas-global-mode 1)
(require 'auto-complete)
(require 'company)
(use-package which-key
:ensure t
:config
(which-key-mode))
(use-package all-the-icons)
(require 'all-the-icons-dired)
;; MultiMarkdown minor mode
(load "/Users/adi/.emacs.d/elpa/mmd-mode-master/mmd-mode")
(use-package mmd-mode)
(require 'recentf)
(setq recentf-max-saved-items 200
recentf-max-menu-items 15)
(recentf-mode)
(use-package undo-tree
:diminish undo-tree-mode
:config
(progn
(global-undo-tree-mode)
(setq undo-tree-visualizer-timestamps t)
(setq undo-tree-visualizer-diff t)))
(load "/Users/adi/.emacs.d/show-point-mode")
(require 'show-point-mode)
(show-point-mode t)
(load "/Users/adi/.emacs.d/elpa/pdftools")
(add-to-list 'load-path "/usr/local/Cellar/maxima/5.38.1/share/maxima/5.38.1/emacs")
(autoload 'maxima-mode "maxima" "Maxima mode" t)
(autoload 'imaxima "imaxima" "Frontend for maxima with Image support" t)
(autoload 'maxima "maxima" "Maxima interaction" t)
(autoload 'imath-mode "imath" "Imath mode for math formula input" t)
(setq imaxima-use-maxima-mode-flag t)
(add-to-list 'auto-mode-alist '("\\.ma[cx]" . maxima-mode))
(setq inferior-lisp-program "clisp")
(add-to-list 'exec-path "/usr/local/bin")
(defvar inferior-lisp-buffer "*inferior-lisp*")
(setq inferior-lisp-buffer "*inferior-lisp*")
(require 'paren)
(show-paren-mode 1)
(setenv "ESHELL" (expand-file-name "~/bin/eshell"))
(require 'multiple-cursors)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ===GLOBAL KEYBINDINGS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(global-set-key (kbd "C-M-ă") 'mark-sexp)
(global-set-key (kbd "M-“") (lambda () (interactive) (insert "~")))
(global-set-key (kbd "M-„") (lambda () (interactive) (insert "`")))
(global-set-key (kbd "C-c j") 'avy-goto-char)
(global-set-key (kbd "C-ă") 'company-complete)
(global-set-key (kbd "C-c ins") 'my-insert-file-name)
(global-set-key (kbd "C-c fi") 'auto-fill-mode)
(global-set-key (kbd "C-c fly") 'flyspell-mode)
(global-set-key (kbd "C-c r n") 'rename-file-and-buffer) ;; keybinding for rename
(global-set-key (kbd "C-c m") 'markdown-preview-file)
(global-set-key (kbd "C-c r e c") 'recentf-open-files) ;; for recent file list
(global-set-key (kbd "C-c C-m e") 'mc/edit-lines)
(global-set-key (kbd "C-ș") 'mc/mark-next-like-this)
(global-set-key (kbd "C-ț") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-â") 'mc/mark-all-like-this)
(global-set-key (kbd "C-c l o c") 'locate)
(global-set-key (kbd "s-c") 'move-beginning-of-line) ;
(global-set-key (kbd "C-w") 'kill-region) ;; cut selection
(global-unset-key (kbd "C-\\"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ===MODE HOOKS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'dired-mode-hook 'all-the-icons-dired-mode)
(add-hook 'dired-by-name-mode-hook 'all-the-icons-dired-mode)
(add-hook 'image-mode-hook 'imagex-global-sticky-mode)
(add-hook 'prog-mode-hook
(lambda ()
;; (rainbow-delimiters-mode)
(flyspell-prog-mode)))
(add-hook 'org-mode-hook
(lambda ()
(define-key org-mode-map "\C-a" 'move-beginning-of-line)
(define-key org-mode-map "\C-e" 'move-end-of-line)
(define-key org-mode-map (kbd "C-c w") 'org-where-am-i)
(define-key org-mode-map (kbd "M-TAB") nil)
(define-key org-mode-map (kbd "C-m") nil) ;; it is equiv to RET, so we don't need it
(auto-fill-mode)
(flyspell-mode 1)
(flyspell-mode -1)
(flyspell-prog-mode)
(pandoc-mode)
;; (rainbow-delimiters-mode)
(define-key org-mode-map (kbd "C-\\") 'org-toggle-pretty-entities)
(define-key org-mode-map (kbd "C-,") nil)))
(add-hook 'markdown-mode-hook
(lambda ()
(turn-on-orgtbl)
(pandoc-mode)))
(add-hook 'haskell-mode-hook 'intero-mode)
(add-hook 'flyspell-mode-hook
(lambda ()
(define-key flyspell-mode-map (kbd "C-c er") 'fd-switch-dictionary)
(define-key flyspell-mode-map (kbd "C-M-i") nil)
(define-key flyspell-mode-map (kbd "M-TAB") nil)
(define-key flyspell-mode-map (kbd "C-,") nil)))
(eval-after-load 'company
'(progn
(define-key company-active-map (kbd "TAB") nil) ;; 'company-complete-common-or-cycle)
(define-key company-active-map (kbd "<tab>") nil) ;;'company-complete-common-or-cycle)
(define-key company-active-map [tab] nil) ;; 'company-complete-common-or-cycle)
(define-key company-active-map (kbd "C-p") 'company-select-previous)
(define-key company-active-map (kbd "C-n")'company-select-next)
(define-key company-active-map (kbd "SPC") nil)
(define-key company-active-map (kbd "C-SPC") nil)))
(add-hook 'LaTeX-mode-hook
(lambda ()
(pandoc-mode)
(reftex-mode)))
(add-hook 'auto-complete-mode-hook
(lambda ()
(define-key ac-menu-map "\C-n" 'ac-next)
(define-key ac-menu-map "\C-p" 'ac-previous)))
(add-hook 'python-mode-hook
(lambda ()
(elpy-mode 1)))
(add-hook 'slime-mode-hook 'set-up-slime-ac)
(add-hook 'slime-repl-mode-hook 'set-up-slime-ac)
(eval-after-load "auto-complete"
'(add-to-list 'ac-modes 'slime-repl-mode))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ===MANUAL CUSTOM SET VARIABLES
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq ac-use-menu-map t)
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
(setq-default line-spacing 3)
(set-face-italic 'font-lock-comment-face nil)
;; Use spotlight index for M-x locate
(setq locate-command "mdfind")
(setq company-dabbrev-downcase nil) ;; make company-complete care about case
(setq company-dabbrev-ignore-case nil) ; default is keep-prefix
(setq neo-theme (if (display-graphic-p) 'icons 'arrow))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ===CUSTOM SET VARIABLES
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(TeX-source-correlate-method (quote synctex))
'(TeX-source-correlate-mode t)
'(TeX-source-correlate-start-server t)
'(ac-auto-show-menu t)
'(ac-auto-start nil)
'(ac-ignore-case nil)
'(ac-menu-height 5)
'(airline-display-directory nil)
'(ansi-color-names-vector
["#073642" "#dc322f" "#859900" "#b58900" "#268bd2" "#d33682" "#2aa198" "#657b83"])
'(ansi-term-color-vector
[unspecified "#2e3440" "#88c0d0" "#bf616a" "#5e81ac" "#ebcb8b" "#a3be8c" "#ebcb8b" "#e5e9f0"] t)
'(backup-directory-alist (quote ((".*" . "/Users/adi/.emacs.d/backups"))))
'(company-auto-complete nil)
'(company-idle-delay nil)
'(company-minimum-prefix-length 1)
'(company-show-numbers t)
'(company-tooltip-idle-delay nil)
'(compilation-message-face (quote default))
'(completion-styles (quote (basic partial-completion emacs22 initials)))
'(cua-global-mark-cursor-color "#2aa198")
'(cua-normal-cursor-color "#839496")
'(cua-overwrite-cursor-color "#b58900")
'(cua-read-only-cursor-color "#859900")
'(custom-enabled-themes (quote (solarized-dark)))
'(custom-safe-themes
(quote
("8aebf25556399b58091e533e455dd50a6a9cba958cc4ebb0aab175863c25b9a4" "c6ca1020bba1e8ca7af8a78b05f45f7a74cae8756da673d5168283fd0fe937d8" default)))
'(enable-completion nil)
'(fci-rule-color "#073642")
'(fill-column 90)
'(font-latex-fontify-script nil)
'(font-latex-fontify-sectioning 1)
'(frame-background-mode (quote dark))
'(frame-resize-pixelwise t)
'(global-auto-complete-mode nil)
'(global-company-mode t)
'(global-hl-line-mode t)
'(global-undo-tree-mode t)
'(global-visual-fill-column-mode t)
'(global-visual-line-mode t)
'(gnus-completion-styles (quote (substring basic partial-completion emacs22)))
'(helm-ff-file-name-history-use-recentf t)
'(helm-ff-search-library-in-sexp t)
'(helm-mode t)
'(helm-move-to-line-cycle-in-source t)
'(helm-net-prefer-curl t)
'(helm-scroll-amount 8)
'(helm-split-window-in-side-p t)
'(highlight-changes-colors (quote ("#d33682" "#6c71c4")))
'(highlight-symbol-colors
(--map
(solarized-color-blend it "#fdf6e3" 0.25)
(quote
("#b58900" "#2aa198" "#dc322f" "#6c71c4" "#859900" "#cb4b16" "#268bd2"))))
'(highlight-symbol-foreground-color "#586e75")
'(highlight-tail-colors
(quote
(("#eee8d5" . 0)
("#B4C342" . 20)
("#69CABF" . 30)
("#69B7F0" . 50)
("#DEB542" . 60)
("#F2804F" . 70)
("#F771AC" . 85)
("#eee8d5" . 100))))
'(hl-bg-colors
(quote
("#DEB542" "#F2804F" "#FF6E64" "#F771AC" "#9EA0E5" "#69B7F0" "#69CABF" "#B4C342")))
'(hl-fg-colors
(quote
("#fdf6e3" "#fdf6e3" "#fdf6e3" "#fdf6e3" "#fdf6e3" "#fdf6e3" "#fdf6e3" "#fdf6e3")))
'(hl-paren-background-colors (quote ("#2492db" "#95a5a6" nil)))
'(hl-paren-colors
(quote
("#B9F" "#B8D" "#B7B" "#B69" "#B57" "#B45" "#B33" "#B11")))
'(hl-sexp-background-color "#1c1f26")
'(imagex-global-sticky-mode t)
'(inferior-lisp-program "/usr/local/bin/clisp" t)
'(inhibit-startup-screen t)
'(initial-frame-alist (quote ((vertical-scroll-bars))))
'(ispell-alternate-dictionary nil)
'(ispell-dictionary "english")
'(ispell-local-dictionary nil)
'(ispell-program-name "/usr/local/bin/aspell")
'(linum-format " %5i ")
'(magit-diff-use-overlays nil)
'(modelinepos-column-limit 80)
'(next-screen-context-lines 20)
'(nrepl-message-colors
(quote
("#dc322f" "#cb4b16" "#b58900" "#546E00" "#B4C342" "#00629D" "#2aa198" "#d33682" "#6c71c4")))
'(ns-alternate-modifier (quote meta))
'(ns-antialias-text t)
'(ns-command-modifier (quote super))
'(ns-function-modifier (quote none))
'(ns-right-alternate-modifier (quote none))
'(org-export-backends (quote (html icalendar latex md odt)))
'(org-export-default-language "en")
'(org-fontify-quote-and-verse-blocks t)
'(org-latex-create-formula-image-program (quote imagemagick))
'(org-modules
(quote
(org-bbdb org-bibtex org-ctags org-docview org-gnus org-info org-irc org-mhe org-rmail org-w3m)))
'(org-odt-convert-process "unoconv")
'(org-odt-convert-processes (quote (("unoconv" "unoconv -f %f -o %d %i"))))
'(org-preview-latex-default-process (quote imagemagick))
'(org-src-fontify-natively t)
'(org-startup-folded (quote showeverything))
'(package-enable-at-startup nil)
'(package-selected-packages
(quote
(spacemacs-theme nord-theme doom-themes rainbow-delimiters circe circe-notifications helm-circe org-pdfview color-theme-solarized counsel counsel-osx-app counsel-projectile flyspell-correct-ivy ivy-bibtex ivy-erlang-complete ivy-gitlab ivy-historian ivy-hydra ivy-pages ivy-rich ivy-todo swiper smooth-scrolling rebox2 boxquote reveal-in-osx-finder htmlize ob-browser ob-http ob-ipython ob-php ob-prolog ob-sagemath ob-translate ox-epub ox-gfm ox-pandoc ox-rst markdown-mode+ magithub gist flycheck-haskell haskell-mode haskell-snippets intero flymake-haskell-multi org-babel-eval-in-repl avy avy-flycheck avy-menu avy-zap common-lisp-snippets lisp-extra-font-lock flylisp sr-speedbar sage-shell-mode neotree typo leuven-theme which-key modeline-posn wide-column gnuplot-mode gnuplot image+ dic-lookup-w3m helm-w3m w3m arjen-grey-theme darktooth-theme atom-one-dark-theme zenburn-theme helm-mode-manager company-bibtex org browse-kill-ring wrap-region all-the-icons-dired all-the-icons magit use-package undo-tree ac-slime wc-mode pandoc-mode rainbow-mode multiple-cursors color-theme-sanityinc-solarized color-theme-sanityinc-tomorrow material-theme markdown-toc org-edit-latex helm-projectile projectile smartparens pdf-tools exec-path-from-shell elpy flycheck-pyflakes py-autopep8 latex-preview-pane helm-ispell helm-flyspell flyspell-correct-popup flyspell-correct-helm ac-ispell helm flyspell-popup flyspell-correct auto-package-update ac-html ac-math ace-mc ace-popup-menu auctex-latexmk auto-complete-auctex auto-complete nyan-mode yasnippet markdown-mode auctex nlinum solarized-theme)))
'(pdf-view-midnight-colors (quote ("#DCDCCC" . "#383838")))
'(pos-tip-background-color "#eee8d5" t)
'(pos-tip-foreground-color "#586e75" t)
'(ps-build-face-reference nil)
'(ps-header-font-family (quote Courier))
'(ps-header-line-pad 5)
'(ps-header-lines 3)
'(ps-header-offset 0)
'(ps-header-title-font-size (quote (10 . 12)))
'(ps-left-header (quote (ps-get-buffer-name)))
'(ps-paper-type (quote a4))
'(ps-print-header-frame nil)
'(ps-top-margin 20)
'(python-shell-exec-path (quote ("/usr/local/bin/")))
'(python-shell-extra-pythonpaths (quote ("/usr/local/bin/")))
'(python-shell-interpreter "python3")
'(rainbow-identifiers-choose-face-function (quote rainbow-identifiers-cie-l*a*b*-choose-face))
'(rainbow-identifiers-cie-l*a*b*-color-count 1024)
'(rainbow-identifiers-cie-l*a*b*-lightness 80)
'(rainbow-identifiers-cie-l*a*b*-saturation 25)
'(ring-bell-function (quote ignore))
'(send-mail-function (quote smtpmail-send-it))
'(smartrep-mode-line-active-bg (solarized-color-blend "#859900" "#eee8d5" 0.2))
'(solarized-use-variable-pitch nil)
'(term-default-bg-color "#fdf6e3")
'(term-default-fg-color "#657b83")
'(tramp-auto-save-directory "/Users/adi/.emacs.d/auto-save-list")
'(uniquify-buffer-name-style (quote post-forward) nil (uniquify))
'(vc-annotate-background nil)
'(vc-annotate-background-mode nil)
'(vc-annotate-color-map
(quote
((20 . "#dc322f")
(40 . "#c85d17")
(60 . "#be730b")
(80 . "#b58900")
(100 . "#a58e00")
(120 . "#9d9100")
(140 . "#959300")
(160 . "#8d9600")
(180 . "#859900")
(200 . "#669b32")
(220 . "#579d4c")
(240 . "#489e65")
(260 . "#399f7e")
(280 . "#2aa198")
(300 . "#2898af")
(320 . "#2793ba")
(340 . "#268fc6")
(360 . "#268bd2"))))
'(vc-annotate-very-old-color nil)
'(visible-bell nil)
'(w3m-home-page "http://www.duckduckgo.com")
'(w3m-search-default-engine "duckduckgo")
'(w3m-search-engine-alist
(quote
(("duckduckgo" "https://duckduckgo.com/lite/?q=%s&kp=1" utf-8))))
'(weechat-color-list
(quote
(unspecified "#fdf6e3" "#eee8d5" "#990A1B" "#dc322f" "#546E00" "#859900" "#7B6000" "#b58900" "#00629D" "#268bd2" "#93115C" "#d33682" "#00736F" "#2aa198" "#657b83" "#839496")))
'(xterm-color-names
["#eee8d5" "#dc322f" "#859900" "#b58900" "#268bd2" "#d33682" "#2aa198" "#073642"])
'(xterm-color-names-bright
["#fdf6e3" "#cb4b16" "#93a1a1" "#839496" "#657b83" "#6c71c4" "#586e75" "#002b36"])
'(yas-global-mode t))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ===CUSTOM SET FACES
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(bold-italic ((t (:weight bold))))
'(custom-button ((t (:box (:line-width 2 :style released-button) :family "Input Mono Narrow"))))
'(custom-face-tag ((t (:weight normal :height 1.2 :family "Input Mono Narrow"))))
'(custom-group-tag ((t (:height 1.2 :family "Input Mono Narrow"))))
'(custom-group-tag-1 ((t (:height 1.2 :family "Input Mono Narrow"))))
'(custom-variable-tag ((t (:height 1.2 :family "Input Mono Narrow"))))
'(font-latex-italic-face ((t (:inherit normal :foreground "#586e75"))))
'(font-latex-sectioning-0-face ((t (:inherit font-latex-sectioning-1-face :height 1))))
'(font-latex-sectioning-1-face ((t (:inherit font-latex-sectioning-2-face :height 1))))
'(font-latex-sectioning-2-face ((t (:height 1))))
'(font-latex-sectioning-3-face ((t (:height 1))))
'(font-latex-sectioning-4-face ((t (:height 1))))
'(font-latex-sectioning-5-face ((t (:inherit variable-pitch :foreground "#b58900" :weight bold :family "Input Mono Narrow"))))
'(font-latex-verbatim-face ((t (:foreground "#657b83" :slant normal))))
'(italic ((t (:slant normal))))
'(markdown-header-face ((t (:foreground "#268bd2" :weight bold))))
'(minibuffer-prompt ((t nil)))
'(modelinepos-column-warning ((t (:foreground "tomato1"))))
'(org-agenda-calendar-sexp ((t (:foreground "#839496" :slant normal))))
'(org-agenda-done ((t (:foreground "#586e75" :slant normal))))
'(org-block-begin-line ((t (:slant normal))))
'(org-code ((t (:inherit shadow))))
'(org-level-1 ((t (:weight bold :height 1.3 :family "Input Mono Narrow"))))
'(org-level-2 ((t (:inherit variable-pitch :weight bold :height 1.2 :family "Input Mono Narrow"))))
'(org-level-3 ((t (:inherit variable-pitch :weight bold :height 1.15 :family "Input Mono Narrow"))))
'(org-level-4 ((t (:inherit variable-pitch :weight bold :height 1.1 :family "Input Mono Narrow"))))
'(org-level-5 ((t (:inherit variable-pitch :weight bold :family "Input Mono Narrow"))))
'(org-level-6 ((t (:inherit variable-pitch :weight bold :family "Input Mono Narrow"))))
'(org-level-7 ((t (:inherit variable-pitch :weight bold :family "Input Mono Narrow"))))
'(org-level-8 ((t (:inherit variable-pitch :weight bold :family "Input Mono Narrow"))))
'(org-quote ((t nil)))
'(org-verse ((t nil))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ===CUSTOM FUNCTIONS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ===SPELLCHECK & AUTOCORRECT
(defun endless/simple-get-word ()
(car-safe (save-excursion (ispell-get-word nil))))
(defun endless/ispell-word-then-abbrev (p)
"Call `ispell-word', then create an abbrev for it.
With prefix P, create local abbrev. Otherwise it will
be global.
If there's nothing wrong with the word at point, keep
looking for a typo until the beginning of buffer. You can
skip typos you don't want to fix with `SPC', and you can
abort completely with `C-g'."
(interactive "P")
(let (bef aft)
(save-excursion
(while (if (setq bef (endless/simple-get-word))
;; Word was corrected or used quit.
(if (ispell-word nil 'quiet)
nil ; End the loop.
;; Also end if we reach `bob'.
(not (bobp)))
;; If there's no word at point, keep looking
;; until `bob'.
(not (bobp)))
(backward-word)
(backward-char))
(setq aft (endless/simple-get-word)))
(if (and aft bef (not (equal aft bef)))
(let ((aft (downcase aft))
(bef (downcase bef)))
(define-abbrev
(if p local-abbrev-table global-abbrev-table)
bef aft)
(message "\"%s\" now expands to \"%s\" %sally"
bef aft (if p "loc" "glob")))
(user-error "No typo at or before point"))))
(setq save-abbrevs 'silently)
;; ===DICTIONARY SWITCH
(defun fd-switch-dictionary()
(interactive)
(let* ((dic ispell-current-dictionary)
(change (if (string= dic "english") "romanian-classic" "english")))
(ispell-change-dictionary change)
(message "Dictionary switched from %s to %s" dic change)
))
;; ===INSERT FILENAME
(defun my-insert-file-name (filename &optional args)
"Insert name of file FILENAME into buffer after point.
Prefixed with \\[universal-argument], expand the file name to
its fully canocalized path. See `expand-file-name'.
Prefixed with \\[negative-argument], use relative path to file
name from current directory, `default-directory'. See
`file-relative-name'.
The default with no prefix is to insert the file name exactly as
it appears in the minibuffer prompt."
;; Based on insert-file in Emacs -- ashawley 20080926
(interactive "*fInsert file name: \nP")
(cond ((eq '- args)
(insert (file-relative-name filename)))
((not (null args))
(insert (expand-file-name filename)))
(t
(insert filename))))
;; ===WHERE AM I?
(defun org-where-am-i ()
"Returns a string of headers indicating where point is in the current tree."
(interactive)
(let (headers)
(save-excursion
(while (condition-case nil
(progn
(push (nth 4 (org-heading-components)) headers)
(outline-up-heading 1))
(error nil))))
(message (mapconcat #'identity headers " > "))))
;; ===RENAME FILE AND BUFFER
(defun rename-file-and-buffer (new-name)
"Renames both current buffer and file it's visiting to NEW-NAME."
(interactive "sNew name: ")
(let ((name (buffer-name))
(filename (buffer-file-name)))
(if (not filename)
(message "Buffer '%s' is not visiting a file!" name)
(if (get-buffer new-name)
(message "A buffer named '%s' already exists!" new-name)
(progn
(rename-file filename new-name 1)
(rename-buffer new-name)
(set-visited-file-name new-name)
(set-buffer-modified-p nil))))))
;; ===HELM ADVANCED CONFIG
(require 'helm)
(require 'helm-config)
;; The default "C-x c" is quite close to "C-x C-c", which quits Emacs.
;; Changed to "C-c h". Note: We must set "C-c h" globally, because we
;; cannot change `helm-command-prefix-key' once `helm-config' is loaded.
(global-set-key (kbd "C-c h") 'helm-command-prefix)
(global-unset-key (kbd "C-x c"))
(global-set-key (kbd "M-x") 'helm-M-x) ; This was not present in the suggested extended config
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action) ; rebind tab to run persistent action
(define-key helm-map (kbd "C-i") 'helm-execute-persistent-action) ; make TAB works in terminal
(define-key helm-map (kbd "C-z") 'helm-select-action) ; list actions using C-z
;; C-o jumps to the other sources (from history/emacs commands)
(when (executable-find "curl")
(setq helm-google-suggest-use-curl-p t))
(setq helm-split-window-in-side-p t ; open helm buffer inside current window, not occupy whole other window
helm-move-to-line-cycle-in-source t ; move to end or beginning of source when reaching top or bottom of source.
helm-ff-search-library-in-sexp t ; search for library in `require' and `declare-function' sexp.
helm-scroll-amount 8 ; scroll 8 lines other window using M-<next>/M-<prior>
)
(helm-mode 1)
;; ===AucTeX SETTINGS
(setq TeX-PDF-mode t)
(setq TeX-fold-mode 1)
(add-hook 'LaTeX-mode-hook
(lambda ()
(push
'("latexmk" "latexmk -pdf %s" TeX-run-TeX nil t
:help "Run latexmk on file")
TeX-command-list)))
(add-hook 'TeX-mode-hook '(lambda () (setq TeX-command-default "latexmk")))
(setq TeX-view-program-selection '((output-pdf "PDF Viewer")))
(setq TeX-view-program-list
'(("PDF Viewer" "/Applications/Skim.app/Contents/SharedSupport/displayline -b -g %n %o %b")))
(getenv "PATH")
(setenv "PATH"
(concat
"/Library/TeX/texbin" ":" "usr/local/bin" ":"
(getenv "PATH")))
(setq debug-on-error t)
(setq LaTeX-includegraphics-read-file 'LaTeX-includegraphics-read-file-relative)
;; ===PREVIEW MARKDOWN IN MARKED
(defun markdown-preview-file ()
"run Marked on the current file and revert the buffer"
(interactive)
(shell-command
(format "open -a /Applications/Marked\\ 2.app %s"
(shell-quote-argument (buffer-file-name)))))