Author Topic: remove all comments  (Read 544 times)

0 Members and 1 Guest are viewing this topic.

domenicomaria

  • Swamp Rat
  • Posts: 725
remove all comments
« on: March 27, 2024, 05:40:07 AM »
is there any utility to remove all comments in a large lsp file?

Lonnie

  • Newt
  • Posts: 177
Re: remove all comments
« Reply #1 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.

Lastknownuser

  • Newt
  • Posts: 28
Re: remove all comments
« Reply #2 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

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: remove all comments
« Reply #3 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

kozmos

  • Newt
  • Posts: 114
Re: remove all comments
« Reply #4 on: March 28, 2024, 11:08:17 AM »
The very old LISPTOOL can do this job, but it doesn't support ;|.......|;

KozMos Inc.

JohnK

  • Administrator
  • Seagull
  • Posts: 10646
Re: remove all comments
« Reply #5 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.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: remove all comments
« Reply #6 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.

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2140
  • class keyThumper<T>:ILazy<T>
Re: remove all comments
« Reply #7 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.  
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: remove all comments
« Reply #8 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:

BIGAL

  • Swamp Rat
  • Posts: 1416
  • 40 + years of using Autocad
Re: remove all comments
« Reply #9 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.
« Last Edit: March 28, 2024, 08:47:13 PM by BIGAL »
A man who never made a mistake never made anything

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2140
  • class keyThumper<T>:ILazy<T>
Re: remove all comments
« Reply #10 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 ?
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.