I look forward to Comments
Since you asked for feedback, here is my constructive criticism and suggestions:
Problem:
...
"(if (KDUB:autoloaderFindFile "
cmdpfile
")"
This will fail if the user provides a filepath containing backslashes instead of forward-slashes, i.e.:
(KDUB:autolspload "C:\\MyFolder\\MyLISP.lsp" '(("c:mylisp")))
This is the same bug that is present in the AutoLISP
autoload function.
Possible Solution:
Suggestion:Use of
foreach over
mapcar to iterate over variable
cmdlst.
foreach will outperform
mapcar when compiled, and will not require the anonymous
lambda function so may be clearer. Also, since you are not using the return of
mapcar, in my opinion, the code is more readable using
foreach.
Suggestion: ...
arglst ""
)
)
)
...
" ("
arglst
" / tst)"
This could be shortened to perhaps:
Suggestion:To avoid the issues encountered with escaping backslashes and converting the argument list to a string, consider replacing this:
"(defun "
cmdnam
" ("
arglst
" / tst)"
"(princ \"\nInitializing....\")"
"(setq tst "
cmdnam
")"
"(if (KDUB:autoloaderFindFile "
cmdpfile
")"
(strcat "(progn (load " cmdpfile
")") cmdpfile
")"
)
)
"(if (/= tst "
cmdnam
")"
"("
cmdnam
" "
arglst
")"
"(KDUB:autoloaderNoReDefun "
"\""
apptyp
"\""
" "
"\""
cmdnam
"\""
")
)
)"
"(KDUB:autoloaderNoFile "
cmdpfile
")
)"
")"
)
)
)
)
With something like:
'
(princ "\nInitializing....") )
(list 'KDUB:autoloaderNoReDefun apptyp cmdnam
) )
)
(list 'KDUB:autoloaderNoFile cmdfile
) )
)
)
)
So the function may become:
(defun KDUB:autoloader
( apptyp cmdfile cmdlst
/ cmdnam cmdsym varlst
) )
'
(princ "\nInitializing....") )
(list 'KDUB:autoloaderNoReDefun apptyp cmdnam
) )
)
(list 'KDUB:autoloaderNoFile cmdfile
) )
)
)
)
)
nil
)
Niggle:You have an extra "\"" in this function:
(DEFUN KDUB:autoloaderNoReDefun
(apptyp cmdnam
) "Load for function/command:\n\n\""
"\""
"\""
)
)
)
Take from my comments what you will
