Skip to content

Instantly share code, notes, and snippets.

@sellout
Created April 24, 2014 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sellout/11269679 to your computer and use it in GitHub Desktop.
Save sellout/11269679 to your computer and use it in GitHub Desktop.
(defun ansi-color-insertion-filter (proc string)
(when (buffer-live-p (process-buffer proc))
(with-current-buffer (process-buffer proc)
(save-excursion
;; Insert the text, advancing the process marker.
(goto-char (process-mark proc))
(insert (ansi-color-apply string))
(set-marker (process-mark proc) (point)))
(goto-char (process-mark proc)))))
(defun idris-ipkg-command (ipkg-file command)
"Run a command on ipkg-file. The command can be build, install, or clean."
;; Idris must have its working directory in the same place as the ipkg file
(let ((dir (file-name-directory ipkg-file))
(file (file-name-nondirectory ipkg-file))
(cmd (cond ((equal command 'build) "--build")
((equal command 'install) "--install")
((equal command 'clean) "--clean")
(t (error "Invalid command name %s" command)))))
(unless dir
(error "Unable to determine directory for filename '%s'" ipkg-file))
(let ((default-directory dir)) ; default-directory is a special variable - this starts idris in dir
(set-process-filter (start-process (concat "idris " cmd)
idris-ipkg-build-buffer-name idris-interpreter-path cmd file)
'ansi-color-insertion-filter)
(with-current-buffer idris-ipkg-build-buffer-name
(idris-ipkg-build-mode))
(pop-to-buffer idris-ipkg-build-buffer-name))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment