TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: domenicomaria on March 27, 2024, 05:40:07 AM

Title: remove all comments
Post by: domenicomaria on March 27, 2024, 05:40:07 AM
is there any utility to remove all comments in a large lsp file?
Title: Re: remove all comments
Post by: Lonnie on March 27, 2024, 05:38:18 PM
How large?

chatgpt will let you put a lisp in up to a maximum limit for input text is 4096. It will clean and comment pretty well. I often use it to write my header.
Title: Re: remove all comments
Post by: Lastknownuser on March 28, 2024, 02:19:00 AM
is there any utility to remove all comments in a large lsp file?

Notepad++
CTRL+H
Find what: ";.*"
Replace with: empty string ""
Replace all
Title: Re: remove all comments
Post by: It's Alive! on March 28, 2024, 10:51:00 AM
I had one in .EXE, but it doesn't run (1991) lol
Id bet common lispers have one
Title: Re: remove all comments
Post by: kozmos on March 28, 2024, 11:08:17 AM
The very old LISPTOOL can do this job, but it doesn't support ;|.......|;

Title: Re: remove all comments
Post by: JohnK on March 28, 2024, 06:24:27 PM
Not sure why you'd want to do this but your text editor should be able to do this as Lastknownuser pointed out.

I had one in .EXE, but it doesn't run (1991) lol
Id bet common lispers have one

Just made one in C. Reads a directory of files and outputs to a new file while skipping all comment lines.
Title: Re: remove all comments
Post by: Lee Mac on March 28, 2024, 06:42:14 PM
is there any utility to remove all comments in a large lsp file?

Notepad++
CTRL+H
Find what: ";.*"
Replace with: empty string ""
Replace all

Consider semi-colons in string literals, and multiline comments.
Title: Re: remove all comments
Post by: kdub_nz on March 28, 2024, 06:59:35 PM
. . . and inline comments

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (setq painInTheButt ;|some note here|; (getvar "petPeeves"))
  3.  
  4.  
Title: Re: remove all comments
Post by: It's Alive! on March 28, 2024, 07:36:51 PM
When I first started using lisp, I’d have a version with comments and extra whitespace in the code removed, thinking it would run faster.
I was like compiling bro :lol:
Title: Re: remove all comments
Post by: BIGAL on March 28, 2024, 08:32:58 PM
Bit like on another forum a poster uses tabs and indents code problem is it pushes so far to right code disappears. I try to use 2 spaces rather than tab. Again use \t in search.

It would be pretty easy if comments are always to right -> end of line single lines, to write a lisp using Vl-position and substr writing to a temp file, option delete original or put some where else, then rename back to original.
Title: Re: remove all comments
Post by: kdub_nz on March 28, 2024, 09:49:43 PM
When I first started using lisp, I’d have a version with comments and extra whitespace in the code removed, thinking it would run faster.
. . .  :lol:

and you believed in the Easter bunny too ?