;;; packages.el --- Latex Layer Configuration File for Spacemacs
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

;; variables

(spacemacs|defvar-company-backends LaTeX-mode)

(spacemacs|define-jump-handlers LaTeX-mode)

(defvar latex-build-command (if (executable-find "latexmk") "LatexMk" "LaTeX")
  "The default command to use with `SPC m b'")

(defvar latex-enable-auto-fill t
  "Whether to use auto-fill-mode or not in tex files.")

(defvar latex-enable-folding nil
  "Whether to use `TeX-fold-mode' or not in tex/latex buffers.")

(defvar latex-nofill-env '("equation"
                           "equation*"
                           "align"
                           "align*"
                           "tabular"
                           "tikzpicture")
  "List of environment names in which `auto-fill-mode' will be inhibited.")

;;; packages.el --- Latex Layer Configuration File for Spacemacs
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

;; variables

(spacemacs|defvar-company-backends LaTeX-mode)

(spacemacs|define-jump-handlers latex-mode)

(defvar latex-build-command (if (executable-find "latexmk") "LatexMk" "LaTeX")
  "The default command to use with `SPC m b'")

(defvar latex-enable-auto-fill t
  "Whether to use auto-fill-mode or not in tex files.")

(defvar latex-enable-folding nil
  "Whether to use `TeX-fold-mode' or not in tex/latex buffers.")

(defvar latex-nofill-env '("equation"
                           "equation*"
                           "align"
                           "align*"
                           "tabular"
                           "tikzpicture")
  "List of environment names in which `auto-fill-mode' will be inhibited.")

Fix latex-mode jump handler definition

Fix latex-mode jump handler definition


;; backup in one place. flat, no tree structure
;; http://ergoemacs.org/emacs/emacs_set_backup_into_a_directory.html
(setq backup-directory-alist '(("" . "~/.emacs.d/emacs-backup")))

;; setup for installing markdown-mode
;; https://jblevins.org/projects/markdown-mode/
(require 'package)
(add-to-list 'package-archives
	     '("melpa-stable"
	       . "https://stable.melpa.org/packages/"))
(package-initialize)

;; Make the default window bigger
(add-to-list 'default-frame-alist '(height . 45))
(add-to-list 'default-frame-alist '(width . 110))

Make emacs default window bigger

Make emacs default window bigger


;;; tools/taskrunner/config.el -*- lexical-binding: t; -*-

(use-package! helm-taskrunner
  :when (featurep! :completion helm)
  :defer t
  :config (helm-taskrunner-minor-mode +1))

(use-package! ivy-taskrunner
  :when (featurep! :completion ivy)
  :defer t
  :config (ivy-taskrunner-minor-mode +1))

;;; tools/taskrunner/config.el -*- lexical-binding: t; -*-

(after! taskrunner
  (set-popup-rule! taskrunner--buffer-name-regexp :quit t))

(use-package! helm-taskrunner
  :when (featurep! :completion helm)
  :defer t
  :config (helm-taskrunner-minor-mode +1))

(use-package! ivy-taskrunner
  :when (featurep! :completion ivy)
  :defer t
  :config (ivy-taskrunner-minor-mode +1))

Set popup rule for taskrunner buffer

tools/taskrunner: Set popup rule for taskrunner buffer


;; Time-stamp: <2015-10-18 11:41:54 kmodi>

;; Beacon
;; https://github.com/Malabarba/beacon

(use-package beacon
  :config
  (progn
    (setq beacon-blink-when-point-moves nil) ; default nil
    (setq beacon-blink-when-buffer-changes t) ; default t
    (setq beacon-blink-when-window-scrolls t) ; default t
    (setq beacon-blink-when-window-changes t) ; default t

    (setq beacon-blink-duration 0.3) ; default 0.3
    (setq beacon-blink-delay 0.3) ; default 0.3
    (setq beacon-size 20) ; default 40
    ;; (setq beacon-color "yellow") ; default 0.5
    (setq beacon-color 0.5) ; default 0.5

    (beacon-mode 1)))

(provide 'setup-beacon)

;; Time-stamp: <2015-10-19 09:42:35 kmodi>

;; Beacon
;; https://github.com/Malabarba/beacon

(use-package beacon
  :config
  (progn
    ;; Remove extra space from minor mode lighters
    (setq beacon-lighter (cond
                          ((char-displayable-p ?💡) "💡")
                          ((char-displayable-p ?Λ) "Λ")
                          (t "*")))

    (setq beacon-blink-when-point-moves nil) ; default nil
    (setq beacon-blink-when-buffer-changes t) ; default t
    (setq beacon-blink-when-window-scrolls t) ; default t
    (setq beacon-blink-when-window-changes t) ; default t

    (setq beacon-blink-duration 0.3) ; default 0.3
    (setq beacon-blink-delay 0.3) ; default 0.3
    (setq beacon-size 20) ; default 40
    ;; (setq beacon-color "yellow") ; default 0.5
    (setq beacon-color 0.5) ; default 0.5

    (beacon-mode 1)))

(provide 'setup-beacon)

Remove space from beacon lighter

Remove space from beacon lighter


(require 'package)

;; Add MELPA repository
(add-to-list 'package-archives
             '("melpa" .
               "http://melpa.milkbox.net/packages/"))

;; Add MELPA Stable
(add-to-list 'package-archives
             '("melpa-stable" .
               "https://stable.melpa.org/packages/"))

;; Add GNU ELPA repository
(add-to-list 'package-archives
             '("gnu" .
               "http://elpa.gnu.org/packages/"))

(setf package-archive-priorities
      '(("melpa-stable" . 20)
        ("gnu" . 10)
        ("marmalade" . 10)
        ("melpa" . 0)))

;; (require 'packup)

(provide 'repositories)

(require 'package)

;; Add MELPA repository
(add-to-list 'package-archives
             '("melpa" .
               "http://melpa.milkbox.net/packages/"))

;; Add MELPA Stable
(add-to-list 'package-archives
             '("melpa-stable" .
               "https://stable.melpa.org/packages/"))

;; Add GNU ELPA repository
(add-to-list 'package-archives
             '("gnu" .
               "http://elpa.gnu.org/packages/"))

(setf package-archive-priorities
      '(("melpa-stable" . 20)
        ("gnu" . 10)
        ("melpa" . 0)))

