Help! I'm trapped in emacs!

This commit is contained in:
Henrik Lissner 2015-05-09 18:08:12 -04:00
parent 3e8d7d1266
commit 1da1ff4583
26 changed files with 306 additions and 405 deletions

View file

@ -5,7 +5,7 @@
:config
(progn
(setq evil-want-visual-char-semi-exclusive t
evil-search-module 'isearch
evil-search-module 'evil-search
evil-search-wrap nil
evil-magic 'magic
evil-want-C-u-scroll t ; enable C-u for scrolling
@ -22,6 +22,7 @@
;; Always ensure evil-shift-width is consistent with tab-width
(add-hook! 'after-change-major-mode-hook (setq evil-shift-width tab-width))
(add-hook 'prog-mode-hook 'hs-minor-mode)
;; highlight matching delimiters where it's important
(defun show-paren-mode-off () (show-paren-mode -1))
@ -49,21 +50,12 @@
(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-commentary
:config (evil-commentary-mode 1))
;; (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-matchit :config (global-evil-matchit-mode 1))
(use-package evil-surround :config (global-evil-surround-mode 1))
(use-package evil-commentary :config (evil-commentary-mode 1))
(use-package evil-search-highlight-persist
:config
(global-evil-search-highlight-persist t))
(use-package evil-jumper
:init (setq evil-jumper-file (expand-file-name "jumplist" my-tmp-dir))
@ -79,17 +71,23 @@
(when evil-exchange--overlays
(evil-exchange-cancel))))
(use-package evil-search-highlight-persist
(use-package evil-visualstar
:config
(progn
(global-evil-search-highlight-persist t)
(set-face-attribute 'evil-search-highlight-persist-highlight-face nil :inherit 'evil-ex-lazy-highlight)))
;; I cut this down because the original visualstar wouldn't remember
;; the last search if evil-search-module was 'evil-search.
(defun evil-visualstar/begin-search (beg end direction)
(when (evil-visual-state-p)
(evil-exit-visual-state)
(let ((selection (regexp-quote (buffer-substring-no-properties beg end))))
(setq isearch-forward direction)
(evil-search selection direction t))))
(global-evil-visualstar-mode 1)))
(use-package evil-snipe
:config
(progn
(global-evil-snipe-mode +1)
(setq evil-snipe-smart-case t)
(setq evil-snipe-override-evil t)
(setq evil-snipe-scope 'line)
@ -117,25 +115,20 @@
(progn ; evil hacks
(defadvice evil-force-normal-state (before evil-esc-quit activate)
(shut-up (evil-search-highlight-persist-remove-all) ; turn off highlights
(evil-ex-nohighlight)
;; Exit minibuffer is alive
(if (minibuffer-window-active-p (minibuffer-window))
(my--minibuffer-quit))))
;; Popwin: close popup window, if any
(after "popwin"
(defadvice evil-force-normal-state (before evil-esc-quit-popwin activate)
(shut-up (popwin:close-popup-window))))
(defadvice evil-force-normal-state (before evil-esc-quit-popwin activate)
(shut-up (popwin:close-popup-window)))
;; Jump to new splits
(defadvice evil-window-split (after evil-window-split-jump activate)
(evil-window-down 1))
(defadvice evil-window-vsplit (after evil-window-vsplit-jump activate)
(evil-window-right 1))
(defadvice undo-tree-load-history-hook (around undo-tree-load-history-shut-up activate)
(shut-up ad-do-it))
(defadvice undo-tree-save-history-hook (around undo-tree-save-history-shut-up activate)
(shut-up ad-do-it)))
(evil-window-right 1)))
(progn ; extensions
(defun evil-visual-line-state-p ()
@ -195,7 +188,7 @@
(evil-define-command my:kill-buffers (&optional bang)
:repeat nil
(interactive "<!>")
(if (and bang (projectile-project-p))
(if (and (not bang) (projectile-project-p))
(projectile-kill-buffers)
(mapc 'kill-buffer (buffer-list)))
(delete-other-windows))

View file

@ -27,8 +27,9 @@
;; Send current file to OSX apps
(defun my-open-with (&optional app-name path)
(interactive)
(let ((app-name (if app-name (concat "-p " app-name)))
(let ((app-name (if app-name (concat "-a " app-name)))
(path (or path (if (eq major-mode 'dired-mode) (dired-get-file-for-visit) (buffer-file-name)))))
(message "Trying: %s" (concat "open " app-name " " (shell-quote-argument path)))
(shell-command (concat "open " app-name " " (shell-quote-argument path)))))

View file

@ -24,7 +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)
;; (setq window-combination-resize nil)
;; do not soft-wrap lines
(setq-default truncate-lines t)
@ -73,7 +73,9 @@
" wg"
" ~"
" s-/"
" yas"
;; " yas"
" emr"
" Refactor"
) "\\|"))
:init
(progn

View file

@ -102,7 +102,7 @@
(keyboard-translate ?\C-i ?\H-i)
;; Save clipboard contents into kill-ring before replace them
(setq save-interprogram-paste-before-kill t)
(setq save-interprogram-paste-before-kill nil)
;; don't let the cursor go into minibuffer prompt
;; Tip taken from Xah Lee: http://ergoemacs.org/emacs/emacs_stop_cursor_enter_prompt.html
@ -132,7 +132,12 @@
;; 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)
savehist-additional-variables '(kill-ring
mark-ring
global-mark-ring
search-ring
regexp-search-ring
extended-command-history)
history-length 1000)
(savehist-mode 1)
@ -162,7 +167,6 @@
(setq-default tab-width 4)
(setq require-final-newline t)
(setq delete-trailing-lines nil)
(add-hook 'makefile-mode-hook 'indent-tabs-mode) ; Use normal tabs in makefiles
@ -184,9 +188,10 @@ determine if a directory is a project."
(throw 'found path)))))) default-directory)
default-directory))
(defun project-has-files (&rest files)
(defun project-has-files (files &optional root)
"Return non-nil if `file' exists in the project root."
(let ((root (project-root))
(let ((root (or root (project-root)))
(files (if (listp files) files (list files)))
found-p file)
(while (and files (not found-p))
(setq file (pop files))
@ -228,11 +233,15 @@ the checking happens for all pairs in auto-minor-mode-alist"
(let* ((scratch-buffer (get-buffer-create "*scratch*"))
(project-name (project-name))
(root (project-root)))
(mapc (lambda (b)
(if (string-match-p "\\*scratch\\* (.+)" (buffer-name b))
(kill-buffer b)))
(buffer-list))
(save-window-excursion
(switch-to-buffer scratch-buffer)
(erase-buffer)
(cd root)
(insert ";; Project: " project-name "\n\n"))))
(rename-buffer (format "*scratch* (%s)" project-name)))))
(add-hook 'find-file-hook 'project-create-scratch-buffer)
@ -255,7 +264,26 @@ the checking happens for all pairs in auto-minor-mode-alist"
(progn ; popwin config
(popwin-mode 1)
(setq popwin:popup-window-height 0.45)
;; (setq display-buffer-function 'popwin:display-buffer)
(push '("\\`\\*helm.*?\\*\\'" :regexp t :position bottom :height 15) popwin:special-display-config)
(push '("^\\*Flycheck.*\\*$" :regexp t :position bottom :height 0.25 :noselect t) popwin:special-display-config)
(push '(inf-enh-ruby-mode :position bottom :stick t) popwin:special-display-config)
(push '(snippet-mode :position bottom :stick t) popwin:special-display-config)
(push '("*ansi-term*" :position bottom :height 0.45 :stick t) popwin:special-display-config)
(push '("*terminal*" :position bottom :height 0.45 :stick t) popwin:special-display-config)
(push '("*Async Shell Command*" :position bottom) popwin:special-display-config)
(push '("* Regexp Explain *" :position top :height 0.35) popwin:special-display-config)
(push '("*anaconda-doc*" :position bottom :height 15 :noselect t) popwin:special-display-config)
(push '("*anaconda-nav*" :position bottom :height 15 :stick t) popwin:special-display-config)
(push '("^\\*Python.+\\*$" :regexp t :position bottom :height 20 :noselect t) popwin:special-display-config)
(push '(help-mode :height 0.5 :position bottom :stick t) popwin:special-display-config)
(push '(compilation-mode :height 0.5 :position bottom :noselect t) popwin:special-display-config)
(push '(diff-mode :position bottom :stick t) popwin:special-display-config)
(push '("*Backtrace*") popwin:special-display-config)
(push '("*Warnings*") popwin:special-display-config)
@ -273,9 +301,9 @@ the checking happens for all pairs in auto-minor-mode-alist"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(cond (is-mac (require 'core-osx))
(is-linux (require 'core-linux))
(is-windows (require 'core-windows)))
(cond (is-mac (require 'core-osx))
(is-linux (require 'core-linux))
(is-windows (require 'core-windows)))
(require 'server)
(unless (server-running-p) (server-start)))

View file

@ -97,7 +97,7 @@ gets killed.")
(defun my-kill-matching-buffers (regexp &optional buffer-list)
(interactive)
(mapc (lambda (b)
(if (s-matches? regexp (buffer-name b))
(if (string-match-p regexp (buffer-name b))
(kill-buffer b)))
(if buffer-list buffer-list (buffer-list))))