Writing Commands

#Syntax

(defun command-name (args)
"documentation" (interactive "template")
body)

#Example

(defun this-line-to-top-of-window (line)
    "Reposition current line to top of window.
With prefix argument LINE, put point on LINE."
    (interactive "P")
    (recenter (if (null line)
                  0
              (prefix-numeric-value line))))

The interactive spec says how to read arguments interactively. Type C-h f interactive RET for more details.

Comments