{"thread":{"id":"12497","subject":"How to make gitk not overwrite my selection?","startedAt":"2008-03-04T15:39:08Z","lastAt":"2008-03-06T11:49:25Z","messageCount":6,"participants":["Jean-Luc Herren","Jeff King","Martin Langhoff","Paul Mackerras"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"70958","messageId":"47CD6D1C.1080202@gmx.ch","threadId":"12497","inReplyTo":null,"subject":"How to make gitk not overwrite my selection?","fromName":"Jean-Luc Herren","fromEmail":"jlh@gmx.ch","sentAt":"2008-03-04T15:39:08Z","receivedAt":"2008-03-04T15:39:08Z","isPatch":false,"sender":{"key":"jlh@gmx.ch","avatar":null},"body":"Hi list!\n\nIn gitk, whenever I select a commit in the tree, the SHA1 field\ngets automatically selected, putting its hash into the current\nselection for easy pasting into other applications.  I wonder if I\ncan disable this, because I find it rather annoying; if I do\nhappen to want to paste the hash somewhere, I can easily double\nclick the SHA1 field.\n\nThis is specially annoying when I select a hash in xterm and then\nstart gitk to paste it in the SHA1 field.  But immediately after\ngitk opens, it preselects the current HEAD, overwriting my\nprevious selection from xterm.\n\nGenerally I think an application should not replace the selection\nunless the user explicitely marks something.  Although I can\nunderstand that it can be useful sometimes with gitk.  Therefore\nit should maybe be optional.\n\nThanks,\njlh\n"},{"id":"71008","messageId":"20080304230306.GA18246@sigill.intra.peff.net","threadId":"12497","inReplyTo":"47CD6D1C.1080202@gmx.ch","subject":"Re: How to make gitk not overwrite my selection?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-03-04T23:03:07Z","receivedAt":"2008-03-04T23:03:07Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Mar 04, 2008 at 04:39:08PM +0100, Jean-Luc Herren wrote:\n\n> In gitk, whenever I select a commit in the tree, the SHA1 field\n> gets automatically selected, putting its hash into the current\n> selection for easy pasting into other applications.  I wonder if I\n> can disable this, because I find it rather annoying; if I do\n> happen to want to paste the hash somewhere, I can easily double\n> click the SHA1 field.\n>\n> This is specially annoying when I select a hash in xterm and then\n> start gitk to paste it in the SHA1 field.  But immediately after\n> gitk opens, it preselects the current HEAD, overwriting my\n> previous selection from xterm.\n>\n> Generally I think an application should not replace the selection\n> unless the user explicitely marks something.  Although I can\n> understand that it can be useful sometimes with gitk.  Therefore\n> it should maybe be optional.\n\nThe patch below seems to work for me (see the \"auto-select sha1\" option\nunder preferences). However, I don't actually know tcl, so I\ncargo-culted all of the option processing magic. Paul, if you want to\ntake this patch, please read it carefully. ;)\n\n-- >8 --\ngitk: make autoselect optional\n\nSome users find it annoying to have the selection automatically changed\nwithout any user intervention, since it can overwrite something they\nactually wanted to keep in the selection buffer.\n\n---\n gitk-git/gitk |   17 ++++++++++++++---\n 1 files changed, 14 insertions(+), 3 deletions(-)\n\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex f1f21e9..915dfb8 100644\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -1163,6 +1163,7 @@ proc savestuff {w} {\n     global viewname viewfiles viewargs viewperm nextviewnum\n     global cmitmode wrapcomment datetimeformat limitdiffs\n     global colors bgcolor fgcolor diffcolors diffcontext selectbgcolor\n+    global autoselect\n \n     if {$stuffsaved} return\n     if {![winfo viewable .]} return\n@@ -1177,6 +1178,7 @@ proc savestuff {w} {\n \tputs $f [list set maxwidth $maxwidth]\n \tputs $f [list set cmitmode $cmitmode]\n \tputs $f [list set wrapcomment $wrapcomment]\n+\tputs $f [list set autoselect $autoselect]\n \tputs $f [list set showneartags $showneartags]\n \tputs $f [list set showlocalchanges $showlocalchanges]\n \tputs $f [list set datetimeformat $datetimeformat]\n@@ -4650,6 +4652,7 @@ proc selectline {l isnew} {\n     global commentend idtags linknum\n     global mergemax numcommits pending_select\n     global cmitmode showneartags allcommits\n+    global autoselect\n \n     catch {unset pending_select}\n     $canv delete hover\n@@ -4705,8 +4708,10 @@ proc selectline {l isnew} {\n     set currentid $id\n     $sha1entry delete 0 end\n     $sha1entry insert 0 $id\n-    $sha1entry selection from 0\n-    $sha1entry selection to end\n+    if {$autoselect} {\n+\t$sha1entry selection from 0\n+\t$sha1entry selection to end\n+    }\n     rhighlight_sel $id\n \n     $ctext conf -state normal\n@@ -7943,7 +7948,7 @@ proc doprefs {} {\n     global maxwidth maxgraphpct\n     global oldprefs prefstop showneartags showlocalchanges\n     global bgcolor fgcolor ctext diffcolors selectbgcolor\n-    global tabstop limitdiffs\n+    global tabstop limitdiffs autoselect\n \n     set top .gitkprefs\n     set prefstop $top\n@@ -7973,6 +7978,11 @@ proc doprefs {} {\n     checkbutton $top.showlocal.b -variable showlocalchanges\n     pack $top.showlocal.b $top.showlocal.l -side left\n     grid x $top.showlocal -sticky w\n+    frame $top.autoselect\n+    label $top.autoselect.l -text [mc \"Auto-select sha1\"] -font optionfont\n+    checkbutton $top.autoselect.b -variable autoselect\n+    pack $top.autoselect.b $top.autoselect.l -side left\n+    grid x $top.autoselect -sticky w\n \n     label $top.ddisp -text [mc \"Diff display options\"]\n     grid $top.ddisp - -sticky w -pady 10\n@@ -8463,6 +8473,7 @@ set maxlinelen 200\n set showlocalchanges 1\n set limitdiffs 1\n set datetimeformat \"%Y-%m-%d %H:%M:%S\"\n+set autoselect 1\n \n set colors {green red blue magenta darkgrey brown orange}\n set bgcolor white\n-- \n1.5.4.3.530.gbda49\n\n"},{"id":"71138","messageId":"47CF223A.60507@gmx.ch","threadId":"12497","inReplyTo":"20080304230306.GA18246@sigill.intra.peff.net","subject":"Re: How to make gitk not overwrite my selection?","fromName":"Jean-Luc Herren","fromEmail":"jlh@gmx.ch","sentAt":"2008-03-05T22:44:10Z","receivedAt":"2008-03-05T22:44:10Z","isPatch":false,"sender":{"key":"jlh@gmx.ch","avatar":null},"body":"Jeff King wrote:\n> On Tue, Mar 04, 2008 at 04:39:08PM +0100, Jean-Luc Herren wrote:\n>> In gitk, whenever I select a commit in the tree, the SHA1 field\n>> gets automatically selected, putting its hash into the current\n>> selection for easy pasting into other applications. \n\n> The patch below seems to work for me (see the \"auto-select sha1\" option\n> under preferences). However, I don't actually know tcl, so I\n> cargo-culted all of the option processing magic. Paul, if you want to\n> take this patch, please read it carefully. ;)\n\nThanks, I don't know tcl either, but the patch seems to work great\nhere.\n\njlh\n"},{"id":"71142","messageId":"46a038f90803051500w508b3093l7061d44828600a5d@mail.gmail.com","threadId":"12497","inReplyTo":"47CF223A.60507@gmx.ch","subject":"Re: How to make gitk not overwrite my selection?","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2008-03-05T23:00:02Z","receivedAt":"2008-03-05T23:00:02Z","isPatch":false,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On Thu, Mar 6, 2008 at 11:44 AM, Jean-Luc Herren <jlh@gmx.ch> wrote:\n>  Thanks, I don't know tcl either, but the patch seems to work great\n>  here.\n\nTaking it too here. Welcome option.\n\n\n\nm\n"},{"id":"71232","messageId":"18383.51382.866732.308234@cargo.ozlabs.ibm.com","threadId":"12497","inReplyTo":"20080304230306.GA18246@sigill.intra.peff.net","subject":"Re: How to make gitk not overwrite my selection?","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2008-03-06T10:34:30Z","receivedAt":"2008-03-06T10:34:30Z","isPatch":false,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"Jeff King writes:\n\n> The patch below seems to work for me (see the \"auto-select sha1\" option\n> under preferences). However, I don't actually know tcl, so I\n> cargo-culted all of the option processing magic. Paul, if you want to\n> take this patch, please read it carefully. ;)\n\nLooks OK to me.  Care to re-send it with a Signed-off-by?  Oh, and\nput \"sha1\" in capitals, i.e. \"SHA1\".\n\n(Tcl is actually a very simple language, and there are man pages for\nit; try \"man Tcl\" for a start. :)\n\nPaul.\n"},{"id":"71237","messageId":"20080306114925.GA6942@sigill.intra.peff.net","threadId":"12497","inReplyTo":"18383.51382.866732.308234@cargo.ozlabs.ibm.com","subject":"[PATCH] gitk: make autoselect optional","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-03-06T11:49:25Z","receivedAt":"2008-03-06T11:49:25Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"Whenever a commit is selected in the graph pane, its SHA1\nis automatically put into the selection buffer for cut and\npaste. However, some users may find this behavior annoying\nsince it can overwrite something they actually wanted to\nkeep in the buffer.\n\nThis patch makes the behavior optional under the name\n\"Auto-select SHA1\", but continues to default to \"on\".\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nOn Thu, Mar 06, 2008 at 09:34:30PM +1100, Paul Mackerras wrote:\n\n> Looks OK to me.  Care to re-send it with a Signed-off-by?  Oh, and\n> put \"sha1\" in capitals, i.e. \"SHA1\".\n\nHere it is, with both requested items and a slightly more coherent\ncommit message.\n\n> (Tcl is actually a very simple language, and there are man pages for\n> it; try \"man Tcl\" for a start. :)\n\nHeh. My biggest concern was \"did I get everywhere that options must be\nmentioned\" (which isn't a Tcl thing at all, of course). I tested that\nthe option works, and that it correctly saves the value in the .gitk\nfile and respects it on the next run.\n\n gitk-git/gitk |   17 ++++++++++++++---\n 1 files changed, 14 insertions(+), 3 deletions(-)\n\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex f1f21e9..36fdecd 100644\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -1163,6 +1163,7 @@ proc savestuff {w} {\n     global viewname viewfiles viewargs viewperm nextviewnum\n     global cmitmode wrapcomment datetimeformat limitdiffs\n     global colors bgcolor fgcolor diffcolors diffcontext selectbgcolor\n+    global autoselect\n \n     if {$stuffsaved} return\n     if {![winfo viewable .]} return\n@@ -1177,6 +1178,7 @@ proc savestuff {w} {\n \tputs $f [list set maxwidth $maxwidth]\n \tputs $f [list set cmitmode $cmitmode]\n \tputs $f [list set wrapcomment $wrapcomment]\n+\tputs $f [list set autoselect $autoselect]\n \tputs $f [list set showneartags $showneartags]\n \tputs $f [list set showlocalchanges $showlocalchanges]\n \tputs $f [list set datetimeformat $datetimeformat]\n@@ -4650,6 +4652,7 @@ proc selectline {l isnew} {\n     global commentend idtags linknum\n     global mergemax numcommits pending_select\n     global cmitmode showneartags allcommits\n+    global autoselect\n \n     catch {unset pending_select}\n     $canv delete hover\n@@ -4705,8 +4708,10 @@ proc selectline {l isnew} {\n     set currentid $id\n     $sha1entry delete 0 end\n     $sha1entry insert 0 $id\n-    $sha1entry selection from 0\n-    $sha1entry selection to end\n+    if {$autoselect} {\n+\t$sha1entry selection from 0\n+\t$sha1entry selection to end\n+    }\n     rhighlight_sel $id\n \n     $ctext conf -state normal\n@@ -7943,7 +7948,7 @@ proc doprefs {} {\n     global maxwidth maxgraphpct\n     global oldprefs prefstop showneartags showlocalchanges\n     global bgcolor fgcolor ctext diffcolors selectbgcolor\n-    global tabstop limitdiffs\n+    global tabstop limitdiffs autoselect\n \n     set top .gitkprefs\n     set prefstop $top\n@@ -7973,6 +7978,11 @@ proc doprefs {} {\n     checkbutton $top.showlocal.b -variable showlocalchanges\n     pack $top.showlocal.b $top.showlocal.l -side left\n     grid x $top.showlocal -sticky w\n+    frame $top.autoselect\n+    label $top.autoselect.l -text [mc \"Auto-select SHA1\"] -font optionfont\n+    checkbutton $top.autoselect.b -variable autoselect\n+    pack $top.autoselect.b $top.autoselect.l -side left\n+    grid x $top.autoselect -sticky w\n \n     label $top.ddisp -text [mc \"Diff display options\"]\n     grid $top.ddisp - -sticky w -pady 10\n@@ -8463,6 +8473,7 @@ set maxlinelen 200\n set showlocalchanges 1\n set limitdiffs 1\n set datetimeformat \"%Y-%m-%d %H:%M:%S\"\n+set autoselect 1\n \n set colors {green red blue magenta darkgrey brown orange}\n set bgcolor white\n-- \n1.5.4.3.532.gf15a6\n\n"}]}