No NARF, only DOOM

This commit is contained in:
Henrik Lissner
2016-05-20 22:37:30 -04:00
parent a984bf4f26
commit ad225d2591
104 changed files with 1404 additions and 1409 deletions

View File

@@ -1,19 +1,21 @@
;;; defuns-window.el --- library for acting on windows
;;;###autoload
(defun narf/evil-window-split ()
(defun doom/evil-window-split ()
(interactive)
(call-interactively 'evil-window-split)
(evil-window-down 1))
(doom/neotree-save
(call-interactively 'evil-window-split)
(evil-window-down 1)))
;;;###autoload
(defun narf/evil-window-vsplit ()
(defun doom/evil-window-vsplit ()
(interactive)
(call-interactively 'evil-window-vsplit)
(evil-window-right 1))
(doom/neotree-save
(call-interactively 'evil-window-vsplit)
(evil-window-right 1)))
;;;###autoload
(defun narf/evil-window-move (direction)
(defun doom/evil-window-move (direction)
"Move current window to the next window in DIRECTION. If there are no windows
there and there is only one window, split in that direction and place this
window there. If there are no windows and this isn't the only window, use
@@ -23,7 +25,7 @@ evil-window-move-* (e.g. `evil-window-move-far-left')"
(that-window (windmove-find-other-window direction nil this-window))
(that-buffer (window-buffer that-window)))
(when (or (minibufferp that-buffer)
(narf/popup-p that-window))
(doom/popup-p that-window))
(setq that-buffer nil that-window nil))
(if (not (or that-window (one-window-p t)))
(funcall (case direction
@@ -37,7 +39,7 @@ evil-window-move-* (e.g. `evil-window-move-far-left')"
((eq direction 'down) 'below)
(t direction))))
(with-selected-window that-window
(switch-to-buffer "*scratch*"))
(switch-to-buffer doom-buffer))
(setq that-buffer (window-buffer that-window)))
(with-selected-window this-window
(switch-to-buffer that-buffer))
@@ -46,61 +48,61 @@ evil-window-move-* (e.g. `evil-window-move-far-left')"
(select-window that-window))))
;;;###autoload
(defun narf/new-buffer ()
(defun doom/new-buffer ()
(interactive)
(switch-to-buffer (generate-new-buffer "*new*")))
;;;###autoload
(defun narf/new-frame ()
(defun doom/new-frame ()
(interactive)
(let ((nlinum-p (and (featurep 'nlinum)
(memq 'nlinum--setup-window window-configuration-change-hook))))
;; Disable nlinum to fix elusive "invalid face linum" bug
(remove-hook 'window-configuration-change-hook 'nlinum--setup-window t)
(let ((frame (new-frame))
(frame-name (format "*new-%s*" (length narf-wg-frames))))
(frame-name (format "*new-%s*" (length doom-wg-frames))))
(with-selected-frame frame
(wg-create-workgroup frame-name t)
(add-to-list 'narf-wg-frames (cons frame frame-name))))
(add-to-list 'doom-wg-frames (cons frame frame-name))))
(when nlinum-p
(add-hook 'window-configuration-change-hook 'nlinum--setup-window nil t))))
;;;###autoload
(defun narf/close-frame ()
(defun doom/close-frame ()
(interactive)
(aif (assq (selected-frame) narf-wg-frames)
(aif (assq (selected-frame) doom-wg-frames)
(progn (wg-delete-workgroup (wg-get-workgroup (cdr it)))
(delete-frame (car it)))
(delete-frame)))
;;;###autoload
(defun narf/evil-window-resize (direction &optional count)
(defun doom/evil-window-resize (direction &optional count)
(interactive)
(let ((count (or count 1))
(next-window (window-in-direction direction)))
(when (or (not next-window) (not (narf/real-buffer-p (window-buffer next-window))))
(when (or (not next-window) (not (doom/real-buffer-p (window-buffer next-window))))
(setq count (- count)))
(cond ((memq direction '(left right))
(evil-window-increase-width count))
((memq direction '(above below))
(evil-window-increase-height count)))))
;;;###autoload (autoload 'narf/evil-window-resize-r "defuns-window" nil t)
(evil-define-command narf/evil-window-resize-r (&optional count)
(interactive "<c>") (narf/evil-window-resize 'right count))
;;;###autoload (autoload 'narf/evil-window-resize-l "defuns-window" nil t)
(evil-define-command narf/evil-window-resize-l (&optional count)
(interactive "<c>") (narf/evil-window-resize 'left count))
;;;###autoload (autoload 'narf/evil-window-resize-u "defuns-window" nil t)
(evil-define-command narf/evil-window-resize-u (&optional count)
;;;###autoload (autoload 'doom/evil-window-resize-r "defuns-window" nil t)
(evil-define-command doom/evil-window-resize-r (&optional count)
(interactive "<c>") (doom/evil-window-resize 'right count))
;;;###autoload (autoload 'doom/evil-window-resize-l "defuns-window" nil t)
(evil-define-command doom/evil-window-resize-l (&optional count)
(interactive "<c>") (doom/evil-window-resize 'left count))
;;;###autoload (autoload 'doom/evil-window-resize-u "defuns-window" nil t)
(evil-define-command doom/evil-window-resize-u (&optional count)
:repeat nil
(interactive "<c>") (narf/evil-window-resize 'above count))
;;;###autoload (autoload 'narf/evil-window-resize-d "defuns-window" nil t)
(evil-define-command narf/evil-window-resize-d (&optional count)
(interactive "<c>") (narf/evil-window-resize 'below count))
(interactive "<c>") (doom/evil-window-resize 'above count))
;;;###autoload (autoload 'doom/evil-window-resize-d "defuns-window" nil t)
(evil-define-command doom/evil-window-resize-d (&optional count)
(interactive "<c>") (doom/evil-window-resize 'below count))
;;;###autoload
(defun narf/window-reorient ()
(defun doom/window-reorient ()
"Reorient all windows that are scrolled to the right."
(interactive)
(let ((i 0))
@@ -109,7 +111,7 @@ evil-window-move-* (e.g. `evil-window-move-far-left')"
(when (> (window-hscroll) 0)
(cl-incf i)
(evil-beginning-of-line))))
(narf/get-visible-windows))
(doom/get-visible-windows))
(message "Reoriented %s windows" i)))
(provide 'defuns-window)