Skip to content

Instantly share code, notes, and snippets.

@marius92mc
Forked from adimanea/emacs.md
Created April 14, 2017 11:05
Show Gist options
  • Save marius92mc/d2d493a36d68e6056a0e229797ed5a52 to your computer and use it in GitHub Desktop.
Save marius92mc/d2d493a36d68e6056a0e229797ed5a52 to your computer and use it in GitHub Desktop.
My emacs tips, tricks & config

My Emacs Setup & Tutorial

Basics

Specific Terminology

  • 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)

(E)Lisp Terminology & Syntax

  • hook = dependency. For example, if a command is preceded by (add-hook 'org-mode-hook (command)), it is evaluated only if org-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);

Basic navigation

  • 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                     

General configuration

  • The init file is ~/.emacs;
  • Packages and their preferences are in ~/.emacs.d/

init file configs:

  1. 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/")
  1. 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
  1. 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)
  1. 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

Customizations from the GUI Menu

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.

Change theme

M-x customize-theme. RET to select it temporarily, RET + C-x C-s to set it permanently.

Major packages I use

How to install packages

  • 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.

Auto Completion

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

Key chords

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…

Nyan mode

Not available in MELPA, must be loaded separately.

AucTeX

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)

Suggestions/Expansions/Matching in commands

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)

Suggestions and Fuzzy Matching in Minibuffer

IDO.

My config:

    (require 'ido)
    (ido-mode t)
    (setq ido-everywhere t)
    (setq ido-enable-flex-matching t) ;; for fuzzy search

Code snippets

Yasnippet. If necessary, download additional snippets (e.g. yasnippet-latex).

My config:

    (require 'yasnippet)
    (yas-global-mode 1)

Undo Tree

With diff and branches as in git.

See Sacha Chua's config.

Recent file list

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

Spellcheck

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 use aspell:
     '(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.

Video demo.

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.

Code

"IDEs":

  • Python: Elpy;
  • Haskell: Intero.

Syntax and style: Flymake.

Git

Magit.

RTFM.

Terminal

3 types:

  • M-x ansi-term;
  • M-x shell;
  • M-x term.

Brief description.

Org

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 of word 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.

View Possible keybindings:

WhichKey.

Press a generic command key (C-c or C-x), wait 1 sec and see all possible commands in the minibuffer.

GoTo

Avy (newer) or AceJump (older).

Functions: goto-char, goto-2chars, goto-line, goto-word…

Multiple cursors

Multiple cursors.

Check this.

File & Directory Navigator

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)

Project management

Projectile.

Outline of file/project

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).

Misc Tips & Tricks

