[xmonad] XMonad.Prompt.File (attached)

John J Foerch jjfoerch at earthlink.net
Fri Mar 18 18:47:52 CET 2011

Norbert Zeh <nzeh at cs.dal.ca> writes:
> John J Foerch [2011.03.17 2345 -0400]:
> [...]
>> Sorry it couldn't be a more profound, creative, and interesting module :D
>> but that's what I needed.  Shell prompt does not fit the bill for two
>> reasons: 1) its prompt string is hard-coded as "Run: ", and 2) I wanted
>> expansion of '~/' but not other special characters, so I have to
>> manipulate the return value before passing it on to spawn.
>> For context, I'm using this in several screenshot commands which prompt
>> for the name of the output file.
>> Maybe there is a better approach for prompting for directories and files
>> both, but the existence of an XMonad.Prompt.Directory and no
>> XMonad.Prompt.File looks to me like a simple omission.  If the latter is a
>> hack, then so is the former, but I'm not campaigning for any outcome, only
>> offering something that I have found useful to others.
> I agree with you on the level that it is odd that there should be a module that
> handles directories but cannot do the same for files and, what's worse, has a
> name that clearly states it deals only with directories, making my suggestion
> (1) below a bit suboptimal.
> However, the issue of whether this functionality is already offered by another
> module aside, there are still two fairly clean ways of including this
> functionality for files without the cutting and pasting:
> (1) Simply add the functionality you need to X.P.Directory, factoring the code
> common to both handling directories and files.
> (2) Move all the code for directories and files to X.P.File, again properly
> factoring it to avoid code duplication.  Then rewrite the existing
> X.P.Directory as a thin wrapper that imports X.P.File and reexports the
> directory-specific functions.  The second part of this solution is to not break
> configurations that currently use X.P.Directory.
> I think (2) is preferable over (1) because "Directory" suggests that this
> module can deal with directories but not with files, while in my experience,
> modules named File-something usually deal with different types of files,
> including directories.

Proposal 2 sounds like the best way to achieve a single module that
handles prompting for any type of file or directory without cluttering
contrib with more specialized and redundant prompt modules.  I will be
glad to implement it if contrib maintainers are favorable.


John Foerch

More information about the xmonad mailing list