Skip to content

Instantly share code, notes, and snippets.

@saitoha
Created December 19, 2012 12:27
Show Gist options
  • Select an option

  • Save saitoha/4336343 to your computer and use it in GitHub Desktop.

Select an option

Save saitoha/4336343 to your computer and use it in GitHub Desktop.
Get DA2/CPR response from emacs-lisp
(defun get-da2 ()
(let ((str ""))
(send-string-to-terminal "\e[>c")
(while (not (equal (setq chr (read-event nil nil 2)) 99))
(setq str (concat str (string chr))))
(if (string-match ">\\([0-9;]+\\)$" str)
(setq params (match-string 1 str)))))
(defun get-cpr ()
(let ((str ""))
(send-string-to-terminal "\e[6n")
(while (not (equal (setq chr (read-event nil nil 2)) 82))
(setq str (concat str (string chr))))
(if (string-match "\\([0-9;]+\\)$" str)
(setq params (match-string 1 str)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment