Next: , Previous: , Up: Api   [Contents][Index]


5.5 Command

If words of command are not clear and distinct, if orders are not thoroughly understood, then the general is to blame.

Sun Tzu

The command module is responsible for a couple things. In Emacs one defines commands by using the special form [[(interactive)]] within the body of the procedure. Consider this simple command.

(defun hello-command ()
  (interactive)
  (message "Hello, Emacs!"))

Emacsy uses a more Scheme-like means of defining commands as shown below.

(define-interactive (hello-command)
  (message "Hello, Emacsy!"))

One deviation from Emacs I want to see within Emacsy is to have the commands be more context sensitive. To illustrate the problem when I hit M-x TAB TAB it autocompletes all the available commands into a buffer. In my case that buffer contains 4,840 commands. This doesn’t seem to hurt command usability, but it does hurt the command discoverability.

I want Emacsy to have command sets that are analogous to keymaps. There will be a global command set [[global-cmdset]] similar to the global keymap [[global-map]]. And in the same way that major and minor modes may add keymaps to a particular buffer, so too may they add command maps.

The class holds the entries, a string completer for tab completion, and potentially a parent command map.

Scheme Procedure: module-command-interface mod
Scheme Procedure: module-export-command! m names
Variable: in-what-command
Variable: this-command
Variable: last-command
Variable: kill-rogue-coroutine?
Variable: seconds-to-wait-for-yield
Variable: this-interactive-command
Scheme Procedure: command-contains? (cmap <command-set>) command-symbol

We have accessors for adding, removing, and testing what’s in the set. Note that the parent set is never mutated.

Scheme Procedure: command-add! (cmap <command-set>) command-symbol
Scheme Procedure: command-remove! (cmap <command-set>) command-symbol
Scheme Procedure: register-interactive name proc
Scheme Procedure: command->proc command
Scheme Procedure: command-name command
Scheme Procedure: command? object
Scheme Procedure: set-command-properties! proc #:optional (name #f)
Scheme Procedure: what-command-am-i?
Scheme Procedure: command-execute command . args
Scheme Procedure: call-interactively command . args
Scheme Procedure: called-interactively? #:optional (kind (quote any))

Next: , Previous: , Up: Api   [Contents][Index]