get it building again
[lice.git] / src / callint.lisp
blob19ec6aa5c92c67b03c06cfa43b0d441599c1b44f
1 ;;; Call a Lisp function interactively.
3 (in-package #:lice)
5 (defvar *prefix-arg* nil
6 "The value of the prefix argument for the next editing command.
7 It may be a number, or the symbol `-' for just a minus sign as arg,
8 or a list whose car is a number for just one or more C-u's
9 or nil if no argument has been specified.
11 You cannot examine this variable to find the argument for this command
12 since it has been set to nil by the time you can look.
13 Instead, you should use the variable `current-prefix-arg', although
14 normally commands can get this prefix argument with (interactive \"P\").")
16 (defvar *last-prefix-arg* nil
17 "The value of the prefix argument for the previous editing command.
18 See `prefix-arg' for the meaning of the value.")
20 (defvar *current-prefix-arg* nil
21 "The value of the prefix argument for this editing command.
22 It may be a number, or the symbol `-' for just a minus sign as arg,
23 or a list whose car is a number for just one or more C-u's
24 or nil if no argument has been specified.
25 This is what `(interactive \"P\")' returns.")
27 (defvar *command-history* nil
28 "List of recent commands that read arguments from terminal.
29 Each command is represented as a form to evaluate.")
31 (defun call-interactively (function &optional record-flag (keys *this-command-keys*))
32 "Call FUNCTION, reading args according to its interactive calling specs.
33 Return the value FUNCTION returns.
34 The function contains a specification of how to do the argument reading.
35 In the case of user-defined functions, this is specified by placing a call
36 to the function `interactive' at the top level of the function body.
37 See `interactive'.
39 Optional second arg RECORD-FLAG non-nil
40 means unconditionally put this command in the command-history.
41 Otherwise, this is done only if an arg is read using the minibuffer.
43 Optional third arg KEYS, if given, specifies the sequence of events to
44 supply, as a vector, if the command inquires which events were used to
45 invoke it. If KEYS is omitted or nil, the return value of
46 `*this-command-keys-vector*' is used."
47 ;;(setf function (lookup-command function))
48 (check-type function command)
50 (let ((args (mapcar (lambda (a)
51 (if (listp a)
52 (apply (gethash (first a) *command-arg-type-hash*) (cdr a))
53 (funcall (gethash a *command-arg-type-hash*))))
54 (command-args function))))
55 ;; XXX: Is this a sick hack? We need to reset the
56 ;; prefix-arg at the right time. After the command
57 ;; is executed we can't because the universal
58 ;; argument code sets the prefix-arg for the next
59 ;; command. The Right spot seems to be to reset it
60 ;; once a command is about to be executed, and
61 ;; after the prefix arg has been gathered to be
62 ;; used in the command. Which is right here.
63 (setf *prefix-arg* nil)
64 ;; Note that we use the actual function. If the
65 ;; function is redefined, the command will
66 ;; continue to be defined and will call the
67 ;; function declared above, not the redefined one.
68 (apply (command-fn function) args)))
70 (defun prefix-numeric-value (prefix)
71 "Return numeric meaning of raw prefix argument RAW.
72 A raw prefix argument is what you get from :raw-prefix.
73 Its numeric meaning is what you would get from :prefix."
74 ;; TODO
75 (cond ((null prefix)
77 ((eq prefix '-)
78 -1)
79 ((and (consp prefix)
80 (integerp (car prefix)))
81 (car prefix))
82 ((integerp prefix)
83 prefix)
84 (t 1)))