Function: hproperty:but-add

hproperty:but-add is a byte-compiled function defined in hproperty.el.

Signature

(hproperty:but-add START END FACE)

Documentation

Add a button between START and END using FACE in the current buffer.

Button is added only if it does not already exist. If it does exist somewhere within START to END, then its range is moved to exactly those positions. Return the button added or moved.

If hproperty:but-emphasize-flag is non-nil when this is called, emphasize that button is selectable whenever the mouse cursor moves over it.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hproperty.el
;;; ************************************************************************
;;; Public functions
;;; ************************************************************************

(defun hproperty:but-add (start end face)
  "Add a button between START and END using FACE in the current buffer.
Button is added only if it does not already exist.  If it does exist
somewhere within START to END, then its range is moved to exactly
those positions.  Return the button added or moved.

If `hproperty:but-emphasize-flag' is non-nil when this is called,
emphasize that button is selectable whenever the mouse cursor
moves over it."
  (let ((but (hproperty:but-get-first-in-region start end 'face face)))
    (unless (and but (eq start (hproperty:but-start but))
		 (eq end (hproperty:but-end but)))
      (if but
	  (hproperty:but-move but start end)
	(atomic-change-group
	  (setq but (make-overlay start end nil t))
	  ;; Delete overlay if start and end are ever the same
	  (hproperty:but-set but 'evaporate t)
	  (overlay-put but 'face face)
	  (when hproperty:but-emphasize-flag
	    (overlay-put but 'mouse-face 'highlight)))
	but))))