Function: hargs:iform-read

hargs:iform-read is a byte-compiled function defined in hargs.el.

Signature

(hargs:iform-read IFORM &optional DEFAULT-ARGS)

Documentation

Read action arguments according to IFORM, a list with car = interactive.

With optional DEFAULT-ARGS equal to t, the current button is being edited, so its attribute values should be presented as defaults. Otherwise, use DEFAULT-ARGS as a list of defaults to present when reading arguments. See also documentation for interactive.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hargs.el
(defun hargs:iform-read (iform &optional default-args)
  "Read action arguments according to IFORM, a list with car = `interactive'.
With optional DEFAULT-ARGS equal to t, the current button is being edited, so
its attribute values should be presented as defaults.  Otherwise, use
DEFAULT-ARGS as a list of defaults to present when reading arguments.
See also documentation for `interactive'."
  ;; This is mostly a translation of `call-interactively' to Lisp.
  ;;
  ;; Save the prefix arg now, since use of minibuffer will clobber it
  (setq prefix-arg current-prefix-arg)
  (when (and (listp iform) (eq (car iform) 'interactive))
    (setq iform (cadr iform)))
  (unless (or (null iform) (and (stringp iform) (equal iform "")))
    (unless (or (stringp iform) (listp iform))
      (error "(hargs:iform-read): `iform' must be either a non-empty interactive string or a list whose car = 'interactive, not:\n%S"
	     iform))
    (if (eq default-args t)
	(setq default-args (hattr:get 'hbut:current 'args)
	      ;; Set hargs:defaults global used by "hactypes.el"
	      hargs:defaults default-args)
      (setq hargs:defaults nil))
    (setq hargs:reading-type t)
    (if (not (stringp iform))
	(eval iform)
      (let ((i 0) (start 0) (end (length iform))
	    (ientry) (results) (val) (default))
	;;
	;; Handle special initial interactive string chars.
	;;
	;;   `*' means error if buffer is read-only.
	;;   Notion of when action cannot be performed due to
	;;   read-only buffer is view-specific, so here, we just
	;;   ignore a read-only specification since it is checked for
	;;   earlier by any ebut edit code.
	;;
	;;   `@' means select window of last mouse event.
	;;
	;;   `^' means activate/deactivate mark depending on invocation thru shift translation
	;;   See `this-command-keys-shift-translated' for an explanation.
	;;
	;;   `_' means keep region in same state (active or inactive)
	;;   after this command.
	;;
	(while (cond
		((eq (aref iform i) ?*))
		((eq (aref iform i) ?@)
		 (hargs:select-event-window)
		 t)
		((eq (aref iform i) ?^)
		 (handle-shift-selection))
		((eq (aref iform i) ?_)
		 (push 'only transient-mark-mode)))
	  (setq i (1+ i) start i))
	;;
	(while (and (< start end)
		    (string-match "\n\\|\\'" iform start))
	  (setq start (match-end 0)
		ientry (substring iform i (match-beginning 0))
		i start
		default (car default-args)
		default (if (or (null default) (stringp default))
			    default
			  (prin1-to-string default))
		val (hargs:get ientry default (car results))
		default-args (cdr default-args)
		results (cond ((or (null val) (not (listp val)))
			       (cons val results))
			      ;; Is a list of args?
			      ((eq (car val) 'args)
			       (append (nreverse (cdr val)) results))
			      (t ;; regular list value
			       (cons val results)))))
	(nreverse results)))))