Skip to content

Instantly share code, notes, and snippets.

@ignacy
Created July 12, 2013 13:10
Show Gist options
  • Select an option

  • Save ignacy/5984355 to your computer and use it in GitHub Desktop.

Select an option

Save ignacy/5984355 to your computer and use it in GitHub Desktop.
(require 'ido)
(defvar ebot-default-process-name "zsh"
"*Default name for the buffer to which we send the commands.*")
(defun ebot-line ()
(number-to-string (count-lines 1 (point))))
(defun ebot-file-name-and-position ()
(concat buffer-file-name ":" (ebot-line)))
(defmacro ebot-command (command-name command &optional process-name)
"Create new ebot command"
(let* ((fun-name (intern command-name))
(process (if (eq process-name nil)
ebot-default-process-name
process-name))
(command-to-run (if (stringp command)
`(concat ,command "\n")
`(concat (,command) "\n"))))
`(defun ,fun-name ()
(interactive)
(comint-send-string (get-buffer-process ,process) ,command-to-run)
(switch-to-buffer ,process))))
;; Note: To test that makro works OK, eval this:
;; (macroexpand '(ebot-command "ls" "ls -al"))
(provide 'ebot)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment