Massive refactor. Refactor all the things
This commit is contained in:
parent
03514fc09d
commit
f234be68a4
56 changed files with 792 additions and 831 deletions
|
@ -1,6 +1,7 @@
|
|||
;;; defuns-popups.el
|
||||
|
||||
(defun narf--popup-remove (window)
|
||||
;;;###autoload
|
||||
(defun narf/popup-remove (window)
|
||||
(setq narf-popup-windows (delete window narf-popup-windows)))
|
||||
|
||||
;;;###autoload
|
||||
|
@ -8,7 +9,7 @@
|
|||
"Whether WINDOW is a shackle popup window or not."
|
||||
(and narf-popup-windows
|
||||
(-any? (lambda (w)
|
||||
(if (window-live-p w) t (narf--popup-remove w) nil))
|
||||
(if (window-live-p w) t (narf/popup-remove w) nil))
|
||||
narf-popup-windows)
|
||||
(if window
|
||||
(-any? (lambda (w) (eq window w)) narf-popup-windows)
|
||||
|
@ -39,7 +40,7 @@
|
|||
((eq major-mode 'messages-buffer-mode)
|
||||
(bury-buffer)
|
||||
(setq dont-kill t)))
|
||||
(narf--popup-remove window)
|
||||
(narf/popup-remove window)
|
||||
(unless dont-kill
|
||||
(let ((kill-buffer-query-functions (delq 'process-kill-buffer-query-function kill-buffer-query-functions)))
|
||||
(kill-buffer (window-buffer window))))
|
||||
|
|
|
@ -20,10 +20,6 @@ determine if a directory is a project."
|
|||
(file-exists-p file)))))
|
||||
found-p))
|
||||
|
||||
;;;###autoload
|
||||
(defun narf/project-name (&optional root)
|
||||
(file-name-nondirectory (directory-file-name (or root (narf/project-root)))))
|
||||
|
||||
;;;###autoload
|
||||
(defalias 'narf/project-p 'projectile-project-p)
|
||||
|
||||
|
|
|
@ -13,9 +13,8 @@
|
|||
|
||||
;;;###autoload (autoload 'narf:build "defuns-quickrun" nil t)
|
||||
(evil-define-command narf: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."
|
||||
"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>")
|
||||
(when (null narf--build-command)
|
||||
(user-error "No build command was set"))
|
||||
|
@ -34,6 +33,7 @@ If ARG is nil this function calls `recompile', otherwise it calls
|
|||
;;;; Code running ;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;###autoload (autoload 'narf:eval-buffer "defuns-quickrun" nil t)
|
||||
(evil-define-command narf:eval-buffer ()
|
||||
"Evaluate the whole buffer."
|
||||
:move-point nil :repeat nil
|
||||
(interactive)
|
||||
(cond ((eq major-mode 'emacs-lisp-mode)
|
||||
|
@ -42,26 +42,27 @@ If ARG is nil this function calls `recompile', otherwise it calls
|
|||
|
||||
;;;###autoload (autoload 'narf:eval-region "defuns-quickrun" nil t)
|
||||
(evil-define-operator narf:eval-region (beg end)
|
||||
"Evaluate a region and, if large enough, prints its output to a popup buffer (if an
|
||||
elisp buffer). Otherwise forward the region to Quickrun."
|
||||
:move-point nil :repeat nil
|
||||
(interactive "<r>")
|
||||
(cond ((eq major-mode 'emacs-lisp-mode)
|
||||
(require 'pp)
|
||||
(let* ((pp-escape-newlines nil)
|
||||
(out (s-trim (pp-to-string (eval (read (buffer-substring-no-properties beg end))))))
|
||||
(out (pp-to-string (eval (read (buffer-substring-no-properties beg end)))))
|
||||
(lines (length (s-lines out))))
|
||||
(if (< lines 5)
|
||||
(princ out t)
|
||||
(let ((buf (get-buffer-create "*eval*")))
|
||||
(with-current-buffer buf
|
||||
(read-only-mode -1)
|
||||
(emacs-lisp-mode)
|
||||
(setq-local scroll-margin 0)
|
||||
(erase-buffer)
|
||||
(insert out)
|
||||
(goto-char (point-min))
|
||||
(read-only-mode 1)
|
||||
(narf|hide-mode-line)
|
||||
(narf/popup-buffer buf))))))
|
||||
(with-current-buffer (get-buffer-create "*eval*")
|
||||
;; (rename-buffer (buffer-name old-buf))
|
||||
(read-only-mode -1)
|
||||
(setq-local scroll-margin 0)
|
||||
(emacs-lisp-mode)
|
||||
(erase-buffer)
|
||||
(insert out)
|
||||
(read-only-mode 1)
|
||||
(goto-char (point-min))
|
||||
(narf/popup-buffer (current-buffer))))))
|
||||
(t (quickrun-region beg end))))
|
||||
|
||||
;;;###autoload (autoload 'narf:eval-region-and-replace "defuns-quickrun" nil t)
|
||||
|
|
|
@ -62,8 +62,7 @@ end file."
|
|||
(start (or start (point-min))))
|
||||
(goto-char start)
|
||||
(while (and (re-search-forward "^$" end-marker t) (not (>= (point) end-marker)))
|
||||
(let (line-start line-end
|
||||
next-start next-end)
|
||||
(let (line-start line-end next-start next-end)
|
||||
(save-excursion
|
||||
;; Check previous line indent
|
||||
(forward-line -1)
|
||||
|
@ -79,7 +78,7 @@ end file."
|
|||
(let* ((line-indent (- line-end line-start))
|
||||
(next-indent (- next-end next-start))
|
||||
(indent (min line-indent next-indent)))
|
||||
(insert (make-string indent ? )))))
|
||||
(insert (make-string (if (zerop indent) 0 (1+ indent)) ? )))))
|
||||
(forward-line 1)))))
|
||||
(set-buffer-modified-p nil))
|
||||
nil)
|
||||
|
@ -93,5 +92,9 @@ end file."
|
|||
(imenu-list-minor-mode -1))))
|
||||
(narf/get-visible-buffers (narf/get-real-buffers))))
|
||||
|
||||
;;;###autoload
|
||||
(defun narf|hide-mode-line (&rest _)
|
||||
(setq mode-line-format nil))
|
||||
|
||||
(provide 'defuns-ui)
|
||||
;;; defuns-ui.el ends here
|
||||
|
|
|
@ -8,7 +8,11 @@
|
|||
|
||||
;;;###autoload
|
||||
(defun narf/wg-projectile-switch-project ()
|
||||
(narf:workgroup-new nil (file-name-nondirectory (directory-file-name (narf/project-root))) t))
|
||||
(let ((project-root (narf/project-root)))
|
||||
(narf:workgroup-new nil (file-name-nondirectory (directory-file-name project-root)) t)
|
||||
(narf|update-scratch-buffer-cwd project-root)
|
||||
(when (featurep 'neotree)
|
||||
(neotree-projectile-action))))
|
||||
|
||||
;;;###autoload (autoload 'narf:save-session "defuns-workgroup" nil t)
|
||||
(evil-define-command narf:save-session (&optional bang session-name)
|
||||
|
|
|
@ -2,10 +2,12 @@
|
|||
;; for ../core-company.el
|
||||
|
||||
;;;###autoload
|
||||
(defmacro define-company-backend! (hook backends)
|
||||
(defmacro def-company-backend! (hooks backends)
|
||||
"Register a company backend for a mode."
|
||||
(let ((def-name (intern (format "narf--init-company-%s" hook)))
|
||||
(quoted (eq (car-safe backends) 'quote)))
|
||||
(let* ((hooks (if (listp hooks) hooks (list hooks)))
|
||||
(def-name (intern (format "narf--init-company-%s"
|
||||
(s-join "-" (mapcar 'symbol-name hooks)))))
|
||||
(quoted (eq (car-safe backends) 'quote)))
|
||||
`(progn
|
||||
(defun ,def-name ()
|
||||
(set (make-local-variable 'company-backends)
|
||||
|
@ -15,7 +17,7 @@
|
|||
(intern (format "company-%s" backend))))
|
||||
(if quoted (cadr backends) backends))))
|
||||
company-backends)))
|
||||
(add-hook ',(intern (format "%s-hook" hook)) ',def-name))))
|
||||
(add-hook! ,hooks ',def-name))))
|
||||
|
||||
(provide 'macros-company)
|
||||
;;; macros-company.el ends here
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
;;; macros-evil.el
|
||||
|
||||
;;;###autoload
|
||||
(defmacro define-text-object! (key start-regex end-regex)
|
||||
(defmacro def-textobj! (key start-regex end-regex)
|
||||
(let ((inner-name (make-symbol "narf--inner-name"))
|
||||
(outer-name (make-symbol "narf--outer-name")))
|
||||
`(progn
|
||||
|
@ -13,7 +13,7 @@
|
|||
(define-key evil-outer-text-objects-map ,key (quote ,outer-name)))))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro define-temp-ex-cmd! (cmd-on cmd-off &rest commands)
|
||||
(defmacro def-tmp-excmd! (cmd-on cmd-off &rest commands)
|
||||
"Creates on-off defuns for a set of ex commands, named CMD-ON and CMD-OFF."
|
||||
(declare (indent 2))
|
||||
`(progn
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
;;; macros-quickrun.el
|
||||
|
||||
;;;###autoload
|
||||
(defmacro define-builder! (mode command &optional build-file)
|
||||
(defmacro def-builder! (mode command &optional build-file)
|
||||
"Register major/minor MODE with build COMMAND. If FILES are provided, do an
|
||||
additional check to make sure they exist in the project root."
|
||||
`(add-hook! ,mode
|
||||
|
@ -10,7 +10,7 @@ additional check to make sure they exist in the project root."
|
|||
(setq narf--build-command '(,command . ,build-file)))))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro define-repl! (mode command)
|
||||
(defmacro def-repl! (mode command)
|
||||
`(push '(,mode . ,command) rtog/mode-repl-alist))
|
||||
|
||||
(provide 'macros-quickrun)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
;;; defuns-spaceline.el
|
||||
|
||||
;;;###autoload
|
||||
(defmacro define-env-command! (mode command)
|
||||
(defmacro def-env-command! (mode command)
|
||||
"Define a COMMAND for MODE that will set `narf--env-command' when that mode is
|
||||
activated, which should return the version number of the current environment. It is used
|
||||
by `narf|spaceline-env-update' to display a version number in the modeline. For instance:
|
||||
|
||||
(define-env-command! ruby-mode \"ruby --version | cut -d' ' -f2\")
|
||||
(def-env-command! ruby-mode \"ruby --version | cut -d' ' -f2\")
|
||||
|
||||
This will display the ruby version in the modeline in ruby-mode buffers. It is cached the
|
||||
first time."
|
||||
|
|
|
@ -2,15 +2,14 @@
|
|||
;; for ../core-yasnippet.el
|
||||
|
||||
;;;###autoload
|
||||
(defmacro add-yas-minor-mode! (mode)
|
||||
(defmacro def-yas-mode! (mode)
|
||||
"Register minor MODES in yasnippet."
|
||||
`(after! yasnippet
|
||||
(when (boundp 'yas--extra-modes)
|
||||
(add-hook ',(intern (concat (symbol-name (cadr mode)) "-hook"))
|
||||
(lambda ()
|
||||
(if (symbol-value ,mode)
|
||||
(yas-activate-extra-mode ,mode)
|
||||
(yas-deactivate-extra-mode ,mode)))))))
|
||||
(add-hook! ,mode
|
||||
(if (symbol-value ,mode)
|
||||
(yas-activate-extra-mode ,mode)
|
||||
(yas-deactivate-extra-mode ,mode))))))
|
||||
|
||||
(provide 'macros-yasnippet)
|
||||
;;; macros-yasnippet.el ends here
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue