[Xmonad] darcs patch: XSelection.hs: simplify creation of window (and 10 more)

Gwern Branwen gwern0 at gmail.com
Tue Oct 23 17:31:09 EDT 2007

On 2007.10.23 23:07:24 +0200, Christian Thiemann <mail at christian-thiemann.de> scribbled 0 lines:
> Gwern Branwen wrote:
>> On 2007.10.23 14:50:35 +0200, Christian Thiemann
>> <mail at christian-thiemann.de> scribbled 0 lines:
>>> Gwern Branwen wrote:
>>>> On 2007.10.23 11:29:34 +0300, "Valery V. Vorotyntsev"
>>>> <valery.vv at gmail.com> scribbled 0 lines:
>>>>> On 10/19/07, gwern0 at gmail.com <gwern0 at gmail.com> wrote:
>>>>>> Fri Oct 19 14:09:00 EDT 2007  gwern0 at gmail.com
>>>>>>   * Run.hs, ShellPrompt.sh: mv runInXTerm to ShellPrompt.hs
>>>>> What is the purpose of this moving?
>>>>> IMHO, the function fits nicely in Run.hs.
>>>> IIRC, leaving runInXTerm in Run.hs causes a cyclical import - but I
>>>> might
>>>> have moved it because it made more sense to me in there.
>>> The function was in a stand-alone module named RunInXTerm before the
>>> runXXX
>>> functions were collected into Run.  So the situation for the function
>>> itself is unchanged.  Probably the dependencies of the other
>>> runXXX-functions cause some cyclical imports, but Run.hs just imports
>>> XMonad from the core and nothing from the contrib, so I don't see where a
>>> problem might arise, unless XMonad.hs imports some contrib modules, which
>>> is not the case.
>>> Conceptually I find it odd that I now need to import the whole
>>> ShellPrompt
>>> facility just to get a command that has nothing to do with ShellPrompt.
>>> Greetings,
>>>   Christian
>> Perhaps I don't understand your intent with runInXTerm then? My
>> understanding was that it was supposed to take a string argument, pass it
>> through the shell which would do whatever it specified, and then run the
>> resultant command in an terminal specified by the shell (falling back to
>> XTerm). This makes perfect sense to go into ShellPrompt to me - it's
>> dealing with the shell, after all. Run.hs has various ways of running
>> commands, ShellPrompt has various ways of running shell commands, and
>> XSelection has various ways of dealing with the X selection.
> ShellPrompt is providing a graphical prompt asking for a command to execute
> (not in a terminal - runInXTerm was introduced by Andrea in RunInXTerm.hs
> for import in SshPrompt.hs to bring up an ssh in a shell).  But you don't
> need the graphical ShellPrompt or the SshPrompt for running something in
> XTerm.  The probably more convincing examples are runProcessWithInput and
> runProcessWithInputAndWait: these were originally defined in Dmenu.hs and
> Dzen.hs - because they were handy functions to bring up a dmenu or dzen
> instance - and some other contribs then included Dmenu or Dzen just to get
> these functions, without using the dmenu or dzen related stuff.  That
> seemed odd to me.  Similarly, SshPrompt relies on being able to run
> something in a terminal (thus it should import some module that provides
> this functionality) but runInXTerm does not need the graphical SshPrompt
> (or ShellPrompt), thus I think one should not need to include ShellPrompt
> to be able to run something in a terminal.
> Greetings,
>   Christian
> --
> Christian Thiemann

Alright, I think I'm understanding this better.

I'm not too thrilled about runInXTerm as it currently exists. The method is cute, certainly, seeing whether an environmental variable exists and if not falling back to XTerm, but it grates on me.

Do you think a new definition would be better, along the lines of
 runInTerm :: String -> String -> X ()
 runInTerm term command = safeSpawn term ("-e " ++ command)

This definition, I think, would make sense to move back into Run.hs, resolving most of your complaint, and it also has other benefits: this way, it's really obvious what the function is doing; the user can easily specify which terminal she wants to use *in* XMonad and not Bash or Zsh or whatever; this would also be nice since that's a common idiom in my Config.hs.

What does everyone think?

Guantanamo CIA secret MI-17 schloss DEADBEEF MJ-12 SADMS dictionary 82
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/xmonad/attachments/20071023/c1e55738/attachment.bin

More information about the Xmonad mailing list