Yet another big update
This commit is contained in:
parent
a8f32547a3
commit
c6862d1489
27 changed files with 474 additions and 355 deletions
9
Cask
9
Cask
|
@ -14,6 +14,7 @@
|
||||||
(depends-on "smex")
|
(depends-on "smex")
|
||||||
(depends-on "floobits")
|
(depends-on "floobits")
|
||||||
(depends-on "pos-tip")
|
(depends-on "pos-tip")
|
||||||
|
(depends-on "vim-empty-lines-mode")
|
||||||
|
|
||||||
;; OSX
|
;; OSX
|
||||||
(depends-on "exec-path-from-shell")
|
(depends-on "exec-path-from-shell")
|
||||||
|
@ -35,7 +36,7 @@
|
||||||
(depends-on "smartparens")
|
(depends-on "smartparens")
|
||||||
(depends-on "yasnippet")
|
(depends-on "yasnippet")
|
||||||
(depends-on "git-gutter-fringe+")
|
(depends-on "git-gutter-fringe+")
|
||||||
(depends-on "ace-jump-mode")
|
;; (depends-on "ace-jump-mode")
|
||||||
(depends-on "pcre2el")
|
(depends-on "pcre2el")
|
||||||
(depends-on "emr")
|
(depends-on "emr")
|
||||||
(depends-on "smart-forward")
|
(depends-on "smart-forward")
|
||||||
|
@ -60,8 +61,10 @@
|
||||||
;;(depends-on "jedi")
|
;;(depends-on "jedi")
|
||||||
|
|
||||||
;; Eeeevil
|
;; Eeeevil
|
||||||
(depends-on "god-mode")
|
;;(depends-on "god-mode")
|
||||||
(depends-on "evil")
|
(depends-on "evil")
|
||||||
|
(depends-on "evil-search-highlight-persist")
|
||||||
|
(depends-on "evil-commentary")
|
||||||
(depends-on "evil-matchit")
|
(depends-on "evil-matchit")
|
||||||
(depends-on "evil-surround")
|
(depends-on "evil-surround")
|
||||||
(depends-on "evil-numbers")
|
(depends-on "evil-numbers")
|
||||||
|
@ -71,7 +74,7 @@
|
||||||
(depends-on "evil-indent-textobject")
|
(depends-on "evil-indent-textobject")
|
||||||
(depends-on "evil-jumper")
|
(depends-on "evil-jumper")
|
||||||
(depends-on "evil-god-state")
|
(depends-on "evil-god-state")
|
||||||
(depends-on "evil-nerd-commenter")
|
;;(depends-on "evil-nerd-commenter")
|
||||||
(depends-on "evil-snipe")
|
(depends-on "evil-snipe")
|
||||||
;; evil-nerd-commenter chokes if it's installed via cask for some reason...
|
;; evil-nerd-commenter chokes if it's installed via cask for some reason...
|
||||||
|
|
||||||
|
|
|
@ -18,20 +18,21 @@
|
||||||
evil-insert-state-cursor '("white" bar)
|
evil-insert-state-cursor '("white" bar)
|
||||||
evil-visual-state-cursor 'hollow)
|
evil-visual-state-cursor 'hollow)
|
||||||
|
|
||||||
(evil-mode)
|
(evil-mode 1)
|
||||||
|
|
||||||
;; Always ensure evil-shift-width is consistent with tab-width
|
;; Always ensure evil-shift-width is consistent with tab-width
|
||||||
(add-hook! 'find-file-hook (setq evil-shift-width tab-width))
|
(add-hook! 'after-change-major-mode-hook (setq evil-shift-width tab-width))
|
||||||
|
|
||||||
;; highlight matching delimiters where it's important
|
;; highlight matching delimiters where it's important
|
||||||
(defun show-paren-mode-off () (show-paren-mode -1))
|
(defun show-paren-mode-off () (show-paren-mode -1))
|
||||||
(add-hook 'evil-insert-state-entry-hook 'show-paren-mode)
|
(add-hook 'evil-insert-state-entry-hook 'show-paren-mode)
|
||||||
(add-hook 'evil-insert-state-exit-hook 'show-paren-mode-off)
|
(add-hook 'evil-insert-state-exit-hook 'show-paren-mode-off)
|
||||||
(add-hook 'evil-visual-state-entry-hook 'show-paren-mode)
|
(add-hook 'evil-visual-state-entry-hook 'show-paren-mode)
|
||||||
(add-hook 'evil-visual-state-exit-hook 'show-paren-mode-off)
|
(add-hook 'evil-visual-state-exit-hook 'show-paren-mode-off)
|
||||||
(add-hook 'evil-motion-state-entry-hook 'show-paren-mode)
|
(add-hook 'evil-motion-state-entry-hook 'show-paren-mode)
|
||||||
(add-hook 'evil-motion-state-exit-hook 'show-paren-mode-off)
|
(add-hook 'evil-motion-state-exit-hook 'show-paren-mode-off)
|
||||||
(add-hook 'evil-operator-state-entry-hook 'show-paren-mode)
|
(add-hook 'evil-operator-state-entry-hook 'show-paren-mode)
|
||||||
(add-hook 'evil-operator-state-exit-hook 'show-paren-mode-off)
|
(add-hook 'evil-operator-state-exit-hook 'show-paren-mode-off)
|
||||||
|
|
||||||
;; Disable highlights on insert-mode
|
;; Disable highlights on insert-mode
|
||||||
(add-hook 'evil-insert-state-entry-hook 'evil-ex-nohighlight)
|
(add-hook 'evil-insert-state-entry-hook 'evil-ex-nohighlight)
|
||||||
|
@ -45,26 +46,24 @@
|
||||||
(evil-set-initial-state `,(car mode-map) `,(cdr mode-map)))
|
(evil-set-initial-state `,(car mode-map) `,(cdr mode-map)))
|
||||||
|
|
||||||
(progn ; evil plugins
|
(progn ; evil plugins
|
||||||
(use-package evil-exchange
|
|
||||||
:config
|
|
||||||
(defadvice evil-force-normal-state (before evil-esc-quit-exchange activate)
|
|
||||||
(when evil-exchange--overlays
|
|
||||||
(evil-exchange-cancel))))
|
|
||||||
|
|
||||||
(use-package evil-ex-registers)
|
(use-package evil-ex-registers)
|
||||||
|
|
||||||
(use-package evil-indent-textobject) ; vii/vai/vaI
|
(use-package evil-indent-textobject) ; vii/vai/vaI
|
||||||
|
|
||||||
(use-package evil-numbers)
|
(use-package evil-numbers)
|
||||||
|
(use-package evil-matchit :config (global-evil-matchit-mode 1))
|
||||||
|
(use-package evil-surround :config (global-evil-surround-mode 1))
|
||||||
|
(use-package evil-visualstar :config (global-evil-visualstar-mode 1))
|
||||||
|
|
||||||
(use-package evil-matchit
|
(use-package evil-commentary
|
||||||
:config (global-evil-matchit-mode 1))
|
:config (evil-commentary-mode 1))
|
||||||
|
|
||||||
(use-package evil-surround
|
;; (use-package evil-nerd-commenter
|
||||||
:config (global-evil-surround-mode 1))
|
;; :commands (evilnc-comment-operator
|
||||||
|
;; evilnc-comment-or-uncomment-lines
|
||||||
(use-package evil-nerd-commenter
|
;; evilnc-toggle-invert-comment-line-by-line
|
||||||
:init (setq evilnc-hotkey-comment-operator "gc"))
|
;; evilnc-comment-or-uncomment-paragraphs
|
||||||
|
;; evilnc-quick-comment-or-uncomment-to-the-line
|
||||||
|
;; evilnc-copy-and-comment-lines)
|
||||||
|
;; :init (setq evilnc-hotkey-comment-operator "gc"))
|
||||||
|
|
||||||
(use-package evil-jumper
|
(use-package evil-jumper
|
||||||
:init (setq evil-jumper-file (expand-file-name "jumplist" my-tmp-dir))
|
:init (setq evil-jumper-file (expand-file-name "jumplist" my-tmp-dir))
|
||||||
|
@ -74,6 +73,18 @@
|
||||||
evil-jumper-auto-save-interval 3600)
|
evil-jumper-auto-save-interval 3600)
|
||||||
(define-key evil-motion-state-map (kbd "H-i") 'evil-jumper/forward)))
|
(define-key evil-motion-state-map (kbd "H-i") 'evil-jumper/forward)))
|
||||||
|
|
||||||
|
(use-package evil-exchange
|
||||||
|
:config
|
||||||
|
(defadvice evil-force-normal-state (before evil-esc-quit-exchange activate)
|
||||||
|
(when evil-exchange--overlays
|
||||||
|
(evil-exchange-cancel))))
|
||||||
|
|
||||||
|
(use-package evil-search-highlight-persist
|
||||||
|
:config
|
||||||
|
(progn
|
||||||
|
(global-evil-search-highlight-persist t)
|
||||||
|
(set-face-attribute 'evil-search-highlight-persist-highlight-face nil :inherit 'evil-ex-lazy-highlight)))
|
||||||
|
|
||||||
(use-package evil-snipe
|
(use-package evil-snipe
|
||||||
:config
|
:config
|
||||||
(progn
|
(progn
|
||||||
|
@ -81,7 +92,7 @@
|
||||||
|
|
||||||
(setq evil-snipe-smart-case t)
|
(setq evil-snipe-smart-case t)
|
||||||
(setq evil-snipe-override-evil t)
|
(setq evil-snipe-override-evil t)
|
||||||
(setq evil-snipe-scope 'visible)
|
(setq evil-snipe-scope 'line)
|
||||||
(setq evil-snipe-repeat-scope 'buffer)
|
(setq evil-snipe-repeat-scope 'buffer)
|
||||||
(setq evil-snipe-override-evil-repeat-keys nil)
|
(setq evil-snipe-override-evil-repeat-keys nil)
|
||||||
(setq-default evil-snipe-symbol-groups
|
(setq-default evil-snipe-symbol-groups
|
||||||
|
@ -94,10 +105,7 @@
|
||||||
|
|
||||||
'visual
|
'visual
|
||||||
"z" 'evil-snipe-s
|
"z" 'evil-snipe-s
|
||||||
"Z" 'evil-snipe-S)))
|
"Z" 'evil-snipe-S))))
|
||||||
|
|
||||||
(use-package evil-visualstar
|
|
||||||
:config (global-evil-visualstar-mode 1)))
|
|
||||||
|
|
||||||
(bind evil-ex-completion-map
|
(bind evil-ex-completion-map
|
||||||
"C-r" #'evil-ex-paste-from-register ; registers in ex-mode
|
"C-r" #'evil-ex-paste-from-register ; registers in ex-mode
|
||||||
|
@ -108,7 +116,7 @@
|
||||||
|
|
||||||
(progn ; evil hacks
|
(progn ; evil hacks
|
||||||
(defadvice evil-force-normal-state (before evil-esc-quit activate)
|
(defadvice evil-force-normal-state (before evil-esc-quit activate)
|
||||||
(shut-up (evil-ex-nohighlight) ; turn off highlights
|
(shut-up (evil-search-highlight-persist-remove-all) ; turn off highlights
|
||||||
;; Exit minibuffer is alive
|
;; Exit minibuffer is alive
|
||||||
(if (minibuffer-window-active-p (minibuffer-window))
|
(if (minibuffer-window-active-p (minibuffer-window))
|
||||||
(my--minibuffer-quit))))
|
(my--minibuffer-quit))))
|
||||||
|
@ -151,7 +159,7 @@
|
||||||
(setq file-name
|
(setq file-name
|
||||||
;; %:p:h => the project root (or current directory otherwise)
|
;; %:p:h => the project root (or current directory otherwise)
|
||||||
(replace-regexp-in-string "\\(^\\|[^\\\\]\\)\\(%:p\\)"
|
(replace-regexp-in-string "\\(^\\|[^\\\\]\\)\\(%:p\\)"
|
||||||
(my--project-root) file-name t t 2))
|
(project-root) file-name t t 2))
|
||||||
(setq file-name
|
(setq file-name
|
||||||
;; %:p => the project root (or current directory otherwise)
|
;; %:p => the project root (or current directory otherwise)
|
||||||
(replace-regexp-in-string "\\(^\\|[^\\\\]\\)\\(%:d\\)"
|
(replace-regexp-in-string "\\(^\\|[^\\\\]\\)\\(%:d\\)"
|
||||||
|
@ -241,11 +249,11 @@ provided."
|
||||||
(if bang (--save-exit)))
|
(if bang (--save-exit)))
|
||||||
(error "Directory doesn't exist: %s" dir))))
|
(error "Directory doesn't exist: %s" dir))))
|
||||||
|
|
||||||
(evil-define-command my:rename-this-file (new-name &optional bang)
|
(evil-define-command my:rename-this-file (new-name)
|
||||||
"Renames current buffer and file it is visiting. Replaces %, # and other
|
"Renames current buffer and file it is visiting. Replaces %, # and other
|
||||||
variables (see `evil-ex-replace-special-filenames')"
|
variables (see `evil-ex-replace-special-filenames')"
|
||||||
:repeat nil
|
:repeat nil
|
||||||
(interactive "<f><!>")
|
(interactive "<f>")
|
||||||
(let ((name (buffer-name))
|
(let ((name (buffer-name))
|
||||||
(filename (buffer-file-name)))
|
(filename (buffer-file-name)))
|
||||||
(if (not (and filename (file-exists-p filename)))
|
(if (not (and filename (file-exists-p filename)))
|
||||||
|
@ -261,8 +269,6 @@ provided."
|
||||||
(set-visited-file-name new-name)
|
(set-visited-file-name new-name)
|
||||||
(set-buffer-modified-p nil)
|
(set-buffer-modified-p nil)
|
||||||
(save-place-forget-unreadable-files)
|
(save-place-forget-unreadable-files)
|
||||||
(when bang
|
|
||||||
(delete-file filename))
|
|
||||||
(message "File '%s' successfully renamed to '%s'"
|
(message "File '%s' successfully renamed to '%s'"
|
||||||
name (file-name-nondirectory new-name)))))))
|
name (file-name-nondirectory new-name)))))))
|
||||||
|
|
||||||
|
|
|
@ -25,32 +25,12 @@
|
||||||
(unless (featurep 'ns) ad-do-it)))
|
(unless (featurep 'ns) ad-do-it)))
|
||||||
|
|
||||||
;; Send current file to OSX apps
|
;; Send current file to OSX apps
|
||||||
(defun my--open-file-with (path &optional appName)
|
(defun my-open-with (&optional app-name path)
|
||||||
(if (and appName
|
(interactive)
|
||||||
(stringp appName)
|
(let ((app-name (if app-name (concat "-p " app-name)))
|
||||||
(not (string= "" appName)))
|
(path (or path (if (eq major-mode 'dired-mode) (dired-get-file-for-visit) (buffer-file-name)))))
|
||||||
(setq appName (concat "-a " appName ".app")))
|
(shell-command (concat "open " app-name " " (shell-quote-argument path)))))
|
||||||
(shell-command (concat "open " appName " " (shell-quote-argument path))))
|
|
||||||
|
|
||||||
(defun my-open-with (appName file)
|
|
||||||
(interactive "sApp name: ")
|
|
||||||
(my--open-file-with file appName))
|
|
||||||
|
|
||||||
(defun my-send-to-transmit (file)
|
|
||||||
(interactive "f")
|
|
||||||
(my-open-with "Transmit" file))
|
|
||||||
|
|
||||||
(defun my-send-to-launchbar (file)
|
|
||||||
(interactive "f")
|
|
||||||
(my-open-with "LaunchBar" file))
|
|
||||||
|
|
||||||
(defun my-send-dir-to-launchbar (dir)
|
|
||||||
(interactive "D")
|
|
||||||
(my--open-file-with dir "LaunchBar"))
|
|
||||||
|
|
||||||
(defun my-send-dir-to-finder (dir)
|
|
||||||
(interactive "D")
|
|
||||||
(my--open-file-with dir "Finder"))
|
|
||||||
|
|
||||||
|
|
||||||
(provide 'core-osx)
|
(provide 'core-osx)
|
||||||
|
;;; core-osx.el ends here
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
;;;; Load Theme ;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;; Load Theme ;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
(when window-system
|
(when window-system
|
||||||
(set-frame-parameter nil 'alpha '(96 86))
|
(set-frame-parameter nil 'alpha '(96 86))
|
||||||
;; Load font
|
(cycle-font 0)) ; Load font
|
||||||
(cycle-font 0))
|
|
||||||
|
|
||||||
(add-to-list 'custom-theme-load-path my-themes-dir)
|
(add-to-list 'custom-theme-load-path my-themes-dir)
|
||||||
(load-dark-theme)
|
(load-dark-theme)
|
||||||
|
@ -12,7 +11,7 @@
|
||||||
|
|
||||||
;;;; GUI Settings ;;;;;;;;;;;;;;;;;;;;;;
|
;;;; GUI Settings ;;;;;;;;;;;;;;;;;;;;;;
|
||||||
(tooltip-mode -1)
|
(tooltip-mode -1)
|
||||||
(blink-cursor-mode 1) ; blink cursor
|
(blink-cursor-mode -1) ; blink cursor
|
||||||
(global-hl-line-mode 1) ; highlight line
|
(global-hl-line-mode 1) ; highlight line
|
||||||
|
|
||||||
(setq linum-format " %3d")
|
(setq linum-format " %3d")
|
||||||
|
@ -25,6 +24,7 @@
|
||||||
(setq-default visible-bell nil) ; silence of the bells
|
(setq-default visible-bell nil) ; silence of the bells
|
||||||
(setq-default use-dialog-box nil) ; avoid GUI
|
(setq-default use-dialog-box nil) ; avoid GUI
|
||||||
(setq-default redisplay-dont-pause t)
|
(setq-default redisplay-dont-pause t)
|
||||||
|
(setq window-combination-resize t)
|
||||||
|
|
||||||
;; do not soft-wrap lines
|
;; do not soft-wrap lines
|
||||||
(setq-default truncate-lines t)
|
(setq-default truncate-lines t)
|
||||||
|
@ -44,10 +44,14 @@
|
||||||
|
|
||||||
|
|
||||||
;;;; Modeline ;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;; Modeline ;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
(use-package vim-empty-lines-mode
|
||||||
|
:config (global-vim-empty-lines-mode +1))
|
||||||
|
|
||||||
(use-package uniquify
|
(use-package uniquify
|
||||||
:config (setq uniquify-buffer-name-style 'post-forward
|
:config
|
||||||
uniquify-separator ":"
|
(setq uniquify-buffer-name-style 'post-forward-angle-brackets
|
||||||
uniquify-ignore-buffers-re "^\\*"))
|
uniquify-separator ":"
|
||||||
|
uniquify-ignore-buffers-re "^\\*"))
|
||||||
|
|
||||||
(use-package smart-mode-line
|
(use-package smart-mode-line
|
||||||
:config
|
:config
|
||||||
|
@ -67,6 +71,9 @@
|
||||||
" hs"
|
" hs"
|
||||||
" ElDoc"
|
" ElDoc"
|
||||||
" wg"
|
" wg"
|
||||||
|
" ~"
|
||||||
|
" s-/"
|
||||||
|
" yas"
|
||||||
) "\\|"))
|
) "\\|"))
|
||||||
:init
|
:init
|
||||||
(progn
|
(progn
|
||||||
|
|
181
core/core.el
181
core/core.el
|
@ -1,7 +1,6 @@
|
||||||
(defconst is-mac (eq system-type 'darwin))
|
(defconst is-mac (eq system-type 'darwin))
|
||||||
(defconst is-linux (eq system-type 'gnu/linux))
|
(defconst is-linux (eq system-type 'gnu/linux))
|
||||||
(defconst is-windows (or (eq system-type 'ms-dos)
|
(defconst is-windows (eq system-type 'windows-nt))
|
||||||
(eq system-type 'windows-nt)))
|
|
||||||
|
|
||||||
(when is-linux (add-to-list 'load-path "~/.cask"))
|
(when is-linux (add-to-list 'load-path "~/.cask"))
|
||||||
(setq use-package-verbose DEBUG-MODE)
|
(setq use-package-verbose DEBUG-MODE)
|
||||||
|
@ -34,8 +33,10 @@
|
||||||
(electric-indent-mode -1) ; In case of emacs >24.4
|
(electric-indent-mode -1) ; In case of emacs >24.4
|
||||||
|
|
||||||
;;; window layout undo/redo
|
;;; window layout undo/redo
|
||||||
|
(setq winner-boring-buffers '("*Completions*" "*Compile-Log*" "*inferior-lisp*"
|
||||||
|
"*Fuzzy Completions*" "*Apropos*" "*Help*" "*cvs*"
|
||||||
|
"*Buffer List*" "*Ibuffer*" "*esh command on file*"))
|
||||||
(winner-mode 1)
|
(winner-mode 1)
|
||||||
(setq winner-boring-buffers '("*Completions*" "*Help*"))
|
|
||||||
|
|
||||||
;;; UTF-8 please
|
;;; UTF-8 please
|
||||||
(setq locale-coding-system 'utf-8) ; pretty
|
(setq locale-coding-system 'utf-8) ; pretty
|
||||||
|
@ -59,8 +60,8 @@
|
||||||
|
|
||||||
(setq-default fill-column 80)
|
(setq-default fill-column 80)
|
||||||
|
|
||||||
;; minibufferception? Nay!
|
;; minibufferception? Yay!
|
||||||
(setq-default enable-recursive-minibuffers nil)
|
(setq-default enable-recursive-minibuffers t)
|
||||||
|
|
||||||
;; Sane scroll settings
|
;; Sane scroll settings
|
||||||
(setq scroll-margin 5)
|
(setq scroll-margin 5)
|
||||||
|
@ -100,6 +101,19 @@
|
||||||
;; Fixes C-i's synonymity with TAB
|
;; Fixes C-i's synonymity with TAB
|
||||||
(keyboard-translate ?\C-i ?\H-i)
|
(keyboard-translate ?\C-i ?\H-i)
|
||||||
|
|
||||||
|
;; Save clipboard contents into kill-ring before replace them
|
||||||
|
(setq save-interprogram-paste-before-kill t)
|
||||||
|
|
||||||
|
;; don't let the cursor go into minibuffer prompt
|
||||||
|
;; Tip taken from Xah Lee: http://ergoemacs.org/emacs/emacs_stop_cursor_enter_prompt.html
|
||||||
|
(setq minibuffer-prompt-properties
|
||||||
|
'(read-only t point-entered minibuffer-avoid-prompt face minibuffer-prompt))
|
||||||
|
|
||||||
|
;; remove annoying ellipsis when printing sexp in message buffer
|
||||||
|
(setq eval-expression-print-length nil
|
||||||
|
eval-expression-print-level nil)
|
||||||
|
|
||||||
|
|
||||||
;;;; Backup ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;; Backup ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Disable all backups (that's what git/dropbox are for)
|
;; Disable all backups (that's what git/dropbox are for)
|
||||||
(setq bookmark-save-flag t)
|
(setq bookmark-save-flag t)
|
||||||
|
@ -114,30 +128,27 @@
|
||||||
;; Remember undo history
|
;; Remember undo history
|
||||||
(setq-default undo-tree-auto-save-history t)
|
(setq-default undo-tree-auto-save-history t)
|
||||||
(setq-default undo-tree-history-directory-alist `(("." . ,my-tmp-dir-undo)))
|
(setq-default undo-tree-history-directory-alist `(("." . ,my-tmp-dir-undo)))
|
||||||
;;;; Save history across sessions
|
|
||||||
(setq savehist-additional-variables '(search ring regexp-search-ring))
|
;; Save history across sessions
|
||||||
(setq savehist-file (concat my-tmp-dir "savehist")) ; keep the home clean
|
(require 'savehist)
|
||||||
|
(setq savehist-file (concat my-tmp-dir "savehist") ; keep the home clean
|
||||||
|
savehist-additional-variables '(kill-ring mark-ring global-mark-ring search-ring regexp-search-ring extended-command-history)
|
||||||
|
history-length 1000)
|
||||||
(savehist-mode 1)
|
(savehist-mode 1)
|
||||||
|
|
||||||
;; Save cursor location across sessions
|
;; Save cursor location across sessions
|
||||||
(use-package saveplace
|
(require 'saveplace)
|
||||||
:init
|
(setq-default save-place-file (concat my-tmp-dir "saveplace"))
|
||||||
(add-hook 'find-file-hook ; activate save-place for files that exist
|
;; activate save-place only for files that exist
|
||||||
(lambda()
|
(add-hook 'find-file-hook (lambda() (if (file-exists-p buffer-file-name) (setq save-place t))))
|
||||||
(if (file-exists-p buffer-file-name)
|
|
||||||
(setq save-place t))))
|
|
||||||
:config
|
|
||||||
(setq save-place-file (concat my-tmp-dir "saveplace")))
|
|
||||||
|
|
||||||
(use-package recentf
|
(require 'recentf)
|
||||||
:config
|
(setq recentf-save-file (concat my-tmp-dir "recentf"))
|
||||||
(progn
|
(setq recentf-exclude '("/tmp/" "/ssh:" "\\.?ido\\.last\\'" "\\.revive\\'", "/TAGS\\'"))
|
||||||
(setq recentf-max-menu-items 0)
|
(setq recentf-max-menu-items 0)
|
||||||
(setq recentf-max-saved-items 1000)
|
(setq recentf-max-saved-items 1000)
|
||||||
(setq recentf-auto-cleanup 'never)
|
(setq recentf-auto-cleanup 'never)
|
||||||
(setq recentf-save-file (concat my-tmp-dir "recentf"))
|
(recentf-mode 1)
|
||||||
(setq recentf-exclude '("/tmp/" "/ssh:" "\\.?ido\\.last\\'" "\\.revive\\'", "/TAGS\\'"))
|
|
||||||
(recentf-mode 1)))
|
|
||||||
|
|
||||||
;; What we do every night, Pinkie...
|
;; What we do every night, Pinkie...
|
||||||
(defun display-startup-echo-area-message ()
|
(defun display-startup-echo-area-message ()
|
||||||
|
@ -154,41 +165,75 @@
|
||||||
|
|
||||||
(setq delete-trailing-lines nil)
|
(setq delete-trailing-lines nil)
|
||||||
(add-hook 'makefile-mode-hook 'indent-tabs-mode) ; Use normal tabs in makefiles
|
(add-hook 'makefile-mode-hook 'indent-tabs-mode) ; Use normal tabs in makefiles
|
||||||
|
|
||||||
|
;; Automatic minor modes ;;;;;;;;;;;
|
||||||
|
(require 'f)
|
||||||
|
(defvar project-root-files '(".git" ".hg" ".svn" "README" "README.md"))
|
||||||
|
(defun project-root (&optional strict-p)
|
||||||
|
"Get the path to the root of your project. Uses `project-root-files' to
|
||||||
|
determine if a directory is a project."
|
||||||
|
(catch 'found
|
||||||
|
(f-traverse-upwards
|
||||||
|
(lambda (path)
|
||||||
|
(let ((path (file-truename path))
|
||||||
|
(home (file-truename "~")))
|
||||||
|
(if (f-equal? home path)
|
||||||
|
(throw 'found (if strict-p nil default-directory))
|
||||||
|
(dolist (file project-root-files)
|
||||||
|
(when (f-exists? (expand-file-name file path))
|
||||||
|
(throw 'found path)))))) default-directory)
|
||||||
|
default-directory))
|
||||||
|
|
||||||
|
(defun project-has-files (&rest files)
|
||||||
|
"Return non-nil if `file' exists in the project root."
|
||||||
|
(let ((root (project-root))
|
||||||
|
found-p file)
|
||||||
|
(while (and files (not found-p))
|
||||||
|
(setq file (pop files))
|
||||||
|
(setq found-p (f-exists? (project-path-to file root))))
|
||||||
|
found-p))
|
||||||
|
|
||||||
|
(defun project-path-to (file &optional root)
|
||||||
|
(let ((root (or root (project-root))))
|
||||||
|
(expand-file-name file root)))
|
||||||
|
|
||||||
|
(defun project-name ()
|
||||||
|
(file-name-nondirectory (directory-file-name (project-root))))
|
||||||
|
|
||||||
|
(defvar auto-minor-mode-alist ()
|
||||||
|
"Alist of filename patterns vs correpsonding minor mode functions,
|
||||||
|
see `auto-mode-alist' All elements of this alist are checked, meaning
|
||||||
|
you can enable multiple minor modes for the same regexp.")
|
||||||
|
(defun enable-minor-mode-based-on-path ()
|
||||||
|
"check file name against auto-minor-mode-alist to enable minor modes
|
||||||
|
the checking happens for all pairs in auto-minor-mode-alist"
|
||||||
|
(when buffer-file-name
|
||||||
|
(let ((name buffer-file-name)
|
||||||
|
(remote-id (file-remote-p buffer-file-name))
|
||||||
|
(alist auto-minor-mode-alist))
|
||||||
|
;; Remove backup-suffixes from file name.
|
||||||
|
(setq name (file-name-sans-versions name))
|
||||||
|
;; Remove remote file name identification.
|
||||||
|
(when (and (stringp remote-id)
|
||||||
|
(string-match-p (regexp-quote remote-id) name))
|
||||||
|
(setq name (substring name (match-end 0))))
|
||||||
|
(while (and alist (caar alist) (cdar alist))
|
||||||
|
(if (string-match (caar alist) name)
|
||||||
|
(funcall (cdar alist) 1))
|
||||||
|
(setq alist (cdr alist))))))
|
||||||
|
(add-hook 'find-file-hook 'enable-minor-mode-based-on-path)
|
||||||
|
|
||||||
;; Make sure scratch buffer is always "in a project"
|
;; Make sure scratch buffer is always "in a project"
|
||||||
(defun set-project-scratch-buffer ()
|
(defun project-create-scratch-buffer ()
|
||||||
(let ((buffer (get-buffer "*scratch*"))
|
(let* ((scratch-buffer (get-buffer-create "*scratch*"))
|
||||||
(pwd (my--project-root)))
|
(project-name (project-name))
|
||||||
(when (buffer-live-p buffer)
|
(root (project-root)))
|
||||||
(save-window-excursion
|
(save-window-excursion
|
||||||
(switch-to-buffer buffer)
|
(switch-to-buffer scratch-buffer)
|
||||||
(unless (eq (my--project-root) pwd)
|
(erase-buffer)
|
||||||
(cd pwd)
|
(cd root)
|
||||||
(rename-buffer (format "*scratch* (%s)" (file-name-nondirectory (directory-file-name pwd)))))))))
|
(insert ";; Project: " project-name "\n\n"))))
|
||||||
(add-hook 'find-file-hook 'set-project-scratch-buffer)
|
(add-hook 'find-file-hook 'project-create-scratch-buffer)
|
||||||
|
|
||||||
|
|
||||||
;;;; Behavior adjustments ;;;;;;;;;;;;;;;;
|
|
||||||
;; Skip special buffers on next/previous-buffer or kill-this-buffer
|
|
||||||
(defadvice next-buffer (after void-messages-buffer-in-next-buffer activate)
|
|
||||||
(let ((buffer-name (buffer-name)))
|
|
||||||
(when (and (string-match-p "\\`\\(\\*.+\\*\\|TAGS\\)$" buffer-name)
|
|
||||||
(not (string-match-p "\\`\\*scratch*" buffer-name)))
|
|
||||||
(next-buffer))))
|
|
||||||
(defadvice previous-buffer (after avoid-messages-buffer-in-previous-buffer activate)
|
|
||||||
(let ((buffer-name (buffer-name)))
|
|
||||||
(when (and (string-match-p "\\`\\(\\*.+\\*\\|TAGS\\)$" buffer-name)
|
|
||||||
(not (string-match-p "\\`\\*scratch*" buffer-name)))
|
|
||||||
(previous-buffer))))
|
|
||||||
(defadvice kill-this-buffer (after kill-this-buffer-no-switch-to-special-buffers activate)
|
|
||||||
(let ((buffer-name (buffer-name)))
|
|
||||||
(if (and (string-match-p "^\\*.+\\*" buffer-name)
|
|
||||||
(not (string-match-p "^\\*scratch\\*" buffer-name)))
|
|
||||||
(previous-buffer))))
|
|
||||||
;; Don't kill the scratch buffer, just empty and bury it
|
|
||||||
(defadvice kill-this-buffer (around kill-this-buffer-or-empty-scratch activate)
|
|
||||||
(if (string-match-p "^\\*scratch\\*" (buffer-name))
|
|
||||||
(bury-buffer)
|
|
||||||
ad-do-it))
|
|
||||||
|
|
||||||
|
|
||||||
;;;; Utility plugins ;;;;;;;;;;;;;;;;;;
|
;;;; Utility plugins ;;;;;;;;;;;;;;;;;;
|
||||||
|
@ -220,26 +265,20 @@
|
||||||
(push '("^\\*scratch\\*.*" :regexp t :stick t) popwin:special-display-config)
|
(push '("^\\*scratch\\*.*" :regexp t :stick t) popwin:special-display-config)
|
||||||
(push '(image-mode) popwin:special-display-config)
|
(push '(image-mode) popwin:special-display-config)
|
||||||
|
|
||||||
(after "evil"
|
|
||||||
(evil-ex-define-cmd "l[ast]" 'popwin:popup-last-buffer)
|
|
||||||
(evil-ex-define-cmd "m[sg]" 'popwin:messages))
|
|
||||||
|
|
||||||
(defun popwin:toggle-popup-window ()
|
(defun popwin:toggle-popup-window ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(if (popwin:popup-window-live-p)
|
(if (popwin:popup-window-live-p)
|
||||||
(popwin:close-popup-window)
|
(popwin:close-popup-window)
|
||||||
(popwin:popup-last-buffer)))))
|
(popwin:popup-last-buffer)))))
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
;;;; Start the party ;;;;;;;;;;;;;;;;;;;
|
(cond (is-mac (require 'core-osx))
|
||||||
(if is-mac (require 'core-osx))
|
(is-linux (require 'core-linux))
|
||||||
;; (if is-linux (require 'core-linux))
|
(is-windows (require 'core-windows)))
|
||||||
;; (if is-windows (require 'core-windows))
|
|
||||||
|
|
||||||
(use-package server
|
(require 'server)
|
||||||
:config
|
(unless (server-running-p) (server-start)))
|
||||||
(unless (server-running-p)
|
|
||||||
(server-start))))
|
|
||||||
|
|
||||||
|
|
||||||
(provide 'core)
|
(provide 'core)
|
||||||
|
|
|
@ -100,3 +100,36 @@ gets killed.")
|
||||||
(if (s-matches? regexp (buffer-name b))
|
(if (s-matches? regexp (buffer-name b))
|
||||||
(kill-buffer b)))
|
(kill-buffer b)))
|
||||||
(if buffer-list buffer-list (buffer-list))))
|
(if buffer-list buffer-list (buffer-list))))
|
||||||
|
|
||||||
|
;; From spacemacs <https://github.com/syl20bnr/spacemacs/blob/master/spacemacs/funcs.el>
|
||||||
|
;;;###autoload
|
||||||
|
(defun my-next-real-buffer ()
|
||||||
|
"Switch to the next buffer and avoid special buffers."
|
||||||
|
(interactive)
|
||||||
|
(switch-to-next-buffer)
|
||||||
|
(let ((i 0))
|
||||||
|
(while (and (< i 100) (string-equal "*" (substring (buffer-name) 0 1)))
|
||||||
|
(1+ i)
|
||||||
|
(switch-to-next-buffer))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun my-previous-real-buffer ()
|
||||||
|
"Switch to the previous buffer and avoid special buffers."
|
||||||
|
(interactive)
|
||||||
|
(switch-to-prev-buffer)
|
||||||
|
(let ((i 0))
|
||||||
|
(while (and (< i 100) (string-equal "*" (substring (buffer-name) 0 1)))
|
||||||
|
(1+ i)
|
||||||
|
(switch-to-prev-buffer))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun my-kill-real-buffer ()
|
||||||
|
"Kill buffer (but only bury scratch buffer)"
|
||||||
|
(interactive)
|
||||||
|
(let ((bname (buffer-name)))
|
||||||
|
(cond ((string-match-p "^\\*scratch\\*" bname)
|
||||||
|
(erase-buffer)
|
||||||
|
(bury-buffer))
|
||||||
|
((string-equal "*" (substring bname 0 1))
|
||||||
|
(previous-buffer))
|
||||||
|
(t (kill-this-buffer)))))
|
||||||
|
|
|
@ -57,16 +57,21 @@ whitespace as possible, or just one char if that's not possible."
|
||||||
((or indent-tabs-mode
|
((or indent-tabs-mode
|
||||||
(= (point-at-bol) (point)))
|
(= (point-at-bol) (point)))
|
||||||
(call-interactively 'backward-delete-char))
|
(call-interactively 'backward-delete-char))
|
||||||
;; Otherwise, delete up to the nearest tab column
|
;; Delete up to the nearest tab column IF only whitespace between point
|
||||||
(t (let ((movement (% (current-column) tab-width))
|
;; and bol.
|
||||||
(p (point)))
|
((looking-back "^[\\t ]*" (point-at-bol))
|
||||||
(when (= movement 0)
|
(let ((movement (% (current-column) tab-width))
|
||||||
(setq movement tab-width))
|
(p (point)))
|
||||||
(save-match-data
|
(when (= movement 0)
|
||||||
(if (string-match "\\w*\\(\\s-+\\)$"
|
(setq movement tab-width))
|
||||||
(buffer-substring-no-properties (- p movement) p))
|
(save-match-data
|
||||||
(backward-delete-char (- (match-end 1) (match-beginning 1)))
|
(if (string-match "\\w*\\(\\s-+\\)$"
|
||||||
(backward-delete-char-untabify 1)))))))
|
(buffer-substring-no-properties (- p movement) p))
|
||||||
|
(backward-delete-char (- (match-end 1) (match-beginning 1)))
|
||||||
|
(backward-delete-char-untabify 1)))))
|
||||||
|
;; Otherwise do a regular delete
|
||||||
|
(t
|
||||||
|
(backward-delete-char-untabify 1))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun my.dumb-indent ()
|
(defun my.dumb-indent ()
|
||||||
|
|
|
@ -30,12 +30,8 @@
|
||||||
(load-dark-theme)))
|
(load-dark-theme)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun cycle-font (&optional i)
|
(defun toggle-fullscreen ()
|
||||||
"Cycle between fonts specified in *fonts in init.el"
|
|
||||||
(interactive)
|
(interactive)
|
||||||
(if (numberp i)
|
(set-frame-parameter nil 'fullscreen
|
||||||
(setq my/cycle-font-i i)
|
(when (not (frame-parameter nil 'fullscreen)) 'fullboth)))
|
||||||
(if (>= my/cycle-font-i (1- (length *fonts)))
|
|
||||||
(setq my/cycle-font-i 0)
|
|
||||||
(cl-incf my/cycle-font-i)))
|
|
||||||
(set-frame-font (nth my/cycle-font-i *fonts)))
|
|
||||||
|
|
|
@ -1,16 +1,9 @@
|
||||||
|
|
||||||
;; String Defuns ;;;;;;;;;;;;;;;;;;;;;;;
|
;; String Defuns ;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(after "s"
|
(defun s-count-lines (s)
|
||||||
(defun s-count-lines (s)
|
"Get number of lines in a string"
|
||||||
"Get number of lines in a string"
|
(length (s-lines s)))
|
||||||
(length (s-lines s))))
|
|
||||||
|
|
||||||
;; File Defuns ;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
;;;###autoload
|
|
||||||
(after "f"
|
|
||||||
(defmacro f--exists? (file dir)
|
|
||||||
`(f-exists? (expand-file-name ,file ,dir))))
|
|
||||||
|
|
||||||
;; Misc Defuns ;;;;;;;;;;;;;;;;;;;;;;;;;
|
;; Misc Defuns ;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
@ -32,3 +25,10 @@
|
||||||
(minor-mode-key-binding key)
|
(minor-mode-key-binding key)
|
||||||
(local-key-binding key)
|
(local-key-binding key)
|
||||||
(global-key-binding key)))
|
(global-key-binding key)))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun echo (msg &rest args)
|
||||||
|
"Display MSG in echo-area without logging it in *Messages* buffer."
|
||||||
|
(interactive)
|
||||||
|
(let ((message-log-max nil))
|
||||||
|
(apply 'message msg args)))
|
||||||
|
|
100
core/defuns.el
100
core/defuns.el
|
@ -1,41 +1,29 @@
|
||||||
;; Convenience ;;;;;;;;;;;;;;;;;;;;;
|
;; Convenience ;;;;;;;;;;;;;;;;;;;;;
|
||||||
(defun associate-mode (match mode)
|
(defun associate-mode (match mode)
|
||||||
|
"Associate a major mode with a filepath through `auto-mode-alist'"
|
||||||
(add-to-list 'auto-mode-alist (cons match mode)))
|
(add-to-list 'auto-mode-alist (cons match mode)))
|
||||||
|
|
||||||
(defun associate-minor-mode (match mode)
|
(defun associate-minor-mode (match mode)
|
||||||
|
"Associate a minor mode with a filepath through `auto-minor-mode-alist'"
|
||||||
(add-to-list 'auto-minor-mode-alist (cons match mode)))
|
(add-to-list 'auto-minor-mode-alist (cons match mode)))
|
||||||
|
|
||||||
;; Automatic minor modes ;;;;;;;;;;;
|
|
||||||
(defvar auto-minor-mode-alist ()
|
|
||||||
"Alist of filename patterns vs correpsonding minor mode functions,
|
|
||||||
see `auto-mode-alist' All elements of this alist are checked, meaning
|
|
||||||
you can enable multiple minor modes for the same regexp.")
|
|
||||||
(defun enable-minor-mode-based-on-extension ()
|
|
||||||
"check file name against auto-minor-mode-alist to enable minor modes
|
|
||||||
the checking happens for all pairs in auto-minor-mode-alist"
|
|
||||||
(when buffer-file-name
|
|
||||||
(let ((name buffer-file-name)
|
|
||||||
(remote-id (file-remote-p buffer-file-name))
|
|
||||||
(alist auto-minor-mode-alist))
|
|
||||||
;; Remove backup-suffixes from file name.
|
|
||||||
(setq name (file-name-sans-versions name))
|
|
||||||
;; Remove remote file name identification.
|
|
||||||
(when (and (stringp remote-id)
|
|
||||||
(string-match-p (regexp-quote remote-id) name))
|
|
||||||
(setq name (substring name (match-end 0))))
|
|
||||||
(while (and alist (caar alist) (cdar alist))
|
|
||||||
(if (string-match (caar alist) name)
|
|
||||||
(funcall (cdar alist) 1))
|
|
||||||
(setq alist (cdr alist))))))
|
|
||||||
(add-hook 'find-file-hook 'enable-minor-mode-based-on-extension)
|
|
||||||
|
|
||||||
(defmacro λ (&rest body)
|
(defmacro λ (&rest body)
|
||||||
|
"A shortcut for: `(lambda () (interactive) ,@body)"
|
||||||
`(lambda () (interactive) ,@body))
|
`(lambda () (interactive) ,@body))
|
||||||
|
|
||||||
|
(defun add-hooks (hooks funs)
|
||||||
|
"Add multiple hooks to multiple funs."
|
||||||
|
(let ((funs (if (listp funs) funs (list funs)))
|
||||||
|
(hooks (if (listp hooks) hooks (list hooks))))
|
||||||
|
(dolist (hook hooks)
|
||||||
|
(dolist (fun funs)
|
||||||
|
(add-hook hook fun)))))
|
||||||
|
|
||||||
(defmacro add-hook! (hook &rest body)
|
(defmacro add-hook! (hook &rest body)
|
||||||
|
"A shortcut macro for `add-hook' that auto-wraps `body' in a lambda"
|
||||||
`(add-hook ,hook (lambda() ,@body)))
|
`(add-hook ,hook (lambda() ,@body)))
|
||||||
|
|
||||||
;; Backwards compatibility
|
;; Backwards compatible `with-eval-after-load'
|
||||||
(unless (fboundp 'with-eval-after-load)
|
(unless (fboundp 'with-eval-after-load)
|
||||||
(defmacro with-eval-after-load (file &rest body)
|
(defmacro with-eval-after-load (file &rest body)
|
||||||
`(eval-after-load ,file
|
`(eval-after-load ,file
|
||||||
|
@ -52,13 +40,6 @@ the checking happens for all pairs in auto-minor-mode-alist"
|
||||||
'with-no-warnings)
|
'with-no-warnings)
|
||||||
(with-eval-after-load ',feature ,@forms)))
|
(with-eval-after-load ',feature ,@forms)))
|
||||||
|
|
||||||
(after "projectile"
|
|
||||||
(defun my--project-root (&optional force-pwd)
|
|
||||||
(if (and (not force-pwd)
|
|
||||||
(projectile-project-p))
|
|
||||||
(projectile-project-root)
|
|
||||||
default-directory)))
|
|
||||||
|
|
||||||
|
|
||||||
;; Keybindings ;;;;;;;;;;;;;;;;;;;;;;;;;
|
;; Keybindings ;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
(defun bind (&rest keys)
|
(defun bind (&rest keys)
|
||||||
|
@ -73,9 +54,9 @@ the checking happens for all pairs in auto-minor-mode-alist"
|
||||||
(t
|
(t
|
||||||
(if (stringp key)
|
(if (stringp key)
|
||||||
(setq key (kbd key)))
|
(setq key (kbd key)))
|
||||||
(setq def (pop keys))
|
(when (eq (length keys) 0)
|
||||||
(when (null def)
|
|
||||||
(user-error "No definition for '%s' keybinding" key))
|
(user-error "No definition for '%s' keybinding" key))
|
||||||
|
(setq def (pop keys))
|
||||||
(if (null state-list)
|
(if (null state-list)
|
||||||
(if (null keymap)
|
(if (null keymap)
|
||||||
(global-set-key key def)
|
(global-set-key key def)
|
||||||
|
@ -118,12 +99,17 @@ key-chord-define."
|
||||||
(defun disable-final-newline ()
|
(defun disable-final-newline ()
|
||||||
(set (make-local-variable 'require-final-newline) nil))
|
(set (make-local-variable 'require-final-newline) nil))
|
||||||
|
|
||||||
(defun load-init-files ()
|
|
||||||
;; (mapc 'require io-modules)
|
;; Font Defuns ;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
(dolist (module my-modules)
|
(defun cycle-font (&optional i)
|
||||||
(message "%s" (symbol-name module))
|
"Cycle between fonts specified in *fonts in init.el"
|
||||||
(with-demoted-errors "#### ERROR: %s"
|
(interactive)
|
||||||
(require module))))
|
(if (numberp i)
|
||||||
|
(setq my/cycle-font-i i)
|
||||||
|
(if (>= my/cycle-font-i (1- (length *fonts)))
|
||||||
|
(setq my/cycle-font-i 0)
|
||||||
|
(cl-incf my/cycle-font-i)))
|
||||||
|
(set-frame-font (nth my/cycle-font-i *fonts)))
|
||||||
|
|
||||||
|
|
||||||
;;;; Global Defuns ;;;;;;;;;;;;;;;;;;;;;
|
;;;; Global Defuns ;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
@ -138,5 +124,39 @@ to abort the minibuffer."
|
||||||
(delete-windows-on "*Completions*"))
|
(delete-windows-on "*Completions*"))
|
||||||
(abort-recursive-edit)))
|
(abort-recursive-edit)))
|
||||||
|
|
||||||
|
(defun my--line-at-click ()
|
||||||
|
"Determine the line number at click"
|
||||||
|
(save-excursion
|
||||||
|
(let ((click-y (cddr (mouse-position)))
|
||||||
|
(debug-on-error t)
|
||||||
|
(line-move-visual t))
|
||||||
|
(goto-char (window-start))
|
||||||
|
(next-line (1- click-y))
|
||||||
|
(1+ (line-number-at-pos)))))
|
||||||
|
|
||||||
|
(defun my-select-linum (event)
|
||||||
|
"Set point as *linum-mdown-line*"
|
||||||
|
(interactive "e")
|
||||||
|
(mouse-select-window event)
|
||||||
|
(goto-line (my--line-at-click))
|
||||||
|
(evil-visual-line)
|
||||||
|
(setq *linum-mdown-line*
|
||||||
|
(line-number-at-pos)))
|
||||||
|
|
||||||
|
(defun my-select-block ()
|
||||||
|
"Select the current block of text between blank lines."
|
||||||
|
(interactive)
|
||||||
|
(let (p1 p2)
|
||||||
|
(progn
|
||||||
|
(if (re-search-backward "\n[ \t]*\n" nil "move")
|
||||||
|
(progn (re-search-forward "\n[ \t]*\n")
|
||||||
|
(setq p1 (point)))
|
||||||
|
(setq p1 (point)))
|
||||||
|
(if (re-search-forward "\n[ \t]*\n" nil "move")
|
||||||
|
(progn (re-search-backward "\n[ \t]*\n")
|
||||||
|
(setq p2 (point)))
|
||||||
|
(setq p2 (point))))
|
||||||
|
(set-mark p1)))
|
||||||
|
|
||||||
|
|
||||||
(provide 'defuns)
|
(provide 'defuns)
|
||||||
|
|
|
@ -159,8 +159,6 @@
|
||||||
;; Tools/defuns ;;;;;;;;;;;;;;;;;;;;;;;;
|
;; Tools/defuns ;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(push '("*compilation*" :height 0.5 :position bottom :noselect t) popwin:special-display-config)
|
(push '("*compilation*" :height 0.5 :position bottom :noselect t) popwin:special-display-config)
|
||||||
|
|
||||||
(add-hook! 'c++-mode-hook (setq my-make-command "make %s"))
|
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,21 +35,23 @@
|
||||||
;; Code building
|
;; Code building
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(defvar my-build-command "make %s")
|
(defvar my-build-command '("make %s" . "Makefile"))
|
||||||
(make-variable-buffer-local 'my-build-command)
|
(make-variable-buffer-local 'my-build-command)
|
||||||
(add-hook! 'enh-ruby-mode-hook (setq my-build-command "rake %s"))
|
|
||||||
|
(defun set-build-command (command &optional file)
|
||||||
|
(setq my-build-command (command . file)))
|
||||||
|
|
||||||
(evil-define-command my:build (arg)
|
(evil-define-command my:build (arg)
|
||||||
"Call a build command in the current directory.
|
"Call a build command in the current directory.
|
||||||
If ARG is nil this function calls `recompile', otherwise it calls
|
If ARG is nil this function calls `recompile', otherwise it calls
|
||||||
`compile' passing ARG as build command."
|
`compile' passing ARG as build command."
|
||||||
(interactive "<sh>")
|
(interactive "<sh>")
|
||||||
(let ((makepath (f-traverse-upwards
|
(when (null my-build-command)
|
||||||
(lambda (path)
|
(user-error "No build command was set"))
|
||||||
(f-exists? (f-expand "Makefile" path)))
|
(let ((build-file (cdr my-build-command))
|
||||||
default-directory)))
|
(build-cmd (car my-build-command)))
|
||||||
(if makepath
|
(if (project-has-files build-file)
|
||||||
(compile (format "cd '%s' && %s" makepath (format my-build-command (or arg ""))))
|
(compile (format "cd '%s' && %s" build-file (format build-cmd (or arg ""))))
|
||||||
(error "Could not find Makefile"))))
|
(error "Could not find Makefile"))))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,16 +6,15 @@
|
||||||
flycheck-disabled-checkers '(emacs-lisp-checkdoc make))
|
flycheck-disabled-checkers '(emacs-lisp-checkdoc make))
|
||||||
:config
|
:config
|
||||||
(progn ; flycheck settings
|
(progn ; flycheck settings
|
||||||
(dolist (hook '(ruby-mode-hook
|
(add-hooks '(ruby-mode-hook
|
||||||
python-mode-hook
|
python-mode-hook
|
||||||
php-mode-hook
|
php-mode-hook
|
||||||
lua-mode-hook
|
lua-mode-hook
|
||||||
shell-mode-hook
|
shell-mode-hook
|
||||||
scss-mode-hook
|
scss-mode-hook
|
||||||
c++-mode-hook
|
c++-mode-hook
|
||||||
c-mode-hook
|
c-mode-hook)
|
||||||
))
|
'flycheck-mode)
|
||||||
(add-hook hook 'flycheck-mode))
|
|
||||||
|
|
||||||
(my--cleanup-buffers-add "^\\*Flycheck.*\\*$")
|
(my--cleanup-buffers-add "^\\*Flycheck.*\\*$")
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,14 @@
|
||||||
|
|
||||||
(my--cleanup-buffers-add "^\\*[Hh]elm.*\\*$")
|
(my--cleanup-buffers-add "^\\*[Hh]elm.*\\*$")
|
||||||
|
|
||||||
|
;; disable popwin-mode in an active Helm session It should be disabled
|
||||||
|
;; otherwise it will conflict with other window opened by Helm persistent
|
||||||
|
;; action, such as *Help* window.
|
||||||
|
(add-hook! 'helm-after-initialize-hook (popwin-mode -1))
|
||||||
|
|
||||||
|
;; Restore popwin-mode after a Helm session finishes.
|
||||||
|
(add-hook! 'helm-cleanup-hook (popwin-mode 1))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(use-package helm-ag
|
(use-package helm-ag
|
||||||
|
@ -23,7 +31,7 @@
|
||||||
:type inclusive
|
:type inclusive
|
||||||
:repeat nil
|
:repeat nil
|
||||||
(interactive "<r><a><!>")
|
(interactive "<r><a><!>")
|
||||||
(let* ((helm-ag-default-directory (my--project-root pwd-p))
|
(let* ((helm-ag-default-directory (if pwd-p default-directory (project-root)))
|
||||||
(helm-ag-command-option (concat (unless regex-p "-Q ")
|
(helm-ag-command-option (concat (unless regex-p "-Q ")
|
||||||
(if hidden-files-p "--hidden ")))
|
(if hidden-files-p "--hidden ")))
|
||||||
(input "")
|
(input "")
|
||||||
|
@ -32,7 +40,6 @@
|
||||||
(progn
|
(progn
|
||||||
(helm-attrset 'search-this-file nil helm-ag-source)
|
(helm-attrset 'search-this-file nil helm-ag-source)
|
||||||
(setq helm-ag--last-query search))
|
(setq helm-ag--last-query search))
|
||||||
(helm-ag-save-current-context)
|
|
||||||
(if (and beg end (/= beg (1- end)))
|
(if (and beg end (/= beg (1- end)))
|
||||||
(setq input (buffer-substring-no-properties beg end))))
|
(setq input (buffer-substring-no-properties beg end))))
|
||||||
(helm-attrset 'name header-name helm-ag-source)
|
(helm-attrset 'name header-name helm-ag-source)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
(defun my-java-project-package ()
|
(defun my-java-project-package ()
|
||||||
(if (eq major-mode 'java-mode)
|
(if (eq major-mode 'java-mode)
|
||||||
(s-chop-suffix "." (s-replace "/" "." (f-dirname (f-relative (buffer-file-name)
|
(s-chop-suffix "." (s-replace "/" "." (f-dirname (f-relative (buffer-file-name)
|
||||||
(concat (my--project-root) "src/")))))
|
(concat (project-root) "src/")))))
|
||||||
""))
|
""))
|
||||||
|
|
||||||
(defun my-java-class-name ()
|
(defun my-java-class-name ()
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
:defer t
|
:defer t
|
||||||
:init
|
:init
|
||||||
(add-hook! 'java-mode-hook
|
(add-hook! 'java-mode-hook
|
||||||
(when (f-exists? (concat (my--project-root) "AndroidManifest.xml"))
|
(when (project-has-files "AndroidManifest.xml")
|
||||||
(android-mode +1))))
|
(android-mode +1))))
|
||||||
|
|
||||||
(use-package groovy-mode :mode "\\.gradle$")
|
(use-package groovy-mode :mode "\\.gradle$")
|
||||||
|
|
|
@ -57,6 +57,11 @@
|
||||||
(enable-tab-width-2)
|
(enable-tab-width-2)
|
||||||
(setq js-indent-level 2))))
|
(setq js-indent-level 2))))
|
||||||
|
|
||||||
|
(define-minor-mode lb6-mode
|
||||||
|
:lighter " lb6"
|
||||||
|
:keymap (make-sparse-keymap)
|
||||||
|
(my--init-yas-mode 'lb6-mode))
|
||||||
|
(associate-minor-mode "/Contents/\\(Scripts\\|Resources\\)/.*$" 'lb6-mode)
|
||||||
|
|
||||||
(provide 'init-js)
|
(provide 'init-js)
|
||||||
;;; init-js.el ends here
|
;;; init-js.el ends here
|
||||||
|
|
|
@ -7,13 +7,15 @@
|
||||||
"Buffer local minor mode for Love2D"
|
"Buffer local minor mode for Love2D"
|
||||||
:init-value nil
|
:init-value nil
|
||||||
:lighter " <3"
|
:lighter " <3"
|
||||||
:keymap (make-sparse-keymap))
|
:keymap (make-sparse-keymap)
|
||||||
(associate-minor-mode "[\\.-]love/.+\\.lua$" 'love-mode)
|
(my--init-yas-mode 'love-mode))
|
||||||
|
(add-hook! 'lua-mode-hook
|
||||||
|
(setq lua-indent-level tab-width)
|
||||||
|
(set-build-command "open -a love.app '%s'" "main.lua")
|
||||||
|
(when (project-has-files "main.lua")
|
||||||
|
(love-mode +1)))
|
||||||
|
|
||||||
(add-hook 'lua-mode-hook 'enable-tab-width-2)
|
(add-hook 'lua-mode-hook 'enable-tab-width-2)))
|
||||||
(add-hook! 'lua-mode-hook (setq lua-indent-level tab-width))
|
|
||||||
|
|
||||||
(add-hook! 'love-mode-hook (setq my-build-command (format "open -a love.app %s" (my--project-root))))))
|
|
||||||
|
|
||||||
|
|
||||||
(provide 'init-lua)
|
(provide 'init-lua)
|
||||||
|
|
|
@ -1,26 +1,18 @@
|
||||||
(use-package projectile
|
(use-package projectile
|
||||||
:init
|
:init (setq-default projectile-enable-caching t)
|
||||||
(setq-default projectile-cache-file (concat my-tmp-dir "projectile.cache")
|
|
||||||
projectile-known-projects-file (concat my-tmp-dir "projectile.projects")
|
|
||||||
projectile-enable-caching t
|
|
||||||
projectile-indexing-method 'alien)
|
|
||||||
:config
|
:config
|
||||||
(progn
|
(progn
|
||||||
(projectile-global-mode +1)
|
(projectile-global-mode +1)
|
||||||
|
|
||||||
|
(setq projectile-sort-order 'recentf
|
||||||
|
projectile-cache-file (concat my-tmp-dir "projectile.cache")
|
||||||
|
projectile-known-projects-file (concat my-tmp-dir "projectile.projects")
|
||||||
|
projectile-indexing-method 'alien)
|
||||||
|
|
||||||
(add-to-list 'projectile-globally-ignored-files "ido.last")
|
(add-to-list 'projectile-globally-ignored-files "ido.last")
|
||||||
(add-to-list 'projectile-globally-ignored-directories "assets")
|
(add-to-list 'projectile-globally-ignored-directories "assets")
|
||||||
(add-to-list 'projectile-other-file-alist '("scss" "css"))
|
(add-to-list 'projectile-other-file-alist '("scss" "css"))
|
||||||
(add-to-list 'projectile-other-file-alist '("css" "scss"))
|
(add-to-list 'projectile-other-file-alist '("css" "scss"))))
|
||||||
|
|
||||||
;; For setting project-specific settings
|
|
||||||
(defmacro my-project-settings (project-name &rest body)
|
|
||||||
(declare (indent 1))
|
|
||||||
`(progn
|
|
||||||
(add-hook 'find-file-hook
|
|
||||||
(lambda ()
|
|
||||||
(when (string-match-p ,project-name (projectile-project-name))
|
|
||||||
,@body)))))))
|
|
||||||
|
|
||||||
|
|
||||||
(provide 'init-projectile)
|
(provide 'init-projectile)
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
(setq enh-ruby-check-syntax nil)
|
(setq enh-ruby-check-syntax nil)
|
||||||
|
|
||||||
(add-hook 'enh-ruby-mode-hook 'enable-tab-width-2)
|
(add-hook 'enh-ruby-mode-hook 'enable-tab-width-2)
|
||||||
|
(add-hook! 'enh-ruby-mode-hook (set-build-command "rake %s" "Rakefile"))
|
||||||
|
|
||||||
(define-key enh-ruby-mode-map [?\n] nil)
|
(define-key enh-ruby-mode-map [?\n] nil)
|
||||||
|
|
||||||
|
@ -54,7 +55,8 @@
|
||||||
|
|
||||||
(define-minor-mode rake-mode
|
(define-minor-mode rake-mode
|
||||||
"Buffer local minor mode for rake files"
|
"Buffer local minor mode for rake files"
|
||||||
:lighter " Rake")
|
:lighter " Rake"
|
||||||
|
(my--init-yas-mode 'rake-mode))
|
||||||
|
|
||||||
(use-package inf-ruby
|
(use-package inf-ruby
|
||||||
:commands (inf-ruby inf-ruby-console-auto)
|
:commands (inf-ruby inf-ruby-console-auto)
|
||||||
|
|
|
@ -18,14 +18,14 @@
|
||||||
(message "[Tmux] %s" command)))
|
(message "[Tmux] %s" command)))
|
||||||
|
|
||||||
(evil-define-command my:tmux-chdir (&optional path bang)
|
(evil-define-command my:tmux-chdir (&optional path bang)
|
||||||
"CDs in tmux using `my--project-root'"
|
"CDs in tmux using `project-root'"
|
||||||
(interactive "<f><!>")
|
(interactive "<f><!>")
|
||||||
(let ((dir (shell-quote-argument
|
(let ((dir (shell-quote-argument
|
||||||
(if (and path (not (s-blank? path)))
|
(if (and path (not (s-blank? path)))
|
||||||
(if (file-directory-p path)
|
(if (file-directory-p path)
|
||||||
(file-truename path)
|
(file-truename path)
|
||||||
(error "Directory doesn't exist %s" path))
|
(error "Directory doesn't exist %s" path))
|
||||||
(my--project-root bang)))))
|
(if bang default-directory (project-root))))))
|
||||||
(my--tmux-send (format "C-u cd Space %s Enter" (shell-quote-argument dir)))
|
(my--tmux-send (format "C-u cd Space %s Enter" (shell-quote-argument dir)))
|
||||||
(when (evil-ex-p)
|
(when (evil-ex-p)
|
||||||
(message "[Tmux] cd %s" dir)))))
|
(message "[Tmux] cd %s" dir)))))
|
||||||
|
|
|
@ -65,6 +65,17 @@
|
||||||
(kbd "M-e") 'emmet-expand-yas
|
(kbd "M-e") 'emmet-expand-yas
|
||||||
(kbd "M-E") 'emmet-expand-line)))
|
(kbd "M-E") 'emmet-expand-line)))
|
||||||
|
|
||||||
|
(define-minor-mode jekyll-mode
|
||||||
|
:init-value nil
|
||||||
|
:lighter " :{"
|
||||||
|
:keymap (make-sparse-keymap)
|
||||||
|
(my--init-yas-mode 'jekyll-mode))
|
||||||
|
(associate-minor-mode "/_\\(layouts\\|posts\\)/.+$" 'jekyll-mode)
|
||||||
|
(add-hooks '(web-mode-hook scss-mode-hook html-mode-hook markdown-mode markdown-mode-hook)
|
||||||
|
(lambda ()
|
||||||
|
(when (project-has-files "_config.yml" "_layouts")
|
||||||
|
(jekyll-mode 1))))
|
||||||
|
|
||||||
|
|
||||||
(provide 'init-web)
|
(provide 'init-web)
|
||||||
;;; init-web.el ends here
|
;;; init-web.el ends here
|
||||||
|
|
|
@ -52,10 +52,9 @@
|
||||||
;; create a new workgroup for the new project.
|
;; create a new workgroup for the new project.
|
||||||
(after "projectile"
|
(after "projectile"
|
||||||
(defun my-projectile-workgroup-switch-project ()
|
(defun my-projectile-workgroup-switch-project ()
|
||||||
(let ((workgroup-name (file-name-nondirectory (directory-file-name (my--project-root)))))
|
(let ((workgroup-name (file-name-nondirectory (directory-file-name (project-root)))))
|
||||||
(wg-create-workgroup workgroup-name t)
|
(wg-create-workgroup workgroup-name t)
|
||||||
(helm-projectile-find-file)))
|
(helm-projectile-find-file)))
|
||||||
|
|
||||||
(setq projectile-switch-project-action 'my-projectile-workgroup-switch-project))
|
(setq projectile-switch-project-action 'my-projectile-workgroup-switch-project))
|
||||||
|
|
||||||
(workgroups-mode 1)))
|
(workgroups-mode 1)))
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
(add-hook 'snippet-mode-hook 'yas-minor-mode)
|
(add-hook 'snippet-mode-hook 'yas-minor-mode)
|
||||||
(add-hook 'text-mode-hook 'yas-minor-mode)
|
(add-hook 'text-mode-hook 'yas-minor-mode)
|
||||||
(add-hook 'prog-mode-hook 'yas-minor-mode)
|
(add-hook 'prog-mode-hook 'yas-minor-mode)
|
||||||
(add-hook 'emacs-lisp-mode-hook 'yas-minor-mode)
|
|
||||||
;; (add-hook 'markdown-mode-hook 'yas-minor-mode)
|
;; (add-hook 'markdown-mode-hook 'yas-minor-mode)
|
||||||
(add-hook 'org-mode-hook 'yas-minor-mode))
|
(add-hook 'org-mode-hook 'yas-minor-mode))
|
||||||
:config
|
:config
|
||||||
|
@ -145,13 +144,21 @@
|
||||||
(when (and field (> (point) sof))
|
(when (and field (> (point) sof))
|
||||||
(delete-region sof (point)))))
|
(delete-region sof (point)))))
|
||||||
|
|
||||||
|
(defun my--init-yas-mode (&rest modes)
|
||||||
|
;; Yasnippet 0.8.1+
|
||||||
|
(when (boundp 'yas-extra-modes)
|
||||||
|
(if (symbol-value mode)
|
||||||
|
(dolist (mode modes)
|
||||||
|
(yas-activate-extra-mode mode))
|
||||||
|
(setq yas-extra-modes (delq mode yas-extra-modes)))))
|
||||||
|
|
||||||
;; keybinds
|
;; keybinds
|
||||||
(bind yas-keymap
|
(bind yas-keymap
|
||||||
"C-e" 'my/yas-goto-end-of-field
|
"C-e" 'my/yas-goto-end-of-field
|
||||||
"C-a" 'my/yas-goto-start-of-field
|
"C-a" 'my/yas-goto-start-of-field
|
||||||
"<M-right>" 'my/yas-goto-end-of-field
|
"<M-right>" 'my/yas-goto-end-of-field
|
||||||
"<M-left>" 'my/yas-goto-start-of-field
|
"<M-left>" 'my/yas-goto-start-of-field
|
||||||
"<S-tab>" 'yas-prev-field
|
"<S-tab>" 'yas-prev-field
|
||||||
"<M-backspace>" 'my/yas-clear-to-sof
|
"<M-backspace>" 'my/yas-clear-to-sof
|
||||||
|
|
||||||
[backspace] 'my/yas-backspace
|
[backspace] 'my/yas-backspace
|
||||||
|
|
|
@ -44,41 +44,45 @@
|
||||||
"M" 'helm-projectile-recentf ; recent PROJECT files
|
"M" 'helm-projectile-recentf ; recent PROJECT files
|
||||||
"]" 'helm-etags-select
|
"]" 'helm-etags-select
|
||||||
"a" 'helm-projectile-find-other-file
|
"a" 'helm-projectile-find-other-file
|
||||||
|
"b" 'my:build
|
||||||
"e" 'ido-find-file
|
"e" 'ido-find-file
|
||||||
"g" 'git-gutter+-show-hunk
|
"g" 'git-gutter+-show-hunk
|
||||||
"h" 'helm-apropos
|
"h" 'helm-apropos
|
||||||
"m" 'helm-recentf
|
"m" 'helm-recentf
|
||||||
"p" 'helm-projectile-switch-project
|
"p" 'helm-projectile-switch-project
|
||||||
"y" 'helm-show-kill-ring
|
"qq" 'evil-save-and-quit
|
||||||
"r" 'emr-show-refactor-menu) ; init-dev.el
|
"QQ" 'evil-quit-all
|
||||||
|
"r" 'emr-show-refactor-menu ; init-dev.el
|
||||||
|
"y" 'helm-show-kill-ring)
|
||||||
|
|
||||||
;; <localleader>
|
;; <localleader>
|
||||||
(bind my-localleader-map
|
(bind my-localleader-map
|
||||||
"\\" 'neotree-toggle
|
"\\" 'neotree-toggle
|
||||||
";" 'linum-mode
|
";" 'linum-mode
|
||||||
"=" 'toggle-transparency
|
"=" 'toggle-transparency
|
||||||
"E" 'evil-emacs-state
|
"E" 'evil-emacs-state
|
||||||
|
|
||||||
"of" (λ (my-send-dir-to-finder default-directory))
|
"oo" 'my-open-with
|
||||||
"oF" 'my-send-dir-to-finder
|
"of" (λ (my-open-with "Finder" default-directory))
|
||||||
"ou" (λ (my-send-to-transmit buffer-file-name))
|
"oF" (λ (my-open-with "Finder" (project-root)))
|
||||||
"oU" 'my-send-to-transmit
|
"ou" (λ (my-open-with "Transmit"))
|
||||||
"ol" (λ (my-send-to-launchbar buffer-file-name))
|
"oU" (λ (my-open-with "Transmit" default-directory))
|
||||||
"oL" 'my-send-to-launchbar
|
"ol" (λ (my-open-with "LaunchBar"))
|
||||||
|
"oL" (λ (my-open-with "LaunchBar" default-directory))
|
||||||
|
|
||||||
;; tmux: cd (default-directory)
|
;; tmux: cd (default-directory)
|
||||||
"ot" (λ (my:tmux-chdir nil t))
|
"ot" (λ (my:tmux-chdir nil t))
|
||||||
;; tmux: cd [project root]
|
;; tmux: cd [project root]
|
||||||
"oT" 'my:tmux-chdir
|
"oT" 'my:tmux-chdir
|
||||||
|
|
||||||
"]" 'next-buffer
|
"]" 'next-buffer
|
||||||
"[" 'previous-buffer
|
"[" 'previous-buffer
|
||||||
|
|
||||||
"g" 'git-gutter+-show-hunk
|
"g" 'git-gutter+-show-hunk
|
||||||
"e" (λ (flycheck-buffer) (flycheck-list-errors))
|
"e" (λ (flycheck-buffer) (flycheck-list-errors))
|
||||||
"p" 'helm-show-kill-ring
|
"p" 'helm-show-kill-ring
|
||||||
"b" 'helm-projectile-switch-to-buffer
|
"b" 'helm-projectile-switch-to-buffer
|
||||||
"w" 'helm-wg)
|
"w" 'helm-wg)
|
||||||
|
|
||||||
|
|
||||||
(bind 'normal
|
(bind 'normal
|
||||||
|
@ -87,10 +91,10 @@
|
||||||
|
|
||||||
;; behave like D and C; yank to end of line
|
;; behave like D and C; yank to end of line
|
||||||
"Y" (λ (evil-yank (point) (point-at-eol)))
|
"Y" (λ (evil-yank (point) (point-at-eol)))
|
||||||
"zx" 'kill-this-buffer
|
"zx" 'my-kill-real-buffer
|
||||||
"ZX" 'bury-buffer
|
"ZX" 'bury-buffer
|
||||||
"]b" 'next-buffer
|
"]b" 'my-next-real-buffer
|
||||||
"[b" 'previous-buffer
|
"[b" 'my-previous-real-buffer
|
||||||
"]w" 'wg-switch-to-workgroup-right
|
"]w" 'wg-switch-to-workgroup-right
|
||||||
"[w" 'wg-switch-to-workgroup-left
|
"[w" 'wg-switch-to-workgroup-left
|
||||||
|
|
||||||
|
@ -117,8 +121,8 @@
|
||||||
"]g" 'git-gutter+-next-hunk
|
"]g" 'git-gutter+-next-hunk
|
||||||
"[g" 'git-gutter+-previous-hunk
|
"[g" 'git-gutter+-previous-hunk
|
||||||
|
|
||||||
"]e" 'next-error
|
"]e" (λ (call-interactively (if flycheck-mode 'flycheck-next-error 'next-error)))
|
||||||
"[e" 'previous-error
|
"[e" (λ (call-interactively (if flycheck-mode 'flycheck-previous-error 'previous-error)))
|
||||||
|
|
||||||
"]\\" 'er/expand-region
|
"]\\" 'er/expand-region
|
||||||
"[\\" 'er/contract-region
|
"[\\" 'er/contract-region
|
||||||
|
@ -169,6 +173,38 @@
|
||||||
"]]" 'help-go-forward
|
"]]" 'help-go-forward
|
||||||
"[[" 'help-go-back))
|
"[[" 'help-go-back))
|
||||||
|
|
||||||
|
(bind '(insert normal)
|
||||||
|
;; Textmate-esque insert-line before/after
|
||||||
|
(kbd "<M-return>") 'evil-open-below
|
||||||
|
(kbd "<S-M-return>") 'evil-open-above)
|
||||||
|
|
||||||
|
(when is-mac
|
||||||
|
;; Restore text nav keys
|
||||||
|
(bind (kbd "<A-left>") 'backward-word
|
||||||
|
(kbd "<A-right>") 'forward-word
|
||||||
|
(kbd "<M-backspace>") 'my.backward-kill-to-bol-and-indent
|
||||||
|
(kbd "M-a") 'mark-whole-buffer
|
||||||
|
(kbd "M-c") 'evil-yank
|
||||||
|
(kbd "M-v") 'evil-paste-after
|
||||||
|
(kbd "M-s") 'save-buffer))
|
||||||
|
|
||||||
|
;; Fix osx keymappings and then some
|
||||||
|
(use-package smart-forward
|
||||||
|
:config
|
||||||
|
(bind 'insert
|
||||||
|
"<M-left>" 'my.move-to-bol
|
||||||
|
"<M-right>" 'my.move-to-eol
|
||||||
|
"<M-up>" 'beginning-of-buffer
|
||||||
|
"<M-down>" 'end-of-buffer
|
||||||
|
"<A-up>" 'smart-up
|
||||||
|
"<A-down>" 'smart-down))
|
||||||
|
|
||||||
|
;; Line selection via linum
|
||||||
|
(bind "<left-margin> <down-mouse-1>" 'my-select-linum
|
||||||
|
"<left-margin> <mouse-1>" 'my-select-linum
|
||||||
|
"<left-margin> <drag-mouse-1>" 'my-select-linum
|
||||||
|
"<left-margin> <double-mouse-1>" 'my-select-block)
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Keymap fixes ;;
|
;; Keymap fixes ;;
|
||||||
|
@ -205,32 +241,18 @@
|
||||||
;; Fixes delete
|
;; Fixes delete
|
||||||
(kbd "<kp-delete>") 'delete-char)
|
(kbd "<kp-delete>") 'delete-char)
|
||||||
|
|
||||||
(bind '(insert normal)
|
;; Make ESC quit all the things
|
||||||
;; Textmate-esque insert-line before/after
|
(dolist (map (list minibuffer-local-map
|
||||||
(kbd "<M-return>") 'evil-open-below
|
minibuffer-local-ns-map
|
||||||
(kbd "<S-M-return>") 'evil-open-above)
|
minibuffer-local-completion-map
|
||||||
|
minibuffer-local-must-match-map
|
||||||
|
minibuffer-local-isearch-map))
|
||||||
|
(bind map "<escape>" 'keyboard-escape-quit))
|
||||||
|
|
||||||
(when is-mac
|
(dolist (map (list evil-ex-search-keymap minibuffer-local-map))
|
||||||
;; Restore text nav keys
|
(bind map "\C-w" 'evil-delete-backward-word))
|
||||||
(bind (kbd "<A-left>") 'backward-word
|
|
||||||
(kbd "<A-right>") 'forward-word
|
|
||||||
(kbd "<M-backspace>") 'my.backward-kill-to-bol-and-indent
|
|
||||||
(kbd "M-a") 'mark-whole-buffer
|
|
||||||
(kbd "M-c") 'evil-yank
|
|
||||||
(kbd "M-v") 'evil-paste-after
|
|
||||||
(kbd "M-s") 'save-buffer))
|
|
||||||
|
|
||||||
;; Fix osx keymappings and then some
|
|
||||||
(use-package smart-forward
|
|
||||||
:config
|
|
||||||
(bind 'insert
|
|
||||||
"<M-left>" 'my.move-to-bol
|
|
||||||
"<M-right>" 'my.move-to-eol
|
|
||||||
"<M-up>" 'beginning-of-buffer
|
|
||||||
"<M-down>" 'end-of-buffer
|
|
||||||
"<A-up>" 'smart-up
|
|
||||||
"<A-down>" 'smart-down))
|
|
||||||
|
|
||||||
|
(global-unset-key (kbd "<drag-mouse-1>"))
|
||||||
|
|
||||||
(provide 'my-bindings)
|
(provide 'my-bindings)
|
||||||
;;; my-bindings.el ends here
|
;;; my-bindings.el ends here
|
||||||
|
|
|
@ -1,21 +1,24 @@
|
||||||
(defalias 'exmap 'evil-ex-define-cmd)
|
(defalias 'exmap 'evil-ex-define-cmd)
|
||||||
|
|
||||||
(exmap "full[scr]" 'toggle-frame-fullscreen)
|
(exmap "l[ast]" 'popwin:popup-last-buffer)
|
||||||
|
(exmap "m[sg]" 'popwin:messages)
|
||||||
|
|
||||||
|
(exmap "full[scr]" 'toggle-fullscreen)
|
||||||
(exmap "ini" 'my:init-files)
|
(exmap "ini" 'my:init-files)
|
||||||
(exmap "n[otes]" 'my:notes)
|
(exmap "n[otes]" 'my:notes)
|
||||||
(exmap "recompile" 'my:byte-compile)
|
(exmap "recompile" 'my:byte-compile)
|
||||||
(exmap "cd" 'my:cd)
|
(exmap "cd" 'my:cd)
|
||||||
(exmap "en[ew]" 'my:create-file)
|
(exmap "en[ew]" 'my:create-file)
|
||||||
(exmap "ren[ame]" 'my:rename-this-file) ; Rename file . Bang: Delete old one
|
(exmap "ren[ame]" 'my:rename-this-file) ; rename [NEWNAME] # rename file
|
||||||
(exmap "al[ign]" 'my:align)
|
(exmap "al[ign]" 'my:align)
|
||||||
(exmap "retab" 'my:retab)
|
(exmap "retab" 'my:retab)
|
||||||
(exmap "sq[uint]" 'my:narrow-indirect) ; Narrow buffer to selection
|
(exmap "sq[uint]" 'my:narrow-indirect) ; Narrow buffer to selection
|
||||||
(exmap "x" 'my:scratch-buffer)
|
(exmap "x" 'my:scratch-buffer)
|
||||||
|
|
||||||
(exmap "k[ill]" 'kill-this-buffer) ; Kill current buffer
|
(exmap "k[ill]" 'kill-this-buffer) ; Kill current buffer
|
||||||
(exmap "k[ill]o" 'my-cleanup-buffers) ; Kill current project buffers
|
(exmap "k[ill]o" 'my-cleanup-buffers) ; Kill current project buffers
|
||||||
(exmap "k[ill]all" 'my:kill-buffers) ; Kill all buffers (bang = project buffers only)
|
(exmap "k[ill]all" 'my:kill-buffers) ; Kill all buffers (bang = project buffers only)
|
||||||
(exmap "k[ill]buried" 'my:kill-buried-buffers) ; Kill all buffers (bang = project buffers only)
|
(exmap "k[ill]buried" 'my:kill-buried-buffers) ; Kill all buffers (bang = project buffers only)
|
||||||
|
|
||||||
(exmap "ma[ke]" 'my:build)
|
(exmap "ma[ke]" 'my:build)
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,4 @@
|
||||||
|
|
||||||
(defmacro -defreplace (name search replace)
|
|
||||||
`(evil-define-operator ,(make-symbol (concat "replace:" (symbol-name name))) (beg end)
|
|
||||||
:type inclusive
|
|
||||||
:repeat nil
|
|
||||||
(interactive "<r>")
|
|
||||||
(replace-regexp ,search ,replace t beg end)))
|
|
||||||
|
|
||||||
;;;; HTML ;;;;
|
;;;; HTML ;;;;
|
||||||
;; Replace smart quotes and other MS Word verbiage into plain text
|
;; Replace smart quotes and other MS Word verbiage into plain text
|
||||||
(defun replace:plain-textify (beg end)
|
(defun replace:plain-textify (beg end)
|
||||||
|
|
|
@ -42,14 +42,6 @@
|
||||||
(kbd "<backspace>") 'ido-delete-backward-updir
|
(kbd "<backspace>") 'ido-delete-backward-updir
|
||||||
"\C-w" 'ido-delete-backward-word-updir))
|
"\C-w" 'ido-delete-backward-word-updir))
|
||||||
|
|
||||||
;; Make ESC quit all the things
|
|
||||||
;; (bind minibuffer-inactive-mode-map [escape] (λ (other-window 1)))
|
|
||||||
(dolist (map (list minibuffer-local-map
|
|
||||||
minibuffer-local-ns-map
|
|
||||||
minibuffer-local-completion-map
|
|
||||||
minibuffer-local-must-match-map
|
|
||||||
minibuffer-local-isearch-map))
|
|
||||||
(bind map [escape] 'my--minibuffer-quit))
|
|
||||||
(bind 'emacs [escape] 'my--minibuffer-quit)
|
(bind 'emacs [escape] 'my--minibuffer-quit)
|
||||||
(bind 'normal evil-command-window-mode-map [escape] 'kill-buffer-and-window)
|
(bind 'normal evil-command-window-mode-map [escape] 'kill-buffer-and-window)
|
||||||
;; (bind evil-ex-map [escape] 'my--minibuffer-quit)
|
;; (bind evil-ex-map [escape] 'my--minibuffer-quit)
|
||||||
|
@ -61,27 +53,23 @@
|
||||||
"\C-u" 'evil-delete-whole-line)
|
"\C-u" 'evil-delete-whole-line)
|
||||||
|
|
||||||
;; Redefine to get rid of that silly delete-other-windows nonsense
|
;; Redefine to get rid of that silly delete-other-windows nonsense
|
||||||
(defun keyboard-escape-quit ()
|
;; (defun keyboard-escape-quit ()
|
||||||
(interactive)
|
;; (interactive)
|
||||||
(cond ((eq last-command 'mode-exited) nil)
|
;; (cond ((eq last-command 'mode-exited) nil)
|
||||||
((region-active-p)
|
;; ((region-active-p)
|
||||||
(deactivate-mark))
|
;; (deactivate-mark))
|
||||||
((> (minibuffer-depth) 0)
|
;; ((> (minibuffer-depth) 0)
|
||||||
(abort-recursive-edit))
|
;; (abort-recursive-edit))
|
||||||
(current-prefix-arg
|
;; (current-prefix-arg
|
||||||
nil)
|
;; nil)
|
||||||
((> (recursion-depth) 0)
|
;; ((> (recursion-depth) 0)
|
||||||
(exit-recursive-edit))
|
;; (exit-recursive-edit))
|
||||||
(buffer-quit-function
|
;; (buffer-quit-function
|
||||||
(funcall buffer-quit-function))
|
;; (funcall buffer-quit-function))
|
||||||
((string-match "^ \\*" (buffer-name (current-buffer)))
|
;; ((string-match "^ \\*" (buffer-name (current-buffer)))
|
||||||
(bury-buffer))))
|
;; (bury-buffer))))
|
||||||
|
|
||||||
(defun my-emacs-is-not-kill ()
|
(if is-mac (global-set-key (kbd "M-q") (λ (message "Gee, I dunno Brain..."))))
|
||||||
(interactive)
|
|
||||||
(message "Gee, I dunno Brain..."))
|
|
||||||
|
|
||||||
(if is-mac (global-set-key (kbd "M-q") 'my-emacs-is-not-kill))
|
|
||||||
|
|
||||||
|
|
||||||
(provide 'my-settings)
|
(provide 'my-settings)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue