Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emacs support #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 () ))