Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cxxxr committed Nov 13, 2017
1 parent fda8823 commit 0a749ce
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
12 changes: 4 additions & 8 deletions lem-core/defcommand.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,23 @@
(car arg-descripters))
(,fn-name ,@(collect-variables parms))))))))

(eval-when (:compile-toplevel :load-toplevel :execute)
(defun function-to-command-name (f)
(check-type f symbol)
(string-downcase f)))

(defun find-command (name)
(car (gethash name *command-table*)))

(defun find-command-symbol (name)
(cdr (gethash name *command-table*)))

(defun function-to-command (f)
(find-command (function-to-command-name f)))
(defun get-command (symbol)
(get symbol 'command))

(defun command-name (command)
(get command 'name))

(defmacro define-command (name parms (&rest arg-descripters) &body body)
(let ((gcmd (gensym (symbol-name name)))
(command-name (function-to-command-name name)))
(command-name (string-downcase name)))
`(progn
(setf (get ',name 'command) ',gcmd)
(setf (get ',gcmd 'name) ,command-name)
(setf (gethash ,command-name *command-table*) (cons ',gcmd ',name))
(defun ,name ,parms ,@body)
Expand Down
2 changes: 1 addition & 1 deletion lem-core/interp.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

(defun call-command (command-name arg)
(run-hooks *pre-command-hook*)
(prog1 (let ((cmd (function-to-command command-name)))
(prog1 (let ((cmd (get-command command-name)))
(if cmd
(funcall cmd arg)
(editor-error "~A: command not found" command-name)))
Expand Down
2 changes: 1 addition & 1 deletion lem-core/keymap.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
(defun find-keybind (key)
(let ((cmd (lookup-keybind key)))
(when (symbolp cmd)
(function-to-command cmd))))
(get-command cmd))))

(let ((abort-key (keyname->keychar "C-g")))
(defun abort-key-p (c)
Expand Down

0 comments on commit 0a749ce

Please sign in to comment.