Page 1 of 1

Interactive documentation

Posted: Tue Dec 06, 2005 10:33 am
by cormullion
I've been spending a lot of time looking through the documentation, and I just wondered - has an interactive documentation tool been developed for newLISP? I'm thinking of a quick way of finding out the syntax of functions... I seem to remember some function in Common Lisp that did something similar...

Posted: Tue Dec 06, 2005 11:07 am
by HPW
You may look here:

http://www.alh.net/newlisp/phpbb/viewto ... hlight=doc

http://www.alh.net/newlisp/phpbb/viewtopic.php?t=378

(Of cource for your own code, not for native commands)

Posted: Tue Dec 06, 2005 11:17 am
by cormullion
Yes, thanks - worth doing, although naturally I can understand all my own code... :-) :-) But I think it would be useful to have quick access to a syntax summary for native functions too...

Posted: Tue Dec 06, 2005 11:25 am
by HPW
But I think it would be useful to have quick access to a syntax summary for native functions too...
You would need to hack the TK-Frontend of newlisp to be able to jump from a highlighted topic/command into the HTML doc and the command as a target. Similar to the index frame in the doc.

Posted: Tue Dec 06, 2005 11:29 am
by HPW
Something like (for example setq):

file:///C:\Programme\newlisp\newlisp_manual.html#setq

Since the editor supports the selection for clipboard operation it should
be possible to take such string and makel a shell call with that manual-call.

Posted: Tue Dec 06, 2005 11:53 am
by cormullion
That's a great idea! I've managed to get a similar effect when using my text editor (which has a "Find in reference" command for the selected word)...

If you're using BBEdit or TextWrangler on MacOS, type this command to customise the Find in reference command for newLISP:

Code: Select all

defaults write com.barebones.bbedit Services:ADCReferenceSearchTemplate "file:///usr/share/newlisp/doc/newlisp_manual.html#%@"
and the relevant page will be displayed. The '%@' means the selected word, apparently. (Change 'bbedit' to 'textwrangler' if you're using the free version.)

I haven't even started to look at newlisp-tk yet ... So much to do :-)

Posted: Tue Dec 06, 2005 11:57 am
by HPW
Similar is possible with Ultraedit on Windows.

But I am quite sure it could be done in newLISP-TK with TCL.

Lutz,

time for newLISP-TK 1.31 ??

;-)

Posted: Tue Dec 06, 2005 5:50 pm
by Lutz
Try this on OSX when running newLISP in a terminal window:

Code: Select all

(define-macro (help func) 
  (if (primitive? (eval func)) 
    (!  (format "open http://newlisp.org/newlisp_manual.html#%s" (name func))) 
    (format "%s is not a built-in function" (name func))))

;; try

(help println) => pops up manual in your default browser and positions to 'println'

(help foo) => "foo is not a built-in function"
A similar thing is possible in Linux/UNIX or Win32 when replacing 'open' with the name of the browser application.

Lutz

Posted: Tue Dec 06, 2005 6:08 pm
by Lutz
if you have lynx installed on yur Linux/UNIX/OSX box you can use the following very fast method:

Code: Select all

(define-macro (help func)
  (if (primitive? (eval func))
    (!  (format "lynx /usr/share/newlisp/doc/newlisp_manual.html#%s" (name func)))
    (format "%s is not a built-in function" (name func))))
I have this in my /usr/share/newlisp/init.lsp file. It is almost instantly because lynx ( a character based web growser) loads very fast.

Lutz

Posted: Tue Dec 06, 2005 7:39 pm
by cormullion
Thanks, Lutz. This is also very useful!

Posted: Wed Dec 07, 2005 4:35 pm
by cormullion
You certainly won't like this version I'm currently using:

Code: Select all

(define-macro (?? func) 
	"(?? println) => displays syntax for func "
  (if (primitive? (eval func))
    (begin 
    	(set 'file (open "/usr/share/newlisp/doc/newlisp_manual.html" "read"))
		(search file (string {<a NAME="} (name func) {">} ) )
		(read-buffer file 'buff 500 )
		(replace  "<.+>" buff "" 512 )
		(replace ">" buff ">")
		(replace "<" buff "<")
		(println buff "...")
		(close file)))) 
but it's so quick I can't help using it. It's wonderful how even a beginner like me can do this sort of thing in (new)LISP...

Posted: Wed Dec 07, 2005 6:08 pm
by Lutz
Actually I like it very much, fast and streight forward.

Lutz

Posted: Wed Dec 07, 2005 9:30 pm
by Sammo
Thanks, cormullion.

This is great! Because it's "nothing but newLisp," it works in Windows, too, with the obvious change.

-- Sam

Posted: Thu Dec 08, 2005 8:24 am
by cormullion
:-) I discovered that it doesn't work with every single function. I think it should do a case-insensitive search...

Posted: Sun Dec 11, 2005 8:23 am
by HPW
But I am quite sure it could be done in newLISP-TK with TCL.
time for newLISP-TK 1.31 ??
Take the newlisp-tk.tcl from 8.7.4 source.

Here we go:

Add a var to config vars (here windows version):

Code: Select all

set Ide(HelpFile) "$env(PROGRAMFILES)/newlisp/newlisp_manual.html"
Add a proc:

Code: Select all

proc CommandHelp { widget } {
	global selectionBuff Ide
	catch [set selectionBuff [selection get -displayof $widget ]]
	exec $Ide(HelpProgram) $Ide(HelpFile)#$selectionBuff
	}
Add a binding to the key-bindings:

Code: Select all

bind $txt <F1> { CommandHelp %W }
Voila, highlight the keyword and press F1 and you get the doku.

time for newLISP-TK 1.31 ??

;-)

Posted: Sun Dec 11, 2005 12:31 pm
by Lutz
It will go into the right-click popup menu

Lutz

Posted: Sun Dec 11, 2005 6:37 pm
by HPW
Lutz,

also nice to put it there, but can you add also the key-binding?
When you have platform concerns you can add it like this in SetupConsole:

Code: Select all

	if { $Ide(platform) == "windows" } {
		bind $txt <F1> { CommandHelp %W }
	}
Windows user usually use F1 as the help-key.
;-)