
(require (quote hpath))

(require (quote set))

(defvar hargs:reading-p nil "\
t only when Hyperbole is prompting user for input, else nil.")

(defun hargs:actype-get (actype &optional modifying) "\
Interactively gets and returns list of arguments for ACTYPE's parameters.
Current button is being modified when MODIFYING is non-nil." (byte-code "!	\"" [actype modifying hargs:action-get actype:action] 4))

(defun hargs:at-p nil "\
Returns thing at point as a string, if of interest as an arg now, else nil.
Caller should have checked whether an argument is presently being read
and set 'hargs:reading-p' to an appropriate argument type.
Handles all of the interactive argument types that 'hargs:iform-read' does." (byte-code "l g	=   =. #( !g) !)g	=: !g C g	= \" =f \"b !) ={ !w !) !  \" g	= \" = \" ! ! ) = ! ! ! ) !  \" g	=\"\"\"g	= 	=3 !\"@)g	=<	=O !\"@)g \"#|	!!{!!\"		))g	= g	==@ 
\";A B \"!OC D R)g	E =F  G H  D!g	I = J !K !)g	L = g	M =$gg	N =HO فP Q #DR !)g	S =gT U !V !fW p!)" [nil hargs:reading-p t major-mode file buffer-file-name dir default-directory name entry Info-current-file Info-directory Info-current-node sym key-seq hmenu selected-window minibuffer-window char-to-string search-backward " " skip-chars-forward 0 ebut ebut:label-p as-label hpath:at-p non-exist dired-mode dired-get-filename hpath:absolute-to monkey-mode monkey-filename hpath:is-p hpath:ange-ftp-p directory file-directory-p string hargs:delimited "\"" "'" "`" actype actypes find-tag-default set:member htype:names ibtype ibtypes equal buffer-name " *Completions*" re-search-backward "^\\|[ 	][ 	]" " 	" looking-at "[^	
]+" buffer-substring match-beginning match-end sexpression hargs:sexpression-p Info-node Info-mode hpath:relative-to string-match "^\\./" "(" ")" mail hmail:reader-p prin1-to-string rmail:msg-id-get symbol fboundp boundp buffer character key hbut:label-p "{" "}" kbd-key:normalize integer skip-chars-backward "-0-9" "-?[0-9]+" read] 61))

(defun hargs:iform-read (iform &optional modifying) "\
Reads action arguments according to IFORM, a list with car = 'interactive.
Optional MODIFYING non-nil indicates current button is being modified, so
button's current values should be presented as defaults.
See also documentation for 'interactive'." (byte-code "	
< 
@=? !
A@
?+ 
;+ 
\"2 ÂՎƉ
;?R I \"
!)
Gc \"
	
	H= 	܉

W 

#!

	!O
	@? ;  !\"A? <? B @= A!\" B !.))" [prefix-arg current-prefix-arg iform nil prev-reading-p hargs:reading-p t defaults modifying i start end ientry results val default interactive error "(hargs:iform-read): arg must be a list whose car = 'interactive." equal "" ((byte-code "	" [hargs:reading-p prev-reading-p] 2)) hattr:get hbut:current args eval 0 42 1 string-match "
\\|\\'" match-end match-beginning prin1-to-string hargs:get append nreverse] 15))

(defun hargs:read (prompt &optional predicate default err val-type) "\
PROMPTs without completion for a value matching PREDICATE and returns it.
PREDICATE is an optional boolean function of one argument.  Optional DEFAULT
is a string to insert after PROMPT as the default return value.  Optional
ERR is a string to display temporarily when an invalid value is given.
Optional VAL-TYPE is a symbol indicating type of value to be read.  If VAL-TYPE
is not equal to 'sexpression' and is non-nil, value is returned as a string." (byte-code " pώ	? 	=* Љ3 	ʉG ;?G !ՏU ʂv j 
\"j 
!!Ov 
\"?   
  !!4 
)." [bad-val nil val stringify prev-reading-p hargs:reading-p read-func owind obuf val-type t default predicate err selected-window ((byte-code "	
!!" [hargs:reading-p prev-reading-p owind obuf select-window switch-to-buffer] 3)) sexpression read-minibuffer read-string prin1-to-string (byte-code " 
#" [bad-val val read-func prompt default funcall] 4) ((error (byte-code "" [bad-val t] 2))) string-match "\\`\"\\([^\"]*\\)\"\\'" match-beginning 1 match-end funcall beep message sit-for 3] 11))

(defun hargs:read-match (prompt table &optional predicate must-match default val-type) "\
PROMPTs with completion for a value in TABLE and returns it.
TABLE is an alist where each element's car is a string, or it may be an
obarray for symbol-name completion.
Optional PREDICATE limits table entries to match against.
Optional MUST-MATCH means value returned must be from TABLE.
Optional DEFAULT is a string inserted after PROMPT as default value.
Optional VAL-TYPE is a symbol indicating type of value to be read." (byte-code " 	? /  pΎ	  Ɖ
	%)," [must-match table nil prev-reading-p hargs:reading-p completion-ignore-case t owind obuf val-type prompt predicate default selected-window ((byte-code "	
!!" [hargs:reading-p prev-reading-p owind obuf select-window switch-to-buffer] 3)) completing-read] 7))

(defun hargs:select-p (&optional value meta) "\
Returns optional VALUE or value selected at point if any, else nil.
If value is the same as the contents of the minibuffer, it is used as
the current minibuffer argument, otherwise, the minibuffer is erased
and value is inserted there.
Optional META non-nil triggers display of Hyperbole menu item help when
appropriate." (byte-code " V   W  ̎ ! !q=8 1 щ!S  \"E  S É cƉ)*" [value owind back-to nil hargs:reading-p meta t buffer-read-only minibuffer-depth 0 hargs:at-p selected-window ((byte-code " 	!" [back-to owind select-window] 2)) select-window minibuffer-window window-buffer hmenu hmenu-help hui:menu-enter string= buffer-string exit-minibuffer erase-buffer] 14))

(or (fboundp (quote find-tag-default)) (defun find-tag-default nil (save-excursion (while (looking-at "\\sw\\|\\s_") (forward-char 1)) (if (re-search-backward "\\sw\\|\\s_" nil t) (progn (forward-char 1) (buffer-substring (point) (progn (forward-sexp -1) (while (looking-at "\\s'") (forward-char 1)) (point)))) nil))))

(defun hargs:action-get (action modifying) "\
Interactively gets list of arguments for ACTION's parameters.
Current button is being modified when MODIFYING is non-nil.
Returns nil if ACTION is not a list, has no interactive form or takes no
arguments." (byte-code "< !	 	
\"!)" [action interactive-form modifying action:commandp action:path-args-rel hargs:iform-read] 5))

