Write core initfiles + defuns

This commit is contained in:
Henrik Lissner 2015-06-15 09:05:52 +02:00
parent c0661f5293
commit b998f4ab08
52 changed files with 2444 additions and 706 deletions

203
core/lib/defuns-buffers.el Normal file
View file

@ -0,0 +1,203 @@
;;; defuns-buffers.el
;;;###autoload
(defun narf:narrow (start end)
"Restrict editing in this buffer to the current region, indirectly.
Inspired from http://demonastery.org/2013/04/emacs-evil-narrow-region/"
(interactive "r")
(deactivate-mark)
(let ((buf (clone-indirect-buffer nil nil)))
(with-current-buffer buf
(narrow-to-region start end))
(switch-to-buffer buf)))
;;;###autoload
(defun narf:widen ()
(interactive)
(when (buffer-narrowed-p)
(widen)))
;;;###autoload
(defun narf/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)
"See http://stackoverflow.com/questions/7410125"
(let ((modified (buffer-modified-p))
(inhibit-read-only t))
(remove-text-properties begin end '(read-only t))
(set-buffer-modified-p modified)))
;; Killing Life and Death ;;;;;;;;;;;;;;
;;;###autoload
(defun narf:kill-real-buffer ()
"Kill buffer (but only bury scratch buffer), then switch to a living buffer."
(interactive)
(let ((bname (buffer-name)))
(cond ((string-match-p "^\\*scratch\\*" bname)
(erase-buffer)
(bury-buffer))
((string-equal "*" (substring bname 0 1)))
(t (kill-this-buffer))))
(unless (narf/real-buffer-p (current-buffer))
(narf/previous-real-buffer)))
;;;###autoload
(defun narf/get-visible-buffers (&optional buffer-list)
"Get a list of buffers that are not buried (i.e. visible)"
(-remove #'get-buffer-window (or buffer-list (buffer-list))))
;;;###autoload
(defun narf/get-buried-buffers (&optional buffer-list)
"Get a list of buffers that are buried (i.e. not visible)"
(-filter #'get-buffer-window (or buffer-list (buffer-list))))
;;;###autoload
(defun narf/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 (buffer-list))))
;;;###autoload
(defun narf/get-real-buffers(&optional buffer-list)
(-filter (lambda (buffer)
(not (--any? (if (stringp it)
(string-match-p it (buffer-name buffer))
(eq (buffer-local-value 'major-mode buffer) it))
narf-unreal-buffers)))
(or buffer-list (buffer-list))))
;;;###autoload
(defun narf:kill-unreal-buffers ()
"Kill all buried, unreal buffers in current frame. See `narf-unreal-buffers'"
(interactive)
(let* ((real-buffers (narf/get-real-buffers))
(kill-list (--filter (not (memq it real-buffers)) narf/get-buried-buffers)))
(message "Cleaned up %s buffers" (length kill-list))
(mapc 'kill-buffer kill-list)
(narf:kill-process-buffers)))
;;;###autoload
(defun narf:kill-process-buffers ()
"Kill all buffers that represent running processes and aren't visible."
(interactive)
(let ((buffer-list (buffer-list)))
(dolist (p (process-list))
(let* ((process-name (process-name p))
(assoc (assoc process-name narf-cleanup-processes-alist)))
(when (and assoc
(not (string= process-name "server"))
(process-live-p p)
(not (--any? (let ((mode (buffer-local-value 'major-mode it)))
(eq mode (cdr assoc)))
buffer-list)))
(message "Cleanup: killing %s" process-name)
(delete-process p))))))
;;;###autoload
(defun narf:kill-matching-buffers (regexp &optional buffer-list)
(interactive)
(mapc (lambda (b)
(if (string-match-p regexp (buffer-name b))
(kill-buffer b)))
(if buffer-list buffer-list (buffer-list))))
;;;###autoload
(defun narf/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)))
(funcall move-func)
(while (let ((current-buffer (current-buffer)))
(and (if (eq current-buffer start-buffer)
(ignore (switch-to-buffer "*scratch*"))
t)
(not (= n 0))
(not (eq current-buffer start-buffer))
(not (memq current-buffer real-buffers))))
(setq n (1- n))
(funcall move-func))))
;;;###autoload
(defun narf/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)))))
;; From spacemacs <https://github.com/syl20bnr/spacemacs/blob/master/spacemacs/funcs.el>
;;;###autoload
(defun narf/next-real-buffer ()
"Switch to the next buffer and avoid special buffers."
(interactive)
(narf/cycle-real-buffers +1))
;;;###autoload
(defun narf/previous-real-buffer ()
"Switch to the previous buffer and avoid special buffers."
(interactive)
(narf/cycle-real-buffers -1))
;;;###autoload (autoload 'narf:kill-buried-buffers "defuns-buffers" nil t)
(evil-define-command narf:kill-buried-buffers (&optional bang)
:repeat nil
(interactive "<!>")
(narf:kill-buried-buffers)
(mapc 'kill-buffer
(narf/get-buried-buffers (if bang (projectile-project-buffers) (buffer-list)))))
;;;###autoload (autoload 'narf:kill-all-buffers "defuns-buffers" nil t)
(evil-define-command narf:kill-all-buffers (&optional bang)
"Kill all project buffers. If BANG, kill *all* buffers."
:repeat nil
(interactive "<!>")
(if (and (not bang) (projectile-project-p))
(projectile-kill-buffers)
(mapc 'kill-buffer (buffer-list)))
(delete-other-windows)
(unless (narf/real-buffer-p)
(narf/previous-real-buffer)))
;;;###autoload (autoload 'narf:scratch-buffer "defuns-buffers" nil t)
(evil-define-operator narf:scratch-buffer (&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
(interactive "<r><!>")
(let ((mode major-mode)
(text (when (and (evil-visual-state-p) beg end)
(buffer-substring beg end))))
(if bang
;; use org-capture with bang
(if text
(org-capture-string text)
(org-capture))
;; or scratch buffer by default
(let* ((project-dir (narf/project-root t))
(buffer-name "*scratch*"))
(popwin:popup-buffer (get-buffer-create buffer-name))
(when (eq (get-buffer buffer-name) (current-buffer))
(when project-dir
(cd project-dir))
(if text (insert text))
(funcall mode))))))
;;;###autoload (autoload 'narf:cd "defuns-buffers" nil t)
(evil-define-command narf:cd (dir)
:repeat nil
(interactive "<f>")
(cd (if (zerop (length dir)) "~" dir)))
(provide 'defuns-buffers)
;;; defuns-buffers.el ends here

View file

@ -0,0 +1,18 @@
;;; defuns-company.el
;;;###autoload
(defun narf/company-evil-complete-next ()
(call-interactively 'company-dabbrev)
(if (eq company-candidates-length 1)
(company-complete)))
;;;###autoload
(defun narf/company-evil-complete-previous ()
(let ((company-selection-wrap-around t))
(call-interactively 'company-dabbrev)
(if (eq company-candidates-length 1)
(company-complete)
(call-interactively 'company-select-previous))))
(provide 'defuns-company)
;;; defuns-company.el ends here

View file

@ -0,0 +1,34 @@
;;; defuns-compile.el
(! (require 'f))
(defun narf--compile-important-dirs ()
(append (list narf-core-dir narf-contrib-dir)
(list (concat narf-modules-dir "lib/")
(concat narf-core-dir "lib/"))
(f-directories narf-contrib-dir)
(list narf-modules-dir narf-private-dir)))
;;;###autoload (autoload 'narf:compile-el "defuns-compile" nil t)
(evil-define-command narf:compile-el (&optional bang)
:repeat nil
(interactive "<!>")
(when (eq major-mode 'emacs-lisp-mode)
(byte-recompile-file (! (f-expand "core-vars.el" narf-core-dir)) t 0)
(byte-recompile-file (! (f-expand "core-defuns.el" narf-core-dir)) t 0)
(if (not bang)
(byte-recompile-file (buffer-file-name) t 0)
(byte-recompile-file (! (f-expand "init-load-path.el" narf-emacs-dir)) nil 0)
(byte-recompile-file (! (f-expand "init.el" narf-emacs-dir)) nil 0)
(dolist (dir (narf--compile-important-dirs))
(byte-recompile-directory dir 0 nil)))))
;;;###autoload (autoload 'narf:compile-autoloads "defuns-compile" nil t)
(evil-define-command narf:compile-autoloads (&optional bang)
:repeat nil
(interactive "<!>")
(defvar generated-autoload-file (! (f-expand "autoloads.el" narf-core-dir)))
(apply #'update-directory-autoloads (narf--compile-important-dirs)))
(provide 'defuns-compile)
;;; defuns-compile.el ends here

31
core/lib/defuns-debug.el Normal file
View file

@ -0,0 +1,31 @@
;;; defuns-debug.el
;;;###autoload
(defun what-face (pos)
"Tells you the name of the face (point) is on."
(interactive "d")
(let ((face (or (get-char-property (point) 'read-face-name)
(get-char-property (point) 'face))))
(if face (message "Face: %s" face) (message "No face at %d" pos))))
;;;###autoload
(defun what-col ()
(interactive)
(message "Column %d" (current-column)))
;;;###autoload
(defun what-bindings (key)
(list
(minor-mode-key-binding key)
(local-key-binding key)
(global-key-binding key)))
;;;###autoload (autoload 'narf:echo "defuns-debug" nil t)
(evil-define-command narf: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)))
(provide 'defuns-debug)
;;; defuns-debug.el ends here

57
core/lib/defuns-editor.el Normal file
View file

@ -0,0 +1,57 @@
;;; defuns-editor.el
;; for ../core-editor.el
;; A hacky attempt to replace ace-jump line mode that incrementally shows where
;; you will land as you type the line number.
(defun narf--goto-line (line)
(let ((lines (count-lines (point-min) (point-max))))
(if (and (<= line (1+ lines))
(> line 0))
(narf/nlinum-hl-line line)
(narf/nlinum-hl-line))))
;;;###autoload
(defun narf/editor-goto-line ()
(interactive)
(let ((keys '())
(orig-point (point))
(echo-keystrokes 0))
(evil-save-echo-area
(catch 'abort
(while t
(let* ((keystr (concat keys))
(key (read-event (concat ":" keystr))))
(cond ((eq key 'escape)
(message "%s" key)
(throw 'abort t))
((eq key 'return)
(when keys
(goto-line (string-to-number keystr)))
(throw 'abort t))
((eq key 'backspace)
(let ((key-len (length keys)))
(if (= key-len 0)
(throw 'abort t)
(if (> key-len 1)
(progn
(nbutlast keys)
(narf--goto-line (string-to-number (concat keys))))
(setq keys '())
(narf/nlinum-hl-line)))))
((and (characterp key)
(s-numeric? (char-to-string key)))
(setq keys (append keys (list key)))
(narf--goto-line (string-to-number (concat keys))))
(t
(if (or (char-equal key ?\C-n)
(char-equal key ?\C-j))
(progn
(setq keys (number-to-string (1+ (string-to-number (concat keys)))))
(narf--goto-line (string-to-number (concat keys))))
(when (or (char-equal key ?\C-p)
(char-equal key ?\C-k))
(setq keys (number-to-string (1- (string-to-number (concat keys)))))
(narf--goto-line (string-to-number (concat keys)))))))))))))
(provide 'defuns-editor)
;;; defuns-editor.el ends here

66
core/lib/defuns-evil.el Normal file
View file

@ -0,0 +1,66 @@
;;; 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)
"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)
"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)))
;;;; Ace Jump ;;;;;;;;;;;;;;;;;;;;;;;;;;
;; https://github.com/winterTTr/ace-jump-mode/issues/23
;;;###autoload (autoload 'narf:evil-ace-jump-two-chars "defuns-evil" nil t)
(evil-define-motion narf/evil-ace-jump-two-chars (count)
:type exclusive
:repeat abort
(evil-without-repeat
(evil-enclose-ace-jump-for-motion
(call-interactively 'ace-jump-two-chars-mode))))
;;;###autoload
(defun narf/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:iedit-restrict-to-region ()
(interactive)
(if (iedit-current-occurrence-string)
(let ((current-prefix-arg '(4)))
(iedit-done)
(call-interactively 'iedit-mode)
(save-excursion (iedit-restrict-region (region-beginning) (region-end)))
(evil-previous-line))
(call-interactively 'evil-ret)))
;;;###autoload
(defun narf*evil-exchange-off ()
(when evil-exchange--overlays
(evil-exchange-cancel)))
;;;###autoload
(defun narf/evil-surround-escaped ()
"Escaped surround characters."
(let* ((char (string (read-char "\\")))
(pair (cond ((string-match "[]})[{(]" char)
(let ((-pair (cdr (assoc (string-to-char char) evil-surround-pairs-alist))))
`(,(car -pair) . ,(cdr -pair))))
(t
`(,char . ,char))))
(format (if (sp-point-in-string) "\\\\%s" "\\%s")))
(cons (format format (car pair))
(format format (cdr pair)))))
(provide 'defuns-evil)
;;; defuns-evil.el ends here

61
core/lib/defuns-file.el Normal file
View file

@ -0,0 +1,61 @@
;;; defuns-file.el
;;;###autoload (autoload 'narf:file-delete "defuns-file" nil t)
(evil-define-command narf:file-delete (&optional bang filename)
"Delete current buffer's file. If bang, then kill the buffer afterwards as well."
:repeat nil
(interactive "<!><f>")
(let ((filename (file-truename (or filename (buffer-file-name)))))
(if (not (file-exists-p filename))
(error "File doesn't exist: %s" filename)
(delete-file filename)
(when bang
(kill-this-buffer)
(unless (narf/real-buffer-p)
(narf/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)
"Deploy files (and their associated templates) quickly. Will prompt
you to fill in each snippet field before buffer closes unless BANG is
provided."
:repeat nil
(interactive "<f><!>")
(let ((dir (f-dirname path))
(fullpath (f-full path))
(is-auto t))
(when (and bang (not (file-exists-p dir))) (f-mkdir dir))
(if (file-exists-p dir)
(if (file-exists-p 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)))
(error "Directory doesn't exist: %s" dir))))
;;;###autoload (autoload 'narf:file-move "defuns-file" nil t)
(evil-define-command narf:file-move (path)
"Move current buffer's file to PATH. Replaces %, # and other variables (see
`evil-ex-replace-special-filenames')"
:repeat nil
(interactive "<f>")
(let* ((old-path (buffer-file-name))
(new-path (cond ((f-dir? path)
(f-expand (f-filename old-path) path))
((f-dir? (f-dirname path))
(f-full path))
(t (user-error "Not a valid destination: %s" path))))
(project-root (narf/project-root)))
(rename-file old-path new-path 1)
(rename-buffer (f-filename new-path))
(set-visited-file-name new-path)
(set-buffer-modified-p nil)
(save-place-forget-unreadable-files)
(message "File '%s' successfully renamed to '%s'"
(f-relative old-path project-root) (f-relative new-path project-root))))
(provide 'defuns-file)
;;; defuns-file.el ends here

View file

@ -0,0 +1,30 @@
;;; defuns-flycheck.el
;; for ../core-flycheck.el
;;;###autoload
(defun narf*fly-shorter-status (result)
(format "[%s]" (replace-regexp-in-string " FlyC:?" "" result)))
;;;###autoload
(defun narf*flycheck-buffer ()
(if (and (featurep 'flycheck) flycheck-mode)
(flycheck-buffer)))
;;;###autoload
(defun narf/flycheck-next-error ()
(interactive)
(call-interactively
(if (bound-and-true-p flycheck-mode)
'flycheck-next-error
'next-error)))
;;;###autoload
(defun narf/flycheck-previous-error ()
(interactive)
(call-interactively
(if (bound-and-true-p flycheck-mode)
'flycheck-previous-error
'previous-error)))
(provide 'defuns-flycheck)
;;; defuns-flycheck.el ends here

115
core/lib/defuns-helm.el Normal file
View file

@ -0,0 +1,115 @@
;;; defuns-helm.el
;; see ../core-helm.el
;;;###autoload
(defun narf|projectile-invalidate-cache-maybe ()
(when (narf/project-p)
(projectile-invalidate-cache nil)))
;;;###autoload
(defun narf*projectile-replace-prompt (&optional string)
"Don't show the project name in the prompts; I already know."
helm-global-prompt)
;;;###autoload
(defun narf*helm-hide-modeline (source &optional force)
"No persistent header."
(setq mode-line-format nil)
(setq header-line-format nil))
;;;###autoload
(defun narf/helm-split-window (window)
"Minimalistic split-fn; leaves popwin to handle helm buffers."
(if (one-window-p t)
(let ((helm-full-frame t))
(selected-window))
(other-window-for-scrolling)))
;;;###autoload
(defun narf/helm-get-org-candidates-in-file (filename min-depth max-depth &optional fontify nofname)
(with-current-buffer (pcase filename
((pred bufferp) filename)
((pred stringp) (find-file-noselect filename)))
(and fontify (jit-lock-fontify-now))
(let ((match-fn (if fontify 'match-string 'match-string-no-properties)))
(save-excursion
(goto-char (point-min))
(cl-loop with width = (window-width)
while (re-search-forward org-complex-heading-regexp nil t)
if (let ((num-stars (length (match-string-no-properties 1))))
(and (>= num-stars min-depth) (<= num-stars max-depth)))
collect `(,(let ((heading (funcall match-fn 4))
(file (unless nofname
(concat (f-no-ext (f-relative filename org-directory)) ":")))
(level (length (match-string-no-properties 1))))
(org-format-outline-path
(append (org-get-outline-path t level heading)
(list heading)) width file))
. ,(point-marker)))))))
;;;###autoload (autoload 'narf:helm-recentf "defuns-helm" nil t)
(evil-define-command narf:helm-recentf (&optional bang)
"Ex-mode interface for `helm-recentf' and `helm-projectile-recentf'. If
`bang', then `search' is interpreted as regexp."
:repeat nil
(interactive "<!>")
(if bang (helm-recentf) (helm-projectile-recentf)))
;; Ex-mode interface for `helm-ag'. If `bang', then `search' is interpreted as
;; regexp.
;;;###autoload (autoload 'narf:helm-search "defuns-helm" nil t)
(evil-define-operator narf:helm-search (beg end &optional search hidden-files-p pwd-p regex-p)
:type inclusive
:repeat nil
(interactive "<r><a><!>")
(require 'helm-ag)
(let* ((helm-ag--default-directory (if pwd-p default-directory (concat (narf/project-root) "/")))
(helm-ag-command-option (concat (unless regex-p "-Q ")
(if hidden-files-p "--hidden ")))
(input "")
(header-name (format "Search in %s" helm-ag--default-directory)))
(if search
(progn
(helm-attrset 'search-this-file nil helm-ag-source)
(setq helm-ag--last-query search))
(if (and beg end (/= beg (1- end)))
(setq input (buffer-substring-no-properties beg end))))
(helm-attrset 'name header-name helm-ag-source)
(helm :sources (if search (helm-ag--select-source) '(helm-source-do-ag))
:buffer "*helm-ag*"
:input input
:prompt helm-global-prompt)))
;;;###autoload (autoload 'narf:helm-regex-search "defuns-helm" nil t)
(evil-define-operator narf:helm-regex-search (beg end &optional search bang)
:type inclusive :repeat nil
(interactive "<r><a><!>")
(narf:helm-search beg end search bang nil t))
;;;###autoload (autoload 'narf:helm-regex-cwd "defuns-helm" nil t)
(evil-define-operator narf:helm-search-cwd (beg end &optional search bang)
;; Ex-mode interface for `helm-do-ag'. If `bang', then `search' is interpreted
;; as regexp
:type inclusive :repeat nil
(interactive "<r><a><!>")
(narf:helm-search beg end search bang t nil))
;;;###autoload (autoload 'narf:helm-regex-search-cwd "defuns-helm" nil t)
(evil-define-operator narf:helm-regex-search-cwd (beg end &optional search bang)
:type inclusive :repeat nil
(interactive "<r><a><!>")
(narf:helm-search beg end search bang t t))
;; 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)
:repeat nil
(interactive "<a><!>")
(if (eq major-mode 'scss-mode)
(if bang (helm-css-scss-multi search) (helm-css-scss search))
(if bang (helm-multi-swoop-all search) (helm-swoop :$query search))))
(provide 'defuns-helm)
;;; defuns-helm.el ends here

65
core/lib/defuns-ido.el Normal file
View file

@ -0,0 +1,65 @@
;;; defuns-ido.el
;;;###autoload
(defun narf*ido-sort-mtime ()
"Sort ido filelist by mtime instead of alphabetically."
(setq ido-temp-list
(sort ido-temp-list
(lambda (a b)
(time-less-p
(sixth (file-attributes (concat ido-current-directory b)))
(sixth (file-attributes (concat ido-current-directory a)))))))
(ido-to-end ;; move . files to end (again)
(delq nil (mapcar
(lambda (x) (and (char-equal (string-to-char x) ?.) x))
ido-temp-list))))
;;;###autoload
(defun narf|ido-setup-home-keybind ()
"Go to $HOME with ~"
(define-key ido-file-completion-map (kbd "~")
(λ (if (looking-back "/")
(insert "~/")
(call-interactively 'self-insert-command)))))
;;;###autoload
(defun narf/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)
(interactive)
(let ((default-directory (or dir default-directory)))
(ido-find-file-other-window)))
;;;###autoload
(defun narf/ido-find-project-file ()
(interactive)
(let ((default-directory (narf/project-root)))
(ido-find-file)))
;;;###autoload
(defun narf/ido-find-org-file ()
(interactive)
(let ((default-directory org-directory))
(ido-find-file)))
;;;###autoload
(defun narf/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
(interactive "<!>")
(if bang
(ido-find-file-in-dir narf-modules-dir)
(ido-find-file-in-dir narf-emacs-dir)))
(provide 'defuns-ido)
;;; defuns-ido.el ends here

View file

@ -0,0 +1,34 @@
;;; defuns-isearch.el
;;;###autoload
(defun narf/isearch-delete-word ()
(interactive)
(let ((num (length isearch-string))
(string (s-reverse isearch-string)))
(when (string-match "[^a-zA-Z0-9]" string 1)
(setq num (match-beginning 0)))
(dotimes (i num)
(isearch-pop-state))
(isearch-update)))
;;;###autoload
(defun narf/isearch-delete-line ()
(interactive)
(let ((num (length isearch-string)))
(dotimes (i num) (isearch-pop-state))
(isearch-update)))
;;;###autoload
(defun narf/isearch-paste-from-register (reg)
(interactive)
(let ((str (evil-get-register reg t)))
(when (> (length str) 0)
(isearch-yank-string str))))
;;;###autoload
(defun narf/isearch-paste-from-clipboard ()
(interactive)
(narf:isearch-paste-from-register ?+))
(provide 'defuns-isearch)
;;; defuns-isearch.el ends here

View file

@ -0,0 +1,40 @@
;;; defuns-neotree.el
;; for ../core-project.el
;;;###autoload
(defun narf/neotree-open (&optional dir)
(interactive)
(neotree-dir (or dir (narf/project-root))))
;;;###autoload
(defun narf/neotree-toggle ()
(interactive)
(if (neo-global--window-exists-p)
(neotree-hide)
(narf/neotree-open)))
;;;###autoload
(defun narf/neotree-find ()
(interactive)
(save-excursion (narf/neotree-open))
(neotree-find))
;;;###autoload
(defun narf|neotree-close-on-window-change ()
"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*neo-buffer-fold-symbol (name)
"Custom hybrid ascii theme with leading whitespace."
(let ((n-insert-symbol (lambda (n)
(neo-buffer--insert-with-face
n 'neo-expand-btn-face))))
(or (and (equal name 'open) (funcall n-insert-symbol "- "))
(and (equal name 'close) (funcall n-insert-symbol "> "))
(and (equal name 'leaf) (funcall n-insert-symbol " ")))))
(provide 'defuns-neotree)
;;; defuns-neotree.el ends here

11
core/lib/defuns-nlinum.el Normal file
View file

@ -0,0 +1,11 @@
;;; defuns-nlinum.el
;;;###autoload
(defun narf/nlinum-toggle ()
(interactive)
(if nlinum-mode
(narf|nlinum-disable)
(narf|nlinum-enable)))
(provide 'defuns-nlinum)
;;; defuns-nlinum.el ends here

11
core/lib/defuns-popwin.el Normal file
View file

@ -0,0 +1,11 @@
;;; defuns-popwin.el
;;;###autoload
(defun narf/popwin-toggle ()
(interactive)
(if (popwin:popup-window-live-p)
(popwin:close-popup-window)
(popwin:popup-last-buffer)))
(provide 'defuns-popwin)
;;; defuns-popwin.el ends here

View file

@ -0,0 +1,44 @@
;;; 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
determine if a directory is a project."
(let ((home (file-truename "~")))
(catch 'found
(f-traverse-upwards
(lambda (path)
(let ((path (file-truename path)))
(if (file-equal-p home path)
(throw 'found (if strict-p nil default-directory))
(dolist (file narf-project-root-files)
(when (file-exists-p (expand-file-name file path))
(throw 'found path)))))) default-directory)
default-directory)))
;;;###autoload
(defun narf/project-has-files (files &optional root)
"Return non-nil if `file' exists in the project root."
(let ((root (or root (narf/project-root)))
(files (if (listp files) files (list files)))
found-p file)
(while (and files (not found-p))
(setq file (pop files))
(setq found-p (file-exists-p (narf/project-path-to file root))))
found-p))
;;;###autoload
(defun narf/project-path-to (file &optional root)
(let ((root (or root (narf/project-root))))
(expand-file-name file root)))
;;;###autoload
(defun narf/project-name (&optional root)
(file-name-nondirectory (directory-file-name (or root (narf/project-root)))))
;;;###autoload
(defun narf/project-p ()
(not (null (narf/project-root t))))
(provide 'defuns-project)
;;; defuns-project.el ends here

View file

@ -0,0 +1,71 @@
;;; defuns-quickrun.el
;;;; Code building ;;;;;;;;;;;;;;;;;;;;;;
(defvar narf--build-command '("make %s" . "Makefile"))
(make-variable-buffer-local 'narf--build-command)
;;;###autoload
(defun narf/set-build-command (command &optional file)
(when (or (null file)
(narf/project-has-files file))
(setq narf--build-command `(,command . ,file))))
;;;###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."
(interactive "<sh>")
(when (null narf--build-command)
(user-error "No build command was set"))
(let ((build-file (cdr narf--build-command))
(build-cmd (car narf--build-command)))
(if (narf/project-has-files build-file)
(compile (format "cd '%s' && %s" build-file (format build-cmd (or arg ""))))
(error "Could not find Makefile"))))
;;;; Code running ;;;;;;;;;;;;;;;;;;;;;;
;;;###autoload (autoload 'narf:eval-buffer "defuns-quickrun" nil t)
(evil-define-command narf:eval-buffer ()
:move-point nil
(interactive)
(cond ((eq major-mode 'emacs-lisp-mode)
(narf: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)
:move-point nil
(interactive "<r>")
(cond ((eq major-mode 'emacs-lisp-mode)
(let* ((pp-escape-newlines nil)
(out (s-trim (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)
(beginning-of-buffer)
(read-only-mode 1)
(popwin:popup-buffer buf :height (if (> lines 25) 25 (1+ lines))))))))
(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)
(interactive "<r>")
(cond ((eq major-mode 'emacs-lisp-mode)
(kill-region beg end)
(condition-case nil
(prin1 (eval (read (current-kill 0)))
(current-buffer))
(error (message "Invalid expression")
(insert (current-kill 0)))))
(t (quickrun-replace-region beg end))))
(provide 'defuns-quickrun)
;;; defuns-quickrun.el ends here

35
core/lib/defuns-tmux.el Normal file
View file

@ -0,0 +1,35 @@
;;; defuns-tmux.el
(defun narf--tmux-send (command)
(shell-command (format "tmux send-keys %s" command)))
(evil-define-interactive-code "<tmux>"
"Ex tmux argument (a mix between <sh> <f> and <fsh>)"
:ex-arg shell
(list (when (evil-ex-p) (evil-ex-file-arg))))
;;;###autoload (autoload 'narf:tmux-run "defuns-tmux" nil t)
(evil-define-command narf:tmux-run (&optional command bang)
"Sends input to tmux. Use `bang' to append to tmux"
(interactive "<tmux><!>")
(nerf/tmux-send (format (if bang "C-u %s Enter" "%s")
(shell-quote-argument command)))
(when (evil-ex-p)
(message "[Tmux] %s" command)))
;;;###autoload (autoload 'narf:tmux-chdir "defuns-tmux" nil t)
(evil-define-command narf:tmux-chdir (&optional path bang)
"CDs in tmux using `narf/project-root'"
(interactive "<f><!>")
(let ((dir (shell-quote-argument
(if (and path (not (s-blank? path)))
(if (file-directory-p path)
(file-truename path)
(error "Directory doesn't exist %s" path))
(if bang default-directory (narf/project-root))))))
(nerf/tmux-send (format "C-u cd Space %s Enter" (shell-quote-argument dir)))
(when (evil-ex-p)
(message "[Tmux] cd %s" dir))))
(provide 'defuns-tmux)
;;; defuns-tmux.el ends here

29
core/lib/defuns-ui.el Normal file
View file

@ -0,0 +1,29 @@
;;; defuns-ui.el
;; for ../core-ui.el
;;;###autoload
(defun narf:toggle-transparency ()
(interactive)
(let* ((alpha (frame-parameter nil 'alpha))
(alpha-val (if (listp alpha) (car alpha) alpha)))
(if (/= alpha-val 97)
(set-frame-parameter nil 'alpha 100)
(set-frame-parameter nil 'alpha 0))))
;;;###autoload
(defun narf:toggle-fullscreen ()
(interactive)
(set-frame-parameter nil 'fullscreen
(when (not (frame-parameter nil 'fullscreen)) 'fullboth)))
(defvar narf--big-mode nil)
;;;###autoload
(defun narf:toggle-big-mode ()
(interactive)
(if narf--big-mode
(set-frame-font (apply #'font-spec narf-default-font))
(set-frame-font (apply #'font-spec narf-big-font)))
(setq narf--big-mode (not narf--big-mode)))
(provide 'defuns-ui)
;;; defuns-ui.el ends here

View file

@ -0,0 +1,168 @@
;;; defuns-whitespace.el
;;;###autoload
(defun narf--point-at-bol-non-blank()
(save-excursion (evil-first-non-blank) (point)))
;;;###autoload
(defun narf/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 ()
"Kill line to the first non-blank character. If invoked again
afterwards, kill line to column 1."
(interactive)
(let ((empty-line (sp-point-in-blank-line)))
(evil-delete (point-at-bol) (point))
(if (not empty-line)
(indent-according-to-mode))))
;;;###autoload
(defun narf/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))
(point (point)))
(if (= point-at-bol point)
(evil-move-beginning-of-line)
(unless (= (point-at-bol) point)
(evil-first-non-blank))))))
;;;###autoload
(defun narf/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))
(if (eq old-point (point)) ;
(evil-move-end-of-line))))))
;; Mimic expandtab in vim
;;;###autoload
(defun narf/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)
(cond ;; If in a string
((sp-point-in-string)
(call-interactively 'backward-delete-char-untabify))
;; If using tabs (or at bol), just delete normally
((or indent-tabs-mode
(= (point-at-bol) (point)))
(call-interactively 'backward-delete-char))
;; Delete up to the nearest tab column IF only whitespace between point
;; and bol.
((looking-back "^[\\t ]*" (point-at-bol))
(let ((movement (% (current-column) tab-width))
(p (point)))
(when (= movement 0)
(setq movement tab-width))
(save-match-data
(if (string-match "\\w*\\(\\s-+\\)$"
(buffer-substring-no-properties (- p movement) p))
(backward-delete-char (- (match-end 1) (match-beginning 1)))
(backward-delete-char-untabify 1)))))
;; Otherwise do a regular delete
(t (backward-delete-char-untabify 1))))
;;;###autoload
(defun narf/dumb-indent ()
"Inserts a tab character (or spaces x tab-width). Checks if the
auto-complete window is open."
(interactive)
(if indent-tabs-mode
(insert "\t")
(let* ((movement (% (current-column) tab-width))
(spaces (if (zerop movement) tab-width (- tab-width movement))))
(insert (s-repeat spaces " ")))))
;;;###autoload
(defun narf/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)
(progn (call-interactively 'self-insert-command)
(save-excursion (call-interactively 'self-insert-command)))
(call-interactively 'self-insert-command)))
;;;###autoload
(defun narf/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."
(interactive)
(save-match-data
(if (narf/surrounded-p)
(let ((whitespace-match (match-string 1)))
(cond ((not whitespace-match)
(call-interactively 'sp-backward-delete-char))
((string-match "\n" whitespace-match)
(evil-delete (point-at-bol) (point))
(delete-char -1)
(save-excursion (delete-char 1)))
(t
(just-one-space 0))))
(narf/backward-delete-whitespace-to-column))))
;;;###autoload
(defun narf/newline-and-indent ()
(interactive)
(cond ((sp-point-in-string)
(newline))
((sp-point-in-comment)
(cond ((eq major-mode 'js2-mode)
(js2-line-break))
((-contains? '(java-mode php-mode) major-mode)
(c-indent-new-comment-line))
((-contains? '(c-mode c++-mode objc-mode css-mode scss-mode) major-mode)
(newline-and-indent)
(insert "* ")
(indent-according-to-mode))
(t (indent-new-comment-line))))
(t (newline-and-indent))))
;;;###autoload (autoload 'narf:whitespace-retab "defuns-whitespace" nil t)
(evil-define-operator narf: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
:move-point nil
:type line
(interactive "<r>")
(unless (and beg end)
(setq beg (point-min))
(setq end (point-max)))
(if indent-tabs-mode
(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)
:repeat nil
(interactive "<r><a><!>")
(when regexp
(align-regexp beg end
(concat "\\(\\s-*\\)" (rxt-pcre-to-elisp regexp)) 1 1)))
;;;###autoload
(defun narf:toggle-delete-trailing-whitespace ()
(interactive)
(if (memq 'delete-trailing-whitespace before-save-hook)
(progn (message "Remove trailing whitespace: OFF")
(remove-hook 'before-save-hook 'delete-trailing-whitespace))
(message "Remove trailing whitespace: ON")
(add-hook 'before-save-hook 'delete-trailing-whitespace)))
(provide 'defuns-whitespace)
;;; defuns-whitespace.el ends here

View file

@ -0,0 +1,56 @@
;;; defuns-workgroup.el
;;;###autoload
(defun narf/wg-helm-switch-to-workgroup (name)
(wg-switch-to-workgroup (wg-get-workgroup name)))
;;;###autoload
(defun narf:helm-wg ()
(interactive)
(helm :sources '(narf/helm-source-wg)))
;;;###autoload
(defun narf/wg-projectile-switch-project ()
(let ((workgroup-name (file-name-nondirectory (directory-file-name (narf/project-root)))))
(wg-create-workgroup workgroup-name t)
(helm-projectile-find-file)))
;;;###autoload (autoload 'narf:save-session "defuns-workgroup" nil t)
(evil-define-command narf:save-session (&optional bang session-name)
(interactive "<!><a>")
(if session-name
(wg-save-session-as (concat wg-workgroup-directory session-name) (not bang))
(wg-save-session)))
;;;###autoload (autoload 'narf:load-session "defuns-workgroup" nil t)
(evil-define-command narf:load-session (&optional bang session-name)
(interactive "<!><a>")
(wg-open-session (if session-name
(concat wg-workgroup-directory session-name)
wg-session-file)))
;;;###autoload (autoload 'narf:workgroup-new "defuns-workgroup" nil t)
(evil-define-command narf:workgroup-new (bang name)
(interactive "<!><a>")
(unless name
(user-error "No name specified for new workgroup"))
(if bang
(wg-clone-workgroup (wg-current-workgroup) name)
(wg-create-workgroup name t)))
;;;###autoload (autoload 'narf:workgroup-rename "defuns-workgroup" nil t)
(evil-define-command narf:workgroup-rename (new-name)
(interactive "<a>")
(wg-rename-workgroup new-name))
;;;###autoload
(defun narf:kill-other-workgroups ()
"Kill all other workgroups."
(interactive)
(let (workgroup (wg-current-workgroup))
(dolist (w (wg-workgroup-list))
(unless (wg-current-workgroup-p w)
(wg-kill-workgroup w)))))
(provide 'defuns-workgroup)
;;; defuns-workgroup.el ends here

View file

@ -0,0 +1,120 @@
;;; defuns-yasnippet.el
;; for ../core-yasnippet.el
;;;###autoload
(defun narf|yas-before-expand ()
"Switch to insert mode when expanding a template via backtab, or go back to
normal mode if there are no fields."
;; Strip out the shitespace before a line selection.
(when (narf/evil-visual-line-state-p)
(setq yas-selected-text
(replace-regexp-in-string
"\\(^ *\\|\n? $\\)" ""
(buffer-substring-no-properties (region-beginning)
(1- (region-end))))))
(evil-insert-state +1))
;;;###autoload
(defun narf|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 ()
"Switch to insert mode when expanding a template via backtab, or go back to
normal mode if there are no fields."
(interactive)
(yas-insert-snippet)
(evil-insert-state +1))
;;;###autoload
(defun narf/yas-goto-start-of-field ()
"Go to the beginning of a field."
(interactive)
(let* ((snippet (car (yas--snippets-at-point)))
(position (yas--field-start (yas--snippet-active-field snippet))))
(if (= (point) position)
(move-beginning-of-line 1)
(goto-char position))))
;;;###autoload
(defun narf/yas-goto-end-of-field ()
(interactive)
(let* ((snippet (car (yas--snippets-at-point)))
(position (yas--field-end (yas--snippet-active-field snippet))))
(if (= (point) position)
(move-end-of-line 1)
(goto-char position))))
;;;###autoload
(defun narf/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
(overlay-buffer yas--active-field-overlay)
(overlay-get yas--active-field-overlay 'yas--field)))))
(cond ((eq (point) (marker-position (yas--field-start field))) nil)
(t (delete-char -1)))))
;;;###autoload
(defun narf/yas-delete (&optional field)
(interactive)
(let ((field (or field (and yas--active-field-overlay
(overlay-buffer yas--active-field-overlay)
(overlay-get yas--active-field-overlay 'yas--field)))))
(cond ((and field
(not (yas--field-modified-p field))
(eq (point) (marker-position (yas--field-start field))))
(yas--skip-and-clear field)
(yas-next-field 1))
((eq (point) (marker-position (yas--field-end field))) nil)
(t (delete-char 1)))))
;;;###autoload
(defun narf/yas-clear-to-sof (&optional field)
(interactive)
(let* ((field (or field (and yas--active-field-overlay
(overlay-buffer yas--active-field-overlay)
(overlay-get yas--active-field-overlay 'yas--field))))
(sof (marker-position (yas--field-start field))))
(when (and field (> (point) sof))
(delete-region sof (point)))))
;; Snippet helpers ;;;;;;;;;;;;;;;;;;;;;
;;;###autoload
(defun !%! ()
"Snippet function. Shorthand defun to surround text with newlines if more
than one line."
(when %
(if (> (length (s-lines %)) 1)
(concat "\n" % "\n")
(s-trim %))))
;;;###autoload
(defun !% ()
"Snippet function. Shorthand defun for snippets: prepends a newline to
`yas-selected-text' IF it contains more than one line."
(when %
(if (> (length (s-lines %)) 1)
(concat "\n" %)
(s-trim %))))
;;;###autoload
(defun %1 ()
"Trim selection; do no further processing."
(s-trim %))
;;;###autoload (autoload 'narf:yas-snippets "defuns-yasnippet" nil t)
(evil-define-command narf:yas-snippets (&optional bang)
(interactive "<!>")
(if bang
(narf/ido-find-file (car narf-snippet-dirs))
(yas-visit-snippet-file)))
;;;###autoload
(defun narf:yas-file-templates ()
(interactive)
(narf/ido-find-file (cdr narf-snippet-dirs)))
(provide 'defuns-yasnippet)
;;; nlinum-defuns.el ends here

View file

@ -0,0 +1,18 @@
;;; macros-auto-insert.el
;; for ../core-auto-insert.el
;;;###autoload
(defmacro add-template! (regexp-or-major-mode uuid yas-mode &optional project-only)
`(define-auto-insert ,regexp-or-major-mode
(lambda ()
(unless (or (and ,project-only (not (narf/project-p)))
(not (or (eq major-mode ,yas-mode)
(symbol-value ,yas-mode))))
(insert ,uuid)
(yas-expand-from-trigger-key)
(if (string-equal ,uuid (s-trim (buffer-string)))
(erase-buffer)
(evil-insert-state 1))))))
(provide 'macros-auto-insert)
;;; macros-auto-insert.el ends here

View file

@ -0,0 +1,8 @@
;;; defuns-buffers.el
;;;###autoload
(defun add-unreal-buffer! (regexp)
(add-to-list 'narf-unreal-buffers regexp))
(provide 'defuns-buffers)
;;; defuns-buffers.el ends here

View file

@ -0,0 +1,22 @@
;;; macros-company.el --- macros for company-mode
;; for ../core-company.el
;;;###autoload
(defmacro add-company-backend! (hook backends)
"Register a company backend for a mode."
(let ((def-name (intern (format "narf--init-company-%s" hook)))
(quoted (eq (car-safe backends) 'quote)))
`(progn
(defun ,def-name ()
(set (make-local-variable 'company-backends)
(append '((,@(mapcar (lambda (backend)
(if quoted
backend
(intern (format "company-%s" backend))))
(if quoted (cadr backends) backends))
company-semantic))
company-backends)))
(add-hook ',(intern (format "%s-hook" hook)) ',def-name))))
(provide 'macros-company)
;;; macros-company.el ends here

13
core/lib/macros-popwin.el Normal file
View file

@ -0,0 +1,13 @@
;;; macros-popwin.el
;;;###autoload
(defmacro add-popwin-rule! (&rest forms)
"Register a rule for popwin. See `popwin:special-display-config'.
Example:
(add-popwin-rule! \"^\\*Flycheck.*\\*$\" :regexp t :position bottom :height 0.25 :noselect t)"
(declare (indent defun))
`(push '(,@forms) popwin:special-display-config))
(provide 'macros-popwin)
;;; macros-popwin.el ends here

View file

@ -0,0 +1,13 @@
;;; macros-quickrun.el
;;;###autoload
(defmacro build-for! (mode command 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
(when (or (null ,build-file)
(narf/project-has-files ,build-file))
(setq narf--build-command '(,command . ,build-file)))))
(provide 'macros-quickrun)
;;; macros-quickrun.el ends here

View file

@ -0,0 +1,17 @@
;;; macros-yasnippet.el
;; for ../core-yasnippet.el
;;;###autoload
(defmacro add-yas-minor-mode! (&rest modes)
"Register minor MODES in yasnippet."
`(after! yasnippet
(when (boundp 'yas-extra-modes)
,@(mapcar (lambda (mode)
`(after! ,(cadr mode)
(if (symbol-value ,mode)
(yas-activate-extra-mode ,mode)
(setq yas-extra-modes (delq ,mode yas-extra-modes)))))
modes))))
(provide 'macros-yasnippet)
;;; macros-yasnippet.el ends here