Function: hui:ibut-label-create

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

Signature

(hui:ibut-label-create)

Documentation

Create an implicit button label for an existing implicit button at point.

Add the label, preceding the button, and delimiters around it plus any necessary label instance number. Signal an error if point is not on an implicit button or if the button already has a label.

If the implicit button type does not specify the starting locations of its buttons, the label is simply inserted at point.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hui.el
(defun hui:ibut-label-create ()
  "Create an implicit button label for an existing implicit button at point.
Add the label, preceding the button, and delimiters around it
plus any necessary label instance number.  Signal an error if
point is not on an implicit button or if the button already has a
label.

If the implicit button type does not specify the starting locations of
its buttons, the label is simply inserted at point."
  (interactive)
  (hui:buf-writable-err (current-buffer) "ibut-label-create")
  (let* ((ibut (ibut:at-p))
	 (ibut-start (when ibut (hattr:get 'hbut:current 'lbl-start)))
	 ;; non-nil when point is within an existing ibut label
	 (label-key-start-end (when ibut (ibut:label-p nil nil nil t t)))
	 lbl)
    (cond (label-key-start-end
	   (error "(hui:ibut-label-create): ibutton at point already has a label; try hui:ibut-rename"))
	  (ibut
	   (save-excursion
	     (when ibut-start
	       (goto-char ibut-start)
	       ;; Skip over any non-whitespace or symbol chars to move
	       ;; back past any opening delimiter
	       (skip-syntax-backward "^-_"))
	     (save-excursion
	       ;; Check if ibut has an existing preceding label
	       (skip-chars-backward "][:=<>a-zA-Z0-9#@!$%^&* -")
	       (skip-chars-forward " ")
	       (when (looking-at (concat (regexp-quote ibut:label-start) "\\s-*[:=a-zA-Z0-9#@!$%^&* -]+" (regexp-quote ibut:label-end)))
		 (error "(hui:ibut-label-create): ibutton at point already has a label; try hui:ibut-rename")))
	     (setq lbl (hui:hbut-label nil "ibut-label-create")) ; prompts for label
	     ;; !! Handle adding instance to label
	     (insert ibut:label-start lbl ibut:label-end ibut:label-separator))
	   (when (called-interactively-p 'interactive)
	     (hui:ibut-message nil)))
	  (t (error "(hui:ibut-label-create): To add a label, point must be within the text of an implicit button")))))