;; (require 'packup)

(provide 'repositories)

Delete Marmalade from our list of package-archive priorities

We don't need to keep it around if it's not configured---Marmalade
users can definitely install it themselves later on.


;; Gosin's Emacs Configuration 2021/01/09
;; add ELPA and MELPA package repos
(setq package-archives
      '(("gnu" . "http://elpa.gnu.org/packages/")
	("melpa" . "http://melpa.org/packages/")))

;; user solarized dark color theme
(add-to-list 'custom-theme-load-path "~/.emacs.d/solarized_theme")
(set-terminal-parameter nil 'background-mode 'dark)
(set-frame-parameter nil 'background-mode 'dark)
(load-theme 'solarized t)

;; define three useful commands(from org guide)
(global-set-key (kbd "C-c l") 'org-store-link)
(global-set-key (kbd "C-c a") 'org-agenda)
(global-set-key (kbd "C-c c") 'org-capture)

(custom-set-variables
 '(global-display-line-numbers-mode t) ; display line numbers
 '(apropos-sort-by-scores t)) ; sort apropos results by relevance

;; store backup and autosave files to temporary directories
(setq backup-director-alist
      '((".*" . ,temporary-file-directory)))

Save backup files to temporary directory for Emacs


(require 'flycheck)

;; todo: show eldoc in modeline, since the minibuffer is used by
;; flycheck.
(add-hook 'c-mode-hook #'c-turn-on-eldoc-mode)

(require 'which-func)
(setq which-func-modes (list #'c-mode))
(add-hook 'c-mode-hook #'which-function-mode)

;; C++
(add-hook
 'c++-mode-hook
 (lambda ()
   (setq flycheck-clang-language-standard "c++11"
         flycheck-clang-definitions '("__STDC_LIMIT_MACROS"
                                      "__STDC_CONSTANT_MACROS"))))

(provide 'c-customisations)

(require 'flycheck)

;; todo: show eldoc in modeline, since the minibuffer is used by
;; flycheck.
(add-hook 'c-mode-hook #'c-turn-on-eldoc-mode)

;; TODO: this doesn't belong here.
(require 'which-func)
(setq which-func-modes (list #'c-mode #'python-mode))

(add-hook 'c-mode-hook #'which-function-mode)

;; C++
(add-hook
 'c++-mode-hook
 (lambda ()
   (setq flycheck-clang-language-standard "c++11"
         flycheck-clang-definitions '("__STDC_LIMIT_MACROS"
                                      "__STDC_CONSTANT_MACROS"))))

(provide 'c-customisations)

Use which-func-mode in python too.

Use which-func-mode in python too.


;; -*- no-byte-compile: t; -*-
;;; ~/.doom.d/packages.el

;;; Examples:
;; (package! some-package)
;; (package! another-package :recipe (:fetcher github :repo "username/repo"))
;; (package! builtin-package :disable t)
(package! flymd)
(package! lispyville)
(package! sort-words)
(package! uuidgen)

;; -*- no-byte-compile: t; -*-
;;; ~/.doom.d/packages.el

;;; Examples:
;; (package! some-package)
;; (package! another-package :recipe (:fetcher github :repo "username/repo"))
;; (package! builtin-package :disable t)
(package! cider
  :recipe (:fetcher github
           :repo "clojure-emacs/cider"
           :commit "200c88adb1314b5811ba749af42ffb6817c1ca1b"
           :files ("*.el" (:exclude ".dir-locals.el"))
           :old-names (nrepl)))
(package! clj-refactor
  :recipe (:fetcher github
           :repo "clojure-emacs/clj-refactor.el"
           :commit "3d5d1fbf28bfcc00f917cd96d6784968dcbbc962"))
(package! flymd)
(package! lispyville)
(package! sort-words)
(package! uuidgen)

Revert "doom-emacs: Remove cider and clj-refactor pins"

This reverts commit afe0422471cb25078cede64bf699d4a25acf4775.


;; -*- no-byte-compile: t; -*-

(package! bison-mode)
(package! vimrc-mode)
(package! ripgrep)
(package! alloy-mode
    :recipe (:host github :repo "dwwmmn/alloy-mode"))
(package! org-ref)
(package! fill-column-indicator)

(package! evil-snipe :disable t)

(package! rebecca-theme)

Add rebecca-theme (from spacemacs) to emacs


(add-hook 'clojure-mode-hook 'enable-paredit-mode)

(setq clojure-src-root (expand-file-name "~/Projects/External"))
(setq swank-clojure-extra-vm-args (list "-server"
                                        "-Xmx1024m"
                                        "-XX:+UseConcMarkSweepGC"
                                        "-XX:+UseCompressedOops"
                                        "-XX:+DoEscapeAnalysis"))

(add-hook 'slime-repl-mode-hook 'slime-redirect-inferior-output)

(eval-after-load "viper"
  '(add-to-list 'viper-vi-state-mode-list 'clojure-mode))

(eval-after-load "gist"
  '(add-to-list 'gist-supported-modes-alist '(clojure-mode . ".clj")))

(provide 'init-clojure)

(add-hook 'clojure-mode-hook 'enable-paredit-mode)

(setq clojure-src-root (expand-file-name "~/Projects/External"))
(setq swank-clojure-extra-vm-args (list "-server"
                                        "-Xmx1024m"
                                        "-XX:+UseConcMarkSweepGC"
                                        "-XX:+UseCompressedOops"
                                        "-XX:+DoEscapeAnalysis"))

(defun slime-clojure-repl-setup ()
  (when (string-equal "clojure" (slime-connection-name))
    (message "Setting up repl for clojure")
    (slime-redirect-inferior-output)
    (when (and (featurep 'paredit) paredit-mode (>= paredit-version 21))
      (define-key paredit-mode-map "{" 'paredit-open-curly)
      (define-key paredit-mode-map "}" 'paredit-close-curly))))

(add-hook 'slime-repl-mode-hook 'slime-clojure-repl-setup)

(eval-after-load "viper"
  '(add-to-list 'viper-vi-state-mode-list 'clojure-mode))

(eval-after-load "gist"
  '(add-to-list 'gist-supported-modes-alist '(clojure-mode . ".clj")))

(provide 'init-clojure)

Make { and } magic in slime repl when connection is to clojure


;; Time-stamp: <2015-02-23 11:42:33 kmodi>

;; wrap-region
;; https://github.com/rejeep/wrap-region.el

(use-package wrap-region
  :config
  (progn
    ;; Enable wrap-region in the following major modes
    (dolist (hook '(emacs-lisp-mode-hook
                    org-mode-hook))
      (add-hook hook 'wrap-region-mode))

    (wrap-region-add-wrapper "`" "'") ; select region, hit ` then region -> `region'

    (wrap-region-add-wrapper "=" "=" nil 'org-mode) ; select region, hit = then region -> =region= in org-mode
    (wrap-region-add-wrapper "*" "*" nil 'org-mode) ; select region, hit * then region -> *region* in org-mode
    (wrap-region-add-wrapper "/" "/" nil 'org-mode) ; select region, hit / then region -> /region/ in org-mode
    (wrap-region-add-wrapper "_" "_" nil 'org-mode) ; select region, hit _ then region -> _region_ in org-mode
    (wrap-region-add-wrapper "+" "+" nil 'org-mode))) ; select region, hit + then region -> +region+ in org-mode

(provide 'setup-wrap-region)

;; Time-stamp: <2015-07-08 14:12:24 kmodi>

;; wrap-region
;; https://github.com/rejeep/wrap-region.el

(use-package wrap-region
  :config
  (progn
    ;; Enable `wrap-region' in the following major modes
    (dolist (hook '(emacs-lisp-mode-hook
                    org-mode-hook
                    text-mode-hook
                    markdown-mode-hook))
      (add-hook hook #'wrap-region-mode))

    (wrap-region-add-wrapper "`" "'" nil 'emacs-lisp-mode)

    (wrap-region-add-wrapper "`" "`"   nil '(text-mode markdown-mode))
    (wrap-region-add-wrapper "**" "**" "*" '(text-mode markdown-mode))
    (wrap-region-add-wrapper "*" "*"   "/" '(text-mode markdown-mode))
    (wrap-region-add-wrapper "~~" "~~" "+" '(text-mode markdown-mode))

    (wrap-region-add-wrapper "=" "=" nil 'org-mode)
    (wrap-region-add-wrapper "*" "*" nil 'org-mode)
    (wrap-region-add-wrapper "/" "/" nil 'org-mode)
    (wrap-region-add-wrapper "_" "_" nil 'org-mode)
    (wrap-region-add-wrapper "+" "+" nil 'org-mode)))

(provide 'setup-wrap-region)

;; (wrap-region-add-wrapper "<CHAR1>" "<CHAR2>" KEY 'MODE), or
;; (wrap-region-add-wrapper "<CHAR1>" "<CHAR2>" KEY '(MODE1 MODE2))
;; - Select TEXT, hit KEY (or <CHAR1> if KEY is nil), then TEXT becomes
;;   <CHAR1>TEXT<CHAR2> in major mode MODE (or in major modes MODE1 and MODE2)

Add `wrap-region` wrappers for `markdown-mode`


; Avoid Emacs asking if to follow a symlink on startup
(setq vc-follow-symlinks t)
(org-babel-load-file "~/.emacs.d/config.org")

Enable following symlinks as early as possible

To prevent Emacs asking on startup

5c3cc950e wasn't enough. Presumably because the Org config is still a
symlink.


;;; to-do-mode -- major mode for editing in to-do format
;;;

(provide 'to-do-mode)

(defvar to-do-mode-hook nil
  "Hook run when to-do-mode is loaded."
  )

(define-derived-mode to-do-mode text-mode "To-Do"
  "Major mode for to-do files.
\\{to-do-mode-map}
Turning on To-Do mode runs the normal hook `to-do-mode-hook'."

  (setq-local indent-tabs-mode nil)
  (local-set-key "\C-C*" 'to-do-mark-item-done)
  )

;;; to-do-mark-item-done
(defun to-do-mark-item-done ()
  "Change the flag character to an asterisk." ; ought to go backward with C-U
  (interactive nil)
  (move-beginning-of-line 1)
  (cond ((looking-at ".*  o ")		; this doesn't handle partial items.  Should search.
	 (re-search-forward "  o ")
	 (delete-backward-char 2)
	 (insert "* "))
	((looking-at "[[:space:]]*$")
	 (insert "  *"))	; probably ought to handle indent.  tricky.
	)
  )

;;; to-do-mode -- major mode for editing in to-do format
;;;

(provide 'to-do-mode)

(defvar to-do-mode-hook nil
  "Hook run when to-do-mode is loaded."
  )

(define-derived-mode to-do-mode text-mode "To-Do"
  "Major mode for to-do files.
\\{to-do-mode-map}
Turning on To-Do mode runs the normal hook `to-do-mode-hook'."

  (setq-local indent-tabs-mode nil)
  (local-set-key "\C-C*" 'to-do-mark-item-done)
  )

;;; to-do-mark-item-done
(defun to-do-mark-item-done ()
  "Change an 'o' flag character to an asterisk.
Move to next line if no open items remain on the line." ; ought to go backward with C-U
  (interactive nil)
  (move-beginning-of-line 1)
  (cond ((looking-at ".*  o ")		; this doesn't handle partial items.  Should search.
	 (re-search-forward "  o ")
	 (delete-backward-char 2)
	 (insert "* "))
	((looking-at "[[:space:]]*$")
	 (insert "  *"))	; probably ought to handle indent.  tricky.
	)
  (or (looking-at ".*  o ") (next-line))
  )

Make ^C* go to next line if no open items


(use-package go-mode
  :ensure t

  :config
  (add-hook 'before-save-hook 'gofmt-before-save)
  (setq-default tab-width 2)
  )

(use-package company-go
  :ensure t

  :config
  (add-hook 'go-mode-hook (lambda ()
                            (set (make-local-variable 'company-backends) '(company-go))
                            (company-mode)))
  )

(provide 'pkg-go)

(use-package go-mode
  :ensure t

  :config
  (add-hook 'before-save-hook 'gofmt-before-save)
  (setq-default tab-width 2)
  (define-key evil-normal-state-map (kbd "M-.") 'godef-jump)
  )

(use-package company-go
  :ensure t

  :config
  (add-hook 'go-mode-hook (lambda ()
                            (set (make-local-variable 'company-backends) '(company-go))
                            (company-mode)))
  )

(provide 'pkg-go)

Add 'M-.' keymap for godef-jump in go-mode


(require 'evil)
(evil-mode 1)

;; Use undo-tree so don't have to figure out the full undo/redo system atm.
;; Evil will detect this.
(require 'undo-tree)

;; Remap ";" to ":" and "," to ";", like vimrc
(define-key evil-motion-state-map ";" 'evil-ex)
(define-key evil-motion-state-map "," 'evil-repeat-find-char)

;; Make <esc> cancel everything
(define-key evil-normal-state-map [escape] 'keyboard-quit)
(define-key evil-visual-state-map [escape] 'keyboard-quit)
(define-key minibuffer-local-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-ns-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-completion-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-must-match-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-isearch-map [escape] 'minibuffer-keyboard-quit)

;; Closest thing to easymotion
(require 'ace-jump-mode)
(define-key evil-normal-state-map (kbd "SPC") 'ace-jump-char-mode)

(require 'evil)
(evil-mode 1)

;; Use undo-tree so don't have to figure out the full undo/redo system atm.
;; Evil will detect this.
(require 'undo-tree)

;; Remap ";" to ":" and "," to ";", like vimrc
(define-key evil-motion-state-map ";" 'evil-ex)
(define-key evil-motion-state-map "," 'evil-repeat-find-char)

;; Make <esc> cancel everything
(define-key evil-normal-state-map [escape] 'keyboard-quit)
(define-key evil-visual-state-map [escape] 'keyboard-quit)
(define-key minibuffer-local-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-ns-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-completion-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-must-match-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-isearch-map [escape] 'minibuffer-keyboard-quit)

;; Closest thing to easymotion
(require 'ace-jump-mode)
(setq ace-jump-mode-scope 'window) ;; it's quicker this way
(define-key evil-normal-state-map (kbd "SPC") 'ace-jump-line-mode)

Tidy emacs jump mode setup

Tidy emacs jump mode setup


;;; prog-modes-config -- general setup for progamming modes
;;; Commentary:
;;;
;;; Code:
(defun bcj/prog-mode-hook ()
    "Custom configuration for programming modes."
    (fci-mode t)
    (require 'idle-highlight)
    (idle-highlight t)
    (linum-relative-on)
  )
(add-hook 'prog-mode-hook 'bcj/prog-mode-hook)

(provide 'prog-modes-config)
;;; prog-modes-config.el ends here

;;; prog-modes-config -- general setup for progamming modes
;;; Commentary:
;;;
;;; Code:

;; thanks to https://emacs.stackexchange.com/questions/21205/flycheck-with-file-relative-eslint-executable
(defun bcj/use-eslint-from-node-modules ()
  (let* ((root (locate-dominating-file
                (or (buffer-file-name) default-directory)
                "node_modules"))
         (eslint (and root
                      (expand-file-name "node_modules/eslint/bin/eslint.js"
                                        root))))
    (when (and eslint (file-executable-p eslint))
      (setq-local flycheck-javascript-eslint-executable eslint))))
(add-hook 'flycheck-mode-hook #'bcj/use-eslint-from-node-modules)

(defun bcj/prog-mode-hook ()
    "Custom configuration for programming modes."
    (fci-mode t)

    (use-package nlinum
      :init
      (global-nlinum-mode t))
    ;; (require 'idle-highlight)
    ;; (idle-highlight t)
    ;(linum-relative-on) ;;makes 400+ line files so laggy to scroll/move!!
  ) ;
(add-hook 'prog-mode-hook 'bcj/prog-mode-hook)

(provide 'prog-modes-config)
;;; prog-modes-config.el ends here

Use local eslint executable for flycheck, remove slow packages

Use the eslint executable that is present in the `node_modules/` of
the current project, so that the correct .eslintrc config file can be
found by eslint.


(when (maybe-require-package 'purescript-mode)
  (when (maybe-require-package 'psc-ide)
    (add-hook 'purescript-mode-hook
              (lambda ()
                (psc-ide-mode)
                (company-mode)
                (flycheck-mode)
                (turn-on-purescript-indentation)))))

(provide 'init-purescript)

(when (maybe-require-package 'purescript-mode)
  (when (maybe-require-package 'psc-ide)
    (add-hook 'purescript-mode-hook
              (lambda ()
                (psc-ide-mode)
                (company-mode)
                (flycheck-mode)
                (turn-on-purescript-indentation))))
  (when (maybe-require-package 'add-node-modules-path)
    (after-load 'purescript-mode
      (add-hook 'purescript-mode-hook 'add-node-modules-path))))

(provide 'init-purescript)

Use node_modules/.bin path for executables in purescript-mode


;; Time-stamp: <2015-07-17 12:57:27 kmodi>

;; Which Key
;; https://github.com/justbur/emacs-which-key

(use-package which-key
  :defer 15
  :config
  (progn
    (setq which-key-popup-type 'minibuffer) ; default
    ;; (setq which-key-popup-type 'side-window)

    (setq which-key-sort t) ; sort keys alphabetically

    (setq which-key-key-replacement-alist
          '(("<\\(\\(C-\\|M-\\)*.+\\)>" . "\\1")
            ("left"  . "◀")
            ("right" . "▶")
            ("up"    . "▲")
            ("down"  . "▼")))

    (setq which-key-special-keys '("SPC" "TAB" "RET" "ESC" "DEL"))

    (setq which-key-key-based-description-replacement-alist
          '(("C-x 8"   . "unicode")
            ("C-x a"   . "abbrev/expand")
            ("C-x r"   . "rect/reg")
            ("C-x w"   . "hi-lock-map")
            ("C-c /"   . "engine-mode-map")
            ("C-x 8 0" . "ZWS")))

    (which-key-mode 1)))

(provide 'setup-which-key)

;; Time-stamp: <2015-07-21 17:19:59 kmodi>

;; Which Key
;; https://github.com/justbur/emacs-which-key

(use-package which-key
  :defer 15
  :config
  (progn
    (setq which-key-popup-type 'minibuffer) ; default
    ;; (setq which-key-popup-type 'side-window)

    (setq which-key-sort t) ; sort keys alphabetically

    (setq which-key-key-replacement-alist
          '(("<\\(\\(C-\\|M-\\)*.+\\)>" . "\\1")
            ("left"  . "◀")
            ("right" . "▶")
            ("up"    . "▲")
            ("down"  . "▼")
            ("next"  . "PgDn")
            ("prior" . "PgUp")))

    (setq which-key-special-keys '("SPC" "TAB" "RET" "ESC" "DEL"))

    (setq which-key-key-based-description-replacement-alist
          '(("C-x 8"   . "unicode")
            ("C-x a"   . "abbrev/expand")
            ("C-x r"   . "rect/reg")
            ("C-x w"   . "hi-lock-map")
            ("C-c /"   . "engine-mode-map")
            ("C-c C-v" . "org-babel")
            ("C-x 8 0" . "ZWS")))

    ;; Paging
    (setq which-key-paging-prefixes '("C-x" "C-c"))
    (setq which-key-paging-key "<next>") ; Pg Down

    (which-key-mode 1)))

(provide 'setup-which-key)

Add paging config for which-key

Add paging config for which-key


(defvar mhc-process nil)

(add-to-list 'process-coding-system-alist '("^mhc$" . utf-8))

(defun mhc-process-send-command (command)
  (with-current-buffer (process-buffer mhc-process)
    (delete-region (point-min) (point-max))
    (process-send-string mhc-process (concat command "\n"))
    (let ((i 1))
      (while (not (and (> (point-max) 1)
                       (eq (char-after (1- (point-max))) ?\n)))
        (message (format "Waiting mhc process...%d" i))
        (setq i (1+ i))
        (accept-process-output mhc-process 0.5)))
      (read (buffer-substring (point-min) (1- (point-max))))))

(defun mhc-start-process ()
  (interactive)
  (let ((base-dir (mhc-summary-folder-to-path mhc-base-folder)))
    (if (and (processp mhc-process)
             (eq (process-status mhc-process) 'run))
        (kill-process mhc-process))
    (setq mhc-process (start-process
                       "mhc"
                       (get-buffer-create " *mhc-scan-process*")
                       "mhc"
                       "server"
                       (format "--repository=%s" base-dir)))
    (set-process-query-on-exit-flag mhc-process nil)
    mhc-process))

(provide 'mhc-process)

(defvar mhc-process nil)

(add-to-list 'process-coding-system-alist '("^mhc$" . utf-8))

(defun mhc-process-send-command (command)
  (with-current-buffer (process-buffer mhc-process)
    (delete-region (point-min) (point-max))
    (process-send-string mhc-process (concat command "\n"))
    (let ((i 1))
      (while (not (and (> (point-max) 1)
                       (eq (char-after (1- (point-max))) ?\n)))
        (message (format "Waiting mhc process...%d" i))
        (setq i (1+ i))
        (accept-process-output mhc-process 0.5)))
      (read (buffer-substring (point-min) (1- (point-max))))))

(defun mhc-start-process ()
  (interactive)
  (let ((base-dir (mhc-summary-folder-to-path mhc-base-folder))
        (process-connection-type nil)) ;; use PIPE not tty
    (if (and (processp mhc-process)
             (eq (process-status mhc-process) 'run))
        (kill-process mhc-process))
    (setq mhc-process (start-process
                       "mhc"
                       (get-buffer-create " *mhc-scan-process*")
                       "mhc"
                       "server"
                       (format "--repository=%s" base-dir)))
    (set-process-query-on-exit-flag mhc-process nil)
    mhc-process))

(provide 'mhc-process)

Use pipe not tty for communicating with mhc process


;;; packages.el --- spotify Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2017 Sylvain Benner & Contributors
;;
;; Author: Brian Hicks <brian@brianthicks.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

(setq spotify-packages
      '(
        spotify
        (helm-spotify :toggle (configuration-layer/package-usedp 'helm))
        ))

(defun spotify/init-spotify ()
  (use-package spotify
    :defer t
    :init
    (progn
      (spacemacs/declare-prefix "am" "music")
      (spacemacs/declare-prefix "ams" "Spotify")
      (spacemacs/set-leader-keys
        "amsp" 'spotify-playpause
        "amsn" 'spotify-next
        "amsN" 'spotify-previous
        "amsQ" 'spotify-quit))))

(defun spotify/init-helm-spotify ()
  (use-package helm-spotify
    :defer t
    :init (spacemacs/set-leader-keys "amsg" 'helm-spotify)))

;;; packages.el --- spotify Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2017 Sylvain Benner & Contributors
;;
;; Author: Brian Hicks <brian@brianthicks.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

(setq spotify-packages
      '(
        spotify
        (helm-spotify-plus :toggle (configuration-layer/package-usedp 'helm))
        ))

(defun spotify/init-spotify ()
  (use-package spotify
    :defer t
    :init
    (progn
      (spacemacs/declare-prefix "am" "music")
      (spacemacs/declare-prefix "ams" "Spotify")
      (spacemacs/set-leader-keys
        "amsp" 'spotify-playpause
        "amsn" 'spotify-next
        "amsN" 'spotify-previous
        "amsQ" 'spotify-quit))))

(defun spotify/init-helm-spotify-plus ()
  (use-package helm-spotify-plus
    :defer t
    :init (spacemacs/set-leader-keys "amsg" 'helm-spotify-plus)))

Use helm-spotify-plus instead of helm-spotify

helm-spotify doesn't work anymore due to changes to the spotify web API


;;; editor/lispy/config.el -*- lexical-binding: t; -*-

(use-package! lispy
  :hook ((lisp-mode . lispy-mode)
         (emacs-lisp-mode . lispy-mode)
         (scheme-mode . lispy-mode)
         (racket-mode . lispy-mode)
         (hy-mode . lispy-mode)
         (lfe-mode . lispy-mode)
         (dune-mode . lispy-mode)
         (clojure-mode . lispy-mode))
  :config
  (setq lispy-close-quotes-at-end-p t)
  (add-hook 'lispy-mode-hook #'turn-off-smartparens-mode))

(use-package! lispyville
  :when (featurep! :editor evil)
  :hook (lispy-mode . lispyville-mode)
  :init
  (setq lispyville-key-theme
        '((operators normal)
          c-w
          (prettify insert)
          (atom-movement t)
          slurp/barf-lispy
          additional
          additional-insert))
  :config
  (lispyville-set-key-theme))

;;; editor/lispy/config.el -*- lexical-binding: t; -*-

(use-package! lispy
  :hook ((lisp-mode . lispy-mode)
         (emacs-lisp-mode . lispy-mode)
         (ielm-mode . lispy-mode)
         (scheme-mode . lispy-mode)
         (racket-mode . lispy-mode)
         (hy-mode . lispy-mode)
         (lfe-mode . lispy-mode)
         (dune-mode . lispy-mode)
         (clojure-mode . lispy-mode))
  :config
  (setq lispy-close-quotes-at-end-p t)
  (add-hook 'lispy-mode-hook #'turn-off-smartparens-mode))

(use-package! lispyville
  :when (featurep! :editor evil)
  :hook (lispy-mode . lispyville-mode)
  :init
  (setq lispyville-key-theme
        '((operators normal)
          c-w
          (prettify insert)
          (atom-movement t)
          slurp/barf-lispy
          additional
          additional-insert))
  :config
  (lispyville-set-key-theme))

Add ielm-mode to lipsy module hooks

Add ielm-mode to lipsy module hooks


(add-hook 'clojure-mode-hook 'pretty-lambdas)
(add-hook 'clojure-mode-hook (lambda () (enable-paredit clojure-mode-map)))

(setq clojure-src-root (expand-file-name "~/Projects/External"))

(setq swank-clojure-jar-path (concat clojure-src-root "/clojure/clojure.jar")
      swank-clojure-extra-classpaths (list (concat clojure-src-root "/clojure-contrib/clojure-contrib.jar")))

(require 'swank-clojure-autoload)

(defun slime-clojure ()
  "Fire up slime running the swank-clojure backend"
  (interactive)
  (slime 'clojure))

(provide 'init-clojure)

(add-hook 'clojure-mode-hook 'pretty-lambdas)
(add-hook 'clojure-mode-hook (lambda () (enable-paredit clojure-mode-map)))

(setq clojure-src-root (expand-file-name "~/Projects/External"))

(setq swank-clojure-jar-path (concat clojure-src-root "/clojure/clojure.jar")
      swank-clojure-extra-classpaths (list (concat clojure-src-root "/clojure-contrib/clojure-contrib.jar")))

(require 'swank-clojure-autoload)

(eval-after-load "slime"
  '(progn
     ;; Ensure we get a REPL
     (slime-setup '(slime-repl))))

(defun slime-clojure ()
  "Fire up slime running the swank-clojure backend"
  (interactive)
  (slime 'clojure))

(provide 'init-clojure)

Enable Slime's REPL feature for clojure, now that that isn't the default behaviour


;;; projectile-conf.el -- Settings for projectile.
(eval-when-compile
  (require 'projectile))

(custom-set-variables
 '(projectile-switch-project-action 'projectile-dired)
 '(projectile-mode-line
   '(:eval (format " [%s]" (projectile-project-name)))))

(add-to-list 'projectile-globally-ignored-modes "mu4e-.*-mode")
(add-to-list 'projectile-globally-ignored-modes "org-agenda-mode")

(add-to-list 'projectile-project-root-files "GNUmakefile")
(add-to-list 'projectile-project-root-files "Rakefile")
(add-to-list 'projectile-project-root-files "package.json")
(add-to-list 'projectile-project-root-files-bottom-up ".dir-locals.el")

(projectile-register-project-type
 'edify '("default.nix" "courses" "content")
 :compile "nix-shell --run 'edify build courses/*'")

(projectile-register-project-type
 'haskell '("default.nix" "Setup.hs")
 :compile "nix-hs")

;;; projectile-conf.el -- Settings for projectile.
(eval-when-compile
  (require 'projectile))

(custom-set-variables
 '(projectile-switch-project-action 'projectile-dired)
 '(projectile-mode-line
   '(:eval (format " [%s]" (projectile-project-name)))))

(add-to-list 'projectile-globally-ignored-modes "mu4e-.*-mode")
(add-to-list 'projectile-globally-ignored-modes "org-agenda-mode")

(add-to-list 'projectile-project-root-files "GNUmakefile")
(add-to-list 'projectile-project-root-files "Rakefile")
(add-to-list 'projectile-project-root-files "package.json")
(add-to-list 'projectile-project-root-files-bottom-up ".dir-locals.el")

(projectile-register-project-type
 'edify '("default.nix" "courses" "content")
 :compile "nix-shell --run 'eval \"$buildPhase\"'")

(projectile-register-project-type
 'haskell '("default.nix" "Setup.hs")
 :compile "nix-hs")

projectile: Update the edify rule to use $buildPhase


;;;; Configuration for Ruby
;;;; https://github.com/zenspider/enhanced-ruby-mode

(use-package enh-ruby-mode
  :ensure t
  :defer t
  :mode ("\\.rb$" . enh-ruby-mode)
  :interpreter ("ruby" . enh-ruby-mode))

(provide 'init-ruby)

;;;; Configuration for Ruby
;;;; https://github.com/zenspider/enhanced-ruby-mode

(use-package enh-ruby-mode
  :ensure t
  :defer t
  :mode ("\\.rb'" . enh-ruby-mode)
  :interpreter ("ruby" . enh-ruby-mode))

(provide 'init-ruby)

Use smarter syntax for ruby files

Use smarter syntax for ruby files


(require 'flycheck)
(add-hook 'flycheck-mode-hook #'flycheck-rust-setup)

(provide 'rust-customisations)

(require 'flycheck)
(add-hook 'flycheck-mode-hook #'flycheck-rust-setup)

(add-hook 'rust-mode-hook #'flycheck-mode)

(provide 'rust-customisations)

Use flycheck for all rust buffers.

Use flycheck for all rust buffers.


;;; Handy code for uploading new versions of my own packages to marmalade

(autoload 'marmalade-upload-buffer "marmalade")

(defun latest-git-tag ()
  (replace-regexp-in-string
   "[ \t\n]*$"
   ""
   (shell-command-to-string "git tag|sort -n|tail -1"))) ;; TODO: sort versions properly

(defun update-version-header (val)
  (save-excursion
    (beginning-of-buffer)
    (re-search-forward "^;;;? ?Version:")
    (kill-line)
    (insert " " val)))

(defun submit-to-marmalade (buf)
  (interactive "bSubmit buffer: ")
  (with-current-buffer buf
    (let ((tag (latest-git-tag)))
      (unless tag
        (error "Not tagged"))
      (update-version-header tag)
      (marmalade-upload-buffer buf))))

(provide 'init-marmalade)

;;; Handy code for uploading new versions of my own packages to marmalade

(autoload 'marmalade-upload-buffer "marmalade")

(defun latest-git-tag ()
  (replace-regexp-in-string
   "[ \t\n]*$"
   ""
   (shell-command-to-string "git tag|sort -n|tail -1"))) ;; TODO: sort versions properly

(defun update-version-header (val)
  (save-excursion
    (beginning-of-buffer)
    (re-search-forward "^;;;? ?Version:")
    (kill-line)
    (insert " " val)))

(defun submit-to-marmalade (buf)
  (interactive "bSubmit buffer: ")
  (with-current-buffer buf
    (let ((tag (latest-git-tag)))
      (unless tag
        (error "Not tagged"))
      (update-version-header tag)
      (marmalade-upload-buffer buf)
      (revert-buffer t t)
      (message "Submitted version %s to marmalade" tag))))

(provide 'init-marmalade)

Revert source buffer after submitting to maramalade


(provide 'init-local)

;; rails reloaded plugin
(push "~/.emacs.d/site-lisp/rails-reloaded" load-path)
(require 'rails-autoload)

;; rails reloaded plugin
(push "~/.emacs.d/site-lisp/rails-reloaded" load-path)
(require 'rails-autoload)

;; Standard ML https://class.coursera.org/proglang-003/wiki/view?page=smlEmacsInstall
(setenv "PATH" (concat "/home/david1/workspace/sml/bin:" (getenv "PATH")))
(setq exec-path (cons "/home/david1/workspace/sml/bin"  exec-path))

(require-package 'sml-mode)
(require 'sml-mode)

(provide 'init-local)

Add support for Standard ML

Add support for Standard ML

including path to a local binary


;;; emacs/electric/autoload.el -*- lexical-binding: t; -*-

;;;###autodef
(defun set-electric! (modes &rest plist)
  "Declare :words (list of strings) or :chars (lists of chars) in MODES that
trigger electric indentation."
  (declare (indent 1))
  (unless plist
    (signal 'wrong-number-of-arguments
            (list '(:char :words) plist)))
  (cl-destructuring-bind (&key chars words) plist
    (dolist (mode (doom-enlist modes))
      (let ((fn (intern (format "+electric|init-%s" mode))))
        (fset fn
              (lambda ()
                (electric-indent-local-mode +1)
                (if chars (setq electric-indent-chars chars))
                (if words (setq +electric-indent-words words))))
        (add-hook (intern (format "%s-hook" mode)) fn)))))

;; FIXME obsolete :electric
;;;###autoload
(def-setting! :electric (modes &rest plist)
  :obsolete set-electric!
  `(set-electric! ,modes ,@plist))

;;; emacs/electric/autoload.el -*- lexical-binding: t; -*-

;;;###autodef
(defun set-electric! (modes &rest plist)
  "Declare :words (list of strings) or :chars (lists of chars) in MODES that
trigger electric indentation."
  (declare (indent 1))
  (dolist (mode (doom-enlist modes))
    (let ((hook (intern (format "%s-hook" mode)))
          (fn   (intern (format "+electric|init-%s" mode))))
      (cond ((null (car-safe plist))
             (remove-hook hook fn)
             (unintern fn nil))
            ((fset fn
                   (lambda ()
                     (cl-destructuring-bind (&key chars words) plist
                       (electric-indent-local-mode +1)
                       (if chars (setq electric-indent-chars chars))
                       (if words (setq +electric-indent-words words)))))
             (add-hook hook fn))))))

;; FIXME obsolete :electric
;;;###autoload
(def-setting! :electric (modes &rest plist)
  :obsolete set-electric!
  `(set-electric! ,modes ,@plist))

Add unset capability to set-electric!

Add unset capability to set-electric!


;;; luhn.el --- luhn (exercism)

;;; Commentary:

;;; Code:

(require 'cl-lib)

(defun luhn-p (dastring)
  "Check if an input string DASTRING is valid using lhun algorithm."
  (let ((str (replace-regexp-in-string " " "" dastring)))
    (if (string-match-p "[^0-9 ]" str)
	(error "String contains invalid character")
      (if (<= (length str) 1)
	  nil
	(let* ((digit-list (reverse (mapcar (lambda (x) (- x 48))
				            (string-to-list (replace-regexp-in-string " " "" str)))))
	       (digit-list-with-index (cl-pairlis (number-sequence 0 (- (length digit-list) 1)) digit-list)))

	    (zerop (mod (apply #'+ (mapcar (lambda (x) (if (equal 1 (mod (car x) 2))
					    (if (> (* 2 (cdr x)) 9)
						(- (* 2 (cdr x)) 9)
					      (* 2 (cdr x)))
					    (cdr x)))
					   digit-list-with-index))
			10))))))))

(provide 'luhn)
;;; luhn.el ends here

;;; luhn.el --- luhn (exercism)

;;; Commentary:

;;; Code:

(require 'cl-lib)

(defun luhn-p (dastring)
  "Check if an input string DASTRING is valid using lhun algorithm."
  (let ((str (replace-regexp-in-string " " "" dastring)))
    (if (string-match-p "[^0-9 ]" str)
	(error "String contains invalid character")
      (if (<= (length str) 1)
	  nil
	(let* ((digit-list (reverse (mapcar (lambda (x) (- x 48))
				            (string-to-list str))))
	       (digit-list-with-index (cl-pairlis (number-sequence 0 (- (length digit-list) 1)) digit-list)))

	    (zerop (mod (apply #'+ (mapcar (lambda (x) (if (equal 1 (mod (car x) 2))
					    (if (> (* 2 (cdr x)) 9)
						(- (* 2 (cdr x)) 9)
					      (* 2 (cdr x)))
					    (cdr x)))
					   digit-list-with-index))
			10))))))))

(provide 'luhn)
;;; luhn.el ends here

Remove duplicated call to replace-regexp-in-string


(setq inhibit-startup-screen t)
(setq make-backup-files nil)
(setq highlight-nonselected-windows t)
(setq browse-url-browser-function 'browse-url-generic
      browse-url-generic-program "firefox")
(setq bookmark-save-flag 1) ; save bookmarks after every modifications

(setq save-place-file "~/.emacs.d/saveplace")
(setq-default save-place t)
(require 'saveplace)

(setq load-prefer-newer t)

(add-hook 'text-mode-hook 'flyspell-mode)
(add-hook 'prog-mode-hook 'hs-minor-mode)

(global-linum-mode)
(line-number-mode)
(column-number-mode)
(size-indication-mode)

;; speedbar ;; replaced by sr-speedbar
;; (when (window-system)
;;   (speedbar t)
;;   (add-hook 'speedbar-mode-hook
;; 	    '(lambda ()
;; 	       (interactive)
;; 	       (other-frame 0))))

;; (add-hook 'after-change-major-mode-hook 'hl-line-mode) ; hl-line-mode is a buffer-local minor mode

;;(global-set-key '[f9] 'shell)
(global-set-key '[f11] 'flyspell-mode)
(global-set-key '[f12] 'compile)

(setq inhibit-startup-screen t)
(setq make-backup-files nil)
(setq highlight-nonselected-windows t)
(setq browse-url-browser-function 'browse-url-generic
      browse-url-generic-program "firefox")
(setq bookmark-save-flag 1) ; save bookmarks after every modifications

(setq save-place-file "~/.emacs.d/saveplace")
(setq-default save-place t)
(require 'saveplace)

(setq load-prefer-newer t)

(add-hook 'text-mode-hook 'flyspell-mode)
(add-hook 'prog-mode-hook 'hs-minor-mode)

(global-linum-mode)
(line-number-mode)
(column-number-mode)
(size-indication-mode)

(tool-bar-mode -1)

;; speedbar ;; replaced by sr-speedbar
;; (when (window-system)
;;   (speedbar t)
;;   (add-hook 'speedbar-mode-hook
;; 	    '(lambda ()
;; 	       (interactive)
;; 	       (other-frame 0))))

;; (add-hook 'after-change-major-mode-hook 'hl-line-mode) ; hl-line-mode is a buffer-local minor mode

;;(global-set-key '[f9] 'shell)
(global-set-key '[f11] 'flyspell-mode)
(global-set-key '[f12] 'compile)

Disable tool-bar-mode on startup to save screen space.


;;; ido-use.el --- Intelligent auto-completion (builtin package)

(use-package ido
  :init
  (setq ido-enable-flex-matching t
        ido-everywhere t)

  :config
  (ido-mode 1)
  (ido-everywhere 1)

  (setq ido-create-new-buffer 'always))  ; Let ido make new files

(use-package smex
  :config
  (smex-initialize)

  (global-set-key (kbd "M-x") 'smex)
  (global-set-key (kbd "M-X") 'smex-major-mode-commands)
  (global-set-key (kbd "C-c C-c M-x") 'execute-extended-command))

(use-package ido-ubiquitous
  :config
  (ido-ubiquitous-mode 1))

(provide 'ido-use)

;;; ido-use.el ends here

;;; ido-use.el --- Intelligent auto-completion (builtin package)

(use-package ido
  :init
  (setq ido-enable-flex-matching t
        ido-everywhere t)

  :config
  (ido-mode 1)
  (ido-everywhere 1)

  (setq ido-create-new-buffer 'always))  ; Let ido make new files

(use-package smex
  :config
  (smex-initialize)

  (global-set-key (kbd "M-x") 'smex)
  (global-set-key (kbd "M-X") 'smex-major-mode-commands)
  (global-set-key (kbd "C-c C-c M-x") 'execute-extended-command))

(use-package ido-ubiquitous
  :config
  (ido-ubiquitous-mode 1))

(use-package recentf
  :config
  (recentf-mode 1)

  (defun ido-use/recentf-ido-find-file ()
    "Open list of most recently used files with ido."
    (interactive)
    (let ((file (ido-completing-read "Recent file: " recentf-list nil t)))
      (when file
        (find-file file))))

  (global-set-key (kbd "C-x C-r") 'ido-use/recentf-ido-find-file)

  (setq recentf-max-saved-items 50))

(provide 'ido-use)

;;; ido-use.el ends here

Add ability to open recently used files with ido


(defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")

;; transpose lines
(define-key my-keys-minor-mode-map (kbd "C-q") 'transpose-lines)

;; compare with previous version
(define-key my-keys-minor-mode-map (kbd "M-P") 'vc-version-ediff)

;; transpose frame
(require 'transpose-frame)
(define-key my-keys-minor-mode-map (kbd "C-t") 'flop-frame)

(define-key my-keys-minor-mode-map (kbd "M-k") 'kill-this-buffer)

;; pretty replace using anzu
(require 'anzu)
(global-anzu-mode)
(global-set-key (kbd "M-%") 'anzu-query-replace)
(global-set-key (kbd "C-M-%") 'anzu-query-replace-regexp)

;; -----------------
(define-minor-mode my-keys-minor-mode
  "A minor mode so that my key settings override annoying major modes."
  t " my-keys" 'my-keys-minor-mode-map)

(my-keys-minor-mode 1)

(defun my-minibuffer-setup-hook ()
  (my-keys-minor-mode 0))

(add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
;; -----------------

(provide 'init-keys)

(defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")

;; transpose lines
(define-key my-keys-minor-mode-map (kbd "C-q") 'transpose-lines)

;; compare with previous version
(define-key my-keys-minor-mode-map (kbd "M-P") 'vc-version-ediff)

;; transpose frame
(require 'transpose-frame)
(define-key my-keys-minor-mode-map (kbd "C-t") 'flop-frame)

(define-key my-keys-minor-mode-map (kbd "M-k") 'kill-this-buffer)

;; -----------------
(define-minor-mode my-keys-minor-mode
  "A minor mode so that my key settings override annoying major modes."
  t " my-keys" 'my-keys-minor-mode-map)

(my-keys-minor-mode 1)

(defun my-minibuffer-setup-hook ()
  (my-keys-minor-mode 0))

(add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
;; -----------------

(provide 'init-keys)

[*] Move anzu shortcut to his right init file


;; Raise the GC threshold massively.
(setq gc-cons-threshold 20000000)

;; Enable spell checking in code and IRC.
(add-hook 'text-mode-hook 'flyspell-mode)
(add-hook 'prog-mode-hook 'flyspell-prog-mode)
(erc-spelling-mode 1)

;; Enable flycheck everywhere.
(global-flycheck-mode)

;; Display all whitespace.
(require 'whitespace)
(setq whitespace-style '(face
                         tabs
                         tab-mark
                         trailing))
(global-whitespace-mode)

;; Indentation for HTML should be four spaces.
(setq sgml-basic-offset 4)

Set HTML indentation to four spaces.

Set HTML indentation to four spaces.


(use-package pyenv-mode
  :init
  :ensure t
  :config (pyenv-mode)

  (setenv "WORKON_HOME" "~/.pyenv/versions/")
  (add-to-list 'exec-path "~/.pyenv/shims")
  (add-hook 'projectile-switch-project-hook 'projectile-pyenv-mode-set)
  (add-hook 'python-mode-hook 'pyenv-mode))

(use-package pyenv-mode-auto
  :ensure t)

(use-package elpy
  :ensure t
  :defer t
  :init
  (advice-add 'python-mode :before 'elpy-enable))

(use-package pyenv-mode
  :init
  :ensure t
  :config (pyenv-mode)

  (setenv "WORKON_HOME" "~/.pyenv/versions/")
  (add-to-list 'exec-path "~/.pyenv/shims")
  (add-hook 'projectile-switch-project-hook 'projectile-pyenv-mode-set)
  (add-hook 'python-mode-hook 'pyenv-mode))

(use-package pyenv-mode-auto
  :ensure t)

(use-package elpy
  :ensure t
  :defer t
  :config
  (setq elpy-modules (delete 'elpy-module-highlight-indentation elpy-modules))
  :init
  (advice-add 'python-mode :before 'elpy-enable))

Emacs: Disable highligh-indentation minor-mode on elpy


;;; crypto-square.el --- Crypto Square (exercism)

;;; Commentary:

;;; Code:

(defun normalize-text (string)
  (replace-regexp-in-string "[^a-z0-9]" "" (downcase string)))

(defun find-rectangle-size (string)
  (ceiling (sqrt (length string))))

(defun chop-string (string columns)
  (with-temp-buffer
    (insert string)
    (goto-char (point-min))
    (while (not (eobp))
      (ignore-errors (forward-char columns))
      (insert "\n"))
    (split-string (buffer-string) "\n" t)))

(defun strings-column (strings column)
  (mapconcat (lambda (string)
               (if (< column (length string))
                      (char-to-string (aref string column))
                      " "))
             strings ""))

(defun transpose-strings (strings columns)
  (mapcar (lambda (col) (strings-column strings col))
          (number-sequence 0 (1- columns))))

(defun encipher (plaintext)
  (let* ((text (normalize-text plaintext))
         (columns (find-rectangle-size text))
         (strings (chop-string text columns))
         (transposed (transpose-strings strings columns)))
    (mapconcat 'identity transposed " ")))

(provide 'crypto-square)
;;; crypto-square.el ends here

Add code commentary to exemplary solution


;; Keyboard bindings

;;;###autoload
(progn
  ;; Font size
  (define-key global-map (kbd "C-+") 'text-scale-increase)
  (define-key global-map (kbd "C--") 'text-scale-decrease)

  ;; Use regex searches by default.
  (global-set-key (kbd "C-s") 'isearch-forward-regexp)
  (global-set-key (kbd "\C-r") 'isearch-backward-regexp)
  (global-set-key (kbd "C-M-s") 'isearch-forward)
  (global-set-key (kbd "C-M-r") 'isearch-backward)

  ;; M-S-6 is awkward
  (global-set-key (kbd "C-c q") 'join-line)

  ;; Help should search more than just commands
  (global-set-key (kbd "C-h a") 'apropos)

  (global-set-key (kbd "C-t") 'textmate-goto-file)

  (global-set-key (kbd "C-x m") 'magit-status)
  (global-set-key (kbd "M-s")   'fixup-whitespace)
)

;; Open tabs in Aquamacs
(if (featurep 'aquamacs)
    (global-set-key (kbd "A-T") 'new-tab))

(provide 'custom-keys)

;; Keyboard bindings

;;;###autoload
(progn
  ;; Font size
  (define-key global-map (kbd "C-+") 'text-scale-increase)
  (define-key global-map (kbd "C--") 'text-scale-decrease)

  ;; Use regex searches by default.
  (global-set-key (kbd "C-s") 'isearch-forward-regexp)
  (global-set-key (kbd "\C-r") 'isearch-backward-regexp)
  (global-set-key (kbd "C-M-s") 'isearch-forward)
  (global-set-key (kbd "C-M-r") 'isearch-backward)

  ;; M-S-6 is awkward
  (global-set-key (kbd "C-c q") 'join-line)
  (global-set-key (kbd "M-j")
            (lambda ()
                  (interactive)
                  (join-line -1)))

  ;; Help should search more than just commands
  (global-set-key (kbd "C-h a") 'apropos)

  (global-set-key (kbd "C-t") 'textmate-goto-file)

  (global-set-key (kbd "C-x m") 'magit-status)
  (global-set-key (kbd "M-s")   'fixup-whitespace)
)

;; Open tabs in Aquamacs
(if (featurep 'aquamacs)
    (global-set-key (kbd "A-T") 'new-tab))

(provide 'custom-keys)

Add additional key binding for join-line


(defun pjs-add-eval-buffer-binding ()
  (local-set-key (kbd "C-c C-k") 'eval-buffer))

(provide 'pjs-emacs-lisp)

(defun pjs-add-eval-buffer-binding ()
  (local-set-key (kbd "C-c C-k") 'eval-buffer)
  (setq fill-column 80))

(provide 'pjs-emacs-lisp)

Use fill-column 80 for emacs lisp.

Use fill-column 80 for emacs lisp.


((js2-mode . ((indent-tabs-mode . nil)
              (js2-basic-offset . 2)
              (show-trailing-whitespace . t))))

((js-mode . ((indent-tabs-mode . nil)
             (js-indent-level . 2)
             (show-trailing-whitespace . t))))

Use js-mode instead of js2-mode

Use js-mode instead of js2-mode


;; My keybindings for paredit

(require 'paredit)

(defun paredit-wrap-round-from-behind ()
  (interactive)
  (forward-sexp -1)
  (paredit-wrap-round)
  (insert " ")
  (forward-char -1))

(defun setup-paredit-for-mode-map (mode-map)
  (define-key mode-map (kbd "s-<up>") 'paredit-raise-sexp)
  (define-key mode-map (kbd "s-<right>") 'paredit-forward-slurp-sexp)
  (define-key mode-map (kbd "s-8") 'paredit-wrap-round)
  (define-key mode-map (kbd "s-9") 'paredit-wrap-round-from-behind)
  (define-key mode-map (kbd "s-<backspace>") 'paredit-splice-sexp-killing-backward)
  (define-key mode-map (kbd "s-t") 'transpose-sexps))

(eval-after-load "lisp-mode" '(setup-paredit-for-mode-map emacs-lisp-mode-map))
(eval-after-load "clojure-mode" '(setup-paredit-for-mode-map clojure-mode-map))

(provide 'setup-paredit)

;; My keybindings for paredit

(require 'paredit)

(defun paredit-wrap-round-from-behind ()
  (interactive)
  (forward-sexp -1)
  (paredit-wrap-round)
  (insert " ")
  (forward-char -1))

(defun setup-paredit-for-mode-map (mode-map)
  (define-key mode-map (kbd "s-<up>") 'paredit-raise-sexp)
  (define-key mode-map (kbd "s-<right>") 'paredit-forward-slurp-sexp)
  (define-key mode-map (kbd "s-<left>") 'paredit-forward-barf-sexp)
  (define-key mode-map (kbd "s-8") 'paredit-wrap-round)
  (define-key mode-map (kbd "s-9") 'paredit-wrap-round-from-behind)
  (define-key mode-map (kbd "s-<backspace>") 'paredit-splice-sexp-killing-backward)
  (define-key mode-map (kbd "s-t") 'transpose-sexps))

(eval-after-load "lisp-mode" '(setup-paredit-for-mode-map emacs-lisp-mode-map))
(eval-after-load "clojure-mode" '(setup-paredit-for-mode-map clojure-mode-map))

(provide 'setup-paredit)

Add paredit-forward-barf-sexp to handy paredit commands.


;;; config.el --- common-lisp Layer Configuration File for Spacemacs
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

(spacemacs|define-jump-handlers lisp-mode slime-inspect-definition)
(spacemacs|define-jump-handlers common-lisp-mode)

Define jump handlers for common-lisp-mode


;; See www.emacswiki.org/emacs/RevertBuffer for more details.
;; revert-buffer without any confirmation
(defun reload-buffer ()
  "Revert buffer without confirmation."
  (interactive)
  (revert-buffer t t)
  )

;; Revert buffers when files are changed
(global-auto-revert-mode)

(setq inhibit-startup-message t)

(column-number-mode t)

;; for auto newline
(setq fill-column 80)

;; delete whitespaces of the end of each line before save.
;; (add-hook 'before-save-hook 'delete-trailing-whitespace)

;; See www.emacswiki.org/emacs/RevertBuffer for more details.
;; revert-buffer without any confirmation
(defun reload-buffer ()
  "Revert buffer without confirmation."
  (interactive)
  (revert-buffer t t)
  )

;; Revert buffers when files are changed
(global-auto-revert-mode)

(setq inhibit-startup-message t)

(column-number-mode t)

;; for auto newline
(setq fill-column 80)

(setq-default indent-tabs-mode nil)
;; delete whitespaces of the end of each line before save.
;; (add-hook 'before-save-hook 'delete-trailing-whitespace)

Use spaces instead of tabs for default modes.


;; don't show the startup help screen
(setq inhibit-startup-screen t)

;; mode line settings
(column-number-mode t)
(line-number-mode t)
(size-indication-mode t)

;; remove clutter from the UI
(menu-bar-mode -1)
(tool-bar-mode -1)
(tooltip-mode -1)
(scroll-bar-mode -1)

;; blinking cursor
(blink-cursor-mode t)

;; enable mouse gestures in terminal
(require 'mouse)
(xterm-mouse-mode t)

;; disable alarm bell beep
(setq ring-bell-function 'ignore)

;; use Monaco font in Mac OS X
(when (eq system-type 'darwin)
  (set-default-font "Monaco"))

;; my (current) theme of choice
(load-theme 'tomorrow-night t)

;; powerline
(setq ns-use-srgb-colorspace nil)
(powerline-default-theme)

;; emacs-plus natural bar for better looks in OS X
(add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))
(add-to-list 'default-frame-alist '(ns-appearance . dark))

;; don't show the startup help screen
(setq inhibit-startup-screen t)

;; mode line settings
(column-number-mode t)
(line-number-mode t)
(size-indication-mode t)

;; remove clutter from the UI
(menu-bar-mode -1)
(tool-bar-mode -1)
(tooltip-mode -1)
(scroll-bar-mode -1)

;; blinking cursor
(blink-cursor-mode t)

;; enable mouse gestures in terminal
(require 'mouse)
(xterm-mouse-mode t)

;; disable alarm bell beep
(setq ring-bell-function 'ignore)

;; use Monaco font in Mac OS X
(when (eq system-type 'darwin)
  (set-default-font "Monaco"))

;; my (current) theme of choice
(load-theme 'material t)

;; powerline
(setq ns-use-srgb-colorspace nil)
(powerline-default-theme)

;; emacs-plus natural bar for better looks in OS X
(add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))
(add-to-list 'default-frame-alist '(ns-appearance . dark))

Use to a more terminal friendly theme

Use to a more terminal friendly theme


;;; Character sets

(defcustom sanityinc/force-default-font-for-symbols nil
  "When non-nil, force Emacs to use your default font for symbols."
  :type 'boolean)

(defun sanityinc/maybe-use-default-font-for-symbols ()
  "Force Emacs to render symbols using the default font, if so configured."
  (when sanityinc/force-default-font-for-symbols
    (set-fontset-font "fontset-default" 'symbol (face-attribute 'default :family))))

(add-hook 'after-init-hook 'sanityinc/maybe-use-default-font-for-symbols)

;;; Changing font sizes

(require-package 'default-text-scale)
(global-set-key (kbd "C-M-=") 'default-text-scale-increase)
(global-set-key (kbd "C-M--") 'default-text-scale-decrease)

(provide 'init-fonts)

;;; Character sets

(defcustom sanityinc/force-default-font-for-symbols nil
  "When non-nil, force Emacs to use your default font for symbols."
  :type 'boolean)

(defun sanityinc/maybe-use-default-font-for-symbols ()
  "Force Emacs to render symbols using the default font, if so configured."
  (when sanityinc/force-default-font-for-symbols
    (set-fontset-font "fontset-default" 'symbol (face-attribute 'default :family))))

(add-hook 'after-init-hook 'sanityinc/maybe-use-default-font-for-symbols)

;; set a default font
;; Download font from here: https://github.com/powerline/fonts
(when (member "Inconsolata-dz for Powerline" (font-family-list))
  (set-face-attribute 'default nil :font "Inconsolata-dz for Powerline"))

;;; Changing font sizes

(require-package 'default-text-scale)
(global-set-key (kbd "C-M-=") 'default-text-scale-increase)
(global-set-key (kbd "C-M--") 'default-text-scale-decrease)

(provide 'init-fonts)

Change font to Inconsolata-dz for Powerline


(require-package 'flymake-cursor)

(setq flymake-gui-warnings-enabled nil)

;; Stop flymake from breaking when ruby-mode is invoked by mmm-mode,
;; at which point buffer-file-name is nil
(eval-after-load 'flymake
  '(progn
     (global-set-key (kbd "C-`") 'flymake-goto-next-error)

     (defun flymake-can-syntax-check-file (file-name)
       "Determine whether we can syntax check FILE-NAME.
Return nil if we cannot, non-nil if we can."
       (if (and file-name (flymake-get-init-function file-name)) t nil))))

(provide 'init-flymake)

(require-package 'flymake-cursor)

(setq flymake-gui-warnings-enabled nil)

;; Stop flymake from breaking when ruby-mode is invoked by mmm-mode,
;; at which point buffer-file-name is nil
(eval-after-load 'flymake
  '(progn
     (defun flymake-can-syntax-check-file (file-name)
       "Determine whether we can syntax check FILE-NAME.
Return nil if we cannot, non-nil if we can."
       (if (and file-name (flymake-get-init-function file-name)) t nil))))

(provide 'init-flymake)

Remove binding of C-` for flymake-goto-next-error


;; ~/.emacs.d/behavior.el
;; Configuration settings for how Emacs should behave

(use-package better-defaults
  :ensure t)

;; NERDTree-style file viewer
(use-package neotree
  :ensure t
  :init
  (global-set-key [f8] 'neotree-toggle))

;; Use Helm for basic autocompletion and dialogs
(use-package helm
  :ensure t)
(helm-mode 1)
(global-set-key "\C-x\C-f" 'helm-find-files)
(global-set-key "\M-x" 'helm-M-x)

;; Always follow symlinks, do not prompt
(setq vc-follow-symlinks t)

;; Automatically download ELPA packages if not present
(setq use-package-always-ensure t)

;; Automatically fill paragraphs instead of doing M-q a whole bunch
;; (add-hook 'text-mode-hook 'turn-on-auto-fill)
;; (add-hook 'org-mode-hook 'turn-on-auto-fill)

;; ~/.emacs.d/behavior.el
;; Configuration settings for how Emacs should behave

(use-package better-defaults
  :ensure t)

;; NERDTree-style file viewer
(use-package neotree
  :ensure t
  :config
  (global-set-key (kbd "C-c t") 'neotree-toggle))

;; Use Helm for basic autocompletion and dialogs
(use-package helm
  :ensure t)
(helm-mode 1)
(global-set-key "\C-x\C-f" 'helm-find-files)
(global-set-key "\M-x" 'helm-M-x)

;; Always follow symlinks, do not prompt
(setq vc-follow-symlinks t)

;; Automatically download ELPA packages if not present
(setq use-package-always-ensure t)

;; Automatically fill paragraphs instead of doing M-q a whole bunch
;; (add-hook 'text-mode-hook 'turn-on-auto-fill)
;; (add-hook 'org-mode-hook 'turn-on-auto-fill)

Use C-c t to open neotree

Use C-c t to open neotree


;;; init-terraform.el -- Terraform mode setup

;;; Commentary:
;;; Terraform mode setup

;;; Code:
(use-package terraform-mode
  :mode (("\\.tf\\'" . terraform-mode)
         ("\\.tfvars\\'" . terraform-mode)))

(provide 'init-terraform)
;;; init-terraform.el ends here

;;; init-terraform.el -- Terraform mode setup

;;; Commentary:
;;; Terraform mode setup

;;; Code:
(use-package terraform-mode
  :mode (("\\.tf\\'" . terraform-mode)
         ("\\.tfvars\\'" . terraform-mode))
  :config
  (add-hook 'terraform-mode-hook 'terraform-format-on-save-mode))

(provide 'init-terraform)
;;; init-terraform.el ends here

Format Terraform files on save

Format Terraform files on save


(maybe-require-package 'docker)
(maybe-require-package 'dockerfile-mode)
(maybe-require-package 'docker-compose-mode)

(provide 'init-docker)

(when (maybe-require-package 'docker)
  (fullframe docker-images tablist-quit)
  (fullframe docker-machines tablist-quit)
  (fullframe docker-volumes tablist-quit)
  (fullframe docker-networks tablist-quit)
  (fullframe docker-containers tablist-quit))
(maybe-require-package 'dockerfile-mode)
(maybe-require-package 'docker-compose-mode)

(provide 'init-docker)

Use fullframe for the various docker list commands


(use-package js2-mode
  :ensure t
  )

(use-package vue-mode
  :ensure t
  )

(provide 'pkg-javascript)

(use-package js2-mode
  :ensure t
  )

(use-package web-mode
  :ensure t
  :config
  (setq web-mode-code-indent-offset 4)
  (setq web-mode-script-padding 0)
  (setq web-mode-markup-indent-offset 2)
  )

(use-package mmm-mode
  :ensure t
  :config
  (setq mmm-global-mode 'maybe)

  (dolist (langsets '(("script" . ((coffee . coffee-mode)
                                   (es6    . js2-mode)))
                      ("style"  . ((stylus . stylus-mode)
                                   (less   . less-css-mode)
                                   (scss   . scss-mode)))))
    (let ((tag (car langsets)))
      (dolist (pair (cdr langsets))
        (let* ((lang       (car pair))
               (submode    (cdr pair))
               (class-name (make-symbol (format "vueify-%s-%s" tag lang)))
               (front      (format "<%s lang=\"%s\">" tag lang))
               (back       (format "</%s>" tag)))
          (mmm-add-classes
           `((,class-name
              :submode ,submode
              :front ,front
              :back ,back)))
          (mmm-add-mode-ext-class nil "\\.vue?\\'" class-name)))))

  (add-to-list 'auto-mode-alist '("\\.vue?\\'" . web-mode))
  )

(provide 'pkg-javascript)

Use web-mode instead of vue-mode

Use web-mode instead of vue-mode


(setq-default compilation-scroll-output t)

(require-package 'alert)

;; Customize `alert-default-style' to get messages after compilation

(defun sanityinc/alert-after-compilation-finish (buf result)
  "Use `alert' to report compilation RESULT if BUF is hidden."
  (unless (catch 'is-visible
            (walk-windows (lambda (w)
                            (when (eq (window-buffer w) buf)
                              (throw 'is-visible t)))))
    (alert (concat "Compilation " result)
           :buffer buf
           :category 'compilation)))

(after-load 'compile
  (add-hook 'compilation-finish-functions
            'sanityinc/alert-after-compilation-finish))

(provide 'init-compile)

(setq-default compilation-scroll-output t)

(require-package 'alert)

;; Customize `alert-default-style' to get messages after compilation

(defun sanityinc/alert-after-compilation-finish (buf result)
  "Use `alert' to report compilation RESULT if BUF is hidden."
  (unless (catch 'is-visible
            (walk-windows (lambda (w)
                            (when (eq (window-buffer w) buf)
                              (throw 'is-visible t))))
            nil)
    (alert (concat "Compilation " result)
           :buffer buf
           :category 'compilation)))

(after-load 'compile
  (add-hook 'compilation-finish-functions
            'sanityinc/alert-after-compilation-finish))

(provide 'init-compile)

Make block result explicit when not "throw"-ing


;; Conventional max line length in Racket is 102 columns
(add-hook 'scheme-mode-hook (lambda () (column-marker-1 102)))
(add-hook 'scheme-mode-hook (lambda () (setq-default fill-column 102)))

;; Show a column marker in markdown mode
(add-hook 'markdown-mode-hook (lambda () (column-marker-1 80)))

;; Paredit for all S-expression-based programming modes
(add-hook 'emacs-lisp-mode-hook 'paredit-mode)
(add-hook 'scheme-mode-hook 'paredit-mode)

;; Fix magit commit message editor, as seen here: http://stackoverflow.com/a/19265280/21957
(if (equal 'darwin system-type)
    (set-variable 'magit-emacsclient-executable "/usr/local/bin/emacsclient"))

;; Conventional max line length in Racket is 102 columns
(add-hook 'scheme-mode-hook (lambda () (column-marker-1 102)))
(add-hook 'scheme-mode-hook (lambda () (setq fill-column 102)))

;; Show a column marker in markdown mode
(add-hook 'markdown-mode-hook (lambda () (column-marker-1 80)))

;; Paredit for all S-expression-based programming modes
(add-hook 'emacs-lisp-mode-hook 'paredit-mode)
(add-hook 'scheme-mode-hook 'paredit-mode)

;; Fix magit commit message editor, as seen here: http://stackoverflow.com/a/19265280/21957
(if (equal 'darwin system-type)
    (set-variable 'magit-emacsclient-executable "/usr/local/bin/emacsclient"))

Fix setting of fill-column value

Fix setting of fill-column value


;; multiple selection
(global-set-key (kbd "M-n") 'mc/mark-next-like-this)
(global-set-key (kbd "M-p") 'mc/mark-previous-like-this)

;; move lines
(global-set-key (kbd "M-S-<up>") 'drag-stuff-up)
(global-set-key (kbd "M-S-<down>") 'drag-stuff-down)

;; move between windows
(global-set-key (kbd "M-<left>") 'windmove-left)
(global-set-key (kbd "M-<right>") 'windmove-right)
(global-set-key (kbd "M-<up>") 'windmove-up)
(global-set-key (kbd "M-<down>") 'windmove-down)

;; comment line or region
(global-set-key (kbd "s-/") 'comment-line)

;; project structure
(global-set-key [f3] 'neotree-toggle)

;; magit
(global-set-key (kbd "C-x g") 'magit-status)

;; multiple selection
(global-set-key (kbd "M-n") 'mc/mark-next-like-this)
(global-set-key (kbd "M-p") 'mc/mark-previous-like-this)

;; move lines
(global-set-key (kbd "M-S-<up>") 'drag-stuff-up)
(global-set-key (kbd "M-S-<down>") 'drag-stuff-down)

;; move between windows
(global-set-key (kbd "M-<left>") 'windmove-left)
(global-set-key (kbd "M-<right>") 'windmove-right)
(global-set-key (kbd "M-<up>") 'windmove-up)
(global-set-key (kbd "M-<down>") 'windmove-down)

;; comment line or region
(global-set-key (kbd "C-x C-_") 'comment-line)
(global-set-key (kbd "C-x C-/") 'comment-line)

;; project structure
(global-set-key [f3] 'neotree-toggle)

;; magit
(global-set-key (kbd "C-x g") 'magit-status)

Change comment out code shortcut

Change comment out code shortcut


;;
;; misc.init.el - Miscellaneous Emacs settings
;;

;; Default to unified diffs
(setq diff-switches "-u")

;;; Always end a file with a newline
;;(setq require-final-newline 'query)

;; Never use double-spaces between sentences.
(setq sentence-end-double-space nil)

;; Automatic (de)compression of files
(auto-compression-mode t)

;; Start emacsclient server
(server-start)

;;; Save minibuffer history between sessions.
;;(setq savehist-additional-variables     ; Also save searches
;;      '(search-ring regexp-search-ring))
;;(savehist-mode t)

;; Set the current working directory to HOME if running on a window system.
;; Needed in Emacs.app, which always defaults to /.
(if (and (window-system) (getenv "HOME"))
    (setq default-directory (concat (getenv "HOME") "/")))

;;
;; misc.init.el - Miscellaneous Emacs settings
;;

;; Default to unified diffs
(setq diff-switches "-u")

;;; Always end a file with a newline
;;(setq require-final-newline 'query)

;; Never use double-spaces between sentences.
(setq sentence-end-double-space nil)

;; Automatic (de)compression of files
(auto-compression-mode t)

;; Uniquify buffer names using directory names instead of numbers
;; (new default in Emacs 24)
(setq uniquify-buffer-name-style 'post-forward-angle-brackets)
(require 'uniquify nil 'noerror)

;; Start emacsclient server
(server-start)

;;; Save minibuffer history between sessions.
(setq savehist-file "~/.emacs.d/history")
(setq savehist-additional-variables
      '(search-ring regexp-search-ring)) ; Also save searches
(savehist-mode t)

;; If browse-kill-ring is available, M-y will activate the kill-ring
;; browser if the previous command was not a yank.
(when (require 'browse-kill-ring nil 'noerror)
  (browse-kill-ring-default-keybindings)
  (setq browse-kill-ring-quit-action 'save-and-restore))

;; Set the current working directory to HOME if running on a window system.
;; Needed in Emacs.app, which always defaults to /.
(if (and (window-system) (getenv "HOME"))
    (setq default-directory (concat (getenv "HOME") "/")))

emacs: Enable uniquify in Emacs 23, savehist, and browse-kill-ring


(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.
 '(ansi-color-names-vector ["#212526" "#ff4b4b" "#b4fa70" "#fce94f" "#729fcf" "#ad7fa8" "#8cc4ff" "#eeeeec"])
 '(auto-save-default nil)
 '(custom-enabled-themes (quote (wheatgrass)))
 '(inhibit-startup-screen t)
 '(make-backup-files nil)
 '(org-agenda-files (quote ("~/Documents/org")))
 '(org-todo-keyword-faces (quote (("DONE" . success) ("IN-PROGRESS" . diary) ("WAITING" . warning) ("TODO" . error))))
 '(org-todo-keywords (quote ((sequence "TODO" "IN-PROGRESS" "WAITING" "DONE")))))
(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.
 )

(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.
 '(ansi-color-names-vector ["#212526" "#ff4b4b" "#b4fa70" "#fce94f" "#729fcf" "#ad7fa8" "#8cc4ff" "#eeeeec"])
 '(auto-save-default nil)
 '(custom-enabled-themes (quote (wheatgrass)))
 '(font-use-system-font t)
 '(inhibit-startup-screen t)
 '(make-backup-files nil)
 '(org-agenda-files (quote ("~/Documents/org")))
 '(org-todo-keyword-faces (quote (("DONE" . success) ("IN-PROGRESS" . diary) ("WAITING" . warning) ("TODO" . error))))
 '(org-todo-keywords (quote ((sequence "TODO" "IN-PROGRESS" "WAITING" "DONE"))))
 '(scalable-fonts-allowed 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.
 )

Enable scalable fonts and system font use


(defun rebuild-ripper-tags ()
  (start-process "rebuild-ripper-tags" nil "rebuild-ripper-tags"))

(add-hook
 'ruby-mode-hook
 (lambda ()
   ;; Check spelling.
   (flyspell-prog-mode)
   ;; Don't autofill
   (auto-fill-mode 0)
   ;; Make enter indent.
   (local-set-key (kbd "C-m") 'reindent-then-newline-and-indent)
   ;; Make smart-tab always indent
   (defvar smart-tab-always-indent nil)
   (setq-local smart-tab-always-indent t)
   ;; Clean up whitespace on save.
   (add-hook 'before-save-hook 'whitespace-cleanup nil t)
   ;; Rebuild tags on save.
   (add-hook (make-local-variable 'after-save-hook) 'rebuild-ripper-tags nil t)
   ;; Disable rubocop
   (defvar flycheck-disabled-checkers "flycheck.el")
   (setq flycheck-disabled-checkers
         (cons 'ruby-rubocop flycheck-disabled-checkers))
   ;; Turn on subword-mode
   (require 'diminish)
   (subword-mode 1)
   (diminish 'subword-mode)
   ;; Make do/end less prominent.
   (defvar paren-face-regexp)
   (setq-local paren-face-regexp
               (rx symbol-start (or "do" "end") symbol-end))))

(defun rebuild-ripper-tags ()
  (start-process "rebuild-ripper-tags" nil "rebuild-ripper-tags"))

(add-hook
 'ruby-mode-hook
 (lambda ()
   ;; Check spelling.
   (flyspell-prog-mode)
   ;; Don't autofill
   (auto-fill-mode 0)
   ;; Make enter indent.
   (local-set-key (kbd "C-m") 'reindent-then-newline-and-indent)
   ;; Make smart-tab always indent
   (defvar smart-tab-always-indent nil)
   (setq-local smart-tab-always-indent t)
   ;; Clean up whitespace on save.
   (add-hook 'before-save-hook 'whitespace-cleanup nil t)
   ;; Rebuild tags on save.
   (add-hook (make-local-variable 'after-save-hook) 'rebuild-tags nil t)
   ;; Disable rubocop
   (defvar flycheck-disabled-checkers "flycheck.el")
   (setq flycheck-disabled-checkers
         (cons 'ruby-rubocop flycheck-disabled-checkers))
   ;; Turn on subword-mode
   (require 'diminish)
   (subword-mode 1)
   (diminish 'subword-mode)
   ;; Make do/end less prominent.
   (defvar paren-face-regexp)
   (setq-local paren-face-regexp
               (rx symbol-start (or "do" "end") symbol-end))))

Switch back to Exuberant CTags for Ruby

Switch back to Exuberant CTags for Ruby


(require-package 'go-mode)
(require-package 'go-autocomplete)

; dafuq is up with autoloads?
(load "go-mode.el")

(require 'go-autocomplete)

; Installed by do-setup
(load-file "/Users/lstoll/gocode/src/code.google.com/p/go.tools/cmd/oracle/oracle.el")

(defun my-go-mode-hook ()
  ; Use goimports instead of go-fmt
  (setq gofmt-command "goimports")
  ; Call Gofmt before saving
  (add-hook 'before-save-hook 'gofmt-before-save)
  ; Customize compile command to run go build
  (if (not (string-match "go" compile-command))
      (set (make-local-variable 'compile-command)
           "go build -v && go test -v && go vet"))
  ; Godef jump key binding
  (local-set-key (kbd "M-.") 'godef-jump))
  ; Go Oracle
  (go-oracle-mode)
(add-hook 'go-mode-hook 'my-go-mode-hook)

(provide 'init-go)

(require-package 'go-mode)
(require-package 'go-autocomplete)

; dafuq is up with autoloads?
(load "go-mode.el")

(require 'go-autocomplete)

; Installed by do-setup
(load-file "/Users/lstoll/gocode/src/code.google.com/p/go.tools/cmd/oracle/oracle.el")

(defun my-go-mode-hook ()
  ; Use goimports instead of go-fmt
  (setq gofmt-command "goimports")
  ; Call Gofmt before saving
  (add-hook 'before-save-hook 'gofmt-before-save)
  ; Customize compile command to run go build
  (if (not (string-match "go" compile-command))
      (set (make-local-variable 'compile-command)
           "go build -v && go test -v && go vet"))
  ; Godef jump key binding
  (local-set-key (kbd "M-.") 'godef-jump))
  ; Go Oracle
  (go-oracle-mode)

  (setq tab-width 4)
(add-hook 'go-mode-hook 'my-go-mode-hook)

(provide 'init-go)

Set tab width to something less crazy

Set tab width to something less crazy


(require 'package)

;; Add MELPA repository
(add-to-list 'package-archives
             '("melpa" .
               "http://melpa.milkbox.net/packages/"))

;; Add MELPA Stable
(add-to-list 'package-archives
             '("melpa-stable" .
               "https://stable.melpa.org/packages/"))

;; Add GNU ELPA repository
(add-to-list 'package-archives
             '("gnu" .
               "http://elpa.gnu.org/packages/"))

(setf package-archive-priorities
      '(("melpa-stable" . 20)
        ("gnu" . 10)
        ("melpa" . 0)))

;; (require 'packup)

(provide 'repositories)

(require 'package)

;; Add MELPA Stable
(add-to-list 'package-archives
             '("melpa-stable" .
               "https://stable.melpa.org/packages/"))

;; Add GNU ELPA repository
(add-to-list 'package-archives
             '("gnu" .
               "http://elpa.gnu.org/packages/"))

;; Add MELPA repository
(add-to-list 'package-archives
             '("melpa" .
               "http://melpa.milkbox.net/packages/"))

(setf package-archive-priorities
      '(("melpa-stable" . 20)
        ("gnu" . 10)
        ("melpa" . 0)))

;; (require 'packup)

(provide 'repositories)

Move MELPA to the bottom of the list of package archive additions

This matches the priority listing.


;; Load theme and set font
(set-frame-font "Droid Sans Mono-10" nil t)
(load-theme 'yoshi :no-confirm)

;; Set font
;; (set-frame-font "Droid Sans Mono-10" nil t)

;; Load Theme
;; Install base16-theme & jazz-theme through package manager

(load-theme 'jazz t) ;; Best looking theme, just needs black bg to be perfect

;; (load-theme 'base16-isotope t) ;; black bg, high contrast, great bright text
;; (load-theme 'base16-pop t) ;; black bg, high contrast, nice
;; (load-theme 'base16-pico t) ;; black bg, interesting, high contrast
;; (load-theme 'base16-bright t) ;; black bg, high contrast
;; (load-theme 'base16-ir-black t) ;; black bg, high contrast

;; (load-theme 'base16-seti-ui t) ;; not black bg but dark, good colours
;; (load-theme 'base16-solar-flare t) ;; not black bg but dark, good colours
;; (load-theme 'base16-google-dark t) ;; not black bg but dark, good colours

;; (load-theme 'base16-solarized-dark t);; not black bg but good colours
;; (load-theme 'base16-spacemacs t) ;; not black bg but good colours

;; (load-theme 'base16-phd t) ;; not black bg, colours not very high contrast
;; (load-theme 'base16-tomorrow-night t) ;; not black bg
;; (load-theme 'base16-twilight t) ;; not black bg

;; (load-theme 'base16-summerfruit-dark t) ;; not great i think
;; (load-theme 'base16-railscasts t) ;; not great i think
;; (load-theme 'base16-macintosh t) ;; not great i think

;;OTHER THEMES
;;Danneskjold Theme
;;https://github.com/emacs-jp/replace-colorthemes

Add theme options w/ comments

Add theme options w/ comments


(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.
 '(apropos-sort-by-scores t)
 '(backup-directory-alist `((".*" \, temporary-file-directory)))
 '(global-display-line-numbers-mode t)
 '(org-log-done 'time)
 '(org-log-into-drawer "LOGBOOK")
 '(package-archives
   '(("gnu" . "https://elpa.gnu.org/packages/")
     ("melpa" . "https://melpa.org/packages/")))
 '(package-selected-packages
   '(paredit sml-mode ycmd solarized-theme rust-mode rainbow-delimiters markdown-mode magit company cmake-mode)))
(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.
 )

(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.
 '(apropos-sort-by-scores t)
 '(backup-directory-alist `((".*" \, temporary-file-directory)))
 '(global-display-line-numbers-mode t)
 '(ido-create-new-buffer 'always)
 '(ido-enable-flex-matching t)
 '(ido-everywhere t)
 '(ido-mode 'both nil (ido))
 '(org-log-done 'time)
 '(org-log-into-drawer "LOGBOOK")
 '(package-archives
   '(("gnu" . "https://elpa.gnu.org/packages/")
     ("melpa" . "https://melpa.org/packages/")))
 '(package-selected-packages
   '(paredit sml-mode ycmd solarized-theme rust-mode rainbow-delimiters markdown-mode magit company cmake-mode)))
(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.
 )

Add customizations for IDO in Emacs

Add customizations for IDO in Emacs


(use-package ensime
  :ensure t
  :pin melpa-stable
  :defer t
  :init
  (add-to-list 'exec-path "/opt/local/bin")
  :config
  (setq ensime-startup-snapshot-notification nil)
  (setq ensime-startup-notification nil)
  :bind (:map ensime-mode-map
         ("C-c C-b h" . sbt-hydra)))

(use-package flycheck-cask
  :commands flycheck-cask-setup
  :config
  (add-hook 'emacs-lisp-mode-hook (flycheck-cask-setup)))

(provide 'setup-scala-mode)

(use-package scala-mode2
  :ensure t
  :defer t
  )

(use-package flycheck-cask
  :commands flycheck-cask-setup
  :config
  (add-hook 'emacs-lisp-mode-hook (flycheck-cask-setup)))

(provide 'setup-scala-mode)

Remove ensime (RIP) and update to scala-mode2


(require 'solarized)

(deftheme solarized-dark "The dark variant of the Solarized colour theme")
(create-solarized-theme 'dark 'solarized-dark)
(provide-theme 'solarized-dark)

(deftheme solarized-light "The light variant of the Solarized colour theme")
(create-solarized-theme 'light 'solarized-light)
(provide-theme 'solarized-light)

(if (equal system-name "QUE-WKS-AA427-Linux")
    (load-theme 'solarized-light t)
    (load-theme 'solarized-dark t))

(require 'solarized)

(deftheme solarized-dark "The dark variant of the Solarized colour theme")
(create-solarized-theme 'dark 'solarized-dark)
(provide-theme 'solarized-dark)

(deftheme solarized-light "The light variant of the Solarized colour theme")
(create-solarized-theme 'light 'solarized-light)
(provide-theme 'solarized-light)

(if (or (equal system-name "QUE-WKS-AA427-Linux")
        (equal system-name "QUE-WKS-AA593"))
    (load-theme 'solarized-light t)
    (load-theme 'solarized-dark t))

Add theme support for AA593

Add theme support for AA593


;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.

(require 'url-vars)
(require 'url-dav)

(require 'json)

(with-current-buffer
    (url-retrieve-synchronously "http://localhost:3000/packages?class=Class")
  (goto-char url-http-end-of-headers)
  (let* ((json-object-type 'plist)
        (rtnval (json-read)))
    (kill-buffer (current-buffer))
    rtnval))

;; (with-current-buffer (url-retrieve-synchronously "http://localhost:3000/")
;;     (goto-char url-http-end-of-headers)
;;     (setq json-array-type 'vector
;;           json-object-type 'alist)

;;     (let ((json-readtable-old (when readtable
;;                     (let ((r json-readtable))
;;                       (setq json-readtable readtable)
;;                       r)))
;;           (rtnval (json-read)))
;;       (kill-buffer (current-buffer))
;;       (when readtable (setq json-readtable json-readtable-old))
;;       rtnval))

;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.

(require 'url-vars)
(require 'url-dav)

(require 'json)

(with-current-buffer
    (url-retrieve-synchronously "http://localhost:3000/classes?name=List")
  (goto-char url-http-end-of-headers)
  (let* ((json-object-type 'plist)
        (rtnval (json-read)))
    (kill-buffer (current-buffer))
    rtnval))

;; (with-current-buffer (url-retrieve-synchronously "http://localhost:3000/")
;;     (goto-char url-http-end-of-headers)
;;     (setq json-array-type 'vector
;;           json-object-type 'alist)

;;     (let ((json-readtable-old (when readtable
;;                     (let ((r json-readtable))
;;                       (setq json-readtable readtable)
;;                       r)))
;;           (rtnval (json-read)))
;;       (kill-buffer (current-buffer))
;;       (when readtable (setq json-readtable json-readtable-old))
;;       rtnval))

Fix emacs client to call API

Fix emacs client to call API


(use-package spacemacs-theme
  :defer t
  :ensure t
  :init
  (setq default-frame-alist (quote ((fullscreen . maximized))))
  (load-theme 'spacemacs-dark t)
  )

(use-package spaceline
  :defer t
  :init
  (setq powerline-default-separator 'slant)
  (setq ns-use-srgb-colorspace nil)
  (setq powerline-height 15)
  )

(use-package spaceline-config
  :demand t
  :ensure spaceline
  :config
  (spaceline-define-segment line-column
    "The current line and column numbers."
    "l:%l c:%2c")
  (spaceline-helm-mode 1)
  (spaceline-spacemacs-theme)
  )

(provide 'setup-theme)

(use-package spacemacs-theme
  :defer t
  :ensure t
  :init
  (setq default-frame-alist (quote ((fullscreen . maximized))))
  (load-theme 'spacemacs-dark t)
  )

(use-package spaceline
  :defer t
  :init
  (setq powerline-default-separator 'slant)
  (setq ns-use-srgb-colorspace nil)
  (setq powerline-height 18)
  )

(use-package spaceline-config
  :demand t
  :ensure spaceline
  :config
  (spaceline-define-segment line-column
    "The current line and column numbers."
    "l:%l c:%2c")
  (spaceline-helm-mode 1)
  (spaceline-spacemacs-theme)
  )

(provide 'setup-theme)

Increase powerline height to 18

Increase powerline height to 18


;; pdf-tools for viewing PDFs

(use-package pdf-tools
  :init
  (pdf-tools-install)
  ;; Setup a hook when we kill a pdf take a bookmark
  (add-hook 'kill-buffer-hook 'kill-buffer-hook-setup)
  :defer 5
  :config
  ;; Set a bookmark on kill
  (defun kill-buffer-hook-setup ()
    ;; Test that we have a filename and file extensions and it's a pdf and the user
    ;; wants to take a bookmark
    (if (and buffer-file-name
             (file-name-extension buffer-file-name)
             (string= (downcase (file-name-extension buffer-file-name)) "pdf")
             (y-or-n-p "Set bookmark with current file name?"))
        ;; Set a bookmark with the name being the buffers full path name
        (bookmark-set (file-name-nondirectory buffer-file-name) nil))))

;; pdf-tools for viewing PDFs

(use-package pdf-tools
  :init
  (pdf-tools-install)
  ;; Setup a hook when we kill a pdf take a bookmark
  (add-hook 'kill-buffer-hook 'kill-buffer-hook-setup)
  :config
  ;; Set a bookmark on kill
  (defun kill-buffer-hook-setup ()
    ;; Test that we have a filename and file extensions and it's a pdf and the user
    ;; wants to take a bookmark
    (if (and buffer-file-name
             (file-name-extension buffer-file-name)
             (string= (downcase (file-name-extension buffer-file-name)) "pdf")
             (y-or-n-p "Set bookmark with current file name?"))
        ;; Set a bookmark with the name being the buffers full path name
        (bookmark-set (file-name-nondirectory buffer-file-name) nil))))

Remove defer for pdf tools

Remove defer for pdf tools


;;; private/lean/config.el -*- lexical-binding: t; -*-

;; (load! +bindings)

(def-package! company-lean)
(def-package! lean-mode)
(def-package! helm-lean)

(defun unlines (lns)
  (mapconcat 'identity lns "\n"))

(defun keep-errors-only (proc string)
  (interactive)
  (let* ((lines (split-string string "\n"))
	     (new-string (seq-filter (lambda (x) (cl-search "error" x)) lines)))
    (if (not (null new-string))
	    (when (buffer-live-p (process-buffer proc))
	      (with-current-buffer (process-buffer proc)
	        (let ((moving (= (point) (process-mark proc))))
	          (save-excursion
		        ;; Insert the text, advancing the process marker.
		        (goto-char (process-mark proc))
		        (insert (unlines new-string))
		        (set-marker (process-mark proc) (point)))
	          (if moving (goto-char (process-mark proc)))
	          (delete-process proc)))))))

(defun lean-leanpkg-run-quiet (cmd &optional restart-lean-server)
  "Call `leanpkg $cmd`"
  (let ((dir (file-name-as-directory (lean-leanpkg-find-dir-safe)))
        (orig-buf (current-buffer)))
    (with-current-buffer (get-buffer-create "*leanpkg*")
      (setq buffer-read-only nil)
      (erase-buffer)
      (switch-to-buffer-other-window (current-buffer))
      (redisplay)
      (insert (format "> leanpkg %s\n" cmd))
      (setq lean-leanpkg-running t)
      (let* ((default-directory dir)
             (out-buf (current-buffer))
             (proc (make-process :name "leanpkg"
				                 :buffer (current-buffer)
				                 :filter 'keep-errors-only
                                 :command (list (lean-leanpkg-executable) cmd))))
        (set-process-sentinel
         proc (lambda (_p _e)
                (setq lean-leanpkg-running nil)
		        (if restart-lean-server
		            (progn
		              (with-current-buffer out-buf
			            (insert "; restarting lean server\n"))
		              (with-current-buffer orig-buf
			            (lean-server-restart)))
		          (progn
		            (with-current-buffer out-buf
			          (insert "; (done)\n"))))))))))

(defun lean-leanpkg-build-quiet ()
  "Call leanpkg build (quiet)"
  (interactive)
  (lean-leanpkg-run-quiet "build"))

(defun lean-leanpkg-test-quiet ()
  "Call leanpkg build (quiet)"
  (interactive)
  (lean-leanpkg-run-quiet "test"))

Add Simon's helper functions for buliding lean files

Handy especially when upgrading Lean and refactoring.

TODO: find a nice key binding for lean-leanpkg-{build,test}-quiet
      functions


(defun split-window-func-with-other-buffer (split-function)
  (lexical-let ((s-f split-function))
    (lambda ()
      (interactive)
      (funcall s-f)
      (set-window-buffer (next-window) (other-buffer)))))

(global-set-key "\C-x2" (split-window-func-with-other-buffer 'split-window-vertically))
(global-set-key "\C-x3" (split-window-func-with-other-buffer 'split-window-horizontally))

(defun split-window-horizontally-instead ()
  (interactive)
  (save-excursion
    (delete-other-windows)
    (funcall (split-window-func-with-other-buffer 'split-window-horizontally))))

(global-set-key "\C-x|" 'split-window-horizontally-instead)

(provide 'init-window-split)

(defun split-window-func-with-other-buffer (split-function)
  (lexical-let ((s-f split-function))
    (lambda ()
      (interactive)
      (funcall s-f)
      (set-window-buffer (next-window) (other-buffer)))))

(global-set-key "\C-x2" (split-window-func-with-other-buffer 'split-window-vertically))
(global-set-key "\C-x3" (split-window-func-with-other-buffer 'split-window-horizontally))

(defun split-window-horizontally-instead ()
  (interactive)
  (save-excursion
    (delete-other-windows)
    (funcall (split-window-func-with-other-buffer 'split-window-horizontally))))

(defun split-window-vertically-instead ()
  (interactive)
  (save-excursion
    (delete-other-windows)
    (funcall (split-window-func-with-other-buffer 'split-window-vertically))))

(global-set-key "\C-x|" 'split-window-horizontally-instead)
(global-set-key "\C-x_" 'split-window-vertically-instead)

(provide 'init-window-split)

Add split-window-vertically-instead, bound to "C-x _"


;;; Mail and News Servers

;; News via NNTP
(setq
 nntp-authinfo-file pmade-authinfo
 gnus-select-method '(nntp "news.gmane.org"))

;; Mail via IMAP and SMTP
(setq
 pmade-mail-server "mail.pmade.com"
 nnimap-authinfo-file pmade-authinfo
 message-send-mail-function 'smtpmail-send-it
 smtpmail-smtp-server pmade-mail-server
 smtpmail-auth-credentials pmade-authinfo
 smtpmail-starttls-credentials `((,pmade-mail-server 25 nil nil))
 smtpmail-local-domain "pmade.com")

(setq gnus-secondary-select-methods
      `((nnimap ,pmade-mail-server (nnimap-stream ssl))))

;; Place sent mail on the server
(setq gnus-message-archive-group "nnimap+mail.pmade.com:INBOX.Sent")

;; Use the correct value for the Message-ID header
(defun message-make-message-id ()
  (concat "<" (message-unique-id) "@pmade.com>"))

;;; Mail and News Servers

;; News via NNTP
(setq nntp-authinfo-file pmade-authinfo
      gnus-select-method '(nntp "news.gmane.org"))

;; IMAP (incoming mail)
(setq pmade-mail-server "mail.pmade.com"
      nnimap-authinfo-file pmade-authinfo)

;; SMTP (outgoing mail)
(setq pmade-smtp-host pmade-mail-server
      pmade-smtp-port 25)

;; When I'm on my laptop, do SMTP through a SSH tunnel (because port
;; 25 is blocked by my ISP and at most coffee shops I frequent)
(let ((host (replace-regexp-in-string "\n" "" (shell-command-to-string "hostname"))))
  (when (string= "skinny.local" host)
    (setq pmade-smtp-host "127.0.0.1"
          pmade-smtp-port 2525
          starttls-extra-arguments '("--insecure"))))

(setq message-send-mail-function 'smtpmail-send-it
      smtpmail-smtp-server pmade-smtp-host
      smtpmail-smtp-service pmade-smtp-port
      smtpmail-auth-credentials pmade-authinfo
      smtpmail-starttls-credentials `((,pmade-smtp-host ,pmade-smtp-port nil nil))
      smtpmail-local-domain "pmade.com"
      starttls-use-gnutls t)

(setq gnus-secondary-select-methods
      `((nnimap ,pmade-mail-server (nnimap-stream ssl))))

;; Place sent mail on the server
(setq gnus-message-archive-group "nnimap+mail.pmade.com:INBOX.Sent")

;; Use the correct value for the Message-ID header
(defun message-make-message-id ()
  (concat "<" (message-unique-id) "@pmade.com>"))

Work around comcast blocking port 25

Work around comcast blocking port 25


;;; funcs.el --- Spacemacs ERC Layer functions File
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

(defun erc//servers (server-list)
  (dolist (s server-list)
    (apply (if
               (plist-get (cdr s) :ssl)
               (progn
                 (remf (cdr s) :ssl)
                 'erc-tls)
             'erc)
           :server s)))

(defun erc/default-servers ()
  (interactive)
  (if erc-server-list
      (erc//servers erc-server-list)
    (message "You must define erc-server-list")))

;;; funcs.el --- Spacemacs ERC Layer functions File
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

(defun erc//servers (server-list)
  (dolist (s server-list)
    (setq s (copy-list s))
    (apply (if
               (plist-get (cdr s) :ssl)
               (progn
                 (remf (cdr s) :ssl)
                 'erc-tls)
             'erc)
           :server s)))

(defun erc/default-servers ()
  (interactive)
  (if erc-server-list
      (erc//servers erc-server-list)
    (message "You must define erc-server-list")))

Fix connecting to default servers with TLS more than once with ERC

The erc//servers function removes the :ssl variable from the list so it
can be passed directly to erc-tls, but this means that subsequent
connections will not use TLS. Thus, we should operate on a copy of the
list instead.


(defun toby/eshell-in-buffer-dir ()
  "Open eshell in the current buffer's directory"
  (interactive)
  (let ((dir default-directory))
    (let ((b (get-buffer eshell-buffer-name)))
      (unless b (eshell))
      )
    (display-buffer eshell-buffer-name t)
    (switch-to-buffer-other-window eshell-buffer-name)
    (end-of-buffer)
    (unless (equalp dir default-directory)
      (cd dir)
      (eshell-send-input)
      (end-of-buffer))))

(global-set-key (kbd "C-x C-m") 'toby/eshell-in-buffer-dir)

(add-hook 'eshell-mode-hook
          (lambda ()
            (defalias 'ff 'find-file)
            ))

Add a function to open eshell in current dir.


;; Time-stamp: <2015-07-15 11:35:12 kmodi>

;; Which Key
;; https://github.com/justbur/emacs-which-key

(use-package which-key
  :defer 15
  :config
  (progn
    (setq which-key-popup-type 'minibuffer) ; default
    ;; (setq which-key-popup-type 'side-window)

    (setq which-key-key-replacement-alist
          '(("<\\(\\(C-\\|M-\\)*.+\\)>" . "\\1")
            ("left"  . "🡄")
            ("right" . "🡆")
            ("up"    . "🡅")
            ("down"  . "🡇")))
    (setq which-key-special-keys '("SPC" "TAB" "RET" "ESC" "DEL"
                                   "🡄" "🡆" "🡅" "🡇"))

    (which-key-mode 1)))

(provide 'setup-which-key)

;; Time-stamp: <2015-07-15 12:09:48 kmodi>

;; Which Key
;; https://github.com/justbur/emacs-which-key

(use-package which-key
  :defer 15
  :config
  (progn
    (setq which-key-popup-type 'minibuffer) ; default
    ;; (setq which-key-popup-type 'side-window)

    (setq which-key-key-replacement-alist
          '(("<\\(\\(C-\\|M-\\)*.+\\)>" . "\\1")
            ("left"  . "◀")
            ("right" . "▶")
            ("up"    . "▲")
            ("down"  . "▼")))
    (setq which-key-special-keys '("SPC" "TAB" "RET" "ESC" "DEL"))

    (which-key-mode 1)))

(provide 'setup-which-key)

Make the arrows in which-key less garish


(require 'clojure-mode)

(define-key clojure-mode-map (kbd "C-c RET jo") 'clj-jump-to-other-file)
(define-key clojure-mode-map (kbd "C-c RET oo") 'clj-jump-to-other-file-other-window)

(provide 'setup-clojure-mode)

(require 'clojure-mode)

(define-key clojure-mode-map (kbd "C-c C-j") 'clj-jump-to-other-file)
(define-key clojure-mode-map (kbd "C-c M-j") 'clj-jump-to-other-file-other-window)

(provide 'setup-clojure-mode)

Change clj keybindings for jumping between tests and source.


;; Time-stamp: <2014-08-19 12:15:30 kmodi>

;; gtags, GNU global

(req-package ggtags
  :require (verilog-mode key-chord)
  :init
  (progn
    (dolist (hook '(verilog-mode-hook
                    matlab-mode-hook))
      (add-hook hook 'ggtags-mode))
    (key-chord-define-global "??" 'ggtags-show-definition)))

(provide 'setup-gtags)

;; Time-stamp: <2014-11-19 10:19:17 kmodi>

;; gtags, GNU global

(req-package ggtags
  :require (verilog-mode key-chord)
  :init
  (progn
    (setq ggtags-navigation-mode-lighter nil)
    (dolist (hook '(verilog-mode-hook
                    matlab-mode-hook
                    c-mode-hook))
      (add-hook hook 'ggtags-mode))
    (key-chord-define-global "??" 'ggtags-show-definition)))

(provide 'setup-gtags)

Enable ggtags-mode in C files too

Enable ggtags-mode in C files too


;; add ELPA and MELPA package repos
(setq package-archives
      '(("gnu" . "http://elpa.gnu.org/packages/")
	("melpa" . "http://melpa.org/packages/")))

;; user solarized dark color theme
(add-to-list 'custom-theme-load-path "~/.emacs.d/solarized_theme")
(set-terminal-parameter nil 'background-mode 'dark)
(set-frame-parameter nil 'background-mode 'dark)
(load-theme 'solarized t)

;; define three useful commands(from org guide)
(global-set-key (kbd "C-c l") 'org-store-link)
(global-set-key (kbd "C-c a") 'org-agenda)
(global-set-key (kbd "C-c c") 'org-capture)

;; display line numbers
(custom-set-variables '(global-display-line-numbers-mode t))

;; Sort apropos result by relevance
(setq apropos-sort-by-scores t)

Sort apropos result by relavence in Emacs