newLISP Fan Club

Forum => Anything else we might add? => Topic started by: cormullion on December 06, 2005, 02:33:48 AM

Title: Interactive documentation
Post by: cormullion on December 06, 2005, 02:33:48 AM
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...
Title:
Post by: HPW on December 06, 2005, 03:07:59 AM
You may look here:



http://www.alh.net/newlisp/phpbb/viewtopic.php?t=782&highlight=doc



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



(Of cource for your own code, not for native commands)
Title:
Post by: cormullion on December 06, 2005, 03:17:31 AM
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...
Title:
Post by: HPW on December 06, 2005, 03:25:03 AM
Quote
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.
Title:
Post by: HPW on December 06, 2005, 03:29:11 AM
Something like (for example setq):



file:///C:Programmenewlispnewlisp_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.
Title:
Post by: cormullion on December 06, 2005, 03:53:12 AM
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:


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 :-)
Title:
Post by: HPW on December 06, 2005, 03:57:27 AM
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 ??



;-)
Title:
Post by: Lutz on December 06, 2005, 09:50:10 AM
Try this on OSX when running newLISP in a terminal window:



(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
Title:
Post by: Lutz on December 06, 2005, 10:08:02 AM
if you have lynx installed on yur Linux/UNIX/OSX box you can use the following very fast method:



(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
Title:
Post by: cormullion on December 06, 2005, 11:39:44 AM
Thanks, Lutz. This is also very useful!
Title:
Post by: cormullion on December 07, 2005, 08:35:25 AM
You certainly won't like this version I'm currently using:


(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...
Title:
Post by: Lutz on December 07, 2005, 10:08:54 AM
Actually I like it very much, fast and streight forward.



Lutz
Title:
Post by: Sammo on December 07, 2005, 01:30:11 PM
Thanks, cormullion.



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



-- Sam
Title:
Post by: cormullion on December 08, 2005, 12:24:21 AM
:-) I discovered that it doesn't work with every single function. I think it should do a case-insensitive search...
Title:
Post by: HPW on December 11, 2005, 12:23:48 AM
Quote
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):

set Ide(HelpFile) "$env(PROGRAMFILES)/newlisp/newlisp_manual.html"


Add a proc:

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:

bind $txt <F1> { CommandHelp %W }


Voila, highlight the keyword and press F1 and you get the doku.



time for newLISP-TK 1.31 ??



;-)
Title:
Post by: Lutz on December 11, 2005, 04:31:35 AM
It will go into the right-click popup menu



Lutz
Title:
Post by: HPW on December 11, 2005, 10:37:41 AM
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:

if { $Ide(platform) == "windows" } {
bind $txt <F1> { CommandHelp %W }
}


Windows user usually use F1 as the help-key.

;-)