Author Topic: Editor with configurable formatting  (Read 3258 times)

0 Members and 1 Guest are viewing this topic.

hmspe

  • Bull Frog
  • Posts: 362
Editor with configurable formatting
« on: January 08, 2008, 10:37:33 AM »
Any suggestions?  I've been using the vlide editor for formatting  and TextPad for coding.  I'm trying to rework some older code that's in all sorts of different formats and am trying to get everything into a common format.  The specific problem in the vlide editor is that I'm getting

   (progn  (defun list->variantArray

when I reformat when I want

   (progn
     (defun list->variantArray

No luck on finding anything useful on the web.  Is there a configuration file for the vlide editor beyond the few settings under Options?  Or an editor, add-on, or routine that's configurable?

Thanks for any suggestions.

Martin
"Science is the belief in the ignorance of experts." - Richard Feynman

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Editor with configurable formatting
« Reply #1 on: January 08, 2008, 11:01:05 AM »
You can see if this will work for you.  [>LINK<]
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Editor with configurable formatting
« Reply #2 on: January 08, 2008, 12:27:42 PM »
The problem & I've had it too is that sometimes you get lisp code without any Carriage Returns in the text.
The result is a long string of text & VLIDE will not add the CRLF to the existing code.
The problem is that you need a list of functions that would signal where the CRLF is to be added.

Vlide does nothing with this code:
(defun C:TEST () (progn (princ "XXX") (setq A (+ 1 (/ 25 2) 6))))
but if you add the CRLF then VLIDE will format the code.

Just imagine you got this code"
Code: [Select]
(setq Opt (getkword "\n <C>urrent, or enter to do multiply: "))(if (/= Opt "Current") (progn  (if (> (vla-get-Count (vla-get-Documents AcadObj)) 1) (prong (alert " Close all but one drawing and run again. ")    (exit)   )  )  (if (/= (getvar "dbmod") 0)   (progn  (initget "Y N") (setq SaveOpt (getkword "\n Drawing has changed.  Save changes before exiting drawings? <Y> ")) (if (or (= SaveOpt "Y") (not SaveOpt)) (setq SaveOpt "N")     (setq SaveOpt "Y")    )   )  ) ))(setq CurDate (rtos (getvar "cdate") 2 4))(setq RevDate (strcat (substr CurDate 5 2)"/"(substr CurDate 7 2)"/"(substr CurDate 3 2)))(setq DiaLoad (load_dialog "3m-Rev.dcl"))(if (not (new_dialog "MMMREV" DiaLoad))(exit))(set_tile "RevDate" RevDate)(set_tile "RevDwnBy" "TMW")(mode_tile "RevDes" 2)(action_tile "RevDes" "(if (/= (get_tile \"RevDes\") \"\")  (mode_tile \"Accept\" 2) )")(action_tile "Accept" "(progn  (setq RevList (list (get_tile \"RevPrjId\") (get_tile \"RevDate\") (get_tile \"RevDes\") (get_tile \"RevDwnBy\") (get_tile \"RevCkBy\")))  (setq NewRev (get_tile \"AddNewRev\"))  (done_dialog 1) )")(action_tile "OrgIssue" "(progn  (setq RevList (list (get_tile \"RevPrjId\") (get_tile \"RevDate\") '\"ORIGINAL ISSUE\" (get_tile \"RevDwnBy\") (get_tile \"RevCkBy\")))  (setq NewRev (get_tile \"AddNewRev\"))  (done_dialog 2) )")(action_tile "Cancel" "(done_dialog 0)")
Where woud you add the CRLF?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

hmspe

  • Bull Frog
  • Posts: 362
Re: Editor with configurable formatting
« Reply #3 on: January 08, 2008, 12:35:09 PM »
You can see if this will work for you.  [>LINK<]

Tim,

Thanks.  I saw your routine when I was looking at options.  I can extend it to do what I want, but was hoping to find a configurable formatting utility that's already coded.  Not a lot of spare time available at the moment, so I don't want to spend time building tools if I can avoid it.  I know back in the days of Turbo Pascal there were "pretty printers" readily available.  I was hoping that there would be the same for Autolisp.

Martin
"Science is the belief in the ignorance of experts." - Richard Feynman

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Editor with configurable formatting
« Reply #4 on: January 08, 2008, 12:48:55 PM »
I don't want to say then.  I think Michael had some code around that would kind of do what you want, but I'm not sure anymore.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

rkmcswain

  • Swamp Rat
  • Posts: 978
Re: Editor with configurable formatting
« Reply #5 on: January 08, 2008, 03:46:27 PM »

Just imagine you got this code"
Code: [Select]
(setq Opt (getkword "\n <C>urrent, or enter to do multiply: "))(if (/= Opt "Current") (progn  (if (> (vla-get-Count (vla-get-Documents AcadObj)) 1) (prong (alert " Close all but one drawing and run again. ")    (exit)   )  )  (if (/= (getvar "dbmod") 0)   (progn  (initget "Y N") (setq SaveOpt (getkword "\n Drawing has changed.  Save changes before exiting drawings? <Y> ")) (if (or (= SaveOpt "Y") (not SaveOpt)) (setq SaveOpt "N")     (setq SaveOpt "Y")    )   )  ) ))(setq CurDate (rtos (getvar "cdate") 2 4))(setq RevDate (strcat (substr CurDate 5 2)"/"(substr CurDate 7 2)"/"(substr CurDate 3 2)))(setq DiaLoad (load_dialog "3m-Rev.dcl"))(if (not (new_dialog "MMMREV" DiaLoad))(exit))(set_tile "RevDate" RevDate)(set_tile "RevDwnBy" "TMW")(mode_tile "RevDes" 2)(action_tile "RevDes" "(if (/= (get_tile \"RevDes\") \"\")  (mode_tile \"Accept\" 2) )")(action_tile "Accept" "(progn  (setq RevList (list (get_tile \"RevPrjId\") (get_tile \"RevDate\") (get_tile \"RevDes\") (get_tile \"RevDwnBy\") (get_tile \"RevCkBy\")))  (setq NewRev (get_tile \"AddNewRev\"))  (done_dialog 1) )")(action_tile "OrgIssue" "(progn  (setq RevList (list (get_tile \"RevPrjId\") (get_tile \"RevDate\") '\"ORIGINAL ISSUE\" (get_tile \"RevDwnBy\") (get_tile \"RevCkBy\")))  (setq NewRev (get_tile \"AddNewRev\"))  (done_dialog 2) )")(action_tile "Cancel" "(done_dialog 0)")
Where woud you add the CRLF?

Using PARNCHK.EXE (from http://garbo.uwasa.fi/pc/autocad.html ) - your single line of code became the following in less than a second.
Code: [Select]

(setq Opt
  (getkword "\n <C>urrent, or enter to do multiply: "))
(if
  (/= Opt "Current")
  (progn 
     (if
        (>
           (vla-get-Count
              (vla-get-Documents AcadObj)) 1)
        (prong
           (alert " Close all but one drawing and run again. ")   
           (exit)   )  ) 
     (if
        (/=
           (getvar "dbmod") 0)   
        (progn 
           (initget "Y N")
           (setq SaveOpt
              (getkword "\n Drawing has changed.  Save changes before exiting drawings? <Y> "))
           (if
              (or
                 (= SaveOpt "Y")
                 (not SaveOpt))
              (setq SaveOpt "N")     
              (setq SaveOpt "Y")    )   )  ) ))
(setq CurDate
  (rtos
     (getvar "cdate") 2 4))
(setq RevDate
  (strcat
     (substr CurDate 5 2)"/"
     (substr CurDate 7 2)"/"
     (substr CurDate 3 2)))
(setq DiaLoad
  (load_dialog "3m-Rev.dcl"))
(if
  (not
     (new_dialog "MMMREV" DiaLoad))
  (exit))
(set_tile "RevDate" RevDate)
(set_tile "RevDwnBy" "TMW")
(mode_tile "RevDes" 2)
(action_tile "RevDes" "
  (if
     (/=
        (get_tile \"RevDes\") \"\") 
     (mode_tile \"Accept\" 2) )")
(action_tile "Accept" "
  (progn 
     (setq RevList
        (list
           (get_tile \"RevPrjId\")
           (get_tile \"RevDate\")
           (get_tile \"RevDes\")
           (get_tile \"RevDwnBy\")
           (get_tile \"RevCkBy\"))) 
     (setq NewRev
        (get_tile \"AddNewRev\")) 
     (done_dialog 1) )")
(action_tile "OrgIssue" "
  (progn 
     (setq RevList
        (list
           (get_tile \"RevPrjId\")
           (get_tile \"RevDate\") '\"ORIGINAL ISSUE\"
           (get_tile \"RevDwnBy\")
           (get_tile \"RevCkBy\"))) 
     (setq NewRev
        (get_tile \"AddNewRev\")) 
     (done_dialog 2) )")
(action_tile "Cancel" "
  (done_dialog 0)")

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Editor with configurable formatting
« Reply #6 on: January 08, 2008, 04:05:28 PM »
Thanks, very cool. :)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

hmspe

  • Bull Frog
  • Posts: 362
Re: Editor with configurable formatting
« Reply #7 on: January 08, 2008, 07:45:43 PM »
Quote
Using PARNCHK.EXE (from http://garbo.uwasa.fi/pc/autocad.html ) - your single line of code became the following in less than a second.

I was able to find the file on their ftp site but got only "connection reset" errors on the http site you listed.  I also found parnchk.exe a few other places.  Unfortunately, it won't run under 64 bit XP. 

Thanks for the suggestion.

Martin
"Science is the belief in the ignorance of experts." - Richard Feynman

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: Editor with configurable formatting
« Reply #8 on: January 08, 2008, 10:51:08 PM »
do a search for "code beautifiers lisp" that should turn up something.
TheSwamp.org  (serving the CAD community since 2003)

hmspe

  • Bull Frog
  • Posts: 362
Re: Editor with configurable formatting
« Reply #9 on: January 09, 2008, 12:19:58 AM »
do a search for "code beautifiers lisp" that should turn up something.

Thanks.  The key is always knowing the correct search terms.

Martin
"Science is the belief in the ignorance of experts." - Richard Feynman

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Editor with configurable formatting
« Reply #10 on: February 23, 2008, 11:40:24 PM »
I don't want to say then.  I think Michael had some code around that would kind of do what you want, but I'm not sure anymore.

I think you might be referring to this post, though I don't think it would ultimately ante up what Martin is seeking.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: Editor with configurable formatting
« Reply #11 on: February 24, 2008, 05:03:26 AM »
The problem & I've had it too is that sometimes you get lisp code without any Carriage Returns in the text.
The result is a long string of text & VLIDE will not add the CRLF to the existing code.
The problem is that you need a list of functions that would signal where the CRLF is to be added.
to avoid problems with editing and formatting the action_tile strings i use vl-prin1-to-string
so, a part of your code will look like this
Code: [Select]
(action_tile
  "Accept"
  (vl-prin1-to-string
    (quote (progn (setq RevList (list (get_tile "RevPrjId")
      (get_tile "RevDate")
      (get_tile "RevDes")
      (get_tile "RevDwnBy")
      (get_tile "RevCkBy")
)
  )
  (setq NewRev (get_tile "AddNewRev"))
  (done_dialog 1)
   )
    )
  )
)