-(defun company-template-add-field (templ pos text)
- (assert templ)
- (save-excursion
- (save-excursion
- (goto-char pos)
- (insert text)
- (when (> (point) (overlay-end templ))
- (move-overlay templ (overlay-start templ) (point))))
- (let ((ov (make-overlay pos (+ pos (length text))))
- (siblings (overlay-get templ 'company-template-fields)))
- ;; (overlay-put ov 'evaporate t)
- (overlay-put ov 'intangible t)
- (overlay-put ov 'face 'company-template-field)
- (overlay-put ov 'company-template-parent templ)
- (overlay-put ov 'insert-in-front-hooks '(company-template-insert-hook))
- (push ov siblings)
- (overlay-put templ 'company-template-fields siblings))))
+(defun company-template-add-field (templ pos text &optional display)
+ "Add new field to template TEMPL at POS, inserting TEXT.
+When DISPLAY is non-nil, set the respective property on the overlay.
+Leave point at the end of the field."
+ (cl-assert templ)
+ (goto-char pos)
+ (insert text)
+ (when (> (point) (overlay-end templ))
+ (move-overlay templ (overlay-start templ) (point)))
+ (let ((ov (make-overlay pos (+ pos (length text))))
+ (siblings (overlay-get templ 'company-template-fields)))
+ ;; (overlay-put ov 'evaporate t)
+ (overlay-put ov 'intangible t)
+ (overlay-put ov 'face 'company-template-field)
+ (when display
+ (overlay-put ov 'display display))
+ (overlay-put ov 'company-template-parent templ)
+ (overlay-put ov 'insert-in-front-hooks '(company-template-insert-hook))
+ (push ov siblings)
+ (overlay-put templ 'company-template-fields siblings)))