- Use 4 space indentation
- Code lines must not exceed 80 characters in length. Never use a single line that has more than 80 chars.
- Source files should be coded in UTF-8 using Unix-style newlines
These general rules are applicable to Tcl & SQL.
Also, the 80 character limit is important because the OpenACS API browser (at /api-doc/) presents documentation defined in ad_proc's doc_string declaration in html format; whereas ad_proc's body of code is presented wrapped in PRE tags. Longer code lines result in API documentation pages (and their paragraphs) stretching outside of typical browser window width.
If you are using Emacs editor, you usually are on the safe side with regards to Tcl, as the tcl-mode indents just as we want it. ADP pages are formatted correctly when editor is in html-mode.
Formatting SQL Statements
- A proper format for select statements is
- A proper format for insert statements (and note the indentation and overflow of attributes)
insert into table_name
(c1, c2, c3 ...
cx, cy, cz)
(v1, v2, v3 ...
vx, vy, vz)
- A proper format for update statements:
There is an OpenACS mode for emacs which has features to help meet formatting standards.
One can add the following stanza to the end of a .tcl file, when using emacs, to avoid, that spaces are changed again into tabs.
# # Local variables: # mode: tcl # tcl-indent-level: 4 # indent-tabs-mode: nil # End:
Allowing user input to include images, see patch in this discussion thread: http://openacs.org/forums/message-view?message_id=182057