Accessing Lua help from Crimson Editor

Posted by Nick Gammon on Tue 16 May 2006 10:36 PM — 3 posts, 21,185 views.

Australia Forum Administrator #0
I found this suggestion at:

http://luaboard.sytes.net/index.php?topic=2381.0


It is so useful I decided to reproduce it here. Effectively it will allow you to go directly to a topic in the helpfile when you press F1 if the word the cursor is currently at in the editor is in the helpfile's index, otherwise it will just open the index at the closest word.

  1. In Crimson editor Open Preferences dialog box (Tools -> Preferences) and select User Tools page
  2. Select an empty slot and fill with the following arguments.
    • Menu Text: Lua Context Help
    • Command: C:\your\pathto\Programming in Lua.chm
    • Argument: $(CurrWord)
    • Initial dir: $(FileDir)
    • Hot key: F1
    • Close on exit: Yes
    • Save before execute: No





The post above suggests the help file can be found at:


ftp://ftp.clanwos.org/pub/ebooks/Programming_in_Lua.chm

http://www.plop.nl/lua_tools/Programming_in_Lua.chm
USA #1
That's awesome.
Australia Forum Administrator #2
An alternative approach nowadays is to use the MUSHclient help files, as they include most of the Lua functions, one per page. This doesn't apply to keywords like "function", "for" etc. but usually once you have been programming in Lua for a little while you remember those.

However often you might wonder what is the exact order of arguments to string.find, for example.

To make this work, first we need to let periods be part of a variable name, so that when we put the cursor over string.find for example, it treats it as one word ("string.find") and neither "string" nor "find". That is because string.find is the keyword in the MUSHclient help file.

To do this, edit the file "lua.spc" - usually this would be here:


"C:\Program Files\Crimson Editor\spec\lua.spc"


Near the start is a $DELIMITERS line - we remove the period from the end of it. In fact the whole file should now look like this:


# LUA LANGUAGE SPECIFICATION FILE FOR CRIMSON EDITOR
# FIRST EDITED BY Walter Souto R. Junior (wsouto@bayweb.com.br) 05.11.2002
# UPDATE to Lua 5.0 by Matteo De Simone (matteo.desimone@libero.it) Jun, 16 2003

$CASESENSITIVE=YES
$DELIMITERS=(){}[]<>+-*/%="'~!@#&$^&|\?:;,
$VARIABLEPREFIX=
$ESCAPECHAR=\
$QUOTATIONMARK1="
$QUOTATIONMARK2='
$LINECOMMENT=--
$SHADOWON=[[
$SHADOWOFF=]]
$BLOCKCOMMENTON=--[[
$BLOCKCOMMENTOFF=--]]
$PAIRS1=()
$PAIRS2=[]
$PAIRS3={}
$MULTILINESTRINGCONSTANT=YES



With that done, we can now make F1 bring up the MUSHclient help file:

  1. In Crimson editor Open Preferences dialog box (Tools -> Preferences) and select User Tools page
  2. Select an empty slot (or the one you are using for F1) and fill with the following arguments.
    • Menu Text: MUSHclient Lua Help
    • Command: C:\WINDOWS\winhlp32.exe
    • Argument: -iLUA_$(CurrWord) mushclient.hlp
    • Initial dir: C:\Program Files\MUSHclient
    • Hot key: F1
    • Close on exit: Yes
    • Save before execute: No


If necessary, amend the path names above to reflect your setup. Now you can put the cursor over any standard Lua function (eg. tonumber, or string.match), press F1, and the MUSHclient help information for that function will be shown.

This should be used in conjunction with my other suggestion, which lets you look up MUSHclient internal functions (eg. world.Note):

http://www.gammon.com.au/forum/?id=6579