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

@ -2,10 +2,10 @@
;; for ../core-auto-insert.el
;;;###autoload
(defun narf/auto-insert-snippet (key &optional mode project-only)
(defun doom/auto-insert-snippet (key &optional mode project-only)
"Auto insert a snippet of yasnippet into new file."
(interactive)
(when (if project-only (narf/project-p) t)
(when (if project-only (doom/project-p) t)
(let ((is-yasnippet-on (not (cond ((functionp yas-dont-activate)
(funcall yas-dont-activate))
((consp yas-dont-activate)

View file

@ -1,7 +1,7 @@
;;; defuns-buffers.el
;;;###autoload (autoload 'narf:narrow "defuns-buffers" nil t)
(evil-define-operator narf:narrow (&optional beg end bang)
;;;###autoload (autoload 'doom:narrow "defuns-buffers" nil t)
(evil-define-operator doom:narrow (&optional beg end bang)
"Restrict editing in this buffer to the current region, indirectly. With BANG,
clone the buffer and hard-narrow the selection. Otherwise use fancy-narrow. If
mark isn't active, then widen the buffer (if narrowed).
@ -18,14 +18,14 @@ Inspired from http://demonastery.org/2013/04/emacs-evil-narrow-region/"
(widen)))
;;;###autoload
(defun narf/set-read-only-region (begin end)
(defun doom/set-read-only-region (begin end)
"See http://stackoverflow.com/questions/7410125"
(let ((modified (buffer-modified-p)))
(add-text-properties begin end '(read-only t))
(set-buffer-modified-p modified)))
;;;###autoload
(defun narf/set-region-writeable (begin end)
(defun doom/set-region-writeable (begin end)
"See http://stackoverflow.com/questions/7410125"
(let ((modified (buffer-modified-p))
(inhibit-read-only t))
@ -41,7 +41,7 @@ Inspired from http://demonastery.org/2013/04/emacs-evil-narrow-region/"
(defalias 'wg-save-session 'ignore))
;;;###autoload
(defun narf/get-buffers (&optional project-p)
(defun doom/get-buffers (&optional project-p)
"Get all buffers in the current workgroup.
If PROJECT-P is non-nil, get all buffers in current workgroup
@ -51,89 +51,91 @@ Inspired from http://demonastery.org/2013/04/emacs-evil-narrow-region/"
(--filter (memq it assocbuf) (buffer-list))
(buffer-list)))
project-root)
(aif (and project-p (narf/project-root t))
(aif (and project-p (doom/project-root t))
(funcall (if (eq project-p 'not) '-remove '-filter)
(lambda (b) (projectile-project-buffer-p b it))
buffers)
buffers)))
;;;###autoload
(defun narf/get-buffer-names (&optional project-p)
(defun doom/get-buffer-names (&optional project-p)
(mapcar (lambda (b) (buffer-name b))
(narf/get-buffers project-p)))
(doom/get-buffers project-p)))
;;;###autoload
(defun narf/get-visible-windows (&optional buffer-list)
(defun doom/get-visible-windows (&optional buffer-list)
(-map #'get-buffer-window
(narf/get-visible-buffers (or buffer-list (narf/get-buffers)))))
(doom/get-visible-buffers (or buffer-list (doom/get-buffers)))))
;;;###autoload
(defun narf/get-visible-buffers (&optional buffer-list)
(defun doom/get-visible-buffers (&optional buffer-list)
"Get a list of buffers that are not buried (i.e. visible)"
(-filter #'get-buffer-window (or buffer-list (narf/get-buffers))))
(-filter #'get-buffer-window (or buffer-list (doom/get-buffers))))
;;;###autoload
(defun narf/get-buried-buffers (&optional buffer-list)
(defun doom/get-buried-buffers (&optional buffer-list)
"Get a list of buffers that are buried (i.e. not visible)"
(let* ((buffers (or buffer-list (narf/get-buffers)))
(let* ((buffers (or buffer-list (doom/get-buffers)))
(old-len (length buffers)))
(-remove 'get-buffer-window buffers)))
;;;###autoload
(defun narf/get-matching-buffers (pattern &optional buffer-list)
(defun doom/get-matching-buffers (pattern &optional buffer-list)
"Get a list of buffers that match the pattern"
(--filter (string-match-p pattern (buffer-name it))
(or buffer-list (narf/get-buffers))))
(or buffer-list (doom/get-buffers))))
;;;###autoload
(defun narf/get-buffers-in-modes (modes &optional buffer-list)
(defun doom/get-buffers-in-modes (modes &optional buffer-list)
"Get a list of buffers whose major-mode is one of MODES"
(--filter (with-current-buffer it (memq major-mode modes))
(or buffer-list (narf/get-buffers))))
(or buffer-list (doom/get-buffers))))
;;;###autoload
(defun narf/get-real-buffers (&optional buffer-list)
(-filter #'narf/real-buffer-p (or buffer-list (narf/get-buffers))))
(defun doom/get-real-buffers (&optional buffer-list)
(-filter #'doom/real-buffer-p (or buffer-list (doom/get-buffers))))
;;;###autoload
(defun narf/kill-real-buffer ()
(defun doom/kill-real-buffer ()
"Kill buffer (but only bury scratch buffer), then switch to a real buffer. Only buries
the buffer if it is being displayed in another window."
(interactive)
(let (new-dir)
(if (string-match-p "^\\*scratch\\*" (or (buffer-name) ""))
(message "Already in the scratch buffer")
(setq new-dir (narf/project-root))
(if (string-match-p doom-buffer-name (or (buffer-name) ""))
(progn
(doom-mode-init t)
(message "Already in the scratch buffer"))
(setq new-dir (doom/project-root))
(if (> (length (get-buffer-window-list (current-buffer) nil t)) 1)
(bury-buffer)
(kill-this-buffer)))
(if (narf/popup-p (selected-window))
(narf/popup-close)
(unless (narf/real-buffer-p (current-buffer))
(narf/previous-real-buffer)
(narf|update-scratch-buffer-cwd new-dir)))))
(kill-this-buffer))
(if (doom/popup-p (selected-window))
(doom/popup-close)
(unless (doom/real-buffer-p (current-buffer))
(doom/previous-real-buffer)
(doom|update-scratch-buffer-cwd new-dir))))))
;;;###autoload
(defun narf/kill-unreal-buffers ()
"Kill all buried, unreal buffers in current frame. See `narf-unreal-buffers'"
(defun doom/kill-unreal-buffers ()
"Kill all buried, unreal buffers in current frame. See `doom-unreal-buffers'"
(interactive)
(let* ((all-buffers (narf/get-buffers))
(real-buffers (narf/get-real-buffers all-buffers))
(let* ((all-buffers (doom/get-buffers))
(real-buffers (doom/get-real-buffers all-buffers))
(kill-list (--filter (not (memq it real-buffers))
(narf/get-buried-buffers all-buffers))))
(doom/get-buried-buffers all-buffers))))
(mapc 'kill-buffer kill-list)
(narf/kill-process-buffers)
(doom/kill-process-buffers)
(message "Cleaned up %s buffers" (length kill-list))))
;;;###autoload
(defun narf/kill-process-buffers ()
(defun doom/kill-process-buffers ()
"Kill all buffers that represent running processes and aren't visible."
(interactive)
(let ((buffer-list (narf/get-buffers))
(let ((buffer-list (doom/get-buffers))
(killed-processes 0))
(dolist (p (process-list))
(let* ((process-name (process-name p))
(assoc (assoc process-name narf-cleanup-processes-alist)))
(assoc (assoc process-name doom-cleanup-processes-alist)))
(when (and assoc
(not (string= process-name "server"))
(process-live-p p)
@ -145,23 +147,23 @@ the buffer if it is being displayed in another window."
(message "Cleaned up %s processes" killed-processes)))
;;;###autoload
(defun narf/kill-matching-buffers (regexp &optional buffer-list)
(defun doom/kill-matching-buffers (regexp &optional buffer-list)
(interactive)
(let ((i 0))
(mapc (lambda (b)
(when (string-match-p regexp (buffer-name b))
(kill-buffer b)
(setq i (1+ i))))
(if buffer-list buffer-list (narf/get-buffers)))
(if buffer-list buffer-list (doom/get-buffers)))
(message "Killed %s matches" i)))
;;;###autoload
(defun narf/cycle-real-buffers (&optional n)
(defun doom/cycle-real-buffers (&optional n)
"Switch to the previous buffer and avoid special buffers. If there's nothing
left, create a scratch buffer."
(let* ((start-buffer (current-buffer))
(move-func (if (< n 0) 'switch-to-next-buffer 'switch-to-prev-buffer))
(real-buffers (narf/get-real-buffers))
(real-buffers (doom/get-real-buffers))
(realc (length real-buffers))
(max 25)
(i 0)
@ -169,16 +171,16 @@ left, create a scratch buffer."
(if (or (= realc 0)
(and (= realc 1) (eq (car real-buffers) (current-buffer))))
(progn
(narf|update-scratch-buffer-cwd)
(switch-to-buffer "*scratch*")
(doom|update-scratch-buffer-cwd)
(switch-to-buffer doom-buffer-name)
(message "Nowhere to go"))
(funcall move-func)
(while (and continue)
(let ((current-buffer (current-buffer)))
(cond ((or (eq current-buffer start-buffer)
(>= i max))
(narf|update-scratch-buffer-cwd)
(switch-to-buffer "*scratch*")
(doom|update-scratch-buffer-cwd)
(switch-to-buffer doom-buffer-name)
(setq continue nil))
((not (memq current-buffer real-buffers))
(funcall move-func))
@ -187,70 +189,70 @@ left, create a scratch buffer."
(cl-incf i)))))
;;;###autoload
(defun narf/real-buffer-p (&optional buffer-or-name)
(defun doom/real-buffer-p (&optional buffer-or-name)
(let ((buffer (if buffer-or-name (get-buffer buffer-or-name) (current-buffer))))
(when (buffer-live-p buffer)
(not (--any? (if (stringp it)
(string-match-p it (buffer-name buffer))
(eq (buffer-local-value 'major-mode buffer) it))
narf-unreal-buffers)))))
doom-unreal-buffers)))))
;; Inspired by spacemacs <https://github.com/syl20bnr/spacemacs/blob/master/spacemacs/funcs.el>
;;;###autoload
(defun narf/next-real-buffer ()
(defun doom/next-real-buffer ()
"Switch to the next buffer and avoid special buffers."
(interactive)
(narf/cycle-real-buffers +1))
(doom/cycle-real-buffers +1))
;;;###autoload
(defun narf/previous-real-buffer ()
(defun doom/previous-real-buffer ()
"Switch to the previous buffer and avoid special buffers."
(interactive)
(narf/cycle-real-buffers -1))
(doom/cycle-real-buffers -1))
(defun narf--kill-buffers (buffers &optional filter-func)
(defun doom--kill-buffers (buffers &optional filter-func)
(let ((buffers (if filter-func (-filter filter-func buffers) buffers))
(affected 0))
(mapc (lambda (b) (when (kill-buffer b) (incf affected))) buffers)
(unless (narf/real-buffer-p)
(narf/previous-real-buffer))
(unless (doom/real-buffer-p)
(doom/previous-real-buffer))
(message "Killed %s buffers" affected)))
;;;###autoload (autoload 'narf:kill-all-buffers "defuns-buffers" nil t)
(evil-define-command narf:kill-all-buffers (&optional bang)
;;;###autoload (autoload 'doom:kill-all-buffers "defuns-buffers" nil t)
(evil-define-command doom:kill-all-buffers (&optional bang)
"Kill all project buffers. If BANG, kill *all* buffers (in workgroup)."
(interactive "<!>")
(narf--kill-buffers (narf/get-buffers (not bang)))
(mapc (lambda (w) (when (eq (window-buffer w) (get-buffer "*scratch*"))
(doom--kill-buffers (doom/get-buffers (not bang)))
(mapc (lambda (w) (when (eq (window-buffer w) doom-buffer)
(delete-window w)))
(narf/get-visible-windows)))
(doom/get-visible-windows)))
;;;###autoload (autoload 'narf:kill-other-buffers "defuns-buffers" nil t)
(evil-define-command narf:kill-other-buffers (&optional bang)
;;;###autoload (autoload 'doom:kill-other-buffers "defuns-buffers" nil t)
(evil-define-command doom:kill-other-buffers (&optional bang)
"Kill all other project buffers. If BANG, kill *all* other buffers (in workgroup)."
(interactive "<!>")
(narf--kill-buffers (narf/get-buffers (not bang))
(doom--kill-buffers (doom/get-buffers (not bang))
(lambda (b) (not (eq b (current-buffer)))))
(when bang
(delete-other-windows)))
;;;###autoload (autoload 'narf:kill-buried-buffers "defuns-buffers" nil t)
(evil-define-command narf:kill-buried-buffers (&optional bang)
;;;###autoload (autoload 'doom:kill-buried-buffers "defuns-buffers" nil t)
(evil-define-command doom:kill-buried-buffers (&optional bang)
"Kill buried project buffers (in workgroup) and report how many it found. BANG = get all
buffers regardless of project."
(interactive "<!>")
(narf--kill-buffers (narf/get-buried-buffers (narf/get-buffers (not bang)))))
(doom--kill-buffers (doom/get-buried-buffers (doom/get-buffers (not bang)))))
;;;###autoload (autoload 'narf:kill-buried-buffers "defuns-buffers" nil t)
(evil-define-command narf:kill-matching-buffers (&optional bang pattern)
;;;###autoload (autoload 'doom:kill-buried-buffers "defuns-buffers" nil t)
(evil-define-command doom:kill-matching-buffers (&optional bang pattern)
"Kill project buffers matching regex pattern PATTERN. If BANG, then extend search to
buffers regardless of project."
:repeat nil
(interactive "<!><a>")
(narf-kill-buffers (narf/get-matching-buffers pattern (narf/get-buffers (not bang)))))
(doom-kill-buffers (doom/get-matching-buffers pattern (doom/get-buffers (not bang)))))
;;;###autoload (autoload 'narf:send-to-scratch-or-org "defuns-buffers" nil t)
(evil-define-operator narf:send-to-scratch-or-org (&optional beg end bang)
;;;###autoload (autoload 'doom:send-to-scratch-or-org "defuns-buffers" nil t)
(evil-define-operator doom:send-to-scratch-or-org (&optional beg end bang)
"Send a selection to the scratch buffer. If BANG, then send it to org-capture instead."
:move-point nil
:type inclusive
@ -261,9 +263,9 @@ buffers regardless of project."
(if bang
(org-capture-string text)
;; or scratch buffer by default
(let* ((project-dir (narf/project-root t))
(buffer-name "*scratch*"))
(narf/popup-buffer buffer-name)
(let* ((project-dir (doom/project-root t))
(buffer-name doom-buffer-name))
(doom/popup-buffer buffer-name)
(with-current-buffer buffer-name
(when project-dir
(cd project-dir))
@ -271,19 +273,19 @@ buffers regardless of project."
(funcall mode))
))))
;;;###autoload (autoload 'narf:cd "defuns-buffers" nil t)
(evil-define-command narf:cd (dir)
;;;###autoload (autoload 'doom:cd "defuns-buffers" nil t)
(evil-define-command doom:cd (dir)
"Ex-command alias for `cd'"
:repeat nil
(interactive "<f>")
(cd (if (zerop (length dir)) "~" dir)))
;;;###autoload
(defun narf/kill-all-buffers-do-not-remember ()
(defun doom/kill-all-buffers-do-not-remember ()
"Kill all buffers so that workgroups2 will wipe its current session."
(interactive)
(let ((confirm-kill-emacs nil))
(mapc 'kill-buffer (narf/get-buffers))
(mapc 'kill-buffer (doom/get-buffers))
(kill-this-buffer)
(delete-other-windows)
(wg-save-session t)

View file

@ -1,13 +1,13 @@
;;; defuns-company.el
;;;###autoload
(defun narf/company-evil-complete-next (&optional arg)
(defun doom/company-evil-complete-next (&optional arg)
(call-interactively 'company-dabbrev)
(if (eq company-candidates-length 1)
(company-complete)))
;;;###autoload
(defun narf/company-evil-complete-previous (&optional arg)
(defun doom/company-evil-complete-previous (&optional arg)
(let ((company-selection-wrap-around t))
(call-interactively 'company-dabbrev)
(if (eq company-candidates-length 1)
@ -15,7 +15,7 @@
(call-interactively 'company-select-previous))))
;;;###autoload
(defun narf/company-complete-common-or-complete-full ()
(defun doom/company-complete-common-or-complete-full ()
(interactive)
(when (company-manual-begin)
(if (eq last-command #'company-complete-common-or-cycle)
@ -27,7 +27,7 @@
(call-interactively #'company-complete-selection)
(call-interactively #'company-complete))))))
(defun narf--company-whole-lines ()
(defun doom--company-whole-lines ()
(split-string
(replace-regexp-in-string
"^[\t\s]+" ""
@ -36,22 +36,22 @@
"\\(\r\n\\|[\n\r]\\)" t))
;;;###autoload
(defun narf/company-whole-lines (command &optional arg &rest ignored)
(defun doom/company-whole-lines (command &optional arg &rest ignored)
(interactive (list 'interactive))
(let ((lines (narf--company-whole-lines)))
(let ((lines (doom--company-whole-lines)))
(cl-case command
(interactive (company-begin-backend 'narf/company-whole-lines))
(interactive (company-begin-backend 'doom/company-whole-lines))
(prefix (company-grab-line "^[\t\s]*\\(.+\\)" 1))
(candidates (all-completions arg lines)))))
;;;###autoload
(defun narf/company-dict-or-keywords ()
(defun doom/company-dict-or-keywords ()
(interactive)
(let ((company-backends '((company-keywords company-dict))))
(call-interactively 'company-complete)))
;;;###autoload
(defun narf/company-complete ()
(defun doom/company-complete ()
"Bring up the completion popup. If there is only one result, auto-complete it."
(interactive)
(when (and (company-manual-begin)

View file

@ -1,15 +1,15 @@
;;; defuns-dash.el --- Dash.app integration
;;;###autoload
(defun narf/dash-at-pt ()
(defun doom/dash-at-pt ()
(interactive)
(if (evil-visual-state-p)
(dash-at-point-run-search (buffer-substring-no-properties (region-beginning) (region-end))
(dash-at-point-guess-docset))
(dash-at-point)))
;;;###autoload (autoload 'narf:dash "defuns-dash" nil t)
(evil-define-command narf:dash (bang input)
;;;###autoload (autoload 'doom:dash "defuns-dash" nil t)
(evil-define-command doom:dash (bang input)
(interactive "<!><a>")
(let ((docset (unless bang (dash-at-point-guess-docset)))
(query input))

View file

@ -28,22 +28,22 @@
(interactive)
(message "Mode: %s" major-mode))
;;;###autoload (autoload 'narf:echo "defuns-debug" nil t)
(evil-define-command narf:echo (bang message)
;;;###autoload (autoload 'doom:echo "defuns-debug" nil t)
(evil-define-command doom:echo (bang message)
"Display MSG in echo-area without logging it in *Messages* buffer."
(interactive "<!><a>")
(let (message-log-max)
(message "%s%s" (if bang ">> " "") message)))
;;;###autoload (autoload 'narf:debug "defuns-debug" nil t)
(evil-define-command narf:debug (&optional path)
;;;###autoload (autoload 'doom:debug "defuns-debug" nil t)
(evil-define-command doom:debug (&optional path)
"Initiate debugger for current major mode"
(interactive "<f>")
(let ((default-directory (narf/project-root)))
(let ((default-directory (doom/project-root)))
(cond ((memq major-mode '(c-mode c++-mode))
(realgud:gdb (if path (concat "gdb " path))))
((memq major-mode '(ruby-mode enh-ruby-mode))
(narf:repl nil (format "run '%s'" (f-filename (or path buffer-file-name)))))
(doom:repl nil (format "run '%s'" (f-filename (or path buffer-file-name)))))
((eq major-mode 'sh-mode)
(let ((shell sh-shell))
(when (string= shell "sh")
@ -60,16 +60,16 @@
(haskell-debug))
(t (user-error "No debugger for %s" major-mode)))))
;;;###autoload (autoload 'narf:debug-toggle-breakpoint "defuns-debug" nil t)
(evil-define-command narf:debug-toggle-breakpoint (&optional bang)
;;;###autoload (autoload 'doom:debug-toggle-breakpoint "defuns-debug" nil t)
(evil-define-command doom:debug-toggle-breakpoint (&optional bang)
(interactive "<!>")
(call-interactively (if bang 'realgud:cmd-clear 'realgud:cmd-break)))
;;;###autoload
(defun narf/debug-quit ()
(defun doom/debug-quit ()
(interactive)
(ignore-errors (call-interactively 'realgud:cmd-quit))
(narf/popup-close)
(doom/popup-close)
(evil-normal-state))
(provide 'defuns-debug)

View file

@ -3,7 +3,7 @@
(defvar *linum-mdown-line* nil)
(defun narf--line-at-click ()
(defun doom--line-at-click ()
(save-excursion
(let ((click-y (cdr (cdr (mouse-position))))
(line-move-visual-store line-move-visual))
@ -16,18 +16,18 @@
(1+ (line-number-at-pos)))))
;;;###autoload
(defun narf/mouse-drag-line ()
(defun doom/mouse-drag-line ()
(interactive)
(goto-line (narf--line-at-click))
(goto-line (doom--line-at-click))
(set-mark (point))
(setq *linum-mdown-line* (line-number-at-pos)))
;;;###autoload
(defun narf/mouse-select-line ()
(defun doom/mouse-select-line ()
(interactive)
(when *linum-mdown-line*
(let (mu-line)
(setq mu-line (narf--line-at-click))
(setq mu-line (doom--line-at-click))
(goto-line *linum-mdown-line*)
(if (> mu-line *linum-mdown-line*)
(progn
@ -40,12 +40,12 @@
(setq *linum-mdown-line* nil))))
;;;###autoload
(defun narf*load-hs-minor-mode ()
(defun doom*load-hs-minor-mode ()
(hs-minor-mode 1)
(advice-remove 'evil-toggle-fold 'narf-load-hs-minor-mode))
(advice-remove 'evil-toggle-fold 'doom-load-hs-minor-mode))
;;;###autoload
(defun narf/reselect-paste ()
(defun doom/reselect-paste ()
(interactive)
(evil-goto-mark ?\[)
(evil-visual-state)

View file

@ -1,6 +1,6 @@
;;; defuns-embrace.el
(defun narf--embrace-get-pair (char)
(defun doom--embrace-get-pair (char)
(acond ((cdr-safe (assoc (string-to-char char) evil-surround-pairs-alist))
`(,(car it) . ,(cdr it)))
((assoc-default char embrace--pairs-list)
@ -11,23 +11,23 @@
(t `(,char . ,char))))
;;;###autoload
(defun narf/embrace-escaped ()
(defun doom/embrace-escaped ()
"Escaped surround characters."
(let ((char (read-char "\\")))
(if (eq char 27)
(cons "" "")
(let ((pair (narf--embrace-get-pair (string char)))
(let ((pair (doom--embrace-get-pair (string char)))
(text (if (sp-point-in-string) "\\\\%s" "\\%s")))
(cons (format text (car pair))
(format text (cdr pair)))))))
;;;###autoload
(defun narf/embrace-latex ()
(defun doom/embrace-latex ()
"LaTeX commands"
(cons (format "\\%s{" (read-string "\\")) "}"))
;;;###autoload
(defun narf/embrace-elisp-fn ()
(defun doom/embrace-elisp-fn ()
(cons (format "(%s " (or (read-string "(") "")) ")"))
(provide 'defuns-embrace)

View file

@ -1,49 +1,48 @@
;;; defuns-evil.el
;; for ../core-evil.el
;;;###autoload (autoload 'narf:evil-open-folds "defuns-evil" nil t)
(evil-define-command narf/evil-open-folds (count)
;;;###autoload (autoload 'doom:evil-open-folds "defuns-evil" nil t)
(evil-define-command doom/evil-open-folds (count)
"Instead of `evil-open-folds'. Accepts COUNT for dictating fold level."
(interactive "P")
(unless (bound-and-true-p hs-minor-mode)
(hs-minor-mode 1))
(if count (hs-hide-level count) (evil-open-folds)))
;;;###autoload (autoload 'narf:evil-open-folds "defuns-evil" nil t)
(evil-define-command narf/evil-close-folds (count)
;;;###autoload (autoload 'doom:evil-open-folds "defuns-evil" nil t)
(evil-define-command doom/evil-close-folds (count)
"Instead of `evil-close-folds'. Accepts COUNT for dictating fold level."
(interactive "P")
(unless (bound-and-true-p hs-minor-mode)
(hs-minor-mode 1))
(if count (hs-hide-level count) (evil-close-folds)))
;;;###autoload (autoload 'narf/multi-next-line "defuns-evil" nil t)
(evil-define-motion narf/multi-next-line (count)
;;;###autoload (autoload 'doom/multi-next-line "defuns-evil" nil t)
(evil-define-motion doom/multi-next-line (count)
"Move down 6 lines"
:type line
(let ((line-move-visual visual-line-mode))
(evil-line-move (* 6 (or count 1)))))
;;;###autoload (autoload 'narf/multi-previous-line "defuns-evil" nil t)
(evil-define-motion narf/multi-previous-line (count)
;;;###autoload (autoload 'doom/multi-previous-line "defuns-evil" nil t)
(evil-define-motion doom/multi-previous-line (count)
"Move up 6 lines"
:type line
(let ((line-move-visual visual-line-mode))
(evil-line-move (- (* 6 (or count 1))))))
;;;###autoload
(defun narf/evil-visual-line-state-p ()
(defun doom/evil-visual-line-state-p ()
"Returns non-nil if in visual-line mode, nil otherwise."
(and (evil-visual-state-p)
(eq (evil-visual-type) 'line)))
;;;###autoload
(defun narf*evil-exchange-off ()
(defun doom*evil-exchange-off ()
(when evil-exchange--overlays
(evil-exchange-cancel)))
;;;###autoload (autoload 'narf/evil-macro-on-all-lines "defuns-evil" nil t)
(evil-define-operator narf/evil-macro-on-all-lines (beg end &optional macro)
;;;###autoload (autoload 'doom/evil-macro-on-all-lines "defuns-evil" nil t)
(evil-define-operator doom/evil-macro-on-all-lines (beg end &optional macro)
"Apply macro to each line."
:motion nil
:move-point nil
@ -57,8 +56,8 @@
(or macro (read-char "@-"))))))
;;; Custom argument handlers
(defvar narf-buffer-match-global evil-ex-substitute-global "")
(defun narf--evil-ex-match-init (name &optional face update-hook)
(defvar doom-buffer-match-global evil-ex-substitute-global "")
(defun doom--evil-ex-match-init (name &optional face update-hook)
(with-current-buffer evil-ex-current-buffer
(cond
((eq flag 'start)
@ -70,7 +69,7 @@
((eq flag 'stop)
(evil-ex-delete-hl name)))))
(defun narf--evil-ex-buffer-match (arg &optional hl-name flags beg end)
(defun doom--evil-ex-buffer-match (arg &optional hl-name flags beg end)
(when (and (eq flag 'update)
evil-ex-substitute-highlight-all
(not (zerop (length arg))))
@ -94,22 +93,22 @@
(evil-ex-pattern-update-ex-info nil (format "?%s" lossage))))))
;;;###autoload
(defun narf/evil-ex-buffer-match (flag &optional arg)
(defun doom/evil-ex-buffer-match (flag &optional arg)
(let ((hl-name 'evil-ex-buffer-match))
(with-selected-window (minibuffer-selected-window)
(narf--evil-ex-match-init hl-name)
(narf--evil-ex-buffer-match arg hl-name (list (if narf-buffer-match-global ?g))))))
(doom--evil-ex-match-init hl-name)
(doom--evil-ex-buffer-match arg hl-name (list (if doom-buffer-match-global ?g))))))
;;;###autoload
(defun narf/evil-ex-global-match (flag &optional arg)
(defun doom/evil-ex-global-match (flag &optional arg)
(let ((hl-name 'evil-ex-global-match))
(with-selected-window (minibuffer-selected-window)
(narf--evil-ex-match-init hl-name)
(doom--evil-ex-match-init hl-name)
(let ((result (car-safe (evil-ex-parse-global arg))))
(narf--evil-ex-buffer-match result hl-name nil (point-min) (point-max))))))
(doom--evil-ex-buffer-match result hl-name nil (point-min) (point-max))))))
;;;###autoload
(defun narf/evil-ex-undefine-cmd (cmd)
(defun doom/evil-ex-undefine-cmd (cmd)
(if (string-match "^[^][]*\\(\\[\\(.*\\)\\]\\)[^][]*$" cmd)
(let ((abbrev (replace-match "" nil t cmd 1))
(full (replace-match "\\2" nil nil cmd 1)))
@ -117,10 +116,10 @@
(setq evil-ex-commands (delq (assoc abbrev evil-ex-commands) evil-ex-commands)))
(setq evil-ex-commands (delq (assoc cmd evil-ex-commands) evil-ex-commands))))
(defvar narf:map-maps '())
(defvar doom:map-maps '())
;;;###autoload (autoload 'narf:map "defuns-evil" nil t)
(evil-define-command narf:map (bang input &optional mode)
;;;###autoload (autoload 'doom:map "defuns-evil" nil t)
(evil-define-command doom:map (bang input &optional mode)
"Map ex commands to keybindings. INPUT should be in the format [KEY] [EX COMMAND]."
(interactive "<!><a>")
(let* ((parts (s-split-up-to " " input 2 t))
@ -138,31 +137,31 @@
(evil-define-key mode nil key fn)
(define-key map key fn))))
;;;###autoload (autoload 'narf:nmap "defuns-evil" nil t)
(evil-define-command narf:nmap (bang input &optional mode)
(interactive "<!><a>") (narf:map bang input 'normal))
;;;###autoload (autoload 'doom:nmap "defuns-evil" nil t)
(evil-define-command doom:nmap (bang input &optional mode)
(interactive "<!><a>") (doom:map bang input 'normal))
;;;###autoload (autoload 'narf:imap "defuns-evil" nil t)
(evil-define-command narf:imap (bang input &optional mode)
(interactive "<!><a>") (narf:map bang input 'insert))
;;;###autoload (autoload 'doom:imap "defuns-evil" nil t)
(evil-define-command doom:imap (bang input &optional mode)
(interactive "<!><a>") (doom:map bang input 'insert))
;;;###autoload (autoload 'narf:vmap "defuns-evil" nil t)
(evil-define-command narf:vmap (bang input &optional mode)
(interactive "<!><a>") (narf:map bang input 'visual))
;;;###autoload (autoload 'doom:vmap "defuns-evil" nil t)
(evil-define-command doom:vmap (bang input &optional mode)
(interactive "<!><a>") (doom:map bang input 'visual))
;;;###autoload (autoload 'narf:mmap "defuns-evil" nil t)
(evil-define-command narf:mmap (bang input &optional mode)
(interactive "<!><a>") (narf:map bang input 'motion))
;;;###autoload (autoload 'doom:mmap "defuns-evil" nil t)
(evil-define-command doom:mmap (bang input &optional mode)
(interactive "<!><a>") (doom:map bang input 'motion))
;;;###autoload (autoload 'narf:omap "defuns-evil" nil t)
(evil-define-command narf:omap (bang input &optional mode)
(interactive "<!><a>") (narf:map bang input 'operator))
;;;###autoload (autoload 'doom:omap "defuns-evil" nil t)
(evil-define-command doom:omap (bang input &optional mode)
(interactive "<!><a>") (doom:map bang input 'operator))
;;;###autoload
(defun narf/evil-snipe-easymotion ()
(defun doom/evil-snipe-easymotion ()
(interactive)
(require 'evil-easymotion)
(call-interactively narf--evil-snipe-repeat-fn))
(call-interactively doom--evil-snipe-repeat-fn))
(provide 'defuns-evil)
;;; defuns-evil.el ends here

View file

@ -1,7 +1,7 @@
;;; defuns-file.el
;;;###autoload (autoload 'narf:file-delete "defuns-file" nil t)
(evil-define-command narf:file-delete (&optional bang filename)
;;;###autoload (autoload 'doom:file-delete "defuns-file" nil t)
(evil-define-command doom:file-delete (&optional bang filename)
"Delete current buffer's file. If bang, then kill the buffer afterwards as well."
:repeat nil
(interactive "<!><f>")
@ -14,18 +14,18 @@
(mapc (lambda (file)
(when (file-exists-p file)
(delete-file file t)))
(narf/org-attachments)))
(doom/org-attachments)))
(set-buffer-modified-p nil)
(delete-file filename)
(kill-this-buffer)
(unless (narf/real-buffer-p)
(narf/previous-real-buffer))
(unless (doom/real-buffer-p)
(doom/previous-real-buffer))
(save-place-forget-unreadable-files)
(message "File successfully deleted: %s" filename)))))
(defun narf--save-exit() (save-buffer) (kill-buffer) (remove-hook 'yas-after-exit-snippet-hook '--save-exit))
;;;###autoload (autoload 'narf:file-create "defuns-file" nil t)
(evil-define-command narf:file-create (path &optional bang)
(defun doom--save-exit() (save-buffer) (kill-buffer) (remove-hook 'yas-after-exit-snippet-hook '--save-exit))
;;;###autoload (autoload 'doom:file-create "defuns-file" nil t)
(evil-define-command doom:file-create (path &optional bang)
"Deploy files (and their associated templates) quickly. Will prompt
you to fill in each snippet field before buffer closes unless BANG is
provided."
@ -40,12 +40,12 @@ provided."
(if (f-exists? fullpath)
(error "File already exists: %s" path)
(find-file fullpath)
(add-hook 'yas-after-exit-snippet-hook 'narf--save-exit)
(if bang (narf--save-exit)))
(add-hook 'yas-after-exit-snippet-hook 'doom--save-exit)
(if bang (doom--save-exit)))
(error "Directory doesn't exist: %s" dir))))
;;;###autoload (autoload 'narf:file-move "defuns-file" nil t)
(evil-define-command narf:file-move (path)
;;;###autoload (autoload 'doom:file-move "defuns-file" nil t)
(evil-define-command doom:file-move (path)
"Move current buffer's file to PATH. Replaces %, # and other variables (see
`evil-ex-replace-special-filenames')"
:repeat nil
@ -56,13 +56,13 @@ provided."
((f-dir? (f-dirname path))
(f-full path))
(t (user-error "Not a valid destination: %s" path))))
(project-root (narf/project-root)))
(project-root (doom/project-root)))
;; Move all attachments if in org-mode
(when (eq major-mode 'org-mode)
(mapc (lambda (file)
(when (and (file-exists-p file) (not (f-same? old-path new-path)))
(rename-file file (f-expand (f-filename old-path) (f-dirname new-path)) t)))
(narf/org-attachments)))
(doom/org-attachments)))
(when (buffer-modified-p)
(save-buffer))
(rename-file old-path new-path 1)
@ -70,7 +70,7 @@ provided."
(set-visited-file-name new-path)
(set-buffer-modified-p nil)
(save-place-forget-unreadable-files)
(setq narf--spaceline-file-path nil)
(setq doom--spaceline-file-path nil)
(message "File '%s' successfully renamed to '%s'"
(f-relative old-path project-root) (f-relative new-path project-root))))

View file

@ -2,12 +2,12 @@
;; for ../core-flycheck.el
;;;###autoload
(defun narf*flycheck-buffer ()
(defun doom*flycheck-buffer ()
(when (bound-and-true-p flycheck-mode)
(flycheck-buffer)))
;;;###autoload
(defun narf/flycheck-next-error ()
(defun doom/flycheck-next-error ()
(interactive)
(call-interactively
(if (bound-and-true-p flycheck-mode)
@ -15,7 +15,7 @@
'next-error)))
;;;###autoload
(defun narf/flycheck-previous-error ()
(defun doom/flycheck-previous-error ()
(interactive)
(call-interactively
(if (bound-and-true-p flycheck-mode)
@ -23,7 +23,7 @@
'previous-error)))
;;;###autoload
(defun narf/flycheck-errors ()
(defun doom/flycheck-errors ()
(interactive)
(when (bound-and-true-p flycheck-mode)
(flycheck-buffer)

View file

@ -1,7 +1,7 @@
;;; defuns-git.el
;;;### (autoload 'narf/git-remote-browse "defuns-git" nil t)
(evil-define-command narf:git-remote-browse (&optional bang)
;;;### (autoload 'doom:git-remote-browse "defuns-git" nil t)
(evil-define-command doom:git-remote-browse (&optional bang)
"Open the website for the current (or specified) version controlled FILE. If BANG,
then use hub to do it."
(interactive "<!>")
@ -11,7 +11,7 @@ then use hub to do it."
(error
(setq url (shell-command-to-string "hub browse -u --"))
(setq url (if url
(concat (s-trim url) "/" (f-relative (buffer-file-name) (narf/project-root))
(concat (s-trim url) "/" (f-relative (buffer-file-name) (doom/project-root))
(when (use-region-p) (format "#L%s-L%s"
(line-number-at-pos (region-beginning))
(line-number-at-pos (region-end)))))))))

View file

@ -1,8 +1,7 @@
;;; defuns-helm.el
;; see ../core-helm.el
;;;###autoload (autoload 'narf:helm-recentf "defuns-helm" nil t)
(evil-define-command narf:helm-recentf (&optional bang)
;;;###autoload (autoload 'doom:helm-recentf "defuns-helm" nil t)
(evil-define-command doom:helm-recentf (&optional bang)
"Ex-mode interface for `helm-recentf' and `helm-projectile-recentf'. If
`bang', then `search' is interpreted as regexp."
:repeat nil
@ -11,8 +10,8 @@
;; Ex-mode interface for `helm-ag'. If `bang', then `search' is interpreted as
;; regexp.
;;;###autoload (autoload 'narf:helm-ag-search "defuns-helm" nil t)
(evil-define-operator narf:helm-ag-search (beg end search regex-p &optional dir)
;;;###autoload (autoload 'doom:helm-ag-search "defuns-helm" nil t)
(evil-define-operator doom:helm-ag-search (beg end search regex-p &optional dir)
"Preform an helm-ag search with SEARCH. If SEARCH is nil and in visual mode, use the
selection, otherwise activate live ag searching in helm.
@ -22,7 +21,7 @@ DIR specifies the default-directory from which ag is run."
:repeat nil
(interactive "<r><a><!>")
(require 'helm-ag)
(let* ((helm-ag--default-directory (or dir (f-slash (narf/project-root))))
(let* ((helm-ag--default-directory (or dir (f-slash (doom/project-root))))
(helm-ag-command-option (unless regex-p "-Q "))
(input "")
(header-name (format "Search in %s" helm-ag--default-directory)))
@ -40,56 +39,56 @@ DIR specifies the default-directory from which ag is run."
;; Ex-mode interface for `helm-do-ag'. If `bang', then `search' is interpreted
;; as regexp
;;;###autoload (autoload 'narf:helm-ag-search-cwd "defuns-helm" nil t)
(evil-define-operator narf:helm-ag-search-cwd (beg end &optional search bang)
;;;###autoload (autoload 'doom:helm-ag-search-cwd "defuns-helm" nil t)
(evil-define-operator doom:helm-ag-search-cwd (beg end &optional search bang)
:type inclusive :repeat nil
(interactive "<r><a><!>")
(narf:helm-ag-search beg end search bang default-directory))
(doom:helm-ag-search beg end search bang default-directory))
;; Ex-mode interface for `helm-swoop', `helm-multi-swoop-all' (if `bang'), or
;; `helm-css-scss' and `helm-css-scss-multi' (if `bang') if major-mode is
;; `scss-mode'
;;;###autoload (autoload 'narf:helm-swoop "defuns-helm" nil t)
(evil-define-command narf:helm-swoop (&optional search bang)
;;;###autoload (autoload 'doom:helm-swoop "defuns-helm" nil t)
(evil-define-command doom:helm-swoop (&optional search bang)
:repeat nil
(interactive "<a><!>")
(if bang (helm-multi-swoop-all search) (helm-swoop :$query search)))
;;;###autoload
(defun narf/helm-find-in-emacsd ()
(defun doom/helm-find-in-emacsd ()
(interactive)
(in! narf-emacs-dir (helm-projectile-find-file)))
(in! doom-emacs-dir (helm-projectile-find-file)))
;;;###autoload
(defun narf/helm-find-in-dotfiles ()
(defun doom/helm-find-in-dotfiles ()
(interactive)
(in! (expand-file-name ".dotfiles" "~") (helm-projectile-find-file)))
;;;###autoload
(defun narf/helm-buffers-dwim (&optional all-p)
(defun doom/helm-buffers-dwim (&optional all-p)
"Displays open buffers in current project. If ALL-P, then show all open
buffers."
(interactive)
(let ((narf-helm-force-project-buffers (and (not all-p) (narf/project-p))))
(let ((doom-helm-force-project-buffers (and (not all-p) (doom/project-p))))
(helm-buffers-list)))
;;;###autoload
(defun narf*helm-replace-prompt (plist)
(defun doom*helm-replace-prompt (plist)
(if (keywordp (car plist))
(setq plist (plist-put plist :prompt helm-global-prompt))
(setcar (nthcdr 2 plist) helm-global-prompt))
plist)
;;;###autoload
(defun narf*helm-hide-header (source &optional force)
(defun doom*helm-hide-header (source &optional force)
(setq header-line-format nil)
(narf|hide-mode-line))
(doom|hide-mode-line))
;;;###autoload
(defun narf*helm-hide-source-header-maybe ()
(defun doom*helm-hide-source-header-maybe ()
(if (<= (length helm-sources) 1)
(set-face-attribute 'helm-source-header nil :height 0.1 :foreground "#111111")
(set-face-attribute 'helm-source-header nil :height 1.0 :foreground narf-helm-header-fg)))
(set-face-attribute 'helm-source-header nil :height 1.0 :foreground doom-helm-header-fg)))
(provide 'defuns-helm)
;;; defuns-helm.el ends here

View file

@ -1,7 +1,7 @@
;;; defuns-highlight-indentation.el
;;;###autoload
(defun narf/add-whitespace (&optional start end)
(defun doom/add-whitespace (&optional start end)
"Maintain indentation whitespace in buffer. Used so that highlight-indentation will
display consistent guides. Whitespace is stripped out on save, so this doesn't affect the
end file."
@ -38,7 +38,7 @@ end file."
nil)
;;;###autoload
(defun narf*hl-indent-guess-offset ()
(defun doom*hl-indent-guess-offset ()
(string-to-int (gethash 'indent_size (editorconfig-get-properties))))
(provide 'defuns-highlight-indentation)

View file

@ -1,7 +1,7 @@
;;; defuns-ido.el
;;;###autoload
(defun narf*ido-sort-mtime ()
(defun doom*ido-sort-mtime ()
"Sort ido filelist by mtime instead of alphabetically."
(setq ido-temp-list
(sort ido-temp-list
@ -16,7 +16,7 @@
ido-temp-list))))
;;;###autoload
(defun narf|ido-setup-home-keybind ()
(defun doom|ido-setup-home-keybind ()
"Go to $HOME with ~"
(define-key ido-file-completion-map (kbd "~")
(λ! (if (looking-back "/")
@ -24,37 +24,37 @@
(call-interactively 'self-insert-command)))))
;;;###autoload
(defun narf/ido-find-file (&optional dir)
(defun doom/ido-find-file (&optional dir)
(interactive)
(let ((default-directory (or dir default-directory)))
(ido-find-file)))
;;;###autoload
(defun narf/ido-find-file-other-window (&optional dir)
(defun doom/ido-find-file-other-window (&optional dir)
(interactive)
(let ((default-directory (or dir default-directory)))
(ido-find-file-other-window)))
;;;###autoload
(defun narf/ido-find-project-file ()
(defun doom/ido-find-project-file ()
(interactive)
(let ((default-directory (narf/project-root)))
(let ((default-directory (doom/project-root)))
(ido-find-file)))
;;;###autoload
(defun narf/ido-recentf ()
(defun doom/ido-recentf ()
"Use `ido-completing-read' to \\[find-file] a recent file"
(interactive)
(if (find-file (ido-completing-read "Find recent file: " recentf-list))
(message "Opening file...")
(message "Aborting")))
;;;###autoload (autoload 'narf:ido-find-file-in-emacsd "defuns-ido" nil t)
(evil-define-command narf:ido-find-file-in-emacsd (&optional bang) :repeat nil
;;;###autoload (autoload 'doom:ido-find-file-in-emacsd "defuns-ido" nil t)
(evil-define-command doom:ido-find-file-in-emacsd (&optional bang) :repeat nil
(interactive "<!>")
(if bang
(ido-find-file-in-dir narf-modules-dir)
(ido-find-file-in-dir narf-emacs-dir)))
(ido-find-file-in-dir doom-modules-dir)
(ido-find-file-in-dir doom-emacs-dir)))
(provide 'defuns-ido)
;;; defuns-ido.el ends here

View file

@ -2,7 +2,7 @@
;; for ../core-project.el
;;;###autoload
(defun narf/neotree ()
(defun doom/neotree ()
"Toggle the neotree window"
(interactive)
(let ((in-neotree (and (neo-global--window-exists-p)
@ -11,14 +11,14 @@
(path buffer-file-name))
(if in-neotree
(neotree-hide)
(let ((project-root (narf/project-root)))
(let ((project-root (doom/project-root)))
(unless (and (neo-global--window-exists-p)
(f-same? (neo-global--with-window neo-buffer--start-node) project-root))
(neotree-dir project-root))
(neotree-find path project-root)))))
;;;###autoload
(defmacro narf/neotree-save (&rest body)
(defmacro doom/neotree-save (&rest body)
`(let ((neo-p (neo-global--window-exists-p)))
(when neo-p (neotree-hide))
,@body
@ -27,30 +27,30 @@
(neotree-show)))))
;;;###autoload
(defun narf|neotree-close-on-window-change (&rest _)
(defun doom|neotree-close-on-window-change (&rest _)
"Close neotree to prevent ensuing mindow buggery."
(unless (and (neo-global--window-exists-p)
(eq (current-buffer) (neo-global--get-buffer)))
(neotree-hide)))
;;;###autoload
(defun narf*save-neotree (orig-fun &rest args)
(defun doom*save-neotree (orig-fun &rest args)
"Prevents messing up the neotree buffer on window changes"
(narf/neotree-save (apply orig-fun args)))
(doom/neotree-save (apply orig-fun args)))
;;;###autoload
(defun narf*neotree-create-node (orig-fun &rest args)
(defun doom*neotree-create-node (orig-fun &rest args)
"Don't ask for confirmation when creating files"
(cl-letf (((symbol-function 'yes-or-no-p) (lambda (&rest _) t)))
(apply orig-fun args)))
;;;###autoload
(defun narf*neotree-shorten-pwd (node)
(defun doom*neotree-shorten-pwd (node)
"Shorter pwd in neotree"
(list (concat "" (projectile-project-name))))
;;;###autoload
(defun narf*neo-theme (name)
(defun doom*neo-theme (name)
"Custom hybrid ascii theme with leading whitespace."
(let ((n-insert-symbol (lambda (n)
(neo-buffer--insert-with-face

View file

@ -1,41 +1,41 @@
;;; defuns-nlinum.el
;;;###autoload
(defun narf/nlinum-toggle ()
(defun doom/nlinum-toggle ()
(interactive)
(if (bound-and-true-p nlinum-mode)
(narf|nlinum-disable)
(narf|nlinum-enable)))
(doom|nlinum-disable)
(doom|nlinum-enable)))
;;;###autoload
(defun narf|nlinum-enable ()
(defun doom|nlinum-enable ()
(nlinum-mode +1)
(add-hook 'post-command-hook 'narf|nlinum-hl-line nil t)
(narf|nlinum-unhl-line))
(add-hook 'post-command-hook 'doom|nlinum-hl-line nil t)
(doom|nlinum-unhl-line))
;;;###autoload
(defun narf|nlinum-disable ()
(defun doom|nlinum-disable ()
(nlinum-mode -1)
(remove-hook 'post-command-hook 'narf|nlinum-hl-line t)
(narf|nlinum-unhl-line))
(remove-hook 'post-command-hook 'doom|nlinum-hl-line t)
(doom|nlinum-unhl-line))
;;;###autoload
(defun narf|nlinum-unhl-line ()
(defun doom|nlinum-unhl-line ()
"Unhighlight line number"
(when narf--hl-nlinum-overlay
(when doom--hl-nlinum-overlay
(let* ((disp (get-text-property
0 'display (overlay-get narf--hl-nlinum-overlay 'before-string)))
0 'display (overlay-get doom--hl-nlinum-overlay 'before-string)))
(str (nth 1 disp)))
(put-text-property 0 (length str) 'face 'linum str)
(setq narf--hl-nlinum-overlay nil
narf--hl-nlinum-line nil)
(setq doom--hl-nlinum-overlay nil
doom--hl-nlinum-line nil)
disp)))
;;;###autoload
(defun narf|nlinum-hl-line (&optional line)
(defun doom|nlinum-hl-line (&optional line)
"Highlight line number"
(let ((line-no (or line (string-to-number (format-mode-line "%l")))))
(if (and nlinum-mode (not (eq line-no narf--hl-nlinum-line)))
(if (and nlinum-mode (not (eq line-no doom--hl-nlinum-line)))
(let* ((pbol (if line
(save-excursion (goto-char 1)
(forward-line line-no)
@ -49,11 +49,11 @@
(jit-lock-fontify-now pbol peol)
(let ((ov (--first (overlay-get it 'nlinum) (overlays-in pbol peol))))
(when ov
(narf|nlinum-unhl-line)
(doom|nlinum-unhl-line)
(let ((str (nth 1 (get-text-property 0 'display (overlay-get ov 'before-string)))))
(put-text-property 0 (length str) 'face 'linum-highlight-face str)
(setq narf--hl-nlinum-overlay ov
narf--hl-nlinum-line line-no))))))))
(setq doom--hl-nlinum-overlay ov
doom--hl-nlinum-line line-no))))))))
(provide 'defuns-nlinum)
;;; defuns-nlinum.el ends here

View file

@ -1,45 +1,45 @@
;;; defuns-popups.el
;;;###autoload
(defun narf/popup-remove (window)
(setq narf-popup-windows (delete window narf-popup-windows)))
(defun doom/popup-remove (window)
(setq doom-popup-windows (delete window doom-popup-windows)))
;;;###autoload
(defun narf/popup-p (&optional window)
(defun doom/popup-p (&optional window)
"Whether WINDOW is a shackle popup window or not."
(and narf-popup-windows
(and doom-popup-windows
(-any? (lambda (w)
(if (window-live-p w) t (narf/popup-remove w) nil))
narf-popup-windows)
(if (window-live-p w) t (doom/popup-remove w) nil))
doom-popup-windows)
(if window
(-any? (lambda (w) (eq window w)) narf-popup-windows)
(-any? (lambda (w) (eq window w)) doom-popup-windows)
t)))
;;;###autoload
(defmacro narf/popup-save (&rest body)
`(let ((popup-p (narf/popup-p)))
(when popup-p (narf/popup-close-all t))
(defmacro doom/popup-save (&rest body)
`(let ((popup-p (doom/popup-p)))
(when popup-p (doom/popup-close-all t))
,@body
(when popup-p
(save-selected-window
(narf/popup-last-buffer)))))
(doom/popup-last-buffer)))))
;;;###autoload
(defun narf/popup-buffer (buffer &optional plist)
(defun doom/popup-buffer (buffer &optional plist)
"Display BUFFER in a shackle popup."
(let ((buffer-name (if (stringp buffer) buffer (buffer-name buffer))))
(shackle-display-buffer (get-buffer-create buffer-name)
nil (or plist (shackle-match buffer-name)))))
;;;###autoload
(defun narf/popup-close (&optional window dont-kill dont-close-all)
(defun doom/popup-close (&optional window dont-kill dont-close-all)
"Find and close the currently active popup (if available)."
(interactive)
(when (not window)
(if (narf/popup-p (selected-window))
(if (doom/popup-p (selected-window))
(setq window (selected-window))
(unless dont-close-all
(narf/popup-close-all dont-kill))))
(doom/popup-close-all dont-kill))))
(when (and window (window-live-p window))
;; REPL buffer
(cond ((and (derived-mode-p 'comint-mode)
@ -49,59 +49,59 @@
((eq major-mode 'messages-buffer-mode)
(bury-buffer)
(setq dont-kill t)))
(narf/popup-remove window)
(doom/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))))
(delete-window window)))
;;;###autoload
(defun narf/popup-close-all (&optional dont-kill-buffers)
(defun doom/popup-close-all (&optional dont-kill-buffers)
"Closes all popup windows (and kills the buffers if DONT-KILL-BUFFERS is non-nil)"
(interactive)
(mapc (lambda (w) (narf/popup-close w dont-kill-buffers))
narf-popup-windows)
(setq narf-popup-windows nil))
(mapc (lambda (w) (doom/popup-close w dont-kill-buffers))
doom-popup-windows)
(setq doom-popup-windows nil))
;;;###autoload
(defun narf/popup-toggle ()
(defun doom/popup-toggle ()
"Toggles the popup window, reopening the last popup (if available)."
(interactive)
(if (narf/popup-p)
(narf/popup-close t)
(narf/popup-last-buffer)))
(if (doom/popup-p)
(doom/popup-close t)
(doom/popup-last-buffer)))
;;;###autoload
(defun narf/popup-last-buffer ()
(defun doom/popup-last-buffer ()
"Pop up the last popup buffer."
(interactive)
(unless shackle-last-buffer
(error "No popup to restore"))
(narf/popup-buffer shackle-last-buffer))
(doom/popup-buffer shackle-last-buffer))
;;;###autoload
(defun narf/popup-messages ()
(defun doom/popup-messages ()
"Pop up the *Messages* buffer."
(interactive)
(narf/popup-buffer "*Messages*")
(doom/popup-buffer "*Messages*")
(with-current-buffer "*Messages*"
(narf|hide-mode-line)
(doom|hide-mode-line)
(goto-char (point-max))))
;;;###autoload
(defun narf|popup-init ()
(add-to-list 'narf-popup-windows (get-buffer-window))
(local-set-key [escape escape] 'narf/popup-close)
(defun doom|popup-init ()
(add-to-list 'doom-popup-windows (get-buffer-window))
(local-set-key [escape escape] 'doom/popup-close)
(when (or (bound-and-true-p repl-toggle-mode)
(derived-mode-p 'tabulated-list-mode)
(memq major-mode '(messages-buffer-mode flycheck-error-list-mode-hook esup-mode)))
(let ((map evil-normal-state-local-map))
(define-key map [escape] 'narf/popup-close)
(define-key map (kbd "ESC") 'narf/popup-close))))
(define-key map [escape] 'doom/popup-close)
(define-key map (kbd "ESC") 'doom/popup-close))))
(defvar shackle-popup-hook '() "Hook run whenever a popup is opened.")
;;;###autoload
(defun narf|run-popup-hooks (&rest _)
(defun doom|run-popup-hooks (&rest _)
(with-current-buffer shackle-last-buffer
(run-hooks 'shackle-popup-hook)))

View file

@ -1,16 +1,16 @@
;;; defuns-project.el
;;;###autoload
(defun narf/project-root (&optional strict-p)
"Get the path to the root of your project. Uses `narf-project-root-files' to
(defun doom/project-root (&optional strict-p)
"Get the path to the root of your project. Uses `doom-project-root-files' to
determine if a directory is a project."
(let (projectile-require-project-root strict-p)
(projectile-project-root)))
;;;###autoload
(defun narf/project-has-files (files &optional root)
(defun doom/project-has-files (files &optional root)
"Return non-nil if FILES exist in the project root."
(let ((root (or root (narf/project-root)))
(let ((root (or root (doom/project-root)))
(files (if (listp files) files (list files)))
(found-p (if files t)))
(while (and found-p files)
@ -21,7 +21,10 @@ determine if a directory is a project."
found-p))
;;;###autoload
(defalias 'narf/project-p 'projectile-project-p)
(defalias 'doom/project-p 'projectile-project-p)
;;;###autoload
(defalias 'doom/project-name 'projectile-project-name)
(provide 'defuns-project)
;;; defuns-project.el ends here

View file

@ -2,25 +2,25 @@
;;;; Code building ;;;;;;;;;;;;;;;;;;;;;;
;;;###autoload
(defvar narf--build-command '("make %s" . "Makefile"))
(make-variable-buffer-local 'narf--build-command)
(defvar doom--build-command '("make %s" . "Makefile"))
(make-variable-buffer-local 'doom--build-command)
;;;###autoload
(defun narf/set-build-command (command &optional file)
(defun doom/set-build-command (command &optional file)
(when (or (null file)
(narf/project-has-files file))
(setq narf--build-command `(,command . ,file))))
(doom/project-has-files file))
(setq doom--build-command `(,command . ,file))))
;;;###autoload (autoload 'narf:build "defuns-quickrun" nil t)
(evil-define-command narf:build (arg)
;;;###autoload (autoload 'doom:build "defuns-quickrun" nil t)
(evil-define-command doom: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."
(interactive "<sh>")
(when (null narf--build-command)
(when (null doom--build-command)
(user-error "No build command was set"))
(let ((build-file (cdr narf--build-command))
(build-cmd (car narf--build-command))
(project-dir (narf/project-root)))
(let ((build-file (cdr doom--build-command))
(build-cmd (car doom--build-command))
(project-dir (doom/project-root)))
(if (or (null build-file) (f-exists? (f-expand build-file project-dir)))
(if (or (symbolp build-cmd) (functionp build-cmd))
(if (commandp build-cmd)
@ -31,17 +31,17 @@
(error "Could not build!"))))
;;;; Code running ;;;;;;;;;;;;;;;;;;;;;;
;;;###autoload (autoload 'narf:eval-buffer "defuns-quickrun" nil t)
(evil-define-command narf:eval-buffer ()
;;;###autoload (autoload 'doom:eval-buffer "defuns-quickrun" nil t)
(evil-define-command doom:eval-buffer ()
"Evaluate the whole buffer."
:move-point nil :repeat nil
(interactive)
(cond ((eq major-mode 'emacs-lisp-mode)
(narf:eval-region (point-min) (point-max)))
(doom:eval-region (point-min) (point-max)))
(t (quickrun))))
;;;###autoload (autoload 'narf:eval-region "defuns-quickrun" nil t)
(evil-define-operator narf:eval-region (beg end)
;;;###autoload (autoload 'doom:eval-region "defuns-quickrun" nil t)
(evil-define-operator doom: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
@ -62,11 +62,11 @@ elisp buffer). Otherwise forward the region to Quickrun."
(insert out)
(read-only-mode 1)
(goto-char (point-min))
(narf/popup-buffer (current-buffer))))))
(doom/popup-buffer (current-buffer))))))
(t (quickrun-region beg end))))
;;;###autoload (autoload 'narf:eval-region-and-replace "defuns-quickrun" nil t)
(evil-define-operator narf:eval-region-and-replace (beg end)
;;;###autoload (autoload 'doom:eval-region-and-replace "defuns-quickrun" nil t)
(evil-define-operator doom:eval-region-and-replace (beg end)
(interactive "<r>")
(cond ((eq major-mode 'emacs-lisp-mode)
(kill-region beg end)

View file

@ -1,36 +1,35 @@
;;; defuns-repl.el
;;;###autoload (autoload 'narf:repl "defuns-repl" nil t)
(evil-define-command narf:repl (&optional bang command)
;;;###autoload (autoload 'doom:repl "defuns-repl" nil t)
(evil-define-command doom:repl (&optional bang command)
:repeat nil
(interactive "<!><a>")
(if (and narf--repl-buffer (buffer-live-p narf--repl-buffer))
(narf/popup-buffer narf--repl-buffer)
(if (and doom--repl-buffer (buffer-live-p doom--repl-buffer))
(doom/popup-buffer doom--repl-buffer)
(rtog/toggle-repl (if (use-region-p) 4))
(setq narf--repl-buffer (current-buffer))
(setq doom--repl-buffer (current-buffer))
(when command
(with-current-buffer narf--repl-buffer
(with-current-buffer doom--repl-buffer
(insert command)
(unless bang (comint-send-input))))))
;;;###autoload (autoload 'narf:repl-eval "defuns-repl" nil t)
(evil-define-operator narf:repl-eval (&optional beg end bang)
;;;###autoload (autoload 'doom:repl-eval "defuns-repl" nil t)
(evil-define-operator doom:repl-eval (&optional beg end bang)
:type inclusive
:repeat nil
(interactive "<r><!>")
(let ((region-p (use-region-p))
(selection (s-trim (buffer-substring-no-properties beg end))))
(narf:repl bang)
(doom:repl bang)
(when (and region-p beg end)
(let* ((buf narf--repl-buffer)
(let* ((buf doom--repl-buffer)
(win (get-buffer-window buf)))
(unless (eq buf (narf/popup-p (get-buffer-window buf)))
(narf/popup-buffer buf))
(when (and narf--repl-buffer (buffer-live-p narf--repl-buffer))
(with-current-buffer narf--repl-buffer
(unless (eq buf (doom/popup-p (get-buffer-window buf)))
(doom/popup-buffer buf))
(when (and doom--repl-buffer (buffer-live-p doom--repl-buffer))
(with-current-buffer doom--repl-buffer
(goto-char (point-max))
(insert selection)))))))
(provide 'defuns-repl)
;;; defuns-repl.el ends here

View file

@ -1,7 +1,7 @@
;;; defuns-smartparens.el
;;;###autoload
(defun narf/sp-insert-yasnippet (id action context)
(defun doom/sp-insert-yasnippet (id action context)
(forward-char -1)
(if (sp-point-after-bol-p id action context)
(yas-expand-from-trigger-key)

View file

@ -1,16 +1,16 @@
;;; defuns-spaceline.el
;;;###autoload
(defun narf|spaceline-env-update ()
(when narf--env-command
(let ((default-directory (narf/project-root)))
(let ((s (shell-command-to-string narf--env-command)))
(setq narf--env-version (if (string-match "[ \t\n\r]+\\'" s)
(defun doom|spaceline-env-update ()
(when doom--env-command
(let ((default-directory (doom/project-root)))
(let ((s (shell-command-to-string doom--env-command)))
(setq doom--env-version (if (string-match "[ \t\n\r]+\\'" s)
(replace-match "" t t s)
s))))))
;;;###autoload
(defun narf/-flycheck-count (state)
(defun doom/-flycheck-count (state)
"Return flycheck information for the given error type STATE."
(when (flycheck-has-current-errors-p state)
(if (eq 'running flycheck-last-status-change)

View file

@ -1,10 +1,9 @@
;;; defuns-ui.el
;; for ../core-ui.el
;;;###autoload (autoload 'narf:toggle-fullscreen "defuns-ui" nil t)
;;;###autoload (autoload 'narf:set-columns "defuns-ui" nil t)
;;;###autoload (autoload 'doom:toggle-fullscreen "defuns-ui" nil t)
;;;###autoload (autoload 'doom:set-columns "defuns-ui" nil t)
(after! evil
(evil-define-command narf:set-columns (&optional bang columns)
(evil-define-command doom:set-columns (&optional bang columns)
"Adjusts visual-fill-column-width on the fly."
(interactive "<!><a>")
(if (or (= (length columns) 0) bang)
@ -19,33 +18,33 @@
(visual-fill-column--adjust-window)
(visual-fill-column-mode 1)))
(evil-define-command narf:toggle-fullscreen ()
(evil-define-command doom:toggle-fullscreen ()
(interactive)
(set-frame-parameter nil 'fullscreen (if (not (frame-parameter nil 'fullscreen)) 'fullboth))))
;;;###autoload
(defun narf/reset-theme ()
(defun doom/reset-theme ()
(interactive)
(narf/load-theme (or narf-current-theme narf-default-theme)))
(doom/load-theme (or doom-current-theme doom-default-theme)))
;;;###autoload
(defun narf/load-font (font)
(defun doom/load-font (font)
(interactive)
(set-frame-font font t)
(setq narf-current-font font))
(setq doom-current-font font))
;;;###autoload
(defun narf/load-theme (theme &optional suppress-font)
(defun doom/load-theme (theme &optional suppress-font)
(interactive)
(when narf-current-theme
(disable-theme narf-current-theme))
(when doom-current-theme
(disable-theme doom-current-theme))
(load-theme theme t)
(unless suppress-font
(narf/load-font narf-current-font))
(setq narf-current-theme theme))
(doom/load-font doom-current-font))
(setq doom-current-theme theme))
;;;###autoload
(defun narf/show-as (how &optional pred)
(defun doom/show-as (how &optional pred)
(let* ((beg (match-beginning 1))
(end (match-end 1))
(ok (or (not pred) (funcall pred beg end))))
@ -54,16 +53,17 @@
nil))
;;;###autoload
(defun narf/imenu-list-quit ()
(defun doom/imenu-list-quit ()
(interactive)
(quit-window)
(mapc (lambda (b) (with-current-buffer b
(when imenu-list-minor-mode
(imenu-list-minor-mode -1))))
(narf/get-visible-buffers (narf/get-real-buffers))))
(doom/get-visible-buffers (doom/get-real-buffers))))
;;;###autoload
(defun narf|hide-mode-line (&rest _)
(defun doom|hide-mode-line (&rest _)
(set-window-fringes (selected-window) 0 0 nil)
(setq mode-line-format nil))
(provide 'defuns-ui)

View file

@ -1,18 +1,18 @@
;;; defuns-whitespace.el
;;;###autoload
(defun narf--point-at-bol-non-blank()
(defun doom--point-at-bol-non-blank()
(save-excursion (evil-first-non-blank) (point)))
;;;###autoload
(defun narf/surrounded-p ()
(defun doom/surrounded-p ()
(and (looking-back "[[{(]\\(\s+\\|\n\\)?\\(\s\\|\t\\)*")
(let* ((whitespace (match-string 1))
(match-str (concat whitespace (match-string 2) "[])}]")))
(looking-at-p match-str))))
;;;###autoload
(defun narf/backward-kill-to-bol-and-indent ()
(defun doom/backward-kill-to-bol-and-indent ()
"Kill line to the first non-blank character. If invoked again
afterwards, kill line to column 1."
(interactive)
@ -22,12 +22,12 @@ afterwards, kill line to column 1."
(indent-according-to-mode))))
;;;###autoload
(defun narf/move-to-bol ()
(defun doom/move-to-bol ()
"Moves cursor to the first non-blank character on the line. If
already there, move it to the true bol."
(interactive)
(evil-save-goal-column
(let ((point-at-bol (narf--point-at-bol-non-blank))
(let ((point-at-bol (doom--point-at-bol-non-blank))
(point (point)))
(if (= point-at-bol point)
(evil-move-beginning-of-line)
@ -35,20 +35,20 @@ already there, move it to the true bol."
(evil-first-non-blank))))))
;;;###autoload
(defun narf/move-to-eol ()
(defun doom/move-to-eol ()
(interactive)
(evil-save-goal-column
(let ((old-point (point)))
(when (comment-search-forward (point-at-eol) t)
(goto-char (match-beginning 0))
(skip-syntax-backward " ^<*" (narf--point-at-bol-non-blank))
(skip-syntax-backward " ^<*" (doom--point-at-bol-non-blank))
(if (eq old-point (point)) ;
(evil-move-end-of-line))))))
;; Mimic expandtab in vim
;;;###autoload
(defun narf/backward-delete-whitespace-to-column ()
(defun doom/backward-delete-whitespace-to-column ()
"Delete back to the previous column of whitespace, or as much
whitespace as possible, or just one char if that's not possible."
(interactive)
@ -75,7 +75,7 @@ whitespace as possible, or just one char if that's not possible."
(t (backward-delete-char-untabify 1))))
;;;###autoload
(defun narf/dumb-indent (&optional smart)
(defun doom/dumb-indent (&optional smart)
"Inserts a tab character (or spaces x tab-width). Checks if the
auto-complete window is open."
(interactive)
@ -86,14 +86,14 @@ auto-complete window is open."
(insert (s-repeat spaces " ")))))
;;;###autoload
(defun narf/smart-indent ()
(defun doom/smart-indent ()
(interactive)
(save-excursion
(back-to-indentation)
(narf/dumb-indent)))
(doom/dumb-indent)))
;;;###autoload
(defun narf/dumb-dedent ()
(defun doom/dumb-dedent ()
(interactive)
(if indent-tabs-mode
(delete-char -1)
@ -105,23 +105,23 @@ auto-complete window is open."
(delete-char (- spaces))))))
;;;###autoload
(defun narf/inflate-space-maybe ()
(defun doom/inflate-space-maybe ()
"Checks if point is surrounded by {} [] () delimiters and adds a
space on either side of the point if so."
(interactive)
(if (narf/surrounded-p)
(if (doom/surrounded-p)
(progn (call-interactively 'self-insert-command)
(save-excursion (call-interactively 'self-insert-command)))
(call-interactively 'self-insert-command)))
;;;###autoload
(defun narf/deflate-space-maybe ()
(defun doom/deflate-space-maybe ()
"Checks if point is surrounded by {} [] () delimiters, and deletes
spaces on either side of the point if so. Resorts to
`narf/backward-delete-whitespace-to-column' otherwise."
`doom/backward-delete-whitespace-to-column' otherwise."
(interactive)
(save-match-data
(if (narf/surrounded-p)
(if (doom/surrounded-p)
(let ((whitespace-match (match-string 1)))
(cond ((not whitespace-match)
(call-interactively 'sp-backward-delete-char))
@ -131,10 +131,10 @@ spaces on either side of the point if so. Resorts to
(save-excursion (delete-char 1)))
(t
(just-one-space 0))))
(narf/backward-delete-whitespace-to-column))))
(doom/backward-delete-whitespace-to-column))))
;;;###autoload
(defun narf/newline-and-indent ()
(defun doom/newline-and-indent ()
(interactive)
(cond ((sp-point-in-string)
(newline))
@ -158,8 +158,8 @@ spaces on either side of the point if so. Resorts to
(newline nil t)
(indent-according-to-mode))))
;;;###autoload (autoload 'narf:whitespace-retab "defuns-whitespace" nil t)
(evil-define-operator narf:whitespace-retab (beg end)
;;;###autoload (autoload 'doom:whitespace-retab "defuns-whitespace" nil t)
(evil-define-operator doom:whitespace-retab (beg end)
"Akin to vim's retab, this changes all tabs-to-spaces or spaces-to-tabs,
depending on `indent-tab-mode'. Untested."
:motion nil
@ -173,8 +173,8 @@ spaces on either side of the point if so. Resorts to
(tabify beg end)
(untabify beg end)))
;;;###autoload (autoload 'narf:whitespace-align "defuns-whitespace" nil t)
(evil-define-command narf:whitespace-align (beg end &optional regexp bang)
;;;###autoload (autoload 'doom:whitespace-align "defuns-whitespace" nil t)
(evil-define-command doom:whitespace-align (beg end &optional regexp bang)
:repeat nil
(interactive "<r><a><!>")
(when regexp

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)

View file

@ -1,37 +1,37 @@
;;; defuns-workgroup.el
;;;###autoload
(defun narf|wg-cleanup ()
(narf/popup-close-all)
(defun doom|wg-cleanup ()
(doom/popup-close-all)
(when (and (featurep 'neotree) (neo-global--window-exists-p))
(neotree-hide)))
;;;###autoload
(defun narf/wg-projectile-switch-project ()
(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)
(defun doom/wg-projectile-switch-project ()
(let ((project-root (doom/project-root)))
(doom:workgroup-new nil (file-name-nondirectory (directory-file-name project-root)) t)
(doom|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)
;;;###autoload (autoload 'doom:save-session "defuns-workgroup" nil t)
(evil-define-command doom:save-session (&optional bang session-name)
(interactive "<!><a>")
(unless (wg-workgroup-list)
(wg-create-workgroup wg-first-wg-name))
(narf|wg-cleanup)
(doom|wg-cleanup)
(wg-save-session-as (if session-name
(concat wg-workgroup-directory session-name)
(if bang
(concat wg-workgroup-directory (f-filename (narf/project-root)))
(concat wg-workgroup-directory (f-filename (doom/project-root)))
wg-session-file))))
;;;###autoload (autoload 'narf:load-session "defuns-workgroup" nil t)
(evil-define-command narf:load-session (&optional bang session-name)
;;;###autoload (autoload 'doom:load-session "defuns-workgroup" nil t)
(evil-define-command doom:load-session (&optional bang session-name)
(interactive "<!><a>")
(let ((session-file (if session-name
(concat wg-workgroup-directory session-name)
(let ((sess (concat wg-workgroup-directory (f-filename (narf/project-root)))))
(let ((sess (concat wg-workgroup-directory (f-filename (doom/project-root)))))
(if bang
(when (file-exists-p sess)
sess)
@ -39,16 +39,16 @@
(unless session-file
(user-error "No session found"))
(wg-open-session session-file))
(narf/workgroup-display t))
(doom/workgroup-display t))
;;;###autoload
(defun narf/clear-sessions ()
(defun doom/clear-sessions ()
"Delete all session files."
(interactive)
(mapc 'delete-file (f-glob (expand-file-name "*" wg-workgroup-directory))))
;;;###autoload (autoload 'narf:workgroup-new "defuns-workgroup" nil t)
(evil-define-command narf:workgroup-new (bang name &optional silent)
;;;###autoload (autoload 'doom:workgroup-new "defuns-workgroup" nil t)
(evil-define-command doom:workgroup-new (bang name &optional silent)
"Create a new workgroup. If BANG, overwrite any workgroup named NAME."
(interactive "<!><a>")
(unless name
@ -58,43 +58,43 @@
(wg-delete-workgroup new-wg)
(setq new-wg nil))
(setq new-wg (or new-wg (wg-make-and-add-workgroup name t)))
(add-to-list 'narf-wg-names (wg-workgroup-uid new-wg))
(add-to-list 'doom-wg-names (wg-workgroup-uid new-wg))
(wg-switch-to-workgroup new-wg))
(unless silent
(narf--workgroup-display (wg-previous-workgroup t)
(doom--workgroup-display (wg-previous-workgroup t)
(format "Created %s" name)
'success)))
;;;###autoload (autoload 'narf:workgroup-rename "defuns-workgroup" nil t)
(evil-define-command narf:workgroup-rename (bang &optional new-name)
;;;###autoload (autoload 'doom:workgroup-rename "defuns-workgroup" nil t)
(evil-define-command doom:workgroup-rename (bang &optional new-name)
(interactive "<!><a>")
(let* ((wg (wg-current-workgroup))
(wg-uid (wg-workgroup-uid wg))
(old-name (wg-workgroup-name wg)))
(if bang
(setq narf-wg-names (delete wg-uid narf-wg-names))
(setq doom-wg-names (delete wg-uid doom-wg-names))
(unless new-name
(user-error "You didn't enter in a name"))
(wg-rename-workgroup new-name wg)
(add-to-list 'narf-wg-names wg-uid)
(narf--workgroup-display wg (format "Renamed '%s'->'%s'" old-name new-name) 'success))))
(add-to-list 'doom-wg-names wg-uid)
(doom--workgroup-display wg (format "Renamed '%s'->'%s'" old-name new-name) 'success))))
;;;###autoload (autoload 'narf:workgroup-delete "defuns-workgroup" nil t)
(evil-define-command narf:workgroup-delete (&optional bang name)
;;;###autoload (autoload 'doom:workgroup-delete "defuns-workgroup" nil t)
(evil-define-command doom:workgroup-delete (&optional bang name)
(interactive "<!><a>")
(let* ((current-wg (wg-current-workgroup))
(wg-name (or name (wg-workgroup-name current-wg))))
(when bang
(setq wg-name (wg-read-workgroup-name)))
(let ((wg (wg-get-workgroup name)))
(setq narf-wg-names (delete (wg-workgroup-uid wg) narf-wg-names))
(setq doom-wg-names (delete (wg-workgroup-uid wg) doom-wg-names))
(if (eq wg current-wg)
(wg-kill-workgroup)
(wg-delete-workgroup wg))
(narf--workgroup-display nil (format "Deleted %s" wg-name) 'success))))
(doom--workgroup-display nil (format "Deleted %s" wg-name) 'success))))
;;;###autoload
(defun narf:kill-other-workgroups ()
(defun doom:kill-other-workgroups ()
"Kill all other workgroups."
(interactive)
(let (workgroup (wg-current-workgroup))
@ -102,7 +102,7 @@
(unless (wg-current-workgroup-p w)
(wg-kill-workgroup w)))))
(defun narf--num-to-unicode (num)
(defun doom--num-to-unicode (num)
"Return a nice unicode representation of a single-digit number STR."
(cl-case num
(1 "")
@ -116,22 +116,22 @@
(9 "")
(0 "")))
(defun narf--workgroup-display (&optional suppress-update message message-face)
(message "%s%s" (narf/workgroup-display suppress-update t)
(defun doom--workgroup-display (&optional suppress-update message message-face)
(message "%s%s" (doom/workgroup-display suppress-update t)
(propertize message 'face message-face)))
;;;###autoload
(defun narf/workgroup-display (&optional suppress-update return-p message)
(defun doom/workgroup-display (&optional suppress-update return-p message)
(interactive)
(when (wg-current-session t)
(unless (eq suppress-update t)
(narf/workgroup-update-names (if (wg-workgroup-p suppress-update) suppress-update)))
(doom/workgroup-update-names (if (wg-workgroup-p suppress-update) suppress-update)))
(let ((output (wg-display-internal
(lambda (workgroup index)
(if (not workgroup) wg-nowg-string
(wg-element-display
workgroup
(format " %s %s " (narf--num-to-unicode (1+ index)) (wg-workgroup-name workgroup))
(format " %s %s " (doom--num-to-unicode (1+ index)) (wg-workgroup-name workgroup))
'wg-current-workgroup-p)))
(wg-workgroup-list))))
(if return-p
@ -139,16 +139,16 @@
(message "%s%s" output (or message ""))))))
;;;###autoload
(defun narf/workgroup-update-names (&optional wg)
(defun doom/workgroup-update-names (&optional wg)
(let ((wg (or wg (wg-current-workgroup))))
(unless (member (wg-workgroup-uid wg) narf-wg-names)
(unless (member (wg-workgroup-uid wg) doom-wg-names)
(ignore-errors
(let ((old-name (wg-workgroup-name wg))
(new-name (f-filename (narf/project-root))))
(new-name (f-filename (doom/project-root))))
(unless (string= new-name old-name)
(wg-rename-workgroup new-name wg)))))))
(defun narf--switch-to-workgroup (direction &optional count)
(defun doom--switch-to-workgroup (direction &optional count)
(interactive "<c>")
(assert (memq direction '(left right)))
(condition-case err
@ -156,52 +156,52 @@
(if count
(wg-switch-to-workgroup-at-index (1- count))
(funcall (intern (format "wg-switch-to-workgroup-%s" direction))))
(narf/workgroup-display t))
(error (narf/workgroup-display t nil (format "Nope! %s" (cadr err))))))
(doom/workgroup-display t))
(error (doom/workgroup-display t nil (format "Nope! %s" (cadr err))))))
;;;###autoload (autoload 'narf:switch-to-workgroup-left "defuns-workgroup" nil t)
(evil-define-command narf:switch-to-workgroup-left (count)
;;;###autoload (autoload 'doom:switch-to-workgroup-left "defuns-workgroup" nil t)
(evil-define-command doom:switch-to-workgroup-left (count)
(interactive "<c>")
(narf--switch-to-workgroup 'left))
(doom--switch-to-workgroup 'left))
;;;###autoload (autoload 'narf:switch-to-workgroup-right "defuns-workgroup" nil t)
(evil-define-command narf:switch-to-workgroup-right (count)
;;;###autoload (autoload 'doom:switch-to-workgroup-right "defuns-workgroup" nil t)
(evil-define-command doom:switch-to-workgroup-right (count)
(interactive "<c>")
(narf--switch-to-workgroup 'right))
(doom--switch-to-workgroup 'right))
;;;###autoload
(defun narf:switch-to-workgroup-at-index (index)
(defun doom:switch-to-workgroup-at-index (index)
(interactive)
(narf/workgroup-update-names)
(doom/workgroup-update-names)
(let ((wg (nth index (wg-workgroup-list-or-error)))
msg)
(if wg
(unless (eq wg (wg-current-workgroup t))
(wg-switch-to-workgroup-at-index index))
(setq msg (format "No tab #%s" (1+ index))))
(narf/workgroup-display t nil msg)))
(doom/workgroup-display t nil msg)))
;;;###autoload
(defun narf/undo-window-change ()
(defun doom/undo-window-change ()
(interactive)
(call-interactively (if (wg-current-workgroup t) 'wg-undo-wconfig-change 'winner-undo)))
;;;###autoload
(defun narf/redo-window-change ()
(defun doom/redo-window-change ()
(interactive)
(call-interactively (if (wg-current-workgroup t) 'wg-redo-wconfig-change 'winner-redo)))
;;;###autoload
(defun narf/close-window-or-workgroup ()
(defun doom/close-window-or-workgroup ()
(interactive)
(if (memq (get-buffer-window) narf-popup-windows)
(narf/popup-close)
(narf/kill-real-buffer)
(if (memq (get-buffer-window) doom-popup-windows)
(doom/popup-close)
(doom/kill-real-buffer)
(if (and (one-window-p t)
(> (length (wg-workgroup-list)) 1))
(if (string= (wg-workgroup-name (wg-current-workgroup)) wg-first-wg-name)
(evil-window-delete)
(narf:workgroup-delete))
(doom:workgroup-delete))
(evil-window-delete))))
(provide 'defuns-workgroup)

View file

@ -2,9 +2,9 @@
;; for ../core-yasnippet.el
;;;###autoload
(defun narf|yas-before-expand ()
(defun doom|yas-before-expand ()
"Strip out the shitespace before a line selection."
(when (narf/evil-visual-line-state-p)
(when (doom/evil-visual-line-state-p)
(setq-local
yas-selected-text
(replace-regexp-in-string
@ -13,13 +13,13 @@
(1- (region-end)))))))
;;;###autoload
(defun narf|yas-after-expand ()
(defun doom|yas-after-expand ()
"Switch to insert mode when expanding a template via backtab, or go back to
normal mode if there are no fields."
(setq yas-selected-text nil))
;;;###autoload
(defun narf/yas-insert-snippet ()
(defun doom/yas-insert-snippet ()
"Switch to insert mode when expanding a template via backtab, or go back to
normal mode if there are no fields."
(interactive)
@ -36,7 +36,7 @@ normal mode if there are no fields."
(unless fields (evil-change-state 'normal))))
;;;###autoload
(defun narf/yas-goto-start-of-field ()
(defun doom/yas-goto-start-of-field ()
"Go to the beginning of a field."
(interactive)
(let* ((snippet (car (yas--snippets-at-point)))
@ -46,7 +46,7 @@ normal mode if there are no fields."
(goto-char position))))
;;;###autoload
(defun narf/yas-goto-end-of-field ()
(defun doom/yas-goto-end-of-field ()
(interactive)
(let* ((snippet (car (yas--snippets-at-point)))
(position (yas--field-end (yas--snippet-active-field snippet))))
@ -55,7 +55,7 @@ normal mode if there are no fields."
(goto-char position))))
;;;###autoload
(defun narf/yas-backspace (&optional field)
(defun doom/yas-backspace (&optional field)
"Prevents Yas from stepping on my toes when I use backspace."
(interactive)
(let ((field (or field (and yas--active-field-overlay
@ -65,7 +65,7 @@ normal mode if there are no fields."
(t (delete-char -1)))))
;;;###autoload
(defun narf/yas-delete (&optional field)
(defun doom/yas-delete (&optional field)
(interactive)
(let ((field (or field (and yas--active-field-overlay
(overlay-buffer yas--active-field-overlay)
@ -79,7 +79,7 @@ normal mode if there are no fields."
(t (delete-char 1)))))
;;;###autoload
(defun narf/yas-clear-to-sof (&optional field)
(defun doom/yas-clear-to-sof (&optional field)
(interactive)
(let* ((field (or field (and yas--active-field-overlay
(overlay-buffer yas--active-field-overlay)
@ -90,10 +90,11 @@ normal mode if there are no fields."
;; Snippet helpers ;;;;;;;;;;;;;;;;;;;;;
;;;###autoload
(defun narf/yas-find-file ()
(defun doom/yas-find-file ()
"Browse through snippets folder"
;; FIXME
(interactive)
(narf/ido-find-file (car narf-snippet-dirs)))
(doom/ido-find-file (car doom-snippet-dirs)))
(provide 'defuns-yasnippet)
;;; nlinum-defuns.el ends here

View file

@ -5,7 +5,7 @@
(defmacro def-company-backend! (hooks backends)
"Register a company backend for a mode."
(let* ((hooks (if (listp hooks) hooks (list hooks)))
(def-name (intern (format "narf--init-company-%s"
(def-name (intern (format "doom--init-company-%s"
(mapconcat 'identity (mapcar 'symbol-name hooks) "-"))))
(quoted (eq (car-safe backends) 'quote)))
`(progn

View file

@ -7,12 +7,12 @@
(chars (plist-get rest :chars))
(words (plist-get rest :words)))
(when (or chars words)
(let ((fn-name (intern (format "narf--electric-%s" (s-join "-" (mapcar 'symbol-name modes))))))
(let ((fn-name (intern (format "doom--electric-%s" (s-join "-" (mapcar 'symbol-name modes))))))
`(progn
(defun ,fn-name ()
(electric-indent-local-mode +1)
,(if chars `(setq electric-indent-chars ',chars))
,(if words `(setq narf-electric-indent-words ',words)))
,(if words `(setq doom-electric-indent-words ',words)))
(add-hook! ,modes ',fn-name))))))
;;;###autoload
@ -23,7 +23,7 @@
(words (plist-get rest :words))
(patterns (plist-get rest :patterns)))
(when (or symbols words patterns)
(let ((fn-name (intern (format "narf--rotate-%s" (s-join "-" (mapcar 'symbol-name modes))))))
(let ((fn-name (intern (format "doom--rotate-%s" (s-join "-" (mapcar 'symbol-name modes))))))
`(progn
(defun ,fn-name ()
,(if symbols `(setq-local rotate-text-local-symbols ',symbols))

View file

@ -4,12 +4,12 @@
(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."
(let ((fn (intern (format "narf--init-builder-%s" mode))))
(let ((fn (intern (format "doom--init-builder-%s" mode))))
`(progn
(defun ,fn ()
(when (or (null ,build-file)
(narf/project-has-files ,build-file))
(setq narf--build-command '(,command . ,build-file))))
(doom/project-has-files ,build-file))
(setq doom--build-command '(,command . ,build-file))))
(add-hook! ,mode ',fn))))
;;;###autoload

View file

@ -9,7 +9,7 @@
(mapc (lambda (cmd) (evil-ex-define-cmd (car cmd) (cdr cmd)))
',commands))
(defun ,cmd-off (&rest _)
(mapc (lambda (cmd) (narf/evil-ex-undefine-cmd (car cmd)))
(mapc (lambda (cmd) (doom/evil-ex-undefine-cmd (car cmd)))
',commands))))
;; Shortcuts for the evil expression register

View file

@ -8,7 +8,7 @@
(words (plist-get rest :words))
(patterns (plist-get rest :patterns))
fn-name)
(setq fn-name (intern (format "narf--rotate-%s"
(setq fn-name (intern (format "doom--rotate-%s"
(s-join "-" (mapcar 'symbol-name modes)))))
`(progn
(defun ,fn-name ()

View file

@ -2,16 +2,16 @@
;;;###autoload
(defmacro def-version-cmd! (modes command)
"Define a COMMAND for MODE that will set `narf--env-command' when that mode is
"Define a COMMAND for MODE that will set `doom--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:
by `doom|spaceline-env-update' to display a version number in the modeline. For instance:
(def-version-cmd! 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."
(add-hook! (focus-in find-file) 'narf|spaceline-env-update)
`(add-hook! ,modes (setq narf--env-command ,command)))
(add-hook! (focus-in find-file) 'doom|spaceline-env-update)
`(add-hook! ,modes (setq doom--env-command ,command)))
(provide 'defuns-spaceline)
;;; defuns-spaceline.el ends here

View file

@ -1,5 +1,4 @@
;;; macros-yasnippet.el
;; for ../core-yasnippet.el
;;;###autoload
(defmacro def-yas-mode! (mode)