(defun hargs:delimited (start-delim end-delim) "\
Returns a single line, delimited argument that point is within, or nil.
START-DELIM and END-DELIM are strings that specify the argument delimiters." (byte-code "` T# T#( ǉ 
R ` `b	#R `GZR 
\")," [opoint eol start end start-delim t end-delim nil beginning-of-line search-forward end-of-line buffer-substring] 8))

(defun hargs:get (interactive-entry &optional default) "\
Prompts for an argument, if need be, from INTERACTIVE-ENTRY, a string.
Optional DEFAULT is inserted after prompt.
First character of INTERACTIVE-ENTRY must be a command character from
the list in the documentation for 'interactive'.
May return a single value or a list of values, in which case the first
element of the list is always the symbol 'args." (byte-code "	?	 	\" ˂ 	HU Â\" 	OU3 !X GWL HL 
#?W \"X ," [cmd interactive-entry prompt nil func val hargs:iform-vector default t equal "" 0 1 error "(hargs:get): Empty interactive-entry arg." funcall "(hargs:get): Bad interactive-entry cmd char: '%c'."] 6))

(defun hargs:prompt (prompt default &optional default-prompt) "\
Returns string of PROMPT including DEFAULT.
Optional DEFAULT-PROMPT is used to describe default value." (byte-code " 	
 \" ǂ % 	" [default prompt default-prompt format "%s(%s%s%s) " "default" equal "" " "] 7))

