Abstract popwin defuns
This commit is contained in:
parent
0cd60e5ae8
commit
5193970d8f
13 changed files with 39 additions and 110 deletions
4
Cask
4
Cask
|
@ -18,11 +18,13 @@
|
|||
(depends-on "dash-at-point")
|
||||
(depends-on "applescript-mode")
|
||||
|
||||
;; Popups --- core/core-popup.el
|
||||
(depends-on "popwin")
|
||||
|
||||
;; UI --- core/core-ui.el
|
||||
(depends-on "yascroll" :git "https://github.com/m2ym/yascroll-el")
|
||||
(depends-on "rainbow-delimiters")
|
||||
(depends-on "rainbow-mode")
|
||||
(depends-on "popwin")
|
||||
(depends-on "volatile-highlights")
|
||||
(depends-on "nlinum")
|
||||
(depends-on "spaceline" :git "https://github.com/TheBB/spaceline")
|
||||
|
|
|
@ -29,6 +29,15 @@
|
|||
evil-echo-state nil
|
||||
evil-ex-substitute-global t
|
||||
|
||||
evil-normal-state-tag "N"
|
||||
evil-insert-state-tag "I"
|
||||
evil-motion-state-tag "M"
|
||||
evil-replace-state-tag "R"
|
||||
evil-emacs-state-tag "E"
|
||||
evil-visual-state-tag "V"
|
||||
evil-operator-state-tag "O"
|
||||
evil-iedit-state-tag "X"
|
||||
|
||||
;; Color-coded state cursors
|
||||
evil-normal-state-cursor 'box
|
||||
evil-emacs-state-cursor 'bar
|
||||
|
@ -59,18 +68,14 @@
|
|||
|
||||
(progn ; evil hacks
|
||||
(defadvice evil-force-normal-state (after evil-esc-quit activate)
|
||||
"Close popwin windows, disable search highlights and quit the minibuffer if open."
|
||||
(when (popwin:popup-window-live-p)
|
||||
(popwin:close-popup-window))
|
||||
"Close popups, disable search highlights and quit the minibuffer if open."
|
||||
(unless (bound-and-true-p org-src-mode)
|
||||
(narf/popup-close))
|
||||
(ignore-errors
|
||||
(evil-ex-nohighlight))
|
||||
(when (minibuffer-window-active-p (minibuffer-window))
|
||||
(narf-minibuffer-quit)))
|
||||
|
||||
;; Fix disruptive errors w/ hidden buffers caused by popwin
|
||||
(defadvice evil-ex-hl-do-update-highlight (around evil-ex-hidden-buffer-ignore-errors activate)
|
||||
(ignore-errors ad-do-it))
|
||||
|
||||
;; buffer-local ex commands, thanks to: http://emacs.stackexchange.com/questions/13186
|
||||
(defun evil-ex-define-cmd-local (cmd function)
|
||||
"Locally binds the function FUNCTION to the command CMD."
|
||||
|
@ -170,7 +175,8 @@
|
|||
(use-package evil-anzu
|
||||
:config
|
||||
(setq anzu-cons-mode-line-p nil
|
||||
anzu-minimum-input-length 2))
|
||||
anzu-minimum-input-length 2
|
||||
anzu-search-threshold 500))
|
||||
|
||||
(use-package evil-args
|
||||
:commands (evil-inner-arg evil-outer-arg evil-forward-arg evil-backward-arg evil-jump-out-args)
|
||||
|
|
|
@ -17,10 +17,8 @@
|
|||
helm-find-files-doc-header nil
|
||||
|
||||
helm-candidate-number-limit 30
|
||||
helm-bookmark-show-location t
|
||||
;; let popwin handle this
|
||||
helm-split-window-default-side 'other
|
||||
helm-split-window-preferred-function 'narf/helm-split-window)
|
||||
helm-bookmark-show-location t)
|
||||
|
||||
:config
|
||||
(evil-set-initial-state 'helm-mode 'emacs)
|
||||
(require 'helm-files)
|
||||
|
@ -116,57 +114,7 @@
|
|||
helm-ag-project-root
|
||||
helm-ag-pop-stack
|
||||
helm-ag-buffers
|
||||
helm-ag-clear-stack)
|
||||
:config
|
||||
(defadvice helm-ag--edit-abort (around helm-ag-edit-abort-popwin-compat activate)
|
||||
(cl-letf (((symbol-function 'select-window) 'ignore)) ad-do-it))
|
||||
(defadvice helm-ag--edit-commit (around helm-ag-edit-commit-popwin-compat activate)
|
||||
(cl-letf (((symbol-function 'select-window) 'ignore)) ad-do-it))
|
||||
|
||||
;; I remove any attempt to kill the helm-ag window, because popwin handles it.
|
||||
(defun helm-ag--edit (_candidate)
|
||||
(let ((default-directory helm-ag--default-directory))
|
||||
(with-current-buffer (get-buffer-create "*helm-ag-edit*")
|
||||
(erase-buffer)
|
||||
(setq-local helm-ag--default-directory helm-ag--default-directory)
|
||||
(let (buf-content)
|
||||
(with-current-buffer (get-buffer "*helm-ag*")
|
||||
(goto-char (point-min))
|
||||
(forward-line 1)
|
||||
(let* ((body-start (point))
|
||||
(marked-lines (cl-loop for ov in (overlays-in body-start (point-max))
|
||||
when (eq 'helm-visible-mark (overlay-get ov 'face))
|
||||
return (helm-marked-candidates))))
|
||||
(if (not marked-lines)
|
||||
(setq buf-content (buffer-substring-no-properties
|
||||
body-start (point-max)))
|
||||
(setq buf-content (concat (mapconcat 'identity marked-lines "\n") "\n")))))
|
||||
(insert buf-content)
|
||||
(add-text-properties (point-min) (point-max)
|
||||
'(read-only t rear-nonsticky t front-sticky t))
|
||||
(let ((inhibit-read-only t))
|
||||
(setq header-line-format
|
||||
(format "[%s] C-c C-c: Commit, C-c C-k: Abort"
|
||||
(abbreviate-file-name helm-ag--default-directory)))
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^\\(\\(?:[^:]+:\\)\\{1,2\\}\\)\\(.*\\)$" nil t)
|
||||
(let ((file-line-begin (match-beginning 1))
|
||||
(file-line-end (match-end 1))
|
||||
(body-begin (match-beginning 2))
|
||||
(body-end (match-end 2)))
|
||||
(add-text-properties file-line-begin file-line-end
|
||||
'(face font-lock-function-name-face
|
||||
intangible t))
|
||||
(remove-text-properties body-begin body-end '(read-only t))
|
||||
(set-text-properties body-end (1+ body-end)
|
||||
'(read-only t rear-nonsticky t))))))))
|
||||
(popwin:display-buffer (get-buffer "*helm-ag-edit*"))
|
||||
;; (other-window 1)
|
||||
;; (switch-to-buffer (get-buffer "*helm-ag-edit*"))
|
||||
(goto-char (point-min))
|
||||
(setq next-error-function 'compilation-next-error-function)
|
||||
(setq-local compilation-locs (make-hash-table :test 'equal :weakness 'value))
|
||||
(use-local-map helm-ag-edit-map)))
|
||||
helm-ag-clear-stack))
|
||||
|
||||
(use-package helm-org
|
||||
:commands (helm-org-in-buffer-headings
|
||||
|
|
|
@ -87,10 +87,6 @@
|
|||
(add-hook! neotree-mode 'narf|neotree-init-keymap)
|
||||
(add-hook! window-configuration-change 'narf|neotree-close-on-window-change)
|
||||
|
||||
(when neo-persist-show
|
||||
(add-hook! 'popwin:before-popup-hook (setq neo-persist-show nil))
|
||||
(add-hook! 'popwin:after-popup-hook (setq neo-persist-show t)))
|
||||
|
||||
(evil-set-initial-state 'neotree-mode 'motion)
|
||||
(after! projectile
|
||||
(setq projectile-switch-project-action 'neotree-projectile-action))
|
||||
|
|
|
@ -9,15 +9,9 @@
|
|||
quickrun-replace-region
|
||||
helm-quickrun)
|
||||
:config
|
||||
(setq quickrun-focus-p nil)
|
||||
(add-to-list 'quickrun-file-alist '("\\.gvy$" . "groovy"))
|
||||
|
||||
(defun narf*quickrun-close-popwin ()
|
||||
(when (get-buffer quickrun/buffer-name)
|
||||
(quickrun/kill-quickrun-buffer)
|
||||
(popwin:close-popup-window-if-necessary)))
|
||||
(advice-add 'quickrun :before 'narf*quickrun-close-popwin)
|
||||
(advice-add 'quickrun-region :before 'narf*quickrun-close-popwin))
|
||||
(setq quickrun-focus-p t)
|
||||
(add-hook! quickrun/mode 'linum-mode)
|
||||
(add-to-list 'quickrun-file-alist '("\\.gvy$" . "groovy")))
|
||||
|
||||
(provide 'core-quickrun)
|
||||
;;; core-quickrun.el ends here
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
(use-package workgroups2
|
||||
:when window-system
|
||||
:init
|
||||
(setq split-height-threshold 10
|
||||
(setq split-height-threshold 8
|
||||
|
||||
wg-session-file (expand-file-name "wg-default" narf-temp-dir)
|
||||
wg-workgroup-directory (expand-file-name "workgroups" narf-temp-dir)
|
||||
|
|
|
@ -92,9 +92,8 @@ Inspired from http://demonastery.org/2013/04/emacs-evil-narrow-region/"
|
|||
(when window-system
|
||||
(mac-start-animation (get-buffer-window) :type 'fade-out :duration 0.3))
|
||||
(kill-this-buffer))))
|
||||
(if (and (eq (current-buffer) popwin:popup-buffer)
|
||||
(popwin:popup-window-live-p))
|
||||
(popwin:close-popup-window)
|
||||
(if (narf/popup-p (current-buffer))
|
||||
(narf/popup-close)
|
||||
(unless (narf/real-buffer-p (current-buffer))
|
||||
(narf/previous-real-buffer))))
|
||||
|
||||
|
@ -227,7 +226,7 @@ left, create a scratch buffer."
|
|||
;; or scratch buffer by default
|
||||
(let* ((project-dir (narf/project-root t))
|
||||
(buffer-name "*scratch*"))
|
||||
(popwin:popup-buffer (get-buffer-create buffer-name))
|
||||
(narf/popup-open (get-buffer-create buffer-name))
|
||||
(when (eq (get-buffer buffer-name) (current-buffer))
|
||||
(when project-dir
|
||||
(cd project-dir))
|
||||
|
|
|
@ -17,14 +17,6 @@
|
|||
(setq mode-line-format nil)
|
||||
(setq header-line-format nil))
|
||||
|
||||
;;;###autoload
|
||||
(defun narf/helm-split-window (&optional window)
|
||||
"Minimalistic split-fn; leaves popwin to handle helm buffers."
|
||||
(if (one-window-p t)
|
||||
(let ((helm-full-frame t))
|
||||
(selected-window))
|
||||
(other-window-for-scrolling)))
|
||||
|
||||
;;;###autoload
|
||||
(defun narf/helm-get-org-candidates-in-file (filename min-depth max-depth &optional fontify nofname)
|
||||
(with-current-buffer (pcase filename
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
;;; defuns-popwin.el
|
||||
|
||||
;;;###autoload
|
||||
(defun narf/popwin-toggle ()
|
||||
(interactive)
|
||||
(if (popwin:popup-window-live-p)
|
||||
(popwin:close-popup-window)
|
||||
(popwin:popup-last-buffer)))
|
||||
|
||||
(provide 'defuns-popwin)
|
||||
;;; defuns-popwin.el ends here
|
|
@ -55,7 +55,7 @@ If ARG is nil this function calls `recompile', otherwise it calls
|
|||
(insert out)
|
||||
(goto-char (point-min))
|
||||
(read-only-mode 1)
|
||||
(popwin:popup-buffer buf :height (if (> lines 25) 25 (1+ lines))))))))
|
||||
(narf/popup-open buf))))))
|
||||
(t (quickrun-region beg end))))
|
||||
|
||||
;;;###autoload (autoload 'narf:eval-region-and-replace "defuns-quickrun" nil t)
|
||||
|
|
7
init.el
7
init.el
|
@ -58,6 +58,7 @@
|
|||
(IS-LINUX 'core-os-linux)
|
||||
(IS-WINDOWS 'core-os-win32))
|
||||
|
||||
core-popup ; popup library and setup
|
||||
core-ui ; draw me like one of your French editors
|
||||
core-evil ; come to the dark side, we have cookies
|
||||
core-editor ; filling the editor-shaped hole in the emacs OS
|
||||
|
@ -72,12 +73,10 @@
|
|||
core-workgroups ; cure Emacs alzheimers
|
||||
|
||||
module-cc ; c/c++/obj-c madness
|
||||
;; module-crystal ; ruby at the speed of c
|
||||
module-csharp ; unity, .NET, and mono shenanigans
|
||||
module-collab ; wonewy, I'm so wonewy~
|
||||
module-data ; dbs 'n data formats
|
||||
module-elisp ; drowning in parentheses
|
||||
;; module-eshell ; eshell (on windows)
|
||||
module-go ; a hipster dialect
|
||||
module-java ; the poster child for carpal tunnel syndome
|
||||
module-js ; alert("not java, javascript!")
|
||||
|
@ -97,6 +96,10 @@
|
|||
module-web ; for the 2.0'er
|
||||
module-writing ; emacs for writing papers or fiction
|
||||
|
||||
;;; Experimental
|
||||
;; module-crystal ; ruby at the speed of c
|
||||
;; module-eshell ; eshell (on windows)
|
||||
|
||||
my-bindings
|
||||
my-commands
|
||||
))
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
"M-b" 'narf:build
|
||||
"M-t" 'helm-projectile-find-file
|
||||
"A-`" 'narf-switch-to-iterm
|
||||
"C-`" 'narf/popwin-toggle
|
||||
"C-`" 'narf/popup-toggle
|
||||
"<f9>" 'what-face
|
||||
|
||||
"M-w" 'evil-window-delete
|
||||
|
@ -322,8 +322,8 @@
|
|||
:n "]]" 'help-go-forward
|
||||
:n "[[" 'help-go-back
|
||||
:n "<escape>" (λ (kill-buffer)
|
||||
(if (eq popwin:popup-buffer (current-buffer))
|
||||
(popwin:close-popup-window)
|
||||
(if (narf/popup-p (current-buffer))
|
||||
(narf/popup-close)
|
||||
(evil-window-delete)))))
|
||||
|
||||
(:map evil-ex-completion-map
|
||||
|
|
|
@ -26,13 +26,13 @@
|
|||
(exmap "k[ill]all" 'narf:kill-all-buffers) ; Kill all buffers (bang = in project)
|
||||
(exmap "k[ill]buried" 'narf:kill-buried-buffers) ; Kill all buried buffers (bang = in project)
|
||||
(exmap "k[ill]o" 'narf:kill-unreal-buffers)
|
||||
(exmap "l[ast]" 'popwin:popup-last-buffer)
|
||||
(exmap "m[sg]" 'popwin:messages)
|
||||
(exmap "l[ast]" 'narf:popup-last-buffer)
|
||||
(exmap "m[sg]" 'narf:popup-messages)
|
||||
(exmap "ma[ke]" 'narf:build)
|
||||
(exmap "mv" 'narf:file-move)
|
||||
(exmap "na[rrow]" 'narf:narrow) ; Narrow buffer to selection
|
||||
(exmap "wi[den]" 'narf:widen) ; Widen narrowed buffer
|
||||
(exmap "pop" 'narf/popwin-toggle)
|
||||
(exmap "pop" 'narf/popup-toggle)
|
||||
(exmap "proj[ect]" 'helm-projectile-switch-project)
|
||||
(exmap "rec[ent]" 'narf:helm-recentf)
|
||||
(exmap "re[gex]" 'narf:regex)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue