No Description 80KB

    NOTE: after changing this file:
  1. Either call isg--generate-isg-init-file or delete ~/.emacs.d/isg-init.el
  2. restart emacs

(defun isg--compile-isg-init ()
  (org-babel-tangle-file (expand-file-name "~/.emacs.d/")
                         (expand-file-name "~/.emacs.d/isg-init.el")
;; (isg--compile-isg-init)

|--------------+-------------+--------------------------------------------------| | Section | Key | Command | |--------------+-------------+--------------------------------------------------| | Capture | C-c c | Capture a thought/event/task | | | C-c C-w | Refile an entry from the inbox | | | | | | Refiling | C-c C-c | add a tag to a heading (use in file) | | | C-c C-t | cycle between TODO/DONE/nothing heading states | | | C-c C-s | Add a schedule time/date to the heading | | | C-c C-d | Add a deadline | | | C-c C-x C-a | Archive | | | | | | Org Mode | C-c C-c | Eval code within BEGIN_SRC/END_SRC blocks | | | C-c ' | Open up a mini-buffer for editing the code block | | | | | | Misc. | M-/ | dabbrev-expand | | | M-x imenu | list all functions and top-level variables | | | | | | Undo | C-/ | undo-tree-undo | | | C-M-/ | hydra-undo-tree/body | | | | | | Search | C-s | Counsel grep (C-y = search current word) | | | C-r | counsel-rg | | | C-M-s | isearch forward | | | C-M-r | isearch backward | | | C-M-g | counsel-git | | | | | | | C-c C-o | print search results into new buffer | | | C-x C-q | ivy-wgrep-change-to-wgrep-mode | | | C-c C-c | commit changes made in wgrep mode | | | | | | | C-c f | hydra show counsel options | | | | | | Highlighting | C-x w . | highlight-symbol-at-point | | | C-x w r | remove highlights | | | C-x w h | highlight-regexp | | | C-x w p | highlight-phrase and choose colour | | | | | | Navigation | C-spc C-spc | set mark, push onto mark ring | | | C-u C-spc | restore mark from mark ring | | | M-z | avy-goto-char-timer | | | | | |--------------+-------------+--------------------------------------------------|

|-----------+---------+---------------------------------------| | Registers | C-x r | Prefix all commands with C-x r | |-----------+---------+---------------------------------------| | | Key | Command | |-----------+---------+---------------------------------------| | | b | jump to a bookmark | | | l | list bookmarks | | | m | set a bookmark | | | | | | | space X | Save current position to register X | | | j X | Restore position in register X | | | | | | | C-\ | Save current position to register X | | | M-\ | Restore position in register X | | | | | | | r u | Save current buffer state to register | | | r U | Restore buffer state from register | | | | | | | s a | Store region as 'a' | | | i a | Insert region stored in 'a' | |-----------+---------+---------------------------------------|

Tramp mode and Eshell $ cd /

End of line conversions M-x set-buffer-file-coding-system utf-8-unix (for LF) M-x set-buffer-file-coding-system utf-8-mac (for CR) M-x set-buffer-file-coding-system utf-8-dos (for CR+LF)

Using an Emacs counter in a keyboard macro definition C-( press f3 to insert a 0 C-) the 0 in subsequent invocations will be replaced with the next integer

kmacro-set-counter to change value

top level file declarations

;; -*- lexical-binding: t; -*-

helper functions

  (isg--timer "helper-functions"
             ;;; display 'fn' as the lambda symbol
             (defun pretty-fn nil
                nil `(("(\\(fn\\>\\)"
                       (0 (progn (compose-region (match-beginning 1) (match-end 1)
                                                 ,(make-char 'greek-iso8859-7 107))
                       (0 (progn (compose-region (match-beginning 1) (match-end 1)

             (defun isg--val (property)
               (get 'isg--local property))

             (defun isg--swap-buffer-with-other-frame ()
               "swaps the current buffer with the one in the other frame"
               (let ((name (buffer-name)))
                 (other-frame 1)
                 (let ((name2 (buffer-name)))
                   (switch-to-buffer name)
                   (other-frame 1)
                   (switch-to-buffer name2))))

             (defun isg--throw-buffer-to-other-frame ()
               "moves the current buffer to the other frame"
               (let ((name (buffer-name)))
                 (other-frame 1)
                 (switch-to-buffer name)
                 (other-frame 1)

             (defun isg--start-shell (shell-name)
               "start a new shell"
               (interactive "sShell name: ")
               (if (string= "" shell-name)
                 (rename-buffer shell-name)))

             (defun isg--unicode-symbol (name)
               "Translate a symbolic name for a Unicode character -- e.g., LEFT-ARROW
           or GREATER-THAN into an actual Unicode character code. "
               (decode-char 'ucs (case name
                                   (left-arrow 8592)
                                   (up-arrow 8593)
                                   (right-arrow 8594)
                                   (down-arrow 8595)
                                   (double-vertical-bar #X2551)
                                   (equal #X003d)
                                   (not-equal #X2260)
                                   (identical #X2261)
                                   (not-identical #X2262)
                                   (less-than #X003c)
                                   (greater-than #X003e)
                                   (less-than-or-equal-to #X2264)
                                   (greater-than-or-equal-to #X2265)
                                   (logical-and #X2227)
                                   (logical-or #X2228)
                                   (logical-neg #X00AC)
                                   (nary-logical-and #X22C0)
                                   (capital-lambda #X039B)
                                   ('nil #X2205)
                                   (horizontal-ellipsis #X2026)
                                   (double-exclamation #X203C)
                                   (prime #X2032)
                                   (double-prime #X2033)
                                   (for-all #X2200)
                                   (there-exists #X2203)
                                   (element-of #X2208)
                                   (square-root #X221A)
                                   (squared #X00B2)
                                   (cubed #X00B3)
                                   (lambda #X03BB)
                                   (alpha #X03B1)
                                   (beta #X03B2)
                                   (gamma #X03B3)
                                   (delta #X03B4))))

             (defun isg--substitute-pattern-with-unicode (pattern symbol)
               "Add a font lock hook to replace the matched part of PATTERN with the
           Unicode symbol SYMBOL looked up with UNICODE-SYMBOL."
                nil `((,pattern
                       (0 (progn (compose-region (match-beginning 1) (match-end 1)
                                                 ,(isg--unicode-symbol symbol)

             (defun isg--substitute-patterns-with-unicode (patterns)
               "Call SUBSTITUTE-PATTERN-WITH-UNICODE repeatedly."
               (mapcar #'(lambda (x)
                           (isg--substitute-pattern-with-unicode (car x)
                                                                (cdr x)))

             (defun isg--correct-symbol-bounds (pretty-alist)
               "Prepend a TAB character to each symbol in this alist,
    this way compose-region called by prettify-symbols-mode
    will use the correct width of the symbols
    instead of the width measured by char-width."
               (mapcar (lambda (el)
                         (setcdr el (string ?\t (cdr el)))

machine settings

split this into multiple source blocks to avoid a lot of git conflicts

  (isg--timer "machine-settings"
             (defun isg--default-machine-settings ()
               "Settings which apply to most of the machines."
               '((foreground-color "grey60")
                 (background-color "black")
                 (default-font "6x12")
                 (machine-os "linux") ; one of "linux" "osx" "windows"
                 (url-opener "chromium-browser")
                 (default-directory "~/code/")
                 (save-folder "/tmp/emacs.d-saves")
                 (deft-directory "~/personal/deft")
                 (gcal-file "~/notes/")
                 (racer-cmd "/home/indy/code/rust/racer/target/release/racer")
                 (racer-rust-src-path "/Users/indy/.multirust/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src")
                 (get-extra-paths (lambda ()
                                    (list (concat (getenv "HOME") "/local/bin")
                 (magit-repos (("~/.emacs.d" . 0)
                               ("~/personal" . 0)
                               ("~/code" . 1))))))

  (isg--timer "windows-home-pc"
             (defvar isg--config-windows-home-pc
               '((default-font "-outline-Hack-normal-normal-normal-mono-13-*-*-*-c-*-iso10646-1")
                 (post-setup-fn (lambda ()
                                  (setenv "GOPATH" "D:\\code\\go")))
                 (machine-os "windows") ; one of "linux" "osx" "windows"
                 (racer-cmd "C:\\Users\\indy\\.cargo\\bin\\racer.exe")
                 (racer-rust-src-path "c:\\Users\\indy\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\src\\rust\\src\\")
                 (save-folder "d:/scratch/emacs-saves")
                 (url-opener "C:\\Program Files\\Mozilla Firefox\\firefox")
                 (deft-directory "C:\\Users\\indy\\personal\\deft")
                 (gcal-file "D:\\Google Drive\\Docs\\notes\\")
                 (magit-repos (("C:\\Users\\indy\\.emacs.d" . 0)
                               ("C:\\Users\\indy\\personal" . 0)
                               ("C:\\Users\\indy\\code" . 1)))

                 (frame-l ((top . 0) (left . 598) (width . 120) (height . 93)))
                 (frame-r ((top . 0) (left . 1575) (width . 120) (height . 93))))))

  (isg--timer "ubuntu-dell"
             (defvar isg--config-ubuntu-dell
               '((default-font "-SRC-Hack-normal-normal-normal-*-11-*-*-*-m-0-iso10646-1")
                 (post-setup-fn (lambda ()
                 (get-extra-paths (lambda ()
                                    (list (concat (getenv "HOME") "/local/bin")
                 (racer-cmd "/home/indy/.cargo/bin/racer")
                 (racer-rust-src-path "/home/indy/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src"))))

  (isg--timer "chromebook"
             (defvar isg--config-chromebook
               '((default-font "-unknown-Hack-normal-normal-normal-*-11-*-*-*-m-0-iso10646-1")
                 (post-setup-fn (lambda ()
                                  (setenv "GOPATH" (concat (getenv "HOME") "/code/go"))))
                 (get-extra-paths (lambda ()
                                    (list (concat (getenv "GOPATH") "/bin")
                                          (concat (getenv "HOME") "/local/bin")
                 (racer-cmd "/home/indy/.cargo/bin/racer")
                 (racer-rust-src-path "/home/indy/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src")
                 (frame-l ((top . 0) (left . 210) (width . 80) (height . 59)))
                 (frame-r ((top . 0) (left . 780) (width . 80) (height . 59))))))

  (isg--timer "old-ubuntu-laptop"
             (defvar isg--config-old-ubuntu-laptop
               '((default-font "-SRC-Hack-normal-normal-normal-*-12-*-*-*-m-0-iso10646-1")
                 (racer-cmd "/home/indy/code/rust/racer/target/release/racer")
                 (racer-rust-src-path "/home/indy/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src")
                 (get-extra-paths (lambda ()
                                    (list (concat (getenv "HOME") "/local/bin")
                 (frame-l ((top . 0) (left . 210) (width . 80) (height . 59)))
                 (frame-r ((top . 0) (left . 780) (width . 80) (height . 59))))))

  (isg--timer "macbook-air"
             (defvar isg--config-macbook-air
               '((default-font "-apple-Inconsolata-medium-normal-normal-*-12-*-*-*-m-0-iso10646-1")
                 (machine-os "osx")
                 ;;(racer-cmd "/Users/indy/code/rust/racer/target/release/racer")
                 (racer-cmd "/Users/indy/.cargo/bin/racer")
                 (racer-rust-src-path "/Users/indy/code/rust/rust/src/")
                 (url-opener "open")

                 (frame-r ((top . 0) (left . 746) (width . 100) (height . 55)))
                 (frame-l ((top . 0) (left . 126) (width . 100) (height . 55)))

                 ;;(frame-r ((top . 0) (left . 864) (width . 80) (height . 55)))
                 ;;(frame-l ((top . 0) (left . 362) (width . 80) (height . 55)))

                 (post-setup-fn (lambda ()
                                  (setq inferior-lisp-program "lein repl"))))))

  (isg--timer "ubuntu-vm"
             (defvar isg--config-ubuntu-vm
               '((default-font "-unknown-Inconsolata-normal-normal-normal-*-12-*-*-*-m-0-iso10646-1")
                 (get-extra-paths (lambda ()
                                    (list (concat (getenv "HOME") "/local/bin")
                 (url-opener "firefox")
                 (frame-l ((top . 0) (left . 600) (width . 120) (height . 90)))
                 (frame-r ((top . 0) (left . 1500) (width . 120) (height . 90))))))

  (defun isg--machine-settings ()
    "System specific overrides go here."
    (let ((sysname (system-name)))
       ((string-match "^BERTRAND"  sysname) isg--config-windows-home-pc)
       ((string-match "^zeno"      sysname) isg--config-ubuntu-dell)
       ((string-match "^localhost" sysname) isg--config-chromebook)
       ((string-match "^socrates"  sysname) isg--config-old-ubuntu-laptop)
       ((string-match "^ernesto"   sysname) isg--config-macbook-air)
       ((string-match "^vb1604"    sysname) isg--config-ubuntu-vm))))

  (cl-labels ((load-settings (which)
                             (mapcar (lambda (pair)
                                       (put 'isg--local (car pair) (cadr pair)))
    (load-settings (isg--default-machine-settings))
    (load-settings (isg--machine-settings)))

obsolete machine settings

((string-match "^debian" system-name) ; debian vm on ernesto '((post-setup-fn (lambda () (setq x-super-keysym 'meta)))))

((string-match "^che" system-name) ; asus ul20a '((post-setup-fn (lambda () (setenv "GOPATH" (concat (getenv "HOME") "/scratch/go")))) (get-extra-paths (lambda () (list (concat (getenv "GOPATH") "/bin") (concat (getenv "HOME") "/local/bin") "/usr/local/bin" "/usr/local/go/bin"))) ;; "/home/indy/code/rust/racer/target/release"

(key-setup (([mouse-1] . nil) ([double-mouse-1] . nil) ([drag-mouse-1] . nil) ([down-mouse-1] . nil)))))

((string-match "^raul" system-name) ; eee 1000 '((hyperspec-root "file:////home/user/docs/cl/HyperSpec/") ;; (default-font "-unknown-DejaVu Sans Mono-normal-normal-normal-*-20-*-*-*-m-0-fontset-startup") (post-setup-fn (lambda () (setenv "PATH" (concat (concat (getenv "HOME") "/local/bin:") "/usr/local/bin:" (getenv "PATH"))) ;;(isg--start-shell "default-shell") (switch-to-buffer "*scratch*")))

(frame-r ((top . 1) (left . 5) (width . 80) (height . 46))) (frame-l ((top . 0) (left . 509) (width . 80) (height . 46)))

(key-setup (([mouse-1] . nil) ; accidently touching touchpad won't shift cursor ([double-mouse-1] . nil) ([drag-mouse-1] . nil) ([down-mouse-1] . nil)))))

((string-match "^blue" system-name) ; G5 iMac at home '((default-font "-apple-andale mono-medium-r-normal--0-0-0-0-m-0-mac-roman") (machine-os "osx") (save-folder "~/.emacs.d/saves") (frame-r ((top . 20) (left . 320) (width . 80) (height . 71))) (frame-l ((top . 20) (left . 902) (width . 80) (height . 71)))))

((string-match "^GOSHCC" system-name) ; GOSH PC '( (default-font "-outline-Courier New-normal-normal-normal-mono-13-*-*-*-c-*-fontset-startup") (machine-os "windows") ; one of "linux" "osx" "windows" (save-folder "~/emacs-saves") (post-setup-fn (lambda () (find-file "k:/Direct Marketing/Data Analyst/indy/notes/") (find-file "k:/Direct Marketing/Data Analyst/indy/notes/") (find-file "k:/Direct Marketing/Data Analyst/indy/notes/")))

(frame-r ((top . 0) (left . 0) (width . 80) (height . 60))) (frame-l ((top . 20) (left . 510) (width . 80) (height . 60)))))

((equal system-name "green") ; old laptop thrown out by orange '((hyperspec-root "file:///usr/share/common-lisp/isg--hyperspec/HyperSpec/")))

;; Windows ;; default font: "file:///usr/share/common-lisp/isg-hyperspec/HyperSpec/" ;; inferior lisp: "C:\\home\\bin\\sbcl\\sbcl.exe" ;; (post-setup-fn (lambda () ;; ((setq exec-path (append exec-path '("c:\\home\\bin\\emacs-22.1\\bin"))) ;; (load-file "~/.emacs.d/site-lisp/external/gnuserv.el") ;; (gnuserv-start) ;; (setq gnuserv-frame(selected-frame)))))


  (isg--timer "frame-setup"
              (defun isg--frame-setup ()
                (when (and (isg--val 'frame-r) (isg--val 'frame-l))
                  (setq initial-frame-alist (isg--val 'frame-r)
                        default-frame-alist (isg--val 'frame-l)))
                (add-to-list 'default-frame-alist
                             (cons 'font
                                   (isg--val 'default-font))))


              (if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
              (if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
              (if (fboundp 'menu-bar-mode) (menu-bar-mode -1)))

essential packages


|---------------+---------+---------------------| | Section | Key | Command | |---------------+---------+---------------------| | | C-c v | magit-status | | | C-c C-c | magit-status | | | | | | | c c | commit | | | C-c C-c | actually commit | | | | | | Push/Pull | F u | pull | | | P u | push | | | | | | Staging | s | stage a file | | | S | stage all files | | | u | unstage file | | | | | | Branching (b) | b b | switch branch | | | b c | checkout new branch | | | | | | Reset (X) | X h | hard reset | | | | | | Stashing (z) | z z | stash | | | z p | pop stash | | | | | | Merging (m) | | | |---------------+---------+---------------------|


|----------------------------+------------------------------------------------| | Command | Description | |----------------------------+------------------------------------------------| | magit-log-trace-definition | shows the history of all changes in a function | |----------------------------+------------------------------------------------|

#+BEGIN_SRC emacs-lisp (isg--timer "magit" (use-package magit :commands magit-status :init (global-set-key "\C-cv" 'magit-status) (global-set-key "\C-c\C-v" 'magit-status) (setq magit-repository-directories (isg--val 'magit-repos)) :config (setq magit-push-always-verify nil))) #+END_SRC

magit rebasing (e.g. squashing commits)

move cursor in magit window down to the earliest commit r i <- rebase interactive move past the first commit (leaving 'pick' next to it)

's' next to any commit that should be squashed 'f' for squash but discard this commit's log message 'M-p' move the commit at point up 'M-n' move the commit at point down 'r' reword a commit

C-c C-c <- commit changes

magit rebasing a feature branch on top of master

make the current branch the feature branch

r e select the master branch

magit merging a feature branch back into master

(assuming that the current branch is the feature branch)

b b checkout the master branch m m select the feature branch

(now delete the feature branch) b k select the feature branch

magit pushing commits upstream

P u

magit stashing



|----------+-------------+--------------------------------------------------| | Section | Key | Command | |----------+-------------+--------------------------------------------------| | Capture | C-c c | Capture a thought/event/task | | | C-c C-w | Refile an entry from the inbox | | Refiling | C-c C-c | add a tag to a heading (use in file) | | | C-c C-t | cycle between TODO/DONE/nothing heading states | | | C-c C-s | Add a schedule time/date to the heading | | | C-c C-d | Add a deadline | | | C-c C-x C-a | Archive | | Org Mode | C-c C-c | Eval code within BEGIN_SRC/END_SRC blocks | | | C-c ' | Open up a mini-buffer for editing the code block | |----------+-------------+--------------------------------------------------|

org-mode + gtd:

All reference documents are put in a references folder next to my Orgmode files. They are then linked (using org-store-link) from Dired buffers into my projects for quick access.

  (isg--timer "org"
              (use-package org
                :mode (("\\.org$" . org-mode))
                (use-package org-bullets
                  (setq org-bullets-bullet-list '("▶")))
                (add-hook 'org-mode-hook (lambda ()
                                           (setq truncate-lines nil)
                                           (setq word-wrap t)
                                           (org-bullets-mode 1)))
                (setq org-hide-leading-stars t)
                (setq org-startup-folded t)
                (setq org-agenda-files '("~/personal/manage/"
                (setq org-capture-templates '(("t" "Todo [inbox]" entry
                                               (file+headline "~/personal/manage/" "Tasks")
                                               "* TODO %i%?")
                                              ("r" "Reminder" entry
                                               (file+headline "~/personal/manage/" "Reminder")
                                               "* %i%? \n %U")))
                (setq org-refile-targets '(("~/personal/manage/" :maxlevel . 1)
                                           ("~/personal/manage/" :level . 1)
                                           ("~/personal/manage/" :maxlevel . 1)))
                (define-key global-map "\C-cc" 'org-capture)
                (require 'org-drill)))

<2017-05-15 Mon>


(isg--timer "hydra"
  (use-package hydra
               :ensure t))

ivy + swiper + counsel

    ivy is a completion framework
  • It provides an interface to list, search, filter and perform actions on a collection of "things". These "things" can range from strings to buffers, Ivy doesn't really care. It just provides a way for the user to interact with this collection.

  (isg--timer "ivy"
              (use-package ivy
                :defer 0.1
                (ivy-count-format "(%d/%d) ")
                (ivy-display-style 'fancy)
                (ivy-use-virtual-buffers t)
                ;; swiper should only search for the typed text
                (setq ivy-re-builders-alist
                      '((swiper . regexp-quote)
                        (t      . ivy--regex-plus)))))

  (isg--timer "ivy-rich"
              (use-package ivy-rich
                :after ivy
                (ivy-virtual-abbreviate 'full
                                        ivy-rich-switch-buffer-align-virtual-buffer t
                                        ivy-rich-path-style 'abbrev)

  (isg--timer "swiper"
              (use-package swiper
                :after ivy))

  (defun ivy-with-thing-at-point (cmd)
    (let ((ivy-initial-inputs-alist
            (cons cmd (thing-at-point 'symbol)))))
      (funcall cmd)))

  ;; search for the word under the cursor, revert to the general search if over
  ;; whitespace or a word I don't want to search for (e.g. common Rust keywords)
  (defun isg--search-thing ()
    (if (or (member (char-after) '(?\s ?\n ?\t))
            (member (thing-at-point 'word) '("use" "fn" "let")))
      (ivy-with-thing-at-point 'swiper)))

  (isg--timer "counsel"
              (use-package counsel
                :after ivy
                (setq counsel-grep-base-command "rg -i -M 120 --no-heading --line-number --color never %s %s")
                (global-set-key (kbd "C-M-s") 'isearch-forward)
                (global-set-key (kbd "C-M-r") 'isearch-backward)

                (global-set-key (kbd "M-x") 'counsel-M-x)

                (global-set-key (kbd "M-x") 'counsel-M-x)
                (global-set-key (kbd "C-s") 'isg--search-thing)

                ;; for a faster simpler search:
                ;; (global-set-key (kbd "C-s") 'swiper-isearch)

                (global-set-key (kbd "C-M-g") 'counsel-git)

                (global-set-key (kbd "C-x C-f") 'counsel-find-file)

                ;; use the hydra equivalents instead (C-c f ...)
                ;; (global-set-key (kbd "C-x C-g") 'counsel-git)
                ;; (global-set-key (kbd "C-x C-r") 'counsel-rg)

                ;; I don't use these bindings - should learn what they do one day
                ;; (global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
                (define-key read-expression-map (kbd "C-r") 'counsel-expression-history))

              (defhydra isg--hydra-counsel (:color pink :exit t)
            Counsel search
            Buffer   : _c_: counsel-grep  _o_: counsel-grep-or-swiper
            Files    : _r_: ripgrep       _d_: rgrep
            Filenames: _g_: git (file)    _f_: find file
            Misc     : _u_: function      _v_: variable  _l_: library _s_: symbol
                ("r" (lambda ()
                       (counsel-rg (format "%s" (or (thing-at-point 'symbol) "")))))
                ("d" rgrep)

                ("c" counsel-grep)
                ("o" counsel-grep-or-swiper)

                ("f" counsel-find-file)
                ("g" counsel-git)

                ("u" counsel-describe-function)
                ("v" counsel-describe-variable)
                ("l" counsel-find-library)
                ("s" counsel-info-lookup-symbol)
                ("RET" nil "done" :color blue))

              (bind-keys ("C-c f" . isg--hydra-counsel/body)))

company - auto completion

  (isg--timer "company"
             (use-package company
               :defer t
                 ;; Reduce the time after which the company auto completion popup opens
                 ;; Reduce the number of characters before company kicks in
                 (setq company-idle-delay 0.8
                       company-minimum-prefix-length 3
                       company-show-numbers t
                       company-require-match nil
                       company-tooltip-align-annotations t
                       company-tooltip-margin 1
                       company-echo-delay 0
                       company-dabbrev-downcase nil
                       company-minimum-prefix-length 1
                       company-selection-wrap-around t
                       company-transformers '(company-sort-by-occurrence
                 (push (apply-partially #'cl-remove-if
                                        (lambda (c) (string-match-p "\\`[0-9]+[f]*\\'" c)))
                 (define-key company-active-map (kbd "C-n") 'company-select-next)
                 (define-key company-active-map (kbd "C-p") 'company-select-previous))))


  (isg--timer "ibuffer"
             (defalias 'list-buffers 'ibuffer)

             (setq ibuffer-saved-filter-groups
                   (quote (("default"
                            ("eshell" (mode . eshell-mode))
                            ("dired" (mode . dired-mode))
                            ("c" (mode . c-mode))
                            ("seni" (mode . seni-mode))
                            ("rust" (mode . rust-mode))
                            ("js" (or (mode . js2-mode)
                                      (mode . rjsx-mode)))
                            ("occur" (name . "^\\*ivy-occur"))
                            ("org" (mode . org-mode))
                            ("web" (or
                                    (mode . html-mode)
                                    (mode . css-mode)))
                            ("emacs" (or
                                      (name . "^\\*scratch\\*$")
                                      (name . "^\\*Messages\\*$")))
                            ("magit" (name . "^\\*magit")))))
                   ibuffer-show-empty-filter-groups nil)

             (add-hook 'ibuffer-mode-hook
                       (lambda ()
                         (ibuffer-switch-to-saved-filter-groups "default"))))

language modes

COMMENT language prep

  (isg--timer "lang-prep"
             ;; the ligature config code uses -iterate and -zip-pair
             (use-package dash
               :demand t)


             (defun my-ligature-list (ligatures codepoint-start)
               "Create an alist of strings to replace with
                codepoints starting from codepoint-start."
               (let ((codepoints (-iterate '1+ codepoint-start (length ligatures))))
                 (-zip-pair ligatures codepoints)))

; list can be found at

             (defvar my-hasklig-ligatures
               (let* ((ligs '("&&" "***" "*>" "\\\\" "||" "|>" "::"
                              "==" "===" "==>" "=>" "=<<" "!!" ">>"
                              ">>=" ">>>" ">>-" ">-" "->" "-<" "-<<"
                              "<*" "<*>" "<|" "<|>" "<$>" "<>" "<-"
                              "<<" "<<<" "<+>" ".." "..." "++" "+++"
                              "/=" ":::" ">=>" "->>" "<=>" "<=<" "<->")))
                 (isg--correct-symbol-bounds (my-ligature-list ligs #Xe100)))))


#+BEGIN_SRC emacs-lisp (isg--timer "c" ;; Set default indentation to 4. (defun my-c-mode-common-hook () (c-set-offset 'substatement-open 0) ;;(setq c++-tab-always-indent nil) (setq c-basic-offset 2) (setq c-indent-level 2) (setq tab-stop-list '(2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60)) (setq tab-width 2)) (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

(add-hook 'c-mode-hook (lambda () ;;(add-to-list (make-local-variable 'company-backends) 'company-clang) (setq comment-start "// " comment-end "")))

COMMENT clojure

(use-package cmake-mode :mode "CMakeLists\\.txt")) #+END_SRC #+BEGIN_SRC emacs-lisp (use-package cider :defer t :init (add-hook 'cider-mode-hook 'cider-turn-on-eldoc-mode)) #+END_SRC

#+BEGIN_SRC emacs-lisp (use-package clojure-mode :mode "\\.clj\\'" :config (define-key clojure-mode-map (kbd ")") 'sp-up-sexp) (pretty-fn))

COMMENT csharp

(setq nrepl-hide-special-buffers t) #+END_SRC

  (isg--timer "csharp"
             (use-package csharp-mode
               :mode "\\.cs\\'"
               (setq default-tab-width 4)))


  (isg--timer "css"
             (use-package css-mode
               :mode (("\\.css\\'" . css-mode)
                      ("\\.less\\'" . css-mode))
               (use-package rainbow-mode)
               (add-hook 'css-mode-hook 'rainbow-mode)
               (setq css-indent-offset 2))
             (add-to-list 'auto-mode-alist '("\\.less$" . css-mode)))


#+BEGIN_SRC emacs-lisp (use-package dart-mode :mode "\\.dart\\'" :config (setq dart-enable-analysis-server t)) #+END_SRC


| key | elm-repl | |---------+-----------------------------------| | C-c C-l | load the current file in a REPL | | C-c C-p | push the current region to a REPL |

#+BEGIN_SRC emacs-lisp (use-package elm-mode :mode "\\.elm\\'" :config (add-hook 'elm-mode-hook (lambda () (add-to-list (make-local-variable 'company-backends) 'company-elm)))

(add-hook 'elm-mode-hook #'elm-oracle-setup-completion)

;; this line is a HACK so that auto-completion will work on Windows ;; TODO: find the root cause of this issue ;; ;;(elm-oracle--get-completions-cached "List.a")) ) #+END_SRC


  (isg--timer "glsl"
             (use-package glsl-mode
               :mode (("\\.glsl\\'" . glsl-mode)
                      ("\\.vert\\'" . glsl-mode)
                      ("\\.frag\\'" . glsl-mode)
                      ("\\.geom\\'" . glsl-mode))
               (autoload 'glsl-mode "glsl-mode" nil t)))


  (isg--timer "go"
             (use-package go-mode
               :mode "\\.go\\'"
               (add-hook 'before-save-hook #'gofmt-before-save)))

COMMENT groovy

COMMENT haskell

#+BEGIN_SRC emacs-lisp (add-to-list 'auto-mode-alist '("\\.gradle$" . groovy-mode)) #+END_SRC

was using the intero package


formatting requires the hindent binary to be installed:

section key command
C-c C-l load this module in the REPL
M-. jump to definition
C-c C-i show information of identifier at point
C-c C-t display type of identifier at point
C-c C-r automatically apply suggestions
C-u C-c C-t insert a type signature for the thing at point
C-c C-c evaluate the selected region in the REPL
C-c C-k clear REPL
C-c C-z switch to and from the REPL
C-c ! l see a list of errors
C-c ! n jump to next error
C-c ! p jump to previous error
formatting C-M-\ format selected region
M-q format current expression

  (isg--timer "haskell-config"
             (defun isg--haskell-config ()
               ;; use the Hasklig font for Haskell mode
               (setq buffer-face-mode-face '(:family "Hasklig"))
               ;; nice glyphs for haskell with hasklig
               (setq prettify-symbols-alist
                     (append my-hasklig-ligatures prettify-symbols-alist))

             (use-package haskell-mode
               :mode "\\.hs\\'"
               (use-package hindent :defer t)
               ;; (require 'hindent)
               (add-hook 'haskell-mode-hook 'isg--haskell-config)
               (add-hook 'haskell-mode-hook #'hindent-mode)
               (setq hindent-reformat-buffer-on-save t)))


| key | command | |---------+------------------------------------------------------------------------| | C-c C-w | js2-mode-toggle-warnings-and-errors (stops annoying orange underlines) | | | |




#+BEGIN_SRC emacs-lisp (isg--timer "javascript" (use-package js2-mode :mode (;; ("\\.js\\'" . js2-mode) ("\\.es6\\'" . js2-mode)) :init (use-package js-comint :defer t) (add-hook 'js2-mode-hook 'ws-butler-mode) :config (setq js2-basic-offset 2) (setq js-indent-level 2) (setq js2-global-externs '("require" "expect" "describe" "it" "beforeEach")) (define-key js2-mode-map (kbd "") #'company-indent-or-complete-common)) (use-package rjsx-mode :mode "\\.js\\'")) #+END_SRC #+BEGIN_SRC emacs-lisp (isg--timer "jsx" (use-package web-mode :mode (("\\.jsx\\'" . web-mode) ("\\.tsx\\'" . web-mode)) :init (add-hook 'web-mode-hook 'ws-butler-mode) ;;(when (string-equal "tsx" (file-name-extension buffer-file-name)) ;;(setup-tide-mode)) (defadvice web-mode-highlight-part (around tweak-jsx activate) (if (equal web-mode-content-type "jsx") (let ((web-mode-enable-part-face nil)) ad-do-it) ad-do-it)))) #+END_SRC #+BEGIN_SRC emacs-lisp (isg--timer "markdown" (use-package markdown-mode :mode (("\\.md\\'" . markdown-mode) ("\\.markdown\\'" . markdown-mode)))) #+END_SRC #+BEGIN_SRC emacs-lisp (use-package nim-mode :mode "\\.nim\\'") #+END_SRC

COMMENT purescript

was using the psc-ide and purescript-mode packages


  (isg--timer "purescript"
             (use-package purescript-mode
               :mode "\\.purs\\'"
               (use-package psc-ide)
               (add-hook 'purescript-mode-hook 'setup-purescript-mode))

             (defun substitute-purescript-syntax-with-unicode ()
                (list ;(cons "\\(<-\\)" 'left-arrow)
                                          ;(cons "\\(->\\)" 'right-arrow)
                                          ;(cons "\\(/=\\)" 'not-equal)
                 (cons "\\(()\\)" 'nil)
                 (cons "\\(/\\\\\\)" 'capital-lambda) ; /\ : should be nary-logical-and but that looks bad
                 (cons "\\<\\(forall\\)\\>" 'for-all)
                                          ;(cons "\\(&&\\)" 'logical-and)
                                          ;(cons "\\(||\\)" 'logical-or)
                 (cons "\\<\\(not\\)\\>" 'logical-neg)
                                          ;(cons "\\(>\\)\\[^=\\]" 'greater-than)
                                          ;(cons "\\(<\\)\\[^=\\]" 'less-than)
                                          ;(cons "[^>]\\(>=\\)" 'greater-than-or-equal-to) ; substitute >= but ignore >>=
                                          ;(cons "\\(<=\\)" 'less-than-or-equal-to)
                 (cons "\\(''\\)" 'double-prime)
                 (cons "\\('\\)" 'prime))))

             (defun setup-purescript-mode ()


               ;; use the Hasklig font for Purescript mode
               (setq buffer-face-mode-face '(:family "Hasklig"))
               ;; nice glyphs for purescript with hasklig
               (setq prettify-symbols-alist (append my-hasklig-ligatures prettify-symbols-alist))

purescript syntax: | <> | string concatenation | | $ | infix apply | | <<< | backwards composition | | >>> | forwards composition | | >>= | bind | | => | double arrow | | | |

emacs psc-ide mode: | C-c C-s | start server | | C-c C-q | quit server | | C-c C-b | rebuild the current module and get quick error reporting | | C-c C-t | show type for identifier under cursor | | C-c C-l | load all modules | | M-. | go to definition | | M-, | jump back | | C-c C-i | add an import for the identifier under cursor | | C-c C-c | case split the given type under cursor (really cool) | | C-c C-a | add a clause for the function definition under cursor |

  • make sure that the purescript project has been compiled.
  • after loading up a purescript file for the first time press C-c C-s to start the server

pulp commands: | pulp init | sets up a folder | | pulp repl | type :? to see commands | | pulp build | | | pulp --psc-package build | use psc-package for package management | | pulp build -O --to output.js | apply dead code elimination | | pulp run | | | pulp browserify | prints code to stdout |

repl: | :paste | enter multi-line input mode | | C-d | exit multi-line input mode | | :type | shows type of an expression | | :kind | shows the kind of a type | | :r | reload imported modules |


psc-package commands | init | create psc-package.json file | | available | lists available packages | | install | $ psc-package install console | | update | update dependencies | | updates | check all packages for new releases |

$ mkdir hello_world $ cd hello_world $ psc-package init $ psc-package available $ psc-package install psci-support $ psc-package install lists $ psc-package install console

<2017-09-28 Thu> a lot of the psc-package commands fail on windows but if we're working with a pre-existing project then we can get by with using pulp

bower: NOT RECOMMENDED - try to use psc-package instead $ bower install purescript-math --save

flare is an easy to use library, easy to make cool interactive graphs pux - similar to the Elm architecture, Interactive React debugger can be wired in halogen - the hardest to understand library


read purescript by example try out Pux or Flare come on #purescript on freenode video meetup try out Halogen

  (isg--timer "racket"
              (use-package racket-mode
                :mode "\\.rkt\\'"))

COMMENT reasonml

  (isg--timer "reasonml"
             (defun shell-cmd (cmd)
               "Returns the stdout output of a shell command or nil if the command returned
        an error"
               (car (ignore-errors (apply 'process-lines (split-string cmd)))))

             (when (not (string-match "windows" (isg--val 'machine-os)))
               (let* ((refmt-bin (or (shell-cmd "refmt ----where")
                                     (shell-cmd "which refmt")))
                      (merlin-bin (or (shell-cmd "ocamlmerlin ----where")
                                      (shell-cmd "which ocamlmerlin")))
                      (merlin-base-dir (when merlin-bin
                                         (replace-regexp-in-string "bin/ocamlmerlin$" "" merlin-bin))))
                 ;; Add npm merlin.el to the emacs load path and tell emacs where to find ocamlmerlin
                 (when merlin-bin
                   (add-to-list 'load-path (concat merlin-base-dir "share/emacs/site-lisp/"))
                   (setq merlin-command merlin-bin))

                 (when refmt-bin
                   (setq refmt-command refmt-bin)))

               (require 'reason-mode)
               (require 'merlin)
               (add-hook 'reason-mode-hook (lambda ()
                                             (add-hook 'before-save-hook 'refmt-before-save)

               (setq merlin-ac-setup t)))



#+BEGIN_SRC emacs-lisp (isg--timer "ruby" (add-to-list 'auto-mode-alist '("Rakefile" . ruby-mode)) (use-package ruby-mode :config (add-hook 'ruby-mode-hook '(lambda () (local-set-key (kbd "C-M-p") #'scroll-down-line) (local-set-key (kbd "C-M-n") #'scroll-up-line))))) #+END_SRC install racer with: $ cargo install racer

cargo.el is a minor mode which allows us to run cargo commands from emacs like: | key | command | |-------------+-------------| | C-c C-c ret | cargo fmt | | C-c C-c C-b | cargo build | | C-c C-c C-r | cargo run | | C-c C-c C-t | cargo test |

one day try and get the lsp stuff working: last attempt at this was <2018-02-27 Tue> - tried it on the Mac, which should have been the easiest to get working. It took ages to compile, worked like the existing setup for a few minutes and then stopped working.

  (defun isg--racer-find-definition ()
    "Run the racer find-definition command and center the cursor"

  (defun isg--pop-tag-mark ()
    "Run the racer find-definition command and center the cursor"

  (isg--timer "rust"
              (use-package company-racer
                :defer t)

              (use-package rust-mode
                :mode "\\.rs\\'"
                ;; Re-use the Cargo windows - don't just make the same window reappear below
                ;; the current buffer if the other frame already contains that window. Useful
                ;; for running tests and not having the *Cargo Test* buffer alway pop up on
                ;; the same frame as the source buffer
                (add-to-list 'display-buffer-alist
                               (display-buffer-reuse-window display-buffer-reuse-window)
                               (reusable-frames . t)))
                (use-package cargo)
                (use-package flycheck-rust
                  (add-hook 'flycheck-mode-hook #'flycheck-rust-setup))
                (use-package racer
                  (setq racer-cmd (isg--val 'racer-cmd)
                        racer-rust-src-path (isg--val 'racer-rust-src-path))
                  (define-key racer-mode-map (kbd "M-.") 'isg--racer-find-definition)
                  (define-key racer-mode-map (kbd "M-,") 'isg--pop-tag-mark)
                  (add-hook 'racer-mode-hook #'eldoc-mode))

                (add-hook 'rust-mode-hook
                          '(lambda ()
                             (add-to-list (make-local-variable 'company-backends)
                             ;; Key binding to jump to method definition
                             (local-set-key (kbd "<tab>") #'company-indent-or-complete-common)))))

COMMENT scheme

  (isg--timer "scheme"
             (add-hook 'scheme-mode-hook
                       (lambda ()
                         (define-key scheme-mode-map (kbd ")") 'sp-up-sexp))))


  (isg--timer "seni"
             (autoload 'seni-mode "seni" nil t)
             (add-to-list 'auto-mode-alist '("\\.seni$" . seni-mode))
             (add-to-list 'auto-mode-alist '("\\.sen$" . seni-mode))
             (add-hook 'seni-mode-hook 'smartparens-strict-mode)
             (add-hook 'seni-mode-hook
                       (lambda ()
                         (define-key seni-mode-map (kbd ")") 'sp-up-sexp))))

COMMENT shader-mode

  (isg--timer "shader"
             (use-package shader-mode
               :mode "\\.shader\\'"
               (setq shader-indent-offset 2)))


to connect to a sql process, first open an sql file, then from that buffer run M-x sql-sqlite C-c C-c should now work

to formatting the results in the SQL buffer: .headers on .mode column

|---------+----------------+------------------------------| | Section | Key | Command | |---------+----------------+------------------------------| | Sql | M-x sql-sqlite | | | | C-c C-c | send paragraph to sql buffer | | | C-c C-r | send region to sql buffer | |---------+----------------+------------------------------|

  (isg--timer "sql"
             (add-to-list 'auto-mode-alist
                          '("\\.sql$" . (lambda ()
             (add-to-list 'auto-mode-alist
                          '("\\.psql$" . (lambda ()


  (isg--timer "toml"
             (use-package toml-mode
               :mode "\\.toml\\'"))

COMMENT typescript

was using the tide package


key description
M-. Jump to definition. With prefix arg, Jump to type definition.
M-, Return to your pre-jump position.
function description
M-x tide-restart-server Restart tsserver. to pickup tsconfig.json changes
M-x tide-documentation-at-point Show documentation for the symbol at point.
M-x tide-references List all references to the symbol at point in a buffer
M-x tide-project-errors List all errors in the project
M-x tide-rename-symbol Rename all occurrences of the symbol at point.
M-x tide-format Format the current region or buffer.
M-x tide-fix Apply code fix for the error at point.

  (isg--timer "typescript"
             (use-package typescript-mode
               :mode "\\.ts\\'"
               (use-package tide)
               (add-hook 'typescript-mode-hook 'setup-tide-mode))

             (defun setup-tide-mode ()
               (flycheck-mode t)
               (setq flycheck-check-syntax-automatically '(save mode-enabled))
               (eldoc-mode t)
               ;; company is an optional dependency. You have to
               ;; install it separately via package-install
               (company-mode t)
               (setq company-tooltip-align-annotations t)
               (tide-hl-identifier-mode +1)))


  (isg--timer "vue"
             (use-package vue-mode
               :mode "\\.vue\\'"
               ;; 0, 1, or 2, representing (respectively) none, low, and high coloring
               (setq mmm-submode-decoration-level 2)))


  (isg--timer "yaml"
             (use-package yaml-mode
               :mode "\\.yaml\\'"))


  (isg--timer "theme-hydra"
             (defun isg--disable-all-themes ()
               (mapc #'disable-theme custom-enabled-themes))

             (defvar isg--theme-hooks nil
               "((theme-id . function) ...)")

             (defun isg--add-theme-hook (theme-id hook-func)
               (add-to-list 'isg--theme-hooks (cons theme-id hook-func)))

             (defun isg--load-theme-advice (f theme-id &optional no-confirm no-enable &rest args)
               "Enhances `load-theme' in two ways:
  1. Disables enabled themes for a clean slate.
  2. Calls functions registered using `isg--add-theme-hook'."
               (unless no-enable
                   (apply f theme-id no-confirm no-enable args)
                 (unless no-enable
                   (pcase (assq theme-id isg--theme-hooks)
                     (`(,_ . ,f) (funcall f))))))

             (advice-add 'load-theme

             (use-package spacemacs-theme
               :defer t)
             (use-package gruvbox-theme
               :defer t)

             (add-to-list 'custom-theme-load-path "~/.emacs.d/themes/")
             (load-theme 'athens t)

             (defhydra isg--hydra-themes (:color pink)
  _A_: Athens
  _M_: Spacemacs Dark _m_: Spacemacs light
  _G_: Gruvbox Dark M   _g_: Gruvbox light M
  _H_: Gruvbox Dark H   _h_: Gruvbox light H
  _S_: Gruvbox Dark S   _s_: Gruvbox light S
  _DEL_: none
               ("A" (load-theme 'athens t))
               ("m" (load-theme 'spacemacs-light t))
               ("M" (load-theme 'spacemacs-dark t))
               ("g" (load-theme 'gruvbox-light-medium t))
               ("G" (load-theme 'gruvbox-dark-medium t))
               ("h" (load-theme 'gruvbox-light-hard t))
               ("H" (load-theme 'gruvbox-dark-hard t))
               ("s" (load-theme 'gruvbox-light-soft t))
               ("S" (load-theme 'gruvbox-dark-soft t))
               ("DEL" (isg--disable-all-themes))
               ("RET" nil "done" :color blue))

             (bind-keys ("C-c w t"  . isg--hydra-themes/body)))

misc helper packages

avy - moving the cursor by searching

  (isg--timer "avy"
             (use-package avy
               :bind ("M-z" . avy-goto-char-timer)))


  (isg--timer "deft"
             (use-package deft
               :commands deft
               (setq deft-directory (isg--val 'deft-directory)
                     deft-extension "org"
                     deft-text-mode 'org-mode
                     deft-use-filename-as-title t
                     deft-auto-save-interval 30.0)))


  (isg--timer "delight"
             (use-package delight
               :ensure t))


access server via ssh in eshell with: $ cd /

  (isg--timer "eshell"
             (defun isg--start-eshell (shell-name)
               "SHELL-NAME the name of the shell."
               (interactive "sEshell name: ")
               (if (string= "" shell-name)
                 (rename-buffer shell-name))))


  (isg--timer "exec-path"
             ;; have to ensure that this is run at startup so that 'cargo' can be
             ;; found when in rust mode and also so that the eshell works as expected

             (use-package exec-path-from-shell
               :ensure t
               :demand t
               ;; (exec-path-from-shell-copy-env "TWITTER_CONSUMER_KEY")
               ;; (exec-path-from-shell-copy-env "TWITTER_CONSUMER_SECRET")
               ;; (exec-path-from-shell-copy-env "TWITTER_ACCESS_TOKEN")
               ;; (exec-path-from-shell-copy-env "TWITTER_ACCESS_TOKEN_SECRET")
               (if (not (string-equal (isg--val 'machine-os) "windows"))
                   (exec-path-from-shell-copy-env "GOPATH"))
               (exec-path-from-shell-setenv "RUST_SRC_PATH" (isg--val 'racer-rust-src-path))
               (when (memq window-system '(mac ns))


  (isg--timer "flycheck"
             ;; setting up flycheck for eslint checks using instructions from:
             ;; C-c ! l : see full list of errors
             ;; C-c ! n : next error
             ;; C-c ! p : previous error
             (use-package flycheck
               :defer 2
               (use-package pkg-info
                 :defer t)
               (setq-default flycheck-disabled-checkers
                             (list 'json-jsonlist
                                   'javascript-jshint ;; disable jshint since we prefer eslint checking

               ;; use eslint with web-mode for jsx files
               (flycheck-add-mode 'javascript-eslint 'web-mode)
               ;; (setq flycheck-eslintrc "~/code/seni-web/.eslintrc.json")
               ;; customize flycheck temp file prefix
               (setq-default flycheck-temp-prefix ".flycheck")
               (setq flycheck-global-modes '(not go-mode org-mode))))

COMMENT highlight thing

  (isg--timer "highlight"
             (use-package highlight-thing
               (setq highlight-thing-delay-seconds 0.5)
               (setq highlight-thing-exclude-thing-under-point t)))


  (isg--timer "htmlize"
             (use-package htmlize
               :commands htmlize-buffer))

COMMENT rich-minority

  (isg--timer "rich-minority"
             (use-package rich-minority
               :ensure t
               (rich-minority-mode 1)))


  (isg--timer "smartparens"
             (use-package smartparens
               :ensure t
               (require 'smartparens-config)
               (smartparens-global-mode t)
               (show-smartparens-global-mode t)
               (mapc (lambda (mode)
                       (add-hook (intern (format "%s-hook" (symbol-name mode))) 'smartparens-strict-mode))
               ;; Conveniently set keys into the sp-keymap, limiting the keybinding to buffers
               ;; with SP mode activated
               (mapc (lambda (info)
                       (let ((key (kbd (car info)))
                             (function (car (cdr info))))
                         (define-key sp-keymap key function)))
                     '(("C-)" sp-up-sexp)
                       ("M-s" sp-splice-sexp)
                       ("C-M-f" sp-forward-sexp)
                       ("C-M-b" sp-backward-sexp)))
               ;; This is from authors config, seems to let you jump to the end of the current
               ;; sexp with paren?
               (define-key emacs-lisp-mode-map (kbd ")") 'sp-up-sexp)
               ;; (define-key scheme-mode-map (kbd ")") 'sp-up-sexp)
               ;; (define-key clojure-mode-map (kbd ")") 'sp-up-sexp)


| key | description | |---------+---------------------------------------| | C-x u | undo-tree-visualize | | C-x r u | Save current buffer state to register | | C-x r U | Restore buffer state from register |

  (isg--timer "undo-tree"
             (use-package undo-tree
               :ensure t
               ;; (global-set-key (kbd "<left>") 'undo-tree-undo)
               ;; (global-set-key (kbd "<right>") 'undo-tree-redo)
               (defhydra hydra-undo-tree (:color yellow)
      _p_: undo  _n_: redo _s_: save _l_: load   "
                 ("p"   undo-tree-undo)
                 ("n"   undo-tree-redo)
                 ("s"   undo-tree-save-history)
                 ("l"   undo-tree-load-history)
                 ("u"   undo-tree-visualize "visualize" :color blue)
                 ("q"   nil "quit" :color blue))
               (global-set-key (kbd "C-M-/") 'hydra-undo-tree/body)))

volatile-highlights - highlights changes to the buffer caused by ‘undo’, ‘yank' etc

  (isg--timer "volatile"
             (use-package volatile-highlights
               :defer 4


  (isg--timer "wgrep"
             (use-package wgrep
               :defer 4))

which key

  (isg--timer "which-key"
             (use-package which-key
               :demand t


  (isg--timer "ws-butler"
             (use-package ws-butler
               :defer t))

global settings

  (isg--timer "global-settings"
             (let ((fn (isg--val 'post-setup-fn)))
               (if fn (funcall fn)))

             (setq default-directory (isg--val 'default-directory))

              ;; visual look: date and time
              display-time-default-load-average nil            ; Don't display load average
              display-time-format "%H:%M"                      ; Format the time string
              display-time-24hr-format t
              european-calendar-style t

              ;; visual look: startup
              inhibit-startup-screen t                         ; Disable start-up screen
              inhibit-startup-message t
              initial-scratch-message ""                       ; Empty the initial *scratch* buffer

              ;; visual look
              font-lock-maximum-decoration t
              show-trailing-whitespace nil                     ; Display trailing whitespaces
              cursor-in-non-selected-windows t                 ; Hide the cursor in inactive windows
              frame-resize-pixelwise t
              window-combination-resize t                      ; Resize windows proportionally
              x-stretch-cursor t                               ; Stretch cursor to the glyph width
              ring-bell-function (lambda () (message "*beep*"))
              visible-bell t
              ns-use-srgb-colorspace nil                       ; Don't use sRGB colors

              ;; changing content
              sentence-end-double-space nil                    ; End a sentence after a dot and a space
              require-final-newline t

              ;; changing content: indentation
              indent-tabs-mode nil                             ; Stop using tabs to indent
              tab-width 4                                      ; Set width for tabs
              standard-indent 4
              default-tab-width 4

              ;; behaviour
              line-move-visual nil
              help-window-select t                             ; Focus new help windows when opened
              mouse-yank-at-point t                            ; Yank at point rather than pointer

              ;; behaviour: scrolling
              fast-but-imprecise-scrolling t
              scroll-conservatively 10000                      ; Always scroll by one line
              scroll-margin 1                                  ; scroll N lines to screen edge
              scroll-step 1                                    ; keyboard scroll one line at a time
              scroll-preserve-screen-position 1

              ;; reduce gc of fonts (better org-bullet mode in Windows)
              inhibit-compacting-font-caches t

              ;; behaviour: clipboard
              select-enable-clipboard t                        ; Merge system's and Emacs' clipboard
              x-select-enable-clipboard t
              x-select-enable-primary t
              save-interprogram-paste-before-kill t

              ;; behaviour: backup
              create-lockfiles nil        ; don't create lockfiles
              backup-by-copying t         ; don't clobber symlinks
              delete-old-versions t
              kept-new-versions 6
              kept-old-versions 2
              version-control t           ; use versioned backups
              backup-directory-alist `((".*" . ,temporary-file-directory))
              auto-save-file-name-transforms `((".*" ,temporary-file-directory t))

              ;; behaviour: vm
              debug-on-error nil
              jit-lock-defer-time 0
              enable-local-variables t

              ;; behaviour: browsing
              browse-url-browser-function 'browse-url-generic
              browse-url-generic-program (isg--val 'url-opener))

             (delete-selection-mode)                           ; Replace region when inserting text
             (setq line-number-mode t)                         ; Enable line numbers in the mode-line
             (setq column-number-mode t)                       ; Enable column numbers in the mode-line
             (size-indication-mode 1)                          ; Enable size status in the mode-line
             (fset 'yes-or-no-p 'y-or-n-p)                     ; Replace yes/no prompts with y/n
             (global-subword-mode)                             ; Iterate through CamelCase words
             (put 'downcase-region 'disabled nil)              ; Enable downcase-region
             (put 'upcase-region 'disabled nil)                ; Enable upcase-region
             (global-hi-lock-mode 1)
             (global-font-lock-mode t)
             (transient-mark-mode t) ; highlight selected text region
             (blink-cursor-mode 0)

             ;; Make sure it uses UTF-8 across the board
             (prefer-coding-system 'utf-8)
             (set-language-environment "UTF-8")
             (set-default-coding-systems 'utf-8)
             (set-terminal-coding-system 'utf-8)
             (set-keyboard-coding-system 'utf-8)
             (setq locale-coding-system 'utf-8)
             (setq default-file-name-coding-system 'utf-8)
             (when (display-graphic-p)
               (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)))

             (autoload 'zap-up-to-char "misc"
               "Kill up to, but not including ARGth occurrence of CHAR." t)

             ;; give buffers unique names
             (require 'uniquify)
             (setq uniquify-buffer-name-style 'post-forward)

             (add-hook 'before-save-hook 'delete-trailing-whitespace)

             ; reload files that have been changed outside of emacs
             (run-with-idle-timer 1 nil (lambda () (global-auto-revert-mode t)))
             (run-with-idle-timer 1 nil (lambda () (show-paren-mode t)))

             (if (not (file-exists-p (isg--val 'save-folder)))
                 (make-directory (isg--val 'save-folder)))

        ;;; os specific settings
              ((string-match "osx" (isg--val 'machine-os))
                mac-command-modifier 'meta
                multi-term-program "/bin/bash")

               (fset 'insertPound "#")
               (global-set-key (kbd "C-M-3") 'insertPound))
              ((string-match "linux" (isg--val 'machine-os))
               (setq multi-term-program "/bin/bash")))
             ;; the standard set of company backends
             (setq company-backends '(company-semantic

             ;; turn on flychecking globally
             (add-hook 'after-init-hook #'global-flycheck-mode)
             (add-hook 'after-init-hook 'global-company-mode)

             ;; todo: read this:

             (use-package tramp
               :defer 5
               (with-eval-after-load 'tramp-cache
                 (setq tramp-persistency-file-name "~/.emacs.d/tramp"))
               (if (eq system-type 'windows-nt)
                   (setq tramp-default-method "plinkx")))

             (defhydra isg--hydra-text-scale (:color pink)
        Text Scale
        _g_: greater
        _l_: lesser
               ("g" text-scale-increase)
               ("l" text-scale-decrease)
               ("RET" nil "done" :color blue))

             (bind-keys ("C-c w s"  . isg--hydra-text-scale/body)))

global window/frame settings

  (isg--timer "window-management"
             ;; the most common form of navigation
             (global-set-key "\M-0" 'other-frame)
             (global-set-key "\M-o" 'other-window)

             ;; label each frame with a number
             (use-package winum
               :demand t
               (setq winum-keymap
                     (let ((map (make-sparse-keymap)))
                       (define-key map (kbd "M-1") 'winum-select-window-1)
                       (define-key map (kbd "M-2") 'winum-select-window-2)
                       (define-key map (kbd "M-3") 'winum-select-window-3)
                       (define-key map (kbd "M-4") 'winum-select-window-4)
                       (define-key map (kbd "M-5") 'winum-select-window-5)
                       (define-key map (kbd "M-6") 'winum-select-window-6)
                       (define-key map (kbd "M-7") 'winum-select-window-7)
                       (define-key map (kbd "M-8") 'winum-select-window-8)

             ;; shift+cursorkeys to move between windows in a frame
             (when (fboundp 'windmove-default-keybindings)

             ;; use winner mode keys for undo/redo operations on window configurations
             ;; C-c left
             ;; C-c right
             (when (fboundp 'winner-mode)
               (winner-mode 1)))

global key settings

  (isg--timer "global-key"
             (global-set-key "\C-w"     'backward-kill-word)
             (global-set-key "\C-x\C-k" 'kill-region)
             (global-set-key "\C-c\C-k" 'kill-region)
             (global-set-key "\M-m" 'call-last-kbd-macro)
             (global-set-key "\M-j" 'eval-print-last-sexp)

             (global-set-key "\C-c\C-f" 'flymake-mode)

             (global-set-key (kbd "C-M-;") 'comment-region)

             (global-set-key (kbd "C-o") 'isg--swap-buffer-with-other-frame)
             (global-set-key (kbd "C-M-o") 'isg--throw-buffer-to-other-frame)

             (global-set-key "\M-&" 'isg--start-shell)
             (global-set-key "\M-*" 'isg--start-eshell)

             (global-set-key (kbd "C-M-p") 'scroll-down-line)
             (global-set-key (kbd "C-M-n") 'scroll-up-line)

             (global-set-key "\M-n" 'forward-paragraph)
             (global-set-key "\M-p" 'backward-paragraph)
             (global-set-key (kbd "C-<return>") 'electric-newline-and-maybe-indent)

             (global-set-key (kbd "C-\\") 'point-to-register)
             (global-set-key (kbd "M-\\") 'jump-to-register)

             (defun isg--machine-set-keys ()
               "set machine specific key bindings"
               (mapcar (lambda (kons)
                         (global-set-key (car kons) (cdr kons)))
                       (isg--val 'key-setup)))