Function: hui:ebut-edit

hui:ebut-edit is an interactive and byte-compiled function defined in hui.el.

Signature

(hui:ebut-edit LBL-KEY)

Documentation

Edit an explicit Hyperbole button given by LBL-KEY.

Signal an error when no such button is found in the current buffer.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hui.el
(defun hui:ebut-edit (lbl-key)
  "Edit an explicit Hyperbole button given by LBL-KEY.
Signal an error when no such button is found in the current buffer."
  (interactive (list (save-excursion
		       (hui:buf-writable-err (current-buffer) "ebut-edit")
		       (ebut:label-to-key
			(hargs:read-match "Button to edit: "
					  (ebut:alist) nil t
					  (ebut:label-p t) 'ebut)))))
  (unless (stringp lbl-key)
    (if (called-interactively-p 'interactive)
	(error "(hui:ebut-edit): No explicit button to edit")
      (error "(hui:ebut-edit): 'lbl-key' argument must be a string, not '%s'" lbl-key)))

  (hypb:assert-same-start-and-end-buffer
    (let ((lbl (ebut:key-to-label lbl-key))
	  (but-buf (current-buffer))
	  actype but new-lbl)
      (hattr:set 'hbut:current 'loc (hui:key-src but-buf))
      (hattr:set 'hbut:current 'dir (hui:key-dir but-buf))
      (save-excursion
	(unless (called-interactively-p 'interactive)
	  (hui:buf-writable-err but-buf "ebut-edit"))

	(unless (setq but (ebut:get lbl-key but-buf))
	  (pop-to-buffer but-buf)
	  (hypb:error "(ebut-edit): Invalid button, no data for '%s'" lbl))

	(setq new-lbl
	      (hargs:read
	       "Change button label to: "
	       (lambda (lbl)
		 (and (not (string-match-p "\\`\\s-*\\'" lbl))
		      (<= (length lbl) (hbut:max-len))))
	       lbl
	       (format "(ebut-edit): Enter a non-blank string of at most %s chars."
		       (hbut:max-len))
	       'string))

	(setq actype (hui:actype (hattr:get but 'actype)))
	(hattr:set 'hbut:current 'actype actype)
	(hattr:set 'hbut:current 'args (hargs:actype-get actype t))
	(hattr:set 'hbut:current 'action
		   (and hui:ebut-prompt-for-action (hui:action actype)))
	(set-buffer but-buf)
	(save-excursion
	  (ebut:operate lbl new-lbl)))
      (when (called-interactively-p 'interactive)
	(hui:ebut-message t)))))