Yet another big update

This commit is contained in:
Henrik Lissner 2015-05-08 03:03:38 -04:00
parent a8f32547a3
commit c6862d1489
27 changed files with 474 additions and 355 deletions

9
Cask
View file

@ -14,6 +14,7 @@
(depends-on "smex")
(depends-on "floobits")
(depends-on "pos-tip")
(depends-on "vim-empty-lines-mode")
;; OSX
(depends-on "exec-path-from-shell")
@ -35,7 +36,7 @@
(depends-on "smartparens")
(depends-on "yasnippet")
(depends-on "git-gutter-fringe+")
(depends-on "ace-jump-mode")
;; (depends-on "ace-jump-mode")
(depends-on "pcre2el")
(depends-on "emr")
(depends-on "smart-forward")
@ -60,8 +61,10 @@
;;(depends-on "jedi")
;; Eeeevil
(depends-on "god-mode")
;;(depends-on "god-mode")
(depends-on "evil")
(depends-on "evil-search-highlight-persist")
(depends-on "evil-commentary")
(depends-on "evil-matchit")
(depends-on "evil-surround")
(depends-on "evil-numbers")
@ -71,7 +74,7 @@
(depends-on "evil-indent-textobject")
(depends-on "evil-jumper")
(depends-on "evil-god-state")
(depends-on "evil-nerd-commenter")
;;(depends-on "evil-nerd-commenter")
(depends-on "evil-snipe")
;; evil-nerd-commenter chokes if it's installed via cask for some reason...

View file

