Skip to content

Instantly share code, notes, and snippets.

@CarlOlson
Created March 31, 2017 01:38
Show Gist options
  • Save CarlOlson/026caa335b342f4e2f76e6a16ad1b1e7 to your computer and use it in GitHub Desktop.
Save CarlOlson/026caa335b342f4e2f76e6a16ad1b1e7 to your computer and use it in GitHub Desktop.
(defmacro se--when-windows (&rest body)
(declare (indent 1))
`(when (or (eq system-type 'ms-dos)
(eq system-type 'windows-nt)
(eq system-type 'cygwin))
,@body))
(se--when-windows
(defun se--remove-drive-letter (path)
(if (string-match-p "^.:" path)
(substring path 2)
path))
(defun se--remove-newline (path)
(cond
((string-suffix-p "\r\n" path)
(substring path 0 -2))
((string-suffix-p "\n" path)
(substring path 0 -1))
(t path)))
(defun se-inf-ask (question &optional fn)
(lexical-let* ((question (se--remove-drive-letter
(se--remove-newline
question)))
(fn fn)
(buffer-name (buffer-name))
(command (concat "echo " question
" | call" cedille-program-name)))
(run-with-idle-timer 0 nil
(lambda ()
(funcall (or fn #'se-inf-process-response)
buffer-name
(shell-command-to-string command))))))
) ;; end of windows-only code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment