(defun mfa-org/org-index ()
  (interactive)
  (find-file (concat org-directory "index.org")))

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

(defun mfa-org/org-index (prefix)
  "Open the org index.
Giving the command a PREFIX arg will open the index in another window."
  (interactive "P")
  (let ((index (concat org-directory "index.org")))
    (if prefix
        (find-file-other-window index)
      (find-file index))))

Add a prefix argument to org-index to open it in a new window


;;; ui/indent-guides/config.el -*- lexical-binding: t; -*-

(def-package! highlight-indent-guides
  :hook ((prog-mode text-mode conf-mode) . highlight-indent-guides-mode)
  :init
  (setq highlight-indent-guides-method 'character)
  :config
  ;; Don't display first level of indentation
  (defun +indent-guides-for-all-but-first-column (level responsive display)
    (unless (< level 1)
      (highlight-indent-guides--highlighter-default level responsive display)))
  (setq highlight-indent-guides-highlighter-function #'+indent-guides-for-all-but-first-column)

  (defun +indent-guides|disable-maybe ()
    (when highlight-indent-guides-mode
      (highlight-indent-guides-mode -1)))
  ;; `highlight-indent-guides' breaks in these modes
  (add-hook 'visual-line-mode-hook #'+indent-guides|disable-maybe)
  (add-hook 'org-indent-mode-hook #'+indent-guides|disable-maybe))

;;; ui/indent-guides/config.el -*- lexical-binding: t; -*-

(def-package! highlight-indent-guides
  :hook ((prog-mode text-mode conf-mode) . highlight-indent-guides-mode)
  :init
  (setq highlight-indent-guides-method 'character)
  :config
  (when (daemonp)
    (highlight-indent-guides-auto-set-faces))

  ;; Don't display first level of indentation
  (defun +indent-guides-for-all-but-first-column (level responsive display)
    (unless (< level 1)
      (highlight-indent-guides--highlighter-default level responsive display)))
  (setq highlight-indent-guides-highlighter-function #'+indent-guides-for-all-but-first-column)

  (defun +indent-guides|disable-maybe ()
    (when highlight-indent-guides-mode
      (highlight-indent-guides-mode -1)))
  ;; `highlight-indent-guides' breaks in these modes
  (add-hook 'visual-line-mode-hook #'+indent-guides|disable-maybe)
  (add-hook 'org-indent-mode-hook #'+indent-guides|disable-maybe))

Fix color of indent guides in daemon sessions


(setq inhibit-startup-message t)
(setq initial-scratch-message ";;;   S C R A T C H   B U F F E R   ;;;")

(menu-bar-mode nil)

(setq inhibit-startup-message t)
(setq initial-scratch-message ";;;   S C R A T C H   B U F F E R   ;;;
")

(menu-bar-mode nil)

Fix emacs scratch buffer message

Fix emacs scratch buffer message


(autoload 'python-mode "python-mode" "Python editing mode." t)
(autoload 'doctest-mode "doctest-mode" "Python doctest editing mode." t)

(setq auto-mode-alist
      (append '(("\\.py$" . python-mode)
		("SConstruct$" . python-mode)
		("SConscript$" . python-mode))
              auto-mode-alist))

(setq interpreter-mode-alist
      (cons '("python" . python-mode) interpreter-mode-alist))

;;----------------------------------------------------------------------------
;; Pymacs and Rope for Python
;;----------------------------------------------------------------------------
;; See http://edward.oconnor.cx/2008/02/ropemacs
(add-hook 'python-mode-hook
          (lambda ()
            (require 'pymacs)
            (pymacs-load "ropemacs" "rope-")))

;;----------------------------------------------------------------------------
;; On-the-fly syntax checking via flymake
;;----------------------------------------------------------------------------
(setq flymake-python-pyflakes-executable "pyflakes-2.6")
(require 'flymake-python)

(add-hook 'python-mode-hook 'flymake-python-load)

(provide 'init-python-mode)

(autoload 'python-mode "python-mode" "Python editing mode." t)
(autoload 'doctest-mode "doctest-mode" "Python doctest editing mode." t)

(setq auto-mode-alist
      (append '(("\\.py$" . python-mode)
		("SConstruct$" . python-mode)
		("SConscript$" . python-mode))
              auto-mode-alist))

(setq interpreter-mode-alist
      (cons '("python" . python-mode) interpreter-mode-alist))

;;----------------------------------------------------------------------------
;; Pymacs and Rope for Python
;;----------------------------------------------------------------------------
;; See http://edward.oconnor.cx/2008/02/ropemacs
(setq pymacs-load-path
      (list (concat el-get-dir "ropemacs")))
(add-hook 'python-mode-hook
          (lambda ()
            (require 'pymacs)
            (pymacs-load "ropemacs" "rope-")))

;;----------------------------------------------------------------------------
;; On-the-fly syntax checking via flymake
;;----------------------------------------------------------------------------
(setq flymake-python-pyflakes-executable "pyflakes-2.6")
(require 'flymake-python)

(add-hook 'python-mode-hook 'flymake-python-load)

(provide 'init-python-mode)

Add ropemacs to pymacs-load-path (part-way to fixing up rope-based auto-completion)


(load-theme 'base16-oceanicnext-dark t)
(tool-bar-mode -1)
(set-frame-parameter nil 'fullscreen 'fullboth)

Configure emacs to start in fullscreen mode


(require 'magit)

(setq magit-save-repository-buffers 'dontask)
(setq magit-diff-refine-hunk nil)
(setq magit-display-buffer-function 'magit-display-buffer-same-window-except-diff-v1)

(set-face-attribute 'magit-diff-added-highlight nil :foreground "#22aa22")

(add-hook 'magit-log-edit-mode-hook 'turn-on-auto-fill)

(add-hook 'magit-mode-hook
          (lambda ()
            (define-key magit-mode-map (kbd "1") 'magit-section-show-level-1-all)
            (define-key magit-mode-map (kbd "2") 'magit-section-show-level-2-all)
            (define-key magit-mode-map (kbd "3") 'magit-section-show-level-3-all)
            (define-key magit-mode-map (kbd "4") 'magit-section-show-level-4-all)))

(require 'magit)

(setq magit-save-repository-buffers 'dontask)
(setq magit-diff-refine-hunk nil)
(setq magit-display-buffer-function 'magit-display-buffer-same-window-except-diff-v1)

(set-face-attribute 'magit-diff-added-highlight nil :foreground "#22aa22")

(add-hook 'magit-log-edit-mode-hook 'turn-on-auto-fill)

(add-hook 'magit-mode-hook
          (lambda ()
            (define-key magit-mode-map (kbd "C-c C-w") 'magit-diff-toggle-refine-hunk)
            (define-key magit-mode-map (kbd "1") 'magit-section-show-level-1-all)
            (define-key magit-mode-map (kbd "2") 'magit-section-show-level-2-all)
            (define-key magit-mode-map (kbd "3") 'magit-section-show-level-3-all)
            (define-key magit-mode-map (kbd "4") 'magit-section-show-level-4-all)))

Add key to toggle word diff for current diff section


;; 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
 ;; score apropos results by relavance.
 '(apropos-sort-by-scores t)
 ;; show line numbers
 '(global-display-line-numbers-mode t))

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

Remove invalid customization to backup directory


(defun set-exec-path-from-shell-PATH ()
  (let ((path-from-shell (shell-command-to-string "$SHELL --login -i -c 'echo $PATH'")))
    (setenv "PATH" path-from-shell)
    (setq exec-path (split-string path-from-shell path-separator))))

(when *is-a-mac*
  (eval-after-load "woman"
    '(setq woman-manpath (append (list "/opt/local/man") woman-manpath)))

  ;; When started from Emacs.app or similar, ensure $PATH
  ;; is the same the user would see in Terminal.app
  (if window-system (set-exec-path-from-shell-PATH)))

(provide 'init-exec-path)

(defun set-exec-path-from-shell-PATH ()
  (let ((path-from-shell (replace-regexp-in-string
                          "[ \t\n]*$"
                          ""
                          (shell-command-to-string "$SHELL --login -i -c 'echo $PATH'"))))
    (setenv "PATH" path-from-shell)
    (setq exec-path (split-string path-from-shell path-separator))))

(when *is-a-mac*
  (eval-after-load "woman"
    '(setq woman-manpath (append (list "/opt/local/man") woman-manpath)))

  ;; When started from Emacs.app or similar, ensure $PATH
  ;; is the same the user would see in Terminal.app
  (if window-system (set-exec-path-from-shell-PATH)))

(provide 'init-exec-path)

Trim trailing whitespace when querying shell for $PATH


(defconst mfa-neotree-packages '(neotree))

(defun mfa-neotree/post-init-neotree ()
  ;; Bind neotree-find to a key.
  (spacemacs/set-leader-keys "fd" #'neotree-find)

  (with-eval-after-load 'neotree
    ;; Enlarge the NeoTree window.
    (setq neo-window-width 40)

(defconst mfa-neotree-packages '(all-the-icons neotree))

(defun mfa-neotree/init-all-the-icons ()
  (use-package all-the-icons
    :defer t
    :config
    ;; Don't waste valuable window real-estate.
    (setq all-the-icons-scale-factor 1.0)))

(defun mfa-neotree/post-init-neotree ()
  ;; Bind neotree-find to a key.
  (spacemacs/set-leader-keys "fd" #'neotree-find)

  (with-eval-after-load 'neotree

    ;; Make the tree more fancy.
    (setq neo-theme (if window-system 'icons 'arrow))

    ;; Enlarge the NeoTree window.
    (setq neo-window-width 40)))

Add all-the-icons, use it as fancy icon theme for neotree


;;; init-dash.el --- Integrate with the Mac app "Dash" -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:

;; Support for the http://kapeli.com/dash documentation browser

(defun sanityinc/dash-installed-p ()
  "Return t if Dash is installed on this machine, or nil otherwise."
  (let ((lsregister "/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister"))
    (and (file-executable-p lsregister)
         (not (string-equal
               ""
               (shell-command-to-string
                (concat lsregister " -dump|grep com.kapeli.dash")))))))

(when (and *is-a-mac* (not (package-installed-p 'dash-at-point)))
  (message "Checking whether Dash is installed")
  (when (sanityinc/dash-installed-p)
    (require-package 'dash-at-point)))

(when (package-installed-p 'dash-at-point)
  (global-set-key (kbd "C-c D") 'dash-at-point))

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

;;; init-dash.el --- Integrate with the Mac app "Dash" -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:

;; Support for the http://kapeli.com/dash documentation browser

(when *is-a-mac*
  (require-package 'dash-at-point)
  (global-set-key (kbd "C-c D") 'dash-at-point))

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

Install dash-at-point unconditionally on MacOS

Closes #691


;;; init-rust.el --- Support for the Rust language -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:

(when (maybe-require-package 'rust-mode)
  (when (maybe-require-package 'racer)
    (add-hook 'rust-mode-hook #'racer-mode))
  (when (maybe-require-package 'company)
    (add-hook 'racer-mode-hook #'company-mode)))

(when (maybe-require-package 'flycheck-rust)
  (with-eval-after-load 'rust-mode
    (add-hook 'flycheck-mode-hook #'flycheck-rust-setup)))

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

;;; init-rust.el --- Support for the Rust language -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:

(when (maybe-require-package 'rust-mode)
  (when (maybe-require-package 'company)
    (add-hook 'racer-mode-hook #'company-mode)))

(when (maybe-require-package 'flycheck-rust)
  (with-eval-after-load 'rust-mode
    (add-hook 'flycheck-mode-hook #'flycheck-rust-setup)))

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

Drop racer from rust config

Drop racer from rust config

Fixes #806


;; Time-stamp: <2015-02-25 13:45:27 kmodi>

;; Diff-hl
;; https://github.com/dgutov/diff-hl

(use-package diff-hl
    :config
  (progn

    (defvar modi/diff-hl-mode-hooks '(emacs-lisp-mode-hook)
      "List of hooks of major modes in which diff-hl-mode should be enabled.")

    (dolist (hook modi/diff-hl-mode-hooks)
      (add-hook hook #'diff-hl-mode))

    (defhydra hydra-diff-hl (:color red)
      "diff-hl"
      ("="     diff-hl-diff-goto-hunk "goto hunk")
      ("<RET>" diff-hl-diff-goto-hunk "goto hunk")
      ("u"     diff-hl-revert-hunk    "revert hunk")
      ("["     diff-hl-previous-hunk  "prev hunk")
      ("p"     diff-hl-previous-hunk  "prev hunk")
      ("]"     diff-hl-next-hunk      "next hunk")
      ("n"     diff-hl-next-hunk      "next hunk")
      ("q" nil                    "cancel"))
    (bind-key "s-v" #'hydra-diff-hl/body modi-mode-map)

    (add-hook 'dired-mode-hook #'diff-hl-dired-mode)))

(provide 'setup-diff-hl)

;; Time-stamp: <2015-04-13 09:49:32 kmodi>

;; Diff-hl
;; https://github.com/dgutov/diff-hl

(use-package diff-hl
  :config
  (progn

    (defvar modi/diff-hl-mode-hooks '(emacs-lisp-mode-hook
                                      sh-mode-hook)
      "List of hooks of major modes in which diff-hl-mode should be enabled.")

    (dolist (hook modi/diff-hl-mode-hooks)
      (add-hook hook #'diff-hl-mode))

    (defhydra hydra-diff-hl (:color red)
      "diff-hl"
      ("="     diff-hl-diff-goto-hunk "goto hunk")
      ("<RET>" diff-hl-diff-goto-hunk "goto hunk")
      ("u"     diff-hl-revert-hunk    "revert hunk")
      ("["     diff-hl-previous-hunk  "prev hunk")
      ("p"     diff-hl-previous-hunk  "prev hunk")
      ("]"     diff-hl-next-hunk      "next hunk")
      ("n"     diff-hl-next-hunk      "next hunk")
      ("q" nil                    "cancel"))
    (bind-key "s-v" #'hydra-diff-hl/body modi-mode-map)

    (add-hook 'dired-mode-hook #'diff-hl-dired-mode)))

(provide 'setup-diff-hl)

Enable diff-hl for sh-mode files too

Change: Enable diff-hl for sh-mode files too


;;; ar-shell.el --- Shell support.

;;; Commentary:
;; Shell helpers.

(require 'comint)

(defun ar/shell-cd (dir-path)
  "Change shell current working directory to DIR-PATH.

Like shell-pop--cd-to-cwd-shell, but without recentering."
  (unless (string-equal mode-name "Shell")
    (error "Not in Shell mode"))
  (message mode-name)
  (goto-char (point-max))
  (comint-kill-input)
  (insert (concat "cd " (shell-quote-argument dir-path)))
  (let ((comint-process-echoes t))
    (comint-send-input)))

(provide 'ar-shell)

;;; ar-shell.el ends here

;;; ar-shell.el --- Shell support.

;;; Commentary:
;; Shell helpers.

(require 'comint)

(defun ar/shell-cd (dir-path)
  "Change shell current working directory to DIR-PATH.

Like shell-pop--cd-to-cwd-shell, but without recentering."
  (unless (string-equal mode-name "Shell")
    (error "Not in Shell mode"))
  (message mode-name)
  (goto-char (point-max))
  (comint-kill-input)
  (insert (concat "cd " (shell-quote-argument dir-path)))
  (let ((comint-process-echoes t))
    (comint-send-input)))

(defun ar/shell-send-command (command)
  "Send COMMAND to shell mode."
  (assert (string-equal mode-name "Shell") nil "Not in Shell mode")
  (message mode-name)
  (goto-char (point-max))
  (comint-kill-input)
  (insert command)
  (let ((comint-process-echoes t))
    (comint-send-input)))

(provide 'ar-shell)

;;; ar-shell.el ends here

Send command to shell mode

Send command to shell mode


;;; aly-org-config.el --- My configurations for org-mode
;; -*- mode: emacs-lisp -*-
;; vim: set ts=8 sw=2 tw=0 fenc=utf-8 ft=lisp:
;;
;; Aaron LI
;; Created: 2016-05-31
;; Updated: 2016-05-31
;;

;;; Commentary:
;; My custom configurations for the `org' of spacemacs.
;; https://github.com/syl20bnr/spacemacs/blob/master/layers/org/README.org
;;

;;; Code:

;; NOTE:
;; Spacemacs use the `org' from the ELPA instead of the one shipped with
;; Emacs.  Then, any `org'-related code should NOT be loaded before
;; `dotspacemacs/user-config'.
(with-eval-after-load 'org
  (setq org-agenda-files '("~/org/todo.org"
                           "~/org/task.org"
                           "~/org/astro.org"))
  ;; active Babel languages
  (org-babel-do-load-languages
   'org-babel-load-languages
   '((emacs-lisp . t)
     (sh . t)
     (python . t)
     (ditaa . t)
     ))
  ;; set the path to the `ditaa' program
  (setq org-ditaa-jar-path "~/.spacemacs.d/local/ditaa/ditaa.jar")
  )  ;; with-eval-after-load 'org

(provide 'aly-org-config)

;;; aly-org-config.el ends here

;;; aly-org-config.el --- My configurations for org-mode
;; -*- mode: emacs-lisp -*-
;; vim: set ts=8 sw=2 tw=0 fenc=utf-8 ft=lisp:
;;
;; Aaron LI
;; Created: 2016-05-31
;;

;;; Commentary:
;; My custom configurations for the `org' of spacemacs.
;; https://github.com/syl20bnr/spacemacs/blob/master/layers/org/README.org
;;

;;; Code:

;; NOTE:
;; Spacemacs use the `org' from the ELPA instead of the one shipped with
;; Emacs.  Then, any `org'-related code should NOT be loaded before
;; `dotspacemacs/user-config'.
(with-eval-after-load 'org
  (setq org-agenda-files '("~/org"))
  ;; active Babel languages
  (org-babel-do-load-languages
   'org-babel-load-languages
   '((emacs-lisp . t)
     (sh . t)
     (python . t)
     (ditaa . t)
     ))
  ;; set the path to the `ditaa' program
  (setq org-ditaa-jar-path "~/.spacemacs.d/local/ditaa/ditaa.jar")
  )  ;; with-eval-after-load 'org

(provide 'aly-org-config)

;;; aly-org-config.el ends here

_spacemacs: Set "org-agenda-files" to be the "~/org" directory


(require 'prodigy)

(prodigy-define-tag :name 'rails
  :ready-message "Listening on 0\\.0\\.0\\.0:[0-9]+, CTRL\\+C to stop")

(prodigy-define-tag
  :name 'zeus
  :on-output
  (prodigy-callback (service)
    (let ((poll-zeus "ps aux | grep -c 'zeus slave:'"))
      (when (>= (string-to-number (shell-command-to-string poll-zeus)) 6)
        (prodigy-set-status service 'ready)))))

(prodigy-define-tag :name 'resque-pool
  :ready-message "Starting worker")

(prodigy-define-tag :name 'resque-scheduler
  :ready-message "Schedules Loaded")

;; ansi-color-apply and filter were causing out-of-range errors for zeus
(setq prodigy-output-filters (remove 'ansi-color-apply prodigy-output-filters))

(provide 'clgc-prodigy)

(require 'prodigy)

(prodigy-define-tag :name 'rails
  :ready-message "Listening on 0\\.0\\.0\\.0:[0-9]+, CTRL\\+C to stop")

(prodigy-define-tag
  :name 'zeus
  :command "/bin/bash"
  ;; Strip zeus start of color codes to prevent ansi out-of-bound errors
  :args '("-c" "zeus start | sed \"s,\x1B\[[0-9;]*[a-zA-Z],,g\"")
  :stop-signal 'sigkill
  :kill-process-buffer-on-stop t
  :on-output
  (prodigy-callback (service)
    (let ((poll-zeus "ps aux | grep -c 'zeus slave:'"))
      (when (>= (string-to-number (shell-command-to-string poll-zeus)) 6)
        (prodigy-set-status service 'ready)))))

(prodigy-define-tag :name 'resque-pool
  :ready-message "Starting worker")

(prodigy-define-tag :name 'resque-scheduler
  :ready-message "Schedules Loaded")

(provide 'clgc-prodigy)

Fix problems with ansi-escape in zeus start

Moves command into tag. Still has a problem on shutdown but I think it's
in prodigy detecting shutdown correctly, not zeus failing to stop. It
cleans up after itself at any rate.


(use-package company
  :defer 2
  :diminish company-mode
  :config (global-company-mode t))

;; C
(use-package irony
  :defer 2
  :diminish irony-mode
  :config
  (add-hook 'c++-mode-hook 'irony-mode)
  (add-hook 'c-mode-hook 'irony-mode)
  (add-hook 'objc-mode-hook 'irony-mode)
  (add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)

  (add-hook 'c-mode-hook
    (lambda () (local-set-key (kbd "<tab>") #'company-complete)
      (local-set-key (kbd "C-SPC") #'company-complete-selection))))

(use-package company-c-headers
  :defer 2
  :config
  (add-to-list 'company-backends 'company-c-headers))

(use-package company-irony-c-headers
  :defer 2
  :config
  (eval-after-load 'company
    '(add-to-list
       'company-backends '(company-irony-c-headers company-irony))))

(use-package company
  :defer 2
  :diminish company-mode
  :config (global-company-mode t))

;; C
(use-package irony
  :defer 2
  :diminish irony-mode
  :config
  (add-hook 'c++-mode-hook 'irony-mode)
  (add-hook 'c-mode-hook 'irony-mode)
  (add-hook 'objc-mode-hook 'irony-mode)
  (add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)

  (add-hook 'c-mode-hook
    (lambda () (local-set-key (kbd "<tab>") #'company-complete)
      (local-set-key (kbd "C-SPC") #'company-complete-selection))))

(use-package company-irony-c-headers
  :defer 2
  :config
  (eval-after-load 'company
    '(add-to-list
       'company-backends '(company-irony-c-headers company-irony))))

Emacs: Remove company-c-headers and use irony instead


;;; lang/emacs-lisp/+parinfer.el -*- lexical-binding: t; -*-

(def-package! parinfer
  :commands (parinfer-mode)
  :init
  (add-hook! (emacs-lisp-mode
              clojure-mode
              common-lisp-mode
              scheme-mode
              lisp-mode)
    (yas-minor-mode -1)
    (parinfer-mode))
  (setq parinfer-extensions
        '(defaults
           pretty-parens
           smart-tab
           smart-yank))
  (if (featurep! :feature evil)
      (push 'evil parinfer-extensions))
  :config
  (map! :map parinfer-mode-map
        :i "<tab>" #'parinfer-smart-tab:dwim-right
        :i "<backtab>" #'parinfer-smart-tab:dwim-left
        :localleader
        :nv "m" #'parinfer-toggle-mode))

;;; lang/emacs-lisp/+parinfer.el -*- lexical-binding: t; -*-

(def-package! parinfer
  :commands (parinfer-mode)
  :init
  (add-hook! (emacs-lisp-mode
              clojure-mode
              common-lisp-mode
              scheme-mode
              lisp-mode)
    (parinfer-mode))
  (setq parinfer-extensions
        '(defaults
           pretty-parens
           smart-tab
           smart-yank))
  (if (featurep! :feature evil)
      (push 'evil parinfer-extensions))
  :config
  (map! :map parinfer-mode-map
        :i "<tab>" #'parinfer-smart-tab:dwim-right-or-complete
        :i "<backtab>" #'parinfer-smart-tab:dwim-left
        :localleader
        :nv "m" #'parinfer-toggle-mode))

Add yasnippet back to parinfer

Add yasnippet back to parinfer


;;; elfeed-lib.el --- misc functions for elfeed -*- lexical-binding: t; -*-

;; This is free and unencumbered software released into the public domain.

;;; Code:

(defun elfeed-expose (function &rest args)
  "Return an interactive version of FUNCTION, 'exposing' it to the user."
  (lambda () (interactive) (apply function args)))

(defun elfeed-goto-line (n)
  "Like `goto-line' but for non-interactive use."
  (goto-char (point-min))
  (forward-line (1- n)))

(defun elfeed-kill-buffer ()
  "Kill the current buffer."
  (interactive)
  (kill-buffer (current-buffer)))

(provide 'elfeed-lib)

;;; elfeed-lib.el ends here

;;; elfeed-lib.el --- misc functions for elfeed -*- lexical-binding: t; -*-

;; This is free and unencumbered software released into the public domain.

;;; Code:

(defun elfeed-expose (function &rest args)
  "Return an interactive version of FUNCTION, 'exposing' it to the user."
  (lambda () (interactive) (apply function args)))

(defun elfeed-goto-line (n)
  "Like `goto-line' but for non-interactive use."
  (goto-char (point-min))
  (forward-line (1- n)))

(defun elfeed-kill-buffer ()
  "Kill the current buffer."
  (interactive)
  (kill-buffer (current-buffer)))

(defmacro elfeed-save-excursion (&rest body)
  "Like `save-excursion', but by line/column instead of point."
  (declare (indent defun))
  `(let ((line (line-number-at-pos))
         (column (current-column)))
     (unwind-protect
         (progn ,@body)
       (elfeed-goto-line line)
       (move-to-column column))))

(defun elfeed-kill-line ()
  "Clear out the current line without touching anything else."
  (beginning-of-line)
  (let ((start (point)))
    (end-of-line)
    (delete-region start (point))))

(provide 'elfeed-lib)

;;; elfeed-lib.el ends here

Add some lib helper functions.

Add some lib helper functions.


;;;; Fuzzy finding, auto-complete, fast navigation

(require 'projectile) ; projectile => kinda like ctrl-p but not really?
(require 'evil)
(require 'helm-projectile)

(helm-mode t) ; helm is a general matching framework that works on freakin' everything apparently
(helm-projectile-on) ; use helm stuff for projectile
(projectile-global-mode t)
(define-key evil-normal-state-map (kbd "C-p") 'helm-projectile)
(setq projectile-tags-file-name "etags")

(provide 'fuzzy-config)

;;;; Fuzzy finding, auto-complete, fast navigation

(require 'projectile) ; projectile => kinda like ctrl-p but not really?
(require 'evil)
(require 'helm-projectile)

(helm-mode t) ; helm is a general matching framework that works on freakin' everything apparently
(helm-projectile-on) ; use helm stuff for projectile
(projectile-global-mode t)
(define-key evil-normal-state-map (kbd "C-p") 'helm-projectile)
(define-key helm-map (kbd "C-j") 'helm-next-line)
(define-key helm-map (kbd "C-k") 'helm-previous-line)
(setq projectile-tags-file-name "etags")

(provide 'fuzzy-config)

Make helm movement slightly more like ctrlp


;; Time-stamp: <2017-05-04 09:31:53 kmodi>

;; Flycheck
;; https://github.com/flycheck/flycheck

(use-package flycheck
  :defer t
  :config
  (progn
    (defconst modi/flycheck-mode-hooks '(python-mode-hook
                                         sh-mode-hook
                                         nim-mode-hook)
      "List of hooks of major modes in which flycheck mode should be enabled.")

    (defun modi/turn-on-flycheck-mode ()
      "Turn on flycheck-mode for the modes in `modi/flycheck-mode-hooks'."
      (interactive)
      (dolist (hook modi/flycheck-mode-hooks)
        (add-hook hook #'flycheck-mode)))

    (defun modi/turn-off-flycheck-mode ()
      "Turn off flycheck-mode for the modes in `modi/flycheck-mode-hooks'."
      (interactive)
      (dolist (hook modi/flycheck-mode-hooks)
        (remove-hook hook #'flycheck-mode)))

    (modi/turn-on-flycheck-mode)))

(provide 'setup-flycheck)

;; Time-stamp: <2018-05-17 14:44:23 kmodi>

;; Flycheck
;; https://github.com/flycheck/flycheck

(use-package flycheck
  :defer t
  :config
  (progn
    (defconst modi/flycheck-mode-hooks '(python-mode-hook
                                         sh-mode-hook
                                         ;; nim-mode-hook
                                         )
      "List of hooks of major modes in which flycheck mode should be enabled.")

    (defun modi/turn-on-flycheck-mode ()
      "Turn on flycheck-mode for the modes in `modi/flycheck-mode-hooks'."
      (interactive)
      (dolist (hook modi/flycheck-mode-hooks)
        (add-hook hook #'flycheck-mode)))

    (defun modi/turn-off-flycheck-mode ()
      "Turn off flycheck-mode for the modes in `modi/flycheck-mode-hooks'."
      (interactive)
      (dolist (hook modi/flycheck-mode-hooks)
        (remove-hook hook #'flycheck-mode)))

    (modi/turn-on-flycheck-mode)))

(provide 'setup-flycheck)

Disable flycheck for Nim i.e. don't run nimsuggest


;; Time-stamp: <2015-01-14 10:57:34 kmodi>

;; Shell Script Mode

(defun my/tcsh-set-indent-functions ()
  (when (or (string-match ".*\\.alias" (buffer-file-name))
            (string-match ".*\\.setup.*" (buffer-file-name))
            (string-match ".*\\.cfg" (buffer-file-name))
            (string-match ".*csh$" (file-name-extension (buffer-file-name))))
    (require 'csh-mode) ; https://github.com/Tux/tcsh/blob/master/csh-mode.el
    (setq-local indent-line-function   'csh-indent-line)
    (setq-local indent-region-function 'csh-indent-region)))
(add-hook 'sh-set-shell-hook #'my/tcsh-set-indent-functions)

(provide 'setup-shell)

;; Time-stamp: <2015-01-15 13:33:25 kmodi>

;; Shell Script Mode

(defun my/tcsh-set-indent-functions ()
  (when (or (string-match ".*\\.alias" (buffer-file-name))
            (string-match ".*\\.setup.*" (buffer-file-name))
            (string-match ".*\\.gpms" (buffer-file-name))
            (string-match ".*\\.cfg" (buffer-file-name))
            (string-match ".*csh$" (file-name-extension (buffer-file-name))))
    (require 'csh-mode) ; https://github.com/Tux/tcsh/blob/master/csh-mode.el
    (setq-local indent-line-function   'csh-indent-line)
    (setq-local indent-region-function 'csh-indent-region)))
(add-hook 'sh-set-shell-hook #'my/tcsh-set-indent-functions)

(provide 'setup-shell)

Add .gpms as one of the files to be viewed in tcsh mode


;; Org2blog mode
(require 'org2blog-autoloads)

;; Read password
(require 'netrc)
(setq blog (netrc-machine (netrc-parse "~/.netrc") "2014roundtheworld" t))

;; Login details for my round the world blog 2014
(setq org2blog/wp-blog-alist
      '(("2014roundtheworld"
         :url "http://2014roundtheworld.wordpress.com/xmlrpc.php"
         :username (netrc-get blog "login")
         :password (netrc-get blog "password"))))

;; Org2blog mode
(require 'org2blog-autoloads)

;; Read password
(require 'netrc)
(setq blog (netrc-machine (netrc-parse "~/.netrc") "2014roundtheworld" t))

(if (file-exists-p "~/.emacs.org2blog.el")
    (load "~/.emacs.org2blog.el")
  )

;; Example
;; ;; Login details for my round the world blog 2014
;; (setq org2blog/wp-blog-alist
;;       '(("2014roundtheworld"
;;          :url "http://2014roundtheworld.wordpress.com/xmlrpc.php"
;;          :username (netrc-get blog "login")
;;          :password (netrc-get blog "password"))))

Move personal org2blog stuff out to a home dir file.


(use-package irony
  :ensure t
  :config
  (add-hook 'c++-mode-hook 'irony-mode)
  (add-hook 'c-mode-hook 'irony-mode)
  (add-hook 'objc-mode-hook 'irony-mode)
  )

;; replace the `completion-at-point' and `complete-symbol' bindings in
;; irony-mode's buffers by irony-mode's function
(defun my-irony-mode-hook ()
  (define-key irony-mode-map [remap completion-at-point]
    'irony-completion-at-point-async)
  (define-key irony-mode-map [remap complete-symbol]
    'irony-completion-at-point-async))

(use-package company-irony
  :ensure t
  :config
  (add-to-list 'company-backends '(company-irony))
  (add-hook 'irony-mode-hook 'company-irony-setup-begin-commands)
  (add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
  (add-hook 'irony-mode-hook 'my-irony-mode-hook)
  )

(use-package company-irony-c-headers
  :ensure t
  :config (add-to-list 'company-backends '(company-irony-c-headers))
  )

(use-package irony-eldoc
  :ensure t
  (add-hook 'irony-mode-hook 'irony-eldoc)
  )

(provide 'setup-irony)

(use-package irony
  :ensure t
  :config
  (add-hook 'c++-mode-hook 'irony-mode)
  (add-hook 'c-mode-hook 'irony-mode)
  (add-hook 'objc-mode-hook 'irony-mode)
  )

;; replace the `completion-at-point' and `complete-symbol' bindings in
;; irony-mode's buffers by irony-mode's function
(defun my-irony-mode-hook ()
  (define-key irony-mode-map [remap completion-at-point]
    'irony-completion-at-point-async)
  (define-key irony-mode-map [remap complete-symbol]
    'irony-completion-at-point-async))

(use-package company-irony
  :ensure t
  :config
  (add-to-list 'company-backends '(company-irony))
  (add-hook 'irony-mode-hook 'company-irony-setup-begin-commands)
  (add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
  (add-hook 'irony-mode-hook 'my-irony-mode-hook)
  )

(use-package company-irony-c-headers
  :ensure t
  :config (add-to-list 'company-backends '(company-irony-c-headers))
  )

(use-package irony-eldoc
  :ensure t
  :config
  (add-hook 'irony-mode-hook 'irony-eldoc)
  )

(provide 'setup-irony)

Fix emacs config error with use-package

Fix emacs config error with use-package


(require-package 'company)
(require 'company)

(setq company-idle-delay 0.1)
(setq company-minimum-prefix-length 1)
(setq company-tooltip-limit 20)

(add-hook 'after-init-hook 'global-company-mode)

(provide 'init-company-mode)

(require-package 'company)
(require 'company)

(setq company-idle-delay 0.1)
(setq company-minimum-prefix-length 1)
(setq company-tooltip-limit 20)
(setq company-global-modes
      '(not
        eshell-mode))

(add-hook 'after-init-hook 'global-company-mode)

(provide 'init-company-mode)

Disable company mode on eshell

Emacs: Disable company mode on eshell


;;; init-javascript.el -- javascript setup

;;; Commentary:
;;; js2 mode setup and related stuff

;;; Code:
(require 'use-package)

(use-package js2-mode
  :config
  (setq js-indent-level 2)
  :mode ("\\.js\\'" . js2-mode)
  :init
  (add-hook 'js2-mode-hook #'tern-mode)
  (add-hook 'js2-mode-hook #'js2-refactor-mode)
  :interpreter ("node" . js2-mode))

(use-package tern
  :commands (tern-mode)
  :config
  (use-package company-tern)
  (add-to-list 'company-backends 'company-tern))

(use-package js2-refactor
  :config
  (js2r-add-keybindings-with-prefix "C-c C-r")
  :commands (js2-refactor-mode)
  :diminish js2-refactor-mode)

(use-package json-mode
  :commands (json-mode)
  :config
  (setq js-indent-level 2
        json-reformat:indent-width 2)
  :init
  (add-to-list 'auto-mode-alist '("\\.tern-project\\'" . json-mode))
  :mode "\\.json'")

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

;;; init-javascript.el -- javascript setup

;;; Commentary:
;;; js2 mode setup and related stuff

;;; Code:
(require 'use-package)

(use-package js2-mode
  :config
  (setq js-indent-level 2
        js2-global-externs '("module" "require" "setTimeout" "clearTimeout"
                             "setInterval" "clearInterval" "location"
                             "__dirname" "console" "JSON")
        js2-idle-timer-delay 0.1
        js2-concat-multiline-strings 'eol
        js2-mode-show-strict-warnings nil
        js2-mode-show-parse-errors nil)
  :mode ("\\.js\\'" . js2-mode)
  :init
  (add-hook 'js2-mode-hook #'tern-mode)
  (add-hook 'js2-mode-hook #'js2-refactor-mode)
  :interpreter ("node" . js2-mode))

(use-package tern
  :commands (tern-mode)
  :config
  (use-package company-tern)
  (add-to-list 'company-backends 'company-tern))

(use-package js2-refactor
  :config
  (js2r-add-keybindings-with-prefix "C-c C-r")
  :commands (js2-refactor-mode)
  :diminish js2-refactor-mode)

(use-package json-mode
  :commands (json-mode)
  :config
  (setq js-indent-level 2
        json-reformat:indent-width 2)
  :init
  (add-to-list 'auto-mode-alist '("\\.tern-project\\'" . json-mode))
  :mode "\\.json'")

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

Add some tweaks to js2-mode

Add some tweaks to js2-mode


((nil . ((compilation-directory . "/home/vava/area9/neko/")
		 (compilation-command . "rake"))
 ))

((c++-mode . ((compilation-directory . "/home/vava/area9/neko/")
		 (compilation-command . "rake"))
 ))

Make sure we turn it on only for cpp files


;;; lang/java/+lsp.el -*- lexical-binding: t; -*-
;;;###if (featurep! +lsp)

;;;###autoload
(defun +java/update-lsp-server ()
  (interactive)
  (lsp--install-server-internal (gethash 'jdtls lsp-clients) t))

(add-hook! java-mode-local-vars #'lsp!)
(map! :map java-mode-map
      :localleader
      :desc "Update the Eclipse LSP server" "U" #'+java/update-lsp-server)

(use-package! lsp-java
  :after (lsp-clients dap-mode)
  :preface
  (setq lsp-java-server-install-dir (concat doom-etc-dir "eclipse.jdt.ls/server/")
        lsp-java-workspace-dir (concat doom-etc-dir "java-workspace")))

;;; lang/java/+lsp.el -*- lexical-binding: t; -*-
;;;###if (featurep! +lsp)

(use-package! lsp-java
  :after (lsp-clients dap-mode)
  :preface
  (setq lsp-java-server-install-dir (concat doom-etc-dir "eclipse.jdt.ls/server/")
        lsp-java-workspace-dir (concat doom-etc-dir "java-workspace"))
  (add-hook! java-mode-local-vars #'lsp!)
  :config
  ;; TODO keybinds
  )

Move hook into use-package, remove update-lsp-server


;;; shm-reformat.el ---

;; Copyright (c) 2014 Chris Done. All rights reserved.

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.

;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

;;; Code:

(require 'shm-ast)
(require 'hindent)

(defun shm-reformat-decl ()
  "Reformat the current declaration with `hindent/reformat-decl'
and then jump back to the right node."
  (interactive)
  (let* ((current-pair (shm-current-node-pair))
         (index (car current-pair))
         (offset (- (point) (shm-node-start (cdr current-pair)))))
    (structured-haskell-mode -1)
    (hindent/reformat-decl)
    (structured-haskell-mode 1)
    (shm/reparse)
    (let ((new-current (elt (shm-decl-ast) index)))
      (goto-char (+ (shm-node-start new-current) offset)))))

(provide 'shm-reformat)

;;; shm-reformat.el ---

;; Copyright (c) 2014 Chris Done. All rights reserved.

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.

;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

;;; Code:

(require 'shm-ast)
(require 'hindent)

(defun shm-reformat-decl ()
  "Reformat the current declaration with `hindent/reformat-decl'
and then jump back to the right node."
  (interactive)
  (if (region-active-p)
      (call-interactively 'hindent-reformat-region)
      (let* ((current-pair (shm-current-node-pair))
         (index (car current-pair))
         (offset (- (point) (shm-node-start (cdr current-pair)))))
    (structured-haskell-mode -1)
    (hindent/reformat-decl)
    (structured-haskell-mode 1)
    (shm/reparse)
    (let ((new-current (elt (shm-decl-ast) index)))
      (goto-char (+ (shm-node-start new-current) offset))))))

(provide 'shm-reformat)

Support only reformatting the selected node


(require 'org)

;; Make windmove work in org-mode:
(add-hook 'org-shiftup-final-hook 'windmove-up)
(add-hook 'org-shiftleft-final-hook 'windmove-left)
(add-hook 'org-shiftdown-final-hook 'windmove-down)
(add-hook 'org-shiftright-final-hook 'windmove-right)

(add-hook 'org-mode-hook 'turn-on-visual-line-mode)

(setq org-completion-use-ido t)

(provide 'clgc-org)

(require 'org)

;; Make windmove work in org-mode:
(add-hook 'org-shiftup-final-hook 'windmove-up)
(add-hook 'org-shiftleft-final-hook 'windmove-left)
(add-hook 'org-shiftdown-final-hook 'windmove-down)
(add-hook 'org-shiftright-final-hook 'windmove-right)

(add-hook 'org-mode-hook 'turn-on-visual-line-mode)

(setq org-directory (expand-file-name "~/Dropbox/org")
      org-default-notes-file (expand-file-name "incoming.org" org-directory)
      org-completion-use-ido t
      org-return-follows-link t
      org-log-done t)

(provide 'clgc-org)

Enable org capture, following links, etc


(use-package popwin
  :init
  (progn
    (popwin-mode 1)
    (push '("*grep*" :dedicated t :position bottom :stick t :noselect t) popwin:special-display-config)
    ;; use popwin with helm
    (push '("^\*helm.+\*$" :regexp t :position bottom) popwin:special-display-config)
    (push '("^\*helm-.+\*$" :regexp t :position bottom) popwin:special-display-config)))

(use-package popwin
  :init
  (progn
    (popwin-mode 1)
    (push '("*grep*"                     :dedicated t :position bottom :stick t :noselect t) popwin:special-display-config)
    (push '("^\*Flycheck.+\*$" :regexp t :dedicated t :position bottom :stick t :noselect t) popwin:special-display-config)
    (push '("^\*helm.+\*$"     :regexp t              :position bottom) popwin:special-display-config)
    (push '("^\*helm-.+\*$"    :regexp t              :position bottom) popwin:special-display-config)))

Make flycheck error window a popup window


;; Enable EditorConfig mode
(editorconfig-mode +1)

(provide 'editorconfig-c)

;; Enable EditorConfig mode
(editorconfig-mode +1)

(defun kotct/editorconfig--disable-smart-tabs-if-indent-tabs-mode-disabled (&optional hash)
  "Disables `smart-tabs-mode' if `indent-tabs-mode' is non-truthy."
  (if (not indent-tabs-mode)
      (progn
        (smart-tabs-mode -1))))

(add-hook 'editorconfig-custom-hooks 'kotct/editorconfig--disable-smart-tabs-if-indent-tabs-mode-disabled)

(provide 'editorconfig-c)

Disable Smart Tabs if indent-tabs-mode is disabled by editorconfig

This new function is run as an EditorConfig custom hook, so it only
takes place in situations where EditorConfig can be loaded.


; Evil Leader

(require 'evil-leader)
(require 'evil-nerd-commenter)

(global-evil-leader-mode)

(evil-leader/set-leader ",")
(evil-leader/set-key
    "b" 'ibuffer
    "q" 'delete-window
    "tt" 'save-buffer
    "k" 'kill-buffer-and-window)

(evil-leader/set-key
    "full" 'toggle-frame-fullscreen)

; Nerd-Commenter
(evil-leader/set-key
    "comm" 'evilnc-comment-or-uncomment-lines)

(provide 'init-evil-leader)

; Evil Leader

(require 'evil-leader)
(require 'evil-nerd-commenter)

(global-evil-leader-mode)

(evil-leader/set-leader ",")
(evil-leader/set-key
    "b" 'ibuffer
    "q" 'delete-window
    "tt" 'save-buffer
    "k" 'kill-buffer-and-window
    "m" 'right-char
    "," 'insert-comma)

(evil-leader/set-key
    "full" 'toggle-frame-fullscreen)

; Nerd-Commenter
(evil-leader/set-key
    "comm" 'evilnc-comment-or-uncomment-lines)

; Mail
(evil-leader/set-key
    "email" 'mu4e
    "fetch" 'mu4e-get-mail-command)

; Allows me to actually type a comma...TODO ability to do this in insert mode.
(defun insert-comma ()
    (interactive)
    (insert ","))

(provide 'init-evil-leader)

Add ability to type , in emacs

Add ability to type , in emacs


;;; init.el -*- lexical-binding: t; -*-

(doom!
 :completion
 ivy
 (company +auto)

 :ui
 doom
 modeline
 ophints
 hl-todo
 nav-flash
 neotree
 (popup +all +defaults)
 (pretty-code +fira)
 vc-gutter
 vi-tilde-fringe
 window-select
 hydra

 :editor
 (evil +everywhere +commands)
 snippets
 file-templates
 multiple-cursors
 rotate-text
 fold

 :emacs
 (dired +icons)
 electric
 vc

 :tools
 (lookup +docsets)
 eval
 make
 magit
 lsp
 editorconfig
 flyspell
 flycheck
 ein

 :lang
 agda
 (sh +fish)
 emacs-lisp
 markdown
 (csharp +unity)
 (haskell +lsp)
 (org
  +attach
  +babel
  +export
  +present)
 (cc +lsp)
 ocaml
 idris
 (web +html +css)
 (latex +latexmk)

 :term
 vterm
 eshell

 :app
 ;;(email +gmail)    ; emacs as an email client
 ;;(rss +org)        ; emacs as an RSS reader
 (write            ; emacs as a word processor (latex + org + markdown)
 +wordnut         ; wordnet (wn) search
 +langtool)       ; a proofreader (grammar/style check) for Emacs

 :collab
 ;;floobits          ; peer programming for a price
 ;;impatient-mode    ; show off code over HTTP

 :config
 (default)
 ;;literate
 )

;;; init.el -*- lexical-binding: t; -*-

(doom!
 :completion
 ivy
 (company +auto)

 :ui
 doom
 modeline
 ophints
 hl-todo
 nav-flash
 neotree
 (popup +all +defaults)
 (pretty-code +fira)
 vc-gutter
 vi-tilde-fringe
 window-select
 hydra

 :editor
 (evil +everywhere +commands)
 snippets
 file-templates
 multiple-cursors
 rotate-text
 fold

 :emacs
 (dired +icons)
 electric
 vc

 :tools
 (lookup +docsets)
 eval
 make
 magit
 lsp
 editorconfig
 flyspell
 flycheck
 pdf
 ein

 :lang
 agda
 (sh +fish)
 emacs-lisp
 markdown
 (csharp +unity)
 (haskell +lsp)
 (org
  +attach
  +babel
  +export
  +present)
 (cc +lsp)
 ocaml
 idris
 (web +html +css)
 (latex +latexmk)

 :term
 vterm
 eshell

 :app
 ;;(email +gmail)    ; emacs as an email client
 ;;(rss +org)        ; emacs as an RSS reader
 (write            ; emacs as a word processor (latex + org + markdown)
 +wordnut         ; wordnet (wn) search
 +langtool)       ; a proofreader (grammar/style check) for Emacs

 :collab
 ;;floobits          ; peer programming for a price
 ;;impatient-mode    ; show off code over HTTP

 :config
 (default)
 ;;literate
 )

Enable :tools pdf in doom

Enable :tools pdf in doom


;;; nix-mode-conf.el --- Settings for nix-mode
;;
;;; Commentary:
;;
;;; Code:

(require 'nix-mode)
(require 'reformatter)

(custom-set-variables
 '(nix-indent-function #'smie-indent-line))

(reformatter-define nix-format
  :program "nixpkgs-fmt"
  :group 'nix-mode)

(defun pjones:nix-mode-hook ()
  "Configure `nix-mode'."
  (pjones:prog-mode-hook)
  (electric-indent-local-mode)
  (nix-format-on-save-mode))

(define-key nix-mode-map (kbd "<return>") #'newline-and-indent)
(add-hook 'nix-mode-hook #'pjones:nix-mode-hook)

;;; nix-mode-conf.el ends here

;;; nix-mode-conf.el --- Settings for nix-mode
;;
;;; Commentary:
;;
;;; Code:

(require 'nix-mode)
(require 'reformatter)

(declare-function pjones:prog-mode-hook "../lisp/code.el")

(custom-set-variables
 '(nix-indent-function #'smie-indent-line)
 '(nix-mode-use-smie t))

(reformatter-define nix-format
  :program "nixpkgs-fmt"
  :group 'nix-mode)

(defun pjones:nix-mode-hook ()
  "Configure `nix-mode'."
  (pjones:prog-mode-hook)
  (nix-format-on-save-mode))

(define-key nix-mode-map (kbd "<return>") #'newline-and-indent)
(add-hook 'nix-mode-hook #'pjones:nix-mode-hook)

;;; nix-mode-conf.el ends here

nix: Clean up this file, make it clear which indentation function is used


;; Use C-f during file selection to switch to regular find-file
(ido-mode t)  ; use 'buffer rather than t to use only buffer switching
(ido-everywhere t)
(ido-ubiquitous t)
(setq ido-enable-flex-matching t)
(setq ido-use-filename-at-point nil)
(setq ido-auto-merge-work-directories-length 0)
(setq ido-use-virtual-buffers t)

;; Allow the same buffer to be open in different frames
(setq ido-default-buffer-method 'selected-window)

(defun steve-ido-choose-from-recentf ()
  "Use ido to select a recently opened file from the `recentf-list'"
  (interactive)
  (if (and ido-use-virtual-buffers (fboundp 'ido-toggle-virtual-buffers))
      (ido-switch-buffer)
    (find-file (ido-completing-read "Open file: " recentf-list nil t))))

(global-set-key [(meta f11)] 'steve-ido-choose-from-recentf)

;;----------------------------------------------------------------------------
;; ido completion in M-x
;;----------------------------------------------------------------------------
(smex-initialize)
(global-set-key "\M-x" 'smex)

(provide 'init-ido)

;; Use C-f during file selection to switch to regular find-file
(ido-mode t)  ; use 'buffer rather than t to use only buffer switching
(ido-everywhere t)
(ido-ubiquitous-mode t)
(setq ido-enable-flex-matching t)
(setq ido-use-filename-at-point nil)
(setq ido-auto-merge-work-directories-length 0)
(setq ido-use-virtual-buffers t)

;; Allow the same buffer to be open in different frames
(setq ido-default-buffer-method 'selected-window)

(defun steve-ido-choose-from-recentf ()
  "Use ido to select a recently opened file from the `recentf-list'"
  (interactive)
  (if (and ido-use-virtual-buffers (fboundp 'ido-toggle-virtual-buffers))
      (ido-switch-buffer)
    (find-file (ido-completing-read "Open file: " recentf-list nil t))))

(global-set-key [(meta f11)] 'steve-ido-choose-from-recentf)

;;----------------------------------------------------------------------------
;; ido completion in M-x
;;----------------------------------------------------------------------------
(smex-initialize)
(global-set-key "\M-x" 'smex)

(provide 'init-ido)

Use 'ido-ubiquitous-mode in place of deprecated 'ido-ubiquitous


;;; ar-helm-projectile.el --- Helm projectile support.

;;; Commentary:
;; Helm projectile helpers.

;;; Code:

(require 'ar-shell)
(require 'cl)
(require 'helm-projectile)
(require 'esh-mode)

(defun ar/helm-projectile-shell-cd ()
  "Change shell current working directory using helm projectile."
  (interactive)
  (assert (or (string-equal mode-name "EShell")
              (string-equal mode-name "Shell")) nil "Not in (E)Shell mode")
  (let ((helm-dir-source (copy-tree  helm-source-projectile-directories-list)))
    (add-to-list 'helm-dir-source (cons 'action (if (string-equal mode-name "EShell")
                                                    (lambda (path)
                                                      (insert (format "cd %s" path))
                                                      (eshell-send-input))
                                                    'ar/shell-cd)))
    (add-to-list 'helm-dir-source '(keymap . nil))
    (add-to-list 'helm-dir-source '(header-line . "cd to directory..."))
    (helm :sources helm-dir-source
          :buffer "*helm-dirs*"
          :candidate-number-limit 10000)))

(provide 'ar-helm-projectile)

;;; ar-helm-projectile.el ends here

;;; ar-helm-projectile.el --- Helm projectile support.

;;; Commentary:
;; Helm projectile helpers.

;;; Code:

(require 'ar-shell)
(require 'cl)
(require 'helm-projectile)
(require 'esh-mode)

(defun ar/helm-projectile-shell-cd ()
  "Change shell current working directory using helm projectile."
  (interactive)
  (assert (or (equal major-mode 'eshell-mode)
              (equal major-mode 'shell-mode)) nil "Not in (E)Shell mode")
  (let ((helm-dir-source (copy-tree  helm-source-projectile-directories-list)))
    (add-to-list 'helm-dir-source (cons 'action (if (string-equal mode-name "EShell")
                                                    (lambda (path)
                                                      (insert (format "cd %s" path))
                                                      (eshell-send-input))
                                                  'ar/shell-cd)))
    (add-to-list 'helm-dir-source '(keymap . nil))
    (add-to-list 'helm-dir-source '(header-line . "cd to directory..."))
    (helm :sources helm-dir-source
          :buffer "*helm-dirs*"
          :candidate-number-limit 10000)))

(provide 'ar-helm-projectile)

;;; ar-helm-projectile.el ends here

Use major-mode when checking for shell (instead of mode-name)


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

(require-package 'which-key)

(which-key-mode)

(provide 'init-which-key)

;; init-which-key.el --- Which Key setup

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

;;; Code:
(use-package which-key
  :diminish which-key-mode
  :init
  (which-key-mode))

(provide 'init-which-key)
;;; init-which-key ends here

Update which-key configuration to use use-package


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

(defvar dtrt-indent-mode-whitelist '(prog-mode text-mode)
  "A list of major modes in which to enable `dtrt-indent' mode.

Also see `dtrt-indent-mode-blacklist'.")

(defvar dtrt-indent-mode-blacklist '()
  "A list of major modes in which not to enable the `dtrt-indent' minor mode.

The blacklist takes precedence over the whitelist. `dtrt-indent' mode will be
enabled in all modes listed in `dtrt-indent-mode-whitelist' as well as modes
derived from them, except in modes listed in `dtrt-indent-mode-blacklist' or
modes derived from them.")

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

(defvar dtrt-indent-mode-whitelist '(conf-mode prog-mode text-mode)
  "A list of major modes in which to enable `dtrt-indent' mode.

Also see `dtrt-indent-mode-blacklist'.")

(defvar dtrt-indent-mode-blacklist '()
  "A list of major modes in which not to enable the `dtrt-indent' minor mode.

The blacklist takes precedence over the whitelist. `dtrt-indent' mode will be
enabled in all modes listed in `dtrt-indent-mode-whitelist' as well as modes
derived from them, except in modes listed in `dtrt-indent-mode-blacklist' or
modes derived from them.")

Enable dtrt-indent in conf-mode as well

Enable dtrt-indent in conf-mode as well


(use-package auto-highlight-symbol
  :commands auto-highlight-symbol-mode
  :init
  (add-to-hooks
   'auto-highlight-symbol-mode '(prog-mode-hook
                                 erlang-mode-hook
                                 org-mode-hook
                                 ))
  :config
  (custom-set-variables
   '(ahs-case-fold-search nil)
   '(ahs-default-range (quote ahs-range-whole-buffer))
   '(ahs-idle-interval 0.5)))

(use-package auto-highlight-symbol
  :commands auto-highlight-symbol-mode
  :init
  (add-to-hooks
   'auto-highlight-symbol-mode '(erlang-mode-hook
                                 prog-mode-hook
                                 org-mode-hook
                                 markdown-mode-hook
                                 ))
  :config
  (custom-set-variables
   '(ahs-case-fold-search nil)
   '(ahs-default-range (quote ahs-range-whole-buffer))
   '(ahs-idle-interval 0.5)))

Add auto highlight symbol mode to markdown mode hook


(set-face-foreground 'mode-line "black")
(set-face-background 'mode-line "purple")
(set-face-background 'mode-line-inactive "blue")
(set-face-background 'modeline-inactive "red")

;; (set-face-foreground 'mode-line "black")
;; (set-face-background 'mode-line "purple")
;; (set-face-background 'mode-line-inactive "blue")
;; (set-face-background 'modeline-inactive "red")

;; (load-theme 'hipster)

Add some color settings ehoch are currently disabled


;;; lang/emacs-lisp/+parinfer.el -*- lexical-binding: t; -*-

(def-package! parinfer
  :commands (parinfer-mode)
  :init
  (add-hook! (emacs-lisp-mode
              clojure-mode
              common-lisp-mode
              scheme-mode
              lisp-mode)
    (yas-minor-mode -1)
    (parinfer-mode))
  (setq parinfer-extensions
        '(defaults
           pretty-parens
           smart-tab
           smart-yank))
  (if (featurep! :feature evil)
      (push 'evil parinfer-extensions))
  :config
  (map! :map emacs-lisp-mode-map
        :i "<tab>" #'parinfer-smart-tab:dwim-right
        :i "<backtab>" #'parinfer-smart-tab:dwim-left
        :localleader
        :nv "m" #'parinfer-toggle-mode))

;;; lang/emacs-lisp/+parinfer.el -*- lexical-binding: t; -*-

(def-package! parinfer
  :commands (parinfer-mode)
  :init
  (add-hook! (emacs-lisp-mode
              clojure-mode
              common-lisp-mode
              scheme-mode
              lisp-mode)
    (yas-minor-mode -1)
    (parinfer-mode))
  (setq parinfer-extensions
        '(defaults
           pretty-parens
           smart-tab
           smart-yank))
  (if (featurep! :feature evil)
      (push 'evil parinfer-extensions))
  :config
  (map! :map parinfer-mode-map
        :i "<tab>" #'parinfer-smart-tab:dwim-right
        :i "<backtab>" #'parinfer-smart-tab:dwim-left
        :localleader
        :nv "m" #'parinfer-toggle-mode))

Swap from emacs-lisp-mode-map to parinfer-mode-map


;;; org-cfg.el --- Note taking and todo list (builtin package)
;;; Commentary:
;;; Code:

(use-package org
  :config
  (setq org-completion-use-ido t)

  (setq org-todo-keywords '("TODO" "WAITING" "NEVER" "DONE"))

  (setq org-startup-folded nil      ; Headings are unfolded when file is opened
        org-startup-indented t      ; Display sections/outlines indented
        org-startup-truncated nil)  ; Wrap long lines instead of truncating

  (setq org-M-RET-may-split-line nil))  ; Make new heading after current heading

(require 'evil-core)
(use-package evil-org
  :config
  ;; Unbind some evil keys that evil-org overrides
  (evil-define-key 'normal evil-org-mode-map
    "g j" nil
    "g k" nil
    "o" nil
    "O" nil
    "J" nil
    "K" nil)

  ;; Now bind our own keys
  (evil-define-key 'normal evil-org-mode-map
    "[" 'outline-previous-visible-heading
    "]" 'outline-next-visible-heading))

(provide 'org-cfg)

;;; org-cfg.el ends here

;;; org-cfg.el --- Note taking and todo list (builtin package)
;;; Commentary:
;;; Code:

(use-package org
  :config
  (setq org-completion-use-ido t)

  (setq org-startup-folded nil      ; Headings are unfolded when file is opened
        org-startup-indented t      ; Display sections/outlines indented
        org-startup-truncated nil)  ; Wrap long lines instead of truncating

  (setq org-pretty-entities t)

  (setq org-M-RET-may-split-line nil))  ; Make new heading after current heading

(require 'evil-core)
(use-package evil-org
  :config
  ;; Unbind some evil keys that evil-org overrides
  (evil-define-key 'normal evil-org-mode-map
    "g j" nil
    "g k" nil
    "o" nil
    "O" nil
    "J" nil
    "K" nil)

  ;; Now bind our own keys
  (evil-define-key 'normal evil-org-mode-map
    "[" 'outline-previous-visible-heading
    "]" 'outline-next-visible-heading))

(provide 'org-cfg)

;;; org-cfg.el ends here

Make minor updates to org-mode config

Make minor updates to org-mode config


(require 'todochiku) ;; growl notifications when compilation finishes
(setq todochiku-icons-directory (expand-file-name "~/.emacs.d/site-lisp/todochiku-icons"))

(provide 'init-growl)

(require 'todochiku) ;; growl notifications when compilation finishes
(setq todochiku-icons-directory (expand-file-name "~/.emacs.d/site-lisp/todochiku-icons"))

;;----------------------------------------------------------------------------
;; Use terminal-notifier in OS X Mountain Lion
;; https://github.com/alloy/terminal-notifier (Install in /Applications)
;;----------------------------------------------------------------------------
(setq terminal-notifier-path
      "/Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier")

(defadvice todochiku-get-arguments (around todochiku-nc)
  (setq ad-return-value
        (list "-title" title "-message" message "-activate" "org.gnu.Emacs")))

(when (file-executable-p terminal-notifier-path)
  (setq todochiku-command terminal-notifier-path)
  (ad-activate 'todochiku-get-arguments))

(provide 'init-growl)

Add support for "Notification Center" in OS X Mountain Lion using terminal-notifier


;;; Package --- Summary:

;;; Summary:

;;; Commentary:

;;; Code:
(defvar mocha-command "mocha")

(defvar mocha-environment-variables nil)

(defvar mocha-reporter "dot")

(defvar mocha-options nil)

(defvar mocha-project-test-directory nil)

(defun mocha-test-project ()
  "Test the current project."
  nil)

(defun mocha-test-file ()
  "Test the current file."
  nil)

(defun mocha-test-at-point ()
  "Test the current innermost 'it' or 'describe' or the file if none is found."
  nil)

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

;;; mocha.el --- Mocha testing for Emacs:

;; Copyright (C) 2016 Al Scott <github.com/scottaj>
;; Author: Al Scott
;; URL: http://github.com/pezra/scottaj/mocha-mode
;; Created: 2016
;; Version: 0.1
;; Keywords: javascript mocha jasmine
;; Package-Requires: ()

;; This file is NOT part of GNU Emacs.
;;
;;; Commentary:
;;
;; This mode provides the ability to run Mocha or Jasmine tests from within Emacs

;;; Code:
(defvar mocha-which-node "node")

(defvar mocha-command "mocha")

(defvar mocha-environment-variables nil)

(defvar mocha-options nil)

(defvar mocha-project-test-directory nil)

(defun mocha-command ()
  "The test command to run."
  (concat mocha-environment-variables " " mocha-which-node " " mocha-command " " mocha-options " " mocha-project-test-directory))

(defun mocha-test-project ()
  "Test the current project."
  (interactive)
  (compile (mocha-command)))

(defun mocha-test-file ()
  "Test the current file."
  (interactive)
  nil)

(defun mocha-test-at-point ()
  "Test the current innermost 'it' or 'describe' or the file if none is found."
  (interactive)
  nil)

(provide 'mocha-mode)
;;; mocha.el ends here

Add ability to run tests on whole directory.


(autoload 'doctest-mode "doctest-mode" "Python doctest editing mode." t)

(setq auto-mode-alist
      (append '(("SConstruct\\'" . python-mode)
		("SConscript\\'" . python-mode))
              auto-mode-alist))

;;----------------------------------------------------------------------------
;; On-the-fly syntax checking via flymake
;;----------------------------------------------------------------------------
(require-package 'flymake-python-pyflakes)
(add-hook 'python-mode-hook 'flymake-python-pyflakes-load)

(provide 'init-python-mode)

Remove defunct autoload for doctest-mode


((sh-mode .  ((indent-tabs-mode . nil)
              (sh-indentation   . 2)
              (sh-basic-offset  . 2))))

((sh-mode .  ((indent-tabs-mode . nil)
              (sh-indentation   . 2)
              (sh-basic-offset  . 2)))
 (c-mode .   ((indent-tabs-mode . nil)
              (c-basic-offset . 2))))

Add Emacs configuration for C

Add Emacs configuration for C


(TeX-add-style-hook "documentation"
 (lambda ()
    (LaTeX-add-environments
     "theorem"
     "lemma"
     "example"
     "remark")
    (LaTeX-add-labels
     "chap:requirements")
    (TeX-run-style-hooks
     "amssymb"
     "amsmath"
     "latex2e"
     "rep10"
     "report"
     "a4paper")))

(TeX-add-style-hook "documentation"
 (lambda ()
    (LaTeX-add-environments
     "theorem"
     "lemma"
     "example"
     "remark")
    (LaTeX-add-labels
     "chap:requirements")
    (TeX-run-style-hooks
     "amssymb"
     "amsmath"
     "microtype"
     "charter"
     "fontenc"
     "T1"
     "latex2e"
     "memoir10"
     "memoir"
     "a4paper")))

Update tex helper emacs .el's

Update tex helper emacs .el's


;; Time-stamp: <2013-12-02 17:08:32 kmodi>

;; Visual Regular Expression search/replace

(require 'visual-regexp)

;;

(setq setup-visual-regexp-loaded t)
(provide 'setup-visual-regexp)

;; Time-stamp: <2014-04-07 10:08:55 kmodi>

;; Visual Regular Expression search/replace

(require 'visual-regexp)
(require 'visual-regexp-steroids)

;;

(setq setup-visual-regexp-loaded t)
(provide 'setup-visual-regexp)

Use visual_regexp_steroids to be able to use non-escaped regex when do regex search(/replace)


;;; js-programming.el --- Javascript programming relevant stuff.
;;; Commentary:
;;; Code:

(use-package js2-mode
  :ensure t
  :pin gnu
  :commands (js2-mode js2-jsx-mode)
  :mode (("\\.js\\'" . js2-mode)
         ("\\.jsx?\\'" . js2-jsx-mode))
  :config
  (add-to-list 'interpreter-mode-alist '("node" . js2-jsx-mode)))

(use-package tern
  :ensure t
  :config
  (add-hook 'js2-mode-hook (lambda () (tern-mode t))))

(use-package company-tern
  :ensure t
  :after (company tern js2-mode)
  :config
  (defun my/add-tern-company ()
    (setq-local company-backends company-backends)
    (add-to-list 'company-backends 'company-tern))
  (add-hook 'js2-mode-hook #'my/add-tern-company))

;; Been using this one for work lately
(use-package json-reformat
  :ensure t)

(provide 'js-programming)
;;; js-programming.el ends here

;;; js-programming.el --- Javascript programming relevant stuff.
;;; Commentary:
;;; Code:

(use-package js2-mode
  :ensure t
  :pin gnu
  :commands (js2-mode js2-jsx-mode)
  :mode (("\\.js\\'" . js2-mode)
         ("\\.jsx?\\'" . js2-jsx-mode))
  :config
  (setq js2-basic-offset 2)
  (setq-default js2-mode-show-parse-errors nil
                js2-mode-show-strict-warnings nil)
  (add-to-list 'interpreter-mode-alist '("node" . js2-jsx-mode)))

(use-package tern
  :ensure t
  :config
  (add-hook 'js2-mode-hook (lambda () (tern-mode t))))

(use-package company-tern
  :ensure t
  :after (company tern js2-mode)
  :config
  (defun my/add-tern-company ()
    (setq-local company-backends company-backends)
    (add-to-list 'company-backends 'company-tern))
  (add-hook 'js2-mode-hook #'my/add-tern-company))

;; Been using this one for work lately
(use-package json-reformat
  :ensure t)

(provide 'js-programming)
;;; js-programming.el ends here

Change js2 basic indent offset to 2 and ignore js2 error checking


;;; org-use.el --- Note taking and todo list (builtin package)
;;; Commentary:
;;; Code:

(use-package org
  :config
  (setq org-completion-use-ido t)

  (setq org-startup-folded nil       ; Headings are unfolded when file is opened
        org-startup-indented t       ; Display sections/outlines indented
        org-startup-truncated nil))  ; Wrap long lines instead of truncating

(require 'evil-core)
(use-package evil-org
  :config
  ;; Unbind some evil keys that evil-org overrides
  (evil-define-key 'normal evil-org-mode-map
    "g j" nil
    "g k" nil
    "o" nil
    "O" nil
    "J" nil
    "K" nil)

  ;; Now bind our own keys
  (evil-define-key 'normal evil-org-mode-map
    "[" 'outline-previous-visible-heading
    "]" 'outline-next-visible-heading))

(provide 'org-use)

;;; org-use.el ends here

;;; org-use.el --- Note taking and todo list (builtin package)
;;; Commentary:
;;; Code:

(use-package org
  :config
  (setq org-completion-use-ido t)

  (setq org-todo-keywords '("TODO" "WAITING" "NEVER" "DONE"))

  (setq org-startup-folded nil       ; Headings are unfolded when file is opened
        org-startup-indented t       ; Display sections/outlines indented
        org-startup-truncated nil))  ; Wrap long lines instead of truncating

(require 'evil-core)
(use-package evil-org
  :config
  ;; Unbind some evil keys that evil-org overrides
  (evil-define-key 'normal evil-org-mode-map
    "g j" nil
    "g k" nil
    "o" nil
    "O" nil
    "J" nil
    "K" nil)

  ;; Now bind our own keys
  (evil-define-key 'normal evil-org-mode-map
    "[" 'outline-previous-visible-heading
    "]" 'outline-next-visible-heading))

(provide 'org-use)

;;; org-use.el ends here

Add more org mode todo keywords

Add more org mode todo keywords


;;; lang/clojure/config.el -*- lexical-binding: t; -*-

(def-package! clojure-mode
  :mode (("\\.clj$" . clojure-mode)
         ("\\.cljs$". clojurescript-mode))
  :commands (clojure-mode clojurescript-mode) ;; this might not be necessary
  :config
  (map! :map clojure-mode-map
        (:localleader
          "'"      #'cider-jack-in
          "\""     #'cider-jack-in-clojurescript
          "b"      #'cider-switch-to-repl-buffer
          "n"      #'cider-repl-switch-ns
          "r"      #'cider-eval-region)))

(def-package! cider
  :commands (cider-jack-in cider-mode cider-jack-in-clojurescript)
  :config
  (setq nrepl-hide-special-buffers t))

;;; lang/clojure/config.el -*- lexical-binding: t; -*-

(def-package! clojure-mode
  :mode (("\\.clj$" . clojure-mode)
         ("\\.cljs$". clojurescript-mode))
  :commands (clojure-mode clojurescript-mode) ;; this might not be necessary?
  :config
  (map! :map clojure-mode-map
        (:localleader
          "'"      #'cider-jack-in
          "\""     #'cider-jack-in-clojurescript
          "b"      #'cider-switch-to-repl-buffer
          "n"      #'cider-repl-set-ns
          "r"      #'cider-eval-region)))

(def-package! cider
  ;; BUG: if you don't have an org directory set (the dir doesn't exist), cider jack in won't work.
  :commands (cider-jack-in cider-mode cider-jack-in-clojurescript)
  :config
  (setq nrepl-hide-special-buffers t)

  ;; TODO: figure out how to set cider to the right window rather than shackle window (https://github.com/hlissner/doom-emacs/issues/171)
  ;; (set! :popup "^\\*cider-.*" :align 'left :noesc t) ;; no luck

  ;; Setup cider for clojurescript / figwheel dev.
  (setq cider-cljs-lein-repl
        "(do (require 'figwheel-sidecar.repl-api)
         (figwheel-sidecar.repl-api/start-figwheel!)
         (figwheel-sidecar.repl-api/cljs-repl))"))

Add figwheel settings + try and unshackle the repl (no luck yet!)


(use-package go-mode
  :config
  (define-key go-mode-map (kbd "M-.") #'godef-jump))

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

;; Go is indented with tabs, so set the tab size in those buffers.
(defun wh/set-go-tab-width ()
  (setq tab-width 4))

(add-hook 'go-mode-hook #'wh/set-go-tab-width)

(add-hook 'go-mode-hook #'go-eldoc-setup)

(require 'go-mode)

(setq gofmt-command "~/go/bin/goimports")
;; Using -s with goimports is not supported with upstream goimports.
;; See https://github.com/golang/go/issues/8759 . Instead, use
;; $ go get github.com/jzelinskie/tools/cmd/goimports
(setq gofmt-args (list "-s"))

;; TODO: send PR for this.
(defun wh/gofmt-before-save ()
  (set (make-local-variable 'before-save-hook)
       (append before-save-hook (list #'gofmt-before-save))))

(add-hook 'go-mode-hook #'wh/gofmt-before-save)

(setq godef-command "~/go/bin/godef")
(provide 'go-customisations)

(use-package go-mode
  :config
  ;; Jump to definitions.
  (setq godef-command "~/go/bin/godef")
  (define-key go-mode-map (kbd "M-.") #'godef-jump)

  ;; Run flycheck as you type.
  (add-hook 'go-mode-hook #'flycheck-mode)

  ;; Go is indented with tabs, so set the tab size in those buffers.
  (defun wh/set-go-tab-width ()
    (setq tab-width 4))
  (add-hook 'go-mode-hook #'wh/set-go-tab-width)

  ;; Show type of variable at point in the minibuffer.
  (add-hook 'go-mode-hook #'go-eldoc-setup)

  ;; Using -s with goimports is not supported with upstream goimports.
  ;; See https://github.com/golang/go/issues/8759. Instead, use
  ;; $ go get github.com/jzelinskie/tools/cmd/goimports
  (setq gofmt-command "~/go/bin/goimports")
  (setq gofmt-args (list "-s"))

  ;; TODO: send PR for this.
  (defun wh/gofmt-before-save ()
    (set (make-local-variable 'before-save-hook)
         (append before-save-hook (list #'gofmt-before-save))))
  (add-hook 'go-mode-hook #'wh/gofmt-before-save))

(provide 'go-customisations)

Move go configuration into the use-package block


;; -*- no-byte-compile: t; -*-
;;;  packages.el

(package! org-super-agenda)

;; -*- no-byte-compile: t; -*-
;;;  packages.el

;; Disabled packages
(package! vi-tilde-fringe :disable t)

(package! org-super-agenda)

Remove ugly vi tilde fringes

Remove ugly vi tilde fringes


(defvar go-packages
  '(
    go-mode
    )
  "List of all packages to install and/or initialize. Built-in packages
which require an initialization must be listed explicitly in the list.")

(defun go/init-go-mode()
  (use-package go-mode
    :defer t
    :init
    (progn
      (evil-leader/set-key
        "mdp"  'godoc-at-point
        "mig"  'go-goto-imports
        "mia"  'go-import-add
        "mir"  'go-remove-unused-imports
        "mpb"  'go-play-buffer
        "mpr"  'go-play-region
        "mpd"  'go-download-play
      )
    )
    :config
    (add-hook 'before-save-hook 'gofmt-before-save)
    )
  )

(defvar go-packages
  '(
    go-mode
    )
  "List of all packages to install and/or initialize. Built-in packages
which require an initialization must be listed explicitly in the list.")

(defun go/init-go-mode()
  (use-package go-mode
    :defer t
    :init
    (progn
      (evil-leader/set-key
        "mdp"  'godoc-at-point
        "mig"  'go-goto-imports
        "mia"  'go-import-add
        "mir"  'go-remove-unused-imports
        "mpb"  'go-play-buffer
        "mpr"  'go-play-region
        "mpd"  'go-download-play
      )
    )
    :config
    (add-hook 'before-save-hook 'gofmt-before-save)
    (add-hook 'go-mode-hook 'flycheck-mode)
    )
  )

Add flycheck-mode to go layer

Add flycheck-mode to go layer


;;; puni-conf.el -- Settings for `puni' -*- lexical-binding: t -*-
;;
;;; Commentary:
;;
;;; Code:

(require 'puni)

(let ((mode puni-mode-map))
  (define-key mode (kbd "C-w") nil))

;;; puni-conf.el ends here

;;; puni-conf.el -- Settings for `puni' -*- lexical-binding: t -*-
;;
;;; Commentary:
;;
;;; Code:

(require 'puni)

(defun pjones:puni-squeeze-splice (arg)
  "Perform a squeeze.
If ARG is non-nil then perform a splice."
  (interactive "P")
  (if arg (puni-splice)
    (puni-squeeze)))

(let ((map puni-mode-map))
  ;; I can't deal with my editor preventing me from deleting
  ;; delimiters:
  (define-key map (kbd "DEL") nil)
  (define-key map (kbd "C-d") nil)
  (define-key map (kbd "C-w") nil)
  (define-key map (kbd "C-M-/") #'puni-split)
  (define-key map (kbd "C-M-k") #'pjones:puni-squeeze-splice)
  (define-key map (kbd "C-M-t") #'puni-transpose))

;;; puni-conf.el ends here

puni: Allow me to break syntax, expose more key bindings


;; Use C-f during file selection to switch to regular find-file
(ido-mode t)  ; use 'buffer rather than t to use only buffer switching
(ido-everywhere t)
(setq ido-enable-flex-matching t)
(setq ido-use-filename-at-point nil)
(setq ido-auto-merge-work-directories-length 0)

(defun steve-ido-choose-from-recentf ()
  "Use ido to select a recently opened file from the `recentf-list'"
  (interactive)
  (find-file (ido-completing-read "Open file: " recentf-list nil t)))
(global-set-key [(meta f11)] 'steve-ido-choose-from-recentf)

;;----------------------------------------------------------------------------
;; ido completion in M-x
;;----------------------------------------------------------------------------
(require 'smex)
(smex-initialize)
(global-set-key "\M-x" 'smex)

(provide 'init-ido)

;; Use C-f during file selection to switch to regular find-file
(ido-mode t)  ; use 'buffer rather than t to use only buffer switching
(ido-everywhere t)
(setq ido-enable-flex-matching t)
(setq ido-use-filename-at-point nil)
(setq ido-auto-merge-work-directories-length 0)

;; Allow the same buffer to be open in different frames
(setq ido-default-buffer-method 'selected-window)

(defun steve-ido-choose-from-recentf ()
  "Use ido to select a recently opened file from the `recentf-list'"
  (interactive)
  (find-file (ido-completing-read "Open file: " recentf-list nil t)))
(global-set-key [(meta f11)] 'steve-ido-choose-from-recentf)

;;----------------------------------------------------------------------------
;; ido completion in M-x
;;----------------------------------------------------------------------------
(require 'smex)
(smex-initialize)
(global-set-key "\M-x" 'smex)

(provide 'init-ido)

Allow the same buffer to be open in different frames when using IDO


(require-package 'rinari)
(after-load 'rinari
  (diminish 'rinari-minor-mode "Rin"))
(global-rinari-mode)

(defun update-rails-ctags ()
  (interactive)
  (let ((default-directory (or (rinari-root) default-directory)))
    (shell-command (concat "ctags -a -e -f " rinari-tags-file-name " --tag-relative -R app lib vendor test"))))

(when (maybe-require-package 'projectile-rails)
  (add-hook 'projectile-mode-hook 'projectile-rails-on)
  (after-load 'guide-key
    (add-to-list 'guide-key/guide-key-sequence "C-c r")))

(provide 'init-rails)

(require-package 'rinari)
(after-load 'rinari
  (diminish 'rinari-minor-mode "Rin"))
(global-rinari-mode)

(defun update-rails-ctags ()
  (interactive)
  (let ((default-directory (or (rinari-root) default-directory)))
    (shell-command (concat "ctags -a -e -f " rinari-tags-file-name " --tag-relative -R app lib vendor test"))))

(when (maybe-require-package 'projectile-rails)
  (after-load 'projectile
    (add-hook 'projectile-mode-hook 'projectile-rails-on)
    (after-load 'guide-key
      (add-to-list 'guide-key/guide-key-sequence "C-c r"))))

(provide 'init-rails)

Enable projectile-rails only after projectile is loaded


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

(defadvice clojure-test-run-tests (before save-first activate)
  (save-buffer))

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

(defadvice clojure-test-run-tests (before save-first activate)
  (save-buffer))

(eval-after-load "nrepl"
  '(progn
     (define-key nrepl-mode-map (kbd "C-,") 'complete-symbol)
     (define-key nrepl-interaction-mode-map (kbd "C-,") 'complete-symbol)))

(provide 'setup-clojure-mode)

Use C-, to complete command in nrepl-modes.


(require-package 'haskell-mode)

(add-hook 'haskell-mode-hook
          (lambda ()
            (define-key haskell-mode-map (kbd "C-c h") 'hoogle)
            (turn-on-haskell-doc-mode)
            (turn-on-haskell-indent)))

(eval-after-load 'haskell-mode
  '(define-key haskell-mode-map (kbd "RET") 'newline))

(require-package 'ghci-completion)
(add-hook 'inferior-haskell-mode-hook 'turn-on-ghci-completion)

(require-package 'flymake-hlint)
(add-hook 'haskell-mode-hook #'flymake-hlint-load)

(provide 'init-haskell)

(require-package 'haskell-mode)

(dolist (hook '(haskell-mode-hook inferior-haskell-mode-hook))
  (add-hook hook 'turn-on-haskell-doc-mode))

(add-hook 'haskell-mode-hook 'turn-on-haskell-indent)

(eval-after-load 'haskell-mode
  '(progn
     (define-key haskell-mode-map (kbd "C-c h") 'hoogle)
     (define-key haskell-mode-map (kbd "RET") 'newline)))

(require-package 'ghci-completion)
(add-hook 'inferior-haskell-mode-hook 'turn-on-ghci-completion)

(require-package 'flymake-hlint)
(add-hook 'haskell-mode-hook #'flymake-hlint-load)

(provide 'init-haskell)

Enable more functionality in inferior-haskell-mode


;;; haskell-mode-conf.el -- Settings for Haskell mode.
(eval-when-compile (require 'haskell-mode))
(pjones:add-programming-hook 'haskell-mode-hook)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)

;;; haskell-mode-conf.el -- Settings for Haskell mode.
(eval-when-compile
  (load "../lisp/code.el")
  (require 'haskell-mode))

(pjones:add-programming-hook 'haskell-mode-hook)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)

Fix a compile error with my Haskell settings in Emacs


;;; lang/json/config.el -*- lexical-binding: t; -*-

(use-package! json-mode
  :mode "\\.js\\(?:on\\|[hl]int\\(?:rc\\)?\\)\\'"
  :init
  (when (featurep! +lsp)
    (add-hook 'json-mode-local-vars-hook #'lsp!))
  :config
  (set-electric! 'json-mode :chars '(?\n ?: ?{ ?}))

  (map! :after json-mode
        :map json-mode-map
        :localleader
        "p" #'jsons-print-path))

(when (featurep! :completion ivy)
  (use-package! counsel-jq
    :defer t
    :init
    (map! :after json-mode
          :map json-mode-map
          :localleader
          "s" #'counsel-jq)))

;;; lang/json/config.el -*- lexical-binding: t; -*-

(use-package! json-mode
  :mode "\\.js\\(?:on\\|[hl]int\\(?:rc\\)?\\)\\'"
  :init
  (when (featurep! +lsp)
    (add-hook 'json-mode-local-vars-hook #'lsp!))
  :config
  (set-electric! 'json-mode :chars '(?\n ?: ?{ ?}))

  (map! :after json-mode
        :map json-mode-map
        :localleader
        "p" #'jsons-print-path))

(use-package! counsel-jq
  :when (featurep! :completion ivy)
  :defer t
  :init
  (map! :after json-mode
    :map json-mode-map
    :localleader
    "s" #'counsel-jq))

Use :when instead of (when ...)

Use :when instead of (when ...)


(require 'package)
(require 'dash)

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

(package-initialize)

(unless (file-exists-p "~/.emacs.d/elpa/archives/melpa")
  (package-refresh-contents))

(defun packages-install (packages)
  (--each packages
    (when (not (package-installed-p it))
      (package-install it)))
  (delete-other-windows))

;;; On-demand installation of packages

(defun require-package (package &optional min-version no-refresh)
  "Install given PACKAGE, optionally requiring MIN-VERSION.
If NO-REFRESH is non-nil, the available package lists will not be
re-downloaded in order to locate PACKAGE."
  (if (package-installed-p package min-version)
      t
    (if (or (assoc package package-archive-contents) no-refresh)
        (package-install package)
      (progn
        (package-refresh-contents)
        (require-package package min-version t)))))

(provide 'setup-package)

(require 'package)
(require 'dash)

;; Add melpa to package repos
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
(add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/") t)

(package-initialize)

(unless (file-exists-p "~/.emacs.d/elpa/archives/melpa")
  (package-refresh-contents))

(defun packages-install (packages)
  (--each packages
    (when (not (package-installed-p it))
      (package-install it)))
  (delete-other-windows))

;;; On-demand installation of packages

(defun require-package (package &optional min-version no-refresh)
  "Install given PACKAGE, optionally requiring MIN-VERSION.
If NO-REFRESH is non-nil, the available package lists will not be
re-downloaded in order to locate PACKAGE."
  (if (package-installed-p package min-version)
      t
    (if (or (assoc package package-archive-contents) no-refresh)
        (package-install package)
      (progn
        (package-refresh-contents)
        (require-package package min-version t)))))

(provide 'setup-package)

Add melpa-stable to package archives

Add melpa-stable to package archives


(defvar iedit-post-extensions '(evil-iedit-state))

(defun iedit/init-evil-iedit-state ()
  (spacemacs/defface-state-color 'iedit "IndianRed1")
  (spacemacs/defface-state-color 'iedit-insert "IndianRed1")
  (defun iedit//lazy-load ()
    (require 'evil-iedit-state)
    (setq evil-iedit-state-cursor `(,(spacemacs/state-color 'iedit) box))
    (setq evil-iedit-insert-state-cursor `((spacemacs/state-color 'iedit-insert) (bar . 2)))
    (evil-leader/set-key "se" 'evil-iedit-state/iedit-mode)
    ;; override the basic edit mode from ahs everywhere
    (eval-after-load 'auto-highlight-symbol
      '(progn
         (evil-leader/set-key "se" 'evil-iedit-state/iedit-mode)
         (defalias 'ahs-edit-mode 'evil-iedit-state/iedit-mode))))
  (add-to-hooks 'iedit//lazy-load '(prog-mode-hook markdown-mode-hook)))

(defvar iedit-post-extensions '(evil-iedit-state))

(defun iedit/init-evil-iedit-state ()
  (spacemacs/defface-state-color 'iedit "IndianRed1")
  (spacemacs/defface-state-color 'iedit-insert "IndianRed1")
  (defun iedit//lazy-load ()
    (require 'evil-iedit-state)
    (setq evil-iedit-state-cursor `(,(spacemacs/state-color 'iedit) box))
    (setq evil-iedit-insert-state-cursor `((spacemacs/state-color 'iedit-insert) (bar . 2)))
    (evil-leader/set-key "se" 'evil-iedit-state/iedit-mode)
    (when (and (boundp 'evil-escape-mode)
               (symbol-value evil-escape-mode))
      (key-chord-define evil-iedit-state-map
                        evil-escape-key-sequence
                        'evil-iedit-state/quit-iedit-mode)
      (key-chord-define evil-iedit-insert-state-map
                        evil-escape-key-sequence
                        'evil-iedit-state/quit-iedit-mode)))
  ;; override the basic edit mode from ahs everywhere
  (eval-after-load 'auto-highlight-symbol
    '(progn
       (evil-leader/set-key "se" 'evil-iedit-state/iedit-mode)
       (defalias 'ahs-edit-mode 'evil-iedit-state/iedit-mode)))
  (add-to-hooks 'iedit//lazy-load '(prog-mode-hook markdown-mode-hook)))

Enable evil-escape `fd` in iedit states to exit to `normal state`


(defun my/new-workspace-with-current-window ()
  (interactive)
  (let* ((default-tag (buffer-name))
         (workspace-tag-from-user (read-from-minibuffer (concat "Tag for new workspace (" default-tag "): ")))
         (workspace-tag (if (string-empty-p workspace-tag-from-user) default-tag workspace-tag-from-user))
         (eyebrowse-new-workspace (buffer-name)))
    (eyebrowse-create-window-config)
    (eyebrowse-rename-window-config (eyebrowse--get 'current-slot) workspace-tag)))

(defun my/close-window-or-workspace ()
  (interactive)
  (cond ((> (list-length (window-list)) 1)
         (delete-window))
        ((> (list-length (eyebrowse--get 'window-configs)) 1)
         (eyebrowse-close-window-config))
        ((y-or-n-p "This is the last workspace. Close the perspective? ") (spacemacs/layouts-ts-close))))

(provide 'my-window-functions)

(defun my/new-workspace-with-current-window ()
  (interactive)
  (let* ((default-tag (buffer-name))
         (workspace-tag-from-user (read-from-minibuffer (concat "Tag for new workspace (" default-tag "): ")))
         (workspace-tag (if (string-empty-p workspace-tag-from-user) default-tag workspace-tag-from-user))
         (eyebrowse-new-workspace (buffer-name)))
    (delete-window)
    (eyebrowse-create-window-config)
    (eyebrowse-rename-window-config (eyebrowse--get 'current-slot) workspace-tag)))

(defun my/close-window-or-workspace ()
  (interactive)
  (cond ((> (list-length (window-list)) 1)
         (delete-window))
        ((> (list-length (eyebrowse--get 'window-configs)) 1)
         (eyebrowse-close-window-config))
        ((y-or-n-p "This is the last workspace. Close the perspective? ") (spacemacs/layouts-ts-close))))

(provide 'my-window-functions)

Spacemacs: Delete the window from the last workspace when running C-w T


;; Time-stamp: <2014-03-07 15:13:15 kmodi>

;; magit
;; Source: https://github.com/magit/magit

(require 'magit)

(setq magit-completing-read-function 'magit-ido-completing-read
      magit-auto-revert-mode nil
      magit-repo-dirs '( "~/.emacs.d"
                         )
      )

(setq setup-magit-loaded t)
(provide 'setup-magit)

;; Time-stamp: <2014-03-09 00:53:22 kmodi>

;; magit
;; Source: https://github.com/magit/magit

(require 'magit)

(setq magit-completing-read-function 'magit-ido-completing-read
      magit-auto-revert-mode nil
      magit-repo-dirs '( "~/.emacs.d"
                         )
      )

(magit-auto-revert-mode -1) ;; Disable magit auto revert

(setq setup-magit-loaded t)
(provide 'setup-magit)

Disable magit auto revert mode.

Disable magit auto revert mode.


;;; js-conf.el -- Configuration options for js-mode (JavaScript).
(eval-when-compile (require 'js))
(setq js-indent-level 2 js-flat-functions t)

;;; js-conf.el -- Configuration options for js-mode (JavaScript).
(eval-when-compile (require 'js))

;; JavaScript mode settings
(setq js-indent-level 2
      js-flat-functions t)

(defvar pjones:js-keywords
  '(("\\(function *\\)("
     (0 (progn (compose-region (match-beginning 1)
                               (match-end 1) "\u0192") nil))))
  "Extra keywords to add to JavaScript buffers.
The Unicode anonymous function code was stolen from
https://github.com/technomancy/emacs-starter-kit")

(defun pjones:js-add-extra-keywords ()
  "Add some extra keywords to JavaScript buffers."
  (interactive)
  (font-lock-add-keywords 'js-mode pjones:js-keywords)
  (font-lock-fontify-buffer))

(defun pjones:js-rm-extra-keywords ()
  "Remove some extra keywords from JavaScript buffers."
  (interactive)
  (let ((modified (buffer-modified-p)))
    (font-lock-remove-keywords 'js-mode pjones:js-keywords)
    (remove-text-properties (point-min) (point-max) '(composition nil))
    (set-buffer-modified-p modified)))

(defun pjones:js-mode-hook ()
  "Configure JS mode and key bindings."
  (local-set-key (kbd "C-c C-k")   'pjones:js-rm-extra-keywords)
  (local-set-key (kbd "C-c C-S-k") 'pjones:js-add-extra-keywords))
(add-hook 'js-mode-hook 'pjones:js-mode-hook)

;; Set up the cool extra keywords right away!
(pjones:js-add-extra-keywords)

Add some extra keywords to JavaScript buffers with functions to toggle them


;;; my-git.el --- Git settings -*- lexical-binding: t -*-

;; Copyright (C) 2016  Sergey Timanin

;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at

;;     http://www.apache.org/licenses/LICENSE-2.0

;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.

;;; Commentary:

;;; Code:

(use-package magit
  :config
  (setq vc-handled-backends (delq 'Git vc-handled-backends))
  :bind
  ("C-x g" . magit-status))

(provide 'my-git)

;;; my-git.el ends here

;;; my-git.el --- Git settings -*- lexical-binding: t -*-

;; Copyright (C) 2016  Sergey Timanin

;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at

;;     http://www.apache.org/licenses/LICENSE-2.0

;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.

;;; Commentary:

;;; Code:

(use-package magit
  :config
  (setq vc-handled-backends (delq 'Git vc-handled-backends))
  :bind
  ("C-x g" . magit-status))

;; full screen magit-status
;; from http://whattheemacsd.com/setup-magit.el-01.html

(defadvice magit-status (around magit-fullscreen activate)
  "Open magit status as a fullscreen buffer."
  (window-configuration-to-register :magit-fullscreen)
  ad-do-it
  (delete-other-windows))

(defun magit-quit-session ()
  "Restore the previous window configuration and kill the magit buffer."
  (interactive)
  (kill-buffer)
  (jump-to-register :magit-fullscreen))

(define-key magit-status-mode-map (kbd "q") 'magit-quit-session)

(provide 'my-git)

;;; my-git.el ends here

Make magit buffer fullscreen to minimise window-jumping


;;; w3m-conf.el --- Settings for w3m.
;;
;;; Commentary:
;;
;;; Code:
(require 'w3m)
(require 'evil-leader)

(custom-set-variables
 '(w3m-use-tab nil)
 '(w3m-pop-up-windows nil)
 '(w3m-pop-up-frames nil)
 '(w3m-display-mode 'plain))

(evil-leader/set-key-for-mode 'w3m-mode
  "DEL r" #'pjones:w3m-rename-buffer)

(defun pjones:w3m-rename-buffer ()
  "Rename the current `w3m' buffer to include its title."
  (interactive)
  (let ((name (concat "*w3m: " w3m-current-title "*")))
    (rename-buffer name t)))

;;; w3m-conf.el ends here

;;; w3m-conf.el --- Settings for w3m.
;;
;;; Commentary:
;;
;;; Code:
(require 'w3m)
(require 'evil-leader)

(custom-set-variables
 '(w3m-use-tab nil)
 '(w3m-pop-up-windows nil)
 '(w3m-pop-up-frames nil)
 '(w3m-display-mode 'plain)
 '(w3m-use-header-line t)
 '(w3m-use-header-line-title t)
 '(w3m-make-new-session t))

(evil-leader/set-key-for-mode 'w3m-mode
  "DEL r" #'pjones:w3m-rename-buffer)

(defun pjones:w3m-rename-buffer ()
  "Rename the current `w3m' buffer to include its title."
  (interactive)
  (let ((name (concat "*w3m: " w3m-current-title "*")))
    (rename-buffer name t)))

;;; w3m-conf.el ends here

w3m: Use the header line to show the page title


(require 'ibuffer)

(require 'ibuffer-vc)

(defun ibuffer-set-up-preferred-filters ()
  (ibuffer-vc-set-filter-groups-by-vc-root)
  (ibuffer-do-sort-by-filename/process))
(add-hook 'ibuffer-mode-hook 'ibuffer-set-up-preferred-filters)

;; Use human readable Size column instead of original one
(define-ibuffer-column size-h
  (:name "Size" :inline t)
  (cond
   ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
   ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
   (t (format "%8d" (buffer-size)))))

;; Modify the default ibuffer-formats
(setq ibuffer-formats
      '((mark modified read-only vc-status-mini " "
              (name 18 18 :left :elide)
              " "
              (size-h 9 -1 :right)
              " "
              (mode 16 16 :left :elide)
              " "
              (vc-status 16 16 :left)
              " "
              filename-and-process)))

(setq ibuffer-filter-group-name-face 'font-lock-doc-face)

(global-set-key (kbd "C-x C-b") 'ibuffer)

(provide 'init-ibuffer)

(require 'ibuffer)

(require 'ibuffer-vc)

(defun ibuffer-set-up-preferred-filters ()
  (ibuffer-vc-set-filter-groups-by-vc-root)
  (ibuffer-do-sort-by-filename/process))

(add-hook 'ibuffer-hook 'ibuffer-set-up-preferred-filters)

;; Use human readable Size column instead of original one
(define-ibuffer-column size-h
  (:name "Size" :inline t)
  (cond
   ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
   ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
   (t (format "%8d" (buffer-size)))))

;; Modify the default ibuffer-formats
(setq ibuffer-formats
      '((mark modified read-only vc-status-mini " "
              (name 18 18 :left :elide)
              " "
              (size-h 9 -1 :right)
              " "
              (mode 16 16 :left :elide)
              " "
              (vc-status 16 16 :left)
              " "
              filename-and-process)))

(setq ibuffer-filter-group-name-face 'font-lock-doc-face)

(global-set-key (kbd "C-x C-b") 'ibuffer)

(provide 'init-ibuffer)

Use ibuffer-hook instead of ibuffer-mode-hook


;;; lang/nim/config.el -*- lexical-binding: t; -*-

(after! nim-mode
  (add-hook! 'nim-mode-hook
    (defun +nim-init-nimsuggest-mode-h ()
      "Conditionally load `nimsuggest-mode', instead of clumsily erroring out if
nimsuggest isn't installed."
      (unless (stringp nimsuggest-path)
        (setq nimsuggest-path (executable-find "nimsuggest")))
      (when (and nimsuggest-path (file-executable-p nimsuggest-path))
        (nimsuggest-mode))))

  (when IS-WINDOWS
    ;; TODO File PR/report upstream (https://github.com/nim-lang/nim-mode)
    (defadvice! +nim--suggest-get-temp-file-name-a (path)
      "Removes invalid characters from the temp file path, including the unicode
character that colon is replaced with, which is known to cause issues on
windows."
      :filter-return #'nimsuggest--get-temp-file-name
      (replace-regexp-in-string "[꞉* |<>\"?*]" "" path)))

  (map! :localleader
        :map nim-mode-map
        "b" #'nim-compile))

(use-package! flycheck-nim
  :when (featurep! :checkers syntax)
  :after nim-mode)

;;; lang/nim/config.el -*- lexical-binding: t; -*-

(after! nim-mode
  :init
  (add-hook! 'nim-mode-hook
    (defun +nim-init-nimsuggest-mode-h ()
      "Conditionally load `nimsuggest-mode', instead of clumsily erroring out if
nimsuggest isn't installed."
      (unless (stringp nimsuggest-path)
        (setq nimsuggest-path (executable-find "nimsuggest")))
      (when (and nimsuggest-path (file-executable-p nimsuggest-path))
        (nimsuggest-mode))))

  (when IS-WINDOWS
    ;; TODO File PR/report upstream (https://github.com/nim-lang/nim-mode)
    (defadvice! +nim--suggest-get-temp-file-name-a (path)
      "Removes invalid characters from the temp file path, including the unicode
character that colon is replaced with, which is known to cause issues on
windows."
      :filter-return #'nimsuggest--get-temp-file-name
      (replace-regexp-in-string "[꞉* |<>\"?*]" "" path)))

  :config
  (set-lookup-handlers! '(nim-mode nimsuggest-mode)
    :definition #'+nimsuggest-find-definition
    :documentation #'nimsuggest-show-doc)

  (map! :localleader
        :map nim-mode-map
        "b" #'nim-compile
        "h" #'nimsuggest-show-doc
        "d" #'nimsuggest-find-definition))

(use-package! flycheck-nim
  :when (featurep! :checkers syntax)
  :after nim-mode)

Add definition and documentation keybindings


;;; ui/hydra/config.el -*- lexical-binding: t; -*-

;;;###package hydra
(setq lv-use-seperator t)

;;; ui/hydra/config.el -*- lexical-binding: t; -*-

(use-package! hydra-examples
  :commands (hydra-move-splitter-up
             hydra-move-splitter-down
             hydra-move-splitter-right
             hydra-move-splitter-left))

;;;###package hydra
(setq lv-use-seperator t)

Load hydra examples without using example hydras.

`+hydra/window-nav` uses functions from `hydra-examples.el` but the file
is never loaded. Adding this does not actually define any hydras (this
would require `hydra-examples-verbatim` to be `t`), it just load the
utility functions to make the hydras defined in doom work.


;; full screen magit-status

(defun magit-status-fullscreen (prefix)
  (interactive "P")
  (magit-status)
  (unless prefix
    (delete-other-windows)))

;; don't prompt me

(set-default 'magit-unstage-all-confirm nil)
(set-default 'magit-stage-all-confirm nil)
(set-default 'magit-push-always-verify nil)
(set-default 'magit-revert-buffers 'silent)

;; full screen vc-annotate

(defun vc-annotate-quit ()
  "Restores the previous window configuration and kills the vc-annotate buffer"
  (interactive)
  (kill-buffer)
  (jump-to-register :vc-annotate-fullscreen))

(eval-after-load "vc-annotate"
  '(progn
     (defadvice vc-annotate (around fullscreen activate)
       (window-configuration-to-register :vc-annotate-fullscreen)
       ad-do-it
       (delete-other-windows))

     (define-key vc-annotate-mode-map (kbd "q") 'vc-annotate-quit)))

(provide 'setup-magit)

;; full screen magit-status

(defun magit-status-fullscreen (prefix)
  (interactive "P")
  (magit-status)
  (unless prefix
    (delete-other-windows)))

;; don't prompt me

(set-default 'magit-unstage-all-confirm nil)
(set-default 'magit-stage-all-confirm nil)
(set-default 'magit-push-always-verify nil)
(set-default 'magit-revert-buffers 'silent)

;; move cursor into position when entering commit message

(defun my/magit-cursor-fix ()
  (beginning-of-buffer)
  (when (looking-at "#")
    (forward-line 2)))

(add-hook 'git-commit-mode-hook 'my/magit-cursor-fix)

;; full screen vc-annotate

(defun vc-annotate-quit ()
  "Restores the previous window configuration and kills the vc-annotate buffer"
  (interactive)
  (kill-buffer)
  (jump-to-register :vc-annotate-fullscreen))

(eval-after-load "vc-annotate"
  '(progn
     (defadvice vc-annotate (around fullscreen activate)
       (window-configuration-to-register :vc-annotate-fullscreen)
       ad-do-it
       (delete-other-windows))

     (define-key vc-annotate-mode-map (kbd "q") 'vc-annotate-quit)))

(provide 'setup-magit)

Move cursor into position when entering commit msg


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

(defconst my-python-packages '(python treemacs))

(defun my-python/post-init-python ()
  (with-eval-after-load 'python
    (modify-syntax-entry ?_ "w" python-mode-syntax-table)
    (autoload 'pyvenv-track-virtualenv "pyvenv")
    (add-hook 'python-mode-local-vars-hook #'pyvenv-track-virtualenv)))

(defun my-python/post-init-treemacs ()
  (with-eval-after-load 'treemacs
    (add-to-list 'treemacs-ignored-file-predicates
                 #'my-python//treemacs-ignored-file-predicates)))

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

(defconst my-python-packages '(python treemacs))

;; TODO: this is global, can this be made buffer-local?
;; maybe use `pyvenv-mode' vs `pyvenv-tracking-mode'?
(defun my-python//activate-virtualenv()
  (pyvenv-track-virtualenv)
  (when pyvenv-virtual-env
    (setq lsp-clients-python-library-directories (list "/usr/" pyvenv-virtual-env))))

(defun my-python/post-init-python ()
  (with-eval-after-load 'python
    (modify-syntax-entry ?_ "w" python-mode-syntax-table)
    (autoload 'pyvenv-track-virtualenv "pyvenv")
    (add-hook 'python-mode-local-vars-hook #'my-python//activate-virtualenv)))

(defun my-python/post-init-treemacs ()
  (with-eval-after-load 'treemacs
    (add-to-list 'treemacs-ignored-file-predicates
                 #'my-python//treemacs-ignored-file-predicates)))

Make "go to definition in library" work with lsp in python projects


(require 'go-mode)

(setq gofmt-command "goimports")
(add-to-list 'load-path "/home/you/goroot/misc/emacs/")
(add-hook 'before-save-hook 'gofmt-before-save)

(provide 'tj-go)

(require 'go-mode)

(setq gofmt-command "goimports")
(add-to-list 'load-path "/home/you/goroot/misc/emacs/")
(add-hook 'before-save-hook 'gofmt-before-save)

(defun go-test ()
  "Runs tests for package in current buffer"
  (interactive)
  (compile (concat "ginkgo " (file-name-directory (buffer-file-name)))))

(provide 'tj-go)

Add a function to run go tests

Add a function to run go tests