7.4 Command Arguments

  • 7.4.1 The Prefix Argument
  • 7.4.2 Lisp Arguments
  • There are three ways in which a command may be invoked: It may be bound to a key which has been typed, it may be invoked as an extended command, or it may be called as a Lisp function. Ideally commands should be written in such a way that they will behave sensibly no matter which way they are invoked. The functions which implement commands must obey certain conventions about argument passing if the command is to function properly. [annotate]

    7.4.1 The Prefix Argument

    Whenever a command is invoked it is passed as its first argument what is known as the prefix argument. The prefix argument is always either an integer or nil. When a command uses this value it is usually as a repeat count, or some conceptually similar function. [annotate]

    prefix-argument   [Function]
              

    This function returns the current value of the prefix argument. When set with setf, the new value becomes the prefix argument for the next command. [annotate]

    [annotate]

    If the prefix argument is not set by the previous command then the prefix argument for a command is nil. The prefix argument is not cleared after a command is invoked due to a transparent key binding. [annotate]

    7.4.2 Lisp Arguments

    It is often desirable to call commands from Lisp code, in which case arguments which would otherwise be prompted for are passed as optional arguments following the prefix argument. A command should prompt for any arguments not supplied.