(py|rb)env version in modeline + define-builder macro
This commit is contained in:
parent
979472385b
commit
c27dfd5540
10 changed files with 89 additions and 38 deletions
13
core/lib/defuns-spaceline.el
Normal file
13
core/lib/defuns-spaceline.el
Normal file
|
@ -0,0 +1,13 @@
|
|||
;;; defuns-spaceline.el
|
||||
|
||||
;;;###autoload
|
||||
(defun narf|spaceline-env-update ()
|
||||
(when narf--env-command
|
||||
(let* ((command (format "cd '%s' && %s" (narf/project-root) narf--env-command))
|
||||
(s (shell-command-to-string command)))
|
||||
(setq narf--env-version (if (string-match "[ \t\n\r]+\\'" s)
|
||||
(replace-match "" t t s)
|
||||
s)))))
|
||||
|
||||
(provide 'defuns-spaceline)
|
||||
;;; defuns-spaceline.el ends here
|
|
@ -1,7 +1,7 @@
|
|||
;;; macros-quickrun.el
|
||||
|
||||
;;;###autoload
|
||||
(defmacro build-for! (mode command &optional build-file)
|
||||
(defmacro define-builder! (mode command &optional build-file)
|
||||
"Register major/minor MODE with build COMMAND. If FILES are provided, do an
|
||||
additional check to make sure they exist in the project root."
|
||||
`(add-hook! ,mode
|
||||
|
|
10
core/lib/macros-spaceline.el
Normal file
10
core/lib/macros-spaceline.el
Normal file
|
@ -0,0 +1,10 @@
|
|||
;;; defuns-spaceline.el
|
||||
|
||||
;;;###autoload
|
||||
(defmacro define-env-command! (mode command)
|
||||
(add-hook! (focus-in find-file) 'narf|spaceline-env-update)
|
||||
`(add-hook ',(intern (format "%s-hook" (symbol-name mode)))
|
||||
(lambda () (setq narf--env-command ,command))))
|
||||
|
||||
(provide 'defuns-spaceline)
|
||||
;;; defuns-spaceline.el ends here
|
Loading…
Add table
Add a link
Reference in a new issue