0

I am trying to resolve a related question relating to creating a simple form to input and return various fields: How to pop open a forms template to enter multiple values To that end, I defined a widget, using a modified version of the multiple fields with INS and DEL. I will be using a fixed number of fields, and have no need for INS and DEL. How can I prepend the field names to each field inserted into the buffer, e.g., field_one through field_five?

BEFORE

1
2
3
4
5

AFTER

field_one:   1
field_two:   2
field_three: 3
field_four:  4
field_five:  5
(define-widget 'my-editable-list 'default
  "A variable list of widgets of the same type."
  :convert-widget 'widget-types-convert-widget
  :copy 'widget-types-copy
  :offset 12
  :format "%v\n"
  :format-handler 'widget-editable-list-format-handler
  :entry-format "%v"
  :value-create 'widget-editable-list-value-create
  :value-get 'widget-editable-list-value-get
  :validate 'widget-children-validate
  :match 'widget-editable-list-match
  :match-inline 'widget-editable-list-match-inline
  :insert-before 'widget-editable-list-insert-before
  :delete-at 'widget-editable-list-delete-at)

(defun example-fn ()
  (interactive)
  "Doc-string."
  (let ((buffer (get-buffer-create "*TEST*")))
    (with-current-buffer buffer
      (erase-buffer)
      (widget-create 'my-editable-list
                     :format "%v\n"
                     :value '("1" "2" "3" "4" "5")
                     '(editable-field
                       :value-to-external
                       (lambda (wid value)
                         (if (widget-get wid :parent)
                             value
                           (message "This is not currently used."))))))
    (display-buffer buffer)))
1

I think you’re going about it the wrong way. Instead of making something complicated and meta, just be explicit:

(define-widget 'bibtex-entry-alist 'lazy
  "Format of `bibtex-BibTeX-entry-alist' and friends."
  :type '(repeat (group (string :tag "Entry type")
                        (string :tag "Documentation")
                        (repeat :tag "Required fields" …))))

Just make five string inputs inside a group. This is especially true if the field labels are always the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.