General clean up

This commit is contained in:
Henrik Lissner 2016-05-20 09:23:46 -04:00
parent 3ff02c51ef
commit bf858508c6
6 changed files with 180 additions and 184 deletions

View file

@ -74,10 +74,8 @@
"Close popups, disable search highlights and quit the minibuffer if open."
(let ((minib-p (minibuffer-window-active-p (minibuffer-window)))
(evil-hl-p (evil-ex-hl-active-p 'evil-ex-search)))
(when minib-p
(abort-recursive-edit))
(when evil-hl-p
(evil-ex-nohighlight))
(when minib-p (abort-recursive-edit))
(when evil-hl-p (evil-ex-nohighlight))
;; Close non-repl popups and clean up `narf-popup-windows'
(unless (or minib-p evil-hl-p
(memq (get-buffer-window) narf-popup-windows))

View file

@ -73,17 +73,16 @@
(add-hook 'shackle-popup-hook 'narf|hide-mode-line) ; No mode line in popups
;; Prevents popups from messaging with windows-moving functions
(after! defuns-popup
(defun narf*save-popups (orig-fun &rest args)
(narf/popup-save (apply orig-fun args)))
(advice-add 'narf--evil-window-move :around 'narf*save-popups)
(advice-add 'narf--evil-swap-windows :around 'narf*save-popups))
(advice-add 'narf/evil-window-move :around 'narf*save-popups))
;;
;; Hacks
;;
(after! help-mode
;;
;; Hacks
;;
(after! help-mode
;; So that help buffer links do not open in the help popup, we need to redefine these
;; three button types to use `switch-to-buffer-other-window' rather than
;; `pop-to-buffer'. Instead of lambas these help-functions should be function symbols,
@ -126,7 +125,7 @@
(message "Unable to find location in file"))))
'help-echo (purecopy "mouse-2, RET: find face's definition")))
(after! helm
(after! helm
;; This is a good alternative to either popwin or shackle, specifically for helm. If
;; either fail me (for the last time), this is where I'll turn.
;;(add-to-list 'display-buffer-alist
@ -142,10 +141,10 @@
(setq-default helm-reuse-last-window-split-state t
helm-split-window-in-side-p t))
(after! helm-swoop
(after! helm-swoop
(setq helm-swoop-split-window-function (lambda ($buf) (narf/popup-buffer $buf))))
(after! helm-ag
(after! helm-ag
;; Helm-ag needs a little coaxing for it to cooperate with shackle. Mostly to prevent
;; it from switching between windows and buffers.
(defadvice helm-ag--edit-abort (around helm-ag-edit-abort-popup-compat activate)
@ -159,7 +158,7 @@
((symbol-function 'switch-to-buffer) 'narf/popup-buffer))
ad-do-it)))
(after! quickrun
(after! quickrun
;; This allows us to run code several times in a row without having to close the popup
;; window and move back to the code buffer.
(defun narf*quickrun-close-popup (&optional _ _ _ _)
@ -179,7 +178,7 @@
(add-hook 'quickrun-after-run-hook 'narf|quickrun-after-run)
(add-hook 'quickrun/mode-hook 'narf|hide-mode-line))
(add-hook! org-load
(add-hook! org-load
;; This ensures org-src-edit yields control of its buffer to shackle.
(defun org-src-switch-to-buffer (buffer context)
(pop-to-buffer buffer))
@ -216,7 +215,7 @@
"q" 'narf/org-agenda-quit
"Q" 'narf/org-agenda-quit))
(after! realgud
(after! realgud
;; This allows realgud debuggers to run in a popup.
;; TODO Find a more elegant advice-based solution
;; FIXME Causes realgud:cmd-* to focus popup on every invocation
@ -245,7 +244,7 @@
(progn
(if cmd-buf (switch-to-buffer cmd-buf))
(message "Error running command: %s" (mapconcat 'identity cmd-args " ")))))
cmd-buf))))
cmd-buf)))
(provide 'core-popup)
;;; core-popup.el ends here

View file

@ -1,5 +1,10 @@
;;; core-ui.el --- interface & mode-line config
;; y/n instead of yes/no
(fset 'yes-or-no-p 'y-or-n-p)
(defvar narf-fringe-size 3 "Default fringe width")
(setq-default
blink-matching-paren nil ; don't blink--too distracting
show-paren-delay 0.075
@ -36,8 +41,6 @@
fringe-indicator-alist (delq (assoc 'continuation fringe-indicator-alist)
fringe-indicator-alist))
(fset 'yes-or-no-p 'y-or-n-p) ; y/n instead of yes/no
;; Ask for confirmation on exit only if there are real buffers left
(when window-system
(setq confirm-kill-emacs
@ -160,8 +163,7 @@
:commands (rainbow-mode)
:init
;; hl-line-mode and rainbow-mode don't play well together
(add-hook! (sass-mode scss-mode less-css-mode)
'(rainbow-mode narf|hl-line-off)))
(add-hook 'rainbow-mode-hook 'narf|hl-line-off))
(use-package nlinum
:commands nlinum-mode

View file

@ -9,7 +9,7 @@
;; narf|… A hook
;; narf*… An advising function
;; narf.… Custom prefix commands
;; …! Macro
;; …! Macro or shortcut alias
;;
;; Autoloaded functions are in {core,modules}/defuns/defuns-*.el
;;
@ -79,21 +79,14 @@
;; Variables
;;
(defvar narf-leader-prefix "," "Prefix key for <leader> maps")
(defvar narf-localleader-prefix "\\" "Prefix key for <localleader> maps")
;; Buffers/Files
(defvar narf-unreal-buffers '("^ ?\\*.+\\*"
image-mode
dired-mode
reb-mode
messages-buffer-mode)
"A list of regexps or modes whose buffers are considered unreal, and will be
ignored when using `narf:next-real-buffer' and `narf:previous-real-buffer', and
killed by `narf/kill-unreal-buffers'.
`narf/kill-real-buffer' will also gloss over these buffers when finding a new
buffer to display.")
ignored when using `narf:next-real-buffer' and `narf:previous-real-buffer' (or
killed by `narf/kill-unreal-buffers', or after `narf/kill-real-buffer').")
(defvar narf-ignore-buffers '("*Completions*" "*Compile-Log*" "*inferior-lisp*"
"*Fuzzy Completions*" "*Apropos*" "*Help*" "*cvs*"
@ -131,21 +124,19 @@ gets killed.")
"A list of files that count as 'project files', which determine whether a
folder is the root of a project or not.")
;; Fringe/margins
(defvar narf-fringe-size 6 "Default width to use for the fringes.")
;;
;; Bootstrap
;; Libraries
;;
(require 'f)
(autoload 'use-package "use-package" "" nil 'macro)
(unless (require 'autoloads nil t)
(load (concat narf-emacs-dir "/scripts/generate-autoloads.el"))
(require 'autoloads))
(require 'core-defuns)
(autoload 'use-package "use-package" "" nil 'macro)
(use-package anaphora
:commands (awhen aif acond awhile))
@ -204,13 +195,14 @@ enable multiple minor modes for the same regexp.")
;;
(add-hook! after-init
;; We add this to `after-init-hook' to allow errors to stop this advice
;; We add this to `after-init-hook' to allow errors to stop it
(defadvice save-buffers-kill-emacs (around no-query-kill-emacs activate)
"Prevent annoying \"Active processes exist\" query when you quit Emacs."
(cl-flet ((process-list ())) ad-do-it))
;; Don't display anything
;; Prevent any auto-displayed text...
(advice-add 'display-startup-echo-area-message :override 'ignore)
;; ...so we can display our own
(message ":: Loaded in %.3fs"
(float-time (time-subtract (current-time) emacs-start-time))))

View file

@ -47,6 +47,10 @@
(defconst narf-terminal-theme 'narf-dark)
(defconst narf-default-font (font-spec :family "Fira Mono" :size 12))
(defconst narf-leader-prefix "," "Prefix for <leader> bindings")
(defconst narf-localleader-prefix "\\" "Prefix for <localleader> bindings")
;; Load packages
(narf `(core ; core/core.el
;; OS-specific config
@ -74,6 +78,7 @@
module-cc ; C/C++/Obj-C madness
module-crystal ; ruby at the speed of c
module-csharp ; unity, .NET, and mono shenanigans
module-css ; #big-bang::before { content: ""; }
module-data ; config and data formats
module-go ; the hipster dialect
module-haskell ; a language that's lazier than I am
@ -92,7 +97,7 @@
module-scala ; Java, but good
module-sh ; she sells Z-shells by the C XOR
module-text ; writing docs for people to ignore
module-web ; #big-bang::before { content: ""; }
module-web ; The end is always near </html>
;; Experimental
;;module-eshell ; for inferior OSes *cough*windows