First commit.
This commit is contained in:
16
lisp/utilities/abbrev.el
Normal file
16
lisp/utilities/abbrev.el
Normal file
@@ -0,0 +1,16 @@
|
||||
;;; abbrev.el --- Configure Emacs abbreviations -*- lexical-binding: t; -*-
|
||||
;;; Commentary:
|
||||
;;; Code:
|
||||
;;; Doc: https://www.emacswiki.org/emacs/AbbrevMode
|
||||
|
||||
(use-package abbrev
|
||||
:disabled
|
||||
:ensure nil
|
||||
:diminish abbrev-mode
|
||||
:config
|
||||
(validate-setq
|
||||
abbrev-file-name (path-join *user-data-directory* "abbrev_defs")))
|
||||
|
||||
|
||||
(provide 'utilities/abbrev)
|
||||
;;; abbrev.el ends here
|
32
lisp/utilities/ag.el
Normal file
32
lisp/utilities/ag.el
Normal file
@@ -0,0 +1,32 @@
|
||||
;;; ag.el --- interface to The Silver Searcher -*- lexical-binding: t; -*-
|
||||
;;; Commentary:
|
||||
;;; Code: https://github.com/emacsorphanage/helm-ag
|
||||
|
||||
(with-executable 'ag
|
||||
(when (feature-p 'helm)
|
||||
(use-package helm-ag
|
||||
:defer
|
||||
:config
|
||||
(validate-setq
|
||||
;; Insert word at point as search term.
|
||||
helm-ag-insert-at-point 'word)))
|
||||
(use-package ag
|
||||
:defer
|
||||
:init
|
||||
(if (and (feature-p 'projectile)
|
||||
(fboundp 'projectile-ag))
|
||||
(global-set-key [remap find-grep] 'projectile-ag)
|
||||
(global-set-key [remap find-grep] 'ag))
|
||||
:config
|
||||
(validate-setq
|
||||
ag-project-root-function
|
||||
'(lambda ()
|
||||
(with-project project (path-buffer-abs)
|
||||
(user/proj-root project))))
|
||||
|
||||
;; Search inside compressed files.
|
||||
(add-to-list 'ag-arguments "--search-zip")))
|
||||
|
||||
|
||||
(provide 'utilities/ag)
|
||||
;;; ag.el ends here
|
26
lisp/utilities/alert.el
Normal file
26
lisp/utilities/alert.el
Normal file
@@ -0,0 +1,26 @@
|
||||
;;; alert.el --- Emacs notifications. -*- lexical-binding: t; -*-
|
||||
;;; Commentary:
|
||||
;;; Code: https://github.com/jwiegley/alert
|
||||
|
||||
(defun user/alert-style ()
|
||||
"Get the preferred alert style."
|
||||
(cond
|
||||
((eq system-type 'darwin) 'growl)
|
||||
((executable-find "notify-send") 'libnotify)
|
||||
((executable-find "dbus-send") 'notifications)
|
||||
(t 'mode-line)))
|
||||
|
||||
(use-package alert
|
||||
:defer
|
||||
:config
|
||||
;; Undiagnosed issue with validate-setq.
|
||||
(setq
|
||||
;; Send alerts to alert buffer.
|
||||
alert-default-style (user/alert-style))
|
||||
(validate-setq
|
||||
;; Disable log.
|
||||
alert-log-messages nil))
|
||||
|
||||
|
||||
(provide 'utilities/alert)
|
||||
;;; alert.el ends here
|
28
lisp/utilities/auth-source.el
Normal file
28
lisp/utilities/auth-source.el
Normal file
@@ -0,0 +1,28 @@
|
||||
;;; auth-source.el --- Configure Emacs authentication sources -*- lexical-binding: t; -*-
|
||||
;;; Commentary:
|
||||
;;; Code: https://github.com/emacs-mirror/emacs/blob/master/lisp/auth-source.el
|
||||
;;; Doc: https://www.gnu.org/software/emacs/manual/html_mono/auth.html
|
||||
|
||||
(use-package auth-source
|
||||
:disabled
|
||||
:ensure nil
|
||||
:defer
|
||||
:config
|
||||
(validate-setq
|
||||
auth-sources
|
||||
`(,(path-join *user-data-directory* "authinfo.gpg")
|
||||
|
||||
,(path-join *user-data-directory* "authinfo")))
|
||||
|
||||
(dolist (source auth-sources)
|
||||
(when (file-exists-p source)
|
||||
(set-file-modes source #o0600)))
|
||||
|
||||
(when (eq system-type 'darwin)
|
||||
(add-many-to-list 'auth-sources
|
||||
'macos-keychain-internet
|
||||
'macos-keychain-generic)))
|
||||
|
||||
|
||||
(provide 'utilities/auth-source)
|
||||
;;; auth-source.el ends here
|
98
lisp/utilities/bookmarks.el
Normal file
98
lisp/utilities/bookmarks.el
Normal file
@@ -0,0 +1,98 @@
|
||||
;;; bookmarks.el --- Bookmarks in Emacs -*- lexical-binding: t; -*-
|
||||
;;; Commentary:
|
||||
;;; Code:
|
||||
;;; Doc: https://www.emacswiki.org/emacs/VisibleBookmarks
|
||||
|
||||
(defconst *visible-bookmarks-data-file* (path-join *user-data-directory*
|
||||
"visible-bookmarks"))
|
||||
(defconst *bookmark+-data-file* (path-join *user-data-directory* "bookmarks"))
|
||||
(defconst *bookmark+-menu-state-file* (path-join *user-cache-directory*
|
||||
"bookmark-menu-state.el"))
|
||||
|
||||
(defun bookmark--local-directory-bookmarks-to-zsh ()
|
||||
"Store Emacs bookmarks in ZSH bookmarks file."
|
||||
(interactive)
|
||||
(when (and (require 'tramp nil t)
|
||||
(require 'bookmark nil t))
|
||||
(set-buffer (find-file-noselect "~/.zsh_bookmarks" t t))
|
||||
(delete-region (point-min) (point-max))
|
||||
(insert "# -*- mode:sh -*-\n")
|
||||
(let (collect-names)
|
||||
(mapc (lambda (item)
|
||||
(let ((name (replace-regexp-in-string "-" "_" (car item)))
|
||||
(file (cdr (assoc 'filename
|
||||
(if (cddr item) item (cadr item))))))
|
||||
(when (and (not (tramp-tramp-file-p file))
|
||||
(file-directory-p file))
|
||||
(setq collect-names (cons (concat "~" name) collect-names))
|
||||
(insert (format "%s=\"%s\"\n" name (expand-file-name file))))))
|
||||
bookmark-alist)
|
||||
(insert ": " (mapconcat 'identity collect-names " ") "\n"))
|
||||
(let ((backup-inhibited t)) (save-buffer))
|
||||
(kill-buffer (current-buffer))))
|
||||
|
||||
|
||||
(use-package bm
|
||||
:defer
|
||||
:init
|
||||
(user/bind-key-global :code :bookmark-toggle 'bm-toggle)
|
||||
(user/bind-key-global :code :bookmark-next 'bm-next)
|
||||
(user/bind-key-global :code :bookmark-prev 'bm-previous)
|
||||
:config
|
||||
(validate-setq
|
||||
;; Persistent bookmarks.
|
||||
bm-repository-file *visible-bookmarks-data-file*
|
||||
bm-buffer-persistence t)
|
||||
|
||||
;; Restore bookmarks on file find.
|
||||
(add-hook 'find-file-hooks 'bm-buffer-restore)
|
||||
;; Save bookmarks when killing buffer.
|
||||
(add-hook 'kill-buffer-hook 'bm-buffer-save)
|
||||
;; Save all bookmarks on exit.
|
||||
(add-hook 'kill-emacs-hook 'bm-save)
|
||||
;; Update repository when saving file.
|
||||
(add-hook 'after-save-hook 'bm-buffer-save)
|
||||
;; Restore bookmarks when buffer is reverted.
|
||||
(add-hook 'after-revert-hook 'bm-buffer-restore))
|
||||
|
||||
(use-package bookmark
|
||||
:disabled
|
||||
:defer
|
||||
:init
|
||||
;; Bind bookmarks to C-c b
|
||||
(global-set-key (user/get-key :code :bookmark-prefix) 'bookmark-map)
|
||||
:config
|
||||
(validate-setq
|
||||
;; Enable versioned backups.
|
||||
bookmark-version-control t
|
||||
bookmark-save-flag 1
|
||||
;; Put the repository in the data directory.
|
||||
bookmark-default-file *bookmark+-data-file*)
|
||||
|
||||
;; Share Emacs directory bookmarks with ZSH.
|
||||
(defadvice bookmark-write-file
|
||||
(after local-directory-bookmarks-to-zsh-advice activate)
|
||||
(bookmark--local-directory-bookmarks-to-zsh))
|
||||
|
||||
(use-package bookmark+
|
||||
:disabled
|
||||
:config
|
||||
(validate-setq
|
||||
;; Save bookmarks after ten updates.
|
||||
bmkp-count-multi-mods-as-one-flag t)
|
||||
|
||||
;;; (Bindings) ;;;
|
||||
(define-key bookmark-map (kbd "l") 'bookmark-jump)
|
||||
(define-key bookmark-map (kbd "e") 'bmkp-edit-bookmark-record)
|
||||
(define-key bookmark-map (kbd "t") 'bmkp-add-tags)
|
||||
|
||||
(use-package bookmark+-bmu
|
||||
:ensure bookmark+
|
||||
:config
|
||||
(validate-setq
|
||||
;; Put the menu state in the cache directory.
|
||||
bmkp-bmenu-state-file *bookmark+-menu-state-file*))))
|
||||
|
||||
|
||||
(provide 'utilities/bookmarks)
|
||||
;;; bookmarks.el ends here
|
74
lisp/utilities/compile.el
Normal file
74
lisp/utilities/compile.el
Normal file
@@ -0,0 +1,74 @@
|
||||
;;; compile.el --- sets up Emacs compile support -*- lexical-binding: t; -*-
|
||||
;;; Commentary:
|
||||
;;; Code:
|
||||
|
||||
(defun user--compilation-mode-hook ()
|
||||
"Compilation mode hook.")
|
||||
|
||||
|
||||
(defun user--compilation-filter-hook ()
|
||||
"Hook for filtering compilation output."
|
||||
;; Temporarily make buffer writable.
|
||||
(let ((inhibit-read-only t))
|
||||
;; Colorize compilation output.
|
||||
(ansi-color-apply-on-region (point-min) (point-max))))
|
||||
|
||||
|
||||
(defun user/compile ()
|
||||
"Compile current context."
|
||||
(interactive)
|
||||
(let ((ede-proj (user/proj-from-path user/ede-proj (path-abs-buffer))))
|
||||
(cond
|
||||
(ede-proj (user/proj-build ede-proj))
|
||||
((feature-p 'flex-compile) (call-interactively 'flex-compile-compile))
|
||||
((fboundp 'mode-compile) (call-interactively 'mode-compile))
|
||||
(t (call-interactively 'compile)))))
|
||||
|
||||
;; https://www.emacswiki.org/emacs/CompileCommand
|
||||
(use-package compile
|
||||
:defer
|
||||
:init
|
||||
(user/bind-key-global :code :compile 'user/compile)
|
||||
:hook ((compilation-mode-hook . user--compilation-mode-hook)
|
||||
(compilation-filter-hook . user--compilation-filter-hook))
|
||||
:config
|
||||
(validate-setq
|
||||
;; Prevent input in compilation buffer.
|
||||
compilation-disable-input nil
|
||||
;; Automatically scroll output.
|
||||
compilation-scroll-output t)
|
||||
|
||||
(with-eval-after-load 'popwin
|
||||
(add-to-list
|
||||
'popwin:special-display-config
|
||||
;; Don't select compilation window when shown
|
||||
'(compilation-mode :height 20 :dedicated t)))
|
||||
|
||||
;; https://github.com/plandes/flex-compile
|
||||
(use-package flex-compile
|
||||
:disabled
|
||||
:pin "MELPA")
|
||||
|
||||
;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Compilation-Mode.html
|
||||
(use-package mode-compile
|
||||
:defer
|
||||
:config
|
||||
;; Ensure byte-run has been loaded or mode-compile will override
|
||||
;; `define-obsolete-variable-alias'.
|
||||
(when (load "byte-run.el" nil :noerror)
|
||||
(validate-setq
|
||||
;; Set a sane compilation frame name.
|
||||
mode-compile-other-frame-name "*compilation*"
|
||||
;; Run make with low priority and use multiple processes.
|
||||
mode-compile-make-program "nice make"
|
||||
mode-compile-default-make-options "-k -j"
|
||||
;; Save the current buffer on compilation.
|
||||
mode-compile-always-save-buffer-p t)
|
||||
|
||||
(with-executable 'clang
|
||||
(add-to-list 'cc-compilers-list "clang")
|
||||
(add-to-list 'c++-compilers-list "clang++")))))
|
||||
|
||||
|
||||
(provide 'utilities/compile)
|
||||
;;; compile.el ends here
|
11
lisp/utilities/coverage.el
Normal file
11
lisp/utilities/coverage.el
Normal file
@@ -0,0 +1,11 @@
|
||||
;;; coverage.el --- Code coverage tools -*- lexical-binding: t; -*-
|
||||
;;; Commentary:
|
||||
;;; Code: https://github.com/AdamNiederer/cov
|
||||
|
||||
;; TODO: Update to use cov for all modes
|
||||
;; TODO: Add pycoverage management
|
||||
(use-package cov
|
||||
:defer)
|
||||
|
||||
(provide 'utilities/coverage)
|
||||
;;; coverage.el ends here
|
13
lisp/utilities/ctable.el
Normal file
13
lisp/utilities/ctable.el
Normal file
@@ -0,0 +1,13 @@
|
||||
;;; ctable --- Table component for Emacs -*- lexical-binding: t; -*-
|
||||
;;; Commentary:
|
||||
;;; Code: https://github.com/kiwanami/emacs-ctable
|
||||
|
||||
(use-package ctable
|
||||
:disabled
|
||||
:defer
|
||||
:init
|
||||
(autoload 'make-ctbl:cmodel "ctable"))
|
||||
|
||||
|
||||
(provide 'utilities/ctable)
|
||||
;;; ctable.el ends here
|
26
lisp/utilities/dap.el
Normal file
26
lisp/utilities/dap.el
Normal file
@@ -0,0 +1,26 @@
|
||||
;;; dap.el --- Debug adapter protocol. -*- lexical-binding: t; -*-
|
||||
;;; Commentary: Emacs client/library for Debug Adapter Protocol is a wire protocol for communication between client and Debug Server.
|
||||
;;; Code: https://github.com/emacs-lsp/dap-mode
|
||||
|
||||
(use-package dap-mode
|
||||
:disabled
|
||||
:pin "MELPA"
|
||||
:hook ((lsp-mode-hook . dap-mode)
|
||||
(lsp-mode-hook . dap-ui-mode))
|
||||
:bind-wrap
|
||||
(:map lsp-mode-map
|
||||
((:key :debug :break) . dap-breakpoint-toggle)
|
||||
((:key :debug :step) . dap-step-in)
|
||||
((:key :debug :next) . dap-next)
|
||||
((:key :debug :run) . dap-debug)
|
||||
((:key :debug :continue) . dap-continue)
|
||||
|
||||
((:key :debug :show-value) . dap-ui-inspect-thing-at-point))
|
||||
:config
|
||||
(validate-setq
|
||||
;; Location of persistent breakpoints.
|
||||
dap-breakpoints-file (path-join *user-cache-directory* "dap-breakpoints")))
|
||||
|
||||
|
||||
(provide 'utilities/dap)
|
||||
;;; dap.el ends here
|
12
lisp/utilities/dash.el
Normal file
12
lisp/utilities/dash.el
Normal file
@@ -0,0 +1,12 @@
|
||||
;;; dash.el --- Dash documentation reading -*- lexical-binding: t; -*-
|
||||
;;; Commentary: This package provides an elisp interface to query and show documenation using Dash docsets.
|
||||
;;; Code: https://github.com/dash-docs-el/dash-docs
|
||||
|
||||
(use-package dash-docs
|
||||
:if (executable-find "sqlite3")
|
||||
:bind-wrap
|
||||
((:key :doc :reference) . helm-dash-at-point))
|
||||
|
||||
|
||||
(provide 'utilities/dash)
|
||||
;;; dash.el ends here
|
88
lisp/utilities/dired.el
Normal file
88
lisp/utilities/dired.el
Normal file
@@ -0,0 +1,88 @@
|
||||
;;; dired.el --- Configuration for dired -*- lexical-binding: t; -*-
|
||||
;;; Commentary: Dired is the main mode for Emacs file-manager operations. The name “Dired” stands for “directory editor”.
|
||||
;;; Code:
|
||||
;;; Docs: https://www.emacswiki.org/emacs/DiredMode
|
||||
|
||||
(defun user--dired-mode-hook ()
|
||||
"Mode hook for dired."
|
||||
(with-feature 'async
|
||||
;; Asynchronous operations in dired.
|
||||
(dired-async-mode t)))
|
||||
|
||||
(use-package dired
|
||||
:ensure nil
|
||||
:defer
|
||||
:config
|
||||
(validate-setq
|
||||
;; Always copy recursively without asking.
|
||||
dired-recursive-copies 'always
|
||||
;; Ask once when recursively deleting a directory.
|
||||
dired-recursive-deletes 'top
|
||||
;; Allow dired to be smart about operations.
|
||||
dired-dwim-target t
|
||||
;; Default flags for ls.
|
||||
dired-listing-switches "-alh")
|
||||
|
||||
;;; (Packages) ;;;
|
||||
;; https://github.com/purcell/diredfl
|
||||
;; Extra font lock rules for a more colourful dired
|
||||
(use-package diredfl
|
||||
:disabled)
|
||||
;; https://github.com/emacsorphanage/dired-k
|
||||
;; highlights dired buffer like k.
|
||||
(use-package dired-k
|
||||
:disabled)
|
||||
;; https://github.com/clemera/dired-git-info
|
||||
;; This Emacs packages provides a minor mode which shows git information inside the dired buffer
|
||||
(use-package dired-git-info
|
||||
:disabled
|
||||
:bind (:map dired-mode-map
|
||||
(")" . dired-git-info-mode)))
|
||||
;; https://github.com/jwiegley/emacs-async
|
||||
;; async.el is a module for doing asynchronous processing in Emacs.
|
||||
(use-package async)
|
||||
;; https://github.com/juan-leon/dired-efap
|
||||
;; dired-efap.el allows the user to edit the filename at point, by hitting a key (like f2) or double-clicking it.
|
||||
(use-package dired-efap
|
||||
:config
|
||||
;;; (Bindings) ;;;
|
||||
(define-key dired-mode-map [R] 'dired-efap)
|
||||
(when (display-graphic-p)
|
||||
(define-key dired-mode-map [down-mouse-1] 'dired-efap-click))
|
||||
(with-eval-after-load 'dired
|
||||
;; Load dired-efap when dired is loaded.
|
||||
(require 'dired-efap)))
|
||||
;; https://github.com/jtbm37/all-the-icons-dired
|
||||
;; This adds dired support to all-the-icons.
|
||||
(use-package all-the-icons-dired
|
||||
:if window-system)
|
||||
;; https://github.com/stsquad/dired-rsync
|
||||
;; This package adds a single command dired-rsync which allows the user to copy marked files in a dired buffer via rsync.
|
||||
(use-package dired-rsync
|
||||
:disabled
|
||||
:if (executable-find "rsync")
|
||||
:bind (:map dired-mode-map
|
||||
("C-c C-r" . dired-rsync)))
|
||||
;; https://github.com/vifon/dired-recent.el
|
||||
;; A history of paths visited with Emacs dired.
|
||||
(use-package dired-recent
|
||||
:disabled
|
||||
:config
|
||||
(validate-setq
|
||||
;; Path to history database.
|
||||
dired-recent-directories-file (path-join *user-cache-directory* "dired-history"))
|
||||
|
||||
(dired-recent-mode t))
|
||||
|
||||
;;; (Bindings) ;;;
|
||||
;; Do not open new buffers when going down or up a directory.
|
||||
(define-key dired-mode-map (kbd "<return>") 'dired-find-alternate-file)
|
||||
(define-key dired-mode-map (kbd "^") (lambda ()
|
||||
(interactive)
|
||||
(find-alternate-file "..")))
|
||||
(when (display-graphic-p)
|
||||
(define-key dired-mode-map [double-mouse-1] 'dired-find-file)))
|
||||
|
||||
|
||||
(provide 'utilities/dired)
|
||||
;;; dired.el ends here
|
24
lisp/utilities/direx.el
Normal file
24
lisp/utilities/direx.el
Normal file
@@ -0,0 +1,24 @@
|
||||
;;; direx.el --- a simple directory explorer -*- lexical-binding: t; -*-
|
||||
;;; Commentary: direx.el is a simple directory explorer. It also works as a generic tree explore library.
|
||||
;;; Code: https://github.com/emacsorphanage/direx
|
||||
|
||||
(use-package direx
|
||||
:defer
|
||||
:init
|
||||
(user/bind-key-global :basic :open-file-context
|
||||
'direx-project:jump-to-project-root-other-window)
|
||||
:config
|
||||
(validate-setq
|
||||
;; Use the functionality from utilities/project to locate project root
|
||||
direx-project:project-root-predicate-functions
|
||||
'((lambda (path)
|
||||
(with-project-root project-root path
|
||||
(and path (equal (file-truename path) (file-truename project-root)))))))
|
||||
|
||||
(with-eval-after-load 'popwin
|
||||
(push '(direx:direx-mode :position left :width 30 :dedicated t)
|
||||
popwin:special-display-config)))
|
||||
|
||||
|
||||
(provide 'utilities/direx)
|
||||
;;; direx.el ends here
|
17
lisp/utilities/docker.el
Normal file
17
lisp/utilities/docker.el
Normal file
@@ -0,0 +1,17 @@
|
||||
;;; docker.el --- Configure Emacs docker support -*- lexical-binding: t; -*-
|
||||
;;; Commentary : Emacs integration for Docker!
|
||||
;;; Code: https://github.com/Silex/docker.el
|
||||
|
||||
(use-package docker
|
||||
:disabled
|
||||
:if (executable-find "docker")
|
||||
:diminish docker-mode
|
||||
:bind-wrap ((:key :util :docker) . docker)
|
||||
:config
|
||||
;; https://github.com/emacs-pe/docker-tramp.el
|
||||
;; docker-tramp.el offers a TRAMP method for Docker containers.
|
||||
(use-package docker-tramp))
|
||||
|
||||
|
||||
(provide 'utilities/docker)
|
||||
;;; docker.el ends here
|
92
lisp/utilities/ecb.el
Normal file
92
lisp/utilities/ecb.el
Normal file
@@ -0,0 +1,92 @@
|
||||
;;; ecb --- Emacs Code Browser -*- lexical-binding: t; -*-
|
||||
;;; Commentary: Emacs Code Browser
|
||||
;;; Code: https://github.com/ecb-home/ecb
|
||||
|
||||
(defvar user/ecb-active nil "Current state of ECB.")
|
||||
|
||||
|
||||
(defun user--ecb-activate-hook ()
|
||||
"ECB activation hook."
|
||||
(setq user/ecb-active t)
|
||||
|
||||
;; Popwin conflicts with ECB.
|
||||
(popwin-mode -1)
|
||||
|
||||
;; Close compile window if open
|
||||
(when (ecb-compile-window-live-p)
|
||||
(ecb-toggle-compile-window))
|
||||
|
||||
;;; (Bindings) ;;;
|
||||
(user/bind-key-local :basic :zoom 'ecb-toggle-ecb-windows)
|
||||
|
||||
(user/bind-key-local :nav :context 'ecb-goto-window-edit1)
|
||||
(user/bind-key-local :basic :open-file-context 'ecb-goto-window-directories)
|
||||
(user/bind-key-local :nav :history 'ecb-goto-window-history)
|
||||
(user/bind-key-local :nav :functions/toc 'ecb-goto-window-methods)
|
||||
(user/bind-key-local :code :compilation-result 'user/ecb-toggle-compile-window))
|
||||
|
||||
|
||||
(defun user--ecb-deactivate-hook ()
|
||||
"ECB deactivation hook."
|
||||
(setq user/ecb-active nil)
|
||||
(popwin-mode t))
|
||||
|
||||
|
||||
(defun user/ecb-toggle-active ()
|
||||
"Toggle ECB state."
|
||||
(interactive)
|
||||
(if user/ecb-active
|
||||
(ecb-deactivate)
|
||||
(ecb-activate)))
|
||||
|
||||
|
||||
(defun user/ecb-toggle-compile-window ()
|
||||
"Toggle the presence of the ECB compilation window."
|
||||
(interactive)
|
||||
(if (and (ecb-compile-window-live-p)
|
||||
(not (ecb-point-in-compile-window)))
|
||||
(ecb-goto-window-compilation)
|
||||
(progn
|
||||
(ecb-toggle-compile-window)
|
||||
(when (ecb-compile-window-live-p)
|
||||
(ecb-goto-window-compilation)))))
|
||||
|
||||
(when (version<= emacs-version "24.4")
|
||||
(use-package ecb
|
||||
:defer
|
||||
:init
|
||||
(add-hook 'ecb-activate-hook 'user--ecb-activate-hook)
|
||||
(add-hook 'ecb-deactivate-hook 'user--ecb-deactivate-hook)
|
||||
(user/bind-key-global :util :ecb-toggle 'user/ecb-toggle-active)
|
||||
:config
|
||||
;; ECB version checking code is very old so that it thinks that the latest
|
||||
;; CEDET/Emacs is not new enough when in fact it is years newer than the
|
||||
;; latest version that it is aware of. So simply bypass the version check.
|
||||
(validate-setq
|
||||
ecb-version-check nil
|
||||
ecb-tip-of-the-day nil
|
||||
;; ECB layout.
|
||||
ecb-layout-name "left6"
|
||||
ecb-layout-window-sizes '(("left6"
|
||||
(ecb-directories-buffer-name 0.17 . 0.41)
|
||||
(ecb-sources-buffer-name 0.17 . 0.21)
|
||||
(ecb-methods-buffer-name 0.17 . 0.41)
|
||||
(ecb-history-buffer-name 0.17 . 0.35)))
|
||||
ecb-show-sources-in-directories-buffer 'always
|
||||
ecb-compile-window-height 12)
|
||||
|
||||
(defadvice ecb-check-requirements (around no-version-check activate compile)
|
||||
"AROUND NO-VERSION-CHECK ACTIVATE COMPILE"
|
||||
(if (or (< emacs-major-version 23)
|
||||
(and (= emacs-major-version 23)
|
||||
(< emacs-minor-version 3)))
|
||||
ad-do-it))
|
||||
|
||||
(when (display-graphic-p)
|
||||
(with-eval-after-load 'ecb-face
|
||||
;; Use a slightly smaller face for the ECB tree-buffers.
|
||||
(set-face-attribute 'ecb-default-general-face nil :height 0.8)))))
|
||||
|
||||
|
||||
(provide 'utilities/ecb)
|
||||
;;; ecb.el ends here
|
85
lisp/utilities/ediff.el
Normal file
85
lisp/utilities/ediff.el
Normal file
@@ -0,0 +1,85 @@
|
||||
;;; ediff.el --- Configuration for ediff -*- lexical-binding: t; -*-
|
||||
;;; Commentary: A comprehensive visual interface to Unix diff and patch utilities
|
||||
;;; Code:
|
||||
;;; Doc: https://www.gnu.org/software/emacs/manual/html_mono/ediff.html
|
||||
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
|
||||
(defun user--ediff-mode-hook ()
|
||||
"Ediff mode hook."
|
||||
(setq
|
||||
;; Don't wrap long lines.
|
||||
truncate-lines t))
|
||||
|
||||
|
||||
(defun user--ediff-startup-hook ()
|
||||
"Ediff startup hook."
|
||||
(validate-setq
|
||||
;; Split window differently depending on frame width.
|
||||
ediff-split-window-function (if (> (frame-width) (* 2 80))
|
||||
'split-window-horizontally
|
||||
'split-window-vertically))
|
||||
|
||||
;; Go to the first difference on startup.
|
||||
(ediff-next-difference))
|
||||
|
||||
|
||||
(defun user/ediff-mergetool ()
|
||||
"Launch ediff as mergetool."
|
||||
(defun ediff-write-merge-buffer ()
|
||||
"Write merge buffer to file."
|
||||
(let ((file ediff-merge-store-file))
|
||||
(set-buffer ediff-buffer-C)
|
||||
(write-region (point-min) (point-max) file)
|
||||
(message "Merge buffer saved in: %s" file)
|
||||
(set-buffer-modified-p nil)
|
||||
(sit-for 1)))
|
||||
|
||||
(validate-setq
|
||||
ediff-quit-hook 'kill-emacs
|
||||
ediff-quit-merge-hook 'ediff-write-merge-buffer)
|
||||
|
||||
(let ((local (pop command-line-args-left))
|
||||
(remote (pop command-line-args-left))
|
||||
(base (pop command-line-args-left))
|
||||
(merged (pop command-line-args-left)))
|
||||
(lexical-let (;; Show only conflicts.
|
||||
(ediff-show-clashes-only t))
|
||||
(ediff-merge-files-with-ancestor local remote base nil merged))))
|
||||
|
||||
|
||||
(defun user/ediff-difftool ()
|
||||
"Launch ediff as difftool."
|
||||
(let ((local (pop command-line-args-left))
|
||||
(remote (pop command-line-args-left)))
|
||||
(ediff local remote)))
|
||||
|
||||
(use-package ediff
|
||||
:defer
|
||||
:init
|
||||
;; Go to first difference on start.
|
||||
(add-hook 'ediff-startup-hook 'user--ediff-startup-hook)
|
||||
:config
|
||||
(validate-setq
|
||||
;; Ignore changes in whitespace.
|
||||
ediff-diff-options "-w"
|
||||
ediff-ignore-similar-regions t)
|
||||
|
||||
(user/bind-key-global :util :diff 'ediff)
|
||||
|
||||
;; window manipulation utilities
|
||||
(use-package ediff-wind
|
||||
:ensure nil
|
||||
:config
|
||||
(validate-setq
|
||||
;; Don't create a separate frame for ediff.
|
||||
ediff-window-setup-function 'ediff-setup-windows-plain))
|
||||
;; https://github.com/fourier/ztree
|
||||
;; Ztree is a project dedicated to implementation of several text-tree applications
|
||||
(use-package ztree))
|
||||
|
||||
|
||||
(provide 'utilities/ediff)
|
||||
;;; ediff.el ends here
|
14
lisp/utilities/eldoc.el
Normal file
14
lisp/utilities/eldoc.el
Normal file
@@ -0,0 +1,14 @@
|
||||
;;; eldoc.el --- Show docstrings in echo area -*- lexical-binding: t; -*-
|
||||
;;; Commentary:
|
||||
;;; Code: https://github.com/emacs-mirror/emacs/blob/master/lisp/emacs-lisp/eldoc.el
|
||||
|
||||
(use-package eldoc
|
||||
:diminish eldoc-mode
|
||||
:config
|
||||
(use-package eldoc-eval
|
||||
:config
|
||||
(eldoc-in-minibuffer-mode t)))
|
||||
|
||||
|
||||
(provide 'utilities/eldoc)
|
||||
;;; eldoc.el ends here
|
11
lisp/utilities/emacs-everywhere.el
Normal file
11
lisp/utilities/emacs-everywhere.el
Normal file
@@ -0,0 +1,11 @@
|
||||
;;; emacs-everywhere.el --- Integrate Emacs with any application -*- lexical-binding: t; -*-
|
||||
;;; Commentary:
|
||||
;;; Code: https://github.com/tecosaur/emacs-everywhere
|
||||
|
||||
(use-package emacs-everywhere
|
||||
:disabled
|
||||
:ensure t)
|
||||
|
||||
|
||||
(provide 'utilities/emacs-everywhere)
|
||||
;;; emacs-everywhere.el ends here
|
15
lisp/utilities/emms.el
Normal file
15
lisp/utilities/emms.el
Normal file
@@ -0,0 +1,15 @@
|
||||
;;; emms --- Emacs Multimedia System -*- lexical-binding: t; -*-
|
||||
;;; Commentary:
|
||||
;;; Code: https://www.gnu.org/software/emms/
|
||||
|
||||
(use-package emms
|
||||
:commands (emms-streams)
|
||||
:config
|
||||
(emms-standard)
|
||||
(emms-default-players)
|
||||
(emms-mode-line nil)
|
||||
(require 'emms-streams)
|
||||
(setq emms-streams-file (path-join *user-data-directory* "streams.emms")))
|
||||
|
||||
(provide 'utilities/emms)
|
||||
;;; emms.el ends here
|
11
lisp/utilities/epc.el
Normal file
11
lisp/utilities/epc.el
Normal file
@@ -0,0 +1,11 @@
|
||||
;;; epc.el --- RPC stack for Emacs -*- lexical-binding: t; -*-
|
||||
;;; Commentary: This program is an asynchronous RPC stack for Emacs
|
||||
;;; Code: https://github.com/kiwanami/emacs-epc
|
||||
|
||||
(use-package epc
|
||||
:disabled
|
||||
:defer)
|
||||
|
||||
|
||||
(provide 'utilities/epc)
|
||||
;;; epc.el ends here
|
87
lisp/utilities/flycheck.el
Normal file
87
lisp/utilities/flycheck.el
Normal file
@@ -0,0 +1,87 @@
|
||||
;;; flycheck.el --- flycheck configuration -*- lexical-binding: t; -*-
|
||||
;;; Commentary: https://www.flycheck.org/en/latest/
|
||||
;;; Code: https://github.com/flycheck/flycheck
|
||||
|
||||
(defun user--flycheck-mode-hook ()
|
||||
"Flycheck mode hook."
|
||||
;;; (Bindings) ;;;
|
||||
(user/bind-key-local :code :warnings/errors 'helm-flycheck)
|
||||
(user/bind-key-local :nav :next 'flycheck-next-error))
|
||||
|
||||
|
||||
(defun user/ede-flycheck-setup ()
|
||||
"Configure `flycheck' using `ede'."
|
||||
(when (and ede-object
|
||||
(slot-exists-p ede-object 'compilation)
|
||||
(oref ede-object compilation))
|
||||
(let* ((comp (oref ede-object compilation))
|
||||
(cmd (get-command-line comp)))
|
||||
(setq
|
||||
flycheck-clang-includes (get-includes comp)
|
||||
flycheck-clang-definitions (get-defines comp)
|
||||
flycheck-clang-include-path (oref comp include-path-common))
|
||||
|
||||
(when (string-match " -std=\\([^ ]+\\)" cmd)
|
||||
(setq
|
||||
flycheck-clang-language-standard (match-string 1 cmd)
|
||||
flycheck-gcc-language-standard (match-string 1 cmd)))
|
||||
(when (string-match " -stdlib=\\([^ ]+\\)" cmd)
|
||||
(setq flycheck-clang-standard-library (match-string 1 cmd)))
|
||||
(when (string-match " -fms-extensions " cmd)
|
||||
(setq flycheck-clang-ms-extensions t))
|
||||
(when (string-match " -fno-exceptions " cmd)
|
||||
(setq
|
||||
flycheck-clang-no-exceptions t
|
||||
flycheck-gcc-no-exceptions t))
|
||||
(when (string-match " -fopenmp" cmd)
|
||||
(setq flycheck-gcc-openmp t))
|
||||
(when (string-match " -fno-rtti " cmd)
|
||||
(setq
|
||||
flycheck-clang-no-rtti t
|
||||
flycheck-gcc-no-rtti t))
|
||||
(when (string-match " -fblocks " cmd)
|
||||
(setq flycheck-clang-blocks t)))))
|
||||
|
||||
|
||||
(use-package flycheck
|
||||
:commands global-flycheck-mode
|
||||
:preface
|
||||
(defvar-local flycheck-local-checkers nil)
|
||||
(defun +flycheck-checker-get(fn checker property)
|
||||
(or (alist-get property (alist-get checker flycheck-local-checkers))
|
||||
(funcall fn checker property)))
|
||||
(advice-add 'flycheck-checker-get :around '+flycheck-checker-get)
|
||||
:hook
|
||||
((flycheck-mode-hook . user--flycheck-mode-hook)
|
||||
(ede-minor-mode-hook . user/ede-flycheck-setup)
|
||||
(ede-compdb-project-rescan-hook . user/ede-flycheck-setup))
|
||||
:config
|
||||
(validate-setq
|
||||
;; Wait five seconds before starting checker
|
||||
flycheck-idle-change-delay 5.0)
|
||||
|
||||
(with-eval-after-load 'popwin
|
||||
;; Use popwin for Flycheck error list.
|
||||
(push '(flycheck-error-list-mode :stick t) popwin:special-display-config))
|
||||
|
||||
;;; (Packages) ;;;
|
||||
;; https://github.com/flycheck/flycheck-pos-tip
|
||||
;; This Flycheck extension shows errors under point in pos-tip popups.
|
||||
(use-package flycheck-pos-tip
|
||||
:if window-system
|
||||
:config
|
||||
;; Make sure flycheck-pos-tip is loaded.
|
||||
(require 'flycheck-pos-tip nil t))
|
||||
;; https://github.com/gexplorer/flycheck-indicator
|
||||
;; An Emacs minor-mode to get a fancy mode line indicator for Flycheck.
|
||||
(use-package flycheck-indicator
|
||||
:hook (flycheck-mode-hook . flycheck-indicator-mode))
|
||||
;; https://github.com/yasuyk/helm-flycheck
|
||||
;; Show flycheck errors with helm.
|
||||
(use-package helm-flycheck)
|
||||
|
||||
(global-flycheck-mode t))
|
||||
|
||||
|
||||
(provide 'utilities/flycheck)
|
||||
;;; flycheck.el ends here
|
15
lisp/utilities/google-this.el
Normal file
15
lisp/utilities/google-this.el
Normal file
@@ -0,0 +1,15 @@
|
||||
;;; google-this.el --- Google item under point -*- lexical-binding: t; -*-
|
||||
;;; Commentary: A set of emacs functions and bindings to google under point.
|
||||
;;; Code: https://github.com/Malabarba/emacs-google-this
|
||||
|
||||
(use-package google-this
|
||||
:defer
|
||||
:diminish google-this-mode
|
||||
:init
|
||||
(user/bind-key-global :util :google 'google-search)
|
||||
(user/bind-key-global :util :google-at-point 'google-this)
|
||||
(user/bind-key-global :util :google-selection 'google-region))
|
||||
|
||||
|
||||
(provide 'utilities/google-this)
|
||||
;;; google-this.el ends here
|
238
lisp/utilities/helm.el
Normal file
238
lisp/utilities/helm.el
Normal file
@@ -0,0 +1,238 @@
|
||||
;;; helm.el --- improved Emacs control -*- lexical-binding: t; -*-
|
||||
;;; Commentary: Helm is an Emacs framework for incremental completions and narrowing selections
|
||||
;;; Code: https://github.com/emacs-helm/helm
|
||||
|
||||
(defun user/helm-apropos ()
|
||||
"A context-aware helm apropos."
|
||||
(interactive)
|
||||
(let ((buffer-name "*helm-apropos*"))
|
||||
(cond
|
||||
((derived-mode-p 'emacs-lisp-mode) (helm-apropos))
|
||||
((derived-mode-p 'sh-mode) (helm-other-buffer
|
||||
'(helm-source-man-pages
|
||||
helm-source-info-pages) buffer-name))
|
||||
((derived-mode-p 'c-mode-common) (helm-other-buffer
|
||||
'(helm-source-man-pages) buffer-name))
|
||||
((derived-mode-p 'python-mode) (helm-pydoc))
|
||||
(t (message (format "Apropos is unavailable for %S" major-mode))))))
|
||||
|
||||
|
||||
(defun user/helm-navigate ()
|
||||
"A context-aware helm navigation aid."
|
||||
(interactive)
|
||||
(cond
|
||||
((derived-mode-p 'prog-mode) (user/helm-navigate-prog))
|
||||
(t (user/helm-navigate-generic))))
|
||||
|
||||
|
||||
(defun user/helm-navigate-prog ()
|
||||
"A context-aware helm for programming modes."
|
||||
(interactive)
|
||||
(let ((helm-sources '(helm-source-buffers-list))
|
||||
(current-file (or (buffer-file-name) default-directory)))
|
||||
(with-feature 'helm-misc
|
||||
;; FIXMEs.
|
||||
(add-to-list 'helm-sources 'helm-source-fixme)
|
||||
;; Emacs lisp.
|
||||
(add-to-list 'helm-sources 'helm-source-emacs-source-defun)
|
||||
(add-to-list 'helm-sources 'helm-source-emacs-lisp-expectations)
|
||||
(add-to-list 'helm-sources 'helm-source-emacs-lisp-toplevels))
|
||||
|
||||
(with-project project current-file
|
||||
;; Bookmarks.
|
||||
(add-to-list 'helm-sources 'helm-source-bookmarks)
|
||||
;; Semantic.
|
||||
(with-feature 'helm-semantic
|
||||
(when (user/proj-from-path user/ede-proj current-file)
|
||||
(add-to-list 'helm-sources 'helm-source-semantic))))
|
||||
|
||||
(helm-other-buffer helm-sources "*helm-navigate-prog*")))
|
||||
|
||||
|
||||
(defun user/helm-navigate-generic ()
|
||||
"A somewhat context-aware generic helm."
|
||||
(interactive)
|
||||
(condition-case nil
|
||||
(let ((helm-sources '(helm-source-buffers-list
|
||||
helm-source-recentf
|
||||
helm-source-file-name-history
|
||||
helm-source-file-cache
|
||||
helm-source-buffer-not-found
|
||||
helm-source-man-pages
|
||||
helm-source-info-pages)))
|
||||
(cond
|
||||
((eq system-type 'darwin)
|
||||
(progn
|
||||
(add-to-list 'helm-sources 'helm-source-mac-spotlight)))
|
||||
((eq system-type 'gnu/linux)
|
||||
(progn
|
||||
(add-to-list 'helm-sources 'helm-source-tracker-search))))
|
||||
(helm-other-buffer helm-sources "*helm-navigate-generic*"))
|
||||
;; Fall back to helm-mini if an error occurs in one of the sources.
|
||||
(error (helm-mini))))
|
||||
|
||||
|
||||
(defun user/helm-mode ()
|
||||
"Start helm-mode."
|
||||
(helm-mode t)
|
||||
|
||||
(with-feature 'helm-descbinds
|
||||
(helm-descbinds-mode t))
|
||||
|
||||
;; Filter out boring buffers.
|
||||
(dolist (pattern
|
||||
(list "\\*clang-complete" "\\*CEDET global" "\\*tramp/scpc"
|
||||
"\\*epc con" "\\*Pymacs" "\\*Completions\\*"))
|
||||
(add-to-list 'helm-boring-buffer-regexp-list pattern))
|
||||
|
||||
;; Filter out boring files.
|
||||
(dolist (pattern
|
||||
(list "\\.elc$" "\\.pyc$" "^#.+#$" "^G[R]TAGS$" "^GPATH$" "^ID$"))
|
||||
(add-to-list 'helm-boring-file-regexp-list pattern)))
|
||||
|
||||
(use-package helm
|
||||
:diminish helm-mode
|
||||
;; :ensure
|
||||
;; Since Helm depends on `eieio', enable it after package initialization.
|
||||
:hook (after-init-hook . user/helm-mode)
|
||||
:init
|
||||
(user/bind-key-global :nav :context 'user/helm-navigate)
|
||||
(user/bind-key-global :doc :apropos 'user/helm-apropos)
|
||||
(user/bind-key-global :emacs :elisp-search 'helm-info-elisp)
|
||||
:config
|
||||
(validate-setq
|
||||
;; Idle delays.
|
||||
helm-input-idle-delay 0.0
|
||||
;; Limit the number of candidates per source to a reasonable amount.
|
||||
helm-candidate-number-limit 75)
|
||||
|
||||
(with-eval-after-load 'popwin
|
||||
(add-to-list
|
||||
'popwin:special-display-config
|
||||
'("helm" :regexp t :height 0.4 :position bottom)))
|
||||
|
||||
;;; (Packages) ;;;
|
||||
;; https://github.com/emacs-helm/helm-descbinds
|
||||
;; Helm Descbinds provides an interface to emacs’ describe-bindings making the currently active key bindings interactively searchable with helm.
|
||||
(use-package helm-descbinds
|
||||
:defer)
|
||||
;; https://github.com/emacsorphanage/helm-swoop
|
||||
;; List match lines to another buffer, which is able to squeeze by any words you input
|
||||
(use-package helm-swoop
|
||||
:defer
|
||||
:init
|
||||
(user/bind-key-global :basic :swoop 'helm-swoop)
|
||||
(user/bind-key-global :basic :swoop-multi 'helm-multi-swoop)
|
||||
:config
|
||||
(validate-setq
|
||||
;; Split window vertically when swooping.
|
||||
helm-swoop-split-direction 'split-window-horizontally)
|
||||
|
||||
;;; (Bindings) ;;;
|
||||
(define-key isearch-mode-map
|
||||
(user/get-key :basic :swoop) 'helm-swoop-from-isearch)
|
||||
(with-eval-after-load 'helm-swoop
|
||||
;; From helm-swoop to helm-multi-swoop-all.
|
||||
(define-key helm-swoop-map
|
||||
(user/get-key :basic :swoop)
|
||||
'helm-multi-swoop-all-from-helm-swoop)))
|
||||
;; https://github.com/emacs-helm/helm/blob/master/helm-adaptive.el
|
||||
;; Adaptive Sorting of Candidates
|
||||
(use-package helm-adaptive
|
||||
:ensure helm
|
||||
:config
|
||||
(validate-setq
|
||||
;; Put adaptive history in cache directory.
|
||||
helm-adaptive-history-file (path-join *user-cache-directory* "helm-adaptive-history")))
|
||||
|
||||
(use-package helm-command
|
||||
:ensure helm
|
||||
:bind* ([remap execute-extended-command] . helm-M-x))
|
||||
|
||||
(use-package helm-files
|
||||
:ensure helm
|
||||
:bind* (([remap find-file] . helm-find-files)
|
||||
:map helm-find-files-map
|
||||
("C-k" . helm-ff-persistent-delete))
|
||||
:config
|
||||
;; `helm-recentf-fuzzy-match' is set via Customize
|
||||
;; Reason: https://emacs.stackexchange.com/a/106/5514
|
||||
(validate-setq
|
||||
helm-ff-file-name-history-use-recentf t
|
||||
;; Don't prompt for new buffer.
|
||||
helm-ff-newfile-prompt-p nil
|
||||
helm-input-idle-delay 0.1
|
||||
;; Don't show boring files.
|
||||
helm-ff-skip-boring-files t
|
||||
;; Search for library in `require' and `declare-function' sexp.
|
||||
helm-ff-search-library-in-sexp t
|
||||
;; Auto-complete in find-files.
|
||||
helm-ff-auto-update-initial-value t))
|
||||
|
||||
(use-package helm-misc
|
||||
:ensure helm
|
||||
:bind* ([remap switch-to-buffer] . helm-mini))
|
||||
|
||||
(use-package helm-buffers
|
||||
:ensure helm
|
||||
:bind (:map helm-buffer-map
|
||||
("C-k" . helm-buffer-run-kill-persistent))
|
||||
:config
|
||||
(validate-setq
|
||||
;; Use fuzzy matching for buffer names.
|
||||
helm-buffers-fuzzy-matching t
|
||||
;; Don't check if remote files exist.
|
||||
helm-buffer-skip-remote-checking t))
|
||||
|
||||
(use-package helm-ring
|
||||
:ensure helm
|
||||
:bind* (([remap yank-pop] . helm-show-kill-ring)
|
||||
("C-c SPC" . helm-all-mark-rings)))
|
||||
|
||||
(use-package helm-imenu
|
||||
:ensure helm
|
||||
:bind (("C-c n i" . helm-imenu-in-all-buffers)
|
||||
("C-c n t" . helm-imenu))
|
||||
:config
|
||||
(validate-setq
|
||||
helm-imenu-fuzzy-match t)
|
||||
;; Incompatible with validate-setq.
|
||||
(setq
|
||||
helm-imenu-execute-action-at-once-if-one nil))
|
||||
|
||||
(use-package helm-bookmark
|
||||
:ensure helm
|
||||
:defer
|
||||
:bind ("C-x r l" . helm-filtered-bookmarks))
|
||||
|
||||
(use-package helm-pages
|
||||
:ensure helm
|
||||
:defer
|
||||
:bind ("C-c n P" . helm-pages))
|
||||
|
||||
(use-package helm-eval
|
||||
:ensure helm
|
||||
:defer
|
||||
:bind (("C-c h M-:" . helm-eval-expression-with-eldoc)
|
||||
("C-c h *" . helm-calcul-expression)))
|
||||
|
||||
(use-package helm-external
|
||||
:ensure helm
|
||||
:defer
|
||||
:bind ("C-c h x" . helm-run-external-command))
|
||||
|
||||
(use-package helm-build-command
|
||||
:defer
|
||||
:quelpa (helm-build-command
|
||||
:fetcher github
|
||||
:repo "tkf/helm-build-command"))
|
||||
|
||||
(use-package helm-icons
|
||||
:if (display-graphic-p)
|
||||
:disabled
|
||||
:config
|
||||
(helm-icons-enable)))
|
||||
|
||||
|
||||
(provide 'utilities/helm)
|
||||
;;; helm.el ends here
|
28
lisp/utilities/hideshow.el
Normal file
28
lisp/utilities/hideshow.el
Normal file
@@ -0,0 +1,28 @@
|
||||
;;; hideshow.el --- Configure hide show -*- lexical-binding: t; -*-
|
||||
;;; Commentary: Hideshow mode is a buffer-local minor mode that allows you to selectively display portions of a program
|
||||
;;; Code: https://github.com/emacs-mirror/emacs/blob/master/lisp/progmodes/hideshow.el
|
||||
|
||||
(defun user--hs-minor-mode-hook ()
|
||||
"Minor mode hook for Hide Show."
|
||||
;;; (Bindings) ;;;
|
||||
(local-set-key (kbd "C-c SPC") 'user/hs-toggle-level)
|
||||
(local-set-key (kbd "C-c <right>") 'hs-show-block)
|
||||
(local-set-key (kbd "C-c <left>") 'hs-hide-block)
|
||||
(local-set-key (kbd "C-c <up>") 'hs-hide-all)
|
||||
(local-set-key (kbd "C-c <down>") 'hs-show-all))
|
||||
|
||||
|
||||
(defun user/hs-toggle-level ()
|
||||
"Toggle hide/show for level at point."
|
||||
(interactive)
|
||||
(hs-show-block)
|
||||
(hs-hide-level 1))
|
||||
|
||||
|
||||
(use-package hideshow
|
||||
:init
|
||||
(add-hook 'hs-minor-mode-hook 'user--hs-minor-mode-hook))
|
||||
|
||||
|
||||
(provide 'utilities/hideshow)
|
||||
;;; hideshow.el ends here
|
25
lisp/utilities/ibuffer.el
Normal file
25
lisp/utilities/ibuffer.el
Normal file
@@ -0,0 +1,25 @@
|
||||
;;; ibuffer --- improved buffer management -*- lexical-binding: t; -*-
|
||||
;;; Commentary: buffer is an advanced replacement for BufferMenu, which lets you operate on buffers much in the same manner as Dired.
|
||||
;;; Code:
|
||||
|
||||
(defun user--ibuffer-hook ()
|
||||
"Hook for improved buffer."
|
||||
(ibuffer-vc-set-filter-groups-by-vc-root)
|
||||
(unless (eq ibuffer-sorting-mode 'filename/process)
|
||||
(ibuffer-do-sort-by-filename/process)))
|
||||
|
||||
(use-package ibuffer
|
||||
:bind* (([remap list-buffers] . ibuffer))
|
||||
:init
|
||||
(add-hook 'ibuffer-hook 'user--ibuffer-hook)
|
||||
:config
|
||||
(validate-setq
|
||||
ibuffer-filter-group-name-face 'font-lock-doc-face)
|
||||
;; https://github.com/purcell/ibuffer-vc
|
||||
;; Group buffers in ibuffer list by VC project
|
||||
(use-package ibuffer-vc
|
||||
:defer))
|
||||
|
||||
|
||||
(provide 'utilities/ibuffer)
|
||||
;;; ibuffer.el ends here
|
33
lisp/utilities/ido.el
Normal file
33
lisp/utilities/ido.el
Normal file
@@ -0,0 +1,33 @@
|
||||
;;; ido.el --- interactively do things -*- lexical-binding: t; -*-
|
||||
;;; Commentary:
|
||||
;;; Code: https://github.com/emacs-mirror/emacs/blob/master/lisp/ido.el
|
||||
|
||||
(defun user--ido-mode-hook ()
|
||||
"Mode hook for ido."
|
||||
(when (feature-p 'flx)
|
||||
(flx-ido-mode t))
|
||||
(when (feature-p 'ido-vertical-mode)
|
||||
(ido-vertical-mode t)))
|
||||
|
||||
(use-package ido
|
||||
:defer
|
||||
:config
|
||||
(validate-setq
|
||||
;; Enable fuzzy matching
|
||||
ido-enable-flex-matching t
|
||||
;; Remember buffers that have been open
|
||||
ido-use-virtual-buffers t
|
||||
;; Allow the same buffer to be opened in different windows
|
||||
ido-default-buffer-method 'selected-window)
|
||||
;; https://github.com/lewang/flx
|
||||
;; Matching engine
|
||||
(use-package flx
|
||||
:config
|
||||
(validate-setq
|
||||
;; Flex has its own highlights.
|
||||
ido-use-faces nil))
|
||||
(use-package ido-vertical-mode))
|
||||
|
||||
|
||||
(provide 'utilities/ido)
|
||||
;;; ido.el ends here
|
51
lisp/utilities/lsp.el
Normal file
51
lisp/utilities/lsp.el
Normal file
@@ -0,0 +1,51 @@
|
||||
;;; lsp.el --- Language server protocol. -*- lexical-binding: t; -*-
|
||||
;;; Commentary:
|
||||
;;; Code: https://github.com/emacs-lsp/lsp-mode
|
||||
|
||||
(defun user--lsp-mode-hook ()
|
||||
"Mode hook for LSP minor modes."
|
||||
(message "user--lsp-mode-hook"))
|
||||
|
||||
(use-package lsp-mode
|
||||
:pin "MELPA"
|
||||
:commands lsp
|
||||
:hook ((lsp-after-open-hook . lsp-enable-imenu)
|
||||
(lsp-mode-hook . user--lsp-mode-hook))
|
||||
:config
|
||||
(validate-setq
|
||||
;; Automatically try to figure out project root.
|
||||
lsp-auto-guess-root t
|
||||
;; Location of persistent LSP session.
|
||||
lsp-session-file (path-join *user-cache-directory* "lsp-session")
|
||||
;; Disable yasnippet integration.
|
||||
lsp-enable-snippet nil
|
||||
;; Don't watch files for changes, prevents freeze during compilation.
|
||||
lsp-enable-file-watchers nil
|
||||
;; Disable headerline
|
||||
lsp-headerline-breadcrumb-enable nil
|
||||
;; Increase the amount of data that can be read from a language server.
|
||||
read-process-output-max (* 3 1024 1024))
|
||||
|
||||
;; https://github.com/emacs-lsp/lsp-ui/
|
||||
;; This package contains all the higher level UI modules of lsp-mode, like flycheck support and code lenses.
|
||||
(use-package lsp-ui
|
||||
:hook (lsp-mode-hook . lsp-ui-mode)
|
||||
:config
|
||||
;; https://emacs-lsp.github.io/lsp-mode/tutorials/how-to-turn-off/
|
||||
(validate-setq
|
||||
lsp-modeline-code-actions-enable nil
|
||||
lsp-ui-sideline-enable nil
|
||||
lsp-ui-doc-delay 3
|
||||
lsp-ui-doc-position 'bottom))
|
||||
|
||||
(use-package lsp-treemacs
|
||||
:ensure t
|
||||
:defer t
|
||||
;; :after (lsp treemacs)
|
||||
:custom
|
||||
(lsp-treemacs-sync-mode 1)
|
||||
)
|
||||
)
|
||||
|
||||
(provide 'utilities/lsp)
|
||||
;;; lsp.el ends here
|
19
lisp/utilities/pandoc.el
Normal file
19
lisp/utilities/pandoc.el
Normal file
@@ -0,0 +1,19 @@
|
||||
;;; pandoc.el --- Interface to Pandoc -*- lexical-binding: t; -*-
|
||||
;;; Commentary: An Emacs mode for interacting with Pandoc
|
||||
;;; Code: https://github.com/joostkremers/pandoc-mode
|
||||
|
||||
(defun user--pandoc-mode-hook ()
|
||||
"Pandoc mode hook."
|
||||
(pandoc-load-default-settings))
|
||||
|
||||
|
||||
(use-package pandoc-mode
|
||||
:if (executable-find "pandoc")
|
||||
:defer
|
||||
:diminish pandoc-mode
|
||||
:init
|
||||
(add-hook 'pandoc-mode 'user--pandoc-mode-hook))
|
||||
|
||||
|
||||
(provide 'utilities/pandoc)
|
||||
;;; pandoc.el ends here
|
10
lisp/utilities/polymode.el
Normal file
10
lisp/utilities/polymode.el
Normal file
@@ -0,0 +1,10 @@
|
||||
;;; polymode.el --- Multiple major modes in a single buffer. -*- lexical-binding: t; -*-
|
||||
;;; Commentary:
|
||||
;;; Code: https://github.com/polymode/polymode
|
||||
|
||||
(use-package polymode
|
||||
:defer)
|
||||
|
||||
|
||||
(provide 'utilities/polymode)
|
||||
;;; polymode.el ends here
|
22
lisp/utilities/presentation.el
Normal file
22
lisp/utilities/presentation.el
Normal file
@@ -0,0 +1,22 @@
|
||||
;;; presentation.el --- Emacs presentation mode -*- lexical-binding: t; -*-
|
||||
;;; Commentary: Presentation mode is a global minor mode to zoom characters
|
||||
;;; Code: https://github.com/zonuexe/emacs-presentation-mode
|
||||
|
||||
(defun user--presentation-on-hook ()
|
||||
"Hook executed when enabling presentation mode."
|
||||
;; Disable Helm.
|
||||
(helm-mode -1))
|
||||
|
||||
(defun user--presentation-off-hook ()
|
||||
"Hook executed when disabling presentation mode."
|
||||
;; Enable Helm.
|
||||
(helm-mode 1))
|
||||
|
||||
(use-package presentation
|
||||
:hook ((presentation-on-hook . user--presentation-on-hook)
|
||||
(presentation-off-hook . user--presentation-off-hook))
|
||||
:bind-wrap ((:key :util :presentation) . presentation-mode))
|
||||
|
||||
|
||||
(provide 'utilities/presentation)
|
||||
;;; presentation.el ends here
|
30
lisp/utilities/profiler.el
Normal file
30
lisp/utilities/profiler.el
Normal file
@@ -0,0 +1,30 @@
|
||||
;;; profiler.el --- Configure Emacs profiler -*- lexical-binding: t; -*-
|
||||
;;; Commentary:
|
||||
;;; Code:
|
||||
;;; Doc: https://www.gnu.org/software/emacs/manual/html_node/elisp/Profiling.html
|
||||
|
||||
(defun user--profiler-report-mode-hook ()
|
||||
"Profiler report mode hook."
|
||||
;;; (Bindings) ;;;
|
||||
(user/bind-key-local :basic :save 'profiler-report-write-profile)
|
||||
(user/bind-key-local :basic :save-as 'profiler-report-write-profile))
|
||||
|
||||
(use-package profiler
|
||||
:defer
|
||||
:init
|
||||
(add-hook 'profiler-report-mode-hook 'user--profiler-report-mode-hook)
|
||||
|
||||
;;; (Bindings) ;;;
|
||||
(user/bind-key-global :emacs :profiler-start 'profiler-start)
|
||||
(user/bind-key-global :emacs :profiler-stop 'profiler-stop)
|
||||
(user/bind-key-global :emacs :profiler-report 'profiler-report)
|
||||
:config
|
||||
(validate-setq
|
||||
;; The maximum number distinct of call-stacks to save.
|
||||
profiler-log-size 100000
|
||||
;; Maximum call-stack depth to record.
|
||||
profiler-max-stack-depth 32))
|
||||
|
||||
|
||||
(provide 'utilities/profiler)
|
||||
;;; profiler.el ends here
|
133
lisp/utilities/project.el
Normal file
133
lisp/utilities/project.el
Normal file
@@ -0,0 +1,133 @@
|
||||
;;; project.el --- helpers for working with projects -*- lexical-binding: t; -*-
|
||||
;;; Commentary:
|
||||
;;; Code:
|
||||
|
||||
(with-eval-after-load 'eieio
|
||||
(defclass user/proj ()
|
||||
()
|
||||
"Project class.")
|
||||
|
||||
(cl-defgeneric user/proj-name ((project user/proj))
|
||||
"Get the PROJECT name.")
|
||||
|
||||
(cl-defgeneric user/proj-root ((project user/proj))
|
||||
"Get the PROJECT root path.")
|
||||
|
||||
(cl-defgeneric user/proj-include-paths ((project user/proj))
|
||||
"Get the include paths for PROJECT.")
|
||||
|
||||
(cl-defgeneric user/proj-build ((project user/proj))
|
||||
"Build PROJECT.")
|
||||
|
||||
(cl-defmethod user/proj-name ((project user/proj))
|
||||
(file-name-nondirectory
|
||||
(directory-file-name (user/proj-root project))))
|
||||
|
||||
(cl-defmethod user/proj-include-paths ((project user/proj)))
|
||||
|
||||
(with-eval-after-load 'ede
|
||||
(defclass user/ede-proj (user/proj)
|
||||
((ede :initarg :ede :initform nil
|
||||
:documentation "EDE project instance."))
|
||||
"EDE project class.")
|
||||
|
||||
(cl-defmethod user/proj-from-path :static ((project user/ede-proj) &rest args)
|
||||
"Constructor for EDE project at path in ARGS."
|
||||
(when (featurep 'ede)
|
||||
(let ((ede-proj (ede-current-project (expand-file-name (first args)))))
|
||||
(when (cl-some (lambda (args)
|
||||
(and (featurep (first args))
|
||||
(funcall (second args) ede-proj)))
|
||||
'((ede/cpp-root ede-cpp-root-project-p)
|
||||
(ede/generic ede-generic-makefile-project-p)
|
||||
(ede/generic ede-generic-cmake-project-p)
|
||||
(ede/linux ede-linux-project-p)
|
||||
(ede/compdb ede-compdb-project-p)))
|
||||
(make-instance 'user/ede-proj :ede ede-proj)))))
|
||||
|
||||
(cl-defmethod user/proj-name ((project user/ede-proj))
|
||||
(ede-name (oref project :ede)))
|
||||
|
||||
(cl-defmethod user/proj-root ((project user/ede-proj))
|
||||
(ede-project-root-directory (oref project :ede)))
|
||||
|
||||
(cl-defmethod user/proj-include-paths ((project user/ede-proj))
|
||||
(let ((root-path (user/proj-root project))
|
||||
(include-paths (oref (oref project :ede) include-path)))
|
||||
(mapcar #'(lambda (path) (expand-file-name path root-path))
|
||||
include-paths)))
|
||||
|
||||
(cl-defmethod user/proj-build ((project user/ede-proj))
|
||||
(let ((ede-proj (oref project :ede)))
|
||||
(project-compile-project
|
||||
ede-proj
|
||||
(read-string "Build command: " (oref ede-proj compile-command))))))
|
||||
|
||||
(with-eval-after-load 'projectile
|
||||
(defclass user/projectile-proj (user/proj)
|
||||
((root-path :initarg :root-path
|
||||
:type string
|
||||
:documentation "Project root path."))
|
||||
"Projectile project class.")
|
||||
|
||||
(cl-defmethod user/proj-from-path :static ((project user/projectile-proj) &rest args)
|
||||
"Constructor for projectile project at path in ARGS."
|
||||
(let ((default-directory (file-name-as-directory (first args)))
|
||||
(projectile-require-project-root nil))
|
||||
(when (and (feature-p 'projectile) (projectile-project-p))
|
||||
(make-instance 'user/projectile-proj :root-path (projectile-project-root)))))
|
||||
|
||||
(cl-defmethod user/proj-root ((project user/projectile-proj))
|
||||
(oref project :root-path)))
|
||||
|
||||
(with-eval-after-load 'vc
|
||||
(defclass user/vc-proj (user/proj)
|
||||
((root-path :initarg :root-path
|
||||
:type string
|
||||
:documentation "Project root path."))
|
||||
"VC project class.")
|
||||
|
||||
(cl-defmethod user/proj-from-path :static ((project user/vc-proj) &rest args)
|
||||
"Constructor for VC project at path in ARGS."
|
||||
(let* ((vc-backend (and (fboundp 'vc-responsible-backend)
|
||||
(ignore-errors
|
||||
(vc-responsible-backend
|
||||
(file-truename (first args))))))
|
||||
(root-path (and vc-backend
|
||||
(vc-call-backend
|
||||
vc-backend 'root (file-truename (first args))))))
|
||||
(when root-path
|
||||
(make-instance 'user/vc-proj :root-path root-path))))
|
||||
|
||||
(cl-defmethod user/proj-root ((project user/vc-proj))
|
||||
(oref project :root-path)))
|
||||
|
||||
(cl-defmethod user/proj-from-path :static ((project user/proj) &rest args)
|
||||
"Constructor for project at path in ARGS."
|
||||
(let ((f (lambda (proj-type)
|
||||
(when (fboundp proj-type)
|
||||
(funcall #'user/proj-from-path proj-type (first args)))))
|
||||
(proj-types '(user/ede-proj user/projectile-proj user/vc-proj)))
|
||||
(cl-some f proj-types))))
|
||||
|
||||
|
||||
(defmacro with-project (project &optional path &rest body)
|
||||
"Bind PROJECT for PATH and evaluate BODY if project exists."
|
||||
(declare (indent defun)
|
||||
(debug let))
|
||||
`(let ((,project (user/proj-from-path user/proj (or ,path (path-abs-buffer)))))
|
||||
(when ,project
|
||||
,@body)))
|
||||
|
||||
|
||||
(defmacro with-project-root (project-root &optional path &rest body)
|
||||
"Bind PROJECT-ROOT for PATH and evaluate BODY if project exists."
|
||||
(declare (indent defun)
|
||||
(debug let))
|
||||
`(with-project project (or ,path (path-abs-buffer))
|
||||
(let ((,project-root (user/proj-root project)))
|
||||
,@body)))
|
||||
|
||||
|
||||
(provide 'utilities/project)
|
||||
;;; project.el ends here
|
33
lisp/utilities/projectile.el
Normal file
33
lisp/utilities/projectile.el
Normal file
@@ -0,0 +1,33 @@
|
||||
;;; projectile.el --- Projectile project management -*- lexical-binding: t; -*-
|
||||
;;; Commentary: Projectile is a project interaction library for Emacs
|
||||
;;; Code: https://github.com/bbatsov/projectile
|
||||
|
||||
(use-package projectile
|
||||
:diminish projectile-mode
|
||||
:defer
|
||||
:init
|
||||
;;; (Bindings) ;;;
|
||||
(user/bind-key-global :basic :open-file-context 'projectile-find-file)
|
||||
:config
|
||||
(validate-setq
|
||||
;; Projectile bookmarks.
|
||||
projectile-known-projects-file (path-join *user-data-directory*
|
||||
"projectile-bookmarks.eld")
|
||||
;; Projectile cache store.
|
||||
projectile-cache-file (path-join *user-cache-directory* "projectile")
|
||||
;; Use default completion that will usually be provided by Helm.
|
||||
projectile-completion-system 'default)
|
||||
|
||||
(with-eval-after-load 'smart-mode-line
|
||||
(validate-setq
|
||||
;; Enable in smart mode line.
|
||||
sml/use-projectile-p 'after-prefixes))
|
||||
|
||||
(with-executable 'ctags-exuberant
|
||||
(validate-setq
|
||||
;; Default to exuberant ctags.
|
||||
projectile-tags-command "ctags-exuberant -Re %s")))
|
||||
|
||||
|
||||
(provide 'utilities/projectile)
|
||||
;;; projectile.el ends here
|
21
lisp/utilities/sauron.el
Normal file
21
lisp/utilities/sauron.el
Normal file
@@ -0,0 +1,21 @@
|
||||
;;; sauron.el --- Emacs event tracker -*- lexical-binding: t; -*-
|
||||
;;; Commentary: sauron is an emacs mode for keeping track of events happening in the (emacs) world around you.
|
||||
;;; Code: https://github.com/djcb/sauron
|
||||
|
||||
(use-package sauron
|
||||
:defer
|
||||
:bind-wrap
|
||||
((:key :util :notifications) . sauron-toggle-hide-show)
|
||||
:config
|
||||
(validate-setq
|
||||
;; Display sauron in current frame.
|
||||
sauron-separate-frame nil)
|
||||
|
||||
(with-eval-after-load 'alert
|
||||
(add-hook 'sauron-event-added-functions 'sauron-alert-el-adapter))
|
||||
|
||||
(sauron-start-hidden))
|
||||
|
||||
|
||||
(provide 'utilities/sauron)
|
||||
;;; sauron.el ends here
|
165
lisp/utilities/smartparens.el
Normal file
165
lisp/utilities/smartparens.el
Normal file
@@ -0,0 +1,165 @@
|
||||
;;; smartparens.el --- Set up smartparens. -*- lexical-binding: t; -*-
|
||||
;;; Commentary: Smartparens is a minor mode for dealing with pairs in Emacs.
|
||||
;;; Code: https://github.com/Fuco1/smartparens
|
||||
|
||||
(defun user/smartparens-enable ()
|
||||
"Enable smartparens in current mode."
|
||||
(when (feature-p 'smartparens)
|
||||
(show-smartparens-mode t)
|
||||
(smartparens-mode t)))
|
||||
|
||||
(defun user--sp-org-point-in-checkbox-p (_id action _context)
|
||||
"Check if smartparens ACTION is inside checkbox."
|
||||
(when (eq action 'insert)
|
||||
(sp--looking-at-p "\\s-*]")))
|
||||
|
||||
(defun user--sp-cxx-point-is-template-p (id action context)
|
||||
"Return t if point with ID using ACTION in CONTEXT is in the right place for C++ angle-brackets."
|
||||
(and (sp-in-code-p id action context)
|
||||
(sp-point-after-word-p id action context)))
|
||||
|
||||
(defun user--sp-cc-point-after-include-p (id action context)
|
||||
"Return t if point with ID using ACTION in CONTEXT is in an #include."
|
||||
(and (sp-in-code-p id action context)
|
||||
(save-excursion
|
||||
(goto-char (line-beginning-position))
|
||||
(looking-at-p "[ ]*#include[^<]+"))))
|
||||
|
||||
(defun user--sp-haskell-after-symbol-p (_id action _context)
|
||||
"Return t if point using ACTION is after a symbol."
|
||||
(when (eq action 'insert)
|
||||
(save-excursion
|
||||
(backward-char 1)
|
||||
(looking-back "\\sw\\|\\s_\\|\\s'"))))
|
||||
|
||||
(defun user--sp-gfm-skip-asterisk (_ms position _me)
|
||||
"Return t if asterisk should be skipped at point with POSITION."
|
||||
(save-excursion
|
||||
(goto-char position)
|
||||
(save-match-data (looking-at "^\\* "))))
|
||||
|
||||
(defun user--sp-php-handle-docstring (&rest _ignored)
|
||||
"Handle PHP docstrings with smartparens."
|
||||
(-when-let (line (save-excursion
|
||||
(forward-line)
|
||||
(thing-at-point 'line)))
|
||||
(cond
|
||||
((string-match-p "function" line)
|
||||
(save-excursion
|
||||
(insert "\n")
|
||||
(let ((args (save-excursion
|
||||
(forward-line)
|
||||
(my-php-get-function-args))))
|
||||
(--each args
|
||||
(insert (format "* @param %s\n" it)))))
|
||||
(insert "* "))
|
||||
((string-match-p ".*class\\|interface" line)
|
||||
(save-excursion (insert "\n*\n* @author\n"))
|
||||
(insert "* ")))
|
||||
(let ((o (sp--get-active-overlay)))
|
||||
(indent-region (overlay-start o) (overlay-end o)))))
|
||||
|
||||
(use-package smartparens
|
||||
:diminish smartparens-mode
|
||||
:bind-wrap
|
||||
(:map smartparens-mode-map
|
||||
([remap kill-line] . sp-kill-hybrid-sexp)
|
||||
((:key :basic :selection-next) . sp-select-next-thing-exchange)
|
||||
((:key :basic :selection-prev) . sp-select-previous-thing)
|
||||
((:key :basic :forward-word) . sp-forward-symbol)
|
||||
((:key :basic :backward-word) . sp-backward-symbol)
|
||||
((:key :basic :forward-expr) . sp-forward-sexp)
|
||||
((:key :basic :backward-expr) . sp-backward-sexp)
|
||||
((:key :code :unwrap-expr) . sp-unwrap-sexp)
|
||||
((:key :code :comment) . sp-comment)
|
||||
((:key :basic :cut-expr) . sp-kill-sexp)
|
||||
((:key :basic :copy-expr) . sp-copy-sexp))
|
||||
:config
|
||||
(validate-setq
|
||||
;; Don't kill trailing whitespace with `sp-hybrid-kill'.
|
||||
sp-hybrid-kill-excessive-whitespace nil)
|
||||
|
||||
;; Don't insert pairs automatically if point is at a word.
|
||||
(sp-pair "{" nil
|
||||
:post-handlers '(("||\n[i]" "RET") ("| " " "))
|
||||
:unless '(sp-point-before-word-p sp-point-before-same-p)
|
||||
:wrap "C-{")
|
||||
(sp-pair "(" nil
|
||||
:post-handlers '(("||\n[i]" "RET") ("| " " "))
|
||||
:unless '(sp-point-before-word-p sp-point-before-same-p)
|
||||
:wrap "C-(")
|
||||
(sp-pair "[" nil
|
||||
:post-handlers '(("| " " "))
|
||||
:unless '(sp-point-before-word-p sp-point-before-same-p))
|
||||
(sp-pair "\"" nil :unless '(sp-point-before-word-p sp-point-after-word-p sp-point-before-same-p))
|
||||
(sp-pair "'" nil :unless '(sp-point-before-word-p sp-point-after-word-p sp-point-before-same-p))
|
||||
|
||||
(sp-with-modes '(c-mode c++-mode objc-mode)
|
||||
;; Automatically add another newline before closing curly brace on enter.
|
||||
(sp-local-pair "{" nil :post-handlers '(("||\n[i]" "RET")))
|
||||
(sp-local-pair "/*" "*/" :post-handlers '((" | " "SPC") ("* ||\n[i]" "RET")))
|
||||
|
||||
(sp-local-pair "<" ">" :when '(user--sp-cxx-point-is-template-p user--sp-cc-point-after-include-p))
|
||||
(sp-local-pair "/*" "*/" :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))
|
||||
;; Doxygen blocks.
|
||||
(sp-local-pair "/**" "*/" :post-handlers '(("||\n[i]" "RET") ("||\n[i]" "SPC")))
|
||||
(sp-local-pair "/*!" "*/" :post-handlers '(("||\n[i]" "RET") ("[d-1]< | " "SPC"))))
|
||||
|
||||
(sp-with-modes '(css-mode scss-mode less-css-mode stylus-mode)
|
||||
(sp-local-pair "/*" "*/" :post-handlers '(("[d-3]||\n[i]" "RET") ("| " "SPC"))))
|
||||
|
||||
(sp-with-modes '(haskell-mode)
|
||||
(sp-local-pair "'" nil :unless '(user--sp-haskell-after-symbol-p))
|
||||
(sp-local-pair "\\(" nil :actions nil))
|
||||
|
||||
(sp-with-modes '(javascript-mode js2-mode js3-mode rjsx-mode)
|
||||
(sp-local-pair "/* " " */" :post-handlers '(("| " "SPC"))))
|
||||
|
||||
(sp-with-modes '(sh-mode markdown-mode gfm-mode rts-mode python-mode cython-mode)
|
||||
(sp-local-pair "`" nil :unless '(sp-point-before-word-p sp-point-after-word-p sp-point-before-same-p)))
|
||||
|
||||
(sp-with-modes '(markdown-mode gfm-mode rst-mode)
|
||||
(sp-local-pair "*" "*" :wrap "C-*" :skip-match 'user--sp-gfm-skip-asterisk)
|
||||
(sp-local-tag "2" "**" "**")
|
||||
(sp-local-tag "<" "<_>" "</_>" :transform 'sp-match-sgml-tags))
|
||||
|
||||
(sp-with-modes '(tex-mode plain-tex-mode latex-mode)
|
||||
(sp-local-tag "i" "\"<" "\">")
|
||||
(sp-local-pair "$" nil :unless '(sp-point-before-word-p))
|
||||
(sp-local-pair "\\[" " \\]")
|
||||
(sp-local-pair "\\(" " \\)")
|
||||
(sp-local-pair "\\{" " \\}")
|
||||
(sp-local-pair "\\left(" " \\right)")
|
||||
(sp-local-pair "\\left\\{" " \\right\\}"))
|
||||
|
||||
(sp-with-modes '(org-mode)
|
||||
(sp-local-pair "*" "*"
|
||||
:post-handlers '(("[d1]" "SPC"))
|
||||
:unless '(sp-point-after-word-p sp-point-before-word-p sp-point-at-bol-p))
|
||||
(sp-local-pair "_" "_"
|
||||
:post-handlers '(("[d1]" "SPC"))
|
||||
:unless '(sp-point-after-word-p sp-point-before-word-p))
|
||||
(sp-local-pair "/" "/"
|
||||
:post-handlers '(("[d1]" "SPC"))
|
||||
:unless '(sp-point-after-word-p sp-point-before-word-p user--sp-org-point-in-checkbox-p))
|
||||
(sp-local-pair "~" "~"
|
||||
:post-handlers '(("[d1]" "SPC"))
|
||||
:unless '(sp-point-after-word-p sp-point-before-word-p))
|
||||
(sp-local-pair "=" "="
|
||||
:post-handlers '(("[d1]" "SPC"))
|
||||
:unless '(sp-point-after-word-p sp-point-before-word-p))
|
||||
(sp-local-pair "«" "»"))
|
||||
|
||||
(sp-with-modes '(php-mode)
|
||||
(sp-local-pair "/**" "*/"
|
||||
:post-handlers '(("| " "SPC") (user--sp-php-handle-docstring "RET")))
|
||||
(sp-local-pair "/*." ".*/" :post-handlers '(("| " "SPC")))
|
||||
(sp-local-pair "{" nil :post-handlers '(("||\n[i]" "RET")))
|
||||
(sp-local-pair "(" nil :prefix "\\(\\sw\\|\\s_\\)*"))
|
||||
|
||||
(sp-with-modes '(scala-mode)
|
||||
(sp-local-pair "'" nil :actions nil)))
|
||||
|
||||
|
||||
(provide 'utilities/smartparens)
|
||||
;;; smartparens.el ends here
|
127
lisp/utilities/spelling.el
Normal file
127
lisp/utilities/spelling.el
Normal file
@@ -0,0 +1,127 @@
|
||||
;;; flyspell.el --- spell checking on the fly -*- lexical-binding: t; -*-
|
||||
;;; Commentary:
|
||||
;;; Code:
|
||||
|
||||
(defconst *user-auto-dictionary-buffer-limit* (* 128 1024)
|
||||
"Maximum buffer size for automatic dictionary detection.")
|
||||
|
||||
|
||||
(defun user--flyspell-mode-common-hook ()
|
||||
"Hook for fly spell common mode."
|
||||
(if (> (buffer-size) *user-auto-dictionary-buffer-limit*)
|
||||
;; Disables automatic dictionary detection in large buffers.
|
||||
(guess-language-mode -1)
|
||||
(with-feature 'flyspell-lazy
|
||||
(guess-language-mode t)
|
||||
;; Enables flyspell lazy mode for small buffers.
|
||||
(flyspell-lazy-mode t)))
|
||||
|
||||
(with-feature 'auto-correct
|
||||
(auto-correct-mode t))
|
||||
|
||||
;;; (Bindings) ;;;
|
||||
(user/bind-key-local :code :spellcheck-word 'ispell-word)
|
||||
(user/bind-key-local :code :spellcheck-add-word 'user/flyspell-add-word-to-dict))
|
||||
|
||||
|
||||
(defun user--flyspell-mode-hook ()
|
||||
"Hook for fly spell mode."
|
||||
(user--flyspell-mode-common-hook))
|
||||
|
||||
|
||||
(defun user--flyspell-prog-mode-hook ()
|
||||
"Hook for fly spell prog mode."
|
||||
(user--flyspell-mode-common-hook))
|
||||
|
||||
|
||||
(defun user/flyspell-add-word-to-dict ()
|
||||
"Add the word at the current location to the private dictionary without question."
|
||||
(interactive)
|
||||
;; Use the correct dictionary.
|
||||
(flyspell-accept-buffer-local-defs)
|
||||
(setq opoint (point-marker))
|
||||
(let ((cursor-location (point))
|
||||
(word (flyspell-get-word nil)))
|
||||
(if (consp word)
|
||||
(let ((start (car (cdr word)))
|
||||
(end (car (cdr (cdr word))))
|
||||
(word (car word)))
|
||||
;; The word is incorrect, we have to propose a replacement.
|
||||
(flyspell-do-correct 'save nil word cursor-location start end opoint)))
|
||||
(ispell-pdict-save t)))
|
||||
|
||||
(defun user-flyspell-p ()
|
||||
"Check if flyspell is available."
|
||||
(or (executable-find "ispell")
|
||||
(executable-find "aspell")
|
||||
(executable-find "hunspell"))
|
||||
nil)
|
||||
|
||||
(when (user-flyspell-p)
|
||||
(use-package flyspell
|
||||
:ensure nil
|
||||
:diminish flyspell-mode
|
||||
:hook ((flyspell-mode-hook . user--flyspell-mode-hook)
|
||||
(flyspell-prog-mode-hook . user--flyspell-prog-mode-hook))
|
||||
:config
|
||||
(validate-setq
|
||||
;; Be silent when checking words.
|
||||
flyspell-issue-message-flag nil)
|
||||
|
||||
(cond
|
||||
(;; Disable Hunspell due to issues on some machines.
|
||||
(and nil (executable-find "hunspell"))
|
||||
(validate-setq
|
||||
ispell-program-name "hunspell"
|
||||
ispell-really-hunspell t
|
||||
ispell-extra-args '("-a" "-i" "utf-8")))
|
||||
((executable-find "aspell")
|
||||
(progn
|
||||
(validate-setq
|
||||
ispell-program-name "aspell"
|
||||
ispell-really-aspell t
|
||||
;; Improve performance by reducing suggestions.
|
||||
ispell-extra-args '("--sug-mode=ultra" "--dont-suggest"))
|
||||
(when (boundp 'flyspell-list-command)
|
||||
(validate-setq
|
||||
flyspell-list-command "--list")))))
|
||||
;; http://elpa.gnu.org/packages/auto-correct.html
|
||||
;; Remembers and automatically fixes past corrections
|
||||
(use-package auto-correct
|
||||
:diminish auto-correct-mode)
|
||||
;; https://github.com/pronobis/helm-flyspell
|
||||
;; Helm extension for correcting words with Flyspell.
|
||||
(use-package helm-flyspell
|
||||
:bind ("C-c c s" . helm-flyspell-correct))
|
||||
;; https://github.com/rolandwalker/flyspell-lazy
|
||||
;; This package reduces the amount of work done by flyspell.
|
||||
;; Instead of checking instantly as you type, spelling will be checked when Emacs has been idle for a short time.
|
||||
(use-package flyspell-lazy
|
||||
:config
|
||||
(validate-setq
|
||||
;; Idle timeout before running spell check on region.
|
||||
flyspell-lazy-idle-seconds 10
|
||||
;; Idle timeout before running spell check on entire buffer.
|
||||
flyspell-lazy-window-idle-seconds 60))
|
||||
;; https://github.com/tmalsburg/guess-language.el
|
||||
;; Emacs minor mode for robust automatic language detection
|
||||
;; TODO: Add fr
|
||||
(use-package guess-language
|
||||
:diminish guess-language-mode
|
||||
:config
|
||||
(validate-setq
|
||||
;; By default only guess English.
|
||||
guess-language-languages '(en)))
|
||||
;; https://github.com/ppold/.emacs.d/blob/master/site-lisp/rw-hunspell.el
|
||||
;; special functions for Hunspell in ispell.el
|
||||
(use-package rw-hunspell
|
||||
:if (executable-find "hunspell")
|
||||
:config
|
||||
(with-eval-after-load 'ispell
|
||||
(when ispell-really-hunspell
|
||||
;; Initialize `rw-hunspell` if Hunspell is in use.
|
||||
(rw-hunspell-setup))))))
|
||||
|
||||
|
||||
(provide 'utilities/flyspell)
|
||||
;;; flyspell.el ends here
|
31
lisp/utilities/term.el
Normal file
31
lisp/utilities/term.el
Normal file
@@ -0,0 +1,31 @@
|
||||
;;; term.el --- Initialize the Emacs terminal -*- lexical-binding: t; -*-
|
||||
;;; Commentary: A terminal in Emacs
|
||||
;;; Code: Cross-referencing commands
|
||||
|
||||
(defun user--term-mode-hook ()
|
||||
"Term mode hook."
|
||||
(user--shell-mode-common-hook))
|
||||
|
||||
|
||||
(defun user--term-exec-hook ()
|
||||
"Term startup hook."
|
||||
;; Automatically close buffer when finished.
|
||||
(let* ((buf (current-buffer))
|
||||
(proc (get-buffer-process buf)))
|
||||
(set-process-sentinel
|
||||
proc
|
||||
`(lambda (process event)
|
||||
(if (string= event "finished\n")
|
||||
(kill-buffer ,buf))))))
|
||||
|
||||
(use-package term
|
||||
:defer
|
||||
:init
|
||||
(add-hook 'term-exec-hook 'user--term-exec-hook)
|
||||
(add-hook 'term-mode-hook 'user--term-mode-hook)
|
||||
:config
|
||||
(define-key term-raw-map (kbd "C-c C-y") 'term-paste))
|
||||
|
||||
|
||||
(provide 'utilities/term)
|
||||
;;; term.el ends here
|
65
lisp/utilities/tramp.el
Normal file
65
lisp/utilities/tramp.el
Normal file
@@ -0,0 +1,65 @@
|
||||
;;; tramp --- remote file access -*- lexical-binding: t; -*-
|
||||
;;; Commentary: https://www.emacswiki.org/emacs/TrampMode
|
||||
;;; Code:
|
||||
|
||||
(use-package tramp
|
||||
:ensure nil
|
||||
:after dash
|
||||
:commands
|
||||
(tramp-tramp-file-p
|
||||
tramp-check-proper-method-and-host)
|
||||
:config
|
||||
(validate-setq
|
||||
;; Auto save storage.
|
||||
tramp-auto-save-directory (path-join *user-auto-save-directory* "tramp")
|
||||
;; Default file transfer method.
|
||||
tramp-default-method "ssh"
|
||||
;; Cache passwords.
|
||||
password-cache t
|
||||
password-cache-expiry 1000
|
||||
;; SSH is properly configured to share connections.
|
||||
tramp-use-ssh-controlmaster-options nil
|
||||
;; Skip looking for dir-local on remote system to speed up tramp.
|
||||
enable-remote-dir-locals nil
|
||||
;; Preserve PATH on remote host.
|
||||
tramp-remote-path (delete 'tramp-default-remote-path tramp-remote-path))
|
||||
|
||||
;; Preserve PATH on remote host.
|
||||
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
|
||||
|
||||
(tramp-set-completion-function
|
||||
"ssh" (mapcar
|
||||
(lambda (x) (list 'tramp-parse-sconfig x))
|
||||
(-remove
|
||||
(lambda (x) (not (file-exists-p x)))
|
||||
`(,(path-join "/" "etc" "ssh_config")
|
||||
,(path-join "/" "etc" "ssh" "ssh_config")
|
||||
,(path-join *user-home-directory* ".ssh" "config")))))
|
||||
|
||||
(unless (fboundp 'tramp-compat-split-string)
|
||||
;; Workaround for Python mode depending on the deleted TRAMP
|
||||
;; function `tramp-compat-split-string'.
|
||||
(defun tramp-compat-split-string (string pattern)
|
||||
"Like `split-string' but omit empty strings.
|
||||
In Emacs, (split-string \"/foo/bar\" \"/\") returns (\"foo\" \"bar\").
|
||||
This is, the first, empty, element is omitted. In XEmacs, the first
|
||||
element is not omitted."
|
||||
(split-string string pattern 'omit)))
|
||||
;; http://web.mit.edu/Emacs/source/emacs/lisp/net/tramp-cache.el
|
||||
;; file information caching for Tramp
|
||||
(use-package tramp-cache
|
||||
:ensure tramp
|
||||
:config
|
||||
(validate-setq
|
||||
;; Persistency files.
|
||||
tramp-persistency-file-name
|
||||
(path-join *user-cache-directory* "tramp")))
|
||||
;; https://github.com/masasam/emacs-helm-tramp
|
||||
;; Tramp helm interface for ssh server and docker and vagrant
|
||||
(use-package helm-tramp
|
||||
:init
|
||||
(user/bind-key-global :basic :open-file-tramp 'helm-tramp)))
|
||||
|
||||
|
||||
(provide 'utilities/tramp)
|
||||
;;; tramp.el ends here
|
22
lisp/utilities/transient.el
Normal file
22
lisp/utilities/transient.el
Normal file
@@ -0,0 +1,22 @@
|
||||
;;; transient.el --- Configuration for transient. -*- lexical-binding: t; -*-
|
||||
;;; Commentary: Taking inspiration from prefix keys and prefix arguments,
|
||||
;;; Transient implements a similar abstraction involving a prefix command, infix arguments and suffix commands
|
||||
;;; Code: https://github.com/magit/transient
|
||||
|
||||
(use-package transient
|
||||
:ensure nil
|
||||
:config
|
||||
;; Using `validate-setq' here will cause loading to file if the
|
||||
;; history file does not exist.
|
||||
(setq
|
||||
;; Location of transient files.
|
||||
transient-history-file (path-join *user-cache-directory* "transient" "history.el")
|
||||
transient-values-file (path-join *user-cache-directory* "transient" "values.el")
|
||||
transient-levels-file (path-join *user-cache-directory* "transient" "levels.el"))
|
||||
|
||||
;; Create the transient cache folder.
|
||||
(make-directory (path-join *user-cache-directory* "transient") t))
|
||||
|
||||
|
||||
(provide 'utilities/transient)
|
||||
;;; transient.el ends here
|
16
lisp/utilities/yasnippet.el
Normal file
16
lisp/utilities/yasnippet.el
Normal file
@@ -0,0 +1,16 @@
|
||||
;;; yasnippet.el --- Configuration for yasnippet -*- lexical-binding: t: -*-
|
||||
;;; Commentary: YASnippet is a template system for Emacs
|
||||
;;; Code:
|
||||
;;; Docs: https://github.com/joaotavora/yasnippet
|
||||
|
||||
(use-package yasnippet
|
||||
:ensure t
|
||||
:config
|
||||
(use-package yasnippet-snippets
|
||||
:ensure t)
|
||||
(define-key yas-minor-mode-map (kbd "<tab>") nil)
|
||||
(define-key yas-minor-mode-map (kbd "TAB") nil)
|
||||
(define-key yas-minor-mode-map (kbd "C-c y") yas-maybe-expand)
|
||||
(yas-global-mode 1))
|
||||
|
||||
;;; yasnippet.el ends here
|
48
lisp/utilities/zettelkasten.el
Normal file
48
lisp/utilities/zettelkasten.el
Normal file
@@ -0,0 +1,48 @@
|
||||
;;; zettelkasten.el --- zettelkasten method -*- lexical-binding: t; -*-
|
||||
;;; Commentary:
|
||||
;;; Code:
|
||||
|
||||
(use-package org-roam
|
||||
:ensure t
|
||||
:init
|
||||
(setq org-roam-v2-ack t)
|
||||
:custom
|
||||
(org-roam-directory "~/.local/share/emacs/org/roam")
|
||||
:bind (("C-c n f" . org-roam-node-find)
|
||||
("C-c n r" . org-roam-node-random)
|
||||
(:map org-mode-map
|
||||
(("C-c n i" . org-roam-node-insert)
|
||||
("C-c n o" . org-id-get-create)
|
||||
("C-c n t" . org-roam-tag-add)
|
||||
("C-c n a" . org-roam-alias-add)
|
||||
("C-c n l" . org-roam-buffer-toggle))))
|
||||
:config
|
||||
;; org-roam-setup is obsolete, use org-roam-db-autosync-enable instead.
|
||||
(org-roam-db-autosync-enable))
|
||||
|
||||
;; Add modified and creation timestamps to the org-roam property drawer.
|
||||
;; https://github.com/ThomasFKJorna/org-roam-timestamps
|
||||
(use-package org-roam-timestamps
|
||||
:ensure t
|
||||
:after org-roam
|
||||
:config
|
||||
;; Overwrite the previous timestamps instead of keeping a list of timestamps.
|
||||
(setq org-roam-timestamps-remember-timestamps nil)
|
||||
(org-roam-timestamps-mode))
|
||||
|
||||
;; A graphical frontend for exploring your org-roam Zettelkasten.
|
||||
;; https://github.com/org-roam/org-roam-ui
|
||||
(use-package org-roam-ui
|
||||
:ensure t
|
||||
:after org-roam
|
||||
:config
|
||||
(setq
|
||||
;; Sync the Emacs theme
|
||||
org-roam-ui-sync-theme t
|
||||
;; TODO:
|
||||
org-roam-ui-follow t
|
||||
;; Enable open in default browser
|
||||
org-roam-ui-open-on-start t)
|
||||
)
|
||||
|
||||
;;; zettelkasten.el ends here
|
Reference in New Issue
Block a user