1

I'm looking for the most convenient way to set up a Customize options page to enter a set of directories and then select one of those directories and one file in the selected directory (if possible, without spelling out the implied extension).

I'd like a constrained file picker, presumably using a pop-up or in the minibuffer, or autocompletion within the text field but the directory and file data types in my widgets give basic text fields instead; this means a lot of copying and pasting.

Is there a convenient way to choose between non-constant values and/or to modify widgets on the fly beyond widget-value-set (I would need to populate a list of files when the selected directory changes)? Can packages like ido, helm, icicles etc. be configured to provide autocompletion in Customize widgets?

  • 1
    It's unclear what you're asking. Do you want a customisable variable which takes a list of directories? Or do you want to present the user with a customise page which returns you the result? Furthermore, this file within directories thing is confusing. Do you preselect the directories, and asks the user for the files? Or does the user choose the directories? Could you streamline this aspect of your question? – Malabarba Oct 23 '14 at 14:10
  • The user needs to choose (adding additional information for each) as many files as he wants, each from any of a set of allowed directories that have been specified in advance; the files will later be used by interactive commands. So there are three logical steps: the set of allowed directories and then, for each item, one of the allowed directories and finally one of the files in that directory. With either autocompletion in a text field or dynamically populated menus, radio button groups etc. the second and third step would become much nicer than the current dumb text fields. – Lorenzo Gatti Oct 23 '14 at 20:35
  • This is a monumental project that is (in my opinion) too broad to be "answered". To the extent that the original poster is still interested in this particular project, it should be broken down into separate threads with one reasonably answerable question per thread. As it stands now, the answer would require someone to write an entire library and/or substantially modify existing libraries. Alternatively, the original poster may wish to submit a feature request to the Emacs team so that the author(s) of the customization menu can take it under consideration. – lawlist May 26 '15 at 18:38
  • You can have a look at the standard widget types directory and file. You have to provide a special completion-table for your purpose. But you can use completion-file-name-table with a predicate as a basis. Should be not too difficult. – Tobias May 6 at 22:43
0

You could construct the widget type like this

`(repeat (choice ,(mapcar (lambda (elt) (list 'const elt)))))

Of course you then also have to arrange for that to be used, but it sounds like you have already figured that part out.

0

For this part of your question (I don't really follow the rest of it, so far):

Can packages like ido, helm, icicles etc. be configured to provide autocompletion in Customize widgets?

The answer is yes, depending I guess on what you mean by "autocompletion".

Vanilla Emacs provides completion for some Customize widgets. And you can define additional widgets that also let the user use completion to choose a value.

Icicles, for example, defines a color-choice widget that provides completion, as follows:

(define-widget 'icicle-color 'editable-field
  "Icicles version of the `color' widget.
`M-TAB' completes the color name using Icicles WYSIWYG completion.
See `icicle-widget-color-complete'."
  :format   "%{%t%}: %v (%{sample%})\n"
  :size     (1+ (apply #'max (mapcar #'length (x-defined-colors))))
  :tag      "Color"
  :match    'widgetp-color-match
  :validate 'widgetp-color-validate
  :value    "black"
  :complete 'icicle-widget-color-complete
  :sample-face-get 'widget-color-sample-face-get
  :notify   'widget-color-notify
  :action   'widget-color-action)

The part that provides (Icicles-style) completion is :complete 'icicle-widget-color-complete. It just specifies that completion is provided by function icicle-widget-color-complete.

(FWIW, I don't think you can easily modify widgets on the fly. I also think you might get more help if you more clearly specify (details) the behavior you are looking for.)

By "autocompletion" do you mean completion that is not initiated on-demand (e.g., from hitting TAB) but automatically, either immediately or after typing one or more chars (some minimum number) or after some minimum delay? That is possible with Icicles, Ido, and Helm, AFAIK.

Or do you mean completion that might be initiated on-demand initially but is updated thereafter automatically, each time you change the input patter (e.g. type or delete a char)? That too is possible with Icicles, Ido, and Helm, AFAIK. (In Icicles it is called incremental completion.)

For Icicles such is controlled by user options:

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.