[TxMt] Re: Searching the Objective-C documentation

dreamcat7 dreamcat7 at googlemail.com
Wed Jan 14 16:27:43 UTC 2009


On 14 Jan 2009, at 07:42, Allan Odgaard wrote:

> On 9 Jan 2009, at 14:23, dreamcat7 wrote:
>
>> 1) We chopped the input into only one word so the script can handle
>> it better and not throw to the tooltip a big error. I put this
>> stripping / to the query string, however it really should move to
>> the search_docs(query) command, where we are executing the search.
>> Sorry but I did add to there and break the ruby code.
>>
>> Ctrl-H --> documentation_for_word() --> search_docs_all(query) -->
>> search_docs(query)**  --> docsetutil
>> Ctrl-H --> documentation_for_word() --> search_docs_all(query) -->
>> man_page(query)**     --> man
>>
>> 2) If we keep the full string in query variable, then when we print
>> the tooltip, we can show the full text back to the user.
>> As it stands we show back the doctored text, i.e. the first word or
>> line of the selected text.
>
> I think the user should see the term that was actually searched for,
> rather than the full (selected) text.
>
> There is however a minor gotcha when presenting the dialog, here it
> has the doctored text, which might not make it very clear from where
> the text comes from (since only the first word is shown).

Probably the way other cocoa apps handle this is to display either the  
first or last line
(as the dialogue can visibly accomodate a single line of text).  
However other Cocoa
apps often don't have the limitation for searching a single word as  
the search term.
>
>
>> 3) With the latest (above) the command it still may not execute
>> right for conditions where there are spaces, tabs, or newline
>> characters etc before the text point. So cleaning up the input
>> should be tested and tweaked some more.
>
> I believe I fixed that in the version I committed (I did make a few
> changes compared to your latest version).
>
>> 4) If the word is wrapped in square brackets. e.g. [NSArray] - then
>> TM_SELECTED_TEXT will not work but TM_CURRENT_WORD will.
>> Again, a better place to sanitize this input may be either
>> search_docs(query) or search_docs_all(query)
>
> I think this is actually because the scope of this selection has it
> call a different documentation lookup function (the one for  
> selectors).
>
>
>> 5) If we have just run the command (Ctrl-H) then we have opened a
>> Web-window and not a text window.
>> Can we press Ctrl-H here (in the html window) to bring up the dialog
>> again to perform another search?
>
> In theory, yes. But it would require doctoring the presented page (to
> handle a key down event on ⌃H and use TextMate.system() to open the
> dialog etc.) — it might be better to leave it be and wait for a more
> general re-run ability for commands with HTML output.
>
>> 6) As Allan wants we will show the search box only conditionally,
>> when there isnt a current word on the caret. However it would be a
>> nice option to have for those who always want to show it. This may
>> sound like a personal request, however i would be very grateful
>> because pressing Ctrl-W is very much more difficult with RSI than to
>> press enter key with the dialog [...]
>
> Why do you need to press ⌃W?

Ctrl-W - "select current word" afterwards to delete the search term just
typed in order to search on? Hey, I think I was a little unclear to  
begin with
so i must apologise.

My point was to request some a configurability on this command, which is
frequently used. Otherwise any change i do will be a hack and therefore
outdated in future revisions.

This suggestion is not meant to affect the default behaviour of TexMate.
I Won't feel hurt if you decide not to add it Allan, if its a little  
inconvenient.


def documentation_for_word( request_string_always = FALSE )
	query = ENV['TM_SELECTED_TEXT'] || ENV['TM_CURRENT_WORD']
	query = $& if query.to_s =~ /\w*/

	if query.to_s.empty? || request_string_always
		query = %x{ __CF_USER_TEXT_ENCODING=$UID:0x8000100:0x8000100 /usr/ 
bin/pbpaste -pboard find }
		query = $& if query =~ /\w+/
		query = TextMate::UI.request_string :title => "Documentation  
Search", :default => query, :prompt => "Search documentation for word"
		abort if query.nil?
	end

	results = search_docs_all(query)
	if results.nil? || results.empty?
		TextMate.exit_show_tool_tip "Cannot find documentation for: #{query}"
	else
		show_document(results, query)
	end
end



dreamcat7
dreamcat7 at googlemail.com

>
> _______________________________________________
> textmate mailing list
> textmate at lists.macromates.com
> http://lists.macromates.com/listinfo/textmate

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20090114/b1c0fbcc/attachment.html>


More information about the textmate mailing list