I'm creating a 'form' of sorts in a buffer that has a few required arguments:
Title: Labels: content content content
When the form is presented, I'd like to be able to edit any and all text after each
Header: without being able to move point into
Header: -- kindof like a minibuffer prompt.
After looking at the definition of
read-from-minibuffer for the right properties, here's what I've got so far:
(defun my--insert-header (header &optional default-value) ;; inhibit point from moving inside the field (setq-local inhibit-point-motion-hooks nil) ;; insert Header: Default-Value pairs (let ((props1 '(front-sticky t rear-non-sticky t field t read-only t intangible t face magit-header-line)) (props2 '(front-sticky nil rear-non-sticky nil field nil read-only nil intangible nil))) (insert (apply #'propertize (format "%s: " header) props1)) (insert (apply #'propertize (or value "") props2)) (insert (apply #'propertize "\n" props1))))
When I run this code in a scratch buffer
(progn (insert "\n\n\n") (my--insert-header "Title" "some title"))
I get an error. I think it's because
(insert (apply #'propertize (or value "") props2)) is trying to insert at read-only text, but I'm not sure how to go about fixing that without compromising the desired behavior.