Function: hywiki-add-command

hywiki-add-command is an interactive and byte-compiled function defined in hywiki.el.

Signature

(hywiki-add-command WIKIWORD)

Documentation

Make WIKIWORD invoke a prompted for command with arguments and return it.

Interactively, use any existing HyWikiWord at point or read an existing or valid new one.

Command is the symbol used in the definition expression, which may be an Emacs command or a Hyperbole action type. If it takes no more than one string argument and that argument is the empty string or matches WIKIWORD sans any #suffix, then WIKIWORD (including any suffix) is sent as the first argument.

If WIKIWORD is invalid, trigger an error if called interactively or return nil if not.

After successfully adding the actype, run hywiki-add-referent-hook.

Use hywiki-get-referent to determine whether WIKIWORD exists prior to calling this function.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260822.1645/hywiki.el
(defun hywiki-add-command (wikiword)
  "Make WIKIWORD invoke a prompted for command with arguments and return it.
Interactively, use any existing HyWikiWord at point or read an existing or
valid new one.

Command is the symbol used in the definition expression, which may be an
Emacs command or a Hyperbole action type.  If it takes no more than one
string argument and that argument is the empty string or matches WIKIWORD
sans any #suffix, then WIKIWORD (including any suffix) is sent as the first
argument.

If WIKIWORD is invalid, trigger an error if called interactively
or return nil if not.

After successfully adding the actype, run `hywiki-add-referent-hook'.

Use `hywiki-get-referent' to determine whether WIKIWORD exists prior to
calling this function."
  (interactive (list (or (hywiki-word-at)
			 (hywiki-word-read-new "Add/Edit HyWikiWord: "))))
  (when (string-empty-p wikiword)
    (error "(hywiki-add-command): No HyWikiWord specified"))

  (let* ((command (hui:actype nil (format "Command for %s: " wikiword)))
	 (args (hargs:actype-get command))
         (first-arg (car args)))
    (hywiki-add-referent wikiword
                         (if (and (= (length args) 1)
                                  (stringp first-arg)
                                  (or (string-empty-p first-arg)
                                      (equal (hywiki-word-strip-suffix first-arg)
                                             (hywiki-word-strip-suffix wikiword))))
                             (cons 'command command)
                           (cons 'command (cons command args))))))