git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-mergetool: Make default smarter by considering user's desktop environment and editor

From
David Kastrup <dak@gnu.org>
Date
Jun 6, 2007, 09:40 UTC
Message-ID
<86lkexjua3.fsf@lola.quinscape.zz>
In-Reply-To
<7vabvd5u7t.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <gitster@pobox.com> writes:
Show 30 quoted lines
> David Kastrup <dak@gnu.org> writes:
>
>> Junio C Hamano <junkio@cox.net> writes:
>>
>>> Josh Triplett <josh@freedesktop.org> writes:
>>>
>>>> Make git-mergetool prefer meld under GNOME, and kdiff3 under KDE.  When
>>>> considering emerge and vimdiff, check $VISUAL and $EDITOR to see which the
>>>> user might prefer.
>>>>
>>>> Signed-off-by: Josh Triplett <josh@freedesktop.org>
>>>
>>> The basic idea is sound.  However...
>>>
>>>  (1) I wonder if we can get rid of the horribly long if .. elif
>>>      chain by using shell function and then iterate a list of them;
>>>
>>>  (2) echo "${VISUAL-$EDITOR}" | grep '^emacs'???
>>>
>>>      Some people may have explicit path (/home/me/bin/emacs),
>>>      and/or runs a variant of emacs called 'xemacs'.  Same for
>>>      vim.
>>
>> Actually, a lot of people run as editor a program called "emacsclient"
>> or "gnuclient": this one connects to an existing Emacs session and
>> passes its arguments to it.  And of course, this is what git-mergetool
>> should then also do.
>
> I do that too, but that is covered by the prefix rule Josh has,
> so it is Ok.

Another note: in my usual Emacs session, EDITOR is set to /usr/local/emacs-22/bin/emacsclient which would not be covered... So that should probably be

useemacs=0
for i in ${VISUAL-$EDITOR}
do
        case "`basename $i`" in [xX][eE]macs*|[eE]macs*|gnuclient*)
             useemacs=1
        esac
        break
done

This should work even when we are talking about something like EDITOR="C:\My Programs\XEmacs\gnuclient.exe" -n "C:\My Programs\XEmacs\XEmacs"

And it does not require starting grep for something which the shell can perfectly well handle on its own. Yes, it does need basename. I don't see a good way to avoid that.

-- 
David Kastrup
Previous: Junio C HamanoNext: Theodore Tso
Message 5 of 6 in “git-mergetool: Make default smarter by considering user's desktop environment and editor”
  1. git-mergetool: Make default smarter by considering user's desktop environment and editorJosh Triplett, Jun 6, 2007
  2. Junio C HamanoJun 6, 2007
  3. David KastrupJun 6, 2007
  4. Junio C HamanoJun 6, 2007
  5. David KastrupJun 6, 2007
  6. Theodore TsoJun 6, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.