Skip to content

Commit

Permalink
WIP: Emacs support
Browse files Browse the repository at this point in the history
  • Loading branch information
polytypic committed Oct 8, 2020
1 parent 1a7864f commit 9824d26
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions emacs/cppsm.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
;;; cppsm --- summary

;;; commentary:

;;; code:

(require 'ansi-color)
(require 'comint)
(require 'subr-x)

(defun cppsm-project-directory-from (candidate)
"Determine current project directory."
(if (file-exists-p (concat candidate ".cppsm"))
candidate
(let ((parent (file-name-directory (directory-file-name candidate))))
(unless (equal parent candidate)
(cppsm-project-directory-from parent)))))

(defconst cppsm-buffer-name "*cppsm*")

(defun cppsm-run-command ())

(defun cppsm-test ()
"Run `cppsm test` in the current project."
(interactive)
(if-let (default-directory (cppsm-project-directory-from default-directory))
(progn
(when-let ((buffer (get-buffer cppsm-buffer-name)))
(kill-buffer buffer))
(when-let ((process (start-process-shell-command
"cppsm-test"
(let ((buffer (get-buffer-create cppsm-buffer-name)))
(with-current-buffer buffer
(comint-mode))
buffer)
"cppsm test")))
(set-process-filter process 'comint-output-filter)
(set-process-sentinel
process
(function (lambda (process event)
(message (string-trim event))
(when-let ((buffer (get-buffer "*cppsm*")))
(with-current-buffer buffer
(compilation-mode))))))))
(message "Couldn't determine cppsm project directory.")))

(provide 'cppsm)
;;; cppsm ends here

(function (lambda () ))

0 comments on commit 9824d26

Please sign in to comment.