(defun event-modifiers (event)
"Returns a list of symbols representing the modifier keys in event EVENT.
The elements of the list may include `meta', `control',
-`shift', `hyper', `super', `alt', `click', `drag', and `down'."
+`shift', `hyper', `super', `alt', `click', `double', `triple', `drag',
+and `down'."
(let ((type event))
(if (listp type)
(setq type (car type)))
The `posn-' functions access elements of such lists."
(nth (if (consp (nth 2 event)) 2 1) event))
+(defsubst event-click-count (event)
+ "Return the multi-click count of EVENT, a click or drag event.
+The return value is a positive integer."
+ (if (integerp (nth 2 event)) (nth 2 event) 1))
+
(defsubst posn-window (position)
"Return the window in POSITION.
POSITION should be a list of the form
Don't change it.")
(defun add-hook (hook function &optional append)
- "Add to the value of HOOK the function FUNCTION unless already present (it
-becomes the first hook on the list unless optional APPEND is non-nil, in
-which case it becomes the last). HOOK should be a symbol, and FUNCTION may be
-any valid function. HOOK's value should be a list of functions, not a single
-function. If HOOK is void, it is first set to nil."
+ "Add to the value of HOOK the function FUNCTION.
+FUNCTION is not added if already present.
+FUNCTION is added (if necessary) at the beginning of the hook list
+unless the optional argument APPEND is non-nil, in which case
+FUNCTION is added at the end.
+
+HOOK should be a symbol, and FUNCTION may be any valid function. If
+HOOK is void, it is first set to nil. If HOOK's value is a single
+function, it is changed to a list of functions."
(or (boundp hook) (set hook nil))
+ ;; If the hook value is a single function, turn it into a list.
+ (let ((old (symbol-value hook)))
+ (if (or (not (listp old)) (eq (car old) 'lambda))
+ (set hook (list old))))
(or (if (consp function)
;; Clever way to tell whether a given lambda-expression
;; is equal to anything in the hook.