(defun hargs:sexpression-p (&optional no-recurse) "\
Returns an sexpression at point as a string.
If point follows an sexpression end character, the preceding sexpression
is returned.  If point precedes an sexpression start character, the
following sexpression is returned.  Otherwise, the innermost sexpression
that point is within is returned or nil if none." (byte-code ")" [nil (byte-code "h!U ! `!`\"D g!U& !3 ` `\"D 	; D !!))" [not-quoted no-recurse nil t (not (and (= (char-syntax (char-after (- (point) 2))) 92) (/= (char-syntax (char-after (- (point) 3))) 92))) char-syntax 41 eval buffer-substring forward-sexp -1 40 up-list 1 hargs:sexpression-p] 11) ((error (byte-code "" [nil] 1)))] 3))

(defvar hargs:iforms nil "\
Alist of (interactive-cmd-chr . (argument-type . get-argument-form)) elts.")

(setq hargs:iforms (quote ((97 symbol intern (completing-read prompt obarray (quote fboundp) t default)) (98 buffer progn (or default (setq default (other-buffer (current-buffer)))) (read-buffer prompt default t)) (66 buffer progn (or default (setq default (other-buffer (current-buffer)))) (read-buffer prompt default nil)) (99 character progn (message (if default (hargs:prompt prompt (if (integerp default) (char-to-string default) default) "Curr:") prompt)) (char-to-string (read-char))) (67 symbol intern (completing-read prompt obarray (quote commandp) t default)) (100 integer point) (68 directory progn (or default (setq default default-directory)) (read-file-name prompt default default (quote existing))) (102 file read-file-name prompt default default (if (eq system-type (quote vms)) nil (quote existing))) (70 file read-file-name prompt default default) (73 Info-node progn (require (quote info)) (hargs:read prompt (quote (lambda (node) (and (string-match "^(\\([^)]+\\))" node) (file-readable-p (hpath:absolute-to (substring node (match-beginning 1) (match-end 1)) Info-directory))))) default "(hargs:read): Use (readable-filename)nodename." (quote Info-node))) (107 key key-description (read-key-sequence (if default (hargs:prompt prompt default "Curr:") prompt))) (109 integer mark) (77 mail progn (while (or (not (listp (setq default (read-minibuffer (hargs:prompt prompt "" "list of (date mail-file)") default)))) (/= (length default) 2) (not (and (stringp (car (cdr default))) (file-exists-p (car (cdr default)))))) (beep)) (cons (quote args) default)) (78 integer if prefix-arg (prefix-numeric-value prefix-arg) (let ((arg)) (while (not (integerp (read-minibuffer prompt default)))) arg)) (110 integer let ((arg)) (while (not (integerp (read-minibuffer prompt default)))) arg) (112 prefix-arg prefix-numeric-value prefix-arg) (80 prefix-arg . prefix-arg) (114 region if (mark) (list (quote args) (min (point) (mark)) (max (point) (mark))) (list (quote args) nil nil)) (115 string read-string prompt default) (83 symbol read-from-minibuffer prompt default minibuffer-local-ns-map (quote sym)) (118 symbol read-variable (if default (hargs:prompt prompt default "Curr:") prompt)) (120 sexpression read-minibuffer prompt default) (88 sexpression eval-minibuffer prompt default))))

(defvar hargs:iform-vector nil "\
Vector of forms for each interactive command char code.")

(setq hargs:iform-vector (let* ((size (1+ (car (sort (mapcar (quote car) hargs:iforms) (quote >))))) (vec (make-vector size nil))) (mapcar (quote (lambda (elt) (aset vec (car elt) (list (quote lambda) (quote (prompt default)) (list (quote setq) (quote hargs:reading-p) (list (quote quote) (car (cdr elt)))) (cdr (cdr elt)))))) hargs:iforms) vec))

(provide (quote hargs))