My init

    (setq user-full-name "Adrian Manea")
    (setq user-mail-address "adrianmanea@fastmail.fm")
    (require 'package)
    (add-to-list 'package-archives '("melpa" . "https://melpa.milkbox.net/packages/"))
    (package-initialize)
    (when (memq window-system '(mac ns)) ;; for bash shell as in macOS
      (exec-path-from-shell-initialize))
    
    (when (window-system)
      (tool-bar-mode -1)
      (scroll-bar-mode -1)
      (set-frame-size (selected-frame) 100 60))
    (set-frame-font "Input Mono Narrow-12") ; "DejaVu Sans Mono for Powerline-12")
    (global-visual-line-mode t)
    (global-hl-line-mode t)
    (global-font-lock-mode t)
    (blink-cursor-mode 0)
    ; (blink-cursor-blinks NN) ;; how many blinks until it stops (0 or negative = forever, def = 10)
    (column-number-mode)
    (require 'auto-complete)
    (require 'company)
    (require 'key-chord)
    (key-chord-mode t)
    
    (defun my/org-mode-hook ()
      "Stop the org-level headers from changing font faces."
      (dolist (face '(org-level-1
                      org-level-2
                      org-level-3
                      org-level-4
                      org-level-5
                      org-level-6
                      org-level-7
                      org-level-8))
        (set-face-attribute face nil :weight 'semi-bold :family "Input Mono Narrow"))) ;"DejaVu Sans Mono for Powerline")))
    (add-hook 'org-mode-hook 'my/org-mode-hook)
    
    (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)
     '(ansi-color-faces-vector
       [default bold shadow italic underline bold bold-italic bold])
     '(ansi-color-names-vector
       (vector "#839496" "#dc322f" "#859900" "#b58900" "#268bd2" "#d33682" "#2aa198" "#eee8d5"))
     '(ansi-term-color-vector
       [unspecified "#2e3440" "#88c0d0" "#bf616a" "#5e81ac" "#ebcb8b" "#a3be8c" "#ebcb8b" "#e5e9f0"] t)
     '(backup-directory-alist (quote ((".*" . "/Users/adi/.emacs.d/backups"))))
     '(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 "#657b83")
     '(cua-overwrite-cursor-color "#b58900")
     '(cua-read-only-cursor-color "#859900")
     '(custom-enabled-themes (quote (solarized-light)))
     '(custom-safe-themes
       (quote
        ("704a108ab29ea8fc8feb718a538e9ce45d732dce41e5b04585f43a6352c5519e" "84d2f9eeb3f82d619ca4bfffe5f157282f4779732f48a5ac1484d94d5ff5b279" "5dc0ae2d193460de979a463b907b4b2c6d2c9c4657b2e9e66b8898d2592e3de5" "2a998a3b66a0a6068bcb8b53cd3b519d230dd1527b07232e54c8b9d84061d48d" "c74e83f8aa4c78a121b52146eadb792c9facc5b1f02c917e3dbb454fca931223" "10e231624707d46f7b2059cc9280c332f7c7a530ebc17dba7e506df34c5332c4" "a25c42c5e2a6a7a3b0331cad124c83406a71bc7e099b60c31dc28a1ff84e8c04" "8453c6ba2504874309bdfcda0a69236814cefb860a528eb978b5489422cb1791" "19ba41b6dc0b5dd34e1b8628ad7ae47deb19f968fe8c31853d64ea8c4df252b8" "ab0950f92dc5e6b667276888cb0cdbc35fd1c16f667170a62c15bd3ed5ae5c5a" "b747fb36e99bc7f497248eafd6e32b45613ee086da74d1d92a8da59d37b9a829" "db2ecce0600e3a5453532a89fc19b139664b4a3e7cbefce3aaf42b6d9b1d6214" "9b59e147dbbde5e638ea1cde5ec0a358d5f269d27bd2b893a0947c4a867e14c1" "c9321e2db48a21fc656a907e97ee85d8cd86967855bf0bed3998bcf9195c758b" "938d8c186c4cb9ec4a8d8bc159285e0d0f07bad46edf20aa469a89d0d2a586ea" "1db337246ebc9c083be0d728f8d20913a0f46edc0a00277746ba411c149d7fe5" "ed317c0a3387be628a48c4bbdb316b4fa645a414838149069210b66dd521733f" "fec45178b55ad0258c5f68f61c9c8fd1a47d73b08fb7a51c15558d42c376083d" "df21cdadd3f0648e3106338649d9fea510121807c907e2fd15565dde6409d6e9" "3e34e9bf818cf6301fcabae2005bba8e61b1caba97d95509c8da78cff5f2ec8e" "85d609b07346d3220e7da1e0b87f66d11b2eeddad945cac775e80d2c1adb0066" "73ad471d5ae9355a7fa28675014ae45a0589c14492f52c32a4e9b393fcc333fd" "93268bf5365f22c685550a3cbb8c687a1211e827edc76ce7be3c4bd764054bad" "aea30125ef2e48831f46695418677b9d676c3babf43959c8e978c0ad672a7329" "12670281275ea7c1b42d0a548a584e23b9c4e1d2dabb747fd5e2d692bcd0d39b" "50d07ab55e2b5322b2a8b13bc15ddf76d7f5985268833762c500a90e2a09e7aa" "5b8eccff13d79fc9b26c544ee20e1b0c499587d6c4bfc38cabe34beaf2c2fc77" "d9dab332207600e49400d798ed05f38372ec32132b3f7d2ba697e59088021555" "85e6bb2425cbfeed2f2b367246ad11a62fb0f6d525c157038a0d0eaaabc1bfee" "5a7830712d709a4fc128a7998b7fa963f37e960fd2e8aa75c76f692b36e6cf3c" "aded4ec996e438a5e002439d58f09610b330bbc18f580c83ebaba026bbef6c82" "82d2cac368ccdec2fcc7573f24c3f79654b78bf133096f9b40c20d97ec1d8016" "3380a2766cf0590d50d6366c5a91e976bdc3c413df963a0ab9952314b4577299" "50b64810ed1c36dfb72d74a61ae08e5869edc554102f20e078b21f84209c08d1" "cbd8e65d2452dfaed789f79c92d230aa8bdf413601b261dbb1291fb88605110c" "d96587ec2c7bf278269b8ec2b800c7d9af9e22d816827639b332b0e613314dfd" "6271fc9740379f8e2722f1510d481c1df1fcc43e48fa6641a5c19e954c21cc8f" "fee4e306d9070a55dce4d8e9d92d28bd9efe92625d2ba9d4d654fc9cd8113b7f" "b8929cff63ffc759e436b0f0575d15a8ad7658932f4b2c99415f3dde09b32e97" "16dd114a84d0aeccc5ad6fd64752a11ea2e841e3853234f19dc02a7b91f5d661" "907bacbe973888e44b057b32439bd51795d38034dceb71876958ffccc808a010" "0c3b1358ea01895e56d1c0193f72559449462e5952bded28c81a8e09b53f103f" "f869a5d068a371532c82027cdf1feefdc5768757c78c48a7e0177e90651503ad" "eae831de756bb480240479794e85f1da0789c6f2f7746e5cc999370bbc8d9c8a" "6145e62774a589c074a31a05dfa5efdf8789cf869104e905956f0cbd7eda9d0e" "ad9747dc51ca23d1c1382fa9bd5d76e958a5bfe179784989a6a666fe801aadf2" "43c1a8090ed19ab3c0b1490ce412f78f157d69a29828aa977dae941b994b4147" "06f0b439b62164c6f8f84fdda32b62fb50b6d00e8b01c2208e55543a6337433a" "527df6ab42b54d2e5f4eec8b091bd79b2fa9a1da38f5addd297d1c91aa19b616" "ef04dd1e33f7cbd5aa3187981b18652b8d5ac9e680997b45dc5d00443e6a46e3" "78c1c89192e172436dbf892bd90562bc89e2cc3811b5f9506226e735a953a9c6" "9be1d34d961a40d94ef94d0d08a364c3d27201f3c98c9d38e36f10588469ea57" "08b8807d23c290c840bbb14614a83878529359eaba1805618b3be7d61b0b0a32" "d8f76414f8f2dcb045a37eb155bfaa2e1d17b6573ed43fb1d18b936febc7bbc2" "5cd0afd0ca01648e1fff95a7a7f8abec925bd654915153fb39ee8e72a8b56a1f" "d431bff071bfc4c300767f2a0b29b23c7994573f7c6b5ef4c77ed680e6f44dd0" "f5512c02e0a6887e987a816918b7a684d558716262ac7ee2dd0437ab913eaec6" "bb08c73af94ee74453c90422485b29e5643b73b05e8de029a6909af6a3fb3f58" "83faf27892c7119f6016e3609f346d3dae3516dede8fd8a5940373d98f615b4e" "4cf3221feff536e2b3385209e9b9dc4c2e0818a69a1cdb4b522756bcdf4e00a4" "4aee8551b53a43a883cb0b7f3255d6859d766b6c5e14bcb01bed572fcbef4328" "628278136f88aa1a151bb2d6c8a86bf2b7631fbea5f0f76cba2a0079cd910f7d" "98cc377af705c0f2133bb6d340bf0becd08944a588804ee655809da5d8140de6" "d677ef584c6dfc0697901a44b885cc18e206f05114c8a3b7fde674fce6180879" "a8245b7cc985a0610d71f9852e9f2767ad1b852c2bdea6f4aadc12cce9c4d6d0" "8aebf25556399b58091e533e455dd50a6a9cba958cc4ebb0aab175863c25b9a4" default)))
     '(enable-completion nil)
     '(fci-rule-color "#073642")
     '(fill-column 80)
     '(font-latex-fontify-script nil)
     '(font-latex-fontify-sectioning 1)
     '(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-mode 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-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 "romanian-classic")
     '(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-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-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
        (magithub gist flycheck-haskell haskell-mode haskell-snippets intero flymake-haskell-multi org-babel-eval-in-repl avy avy-flycheck avy-menu avy-zap flycheck-rtags company-rtags company-irony company-irony-c-headers flycheck-irony irony flycheck-clangcheck flycheck-clang-tidy rtags cmake-ide common-lisp-snippets lisp-extra-font-lock flylisp key-chord sr-speedbar sage-shell-mode neotree jazz-theme typo leuven-theme which-key spaceline smart-mode-line-powerline-theme smart-mode-line powerline modeline-posn wide-column gnuplot-mode gnuplot gruvbox-theme image+ wiki-summary dic-lookup-w3m helm-w3m w3m obsidian-theme white-sand-theme warm-night-theme underwater-theme arjen-grey-theme silkworm-theme darktooth-theme ample-zen-theme ample-theme base16-theme atom-one-dark-theme spacegray-theme anti-zenburn-theme zenburn-theme rebecca-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 slime relative-line-numbers wc-mode spu pandoc-mode rainbow-mode multiple-cursors labburn-theme color-theme-sanityinc-solarized color-theme-sanityinc-tomorrow material-theme markdown-toc trie org-edit-latex helm-projectile projectile magic-latex-buffer smartparens jedi 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 popup-complete flyspell-popup flyspell-correct popup 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))
     '(smartrep-mode-line-active-bg (solarized-color-blend "#859900" "#eee8d5" 0.2))
     '(sml/mode-width
       (if
           (eq
            (powerline-current-separator)
            (quote arrow))
           (quote right)
         (quote full)))
     '(sml/pos-id-separator
       (quote
        (""
         (:propertize " " face powerline-active1)
         (:eval
          (propertize " "
                      (quote display)
                      (funcall
                       (intern
                        (format "powerline-%s-%s"
                                (powerline-current-separator)
                                (car powerline-default-separator-dir)))
                       (quote powerline-active1)
                       (quote powerline-active2))))
         (:propertize " " face powerline-active2))))
     '(sml/pos-minor-modes-separator
       (quote
        (""
         (:propertize " " face powerline-active1)
         (:eval
          (propertize " "
                      (quote display)
                      (funcall
                       (intern
                        (format "powerline-%s-%s"
                                (powerline-current-separator)
                                (cdr powerline-default-separator-dir)))
                       (quote powerline-active1)
                       (quote sml/global))))
         (:propertize " " face sml/global))))
     '(sml/pre-id-separator
       (quote
        (""
         (:propertize " " face sml/global)
         (:eval
          (propertize " "
                      (quote display)
                      (funcall
                       (intern
                        (format "powerline-%s-%s"
                                (powerline-current-separator)
                                (car powerline-default-separator-dir)))
                       (quote sml/global)
                       (quote powerline-active1))))
         (:propertize " " face powerline-active1))))
     '(sml/pre-minor-modes-separator
       (quote
        (""
         (:propertize " " face powerline-active2)
         (:eval
          (propertize " "
                      (quote display)
                      (funcall
                       (intern
                        (format "powerline-%s-%s"
                                (powerline-current-separator)
                                (cdr powerline-default-separator-dir)))
                       (quote powerline-active2)
                       (quote powerline-active1))))
         (:propertize " " face powerline-active1))))
     '(sml/pre-modes-separator (propertize " " (quote face) (quote sml/modes)))
     '(sml/theme (quote respectful))
     '(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 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))))
     '(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 nil)))
     '(markdown-header-face ((t (:foreground "#268bd2" :weight bold))))
     '(minibuffer-prompt ((t nil)))
     '(modelinepos-column-warning ((t (:foreground "tomato1")))))
    
    
    (delete-selection-mode 1)
    
    ;; make the fringe stand out from the backrground
    (setq solarized-distinct-fringe-background t)
    
    
    ;; don't use italic
    (setq solarized-italic nil)
    
    ;; Tell emacs where is your personal elisp lib dir
    (add-to-list 'load-path "~/.emacs.d/elpa/nyan-mode-master/")
    
    ;; load the packaged named xyz.
    (load "nyan-mode") ;; best not to include the ending “.el” or “.elc”
    ;; (require 'nyan-mode)
    ;;(nyan-mode)  ;; Load Nyan Mode at startup
    (load "/Users/adi/.emacs.d/elpa/pdftools")
    
    
    
    
    ;; 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)
    (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)
    
    ;; yasnippet code 'optional', before auto-complete
    (require 'yasnippet)
    (yas-global-mode 1)
    
    
    (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)))
    
    (setq ac-use-menu-map t)
    (require 'ido)
    (ido-mode t)
    (setq ido-everywhere t)
    (setq ido-enable-flex-matching t) ;; fuzzy search in IDO
    
    ;; Associate minor modes with file extensions.
    (add-hook 'find-file-hook
          (lambda ()
            (when (string= (file-name-extension buffer-file-name) "py")
              (elpy-mode 1)
              (abbrev-mode 1))))
    
    
    
    (setq-default line-spacing 3)
    
    (global-set-key (kbd "s-c") 'move-beginning-of-line) ;
    (global-set-key (kbd "C-w") 'kill-region) ;; cut selection
    (set-face-italic 'font-lock-comment-face nil)
    
    
    (show-paren-mode 1)
    (require 'paren)
    (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 cursor position
    (save-place-mode)
    
    ;; function for selecting the current line
    (defun select-current-line ()
      "Selects the current line"
      (interactive) ;; can be accessed via M-x or shortcut
      (end-of-line)
      (push-mark (line-beginning-position) nil t))
    (global-set-key (kbd "C-.") 'select-current-line)
    
    (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))))
    )
    (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
    ;; Use spotlight index for M-x locate
    (setq locate-command "mdfind")
    (global-set-key (kbd "C-c l o c") 'locate)
    (require 'multiple-cursors)
    (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)
    (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)))
    
    ;;(global-set-key (kbd "C-c j") 'ace-jump-char-mode)
    (setenv "ESHELL" (expand-file-name "~/bin/eshell"))
    
    (add-hook 'markdown-mode-hook 'pandoc-mode)
    (add-hook 'LaTeX-mode-hook 'pandoc-mode)
    (add-hook 'org-mode-hook 'pandoc-mode)
    (add-hook 'LaTeX-mode-hook 'reftex-mode)
    
    (load "/Users/adi/.emacs.d/show-point-mode")
    (require 'show-point-mode)
     (show-point-mode t)
    ;; Slime mode specific function added for AC mode.
    (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))
    
    
    ;; Sacha Chua's config
    ;; People often struggle with the Emacs undo model, where there's really no concept of "redo" - you simply undo the undo.
    ;;This lets you use C-x u (undo-tree-visualize) to visually walk through the changes you've made, undo back to a certain point (or redo), and go down different branches.
    (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)))
    
    ;; for utf-8 encoding
    (prefer-coding-system 'utf-8)
    (when (display-graphic-p)
      (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)))
    
    
    ;; for recent files
    (require 'recentf)
    (setq recentf-max-saved-items 200
          recentf-max-menu-items 15)
    (recentf-mode)
    
    
    ;; Show where buffer ends
    (setq-default indicate-empty-lines t)
    
    
    
    
    ;;(require 'all-the-icons)
    (use-package all-the-icons)
    (require 'all-the-icons-dired)
    ;;(load "/Users/adi/.emacs.d/elpa/all-the-icons-20170330.2336/fonts")
    
    ;; file and folder icons for dired
    (add-hook 'dired-by-name-mode-hook 'all-the-icons-dired-mode)
    
    
    ;; MultiMarkdown minor mode
    (load "/Users/adi/.emacs.d/elpa/mmd-mode-master/mmd-mode")
    (use-package mmd-mode)
    
    
    ;; Wrap region in symbols
    (wrap-region-mode t)
    ;; The above are the default wrappers. You can add more yourself:
    ;; (wrap-region-add-wrapper "$" "$")
    ;; (wrap-region-add-wrapper "{-" "-}" "#")
    ;; (wrap-region-add-wrapper "/" "/" nil 'ruby-mode)
    ;; (wrap-region-add-wrapper "/* " " */" "#" '(java-mode javascript-mode css-mode))
    ;; (wrap-region-add-wrapper "`" "`" nil '(markdown-mode ruby-mode))
    
    ;; The same can be done with:
    ;; (wrap-region-add-wrappers
    ;;  '(("$" "$")
    ;;    ("{-" "-}" "#")
    ;;    ("/" "/" nil ruby-mode)
    ;;    ("/* " " */" "#" (java-mode javascript-mode css-mode))
    ;;    ("`" "`" nil (markdown-mode ruby-mode))))
    
    
    
    (setq company-dabbrev-downcase nil) ;; make company-complete care about case
    (setq company-dabbrev-ignore-case nil) ; default is keep-prefix
    
    
    
    
    ;; for renaming current buffer
    ;; source: http://steve.yegge.googlepages.com/my-dot-emacs-file
    (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))))))
    
    
    ;;; IMAGE PREVIEW
    
    ;; * To manupulate a image under cursor.
    ;;
    ;;  M-x imagex-global-sticky-mode
    ;;
    ;; * C-c + / C-c -: Zoom in/out image.
    ;; * C-c M-m: Adjust image to current frame size.
    ;; * C-c C-x C-s: Save current image.
    ;;
    ;; * Adjusted image when open image file.
    ;;
    ;;  M-x imagex-auto-adjust-mode
    
    (add-hook 'dired-mode-hook 'all-the-icons-dired-mode)
    (add-hook 'image-mode-hook 'imagex-global-sticky-mode)
    (global-set-key (kbd "C-c r n") 'rename-file-and-buffer) ;; keybinding for rename
    
    ;; Show the current function name in the header line
    ;;(which-function-mode)
    ;;(setq-default header-line-format
      ;;            '((which-func-mode ("" which-func-format " "))))
    ;;(setq mode-line-misc-info
                ;; We remove Which Function Mode from the mode line, because it's mostly
                ;; invisible here anyway.
    ;;            (assq-delete-all 'which-func-mode mode-line-misc-info))
    ;; (defun org-which-function ()
    ;;   (interactive)
    ;;   (when (eq major-mode 'org-mode)
    ;;     (mapconcat 'identity (org-get-outline-path t)
    ;;                " > ")
    ;;   ))
    
    ;; (add-to-list 'which-func-functions #'org-which-function)
    ;; (setq header-line-format
    ;;   '(:eval
    ;;    (list
    ;;     (header-buffer-name)
    ;;     " "
    ;;     (header-function-name))))
    (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 " > "))))
    
    (add-hook 'org-mode-hook
              (lambda ()
                (define-key org-mode-map (kbd "C-c w") 'org-where-am-i)
                (define-key org-mode-map (kbd "M-TAB") nil)))
    
    
    (use-package which-key
      :ensure t
      :config
      (which-key-mode))
    (setq neo-theme (if (display-graphic-p) 'icons 'arrow))
    (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))))
    
    (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)
    
    (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))
    (add-hook 'org-mode-hook 'auto-fill-mode)
    ;;(add-hook 'org-mode-hook 'auto-complete-mode)
    (defun org-tree-open-in-right-frame ()
      (interactive)
      (org-tree-to-indirect-buffer)
      (windmove-right))
    
    (defun my/open-tree-view ()
      "Open a clone of the current buffer to the left, resize it to 30 columns, and bind <mouse-1> to jump to the same position in the base buffer."
      (interactive)
      (let ((new-buffer-name (concat "<tree>" (buffer-name))))
        ;; Create tree buffer
        (split-window-right 30)
        (if (get-buffer new-buffer-name)
            (switch-to-buffer new-buffer-name)  ; Use existing tree buffer
          ;; Make new tree buffer
          (progn  (clone-indirect-buffer new-buffer-name nil t)
                  (switch-to-buffer new-buffer-name)
                  (read-only-mode)
                  (hide-body)
                  (toggle-truncate-lines)
    
                  ;; Do this twice in case the point is in a hidden line
                  (dotimes (_ 2 (forward-line 0)))
    
                  ;; Map keys
                  (use-local-map (copy-keymap outline-mode-map))
                  (local-set-key (kbd "q") 'delete-window)
                  (mapc (lambda (key) (local-set-key (kbd key) 'my/jump-to-point-and-show))
                        '("<mouse-1>" "RET"))))))
    
    (defun my/jump-to-point-and-show ()
      "Switch to a cloned buffer's base buffer and move point to the cursor position in the clone."
      (interactive)
      (let ((buf (buffer-base-buffer)))
        (unless buf
          (error "You need to be in a cloned buffer!"))
        (let ((pos (point))
              (win (car (get-buffer-window-list buf))))
          (if win
              (select-window win)
            (other-window 1)
            (switch-to-buffer buf))
          (goto-char pos)
          (when (invisible-p (point))
            (show-branches)))))
    
    
    ;;(define-key ac-mode-map (kbd "M-TAB") 'auto-complete)
    
    (setq-default key-chord-two-keys-delay 0.05)
    (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)
            ))
    
    
    
    
    ;;(key-chord-define-global "e/" 'fd-switch-dictionary)
    ;;(key-chord-define-global "v/" 'eval-buffer)
    ;;(key-chord-define-global "f/" 'flyspell-mode)
    ;;(key-chord-define-global "d/" 'ispell-change-dictionary)
    ;;(key-chord-define-global "r/" 'recentf-open-files)
    (global-unset-key (kbd "C-\\"))
    (add-hook 'org-mode-hook
              (lambda ()
                (define-key org-mode-map (kbd "C-\\") 'org-toggle-pretty-entities)))
    
    
    
    (eval-after-load 'company
      '(progn
         (define-key company-active-map (kbd "TAB") nil)
         (define-key company-active-map (kbd "<tab>") nil)
         (define-key company-active-map [tab] nil)
         (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)))
    
    (global-set-key (kbd "C-ă") 'company-complete)
    
    
    (add-hook 'flyspell-mode-hook
              (lambda ()
                ;;(key-chord-define flyspell-mode-map "c/" 'flyspell-correct-word-before-point)
                (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)))
    
    
    (add-hook 'haskell-mode-hook 'intero-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*")
    (global-set-key (kbd "C-c g") 'avy-goto-char)
    ;; (require 'rtags)
    ;; (require 'company-rtags)
    
    ;; (setq rtags-completions-enabled t)
    ;; (eval-after-load 'company
    ;;   '(add-to-list
    ;;     'company-backends 'company-rtags))
    ;; (setq rtags-autostart-diagnostics t)
    ;; (rtags-enable-standard-keybindings)
    ;; (require 'helm-rtags)
    ;; (setq rtags-use-helm t)
    ;; (require 'flycheck-rtags)
    
    ;; (defun my-flycheck-rtags-setup ()
    ;;   (flycheck-select-checker 'rtags)
    ;;   (setq-local flycheck-highlighting-mode nil) ;; RTags creates more accurate overlays.
    ;;   (setq-local flycheck-check-syntax-automatically nil))
    ;; ;; c-mode-common-hook is also called by c++-mode
    ;; (add-hook 'c-mode-common-hook #'my-flycheck-rtags-setup)
    (add-hook 'markdown-mode-hook 'turn-on-orgtbl)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment