Created
July 12, 2013 13:10
-
-
Save ignacy/5984355 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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