Function: hui:ibut-create

hui:ibut-create is an interactive and byte-compiled function defined in hui.el.

Signature

(hui:ibut-create &optional START END)

Documentation

Interactively create an implicit Hyperbole button at point.

Use any name between optional START and END points (when interactive, any active region). Indicate button creation by delimiting and adding any necessary instance number to the button name.

For programmatic creation, use ibut:program instead.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hui.el
(defun hui:ibut-create (&optional start end)
  "Interactively create an implicit Hyperbole button at point.
Use any name between optional START and END points (when interactive,
any active region).  Indicate button creation by delimiting
and adding any necessary instance number to the button name.

For programmatic creation, use `ibut:program' instead."
  (interactive (list (when (use-region-p) (region-beginning))
		     (when (use-region-p) (region-end))))
  (hui:buf-writable-err (current-buffer) "ibut-create")
  (when (ebut:at-p)
    (error "(ibut:program): Move off explicit button at point to create an implicit button"))
  (hypb:assert-same-start-and-end-buffer
    (let (default-name name but-buf actype)
      (setq but-buf (current-buffer))
      (hattr:clear 'hbut:current)

      ;; Throw an error if on a named or delimited Hyperbole button since
      ;; cannot create another button within such contexts.
      (when (ibut:at-p)
	(let ((name (hattr:get 'hbut:current 'name))
	      (lbl (hbut:key-to-label (hattr:get 'hbut:current 'lbl-key)))
	      (lbl-start (hattr:get 'hbut:current 'lbl-start))
	      (lbl-end (hattr:get 'hbut:current 'lbl-end)))
	  (when (or name lbl (and lbl-start lbl-end))
	    (error "(ibut-create): Cannot nest an ibut within the existing button: '%s'"
		   (or name lbl (buffer-substring-no-properties lbl-start lbl-end))))))

      (save-excursion
	(setq default-name (hui:hbut-label-default start end (not (called-interactively-p 'interactive)))
	      name (hui:hbut-label default-name "ibut-create"))
	(unless (equal name default-name)
	  (setq default-name nil))

	(hattr:set 'hbut:current 'name name)
	(hattr:set 'hbut:current 'categ 'implicit)
	(hattr:set 'hbut:current 'loc (hui:key-src but-buf))
	(hattr:set 'hbut:current 'dir (hui:key-dir but-buf))
	(setq actype (hui:actype))
	(hattr:set 'hbut:current 'actype actype)
	(hattr:set 'hbut:current 'args (hargs:actype-get actype))
	(hattr:set 'hbut:current 'action nil)
	;; Adds instance number to in-buffer label if necessary
	(ibut:operate)
	(when (called-interactively-p 'interactive)
	  (hui:ibut-message nil))))))