-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from kotct/release/v0.0.0
RELEASE v0.0.0
- Loading branch information
Showing
59 changed files
with
1,840 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# autosaves | ||
*~ | ||
\#*\# | ||
|
||
# compiled files | ||
*.elc | ||
lisp/kotct-loaddefs.el | ||
|
||
# various files | ||
ac-comphist.dat | ||
smex-items | ||
ido.last | ||
tramp | ||
.emacs.desktop | ||
.emacs.desktop.lock | ||
network-security.data | ||
session.* | ||
recentf | ||
custom.el | ||
|
||
# packages | ||
elpa/ | ||
|
||
# games | ||
games/ | ||
|
||
# tutorial data | ||
tutorial/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'fileutils' | ||
|
||
namespace :emacs do | ||
|
||
desc 'Installs the Emacs configuration' | ||
task :install do | ||
|
||
target = File.join(Dir.home, '.emacs.d') | ||
file = File.dirname(__FILE__) | ||
|
||
puts "Installing #{file} to #{target}." | ||
|
||
if File.exist?(target) | ||
puts "#{target} already exists. Removing." | ||
|
||
FileUtils.remove_entry(target) | ||
end | ||
|
||
puts "Symlinking #{file} to #{target}." | ||
|
||
File.symlink(file, target) | ||
|
||
puts "Done!" | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
;;; dot/.emacs | ||
|
||
;; Initialize the package repository. | ||
(package-initialize) | ||
|
||
;; Create variable to determine if we are in dev mode or not. | ||
;; (Set this in your user hub.) | ||
(defvar kotct/dev-mode | ||
nil | ||
"Whether or not kotct/dot emacs dev mode is enabled. | ||
Makes tests runnable and other dev-only goodies.") | ||
|
||
|
||
;;; Autoload Configuration | ||
(setf generated-autoload-file "~/.emacs.d/lisp/kotct-loaddefs.el") | ||
|
||
|
||
;;; Hub Initialization | ||
(defvar kotct/hub-list | ||
'("package" | ||
"file" | ||
"visual" | ||
"behavior" | ||
"code" | ||
"system" | ||
"user") | ||
"A list of hubs to load at init.") | ||
|
||
;; This variable is `nil' to begin with but gets populated by | ||
;; `kotct/hub' later on. | ||
(defvar kotct/files-to-compile | ||
nil | ||
"A list of files that ought to be byte-compiled.") | ||
|
||
;; Used by hubs to register themselves | ||
(defmacro kotct/hub (hubname features &optional autoloads) | ||
"Loads the hub denoted by HUBNAME. | ||
Defines a variable of the format kotct/HUBNAME-features to be the | ||
list FEATURES. | ||
Adds a list containing all of the files that need to be compiled | ||
in that directory to `kotct/files-to-compile'. | ||
If AUTOLOADS is non-nil, update the autoloads for that directory." | ||
(let ((feature-var (intern (concat "kotct/" hubname "-features")))) | ||
`(progn (defvar ,feature-var | ||
',features | ||
,(concat "A list of features to require from within the " hubname " hub.")) | ||
|
||
,(if autoloads '(update-directory-autoloads (file-name-directory load-file-name))) | ||
|
||
(setf kotct/files-to-compile | ||
(append kotct/files-to-compile | ||
(mapcar (lambda (x) | ||
(concat (file-name-directory load-file-name) (symbol-name x) ".el")) | ||
(append ',features ',autoloads)))) | ||
|
||
(mapc #'require ,feature-var)))) | ||
|
||
;; Add hub directories to the load paths. | ||
(let ((default-directory "~/.emacs.d/lisp/")) | ||
(add-to-list 'load-path default-directory) | ||
(normal-top-level-add-to-load-path kotct/hub-list)) | ||
|
||
(defun kotct/load-hubs (&optional frame) | ||
"Does the majority of initialization for dot/.emacs, | ||
by loading the hubs defined in `kotct/hub-list'. | ||
Pass FRAME if the function is being called on `after-make-frame-functions' | ||
and we need to remove the hook and specifically use the frame." | ||
;; If byte-compiled files are older, load newer version. | ||
(let ((load-prefer-newer t)) | ||
(when frame | ||
(select-frame frame) | ||
;; second run, we already have the resources to verify packages | ||
(kotct/check-dependency-list frame) | ||
(remove-hook 'after-make-frame-functions #'kotct/load-hubs)) | ||
;; require all hubs | ||
(mapc (lambda (hub) | ||
(require (intern (concat hub "-hub")))) | ||
kotct/hub-list) | ||
;; Load the loaddefs. | ||
(require 'kotct-loaddefs))) | ||
|
||
;; if we are running in daemon-mode and some packages aren't installed, | ||
;; wait until a frame is created to finish loading | ||
(if (eq 'daemon-mode | ||
(catch 'daemon-mode | ||
(kotct/load-hubs))) | ||
(add-hook 'after-make-frame-functions #'kotct/load-hubs)) | ||
|
||
|
||
;;; Asynchronous Byte Compilation | ||
(let* ((to-eval `(let ((default-directory "~/.emacs.d/lisp/")) | ||
(package-initialize) | ||
(add-to-list 'load-path default-directory) | ||
(normal-top-level-add-to-load-path ',kotct/hub-list) | ||
(batch-byte-compile t))) | ||
;; Command-line args as a list | ||
(args `("config-compilation" "*config-compilation*" "emacs" "--batch" "--eval" ,(format "%S" to-eval) ,@kotct/files-to-compile))) | ||
;; Start the process in *config-compilation* buffer | ||
(apply #'start-process args)) | ||
|
||
;; Warn the user about shadowed files on the load path. This usually | ||
;; happens when one keeps .elc files from removed .el files. | ||
(if (list-load-path-shadows) | ||
(message "There are shadowed files on your load path. | ||
This could indicate an issue with your emacs installation. | ||
Despite this, your config appears to have loaded successfully.") | ||
(message "Your config appears to have loaded successfully. Rock on!")) | ||
|
||
;; Kill the buffer corresponding to `generated-autoload-file'. After | ||
;; loading autoloads, we don't need it anymore. | ||
(let ((loaddefs-buffer (get-buffer (file-name-nondirectory generated-autoload-file)))) | ||
(if loaddefs-buffer | ||
(kill-buffer loaddefs-buffer))) | ||
|
||
;; If in dev mode, load the test runner. | ||
(when kotct/dev-mode | ||
(require 'dot-tests "~/.emacs.d/test/lisp/dot-tests")) | ||
|
||
|
||
;;; Customization File | ||
;; We set this to something we don't track because it can be unique | ||
;; for each system. | ||
(setf custom-file "~/.emacs.d/custom.el") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(kotct/hub "behavior" | ||
(completion-c | ||
pane-management | ||
window-management | ||
text)) | ||
|
||
(provide 'behavior-hub) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
;;; M-x: ido-completed M-x | ||
;;; C-c C-c M-x: normal M-x | ||
;;; | ||
;;; implicitly rebinds C-x C-f, C-x C-b, and similar functions to use ido | ||
;;; different keybindings for ido navigation based on menu mode | ||
;;; see docs for ido, ido-vertical-mode, and ido-grid-mode | ||
|
||
|
||
;;; ido | ||
(ido-mode t) | ||
(setf ido-enable-flex-matching t) | ||
|
||
(defvar kotct/ido-current-menu-mode | ||
;; set initially below, using kotct/ido-set-menu-mode | ||
nil | ||
"A symbol representing the current menu mode for ido. | ||
Should be either 'grid, 'vertical, or 'normal.") | ||
|
||
(defun kotct/ido-unset-menu-mode () | ||
"Unsets the current menu mode for ido, to allow a new mode to be set." | ||
(cond ((eq kotct/ido-current-menu-mode 'grid) | ||
(ido-grid-mode -1)) | ||
((eq kotct/ido-current-menu-mode 'vertical) | ||
(ido-vertical-mode -1)))) | ||
|
||
(defun kotct/ido-set-menu-mode (mode) | ||
"Set ido to use a menu type MODE. | ||
MODE is a symbol which can be grid (default), vertical, or normal." | ||
(kotct/ido-unset-menu-mode) | ||
(cond | ||
((eq mode 'grid) | ||
(ido-grid-mode 1) | ||
(setf kotct/ido-current-menu-mode 'grid)) | ||
((eq mode 'vertical) | ||
(ido-vertical-mode 1) | ||
(setq ido-vertical-show-count t) | ||
(setq ido-vertical-define-keys 'C-n-C-p-up-down-left-right) | ||
(setf kotct/ido-current-menu-mode 'vertical)) | ||
(t ;; note that for 'normal we don't need to do anything | ||
(setf kotct/ido-current-menu-mode 'normal)))) | ||
|
||
;; default to grid mode | ||
(kotct/ido-set-menu-mode 'grid) | ||
|
||
;;; smex | ||
(smex-initialize) | ||
(global-set-key (kbd "M-x") #'smex) | ||
(global-set-key (kbd "C-c C-c M-x") 'execute-extended-command) | ||
|
||
;; keep things contained within ~/.emacs.d | ||
(setf smex-save-file "~/.emacs.d/smex-items") | ||
|
||
;;; autocomplete | ||
(ac-config-default) | ||
|
||
(provide 'completion-c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
;;; C-x C-c: close current frame or, with confirmation, emacs session | ||
;;; C-c C-x C-c: old C-x C-c | ||
|
||
(defun kotct/close-current-frame-or-emacs (&optional arg) | ||
"Closes the current frame or Emacs. | ||
Kills Emacs if 1 frame is in (frame-list) and not a server process, | ||
or if passed an argument, but just current frame if otherwise." | ||
(interactive "P") | ||
|
||
(condition-case nil | ||
(let ((frame-list (frame-list))) | ||
(if (or (= (length frame-list) 1) arg) | ||
(if (not (boundp 'server-process)) | ||
(if (y-or-n-p "Kill Emacs?") | ||
(kill-emacs) | ||
(message "Didn't do anything, promise!")) | ||
(if (y-or-n-p "Kill Emacs?") | ||
(kill-emacs) | ||
(if (y-or-n-p "Delete current frame?") | ||
(delete-frame) | ||
(message "Didn't do anything, promise!")))) | ||
(delete-frame))) | ||
(error (kill-emacs)))) | ||
|
||
;; bind old C-x C-c to C-c C-x C-c | ||
(global-set-key (kbd "C-c C-x C-c") (key-binding (kbd "C-x C-c"))) | ||
(global-set-key (kbd "C-x C-c") #'kotct/close-current-frame-or-emacs) | ||
|
||
;; Set yes-or-no prompt to y or n | ||
(fset 'yes-or-no-p 'y-or-n-p) | ||
|
||
;;; i recommend some hydrocodone | ||
(provide 'pane-management) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
;;; C-c SPC: jump to any visible word | ||
;;; M-z: like C-c SPC but deletes all characters between and including point and the destination char | ||
;;; C-=: expand reigon to surrounding sexp | ||
;;; C-+: undo C-= | ||
;;; C-M-w: copy sexp to kill ring, appending if called repeatedly | ||
|
||
(require 'cl) | ||
|
||
;;; ace jump mode | ||
(global-set-key (kbd "C-c SPC") #'ace-jump-mode) | ||
|
||
;; save zapped chars to kill ring | ||
(setf ajz/zap-function #'kill-region) | ||
(global-set-key (kbd "M-z") #'ace-jump-zap-to-char) | ||
|
||
|
||
;;; jump to line | ||
(global-set-key (kbd "C-x g") #'goto-line) | ||
|
||
|
||
;;; expand-region | ||
(global-set-key (kbd "C-=") #'er/expand-region) | ||
(global-set-key (kbd "C-+") #'er/contract-region) | ||
|
||
|
||
;;; appending sexp copy | ||
(defvar kotct/sexp-copy-count | ||
0 | ||
"Number of commands since last `kotct/sexp-copy-as-kill'.") | ||
|
||
(add-hook 'pre-command-hook (lambda () (incf kotct/sexp-copy-count))) | ||
|
||
(defun kotct/sexp-copy-as-kill (arg) | ||
"Save next sexp as if killed, but don't kill it, appending if called repeatedly." | ||
(interactive "p") | ||
(message "%s" arg) | ||
(let ((beg (point))) | ||
(let ((parse-sexp-ignore-comments t)) | ||
(forward-sexp arg)) | ||
(if (= 1 kotct/sexp-copy-count) | ||
(append-next-kill)) | ||
(clipboard-kill-ring-save beg (point)) | ||
(setq kotct/sexp-copy-count 0))) | ||
|
||
(global-set-key (kbd "C-M-w") #'kotct/sexp-copy-as-kill) | ||
|
||
;; Always delete trailing whitespace before saving. | ||
(add-hook 'before-save-hook #'delete-trailing-whitespace) | ||
|
||
(provide 'text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
;;; C-s-l: switch focus to window above current | ||
;;; C-s-k: switch focus to window below current | ||
;;; C-s-j: switch focus to window to the left of current | ||
;;; C-s-;: switch focus to window to the right of current | ||
;;; C-M-s-l: move current buffer to window above current | ||
;;; C-M-s-k: move current buffer to window below current | ||
;;; C-M-s-j: move current buffer to window to the left of current | ||
;;; C-M-s-;: move current buffer to window to the right of current | ||
|
||
;;; windmove | ||
(global-set-key (kbd "C-s-l") #'windmove-up) | ||
(global-set-key (kbd "C-s-k") #'windmove-down) | ||
(global-set-key (kbd "C-s-j") #'windmove-left) | ||
(global-set-key (kbd "C-s-;") #'windmove-right) | ||
|
||
;;; buffer-move | ||
(global-set-key (kbd "C-M-s-l") #'buf-move-up) | ||
(global-set-key (kbd "C-M-s-k") #'buf-move-down) | ||
(global-set-key (kbd "C-M-s-j") #'buf-move-left) | ||
(global-set-key (kbd "C-M-s-;") #'buf-move-right) | ||
|
||
(provide 'window-management) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
(kotct/hub "code" | ||
(editorconfig-c | ||
magit-c | ||
indentation | ||
code-navigation)) | ||
|
||
;;; load individual language files via language-hub | ||
(add-to-list 'load-path (concat (file-name-directory load-file-name) "languages/")) | ||
(require 'language-hub) | ||
|
||
(provide 'code-hub) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
;;; M-n: go the next occurence of the symbol under point | ||
;;; M-p: go the previous occurence of the symbol under point | ||
;;; note: these keybindings are enabled as a part of `highlight-symbol-nav-mode' | ||
;;; M-': replace all following occurences of the symbol under point | ||
|
||
;; enable highlight-symbol mode for all programming modes | ||
(add-hook 'prog-mode-hook (lambda () | ||
(highlight-symbol-mode +1) | ||
(highlight-symbol-nav-mode +1) | ||
(local-set-key (kbd "M-'") #'highlight-symbol-query-replace))) | ||
|
||
(provide 'code-navigation) |
Oops, something went wrong.