<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 14 Jan 2009, at 07:42, Allan Odgaard wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>On 9 Jan 2009, at 14:23, dreamcat7 wrote:<br><br><blockquote type="cite">1) We chopped the input into only one word so the script can handle  <br></blockquote><blockquote type="cite">it better and not throw to the tooltip a big error. I put this  <br></blockquote><blockquote type="cite">stripping / to the query string, however it really should move to  <br></blockquote><blockquote type="cite">the search_docs(query) command, where we are executing the search.  <br></blockquote><blockquote type="cite">Sorry but I did add to there and break the ruby code.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Ctrl-H --> documentation_for_word() --> search_docs_all(query) -->  <br></blockquote><blockquote type="cite">search_docs(query)**  --> docsetutil<br></blockquote><blockquote type="cite">Ctrl-H --> documentation_for_word() --> search_docs_all(query) -->  <br></blockquote><blockquote type="cite">man_page(query)**     --> man<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">2) If we keep the full string in query variable, then when we print  <br></blockquote><blockquote type="cite">the tooltip, we can show the full text back to the user.<br></blockquote><blockquote type="cite">As it stands we show back the doctored text, i.e. the first word or  <br></blockquote><blockquote type="cite">line of the selected text.<br></blockquote><br>I think the user should see the term that was actually searched for,  <br>rather than the full (selected) text.<br><br>There is however a minor gotcha when presenting the dialog, here it  <br>has the doctored text, which might not make it very clear from where  <br>the text comes from (since only the first word is shown).</div></blockquote><br><div>Probably the way other cocoa apps handle this is to display either the first or last line </div><div>(as the dialogue can visibly accomodate a single line of text). However other Cocoa </div><div>apps often don't have the limitation for searching a single word as the search term. </div><blockquote type="cite"><div><br><br><blockquote type="cite">3) With the latest (above) the command it still may not execute  <br></blockquote><blockquote type="cite">right for conditions where there are spaces, tabs, or newline  <br></blockquote><blockquote type="cite">characters etc before the text point. So cleaning up the input  <br></blockquote><blockquote type="cite">should be tested and tweaked some more.<br></blockquote><br>I believe I fixed that in the version I committed (I did make a few  <br>changes compared to your latest version).<br><br><blockquote type="cite">4) If the word is wrapped in square brackets. e.g. [NSArray] - then  <br></blockquote><blockquote type="cite">TM_SELECTED_TEXT will not work but TM_CURRENT_WORD will.<br></blockquote><blockquote type="cite">Again, a better place to sanitize this input may be either  <br></blockquote><blockquote type="cite">search_docs(query) or search_docs_all(query)<br></blockquote><br>I think this is actually because the scope of this selection has it  <br>call a different documentation lookup function (the one for selectors).</div></blockquote><blockquote type="cite"><div><br><br><blockquote type="cite">5) If we have just run the command (Ctrl-H) then we have opened a  <br></blockquote><blockquote type="cite">Web-window and not a text window.<br></blockquote><blockquote type="cite">Can we press Ctrl-H here (in the html window) to bring up the dialog  <br></blockquote><blockquote type="cite">again to perform another search?<br></blockquote><br>In theory, yes. But it would require doctoring the presented page (to  <br>handle a key down event on ⌃H and use TextMate.system() to open the  <br>dialog etc.) — it might be better to leave it be and wait for a more  <br>general re-run ability for commands with HTML output.</div></blockquote><blockquote type="cite"><div><br><blockquote type="cite">6) As Allan wants we will show the search box only conditionally,  <br></blockquote><blockquote type="cite">when there isnt a current word on the caret. However it would be a  <br></blockquote><blockquote type="cite">nice option to have for those who always want to show it. This may  <br></blockquote><blockquote type="cite">sound like a personal request, however i would be very grateful  <br></blockquote><blockquote type="cite">because pressing Ctrl-W is very much more difficult with RSI than to  <br></blockquote><blockquote type="cite">press enter key with the dialog [...]<br></blockquote><br>Why do you need to press ⌃W?</div></blockquote><br>Ctrl-W - "select current word" afterwards to delete the search term just </div><div>typed in order to search on? Hey, I think I was a little unclear to begin with </div><div>so i must apologise. </div><div><br></div><div>My point was to request some a configurability on this command, which is </div><div>frequently used. Otherwise any change i do will be a hack and therefore </div><div>outdated in future revisions.</div><div><br></div><div>This suggestion is not meant to affect the default behaviour of TexMate.</div><div>I Won't feel hurt if you decide not to add it Allan, if its a little inconvenient.</div><div><br></div><div><div><br></div></div><div><div>def documentation_for_word<b>( request_string_always = FALSE )</b></div><div><span class="Apple-tab-span" style="white-space:pre">  </span>query = ENV['TM_SELECTED_TEXT'] || ENV['TM_CURRENT_WORD']</div><div><span class="Apple-tab-span" style="white-space:pre">    </span>query = $& if query.to_s =~ /\w*/</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">       </span>if query.to_s.empty?<b> || request_string_always</b></div><div><span class="Apple-tab-span" style="white-space:pre">             </span>query = %x{ __CF_USER_TEXT_ENCODING=$UID:0x8000100:0x8000100 /usr/bin/pbpaste -pboard find }</div><div><span class="Apple-tab-span" style="white-space:pre">         </span>query = $& if query =~ /\w+/</div><div><span class="Apple-tab-span" style="white-space:pre">             </span>query = TextMate::UI.request_string :title => "Documentation Search", :default => query, :prompt => "Search documentation for word"    </div><div><span class="Apple-tab-span" style="white-space:pre">               </span>abort if query.nil?</div><div><span class="Apple-tab-span" style="white-space:pre">  </span>end</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>results = search_docs_all(query)</div><div><span class="Apple-tab-span" style="white-space:pre">     </span>if results.nil? || results.empty?</div><div><span class="Apple-tab-span" style="white-space:pre">            </span>TextMate.exit_show_tool_tip "Cannot find documentation for: #{query}"</div><div><span class="Apple-tab-span" style="white-space:pre">      </span>else</div><div><span class="Apple-tab-span" style="white-space:pre">         </span>show_document(results, query)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>end</div><div>end</div><div><br></div><div><br></div><div><br></div><div>dreamcat7</div><div><a href="mailto:dreamcat7@googlemail.com">dreamcat7@googlemail.com</a></div></div><div><br><blockquote type="cite"><div><br>_______________________________________________<br>textmate mailing list<br><a href="mailto:textmate@lists.macromates.com">textmate@lists.macromates.com</a><br>http://lists.macromates.com/listinfo/textmate<br></div></blockquote></div><br></body></html>