Created
July 25, 2018 15:35
-
-
Save jmercouris/bce04b7cbdb5d3604cc1b54ebd2110b6 to your computer and use it in GitHub Desktop.
This file contains 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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; COMMAND.lisp -- where the mcro is stored | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(defparameter *commands* (make-hash-table :test 'equalp)) | |
(defclass command () | |
((name :initarg :name :accessor name) | |
(implementation :initarg :impl :accessor impl) | |
(completion :initarg :compl :accessor cmpl) | |
(documentation :initarg :doc :accessor doc))) | |
(defmacro define-command (name arglist &body body) | |
(let ((documentation (if (stringp (first body)) (first body) nil)) | |
(body (if (stringp (first body)) (rest body) body))) | |
`(progn | |
(defun ,name ,arglist ,@body) | |
(make-instance 'command | |
:name (symbol-name ',name) | |
:impl #',name | |
:doc ,documentation)))) | |
(defmacro define-command-completion (name arglist &body body) | |
(let* ((body (if (stringp (first body)) (rest body) body)) | |
(prefix-name (concatenate 'string (symbol-name name) "-COMPLETION")) | |
(symbol-name (intern prefix-name))) | |
`(progn | |
(defun ,symbol-name ,arglist ,@body) | |
(setf (cmpl (get-named-command (symbol-name ',name))) #',symbol-name)))) | |
(defmethod initialize-instance :after ((command command) &key) | |
(setf (gethash (name command) *commands*) command)) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; DEFINE.lisp | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(define-command define (interface arguments) | |
"Define a term, prompt for words to select." | |
(list "return a definition")) | |
(define-command-completion define (interface arguments) | |
"Show candidates of possible words for the user" | |
(list "return completions for a word")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment