feature suggestion: modeline / view defaults

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

feature suggestion: modeline / view defaults

chrysn
hi openscad developers,

i'd like to suggest a feature addition: editor modelines (or something
else that allows per-file default options) (a nice introduction to
modelines is at [1])

coming from vim, i'd suggest them to look like vi's, for example:

// scad:noeditor:autoreload:axes

that means: "openscad, the new default options are to hide the editor,
to turn on the auto-reload feature (this implies rendering immediately
after startup), and to display the axes indicator".

mode lines are traditionally hidden in comments, because generic editors
don't know which language comes along, and scan everywhere in the file
without knowledge of comments, so the editor-specific commands can be
escaped by whatever way the particular file has for commenting out
stuff.

an alternative would be to use openscad variable syntax, looking like
this (for the same commands):

$show_editor = false;
$autoreload = true;
$show_axes = true;

this has the disadvantage that the file needs to be parsed on load, and
the advantage that we don't need another parser.

would you consider such a mechanism feasible?

regards
chrysn

[1] http://shallowsky.com/blog/linux/editors/modelines.html

--
You don't become great by trying to be great. You become great
by wanting to do something, and then doing it so hard that you
become great in the process.
  -- Marie Curie (as quoted by Randall Munroe)

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: feature suggestion: modeline / view defaults

chrysn
On Tue, Jun 21, 2011 at 03:08:53PM +0200, chrysn wrote:
> // scad:noeditor:autoreload:axes

i've just completed a patch that implements the described behavior. it
can be fetched from my openscad repostiory at [1] (in the patched
branch, commit 40b82f41).

although tempting, i didn't touch on the topic of setting the view point
-- at the moment, this can only be done rotating the model (effectively
abusing the modelview matrix as a projection matrix). implementing a
"top" and a "orthogonal" option would be easy, though -- i just think
that sooner or later we'll need camera options directly accessible
anyway.

the options currently supported are:

* [no]editor, [no]console -- hide or show the editor or the console
* [no]autoreload -- control automatic reload behavior
* [no]axes, [no]crosshairs, [no]edges -- show axes, crosshairs or edges
* opencsg, cgalsurfaces, cgalgrid, throwntogether -- change the default
  display mode (the cgalsurfaces and cgalgrid are only partially
  functional as they are reset on reload -- is there a resaon why this
  happens?)

the syntax is just the one vi uses, without the legacy set part -- that
is, whitespace, then 'scad:', then options separated by colons, possibly
surrounded by whitespace.

regards
chrysn

[1] git://gitorious.org/openscad-debian/openscad.git

--
To use raw power is to make yourself infinitely vulnerable to greater powers.
  -- Bene Gesserit axiom

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: feature suggestion: modeline / view defaults

nophead
I would have thought that noeditor and autoreload should be user preferences applied to any file rather than stored in the model file. I.e. they should be set by the menu and persist across sessions. Possibly they should also be combined as I can't see why you would have one without the other. 

On 21 June 2011 23:04, chrysn <[hidden email]> wrote:
On Tue, Jun 21, 2011 at 03:08:53PM +0200, chrysn wrote:
> // scad:noeditor:autoreload:axes

i've just completed a patch that implements the described behavior. it
can be fetched from my openscad repostiory at [1] (in the patched
branch, commit 40b82f41).

although tempting, i didn't touch on the topic of setting the view point
-- at the moment, this can only be done rotating the model (effectively
abusing the modelview matrix as a projection matrix). implementing a
"top" and a "orthogonal" option would be easy, though -- i just think
that sooner or later we'll need camera options directly accessible
anyway.

the options currently supported are:

* [no]editor, [no]console -- hide or show the editor or the console
* [no]autoreload -- control automatic reload behavior
* [no]axes, [no]crosshairs, [no]edges -- show axes, crosshairs or edges
* opencsg, cgalsurfaces, cgalgrid, throwntogether -- change the default
 display mode (the cgalsurfaces and cgalgrid are only partially
 functional as they are reset on reload -- is there a resaon why this
 happens?)

the syntax is just the one vi uses, without the legacy set part -- that
is, whitespace, then 'scad:', then options separated by colons, possibly
surrounded by whitespace.

regards
chrysn

[1] git://gitorious.org/openscad-debian/openscad.git

--
To use raw power is to make yourself infinitely vulnerable to greater powers.
 -- Bene Gesserit axiom

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad


Reply | Threaded
Open this post in threaded view
|

Re: feature suggestion: modeline / view defaults

chrysn
On Tue, Jun 21, 2011 at 11:34:18PM +0100, nop head wrote:
> I would have thought that noeditor and autoreload should be user preferences
> applied to any file rather than stored in the model file. I.e. they should
> be set by the menu and persist across sessions. Possibly they should also be
> combined as I can't see why you would have one without the other.

i'm not opposed to having them as global persistable options, but there
are times when they are useful on a per-file basis, for example if, in a
project, there is one generated file that never needs an editor shown.

besides, modelines allow to have options in a projects that apply over
different users' checkouts independent of local settings.

regards
chrysn

--
To use raw power is to make yourself infinitely vulnerable to greater powers.
  -- Bene Gesserit axiom

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: feature suggestion: modeline / view defaults

Len Trigg
In reply to this post by chrysn
I think it would be much better to have command-line flags to control
the initial behaviour of those options.

Cheers,
Len.

On Wed, Jun 22, 2011 at 1:08 AM, chrysn <[hidden email]> wrote:

> hi openscad developers,
>
> i'd like to suggest a feature addition: editor modelines (or something
> else that allows per-file default options) (a nice introduction to
> modelines is at [1])
>
> coming from vim, i'd suggest them to look like vi's, for example:
>
> // scad:noeditor:autoreload:axes
>
> that means: "openscad, the new default options are to hide the editor,
> to turn on the auto-reload feature (this implies rendering immediately
> after startup), and to display the axes indicator".
>
> mode lines are traditionally hidden in comments, because generic editors
> don't know which language comes along, and scan everywhere in the file
> without knowledge of comments, so the editor-specific commands can be
> escaped by whatever way the particular file has for commenting out
> stuff.
>
> an alternative would be to use openscad variable syntax, looking like
> this (for the same commands):
>
> $show_editor = false;
> $autoreload = true;
> $show_axes = true;
>
> this has the disadvantage that the file needs to be parsed on load, and
> the advantage that we don't need another parser.
>
> would you consider such a mechanism feasible?
>
> regards
> chrysn
>
> [1] http://shallowsky.com/blog/linux/editors/modelines.html
>
> --
> You don't become great by trying to be great. You become great
> by wanting to do something, and then doing it so hard that you
> become great in the process.
>  -- Marie Curie (as quoted by Randall Munroe)
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad
>
>

Reply | Threaded
Open this post in threaded view
|

Re: feature suggestion: modeline / view defaults

chrysn
On Wed, Jun 22, 2011 at 01:16:59PM +1200, Len Trigg wrote:
> I think it would be much better to have command-line flags to control
> the initial behaviour of those options.

no objections either. if you look at other editors (again, coming from
vim), all three (modelines, per-user config, command line arguments) are
possible.

c

signature.asc (836 bytes) Download Attachment