Function: hui:hbut-delete

hui:hbut-delete is an interactive and byte-compiled function defined in hui.el.

Signature

(hui:hbut-delete &optional BUT-KEY KEY-SRC)

Documentation

Delete a Hyperbole button given by optional BUT-KEY in optional KEY-SRC.

For an implicit button, the BUT-KEY is the text key, not the name key.

Use current buffer if no KEY-SRC is given. Return t if button is deleted, nil if user chooses not to delete, or signal an error otherwise. If called interactively, prompt user for whether to delete and derive BUT-KEY from the button that point is within. Signal an error if point is not within a button.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hui.el
(defun hui:hbut-delete (&optional but-key key-src)
  "Delete a Hyperbole button given by optional BUT-KEY in optional KEY-SRC.
For an implicit button, the BUT-KEY is the text key, not the name key.

Use current buffer if no KEY-SRC is given.  Return t if button
is deleted, nil if user chooses not to delete, or signal an error
otherwise.  If called interactively, prompt user for whether to
delete and derive BUT-KEY from the button that point is within.
Signal an error if point is not within a button."
  (interactive)
  (when (and (null but-key) (hbut:at-p))
    (setq but-key (hattr:get 'hbut:current 'lbl-key)))
  (unless key-src
    (setq key-src (or (hypb:buffer-file-name) (current-buffer))))
  (cond ((null but-key)
	 (hypb:error
	  "(hbut-delete): Point is not over the label of an existing button"))
	((not (stringp but-key))
	 (hypb:error
	  "(hbut-delete): Invalid label key argument: '%s'" but-key)))
  (save-excursion
    (with-current-buffer (if (bufferp key-src) key-src (find-file-noselect key-src))
      (let ((interactive (called-interactively-p 'interactive))
	    (label (hbut:key-to-label but-key)))
	(cond ((ebut:to but-key)
	       (if (and hui:hbut-delete-confirm-flag interactive)
		   (if (y-or-n-p (format "Delete button %s%s%s? "
					 ebut:label-start label ebut:label-end))
		       (hui:ebut-delete-op interactive but-key key-src)
		     (message "")
		     nil)
		 (hui:ebut-delete-op interactive but-key key-src)))
	      ((ibut:to but-key)
	       (if (and hui:hbut-delete-confirm-flag interactive)
		   (if (y-or-n-p (format "Delete button %s%s%s? "
					 ibut:label-start label ibut:label-end))
		       (hui:ibut-delete-op interactive but-key key-src)
		     (message "")
		     nil)
		 (hui:ibut-delete-op interactive but-key key-src)))
	      (t (hypb:error "(hbut-delete): Invalid button '%s'" label)))))))