;;; static-properties.el --- Public API static TP property examples -*- lexical-binding: t; -*- ;; Copyright (C) 2026 Geekinney ;; SPDX-License-Identifier: GPL-3.0-or-later ;;; Commentary: ;; Examples that use only the one-shot public TP APIs: `tp-propertize` and ;; `tp-apply`. They do not rely on layer stacks, retained runtimes, or ;; managed state. ;;; Code: (require 'tp) (defconst tp-example-static-properties-caption-buffer-width 28 "Fixed width used by static diagnostics in this example set.") (defvar tp-example-static-properties-keymap (let ((map (make-sparse-keymap))) (define-key map (kbd "RET") #'ignore) map) "Keymap stored literally on the static title string.") (defun tp-example-static-properties-help (_window _object _position) "Return help text for a static title. WINDOW, OBJECT, and POSITION are supplied by Emacs help display." "Static TP title") (defun tp-example-static-properties-format-title (label) "Return LABEL padded and styled as a static title. LABEL is shown using native Emacs properties only. The returned value is a propertized string (no surface, no anchor, no object)." (let ((text (format (format "%%-%ds" tp-example-static-properties-caption-buffer-width) label))) (tp-propertize text `(face ((:weight bold) (:foreground "white" :background "#3c4656")) keymap ,tp-example-static-properties-keymap help-echo ,#'tp-example-static-properties-help mouse-face nil)))) (defun tp-example-static-properties-mark-range (buffer start end &optional color) "Apply a one-shot property run on BUFFER [START, END). COLOR defaults to a light neutral background and preserves all existing properties outside [START, END)." (tp-apply buffer start end `(face (:background ,(or color "#f0e6cc")) help-echo "Static range marker"))) (provide 'static-properties) ;;; static-properties.el ends here