Function: defib

defib is a macro defined in hbut.el.

Signature

(defib TYPE PARAMS DOC AT-P &optional TO-P STYLE)

Documentation

Create Hyperbole implicit button TYPE with PARAMS, described by DOC.

TYPE is an unquoted symbol. PARAMS are presently ignored.

AT-P is a boolean form of no arguments which determines whether or not point is within a button of this type. When non-nil, it must contain a call to ibut:label-set with the text and optional buffer region of the button's label. This almost always should be followed by a call to hact with an action to be performed whenever a button of this type is activated.

The action may be a regular Emacs Lisp function or a Hyperbole action type created with defact but may not return nil since any nil value returned is converted to t to ensure the implicit button checker recognizes that the action has been executed.

Optional TO-P is a boolean form which moves point immediately after the next button of this type within the current buffer and returns a list of (button- label start-pos end-pos), or nil when none is found.

Optional STYLE is a display style specification to use when highlighting buttons of this type; most useful when TO-P is also given.

Return symbol created when successful, else nil. Nil indicates that action type for ibtype is presently undefined.

Aliases

ibtype:create

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hbut.el
(defmacro defib (type _params doc at-p &optional to-p style)
  "Create Hyperbole implicit button TYPE with PARAMS, described by DOC.
TYPE is an unquoted symbol.  PARAMS are presently ignored.

AT-P is a boolean form of no arguments which determines whether or not point
is within a button of this type.  When non-nil, it must contain a call
to `ibut:label-set' with the text and optional buffer region of the
button's label.  This almost always should be followed by a call to
`hact' with an action to be performed whenever a button of this type
is activated.

The action may be a regular Emacs Lisp function or a Hyperbole action
type created with `defact' but may not return nil since any nil value
returned is converted to t to ensure the implicit button checker
recognizes that the action has been executed.

Optional TO-P is a boolean form which moves point immediately after the next
button of this type within the current buffer and returns a list of (button-
label start-pos end-pos), or nil when none is found.

Optional STYLE is a display style specification to use when highlighting
buttons of this type; most useful when TO-P is also given.

Return symbol created when successful, else nil.  Nil indicates that action
type for ibtype is presently undefined."
  (declare (indent defun)
           (doc-string 3)
           (debug (&define name lambda-list
                           [&optional stringp] ; Doc string, if present.
                           def-body)))
  (when type
    (let* ((to-func (when to-p (action:create nil (list to-p))))
	   (at-func `((progn (ibtype:ensure-current-hbut-is-set)
			     ,at-p)))
	   (at-func-symbols (flatten-tree at-func)))
      (progn (unless (or (member 'ibut:label-set at-func-symbols)
			 (member 'hsys-org-set-ibut-label at-func-symbols))
	       (error "(defib): `at-p' argument for %s must include a call to `ibut:label-set'" type))
	     `(progn (symtable:add ',type symtable:ibtypes)
		     (htype:create ,type ibtypes ,doc nil ,at-func
				   '(to-p ,to-func style ,style)))))))