Interactive documentation

For the Compleat Fan
Locked
cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Interactive documentation

Post 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...

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post 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)
Hans-Peter

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post 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...

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post 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.
Hans-Peter

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post 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.
Hans-Peter

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post 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 :-)

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post 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 ??

;-)
Hans-Peter

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post 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

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post 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

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

Thanks, Lutz. This is also very useful!

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post 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...

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Actually I like it very much, fast and streight forward.

Lutz

Sammo
Posts: 180
Joined: Sat Dec 06, 2003 6:11 pm
Location: Loveland, Colorado USA

Post by Sammo »

Thanks, cormullion.

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

-- Sam

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

:-) I discovered that it doesn't work with every single function. I think it should do a case-insensitive search...

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post 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 ??

;-)
Hans-Peter

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

It will go into the right-click popup menu

Lutz

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post 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.
;-)
Hans-Peter

Locked