
(require (quote hhist))

(defvar hrule:action (quote actype:act) "\
Value is a function of any number of arguments that executes actions.
Variable is used to vary actual effect of evaluating a Hyperbole action,
e.g. to inhibit actions.")

(fset (quote action:commandp) (quote commandp))

(defun action:create (param-list body) "\
Create an action defined by PARAM-LIST and BODY, a list of Lisp forms." (byte-code "9ƒ	 ‚ Â	BB‡" [body param-list lambda] 3))

(defun action:act (hbut action &optional same-window) "\
DON'T CALL THIS FUNCTION.  USE actype:act INSTEAD.
USED ONLY BY VERSION 1 HYPERBOLE BUTTONS.
Performs HBUT's ACTION.
An action may be a symbol, key sequence string, or any Lisp form.
Call 'action:kbd-macro' to create an action which executes a keyboard macro.
Optional SAME-WINDOW (only used by version 1 buttons) means output from
action should appear in same window.
Runs 'action:act-hook' before performing ACTION." (byte-code "	ËÂ\"Ì?ƒ Æ‚x Í ÎÏ!ˆ9ƒJ Ð!Æ	GÑUƒ4 Ò ‚F Ó!ƒ@ Ô!‚F ÕÖÐ!\"*‚r <ƒU Ô!‚r ;…f ×!‰…f Ø!?ƒo Ô!‚r Ô!ˆÙ!)+‡" [prefix-arg current-prefix-arg args hbut act action nil hist-elt sym-name action-name t hattr:get (apply action args) hhist:element run-hooks action:act-hook symbol-name 2 hyperb:action-v1 boundp eval error "(action:act): Action not defined: '%s'" key-binding integerp hhist:add] 16))

(defun action:kbd-macro (macro &optional repeat-count) "\
Returns Hyperbole action that executes a keyboard MACRO REPEAT-COUNT times." (byte-code "Â	E‡" [macro repeat-count execute-kbd-macro] 3))

(defun action:params (action) "\
Returns unmodified ACTION parameter list." (byte-code "<ƒ	 ‚ 9… Á!… K‰ˆA@‡" [action fboundp] 3))

(defun action:param-list (action) "\
Returns list of actual ACTION parameters (removes '&' special forms)." (byte-code "ÂÀÃÄÅ	!\"\"‡" [nil action delq mapcar (lambda (param) (byte-code "Â!ÃHÄUƒ Á‚ ‡" [param nil symbol-name 0 38] 3)) action:params] 6))

(defun action:path-args-abs (args-list &optional default-dirs) "\
Return any paths in ARGS-LIST made absolute.
Uses optional DEFAULT-DIRS or 'default-directory'.
Other arguments are returned unchanged." (byte-code "ÁÂ\"‡" [args-list mapcar (lambda (arg) (byte-code "Â	\"‡" [arg default-dirs hpath:absolute-to] 3))] 3))

(defun action:path-args-rel (args-list) "\
Return any paths in ARGS-LIST below current directory made relative.
Other paths are simply expanded.  Non-path arguments are returned unchanged." (byte-code "ÂÃÀ\"ÄÅ	\")‡" [dir args-list hattr:get hbut:current mapcar (lambda (arg) (byte-code "Â	\"‡" [arg dir hpath:relative-to] 3))] 4))

(defmacro hact (&rest args) "Performs action formed from rest of ARGS.
First arg may be a symbol or symbol name for either an action type or a
function.  Runs 'action:act-hook' before performing action." (byte-code "ÁÂÃÄDE!‡" [args eval cons hrule:action quote] 5))

(defun actype:act (actype &rest args) "\
Performs action formed from ACTYPE and rest of ARGS and returns value.
If value is nil, however, t is returned instead, to ensure that implicit button
types register the performance of the action.  ACTYPE may be a symbol or symbol
name for either an action type or a function.  Runs 'action:act-hook' before
performing ACTION." (byte-code "É!‰ˆ
Ê!Ë?ƒ ÌÍ\"‚^ Î ÏÐ!ˆ9†) <ƒ2 Ñ!‚T ;…H Ò!Ó!?…G ‰)ƒQ Ñ!‚T Ñ!†X ÈÔ!ˆ)+‡" [args prefix-arg current-prefix-arg action actype act hist-elt func t action:path-args-abs actype:action (apply action args) error "(actype:act): Null action for: '%s'" hhist:element run-hooks action:act-hook eval key-binding integerp hhist:add] 13))

(defun actype:action (actype) "\
Returns action part of ACTYPE (a symbol or symbol name).
ACTYPE may be a Hyperbole actype or Emacs Lisp function." (byte-code "Â	;ƒ 	Ã	!‰‚ Ä	!‰ˆÅÆÇ\"ƒ# 	‚( ÈÉP!Ê\"†4 Ë	!…4 	)‡" [actname actype nil intern symbol-name hattr:get string-match "::" intern-soft "actypes::" action fboundp] 7))

(defmacro actype:create (type params doc &rest default-action) "Creates an action TYPE (an unquoted symbol) with PARAMS, described by DOC.
The type uses PARAMS to perform DEFAULT-ACTION (list of the rest of the
arguments).  A call to this function is syntactically the same as for
'defun',  but a doc string is required.

Returns symbol created when successful, else nil." (byte-code "Å	\"‰ˆÆDÇÈÉ
%)‡" [default-action params plist type doc action:create action list htype:create actypes] 7))

(fset (quote defact) (quote actype:create))

(put (quote actype:create) (quote lisp-indent-hook) (quote defun))

(defun actype:delete (type) "\
Deletes an action TYPE (a symbol).  Returns TYPE's symbol if it existed." (byte-code "ÁÂ\"‡" [type htype:delete actypes] 3))

(defun actype:doc (hbut &optional full) "\
Returns first line of act doc for HBUT (a Hyperbole button symbol).
With optional FULL, returns full documentation string.
Returns nil when no documentation." (byte-code "Ç	!… È	É\"† È	Ê\"… 9ÄÄ
…& Ë!‰…? Ì!‰ˆ†? ÍÎ\"ÏO‰ˆ,‡" [act hbut sym-p end-line nil doc full hbut:is-p hattr:get action actype htype:doc substitute-command-keys string-match "[
]" 0] 9))

(defun actype:identity (&rest args) "\
Returns list of ARGS unchanged or if no ARGS, returns t.
Used as the setting of 'hrule:action' to inhibit action evaluation." (byte-code "† Á‡" [args t] 1))

(defun actype:interact (actype) "\
Interactively calls default action for ACTYPE.
ACTYPE is a symbol that was previously defined with 'defact'.
Returns nil only when no action is found or the action has no interactive
calling form." (byte-code "ÃÄÅÆ	!P!À\"… Ç!… È!† Â)‡" [action actype t hattr:get intern-soft "actypes::" symbol-name action:commandp call-interactively] 6))

(defun actype:params (actype) "\
Returns list of ACTYPE's parameters." (byte-code "ÁÂ!!‡" [actype action:params actype:action] 3))

(provide (quote hact))