@ -18,20 +18,21 @@
evil-insert-state-cursor '("white" bar)
evil-visual-state-cursor 'hollow)
(evil-mode)
(evil-mode 1)
;; 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
(defun show-paren-mode-off () (show-paren-mode -1))
(add-hook 'evil-insert-state-entry-hook 'show-paren-mode)
(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-exit-hook 'show-paren-mode-off)
(add-hook 'evil-motion-state-entry-hook 'show-paren-mode)
(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-exit-hook 'show-paren-mode-off)
(add-hook 'evil-insert-state-entry-hook 'show-paren-mode)
(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-exit-hook 'show-paren-mode-off)
(add-hook 'evil-motion-state-entry-hook 'show-paren-mode)
(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-exit-hook 'show-paren-mode-off)
;; Disable highlights on insert-mode
(add-hook 'evil-insert-state-entry-hook 'evil-ex-nohighlight)
@ -45,26 +46,24 @@
(evil-set-initial-state `,(car mode-map) `,(cdr mode-map)))
(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-indent-textobject) ; vii/vai/vaI
(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
:config (global-evil-matchit-mode 1))
(use-package evil-commentary
:config (evil-commentary-mode 1))
(use-package evil-surround
:config (global-evil-surround-mode 1))
(use-package evil-nerd-commenter
:init (setq evilnc-hotkey-comment-operator "gc"))
;; (use-package evil-nerd-commenter
;; :commands (evilnc-comment-operator
;; evilnc-comment-or-uncomment-lines
;; evilnc-toggle-invert-comment-line-by-line
;; 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
:init (setq evil-jumper-file (expand-file-name "jumplist" my-tmp-dir))
@ -74,6 +73,18 @@
evil-jumper-auto-save-interval 3600)
(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
:config
(progn
@ -81,7 +92,7 @@
(setq evil-snipe-smart-case 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-override-evil-repeat-keys nil)
(setq-default evil-snipe-symbol-groups
@ -94,10 +105,7 @@
'visual
"z" 'evil-snipe-s
"Z" 'evil-snipe-S)))
(use-package evil-visualstar
:config (global-evil-visualstar-mode 1)))
"Z" 'evil-snipe-S))))
(bind evil-ex-completion-map
"C-r" #'evil-ex-paste-from-register ; registers in ex-mode
@ -108,7 +116,7 @@
(progn ; evil hacks
(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
(if (minibuffer-window-active-p (minibuffer-window))
(my--minibuffer-quit))))
@ -151,7 +159,7 @@
(setq file-name
;; %:p:h => the project root (or current directory otherwise)
(replace-regexp-in-string "\\(^\\|[^\\\\]\\)\\(%:p\\)"
(my--project-root) file-name t t 2))
(project-root) file-name t t 2))
(setq file-name
;; %:p => the project root (or current directory otherwise)
(replace-regexp-in-string "\\(^\\|[^\\\\]\\)\\(%:d\\)"
@ -241,11 +249,11 @@ provided."
(if bang (--save-exit)))
(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
variables (see `evil-ex-replace-special-filenames')"
:repeat nil
(interactive "<f><!>")
(interactive "<f>")
(let ((name (buffer-name))
(filename (buffer-file-name)))
(if (not (and filename (file-exists-p filename)))
@ -261,8 +269,6 @@ provided."
(set-visited-file-name new-name)
(set-buffer-modified-p nil)
(save-place-forget-unreadable-files)
(when bang
(delete-file filename))
(message "File '%s' successfully renamed to '%s'"
name (file-name-nondirectory new-name)))))))

View file

@ -25,32 +25,12 @@
(unless (featurep 'ns) ad-do-it)))
;; Send current file to OSX apps
(defun my--open-file-with (path &optional appName)
(if (and appName
(stringp appName)
(not (string= "" appName)))
(setq appName (concat "-a " appName ".app")))
(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"))
(defun my-open-with (&optional app-name path)
(interactive)
(let ((app-name (if app-name (concat "-p " app-name)))
(path (or path (if (eq major-mode 'dired-mode) (dired-get-file-for-visit) (buffer-file-name)))))
(shell-command (concat "open " app-name " " (shell-quote-argument path)))))
(provide 'core-osx)
;;; core-osx.el ends here

View file

@ -3,8 +3,7 @@
;;;; Load Theme ;;;;;;;;;;;;;;;;;;;;;;;;
(when window-system
(set-frame-parameter nil 'alpha '(96 86))
;; Load font
(cycle-font 0))
(cycle-font 0)) ; Load font
(add-to-list 'custom-theme-load-path my-themes-dir)
(load-dark-theme)
@ -12,7 +11,7 @@
;;;; GUI Settings ;;;;;;;;;;;;;;;;;;;;;;
(tooltip-mode -1)
(blink-cursor-mode 1) ; blink cursor
(blink-cursor-mode -1) ; blink cursor
(global-hl-line-mode 1) ; highlight line
(setq linum-format " %3d")
@ -25,6 +24,7 @@
(setq-default visible-bell nil) ; silence of the bells
(setq-default use-dialog-box nil) ; avoid GUI
(setq-default redisplay-dont-pause t)
(setq window-combination-resize t)
;; do not soft-wrap lines
(setq-default truncate-lines t)
@ -44,10 +44,14 @@
;;;; Modeline ;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package vim-empty-lines-mode
:config (global-vim-empty-lines-mode +1))
(use-package uniquify
:config (setq uniquify-buffer-name-style 'post-forward
uniquify-separator ":"
uniquify-ignore-buffers-re "^\\*"))
:config
(setq uniquify-buffer-name-style 'post-forward-angle-brackets
uniquify-separator ":"
uniquify-ignore-buffers-re "^\\*"))
(use-package smart-mode-line
:config
@ -67,6 +71,9 @@
" hs"
" ElDoc"
" wg"
" ~"
" s-/"
" yas"
) "\\|"))
:init
(progn

View file

@ -1,7 +1,6 @@
(defconst is-mac (eq system-type 'darwin))
(defconst is-linux (eq system-type 'gnu/linux))
(defconst is-windows (or (eq system-type 'ms-dos)
(eq system-type 'windows-nt)))
(defconst is-windows (eq system-type 'windows-nt))
(when is-linux (add-to-list 'load-path "~/.cask"))
(setq use-package-verbose DEBUG-MODE)
@ -34,8 +33,10 @@
(electric-indent-mode -1) ; In case of emacs >24.4
;;; 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)
(setq winner-boring-buffers '("*Completions*" "*Help*"))
;;; UTF-8 please
(setq locale-coding-system 'utf-8) ; pretty
@ -59,8 +60,8 @@
(setq-default fill-column 80)
;; minibufferception? Nay!
(setq-default enable-recursive-minibuffers nil)
;; minibufferception? Yay!
(setq-default enable-recursive-minibuffers t)
;; Sane scroll settings
(setq scroll-margin 5)
@ -100,6 +101,19 @@
;; Fixes C-i's synonymity with TAB
(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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Disable all backups (that's what git/dropbox are for)
(setq bookmark-save-flag t)
@ -114,30 +128,27 @@
;; Remember undo history
(setq-default undo-tree-auto-save-history t)
(setq-default undo-tree-history-directory-alist `(("." . ,my-tmp-dir-undo)))
;;;; Save history across sessions
(setq savehist-additional-variables '(search ring regexp-search-ring))
(setq savehist-file (concat my-tmp-dir "savehist")) ; keep the home clean
;; Save history across sessions
(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)
;; Save cursor location across sessions
(use-package saveplace
:init
(add-hook 'find-file-hook ; activate save-place for files that exist
(lambda()
(if (file-exists-p buffer-file-name)
(setq save-place t))))
:config
(setq save-place-file (concat my-tmp-dir "saveplace")))
(require 'saveplace)
(setq-default save-place-file (concat my-tmp-dir "saveplace"))
;; activate save-place only for files that exist
(add-hook 'find-file-hook (lambda() (if (file-exists-p buffer-file-name) (setq save-place t))))
(use-package recentf
:config
(progn
(setq recentf-max-menu-items 0)
(setq recentf-max-saved-items 1000)
(setq recentf-auto-cleanup 'never)
(setq recentf-save-file (concat my-tmp-dir "recentf"))
(setq recentf-exclude '("/tmp/" "/ssh:" "\\.?ido\\.last\\'" "\\.revive\\'", "/TAGS\\'"))
(recentf-mode 1)))
(require 'recentf)
(setq recentf-save-file (concat my-tmp-dir "recentf"))
(setq recentf-exclude '("/tmp/" "/ssh:" "\\.?ido\\.last\\'" "\\.revive\\'", "/TAGS\\'"))
(setq recentf-max-menu-items 0)
(setq recentf-max-saved-items 1000)
(setq recentf-auto-cleanup 'never)
(recentf-mode 1)
;; What we do every night, Pinkie...
(defun display-startup-echo-area-message ()
@ -154,41 +165,75 @@
(setq delete-trailing-lines nil)
(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"
(defun set-project-scratch-buffer ()
(let ((buffer (get-buffer "*scratch*"))
(pwd (my--project-root)))
(when (buffer-live-p buffer)
(save-window-excursion
(switch-to-buffer buffer)
(unless (eq (my--project-root) pwd)
(cd pwd)
(rename-buffer (format "*scratch* (%s)" (file-name-nondirectory (directory-file-name pwd)))))))))
(add-hook 'find-file-hook 'set-project-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))
(defun project-create-scratch-buffer ()
(let* ((scratch-buffer (get-buffer-create "*scratch*"))
(project-name (project-name))
(root (project-root)))
(save-window-excursion
(switch-to-buffer scratch-buffer)
(erase-buffer)
(cd root)
(insert ";; Project: " project-name "\n\n"))))
(add-hook 'find-file-hook 'project-create-scratch-buffer)
;;;; Utility plugins ;;;;;;;;;;;;;;;;;;
@ -220,26 +265,20 @@
(push '("^\\*scratch\\*.*" :regexp t :stick t) 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 ()
(interactive)
(if (popwin:popup-window-live-p)
(popwin:close-popup-window)
(popwin:popup-last-buffer)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Start the party ;;;;;;;;;;;;;;;;;;;
(if is-mac (require 'core-osx))
;; (if is-linux (require 'core-linux))
;; (if is-windows (require 'core-windows))
(cond (is-mac (require 'core-osx))
(is-linux (require 'core-linux))
(is-windows (require 'core-windows)))
(use-package server
:config
(unless (server-running-p)
(server-start))))
(require 'server)
(unless (server-running-p) (server-start)))
(provide 'core)

View file

@ -100,3 +100,36 @@ gets killed.")
(if (s-matches? regexp (buffer-name b))
(kill-buffer b)))
(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)))))

View file

@ -57,16 +57,21 @@ whitespace as possible, or just one char if that's not possible."
((or indent-tabs-mode
(= (point-at-bol) (point)))
(call-interactively 'backward-delete-char))
;; Otherwise, delete up to the nearest tab column
(t (let ((movement (% (current-column) tab-width))
(p (point)))
(when (= movement 0)
(setq movement tab-width))
(save-match-data
(if (string-match "\\w*\\(\\s-+\\)$"
(buffer-substring-no-properties (- p movement) p))
(backward-delete-char (- (match-end 1) (match-beginning 1)))
(backward-delete-char-untabify 1)))))))
;; Delete up to the nearest tab column IF only whitespace between point
;; and bol.
((looking-back "^[\\t ]*" (point-at-bol))
(let ((movement (% (current-column) tab-width))
(p (point)))
(when (= movement 0)
(setq movement tab-width))
(save-match-data
(if (string-match "\\w*\\(\\s-+\\)$"
(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
(defun my.dumb-indent ()

View file

@ -30,12 +30,8 @@
(load-dark-theme)))
;;;###autoload
(defun cycle-font (&optional i)
"Cycle between fonts specified in *fonts in init.el"
(defun toggle-fullscreen ()
(interactive)
(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)))
(set-frame-parameter nil 'fullscreen
(when (not (frame-parameter nil 'fullscreen)) 'fullboth)))

View file

@ -1,16 +1,9 @@
;; String Defuns ;;;;;;;;;;;;;;;;;;;;;;;
;;;###autoload
(after "s"
(defun s-count-lines (s)
"Get number of lines in a string"
(length (s-lines s))))
;; File Defuns ;;;;;;;;;;;;;;;;;;;;;;;;;
;;;###autoload
(after "f"
(defmacro f--exists? (file dir)
`(f-exists? (expand-file-name ,file ,dir))))
(defun s-count-lines (s)
"Get number of lines in a string"
(length (s-lines s)))
;; Misc Defuns ;;;;;;;;;;;;;;;;;;;;;;;;;
;;;###autoload
@ -32,3 +25,10 @@
(minor-mode-key-binding key)
(local-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)))

View file

@ -1,41 +1,29 @@
;; Convenience ;;;;;;;;;;;;;;;;;;;;;
(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)))
(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)))
;; 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)
"A shortcut for: `(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)
"A shortcut macro for `add-hook' that auto-wraps `body' in a lambda"
`(add-hook ,hook (lambda() ,@body)))
;; Backwards compatibility
;; Backwards compatible `with-eval-after-load'
(unless (fboundp 'with-eval-after-load)
(defmacro with-eval-after-load (file &rest body)
`(eval-after-load ,file
@ -52,13 +40,6 @@ the checking happens for all pairs in auto-minor-mode-alist"
'with-no-warnings)
(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 ;;;;;;;;;;;;;;;;;;;;;;;;;
(defun bind (&rest keys)
@ -73,9 +54,9 @@ the checking happens for all pairs in auto-minor-mode-alist"
(t
(if (stringp key)
(setq key (kbd key)))
(setq def (pop keys))
(when (null def)
(when (eq (length keys) 0)
(user-error "No definition for '%s' keybinding" key))
(setq def (pop keys))
(if (null state-list)
(if (null keymap)
(global-set-key key def)
@ -118,12 +99,17 @@ key-chord-define."
(defun disable-final-newline ()
(set (make-local-variable 'require-final-newline) nil))
(defun load-init-files ()
;; (mapc 'require io-modules)
(dolist (module my-modules)
(message "%s" (symbol-name module))
(with-demoted-errors "#### ERROR: %s"
(require module))))
;; Font Defuns ;;;;;;;;;;;;;;;;;;;;;;;;;
(defun cycle-font (&optional i)
"Cycle between fonts specified in *fonts in init.el"
(interactive)
(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 ;;;;;;;;;;;;;;;;;;;;;
@ -138,5 +124,39 @@ to abort the minibuffer."
(delete-windows-on "*Completions*"))
(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)

View file

@ -159,8 +159,6 @@
;; Tools/defuns ;;;;;;;;;;;;;;;;;;;;;;;;
(push '("*compilation*" :height 0.5 :position bottom :noselect t) popwin:special-display-config)
(add-hook! 'c++-mode-hook (setq my-make-command "make %s"))
))

View file

@ -35,21 +35,23 @@
;; Code building
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar my-build-command "make %s")
(defvar my-build-command '("make %s" . "Makefile"))
(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)
"Call a build command in the current directory.
If ARG is nil this function calls `recompile', otherwise it calls
`compile' passing ARG as build command."
(interactive "<sh>")
(let ((makepath (f-traverse-upwards
(lambda (path)
(f-exists? (f-expand "Makefile" path)))
default-directory)))
(if makepath
(compile (format "cd '%s' && %s" makepath (format my-build-command (or arg ""))))
(when (null my-build-command)
(user-error "No build command was set"))
(let ((build-file (cdr my-build-command))
(build-cmd (car my-build-command)))
(if (project-has-files build-file)
(compile (format "cd '%s' && %s" build-file (format build-cmd (or arg ""))))
(error "Could not find Makefile"))))

View file

@ -6,16 +6,15 @@
flycheck-disabled-checkers '(emacs-lisp-checkdoc make))
:config
(progn ; flycheck settings
(dolist (hook '(ruby-mode-hook
python-mode-hook
php-mode-hook
lua-mode-hook
shell-mode-hook
scss-mode-hook
c++-mode-hook
c-mode-hook
))
(add-hook hook 'flycheck-mode))
(add-hooks '(ruby-mode-hook
python-mode-hook
php-mode-hook
lua-mode-hook
shell-mode-hook
scss-mode-hook
c++-mode-hook
c-mode-hook)
'flycheck-mode)
(my--cleanup-buffers-add "^\\*Flycheck.*\\*$")

View file

@ -12,6 +12,14 @@
(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
@ -23,7 +31,7 @@
:type inclusive
:repeat nil
(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 ")
(if hidden-files-p "--hidden ")))
(input "")
@ -32,7 +40,6 @@
(progn
(helm-attrset 'search-this-file nil helm-ag-source)
(setq helm-ag--last-query search))
(helm-ag-save-current-context)
(if (and beg end (/= beg (1- end)))
(setq input (buffer-substring-no-properties beg end))))
(helm-attrset 'name header-name helm-ag-source)

View file

@ -1,7 +1,7 @@
(defun my-java-project-package ()
(if (eq major-mode 'java-mode)
(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 ()
@ -37,7 +37,7 @@
:defer t
:init
(add-hook! 'java-mode-hook
(when (f-exists? (concat (my--project-root) "AndroidManifest.xml"))
(when (project-has-files "AndroidManifest.xml")
(android-mode +1))))
(use-package groovy-mode :mode "\\.gradle$")

View file

@ -57,6 +57,11 @@
(enable-tab-width-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)
;;; init-js.el ends here

View file

@ -7,13 +7,15 @@
"Buffer local minor mode for Love2D"
:init-value nil
:lighter " <3"
:keymap (make-sparse-keymap))
(associate-minor-mode "[\\.-]love/.+\\.lua$" 'love-mode)
:keymap (make-sparse-keymap)
(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 (setq lua-indent-level tab-width))
(add-hook! 'love-mode-hook (setq my-build-command (format "open -a love.app %s" (my--project-root))))))
(add-hook 'lua-mode-hook 'enable-tab-width-2)))
(provide 'init-lua)

View file

@ -1,26 +1,18 @@
(use-package projectile
:init
(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)
:init (setq-default projectile-enable-caching t)
:config
(progn
(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-directories "assets")
(add-to-list 'projectile-other-file-alist '("scss" "css"))
(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)))))))
(add-to-list 'projectile-other-file-alist '("css" "scss"))))
(provide 'init-projectile)

View file

@ -23,6 +23,7 @@
(setq enh-ruby-check-syntax nil)
(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)
@ -54,7 +55,8 @@
(define-minor-mode rake-mode
"Buffer local minor mode for rake files"
:lighter " Rake")
:lighter " Rake"
(my--init-yas-mode 'rake-mode))
(use-package inf-ruby
:commands (inf-ruby inf-ruby-console-auto)

View file

@ -18,14 +18,14 @@
(message "[Tmux] %s" command)))
(evil-define-command my:tmux-chdir (&optional path bang)
"CDs in tmux using `my--project-root'"
"CDs in tmux using `project-root'"
(interactive "<f><!>")
(let ((dir (shell-quote-argument
(if (and path (not (s-blank? path)))
(if (file-directory-p path)
(file-truename 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)))
(when (evil-ex-p)
(message "[Tmux] cd %s" dir)))))

View file

@ -65,6 +65,17 @@
(kbd "M-e") 'emmet-expand-yas
(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)
;;; init-web.el ends here

View file

@ -52,10 +52,9 @@
;; create a new workgroup for the new project.
(after "projectile"
(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)
(helm-projectile-find-file)))
(setq projectile-switch-project-action 'my-projectile-workgroup-switch-project))
(workgroups-mode 1)))

View file

@ -14,7 +14,6 @@
(add-hook 'snippet-mode-hook 'yas-minor-mode)
(add-hook 'text-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 'org-mode-hook 'yas-minor-mode))
:config
@ -145,13 +144,21 @@
(when (and field (> (point) sof))
(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
(bind yas-keymap
"C-e" 'my/yas-goto-end-of-field
"C-a" 'my/yas-goto-start-of-field
"<M-right>" 'my/yas-goto-end-of-field
"<M-left>" 'my/yas-goto-start-of-field
"<S-tab>" 'yas-prev-field
"C-e" 'my/yas-goto-end-of-field
"C-a" 'my/yas-goto-start-of-field
"<M-right>" 'my/yas-goto-end-of-field
"<M-left>" 'my/yas-goto-start-of-field
"<S-tab>" 'yas-prev-field
"<M-backspace>" 'my/yas-clear-to-sof
[backspace] 'my/yas-backspace

View file

@ -44,41 +44,45 @@
"M" 'helm-projectile-recentf ; recent PROJECT files
"]" 'helm-etags-select
"a" 'helm-projectile-find-other-file
"b" 'my:build
"e" 'ido-find-file
"g" 'git-gutter+-show-hunk
"h" 'helm-apropos
"m" 'helm-recentf
"p" 'helm-projectile-switch-project
"y" 'helm-show-kill-ring
"r" 'emr-show-refactor-menu) ; init-dev.el
"qq" 'evil-save-and-quit
"QQ" 'evil-quit-all
"r" 'emr-show-refactor-menu ; init-dev.el
"y" 'helm-show-kill-ring)
;; <localleader>
(bind my-localleader-map
"\\" 'neotree-toggle
";" 'linum-mode
"=" 'toggle-transparency
"E" 'evil-emacs-state
"\\" 'neotree-toggle
";" 'linum-mode
"=" 'toggle-transparency
"E" 'evil-emacs-state
"of" (λ (my-send-dir-to-finder default-directory))
"oF" 'my-send-dir-to-finder
"ou" (λ (my-send-to-transmit buffer-file-name))
"oU" 'my-send-to-transmit
"ol" (λ (my-send-to-launchbar buffer-file-name))
"oL" 'my-send-to-launchbar
"oo" 'my-open-with
"of" (λ (my-open-with "Finder" default-directory))
"oF" (λ (my-open-with "Finder" (project-root)))
"ou" (λ (my-open-with "Transmit"))
"oU" (λ (my-open-with "Transmit" default-directory))
"ol" (λ (my-open-with "LaunchBar"))
"oL" (λ (my-open-with "LaunchBar" default-directory))
;; tmux: cd (default-directory)
"ot" (λ (my:tmux-chdir nil t))
;; tmux: cd [project root]
"oT" 'my:tmux-chdir
"]" 'next-buffer
"[" 'previous-buffer
"]" 'next-buffer
"[" 'previous-buffer
"g" 'git-gutter+-show-hunk
"e" (λ (flycheck-buffer) (flycheck-list-errors))
"p" 'helm-show-kill-ring
"b" 'helm-projectile-switch-to-buffer
"w" 'helm-wg)
"g" 'git-gutter+-show-hunk
"e" (λ (flycheck-buffer) (flycheck-list-errors))
"p" 'helm-show-kill-ring
"b" 'helm-projectile-switch-to-buffer
"w" 'helm-wg)
(bind 'normal
@ -87,10 +91,10 @@
;; behave like D and C; yank to end of line
"Y" (λ (evil-yank (point) (point-at-eol)))
"zx" 'kill-this-buffer
"zx" 'my-kill-real-buffer
"ZX" 'bury-buffer
"]b" 'next-buffer
"[b" 'previous-buffer
"]b" 'my-next-real-buffer
"[b" 'my-previous-real-buffer
"]w" 'wg-switch-to-workgroup-right
"[w" 'wg-switch-to-workgroup-left
@ -117,8 +121,8 @@
"]g" 'git-gutter+-next-hunk
"[g" 'git-gutter+-previous-hunk
"]e" 'next-error
"[e" 'previous-error
"]e" (λ (call-interactively (if flycheck-mode 'flycheck-next-error 'next-error)))
"[e" (λ (call-interactively (if flycheck-mode 'flycheck-previous-error 'previous-error)))
"]\\" 'er/expand-region
"[\\" 'er/contract-region
@ -169,6 +173,38 @@
"]]" 'help-go-forward
"[[" '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 ;;
@ -205,32 +241,18 @@
;; Fixes delete
(kbd "<kp-delete>") 'delete-char)
(bind '(insert normal)
;; Textmate-esque insert-line before/after
(kbd "<M-return>") 'evil-open-below
(kbd "<S-M-return>") 'evil-open-above)
;; Make ESC quit all the things
(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>" 'keyboard-escape-quit))
(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))
(dolist (map (list evil-ex-search-keymap minibuffer-local-map))
(bind map "\C-w" 'evil-delete-backward-word))
(global-unset-key (kbd "<drag-mouse-1>"))
(provide 'my-bindings)
;;; my-bindings.el ends here

View file

@ -1,21 +1,24 @@
(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 "n[otes]" 'my:notes)
(exmap "recompile" 'my:byte-compile)
(exmap "cd" 'my:cd)
(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 "retab" 'my:retab)
(exmap "sq[uint]" 'my:narrow-indirect) ; Narrow buffer to selection
(exmap "x" 'my:scratch-buffer)
(exmap "k[ill]" 'kill-this-buffer) ; Kill current buffer
(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]buried" 'my:kill-buried-buffers) ; Kill all buffers (bang = project buffers only)
(exmap "k[ill]" 'kill-this-buffer) ; Kill current buffer
(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]buried" 'my:kill-buried-buffers) ; Kill all buffers (bang = project buffers only)
(exmap "ma[ke]" 'my:build)

View file

@ -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 ;;;;
;; Replace smart quotes and other MS Word verbiage into plain text
(defun replace:plain-textify (beg end)

View file

@ -42,14 +42,6 @@
(kbd "<backspace>") 'ido-delete-backward-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 'normal evil-command-window-mode-map [escape] 'kill-buffer-and-window)
;; (bind evil-ex-map [escape] 'my--minibuffer-quit)
@ -61,27 +53,23 @@
"\C-u" 'evil-delete-whole-line)
;; Redefine to get rid of that silly delete-other-windows nonsense
(defun keyboard-escape-quit ()
(interactive)
(cond ((eq last-command 'mode-exited) nil)
((region-active-p)
(deactivate-mark))
((> (minibuffer-depth) 0)
(abort-recursive-edit))
(current-prefix-arg
nil)
((> (recursion-depth) 0)
(exit-recursive-edit))
(buffer-quit-function
(funcall buffer-quit-function))
((string-match "^ \\*" (buffer-name (current-buffer)))
(bury-buffer))))
;; (defun keyboard-escape-quit ()
;; (interactive)
;; (cond ((eq last-command 'mode-exited) nil)
;; ((region-active-p)
;; (deactivate-mark))
;; ((> (minibuffer-depth) 0)
;; (abort-recursive-edit))
;; (current-prefix-arg
;; nil)
;; ((> (recursion-depth) 0)
;; (exit-recursive-edit))
;; (buffer-quit-function
;; (funcall buffer-quit-function))
;; ((string-match "^ \\*" (buffer-name (current-buffer)))
;; (bury-buffer))))
(defun my-emacs-is-not-kill ()
(interactive)
(message "Gee, I dunno Brain..."))
(if is-mac (global-set-key (kbd "M-q") 'my-emacs-is-not-kill))
(if is-mac (global-set-key (kbd "M-q") (λ (message "Gee, I dunno Brain..."))))
(provide 'my-settings)