Moves helper functions to separate file

This commit is contained in:
William Carroll 2017-05-31 23:58:17 -04:00
parent 39b0e5056b
commit 23f4e84ada
2 changed files with 480 additions and 439 deletions

View file

@ -113,15 +113,9 @@
(powerline-default-theme)) (powerline-default-theme))
(defun wc/projectile-shell-pop () ;; Load custom Emacs functions
"Opens `ansi-term' at the project root according to Projectile." (load "~/.emacs/wc-helper-functions.lisp")
(interactive)
(let ((default-directory (projectile-project-root)))
(if (get-buffer "*ansi-term*")
(switch-to-buffer "*ansi-term*")
(ansi-term "/bin/zsh"))
(term-send-string (terminal) (format "cd '%s'\n" default-directory))
(get-buffer-process "*ansi-term*")))
;; ERC configuration (IRC in Emacs) ;; ERC configuration (IRC in Emacs)
(use-package erc (use-package erc
@ -130,12 +124,6 @@
(setq erc-autojoin-channels-alist '(("freenode.net" "#emacs" "#elixir")))) (setq erc-autojoin-channels-alist '(("freenode.net" "#emacs" "#elixir"))))
(defun wc/join-erc ()
"Boots `erc' and autojoins channels."
(interactive)
(erc :server "irc.freenode.net" :port "6667" :nick "wpcarro"))
;; Disable fringes in Emacs ;; Disable fringes in Emacs
(fringe-mode 0) (fringe-mode 0)
@ -192,16 +180,6 @@
:ensure t) :ensure t)
(defun wc/bootstrap-ansi-term ()
"Custom `ansi-term' configuration."
(interactive)
(linum-mode nil)
(local-set-key (kbd "C-h") 'evil-window-left)
(local-set-key (kbd "C-l") 'evil-window-right)
(local-set-key (kbd "C-k") 'evil-window-up)
(local-set-key (kbd "C-j") 'evil-window-down)
(define-key term-raw-map (kbd "s-v") 'term-paste))
(defadvice term-sentinel (around my-advice-term-sentinel (proc msg)) (defadvice term-sentinel (around my-advice-term-sentinel (proc msg))
(if (memq (process-status proc) '(signal exit)) (if (memq (process-status proc) '(signal exit))
(let ((buffer (process-buffer proc))) (let ((buffer (process-buffer proc)))
@ -211,15 +189,6 @@
(ad-activate 'term-sentinel) (ad-activate 'term-sentinel)
(defun wc/ansi-term-paste (&optional string)
"Paste into `ansi-term'."
(interactive)
(process-send-string
(get-buffer-process (current-buffer))
(if string string (current-kill 0)))))
;; Ansi-Term ;; Ansi-Term
(use-package term (use-package term
:ensure t :ensure t
@ -245,8 +214,8 @@
;; Dired Settings ;; Dired Settings
(use-package dired (use-package dired
:bind (:map dired-mode-map :bind (:map dired-mode-map
("c" . find-file) ("c" . find-file)
("K" . dired-up-directory))) ("K" . dired-up-directory)))
;; Evil Settings ;; Evil Settings
@ -254,58 +223,58 @@
:ensure t :ensure t
:commands (evil-mode local-evil-mode) :commands (evil-mode local-evil-mode)
:bind (:map evil-visual-state-map :bind (:map evil-visual-state-map
("H" . evil-first-non-blank) ("H" . evil-first-non-blank)
("L" . evil-end-of-visual-line) ("L" . evil-end-of-visual-line)
:map evil-motion-state-map :map evil-motion-state-map
("<return>" . nil) ("<return>" . nil)
("<tab>" . nil) ("<tab>" . nil)
("SPC" . nil) ("SPC" . nil)
("M-." . nil) ("M-." . nil)
:map evil-insert-state-map :map evil-insert-state-map
("C-k" . nil) ("C-k" . nil)
("C-p" . nil) ("C-p" . nil)
("C-n" . nil) ("C-n" . nil)
("C-r" . nil) ("C-r" . nil)
("C-t" . nil) ("C-t" . nil)
("C-e" . nil) ("C-e" . nil)
("C-a" . nil) ("C-a" . nil)
("C-h" . evil-window-left) ("C-h" . evil-window-left)
("C-l" . evil-window-right) ("C-l" . evil-window-right)
("C-k" . evil-window-up) ("C-k" . evil-window-up)
("C-j" . evil-window-down) ("C-j" . evil-window-down)
("C-c" . term-interrupt-subjob) ("C-c" . term-interrupt-subjob)
:map evil-normal-state-map :map evil-normal-state-map
("<return>" . nil) ("<return>" . nil)
("<tab>" . nil) ("<tab>" . nil)
("K" . nil) ("K" . nil)
("M-." . nil) ("M-." . nil)
("s" . nil) ("s" . nil)
("C-p" . nil) ("C-p" . nil)
("C-h" . evil-window-left) ("C-h" . evil-window-left)
("C-l" . evil-window-right) ("C-l" . evil-window-right)
("C-k" . evil-window-up) ("C-k" . evil-window-up)
("C-j" . evil-window-down) ("C-j" . evil-window-down)
("g c" . comment-or-uncomment-region) ("g c" . comment-or-uncomment-region)
("s h" . evil-window-vsplit) ("s h" . evil-window-vsplit)
("s l" . evil-window-vsplit-right) ("s l" . evil-window-vsplit-right)
("s k" . evil-window-split) ("s k" . evil-window-split)
("s j" . evil-window-split-down) ("s j" . evil-window-split-down)
("H" . evil-first-non-blank) ("H" . evil-first-non-blank)
("L" . evil-end-of-line) ("L" . evil-end-of-line)
("<S-left>" . evil-window-increase-width) ("<S-left>" . evil-window-increase-width)
("<S-right>" . evil-window-decrease-width) ("<S-right>" . evil-window-decrease-width)
("<S-up>" . evil-window-decrease-height) ("<S-up>" . evil-window-decrease-height)
("<S-down>" . evil-window-increase-height) ("<S-down>" . evil-window-increase-height)
:map evil-ex-map :map evil-ex-map
("tb" . alchemist-test-this-buffer) ("tb" . alchemist-test-this-buffer)
("tap" . alchemist-test-at-point) ("tap" . alchemist-test-at-point)
("lt" . alchemist-mix-rerun-last-test) ("lt" . alchemist-mix-rerun-last-test)
) )
:init :init
(setq evil-emacs-state-cursor '("VioletRed3" box)) (setq evil-emacs-state-cursor '("VioletRed3" box))
(setq evil-normal-state-cursor '("DeepSkyBlue2" box)) (setq evil-normal-state-cursor '("DeepSkyBlue2" box))
@ -330,362 +299,234 @@
(call-interactively 'evil-scroll-line-to-center)) (call-interactively 'evil-scroll-line-to-center))
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/") (add-to-list 'custom-theme-load-path "~/.emacs.d/themes/")
(defun evil-window-vsplit-right () ;; Evil Leader Settings
"Vertically split a window and move right." (use-package evil-leader
(interactive) :ensure t
(evil-window-vsplit nil) :commands (global-evil-leader-mode)
(evil-window-right 1)) :config
(evil-leader/set-leader "<SPC>")
(defun evil-window-split-down () (evil-leader/set-key
"Split a window and move right." "w" 'toggle-truncate-lines
(interactive) "x" 'helm-M-x
(evil-window-split nil) "<SPC>" 'wc/switch-to-mru-buffer
(evil-window-down 1)) "a" 'ace-delete-window
"s" 'ace-swap-window
"n" 'neotree-toggle-project-dir
(defun wc/switch-to-mru-buffer () "N" 'neotree-reveal-current-buffer
"Switches to the most recently used buffer, including visible buffers." "t" 'alchemist-project-toggle-file-and-tests
(interactive) "f" 'helm-projectile
(switch-to-buffer (other-buffer (current-buffer) t (selected-frame)))) "p" 'helm-projectile-ag
"d" 'dired-jump
"D" 'projectile-dired
;; Evil Leader Settings "q" 'kill-this-buffer
(use-package evil-leader "h" 'evil-window-left
:ensure t "i" 'helm-semantic-or-imenu
:commands (global-evil-leader-mode) "l" 'evil-window-right
:config "k" 'evil-window-up
(evil-leader/set-leader "<SPC>") "j" 'evil-window-down
(evil-leader/set-key "b" 'helm-mini
"w" 'toggle-truncate-lines "T" 'alchemist-mix-test-at-point
"x" 'helm-M-x "B" 'alchemist-mix-test-this-buffer
"<SPC>" 'wc/switch-to-mru-buffer "L" 'alchemist-mix-rerun-last-test
"a" 'ace-delete-window "g" 'magit-status
"s" 'ace-swap-window "z" 'wc/projectile-shell-pop
"n" 'neotree-toggle-project-dir ))
"N" 'neotree-reveal-current-buffer
"t" 'alchemist-project-toggle-file-and-tests
"f" 'helm-projectile ;; Evil Match-it
"p" 'helm-projectile-ag (use-package evil-matchit
"d" 'dired-jump :ensure t
"D" 'projectile-dired :commands (global-evil-matchit-mode))
"q" 'kill-this-buffer
"h" 'evil-window-left
"i" 'helm-semantic-or-imenu ;; Evil Surround
"l" 'evil-window-right (use-package evil-surround
"k" 'evil-window-up :ensure t
"j" 'evil-window-down :commands (global-evil-surround-mode))
"b" 'helm-mini
"T" 'alchemist-mix-test-at-point
"B" 'alchemist-mix-test-this-buffer ;; Flycheck Mix Settings
"L" 'alchemist-mix-rerun-last-test (use-package flycheck-mix
"g" 'magit-status :ensure t
"z" 'wc/projectile-shell-pop :init
)) (flycheck-mix-setup))
;; Evil Match-it ;; Flycheck
(use-package evil-matchit (use-package flycheck
:ensure t :ensure t
:commands (global-evil-matchit-mode)) :config
(setq flycheck-display-errors-function 'ignore))
;; Evil Surround
(use-package evil-surround ;; Flycheck Credo Settings
:ensure t (use-package flycheck-credo
:commands (global-evil-surround-mode)) :ensure t
:init
(flycheck-credo-setup))
;; Flycheck Mix Settings
(use-package flycheck-mix
:ensure t ;; Popwin Settings
:init (use-package popwin
(flycheck-mix-setup)) :ensure t)
;; Flycheck (add-hook 'helm-minibuffer-set-up-hook #'*-popwin-help-mode-off)
(use-package flycheck (add-hook 'helm-cleanup-hook #'*-popwin-help-mode-on)
:ensure t
:config (setq display-buffer-function 'popwin:display-buffer)
(setq flycheck-display-errors-function 'ignore)) (setq helm-split-window-preferred-function 'ignore)
(push '("^\*helm .+\*$" :regexp t) popwin:special-display-config)
(push '("^\*helm-.+\*$" :regexp t) popwin:special-display-config)
;; Flycheck Credo Settings
(use-package flycheck-credo
:ensure t ;; Alchemist Settings
:init (use-package alchemist
(flycheck-credo-setup)) :ensure t
:config
(setq alchemist-mix-env "prod")
;; Popwin Settings (setq alchemist-goto-elixir-source-dir "~/source_code/elixir/")
(use-package popwin (setq alchemist-goto-erlang-source-dir "~/source_code/otp/")
:ensure t) :init
(linum-mode))
(defun *-popwin-help-mode-off ()
"Turn `popwin-mode' off for *Help* buffers."
(add-hook 'erlang-mode-hook 'wc/custom-erlang-mode-hook)
(when (boundp 'popwin:special-display-config)
(customize-set-variable 'popwin:special-display-config
(delq 'help-mode popwin:special-display-config)))) ;; NeoTree Settings
(use-package neotree
(defun *-popwin-help-mode-on () :ensure t
"Turn `popwin-mode' on for *Help* buffers." :bind (:map neotree-mode-map
("j" . next-line)
(when (boundp 'popwin:special-display-config) ("k" . previous-line)
(customize-set-variable 'popwin:special-display-config ("<return>" . neotree-enter)
(add-to-list 'popwin:special-display-config 'help-mode nil #'eq)))) ("<tab>" . neotree-enter)
("D" . neotree-delete-node)
(add-hook 'helm-minibuffer-set-up-hook #'*-popwin-help-mode-off) ("R" . neotree-rename-node)
(add-hook 'helm-cleanup-hook #'*-popwin-help-mode-on) ("c" . neotree-create-node)
("C-h" . evil-window-left)
(setq display-buffer-function 'popwin:display-buffer) ("C-l" . evil-window-right)
(setq helm-split-window-preferred-function 'ignore) ("C-k" . evil-window-up)
(push '("^\*helm .+\*$" :regexp t) popwin:special-display-config) ("C-j" . evil-window-down)
(push '("^\*helm-.+\*$" :regexp t) popwin:special-display-config) ("C-p" . helm-ag-neotree-node)
)
:init
;; Alchemist Settings (hl-line-mode)
(use-package alchemist (setq neo-theme (if (display-graphic-p) 'icons 'arrow))
:ensure t (setq-default neo-show-hidden-files t))
:config
(setq alchemist-mix-env "prod")
(setq alchemist-goto-elixir-source-dir "~/source_code/elixir/") ;; Whitespace Settings
(setq alchemist-goto-erlang-source-dir "~/source_code/otp/") (use-package whitespace
:init :ensure t
(linum-mode)) :commands (whitespace-mode)
:config
(defun custom-erlang-mode-hook () (setq whitespace-line-column 100)
"Jump to and from Elixir, Erlang, Elixir files." (setq whitespace-style '(face lines-tail)))
(define-key erlang-mode-map (kbd "M-,") 'alchemist-goto-jump-back))
(add-hook 'erlang-mode-hook 'custom-erlang-mode-hook) ;; Helm Settings
(use-package helm
:ensure t
(defun helm-ag-neotree-node () :commands (helm-mode)
"Run Helm-ag on Neotree directory." :bind (
(interactive) ("M-x" . helm-M-x)
(let ((search-root (neo-buffer--get-filename-current-line))) ("M-y" . helm-show-kill-ring)
(if search-root ("C-x b" . helm-mini)
;; search directory :map helm-map
(progn ("TAB" . helm-execute-persistent-action)
(evil-window-right 1) ("C-z" . helm-select-action)
(helm-ag search-root)) :term-raw-map
(message "Could not find directory at point.")))) ("M-x" . helm-M-x))
:init
(setq helm-buffers-fuzzy-matching t)
;; NeoTree Settings (setq helm-recentf-fuzzy-match t)
(use-package neotree (setq helm-semantic-fuzzy-match t)
:ensure t (setq helm-imenu-fuzzy-match t)
:bind (:map neotree-mode-map (setq helm-locate-fuzzy-match t))
("j" . next-line)
("k" . previous-line)
("<return>" . neotree-enter) ;; Helm Projectile Settings
("<tab>" . neotree-enter) (use-package helm-projectile
("D" . neotree-delete-node) :ensure t)
("R" . neotree-rename-node)
("c" . neotree-create-node)
("C-h" . evil-window-left) ;; Elm Mode
("C-l" . evil-window-right) (use-package elm-mode
("C-k" . evil-window-up) :config
("C-j" . evil-window-down) (add-to-list 'company-backends 'company-elm))
("C-p" . helm-ag-neotree-node)
)
:init ;; Company Settings
(hl-line-mode) (use-package company
(setq neo-theme (if (display-graphic-p) 'icons 'arrow)) :bind (
(setq-default neo-show-hidden-files t)) ("C-j" . company-select-next)
("C-k" . company-select-previous))
(defun neotree-toggle-project-dir () :config
"Toggle neotree sidebar." (setq company-idle-delay 0))
(interactive)
(let ((project-dir (projectile-project-root))
(file-name (buffer-file-name))) (add-hook 'after-init-hook 'evil-mode)
(neotree-toggle) (add-hook 'after-init-hook 'global-whitespace-mode)
(if project-dir (add-hook 'after-init-hook 'global-hl-line-mode)
(if (neo-global--window-exists-p) (add-hook 'after-init-hook 'global-linum-mode)
(progn (add-hook 'after-init-hook 'global-flycheck-mode)
(neotree-dir project-dir) (add-hook 'after-init-hook 'global-company-mode)
(neotree-show) (add-hook 'after-init-hook 'projectile-mode)
(evil-window-mru))) (add-hook 'after-init-hook 'helm-mode)
(message "Could not find git project root.")))) (add-hook 'before-save-hook 'delete-trailing-whitespace)
(defun neotree-reveal-current-buffer () ;; Scrolling Settings
"Reveal current buffer in Neotree." (setq scroll-step 1)
(interactive) (setq scroll-conservatively 10000)
(let ((project-dir (projectile-project-root))
(file-name (buffer-file-name)))
(neotree-show) ;; Properly configure GUI Emacs to use $PATH values
(if project-dir (when (memq window-system '(mac ns))
(if (neo-global--window-exists-p) (exec-path-from-shell-initialize))
(progn
(neotree-dir project-dir)
(neotree-find file-name) ;; Emacs backup / autosave files
(evil-window-mru))) ;; (setq-default make-backup-files nil)
(message "Could not find git project root.")))) (setq backup-directory-alist `(("." . "~/.emacs-tmp")))
(setq auto-save-file-name-transforms `((".*" "~/.emacs-tmp/" t)))
(defun message-project-root ()
"Outputs project-root." ;; Automatically follow symlinks
(interactive) (setq vc-follow-symlinks t)
(let (project-dir (projectile-project-root))
(if project-dir
(message "Project dir found!") ;; Commenting / Uncommenting
(message "No project-dir found.")))) (global-set-key (kbd "C-x C-;") 'comment-or-uncomment-region)
;; Whitespace Settings ;; Fullscreen settings
(use-package whitespace (setq ns-use-native-fullscreen nil)
:ensure t (global-set-key (kbd "<s-return>") 'toggle-frame-fullscreen)
:commands (whitespace-mode)
:config
(setq whitespace-line-column 100) ;; General Settings
(setq whitespace-style '(face lines-tail))) ;; Hide the menu-bar
(setq ns-auto-hide-menu-bar t)
;; Helm Settings ;; Native App Settings
(use-package helm (tool-bar-mode -1)
:ensure t
:commands (helm-mode) ;; Disable GUI scrollbars
:bind ( (when (display-graphic-p)
("M-x" . helm-M-x) (scroll-bar-mode -1)
("M-y" . helm-show-kill-ring) )
("C-x b" . helm-mini)
:map helm-map ;; Use spaces instead of tabs
("TAB" . helm-execute-persistent-action) (setq-default indent-tabs-mode nil)
("C-z" . helm-select-action)
:term-raw-map ;; Change font settings
("M-x" . helm-M-x)) (add-to-list 'default-frame-alist '(font . "Menlo-12"))
:init
(setq helm-buffers-fuzzy-matching t)
(setq helm-recentf-fuzzy-match t)
(setq helm-semantic-fuzzy-match t)
(setq helm-imenu-fuzzy-match t)
(setq helm-locate-fuzzy-match t))
;; Helm Projectile Settings
(use-package helm-projectile
:ensure t)
;; Elm Mode
(use-package elm-mode
:config
(add-to-list 'company-backends 'company-elm))
;; Company Settings
(use-package company
:bind (
("C-j" . company-select-next)
("C-k" . company-select-previous))
:config
(setq company-idle-delay 0))
(add-hook 'after-init-hook 'evil-mode)
(add-hook 'after-init-hook 'global-whitespace-mode)
(add-hook 'after-init-hook 'global-hl-line-mode)
(add-hook 'after-init-hook 'global-linum-mode)
(add-hook 'after-init-hook 'global-flycheck-mode)
(add-hook 'after-init-hook 'global-company-mode)
(add-hook 'after-init-hook 'projectile-mode)
(add-hook 'after-init-hook 'helm-mode)
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;; Scrolling Settings
(setq scroll-step 1)
(setq scroll-conservatively 10000)
;; Properly configure GUI Emacs to use $PATH values
(when (memq window-system '(mac ns))
(exec-path-from-shell-initialize))
;; Emacs backup / autosave files
;; (setq-default make-backup-files nil)
(setq backup-directory-alist `(("." . "~/.emacs-tmp")))
(setq auto-save-file-name-transforms `((".*" "~/.emacs-tmp/" t)))
;; Automatically follow symlinks
(setq vc-follow-symlinks t)
;; Commenting / Uncommenting
(global-set-key (kbd "C-x C-;") 'comment-or-uncomment-region)
;; Fullscreen settings
(setq ns-use-native-fullscreen nil)
(global-set-key (kbd "<s-return>") 'toggle-frame-fullscreen)
;; General Settings
;; Hide the menu-bar
(setq ns-auto-hide-menu-bar t)
;; Native App Settings
(tool-bar-mode -1)
;; Disable GUI scrollbars
(when (display-graphic-p)
(scroll-bar-mode -1)
)
;; Use spaces instead of tabs
(setq-default indent-tabs-mode nil)
;; Change font settings
(add-to-list 'default-frame-alist '(font . "Menlo-12"))
;; Force save buffers
(defun save-buffer-always ()
"Save the buffer even if it is not modified."
(interactive)
(set-buffer-modified-p t)
(save-buffer))
(global-set-key (kbd "C-x C-s") nil)
(global-set-key (kbd "C-x C-s") 'save-buffer-always)
;; Upgrade all packages
(defun package-upgrade-all ()
"Upgrade all packages automatically without showing *Packages* buffer."
(interactive)
(package-refresh-contents)
(let (upgrades)
(cl-flet ((get-version (name where)
(let ((pkg (cadr (assq name where))))
(when pkg
(package-desc-version pkg)))))
(dolist (package (mapcar #'car package-alist))
(let ((in-archive (get-version package package-archive-contents)))
(when (and in-archive
(version-list-< (get-version package package-alist)
in-archive))
(push (cadr (assq package package-archive-contents))
upgrades)))))
(if upgrades
(when (yes-or-no-p
(message "Upgrade %d package%s (%s)? "
(length upgrades)
(if (= (length upgrades) 1) "" "s")
(mapconcat #'package-desc-full-name upgrades ", ")))
(save-window-excursion
(dolist (package-desc upgrades)
(let ((old-package (cadr (assq (package-desc-name package-desc)
package-alist))))
(package-install package-desc)
(package-delete old-package)))))
(message "All packages are up to date"))))
;; Colorscheme ;; Colorscheme
@ -699,3 +540,4 @@
;; Add transparency ;; Add transparency
(set-frame-parameter (selected-frame) 'alpha '(100 . 100)) (set-frame-parameter (selected-frame) 'alpha '(100 . 100))
(add-to-list 'default-frame-alist '(alpha . (100 . 100))) (add-to-list 'default-frame-alist '(alpha . (100 . 100)))
(put 'narrow-to-region 'disabled nil)

View file

@ -0,0 +1,199 @@
(defun wc/projectile-shell-pop ()
"Opens `ansi-term' at the project root according to Projectile."
(interactive)
(let ((default-directory (projectile-project-root)))
(if (get-buffer "*ansi-term*")
(switch-to-buffer "*ansi-term*")
(ansi-term "/bin/zsh"))
(term-send-string (terminal) (format "cd '%s'\n" default-directory))
(get-buffer-process "*ansi-term*")))
(defun wc/join-erc ()
"Boots `erc' and autojoins channels."
(interactive)
(erc :server "irc.freenode.net" :port "6667" :nick "wpcarro"))
(defun wc/bootstrap-ansi-term ()
"Custom `ansi-term' configuration."
(interactive)
(linum-mode nil)
(local-set-key (kbd "C-h") 'evil-window-left)
(local-set-key (kbd "C-l") 'evil-window-right)
(local-set-key (kbd "C-k") 'evil-window-up)
(local-set-key (kbd "C-j") 'evil-window-down)
(define-key term-raw-map (kbd "s-v") 'term-paste))
(defun wc/ansi-term-paste (&amp;optional string)
"Paste into `ansi-term'."
(interactive)
(process-send-string
(get-buffer-process (current-buffer))
(if string string (current-kill 0)))))
(defun evil-window-vsplit-right ()
"Vertically split a window and move right."
(interactive)
(evil-window-vsplit nil)
(evil-window-right 1))
(defun evil-window-split-down ()
"Split a window and move right."
(interactive)
(evil-window-split nil)
(evil-window-down 1))
(defun wc/switch-to-mru-buffer ()
"Switches to the most recently used buffer, including visible buffers."
(interactive)
(switch-to-buffer (other-buffer (current-buffer) t (selected-frame))))
(defun *-popwin-help-mode-off ()
"Turn `popwin-mode' off for *Help* buffers."
(when (boundp 'popwin:special-display-config)
(customize-set-variable 'popwin:special-display-config
(delq 'help-mode popwin:special-display-config))))
(defun *-popwin-help-mode-on ()
"Turn `popwin-mode' on for *Help* buffers."
(when (boundp 'popwin:special-display-config)
(customize-set-variable 'popwin:special-display-config
(add-to-list 'popwin:special-display-config 'help-mode nil #'eq))))
(defun wc/custom-erlang-mode-hook ()
"Jump to and from Elixir, Erlang, Elixir files."
(define-key erlang-mode-map (kbd "M-,") 'alchemist-goto-jump-back))
(defun helm-ag-neotree-node ()
"Run Helm-ag on Neotree directory."
(interactive)
(let ((search-root (neo-buffer--get-filename-current-line)))
(if search-root
;; search directory
(progn
(evil-window-right 1)
(helm-ag search-root))
(message "Could not find directory at point."))))
(defun neotree-toggle-project-dir ()
"Toggle neotree sidebar."
(interactive)
(let ((project-dir (projectile-project-root))
(file-name (buffer-file-name)))
(neotree-toggle)
(if project-dir
(if (neo-global--window-exists-p)
(progn
(neotree-dir project-dir)
(neotree-show)
(evil-window-mru)))
(message "Could not find git project root."))))
(defun neotree-reveal-current-buffer ()
"Reveal current buffer in Neotree."
(interactive)
(let ((project-dir (projectile-project-root))
(file-name (buffer-file-name)))
(neotree-show)
(if project-dir
(if (neo-global--window-exists-p)
(progn
(neotree-dir project-dir)
(neotree-find file-name)
(evil-window-mru)))
(message "Could not find git project root."))))
(defun save-buffer-always ()
"Save the buffer even if it is not modified."
(interactive)
(set-buffer-modified-p t)
(save-buffer))
(global-set-key (kbd "C-x C-s") nil)
(global-set-key (kbd "C-x C-s") 'save-buffer-always)
;; Upgrade all packages
(defun package-upgrade-all ()
"Upgrade all packages automatically without showing *Packages* buffer."
(interactive)
(package-refresh-contents)
(let (upgrades)
(cl-flet ((get-version (name where)
(let ((pkg (cadr (assq name where))))
(when pkg
(package-desc-version pkg)))))
(dolist (package (mapcar #'car package-alist))
(let ((in-archive (get-version package package-archive-contents)))
(when (and in-archive
(version-list-< (get-version package package-alist)
in-archive))
(push (cadr (assq package package-archive-contents))
upgrades)))))
(if upgrades
(when (yes-or-no-p
(message "Upgrade %d package%s (%s)? "
(length upgrades)
(if (= (length upgrades) 1) "" "s")
(mapconcat #'package-desc-full-name upgrades ", ")))
(save-window-excursion
(dolist (package-desc upgrades)
(let ((old-package (cadr (assq (package-desc-name package-desc)
package-alist))))
(package-install package-desc)
(package-delete old-package)))))
(message "All packages are up to date"))))
(defun message-project-root ()
"Outputs project-root."
(interactive)
(let (project-dir (projectile-project-root))
(if project-dir
(message "Project dir found!")
(message "No project-dir found."))))
;; Upgrade all packages
(defun package-upgrade-all ()
"Upgrade all packages automatically without showing *Packages* buffer."
(interactive)
(package-refresh-contents)
(let (upgrades)
(cl-flet ((get-version (name where)
(let ((pkg (cadr (assq name where))))
(when pkg
(package-desc-version pkg)))))
(dolist (package (mapcar #'car package-alist))
(let ((in-archive (get-version package package-archive-contents)))
(when (and in-archive
(version-list-< (get-version package package-alist)
in-archive))
(push (cadr (assq package package-archive-contents))
upgrades)))))
(if upgrades
(when (yes-or-no-p
(message "Upgrade %d package%s (%s)? "
(length upgrades)
(if (= (length upgrades) 1) "" "s")
(mapconcat #'package-desc-full-name upgrades ", ")))
(save-window-excursion
(dolist (package-desc upgrades)
(let ((old-package (cadr (assq (package-desc-name package-desc)
package-alist))))
(package-install package-desc)
(package-delete old-package)))))
(message "All packages are up to date"))))