Notepad++ syntax highlighting for CAD LISP

Bricsys developer Torsten Moses improved the LISP development environment BLADE in many aspects. It runs also on Scintilla, just as Notepad++. So if you’re using BricsCAD V19, you may consider using BLADE instead. Even if you code for AutoCAD, you may want to use BricsCAD with BLADE for that purpose, it is simply a way better tool set and combined with ACME autoloader you can switch from BricsCAD to AutoCAD and back. Then again, you can simply keep on using npp with this extension. Time for a comparison:

Task

NPP+CAD_LISP

BLADE

Selecting parts including opening and closing parenthesis

cursor near ( or ) and Ctrl-Alt-B

Ctrl-Shift-R

Selecting parts between parenthesis

Ctrl+DLMB

?

Select a complete line, carriage return etc. included

TLMB

TLMB

Indent

Select block and Tab or Shift-Tab

Select block and Tab or Shift-Tab

Line duplicate

Ctrl+D

Alt-O

Line delete

Ctrl-L

Shift-Del

Commenting

Ctrl-Q toggles comment / uncomment

Comment Alt-L, Uncomment Alt-N

Notepad++, abbreviated npp, has a LISP template built-in. But LISP for CAD is quite different from LISP for “plain” programming.

Several templates for CAD circulate on the net, none made me 100% happy.So, after starting npp, it was time to choose “Language” -> “Define User Language”.It did not take much time to make something and I’m happy with it. This is the result:

I would like to share the XML file.You can download it and I hope it helps you.I also hope that some feedback can improve the file.See below.

But that is not all, a discussion here https://forum.bricsys.com/discussion/comment/33907 did lead to another version with all (!) commands build in. Special thanks to Torsten Moses for his contribution (and CADbloke for inspiring). Torsten’s extensive function list for UltraEdit was included.

Anyway, the result is a second download below and despite its size, you probably prefer this one.

Assumptions

A long program must be readable.Therefore, all comments have a light background colour.Just get used to it and notice that it works well. Toggle for comments: Ctrl-q. Because functions like (princ “information”) contribute to the readability of a program, strings have also a light background.

An exhibition of colours does not contribute to proper readability. On the other hand: differences between functions, variables and texts must be clear enough.

“Lost In Stupid Parenthesis”: Parenthesis should be very clear. Everyone forgets one now and then, but it should be very easy to find the ones that do not match. They are notably visible. Highlighting works well in npp and parenthesis turn red when the cursor is next to it. Ctrl-b and or Ctrl+DLMB to select a block is also very helpful.

LISP as used in BricsCAD is extremely compatible with AutoCAD. However, at Bricsys they are doing product development. So they have commands that do not work in AutoCAD. Those functions have the same colour but are – as a warning – italic. At Bricsys they try to solve that problem with “VLE functions”. These are native and fast functions in BricsCAD and Bricsys offers a variant in LISP written for AutoCAD. You can even distribute these functions with your app for AutoCAD. They are a bit slower then but that is in line with recent AutoCAD versions.

The function list was based on the AutoCAD function list for OS-X. But if you have an Apple and want to run CAD software and think about it, you’ll skip Autodesk and go to Bricsys. So I changed the function list and took AutoCAD 2016 as a base and added the BricsCAD V17 extra functions. All in all, this xml code now covers thousands of functions.

Files for download

Example

Why all the work to put thousands of functions in this language file? A real world example gives a clue:

In a complex LISP file (many hundreds of lines) , some functions are defined: “primer”, “position”, “shapes”, and “varset”. They are called in a sequence:

In AutoCAD you will not notice anything. However, BricsCAD has a more modern and richer LISP environment and “position” is an internal function that is lacking in AutoCAD. Since functions are red and differing functions are in italics, you see a problem arise. Ask yourself, hoe would it be if all functions would appear similar? Exactly, crashes and seeking needles in haystacks.

Bonus

Some things to remember. You have a powerful editor configured, giving you the possibility to drive your efficiency to new heights. Take advantage of that:

Mark your code as CAD_LISP: Menu > Language > CAD_LISP

Selecting:

Parts including opening and closing parenthesis: put cursor right before or after ( or ) and Ctrl-Alt-b.

quoted parts were green. For something like '(a,b) that is fine. However, when using function '(lambda () ...), a large range of parenthesis could be excluded from bracket matching. So this item has been disabled.