unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* make a drawing with Emacs
@ 2020-08-31  3:05 Emanuel Berg via Users list for the GNU Emacs text editor
  2020-08-31  7:36 ` tomas
                   ` (3 more replies)
  0 siblings, 4 replies; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-08-31  3:05 UTC (permalink / raw)
  To: help-gnu-emacs

Hello everyone,

the project I'm currently working on is a tree house.
It has two floors and then several extension
platforms which are reachable by ropes. Here are some
photos [1] - the "new-deck" was completed only one
week ago or something :)

Anyway, I'd like to make a drawing of it. Any idea
what software might be used? Can Emacs do this?
Or can you input the data in an Emacs buffer, and
have it compile into an image using some
3rd-hand software?

Optimally I'd like to just measure everything, then
input the data - perhaps as geometrical figures?
(e.g., a tree could be a circle, I input the diameter
and relative position...) and then the programs
compiles and produce the image ... good idea, right?

Last time I asked this, several years ago and
regarding another project, someone said org-mode can
do this. I never used it, so are there some starters?
I know org-mode can do state diagrams and all
computer things, but can you have it draw arbitrary
figures? If so, how?

TIA


[1] https://dataswamp.org/~incal/work-photos/tree-house/

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-08-31  3:05 make a drawing with Emacs Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-08-31  7:36 ` tomas
  2020-08-31 20:29   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-08-31 17:41 ` Marcin Borkowski
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 60+ messages in thread
From: tomas @ 2020-08-31  7:36 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 825 bytes --]

On Mon, Aug 31, 2020 at 05:05:02AM +0200, Emanuel Berg via Users list for the GNU Emacs text editor wrote:
> Hello everyone,
> 
> the project I'm currently working on is a tree house.
> It has two floors and then several extension
> platforms which are reachable by ropes. Here are some
> photos [1] - the "new-deck" was completed only one
> week ago or something :)
> 
> Anyway, I'd like to make a drawing of it. Any idea
> what software might be used? Can Emacs do this?
> Or can you input the data in an Emacs buffer, and
> have it compile into an image using some
> 3rd-hand software?

If you are thinking 3D, then OpenSCAD [1] might suit
you: pametric, script-centric, text-friendly.

Available on most of your friendly distro dealers :-)

Cheers

[1] https://en.wikipedia.org/wiki/OpenSCAD
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-08-31  3:05 make a drawing with Emacs Emanuel Berg via Users list for the GNU Emacs text editor
  2020-08-31  7:36 ` tomas
@ 2020-08-31 17:41 ` Marcin Borkowski
  2020-08-31 20:30   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-08-31 19:40 ` Carlo Tambuatco
  2020-08-31 20:56 ` Gregory Heytings via Users list for the GNU Emacs text editor
  3 siblings, 1 reply; 60+ messages in thread
From: Marcin Borkowski @ 2020-08-31 17:41 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs

artist-mode? ;-)

On a more serious note, how about tikz?

Hth,
mb


On 2020-08-31, at 05:05, Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:

> Hello everyone,
>
> the project I'm currently working on is a tree house.
> It has two floors and then several extension
> platforms which are reachable by ropes. Here are some
> photos [1] - the "new-deck" was completed only one
> week ago or something :)
>
> Anyway, I'd like to make a drawing of it. Any idea
> what software might be used? Can Emacs do this?
> Or can you input the data in an Emacs buffer, and
> have it compile into an image using some
> 3rd-hand software?
>
> Optimally I'd like to just measure everything, then
> input the data - perhaps as geometrical figures?
> (e.g., a tree could be a circle, I input the diameter
> and relative position...) and then the programs
> compiles and produce the image ... good idea, right?
>
> Last time I asked this, several years ago and
> regarding another project, someone said org-mode can
> do this. I never used it, so are there some starters?
> I know org-mode can do state diagrams and all
> computer things, but can you have it draw arbitrary
> figures? If so, how?
>
> TIA
>
>
> [1] https://dataswamp.org/~incal/work-photos/tree-house/


--
Marcin Borkowski
http://mbork.pl



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-08-31  3:05 make a drawing with Emacs Emanuel Berg via Users list for the GNU Emacs text editor
  2020-08-31  7:36 ` tomas
  2020-08-31 17:41 ` Marcin Borkowski
@ 2020-08-31 19:40 ` Carlo Tambuatco
  2020-08-31 20:33   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-08-31 20:56 ` Gregory Heytings via Users list for the GNU Emacs text editor
  3 siblings, 1 reply; 60+ messages in thread
From: Carlo Tambuatco @ 2020-08-31 19:40 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

Blender.

On Sun, Aug 30, 2020, 11:05 PM Emanuel Berg via Users list for the GNU
Emacs text editor <help-gnu-emacs@gnu.org> wrote:

> Hello everyone,
>
> the project I'm currently working on is a tree house.
> It has two floors and then several extension
> platforms which are reachable by ropes. Here are some
> photos [1] - the "new-deck" was completed only one
> week ago or something :)
>
> Anyway, I'd like to make a drawing of it. Any idea
> what software might be used? Can Emacs do this?
> Or can you input the data in an Emacs buffer, and
> have it compile into an image using some
> 3rd-hand software?
>
> Optimally I'd like to just measure everything, then
> input the data - perhaps as geometrical figures?
> (e.g., a tree could be a circle, I input the diameter
> and relative position...) and then the programs
> compiles and produce the image ... good idea, right?
>
> Last time I asked this, several years ago and
> regarding another project, someone said org-mode can
> do this. I never used it, so are there some starters?
> I know org-mode can do state diagrams and all
> computer things, but can you have it draw arbitrary
> figures? If so, how?
>
> TIA
>
>
> [1] https://dataswamp.org/~incal/work-photos/tree-house/
>
> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>


^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-08-31  7:36 ` tomas
@ 2020-08-31 20:29   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-08-31 20:49     ` Yuri Khan
  0 siblings, 1 reply; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-08-31 20:29 UTC (permalink / raw)
  To: help-gnu-emacs

tomas wrote:

> If you are thinking 3D, then OpenSCAD might suit
> you: pametric, script-centric, text-friendly.

No no, 2D, top-view! Like an old school engineering
drawing, but less detailed. But with real units...

But thanks anyway. Maybe 3D will be the next step.

But then I think I'd make it a Quake level.
OTOH shouldn't normalize falling down from it :)

*gulp*

PS. Fun fact: How did the French secret service
    reveal German spies? They said, "this place is
    fine but there are no good drawings. maybe you
    can make one?" a couple of days later, if they
    got a drawing that was perfect in every detail -
    bring the gun, it's a German spy for sure :)

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-08-31 17:41 ` Marcin Borkowski
@ 2020-08-31 20:30   ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-08-31 20:30 UTC (permalink / raw)
  To: help-gnu-emacs

Marcin Borkowski wrote:

> On a more serious note, how about tikz?

Will check that out, thanks.

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-08-31 19:40 ` Carlo Tambuatco
@ 2020-08-31 20:33   ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-08-31 20:33 UTC (permalink / raw)
  To: help-gnu-emacs

Carlo Tambuatco wrote:

> Blender.

"Very fast and versatile 3D modeller/renderer"
(Debian repos)

Maybe it can do 2D as well...

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-08-31 20:29   ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-08-31 20:49     ` Yuri Khan
  2020-08-31 20:52       ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 60+ messages in thread
From: Yuri Khan @ 2020-08-31 20:49 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Tue, 1 Sep 2020 at 03:29, Emanuel Berg via Users list for the GNU
Emacs text editor <help-gnu-emacs@gnu.org> wrote:

> > If you are thinking 3D, then OpenSCAD might suit
> > you: pametric, script-centric, text-friendly.
>
> No no, 2D, top-view! Like an old school engineering
> drawing, but less detailed. But with real units...

You want 2D, get LibreCAD.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-08-31 20:49     ` Yuri Khan
@ 2020-08-31 20:52       ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-08-31 21:01         ` Yuri Khan
  2020-09-01  8:18         ` tomas
  0 siblings, 2 replies; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-08-31 20:52 UTC (permalink / raw)
  To: help-gnu-emacs

Yuri Khan wrote:

>>> If you are thinking 3D, then OpenSCAD might suit
>>> you: pametric, script-centric, text-friendly.
>>
>> No no, 2D, top-view! Like an old school
>> engineering drawing, but less detailed. But with
>> real units...
>
> You want 2D, get LibreCAD.

I want to write code (data) and then have it
translate into a drawing. See the original post.
So no GUI, no actual "drawing". CAD doesn't sound
like that, but maybe I'm wrong?

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-08-31  3:05 make a drawing with Emacs Emanuel Berg via Users list for the GNU Emacs text editor
                   ` (2 preceding siblings ...)
  2020-08-31 19:40 ` Carlo Tambuatco
@ 2020-08-31 20:56 ` Gregory Heytings via Users list for the GNU Emacs text editor
  2020-08-31 21:00   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-09-01  5:37   ` Peter Münster
  3 siblings, 2 replies; 60+ messages in thread
From: Gregory Heytings via Users list for the GNU Emacs text editor @ 2020-08-31 20:56 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs


>
> Anyway, I'd like to make a drawing of it. Any idea what software might 
> be used? Can Emacs do this? Or can you input the data in an Emacs 
> buffer, and have it compile into an image using some 3rd-hand software?
>
> Optimally I'd like to just measure everything, then input the data - 
> perhaps as geometrical figures? (e.g., a tree could be a circle, I input 
> the diameter and relative position...) and then the programs compiles 
> and produce the image ... good idea, right?
>

I would do that with MetaPost.  It allows you to do exactly what you want: 
input the data in an Emacs buffer (Emacs has a MetaPost mode), as a series 
of geometrical figures and equations, which is compiled into an image.

Gregory



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-08-31 20:56 ` Gregory Heytings via Users list for the GNU Emacs text editor
@ 2020-08-31 21:00   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-09-01  8:40     ` Gregory Heytings via Users list for the GNU Emacs text editor
  2020-09-01  5:37   ` Peter Münster
  1 sibling, 1 reply; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-08-31 21:00 UTC (permalink / raw)
  To: help-gnu-emacs

Gregory Heytings via Users list for the GNU Emacs text editor wrote:

> I would do that with MetaPost. It allows you to do
> exactly what you want: input the data in an Emacs
> buffer (Emacs has a MetaPost mode), as a series of
> geometrical figures and equations, which is
> compiled into an image.

Wonderful! Yes, I have `metapost-mode'!

In the repos is texlive-metapost (and -doc)

That's it, I take it?

You have a small example I can compile?

Thanks anyway/already, now we're getting somewhere :)

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-08-31 20:52       ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-08-31 21:01         ` Yuri Khan
  2020-08-31 21:04           ` Emanuel Berg via Users list for the GNU Emacs text editor
                             ` (2 more replies)
  2020-09-01  8:18         ` tomas
  1 sibling, 3 replies; 60+ messages in thread
From: Yuri Khan @ 2020-08-31 21:01 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Tue, 1 Sep 2020 at 03:54, Emanuel Berg via Users list for the GNU
Emacs text editor <help-gnu-emacs@gnu.org> wrote:

> I want to write code (data) and then have it
> translate into a drawing. See the original post.
> So no GUI, no actual "drawing". CAD doesn't sound
> like that, but maybe I'm wrong?

Hm, why not just write SVG?



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-08-31 21:01         ` Yuri Khan
@ 2020-08-31 21:04           ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-08-31 22:48             ` Perry Smith
  2020-09-01  8:22           ` tomas
  2020-09-01  8:32           ` Emanuel Berg via Users list for the GNU Emacs text editor
  2 siblings, 1 reply; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-08-31 21:04 UTC (permalink / raw)
  To: help-gnu-emacs

Yuri Khan wrote:

>> I want to write code (data) and then have it
>> translate into a drawing. See the original post.
>> So no GUI, no actual "drawing". CAD doesn't sound
>> like that, but maybe I'm wrong?
>
> Hm, why not just write SVG?

I don't know? :)

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-08-31 21:04           ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-08-31 22:48             ` Perry Smith
  2020-08-31 23:09               ` Ulrich Deiters
  0 siblings, 1 reply; 60+ messages in thread
From: Perry Smith @ 2020-08-31 22:48 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs



> On Aug 31, 2020, at 4:04 PM, Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
> 
> Yuri Khan wrote:
> 
>>> I want to write code (data) and then have it
>>> translate into a drawing. See the original post.
>>> So no GUI, no actual "drawing". CAD doesn't sound
>>> like that, but maybe I'm wrong?
>> 
>> Hm, why not just write SVG?
> 
> I don't know? :)

It may not be suited for general drawings but Graphiz has “pic” … a language (flat ASCII text) that defines “graphs”.

https://en.wikipedia.org/wiki/Graphviz <https://en.wikipedia.org/wiki/Graphviz>



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-08-31 22:48             ` Perry Smith
@ 2020-08-31 23:09               ` Ulrich Deiters
  0 siblings, 0 replies; 60+ messages in thread
From: Ulrich Deiters @ 2020-08-31 23:09 UTC (permalink / raw)
  To: help-gnu-emacs

If you need something that plots functions, data points, etc. (even
including parameter fitting, various interpolation methods), I
can offer "grafix". It abuses emacs as an XML editor and builds
a human-readable graphics file, and then translates that into
PostScript.

-- 
Prof. i.R. Dr. Ulrich K. Deiters ______________________________________
Institut f. Physikalische Chemie \ Greinstr. 4–6, D-50939 Köln
Universitaet zu Köln   /\/\...    \ Tel. +49 (0)2232 932964
_______________________L|L|__|_____\ http://www.uni-koeln.de/deiters/



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-08-31 20:56 ` Gregory Heytings via Users list for the GNU Emacs text editor
  2020-08-31 21:00   ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-09-01  5:37   ` Peter Münster
  1 sibling, 0 replies; 60+ messages in thread
From: Peter Münster @ 2020-09-01  5:37 UTC (permalink / raw)
  To: help-gnu-emacs

On Mon, Aug 31 2020, Gregory Heytings via Users list for the GNU Emacs text editor wrote:

> I would do that with MetaPost.

Or MetaFun (MetaPost with extensions).

-- 
           Peter




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-08-31 20:52       ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-08-31 21:01         ` Yuri Khan
@ 2020-09-01  8:18         ` tomas
  2020-09-24 15:09           ` Jean Louis
  1 sibling, 1 reply; 60+ messages in thread
From: tomas @ 2020-09-01  8:18 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 947 bytes --]

On Mon, Aug 31, 2020 at 10:52:59PM +0200, Emanuel Berg via Users list for the GNU Emacs text editor wrote:
> Yuri Khan wrote:
> 
> >>> If you are thinking 3D, then OpenSCAD might suit
> >>> you: pametric, script-centric, text-friendly.
> >>
> >> No no, 2D, top-view! Like an old school
> >> engineering drawing, but less detailed. But with
> >> real units...
> >
> > You want 2D, get LibreCAD.
> 
> I want to write code (data) and then have it
> translate into a drawing. See the original post.
> So no GUI, no actual "drawing". CAD doesn't sound
> like that, but maybe I'm wrong?

TiKZ and OpenSCAD qualify, but they cover different areas (the one
is for (gorgeous!) diagranms and the other is for (dimensional)
drawings.

Don't let the 'CAD' in OpenSCAD lead you astray: you specify the
drawings in a written language (somewhat reminiscent of C). You get
some help from a viewer and a rudimentary editor.

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-08-31 21:01         ` Yuri Khan
  2020-08-31 21:04           ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-09-01  8:22           ` tomas
  2020-09-01  8:38             ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-09-01 12:22             ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-09-01  8:32           ` Emanuel Berg via Users list for the GNU Emacs text editor
  2 siblings, 2 replies; 60+ messages in thread
From: tomas @ 2020-09-01  8:22 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 883 bytes --]

On Tue, Sep 01, 2020 at 04:01:51AM +0700, Yuri Khan wrote:
> On Tue, 1 Sep 2020 at 03:54, Emanuel Berg via Users list for the GNU
> Emacs text editor <help-gnu-emacs@gnu.org> wrote:
> 
> > I want to write code (data) and then have it
> > translate into a drawing. See the original post.
> > So no GUI, no actual "drawing". CAD doesn't sound
> > like that, but maybe I'm wrong?
> 
> Hm, why not just write SVG?

I'd prefer writing Emacs lisp which writes SVG (actually I've dabbled
in that: much more fun!). Start about here:

  (require 'svg)
  (insert-image
   (svg-image
    (let ((svg (svg-create 100 100)))
      (svg-circle svg 50 50 20 :stroke-width 6 :stroke 'blue :fill 'yellow)
      svg)))

Of course, once you've got all the infrastructure for the drawings
of a tree house up and running, the tree might have grown out of
reach ;-)

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-08-31 21:01         ` Yuri Khan
  2020-08-31 21:04           ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-09-01  8:22           ` tomas
@ 2020-09-01  8:32           ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-09-01  8:58             ` tomas
  2 siblings, 1 reply; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-09-01  8:32 UTC (permalink / raw)
  To: help-gnu-emacs

Yuri Khan wrote:

>> I want to write code (data) and then have it
>> translate into a drawing. See the original post.
>> So no GUI, no actual "drawing". CAD doesn't sound
>> like that, but maybe I'm wrong?
>
> Hm, why not just write SVG?

I think SVG seems like a really good alternative.
I can't find a complete syntax reference tho. This is
the best page I found so far:

  https://flaviocopes.com/svg/

The .svg extension in Emacs gives me the major mode
`nxml-mode'

  nXML mode defined in ‘nxml-mode.el’:
  Major mode for editing XML.

So a file test.svg:

  <svg width="10" height="10">
    <rect
        x="0"
        y="0"
        width="10"
        height="10"
        fill="blue"
        />
  </svg>

works well! Only not in feh(1), my image viewer [1] -
but with

  $ convert test.svg test.png

I get a PNG!

Great :D


[1] https://dataswamp.org/~incal/SOFTWARE

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-01  8:22           ` tomas
@ 2020-09-01  8:38             ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-09-01  9:04               ` tomas
  2020-09-01 12:22             ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-09-01  8:38 UTC (permalink / raw)
  To: help-gnu-emacs

tomas wrote:

> I'd prefer writing Emacs lisp which writes SVG
> (actually I've dabbled in that: much more fun!)

Please share <3

> Start about here:
>
> (require 'svg)
> (insert-image
>  (svg-image
>   (let ((svg (svg-create 100 100)))
>     (svg-circle svg 50 50 20 :stroke-width 6 :stroke 'blue :fill 'yellow)
>     svg)))

Yeah but ... what is the advantage with that compared
to editing a text file, using Emacs? Syntax?
User-defined functions? It's Lisp?

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-08-31 21:00   ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-09-01  8:40     ` Gregory Heytings via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 60+ messages in thread
From: Gregory Heytings via Users list for the GNU Emacs text editor @ 2020-09-01  8:40 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs


>
>> I would do that with MetaPost. It allows you to do exactly what you 
>> want: input the data in an Emacs buffer (Emacs has a MetaPost mode), as 
>> a series of geometrical figures and equations, which is compiled into 
>> an image.
>
> Wonderful! Yes, I have `metapost-mode'!
>
> In the repos is texlive-metapost (and -doc)
>
> That's it, I take it?
>

Yes, that's the (Debian) package, and all you need.

>
> You have a small example I can compile?
>

See http://tex.loria.fr/prod-graph/zoonekynd/metapost/metapost.html .

The MetaPost manual is quite readable, and contains many small examples : 
https://www.tug.org/docs/metapost/mpman.pdf .



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-01  8:32           ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-09-01  8:58             ` tomas
  0 siblings, 0 replies; 60+ messages in thread
From: tomas @ 2020-09-01  8:58 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1363 bytes --]

On Tue, Sep 01, 2020 at 10:32:48AM +0200, Emanuel Berg via Users list for the GNU Emacs text editor wrote:
> Yuri Khan wrote:
> 
> >> I want to write code (data) and then have it
> >> translate into a drawing. See the original post.
> >> So no GUI, no actual "drawing". CAD doesn't sound
> >> like that, but maybe I'm wrong?
> >
> > Hm, why not just write SVG?
> 
> I think SVG seems like a really good alternative.
> I can't find a complete syntax reference tho. This is
> the best page I found so far:
> 
>   https://flaviocopes.com/svg/

Straight from the Horse's Mouth:

  https://www.w3.org/TR/SVG11/

W3.org is the keeper of SVG. They have a ton of other resources
on it.

What I don't like about SVG:

 - it's XML: XML is gross.
 - It's not XML: there's a whole lot of sublanguage hidden
   in the attribute strings which escapes the "XML lens".
   This is even grosser.

But it's a nice output format, which is not only vector, but can
be extended (e.g. sub-elements can be URL links and such things).
It can be married to CSS. So that part is nice.

What I don't like about SVG in Emacs: for display, it is "flattened"
to a "dead image", so the nifty and dynamical things get lost.

But hey. Set up a crowdfunding and give me two years (or give Stefan
a quarter of a year ;-)

So much for SVG :-)

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-01  8:38             ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-09-01  9:04               ` tomas
  2020-09-01 17:22                 ` Marcin Borkowski
  0 siblings, 1 reply; 60+ messages in thread
From: tomas @ 2020-09-01  9:04 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1221 bytes --]

On Tue, Sep 01, 2020 at 10:38:21AM +0200, Emanuel Berg via Users list for the GNU Emacs text editor wrote:
> tomas wrote:
> 
> > I'd prefer writing Emacs lisp which writes SVG
> > (actually I've dabbled in that: much more fun!)
> 
> Please share <3
> 
> > Start about here:
> >
> > (require 'svg)
> > (insert-image
> >  (svg-image
> >   (let ((svg (svg-create 100 100)))
> >     (svg-circle svg 50 50 20 :stroke-width 6 :stroke 'blue :fill 'yellow)
> >     svg)))
> 
> Yeah but ... what is the advantage with that compared
> to editing a text file, using Emacs? Syntax?
> User-defined functions? It's Lisp?

Mainly the last.

Once you've spent a week telling your stupid SVG "this triangle
goes to (23.2, 5.7), and this other goes to (29.7, 6.2)" you want
to be able to be more abstract and say "triangle C goes smack in
the middle of A and B" and "circle X goes somewhere between Y and
Z, but choose a spot which looks nice".

You want programmability.

Look into TiKZ (whether you end up using it or not) for some
inspiration on what you might want a drawing program to do for
you.

Or Metapost: as an heir to Metafont, it probably has that declarative
touch to it.

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-01  8:22           ` tomas
  2020-09-01  8:38             ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-09-01 12:22             ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-09-01 14:58               ` tomas
  1 sibling, 1 reply; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-09-01 12:22 UTC (permalink / raw)
  To: help-gnu-emacs

tomas wrote:

>  (require 'svg)
>   (insert-image
>    (svg-image
>     (let ((svg (svg-create 100 100)))
>       (svg-circle svg 50 50 20 :stroke-width 6 :stroke 'blue :fill 'yellow)
>       svg)))

OK, I see the point, that makes sense and it seems
like a pleasant workbench.

Only, how do you get an image file?

Also, that evaluates to

  image-type: Invalid image type ‘svg’

That might be an emacs-nox thing, perhaps?

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-01 12:22             ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-09-01 14:58               ` tomas
  2020-09-01 20:45                 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-09-02 21:10                 ` Tomas Hlavaty
  0 siblings, 2 replies; 60+ messages in thread
From: tomas @ 2020-09-01 14:58 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 884 bytes --]

On Tue, Sep 01, 2020 at 02:22:32PM +0200, Emanuel Berg via Users list for the GNU Emacs text editor wrote:
> tomas wrote:
> 
> >  (require 'svg)
> >   (insert-image
> >    (svg-image
> >     (let ((svg (svg-create 100 100)))
> >       (svg-circle svg 50 50 20 :stroke-width 6 :stroke 'blue :fill 'yellow)
> >       svg)))
> 
> OK, I see the point, that makes sense and it seems
> like a pleasant workbench.
> 
> Only, how do you get an image file?
> 
> Also, that evaluates to
> 
>   image-type: Invalid image type ‘svg’
> 
> That might be an emacs-nox thing, perhaps?

Your Emacs has to be able to display svg images. Your easiest bet is
that you are just missing librsvg (package librsvg2-2 or thereabouts,
if you are on Debian) -- but of course, your Emacs has to be compiled
with SVG support built in (no idea whether emacs-nox does).

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-01  9:04               ` tomas
@ 2020-09-01 17:22                 ` Marcin Borkowski
  2020-09-01 20:48                   ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 60+ messages in thread
From: Marcin Borkowski @ 2020-09-01 17:22 UTC (permalink / raw)
  To: tomas; +Cc: help-gnu-emacs


On 2020-09-01, at 11:04, tomas@tuxteam.de wrote:

> You want programmability.
>
> Look into TiKZ (whether you end up using it or not) for some
> inspiration on what you might want a drawing program to do for
> you.
>
> Or Metapost: as an heir to Metafont, it probably has that declarative
> touch to it.

To expand a bit (as a TikZ user and a former METAPOST user):

METAPOST is older, has (I think) less add-ons than TikZ, but has a few
very distinctive features, most notably drawing "nice" Bezier curves
without specifying the control points, and a declarative engine for
solving systems of linear equations - a very nice thing to have when you
want to find intersections of lines.  (TikZ has the former if you use
LuaTeX and some package I don't remember the name of, and the latter
sort-of, i.e., much less general.)

METAPOST is rather sparsely documented (that said, I used it for
considerable time and was satisfied with it).

If you stick with METAPOST, consider looking at ConTeXt, which heavily
extends it with the so-called "METAFUN macros".

Most probably, you want TikZ.  Excellent software, excellent
documentation, numerous add-ons.  Nice things are:

- it has a _lot_ of ways to specify coordinates (2D, pseudo-3D, polar
coordinates and a lot more),

- there are a lot of ways to add various labels (called "nodes") to the
drawing.

Hth,

--
Marcin Borkowski
http://mbork.pl



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-01 14:58               ` tomas
@ 2020-09-01 20:45                 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-09-02 21:10                 ` Tomas Hlavaty
  1 sibling, 0 replies; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-09-01 20:45 UTC (permalink / raw)
  To: help-gnu-emacs

tomas wrote:

> Your Emacs has to be able to display svg images.
> Your easiest bet is that you are just missing
> librsvg (package librsvg2-2 or thereabouts, if you
> are on Debian

OK... 1s, no I have it

  i A librsvg2-2 - SAX-based renderer library for SVG f

Got into a discussion the other day, is Ubuntu
Debian? I think it is. What do you think?

Not that I don't use Debian :)

> ) -- but of course, your Emacs has to be compiled
> with SVG support built in (no idea whether
> emacs-nox does).

Me neither :)

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-01 17:22                 ` Marcin Borkowski
@ 2020-09-01 20:48                   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-09-02  8:25                     ` tomas
  0 siblings, 1 reply; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-09-01 20:48 UTC (permalink / raw)
  To: help-gnu-emacs

Marcin Borkowski wrote:

>> You want programmability. Look into TiKZ (whether
>> you end up using it or not) for some inspiration
>> on what you might want a drawing program to do for
>> you. Or Metapost: as an heir to Metafont, it
>> probably has that declarative touch to it.
>
> To expand a bit (as a TikZ user and a former
> METAPOST user):
>
> METAPOST is older, has (I think) less add-ons than
> TikZ, but has a few very distinctive features, most
> notably drawing "nice" Bezier curves without
> specifying the control points, and a declarative
> engine for solving systems of linear equations -
> a very nice thing to have when you want to find
> intersections of lines. (TikZ has the former if you
> use LuaTeX and some package I don't remember the
> name of, and the latter sort-of, i.e., much
> less general.)
>
> METAPOST is rather sparsely documented (that said,
> I used it for considerable time and was satisfied
> with it).
>
> If you stick with METAPOST, consider looking at
> ConTeXt, which heavily extends it with the
> so-called "METAFUN macros".
>
> Most probably, you want TikZ. Excellent software,
> excellent documentation, numerous add-ons.
> Nice things are:
>
> - it has a _lot_ of ways to specify coordinates
> (2D, pseudo-3D, polar coordinates and a lot more),
>
> - there are a lot of ways to add various labels
> (called "nodes") to the drawing.

WOW, good post.

I don't know anything about this! What is
this software?

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-01 20:48                   ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-09-02  8:25                     ` tomas
  0 siblings, 0 replies; 60+ messages in thread
From: tomas @ 2020-09-02  8:25 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 830 bytes --]

On Tue, Sep 01, 2020 at 10:48:01PM +0200, Emanuel Berg via Users list for the GNU Emacs text editor wrote:
> Marcin Borkowski wrote:

[...]

> WOW, good post.
> 
> I don't know anything about this! What is
> this software?

TiKZ is impressive. I found it a bit hard to wrap one's head
around it. It grew around the TeX and Metafont ideas. To get
a rough impression of what it's capable of, have a look at
their showcase

  https://texample.net/

their "resources" page

  https://texample.net/tikz/resources/

Their manual is recommended reading:

  http://paws.wcu.edu/tsfoguel/tikzpgfmanual.pdf

also available in the dead tree version.

For a quick-and-dirty technical dimensioned drawing, I still
think you're better off with OpenSCAD. But the journey is the
reward, as they say.

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-01 14:58               ` tomas
  2020-09-01 20:45                 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-09-02 21:10                 ` Tomas Hlavaty
  2020-09-02 21:51                   ` Emanuel Berg via Users list for the GNU Emacs text editor
                                     ` (2 more replies)
  1 sibling, 3 replies; 60+ messages in thread
From: Tomas Hlavaty @ 2020-09-02 21:10 UTC (permalink / raw)
  To: help-gnu-emacs

>> That might be an emacs-nox thing, perhaps?
>
> Your Emacs has to be able to display svg images.

It is a shame that image code in emacs is completely dependent on unsafe
foreign libraries and tightly coupled with graphics toolkits.

> Your easiest bet is that you are just missing librsvg (package
> librsvg2-2 or thereabouts, if you are on Debian) -- but of course,
> your Emacs has to be compiled with SVG support built in (no idea
> whether emacs-nox does).

Here is an alternative which works even on console without any graphics
toolkit compiled in:

(require 'xml)
(with-temp-buffer
  (xml-print
   '((svg
      ((xmlns . "http://www.w3.org/2000/svg")
       (viewBox . "0 0 100 100"))
      (circle
       ((cx . "50") (cy . "50") (r . "20"))))))
  (write-file "/tmp/a.svg"))

The /tmp/a.svg file will contain the SVG image.

Now the nice part of doing it in pure Elisp is that you can refactor the
code into useful functions as you need.  For example:

(defun svg (x y w h &rest body)
  `((svg
     ((xmlns . "http://www.w3.org/2000/svg")
      (viewBox . ,(format "%s %s %s %s" x y w h)))
     ,@body)))

(defun svg-circle (cx cy r)
  `(circle
    ((cx . ,(format "%s" cx)
     (cy . ,(format "%s" cy))
     (r . ,(format "%s" r))))))

(with-temp-buffer
  (xml-print
   (svg 0 0 100 100 (svg-circle 50 50 20)))
  (write-file "/tmp/a.svg"))

You can then display the generated image in the console using
https://logand.com/sw/emacs-framebuffer/file/emacs-framebuffer.el.html



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-02 21:10                 ` Tomas Hlavaty
@ 2020-09-02 21:51                   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-09-03  1:26                     ` Leo Butler
  2020-09-02 22:28                   ` Stefan Monnier
  2020-09-03  7:14                   ` tomas
  2 siblings, 1 reply; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-09-02 21:51 UTC (permalink / raw)
  To: help-gnu-emacs

Tomas Hlavaty wrote:

> Here is an alternative which works even on console without any graphics
> toolkit compiled in:
>
> (require 'xml)
> (with-temp-buffer
>   (xml-print
>    '((svg
>       ((xmlns . "http://www.w3.org/2000/svg")
>        (viewBox . "0 0 100 100"))
>       (circle
>        ((cx . "50") (cy . "50") (r . "20"))))))
>   (write-file "/tmp/a.svg"))
>
> The /tmp/a.svg file will contain the SVG image.
>
> Now the nice part of doing it in pure Elisp is that
> you can refactor the code into useful functions as
> you need. For example [...]

Indeed, that works great! Thanks a lot! Now I just
have to get the primitives from the W3C tutorial and
then implement neat little Elisp wrappers for all the
common stuff...

https://dataswamp.org/~incal/emacs-init/svg-my.el

> You can then display the generated image in the console using
> https://logand.com/sw/emacs-framebuffer/file/emacs-framebuffer.el.html

Really? :O

And... how do I get just the .el file?

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-02 21:10                 ` Tomas Hlavaty
  2020-09-02 21:51                   ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-09-02 22:28                   ` Stefan Monnier
  2020-09-03  5:13                     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-09-03  7:34                     ` Tomas Hlavaty
  2020-09-03  7:14                   ` tomas
  2 siblings, 2 replies; 60+ messages in thread
From: Stefan Monnier @ 2020-09-02 22:28 UTC (permalink / raw)
  To: help-gnu-emacs

> Now the nice part of doing it in pure Elisp is that you can refactor the
> code into useful functions as you need.  For example:

That's pretty much what the svg.el package mentioned earlier in the
thread does.  Instead of `svg-image`, use `svg-print`.


        Stefan




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-02 21:51                   ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-09-03  1:26                     ` Leo Butler
  0 siblings, 0 replies; 60+ messages in thread
From: Leo Butler @ 2020-09-03  1:26 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

> ********************************************************
> Caution: This message was sent from outside the University of Manitoba.
> ********************************************************
>
> Tomas Hlavaty wrote:
>
>> Here is an alternative which works even on console without any graphics
>> toolkit compiled in:
>>
>> (require 'xml)
>> (with-temp-buffer
>>   (xml-print
>>    '((svg
>>       ((xmlns . "http://www.w3.org/2000/svg")
>>        (viewBox . "0 0 100 100"))
>>       (circle
>>        ((cx . "50") (cy . "50") (r . "20"))))))
>>   (write-file "/tmp/a.svg"))
>>
>> The /tmp/a.svg file will contain the SVG image.
>>
>> Now the nice part of doing it in pure Elisp is that
>> you can refactor the code into useful functions as
>> you need. For example [...]
>
> Indeed, that works great! Thanks a lot! Now I just
> have to get the primitives from the W3C tutorial and
> then implement neat little Elisp wrappers for all the
> common stuff...
>
> https://dataswamp.org/~incal/emacs-init/svg-my.el
>
>> You can then display the generated image in the console using
>> https://logand.com/sw/emacs-framebuffer/file/emacs-framebuffer.el.html
>
> Really? :O
>
> And... how do I get just the .el file?

Line 9 of the file:

Download: git clone https://logand.com/git/emacs-framebuffer.git

Interesting thread.

Leo



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-02 22:28                   ` Stefan Monnier
@ 2020-09-03  5:13                     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-09-03  7:34                     ` Tomas Hlavaty
  1 sibling, 0 replies; 60+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-09-03  5:13 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier wrote:

>> Now the nice part of doing it in pure Elisp is
>> that you can refactor the code into useful
>> functions as you need. For example [...]
>
> That's pretty much what the svg.el package
> mentioned earlier in the thread does. Instead of
> `svg-image`, use `svg-print`.

Did anyone do neat Elisp wrappers around the
essentials as well?

Because if the programmability was one of the main
advantages with Emacs vs. plain SVG (and I agree)
then that sounds like a natural step :)

I'm not lazy, and happy to do it myself, but, if
someone else already did it, I might prefer to use
that for quality concerns :)

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-02 21:10                 ` Tomas Hlavaty
  2020-09-02 21:51                   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-09-02 22:28                   ` Stefan Monnier
@ 2020-09-03  7:14                   ` tomas
  2020-09-03  8:03                     ` Tomas Hlavaty
  2 siblings, 1 reply; 60+ messages in thread
From: tomas @ 2020-09-03  7:14 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1138 bytes --]

On Wed, Sep 02, 2020 at 11:10:29PM +0200, Tomas Hlavaty wrote:
> >> That might be an emacs-nox thing, perhaps?
> >
> > Your Emacs has to be able to display svg images.
> 
> It is a shame that image code in emacs is completely dependent on unsafe
> foreign libraries and tightly coupled with graphics toolkits.

I think there is a misunderstanding. All the functions in 'svg
basically do what you sketch in your mail (i.e. manipulate a dom
as an abstract data structure with an XML representation: so
basically generate and serialize XML) and don't rely on librsvg
et al. (I guess that is what you chastise as "unsafe foreign
library").

Librsvg is used to display the svg in-buffer, as libpng is used
to display PNGs in-buffer. Feel free to re-implement that in
Emacs Lisp ;-)

[...]

> You can then display the generated image in the console using
> https://logand.com/sw/emacs-framebuffer/file/emacs-framebuffer.el.html

That's interesting -- and this is the part librsvg is an alternative
for.

How does the emacs framebuffer work? Can it display images as
parts of a regular Emacs buffer?

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-02 22:28                   ` Stefan Monnier
  2020-09-03  5:13                     ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-09-03  7:34                     ` Tomas Hlavaty
  2020-09-03 13:38                       ` Stefan Monnier
       [not found]                       ` <mailman.2156.1599118473.2469.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 60+ messages in thread
From: Tomas Hlavaty @ 2020-09-03  7:34 UTC (permalink / raw)
  To: help-gnu-emacs

On Wed 02 Sep 2020 at 18:28, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> That's pretty much what the svg.el package mentioned earlier in the
> thread does.  Instead of `svg-image`, use `svg-print`.

Thanks for the info.

I see two problems with the svg.el package.

1) It is not clear upfront, when it does not work, as demonstrated with
   svg-image vs svg-print.

   This is general problem with foreign dependencies.

2) Elisp does not have keyword arguments.  However, svg.el works around
   that with rest arg plist.  This brings the worst of both worlds:
   complexity and useless tools.

   For example, I use eldoc.  Eldoc hint for svg-circle is useless:

      svg-circle: (SVG X Y RADIUS &rest ARGS)

   I have to dig into the source code to find out what ARGS is.  Every
   time I use svg-circle.

Writing own alternative to svg.el offers a chance to fix those problems.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-03  7:14                   ` tomas
@ 2020-09-03  8:03                     ` Tomas Hlavaty
  0 siblings, 0 replies; 60+ messages in thread
From: Tomas Hlavaty @ 2020-09-03  8:03 UTC (permalink / raw)
  To: help-gnu-emacs

On Thu 03 Sep 2020 at 09:14, <tomas@tuxteam.de> wrote:
> On Wed, Sep 02, 2020 at 11:10:29PM +0200, Tomas Hlavaty wrote:
>> >> That might be an emacs-nox thing, perhaps?
>> >
>> > Your Emacs has to be able to display svg images.
>> 
>> It is a shame that image code in emacs is completely dependent on unsafe
>> foreign libraries and tightly coupled with graphics toolkits.
>
> I think there is a misunderstanding. All the functions in 'svg
> basically do what you sketch in your mail (i.e. manipulate a dom
> as an abstract data structure with an XML representation: so
> basically generate and serialize XML) and don't rely on librsvg
> et al. (I guess that is what you chastise as "unsafe foreign
> library").

Not true.  For example svg-image does rely on librsvg.  There might be
other functions but I don't know that and there is no easy way to find
out except reading all that source code.

> How does the emacs framebuffer work? Can it display images as
> parts of a regular Emacs buffer?

Based on where the buffer is on the screen it calculates where to draw
the image on the Linux framebuffer.  Then it works like w3m web browser.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-03  7:34                     ` Tomas Hlavaty
@ 2020-09-03 13:38                       ` Stefan Monnier
  2020-09-03 15:21                         ` Tomas Hlavaty
       [not found]                       ` <mailman.2156.1599118473.2469.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 60+ messages in thread
From: Stefan Monnier @ 2020-09-03 13:38 UTC (permalink / raw)
  To: help-gnu-emacs

> 1) It is not clear upfront, when it does not work, as demonstrated with
>    svg-image vs svg-print.
>    This is general problem with foreign dependencies.

I believe svg-image is the only exception and it's an intuitive one at
that since it is used to create an internal Emacs image object whose
only use is to display the image inside an Emacs buffer.

> 2) Elisp does not have keyword arguments.  However, svg.el works around
>    that with rest arg plist.  This brings the worst of both worlds:
>    complexity and useless tools.
>
>    For example, I use eldoc.  Eldoc hint for svg-circle is useless:
>
>       svg-circle: (SVG X Y RADIUS &rest ARGS)
>
>    I have to dig into the source code to find out what ARGS is.  Every
>    time I use svg-circle.
>
> Writing own alternative to svg.el offers a chance to fix those problems.

Or maybe you can improve the package instead of writing a new one.
Code is sometimes called "software" because presumably it's more
malleable than "hardware".


        Stefan




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-03 13:38                       ` Stefan Monnier
@ 2020-09-03 15:21                         ` Tomas Hlavaty
  2020-09-03 16:59                           ` Stefan Monnier
  0 siblings, 1 reply; 60+ messages in thread
From: Tomas Hlavaty @ 2020-09-03 15:21 UTC (permalink / raw)
  To: help-gnu-emacs

On Thu 03 Sep 2020 at 09:38, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> 1) It is not clear upfront, when it does not work, as demonstrated with
>>    svg-image vs svg-print.
>>    This is general problem with foreign dependencies.
>
> I believe svg-image is the only exception and it's an intuitive one at
> that

Sorry it wasn't intuitive to me as I don't know emacs internals (yet?).

> since it is used to create an internal Emacs image object whose only
> use is to display the image inside an Emacs buffer.

There seem to be other uses as well, e.g. to save the image (image-save
function).  Maybe other uses like create a screenshot?

image.el also has some questionable constraints.  For example:

- Can an image have pages?
- What about tiff images?
- Why is pdf not an image?
- Can I implement new or redefine old image format in pure Elisp?  How?

Many modes depend on image.el which is hard to plug into when the
foreign libraries are not there.  That is why I have to reimplement more
than I like in emacs-framebuffer.el.  And probably the reason why there
are more than one pdf viewers.

>> 2) Elisp does not have keyword arguments.  However, svg.el works around
>>    that with rest arg plist.  This brings the worst of both worlds:
>>    complexity and useless tools.
>>
>>    For example, I use eldoc.  Eldoc hint for svg-circle is useless:
>>
>>       svg-circle: (SVG X Y RADIUS &rest ARGS)
>>
>>    I have to dig into the source code to find out what ARGS is.  Every
>>    time I use svg-circle.
>>
>> Writing own alternative to svg.el offers a chance to fix those problems.
>
> Or maybe you can improve the package instead of writing a new one.
> Code is sometimes called "software" because presumably it's more
> malleable than "hardware".

Maybe.  svg.el seems to be 4 years old and likely has many users
already.  The fake keyword args as rest args plist was a bad choice 4
years ago which will be hard to fix.  What would be the right way to do
this if not writing svg2.el?  Perhaps to implement proper keyword
support in Elisp?



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-03 15:21                         ` Tomas Hlavaty
@ 2020-09-03 16:59                           ` Stefan Monnier
       [not found]                             ` <87tuwen4mo.fsf@logand.com>
  0 siblings, 1 reply; 60+ messages in thread
From: Stefan Monnier @ 2020-09-03 16:59 UTC (permalink / raw)
  To: help-gnu-emacs

>>> 1) It is not clear upfront, when it does not work, as demonstrated with
>>>    svg-image vs svg-print.
>>>    This is general problem with foreign dependencies.
>> I believe svg-image is the only exception and it's an intuitive one at

It seems `svg-insert-image` is another exception.

> Sorry it wasn't intuitive to me as I don't know emacs internals (yet?).

;-)

>> since it is used to create an internal Emacs image object whose only
>> use is to display the image inside an Emacs buffer.
> There seem to be other uses as well, e.g. to save the image (image-save
> function).  Maybe other uses like create a screenshot?

That doesn't seem related to `svg.el` which focuses on generating the
XML representation of an SVG image (with one or two extra help functions
like `svg-image` which also tries to help *display* that image).
Searching for `save` only finds a single match (and it's for
`save-excursion` and it's not even in the code but in a comment).

> image.el also has some questionable constraints.

`svg.el` is unrelated to `image.el` (except via `svg-image`, AFAIK).

>> Or maybe you can improve the package instead of writing a new one.
>> Code is sometimes called "software" because presumably it's more
>> malleable than "hardware".
> Maybe.  svg.el seems to be 4 years old and likely has many users
> already.

Probably not "many", but then again, the more users it has, the higher
the benefit of improving it rather than writing another one.

> The fake keyword args as rest args plist was a bad choice 4
> years ago which will be hard to fix.  What would be the right way to do
> this if not writing svg2.el?  Perhaps to implement proper keyword
> support in Elisp?

The answer probably depends on exactly how else you want to handle
those properties.  I don't know what "proper keyword support" you're
thinking of, but if you're thinking of Common List keywords, then you
can simply change `defun` into `cl-defun` and then use `&key`.

BTW, if you're only concerned about the Eldoc and `C-h o` info, then you
can also just provide the more precise info in the docstring e.g.:

    (defun svg-create (width height &rest args)
      "Create a new, empty SVG image with dimensions WIDTH x HEIGHT.
    ARGS can be used to provide `stroke' and `stroke-width' parameters to
    any further elements added.

    \(fn WIDTH HEIGHT &key STROKE STROKE-WIDTH)"
      ...)


-- Stefan




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
       [not found]                       ` <mailman.2156.1599118473.2469.help-gnu-emacs@gnu.org>
@ 2020-09-03 17:23                         ` Lars Magne Ingebrigtsen
       [not found]                           ` <mailman.2212.1599153847.2469.help-gnu-emacs@gnu.org>
  0 siblings, 1 reply; 60+ messages in thread
From: Lars Magne Ingebrigtsen @ 2020-09-03 17:23 UTC (permalink / raw)
  To: Tomas Hlavaty; +Cc: help-gnu-emacs

Tomas Hlavaty <tom@logand.com> writes:

> 2) Elisp does not have keyword arguments.  However, svg.el works around
>    that with rest arg plist.  This brings the worst of both worlds:
>    complexity and useless tools.
>
>    For example, I use eldoc.  Eldoc hint for svg-circle is useless:
>
>       svg-circle: (SVG X Y RADIUS &rest ARGS)
>
>    I have to dig into the source code to find out what ARGS is.  Every
>    time I use svg-circle.

The arguments can be any attribute that's valid for an SVG element.  I'm
not sure how digging into the source code helps you with determining
that -- you'd need to look at the SVG standards document to find out
what keywords/values are valid.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
       [not found]                           ` <mailman.2212.1599153847.2469.help-gnu-emacs@gnu.org>
@ 2020-09-03 17:28                             ` Lars Magne Ingebrigtsen
  2020-09-03 17:41                               ` Stefan Monnier
  2020-09-03 17:55                               ` Tomas Hlavaty
  0 siblings, 2 replies; 60+ messages in thread
From: Lars Magne Ingebrigtsen @ 2020-09-03 17:28 UTC (permalink / raw)
  To: Tomas Hlavaty; +Cc: help-gnu-emacs

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> The arguments can be any attribute that's valid for an SVG element.  I'm
> not sure how digging into the source code helps you with determining
> that -- you'd need to look at the SVG standards document to find out
> what keywords/values are valid.

(That said, changing the signature on all these functions to

  (cl-defun svg-... (... &key stroke-width stroke-color fill-color ... &allow-other-keys)
  
would be fine by me, and should be backwards-compatible.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-03 17:28                             ` Lars Magne Ingebrigtsen
@ 2020-09-03 17:41                               ` Stefan Monnier
       [not found]                                 ` <mailman.2217.1599154928.2469.help-gnu-emacs@gnu.org>
  2020-09-03 17:55                               ` Tomas Hlavaty
  1 sibling, 1 reply; 60+ messages in thread
From: Stefan Monnier @ 2020-09-03 17:41 UTC (permalink / raw)
  To: help-gnu-emacs

>> The arguments can be any attribute that's valid for an SVG element.  I'm
>> not sure how digging into the source code helps you with determining
>> that -- you'd need to look at the SVG standards document to find out
>> what keywords/values are valid.
>
> (That said, changing the signature on all these functions to
>
>   (cl-defun svg-... (... &key stroke-width stroke-color fill-color ... &allow-other-keys)
>   
> would be fine by me, and should be backwards-compatible.)

IIRC it would make the code slower, tho.  It adds code like

    (let ((stroke-color (cadr (plist-member args :stroke-color))))

which the compiler fails to optimize away when `stroke-color` is not used.


        Stefan




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
       [not found]                                 ` <mailman.2217.1599154928.2469.help-gnu-emacs@gnu.org>
@ 2020-09-03 17:45                                   ` Lars Magne Ingebrigtsen
  2020-09-03 18:23                                     ` Tomas Hlavaty
  0 siblings, 1 reply; 60+ messages in thread
From: Lars Magne Ingebrigtsen @ 2020-09-03 17:45 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> IIRC it would make the code slower, tho.  It adds code like
>
>     (let ((stroke-color (cadr (plist-member args :stroke-color))))
>
> which the compiler fails to optimize away when `stroke-color` is not used.

I didn't know that...  but on the other hand, all these functions end up
calling this internal function:

(defun svg--arguments (svg args)
  (let ((stroke-width (or (plist-get args :stroke-width)
			  (dom-attr svg 'stroke-width)))
	(stroke-color (or (plist-get args :stroke-color)
                          (dom-attr svg 'stroke-color)))
        (fill-color (plist-get args :fill-color))
	attr)

Which could then lose these plist-gets, so we'd end up with
approximately the same slowness, I think.  :-)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-03 17:28                             ` Lars Magne Ingebrigtsen
  2020-09-03 17:41                               ` Stefan Monnier
@ 2020-09-03 17:55                               ` Tomas Hlavaty
       [not found]                                 ` <mailman.2221.1599155709.2469.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 60+ messages in thread
From: Tomas Hlavaty @ 2020-09-03 17:55 UTC (permalink / raw)
  To: help-gnu-emacs

On Thu 03 Sep 2020 at 19:28, Lars Magne Ingebrigtsen <larsi@gnus.org> wrote:
> Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>> The arguments can be any attribute that's valid for an SVG element.  I'm
>> not sure how digging into the source code helps you with determining
>> that -- you'd need to look at the SVG standards document to find out
>> what keywords/values are valid.

At the moment, args is passed to svg--arguments.

But the point is that eldoc should be useful so that nobody needs to
look anywhere else.

> (That said, changing the signature on all these functions to
>
>   (cl-defun svg-... (... &key stroke-width stroke-color fill-color ... &allow-other-keys)
>   
> would be fine by me, and should be backwards-compatible.)

Why &allow-other-keys?  How would you pass the other keys to
svg-arguments?



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
       [not found]                                 ` <mailman.2221.1599155709.2469.help-gnu-emacs@gnu.org>
@ 2020-09-03 18:04                                   ` Lars Magne Ingebrigtsen
       [not found]                                     ` <mailman.2222.1599156265.2469.help-gnu-emacs@gnu.org>
  0 siblings, 1 reply; 60+ messages in thread
From: Lars Magne Ingebrigtsen @ 2020-09-03 18:04 UTC (permalink / raw)
  To: Tomas Hlavaty; +Cc: help-gnu-emacs

Tomas Hlavaty <tom@logand.com> writes:

> Why &allow-other-keys?

Because you can pass any SVG attributes you want and have them end up in
the resulting SVG document.

> How would you pass the other keys to svg-arguments?

Same as now.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
       [not found]                                     ` <mailman.2222.1599156265.2469.help-gnu-emacs@gnu.org>
@ 2020-09-03 18:09                                       ` Lars Magne Ingebrigtsen
  2020-09-03 18:29                                         ` Tomas Hlavaty
  0 siblings, 1 reply; 60+ messages in thread
From: Lars Magne Ingebrigtsen @ 2020-09-03 18:09 UTC (permalink / raw)
  To: Tomas Hlavaty; +Cc: help-gnu-emacs

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

>> How would you pass the other keys to svg-arguments?
>
> Same as now.

Sorry; forgot the &rest you also then need to actually get at the
unspecified keywords.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-03 17:45                                   ` Lars Magne Ingebrigtsen
@ 2020-09-03 18:23                                     ` Tomas Hlavaty
       [not found]                                       ` <mailman.2224.1599157422.2469.help-gnu-emacs@gnu.org>
  0 siblings, 1 reply; 60+ messages in thread
From: Tomas Hlavaty @ 2020-09-03 18:23 UTC (permalink / raw)
  To: help-gnu-emacs

On Thu 03 Sep 2020 at 19:45, Lars Magne Ingebrigtsen <larsi@gnus.org> wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
>> IIRC it would make the code slower, tho.  It adds code like
>>
>>     (let ((stroke-color (cadr (plist-member args :stroke-color))))
>>
>> which the compiler fails to optimize away when `stroke-color` is not used.
>
> I didn't know that...  but on the other hand, all these functions end up
> calling this internal function:
>
> (defun svg--arguments (svg args)
>   (let ((stroke-width (or (plist-get args :stroke-width)
> 			  (dom-attr svg 'stroke-width)))
> 	(stroke-color (or (plist-get args :stroke-color)
>                           (dom-attr svg 'stroke-color)))
>         (fill-color (plist-get args :fill-color))
> 	attr)
>
> Which could then lose these plist-gets, so we'd end up with
> approximately the same slowness, I think.  :-)

&allow-other-keys does not make sense for functions.

svg--arguments is called in 9 places.  Should it be possible to identify
all relevant keys for each use-case or is that not reasonable for svg?



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-03 18:09                                       ` Lars Magne Ingebrigtsen
@ 2020-09-03 18:29                                         ` Tomas Hlavaty
  2020-09-03 18:32                                           ` Tomas Hlavaty
  0 siblings, 1 reply; 60+ messages in thread
From: Tomas Hlavaty @ 2020-09-03 18:29 UTC (permalink / raw)
  To: help-gnu-emacs

On Thu 03 Sep 2020 at 20:09, Lars Magne Ingebrigtsen <larsi@gnus.org> wrote:
> Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>
>>> How would you pass the other keys to svg-arguments?
>>
>> Same as now.
>
> Sorry; forgot the &rest you also then need to actually get at the
> unspecified keywords.

Exactly.  Your suggestion:

   (cl-defun svg-... (... &key stroke-width stroke-color fill-color
            ... &allow-other-keys)

did not make any sense.

- &allow-other-keys does not make any sense for functions

- &rest args &key a b is broken in eldoc



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-03 18:29                                         ` Tomas Hlavaty
@ 2020-09-03 18:32                                           ` Tomas Hlavaty
  0 siblings, 0 replies; 60+ messages in thread
From: Tomas Hlavaty @ 2020-09-03 18:32 UTC (permalink / raw)
  To: help-gnu-emacs

On Thu 03 Sep 2020 at 20:29, Tomas Hlavaty <tom@logand.com> wrote:
> On Thu 03 Sep 2020 at 20:09, Lars Magne Ingebrigtsen <larsi@gnus.org> wrote:
>    (cl-defun svg-... (... &key stroke-width stroke-color fill-color
>             ... &allow-other-keys)
>
> did not make any sense.
>
> - &allow-other-keys does not make any sense for functions

for functions without &rest &key



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
       [not found]                                       ` <mailman.2224.1599157422.2469.help-gnu-emacs@gnu.org>
@ 2020-09-03 19:43                                         ` Lars Magne Ingebrigtsen
  2020-09-03 19:50                                           ` Tomas Hlavaty
  0 siblings, 1 reply; 60+ messages in thread
From: Lars Magne Ingebrigtsen @ 2020-09-03 19:43 UTC (permalink / raw)
  To: Tomas Hlavaty; +Cc: help-gnu-emacs

Tomas Hlavaty <tom@logand.com> writes:

> svg--arguments is called in 9 places.  Should it be possible to identify
> all relevant keys for each use-case or is that not reasonable for svg?

It's not reasonable.  Different SVG renderers accept different
parameters, etc.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-03 19:43                                         ` Lars Magne Ingebrigtsen
@ 2020-09-03 19:50                                           ` Tomas Hlavaty
  2020-09-04  8:43                                             ` tomas
  0 siblings, 1 reply; 60+ messages in thread
From: Tomas Hlavaty @ 2020-09-03 19:50 UTC (permalink / raw)
  To: help-gnu-emacs

On Thu 03 Sep 2020 at 21:43, Lars Magne Ingebrigtsen <larsi@gnus.org> wrote:
> Tomas Hlavaty <tom@logand.com> writes:
>
>> svg--arguments is called in 9 places.  Should it be possible to identify
>> all relevant keys for each use-case or is that not reasonable for svg?
>
> It's not reasonable.  Different SVG renderers accept different
> parameters, etc.

interesting

why does it depend on the renderer and not on svg spec?  sounds strange.
do you have an example?

i can imagine a case where svg is inside html and maybe it could have
arbitrary attributes, e.g. data-myattr1



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
       [not found]                               ` <jwvimcuiqur.fsf-monnier+emacs@gnu.org>
@ 2020-09-04  8:42                                 ` Tomas Hlavaty
  0 siblings, 0 replies; 60+ messages in thread
From: Tomas Hlavaty @ 2020-09-04  8:42 UTC (permalink / raw)
  To: help-gnu-emacs

thanks, bug reported

On Thu 03 Sep 2020 at 15:52, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> (cl-defun foo (a &rest args &key b c)
>>   (cons a args))
>>
>> (foo 1 :b 2 :c 3)
>>
>> This works.
>>
>> But positioning cursor somewhere on :b 2 highlights args instead of b.
>> Strangely enough, positioning it on :c 3 highlights c correctly.
>
> Probably a happy accident.
>
>> If this worked it would be enough to use cl-defun and add key list
>> without having to change anything else.
>
> Indeed, that's a bug (or lack of feature).
> `M-x report-emacs-bug` seems to be in order.
>
>>> BTW, if you're only concerned about the Eldoc and `C-h o` info, then you
>>> can also just provide the more precise info in the docstring e.g.:
>>>
>>>     (defun svg-create (width height &rest args)
>>>       "Create a new, empty SVG image with dimensions WIDTH x HEIGHT.
>>>     ARGS can be used to provide `stroke' and `stroke-width' parameters to
>>>     any further elements added.
>>>
>>>     \(fn WIDTH HEIGHT &key STROKE STROKE-WIDTH)"
>>>       ...)
>>
>> I don't understand.  Should \(fn WIDTH HEIGHT &key STROKE STROKE-WIDTH)
>> in docstring magically make eldoc to work?  It does not work for me.
>
> It makes eldoc work the same way as `cl-defun` does (it's actually the
> mechanism used internally by eldoc to preserve the &key arguments into
> the `C-h o` and the eldoc output), but without having to change the
> actual code.
>
>
>         Stefan



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-03 19:50                                           ` Tomas Hlavaty
@ 2020-09-04  8:43                                             ` tomas
  2020-09-04  8:59                                               ` Tomas Hlavaty
  0 siblings, 1 reply; 60+ messages in thread
From: tomas @ 2020-09-04  8:43 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1864 bytes --]

On Thu, Sep 03, 2020 at 09:50:38PM +0200, Tomas Hlavaty wrote:
> On Thu 03 Sep 2020 at 21:43, Lars Magne Ingebrigtsen <larsi@gnus.org> wrote:
> > Tomas Hlavaty <tom@logand.com> writes:
> >
> >> svg--arguments is called in 9 places.  Should it be possible to identify
> >> all relevant keys for each use-case or is that not reasonable for svg?
> >
> > It's not reasonable.  Different SVG renderers accept different
> > parameters, etc.
> 
> interesting
> 
> why does it depend on the renderer and not on svg spec?  sounds strange.
> do you have an example?

Go through the W3C specs [1] with a critical eye and you'll see lots
of those little things. After all, W3C is a consortium with very big
players in it (it wouldn't work if it weren't) -- and each of them
follows their own interest. Thus, W3C recommendations resemble a bit
those international treaties where each party has some leeway of
interpretation [2].

And then implementors do what they want anyway; users will come to
us whining that "chrome does this-and-this", we'll tell them "chrome
is wrong", they'll call us "arrogant twits" ;-)

> i can imagine a case where svg is inside html and maybe it could have
> arbitrary attributes, e.g. data-myattr1

In theory, that's what namespaces are for. In practice, though...

Nevertheless, independently of how you embed the thing syntactically
(SVG even allows extending the DTD!) users will throw chairs at you
whenever it looks differently than in Chrome/Firefox/Internet Exploder
Version 0.95 or something. Be sure to duck quickly :-)

Cheers

[1] https://www.w3.org/TR/SVG11/
[2] Similar structures lead to similar "laws". To me, this is an
   obvious extension of Conway's Law [3]: laws/tech specs are just
   some weird kind of software, after all.
[3] https://en.wikipedia.org/wiki/Conway%27s_law

 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-04  8:43                                             ` tomas
@ 2020-09-04  8:59                                               ` Tomas Hlavaty
  2020-09-04  9:26                                                 ` tomas
  0 siblings, 1 reply; 60+ messages in thread
From: Tomas Hlavaty @ 2020-09-04  8:59 UTC (permalink / raw)
  To: help-gnu-emacs

thanks for the interesting info

On Fri 04 Sep 2020 at 10:43, <tomas@tuxteam.de> wrote:
>> i can imagine a case where svg is inside html and maybe it could have
>> arbitrary attributes, e.g. data-myattr1
>
> In theory, that's what namespaces are for. In practice, though...

html does not have namespaces

but you are right, if treated as xml, args could contain attributes from
other namespaces.  i forgot about that

> Nevertheless, independently of how you embed the thing syntactically
> (SVG even allows extending the DTD!) users will throw chairs at you
> whenever it looks differently than in Chrome/Firefox/Internet Exploder
> Version 0.95 or something. Be sure to duck quickly :-)

extending dtd?  interesting



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-04  8:59                                               ` Tomas Hlavaty
@ 2020-09-04  9:26                                                 ` tomas
  2020-09-04  9:48                                                   ` Tomas Hlavaty
  0 siblings, 1 reply; 60+ messages in thread
From: tomas @ 2020-09-04  9:26 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1783 bytes --]

On Fri, Sep 04, 2020 at 10:59:05AM +0200, Tomas Hlavaty wrote:
> thanks for the interesting info
> 
> On Fri 04 Sep 2020 at 10:43, <tomas@tuxteam.de> wrote:
> >> i can imagine a case where svg is inside html and maybe it could have
> >> arbitrary attributes, e.g. data-myattr1
> >
> > In theory, that's what namespaces are for. In practice, though...
> 
> html does not have namespaces

No, but SVG is XML, and thus it has. You can embed hyperlinks in SVG by
using the xlink namespace -- firefox even honours that. And you embed
SVG in html5, which isn't XML (we nearly had that, btw). That's the result
of that consortium thing: they prefer to continue their "fuzzy parser
wars". Gotta live with that.

> but you are right, if treated as xml, args could contain attributes from
> other namespaces.  i forgot about that

Yep. SVG /is/ XML, for better or worse :-)

> > Nevertheless, independently of how you embed the thing syntactically
> > (SVG even allows extending the DTD!) users will throw chairs at you
> > whenever it looks differently than in Chrome/Firefox/Internet Exploder
> > Version 0.95 or something. Be sure to duck quickly :-)
> 
> extending dtd?  interesting

Yep [1]. "Interesting" is a polite way to put it. My take would rather
be "@%#$&*!", but then, I was born in Spain, and some of us are said
to have bad language ;-)

My point is that those "norms" are built to leave bigcorps enough
wiggle room to try to dominate the market by bending them. Otherwise
the "norms" wouldn't be relevant in the first place.

OTOH, no norms would be even worse. But one shouldn't be too naive
to believe what's on the box. Just look inside :-)

Cheers

[1] https://www.w3.org/TR/SVG11/extend.html#PrivateElementsAndAttribute

 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-04  9:26                                                 ` tomas
@ 2020-09-04  9:48                                                   ` Tomas Hlavaty
  0 siblings, 0 replies; 60+ messages in thread
From: Tomas Hlavaty @ 2020-09-04  9:48 UTC (permalink / raw)
  To: help-gnu-emacs

On Fri 04 Sep 2020 at 11:26, <tomas@tuxteam.de> wrote:
>> > Nevertheless, independently of how you embed the thing syntactically
>> > (SVG even allows extending the DTD!) users will throw chairs at you
>> > whenever it looks differently than in Chrome/Firefox/Internet Exploder
>> > Version 0.95 or something. Be sure to duck quickly :-)
>> 
>> extending dtd?  interesting
>
> Yep [1]. "Interesting" is a polite way to put it. My take would rather
> be "@%#$&*!", but then, I was born in Spain, and some of us are said
> to have bad language ;-)
>
> My point is that those "norms" are built to leave bigcorps enough
> wiggle room to try to dominate the market by bending them. Otherwise
> the "norms" wouldn't be relevant in the first place.
>
> OTOH, no norms would be even worse. But one shouldn't be too naive
> to believe what's on the box. Just look inside :-)
>
> Cheers
>
> [1] https://www.w3.org/TR/SVG11/extend.html#PrivateElementsAndAttribute

I see what you mean by extending dtd.

I am not sure I would describe it that way.  SVG is limited in
fundamental ways and foreignObject allows to escape that limitation.  I
have used that in html with embeded svg to get into html again.  It is
not perfect but better than not having that ability at all.  VML was
much better in that regard.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-01  8:18         ` tomas
@ 2020-09-24 15:09           ` Jean Louis
  2020-09-24 16:53             ` Leo Butler
  2020-09-24 20:14             ` tomas
  0 siblings, 2 replies; 60+ messages in thread
From: Jean Louis @ 2020-09-24 15:09 UTC (permalink / raw)
  To: tomas; +Cc: help-gnu-emacs

* tomas@tuxteam.de <tomas@tuxteam.de> [2020-09-01 11:19]:
> On Mon, Aug 31, 2020 at 10:52:59PM +0200, Emanuel Berg via Users list for the GNU Emacs text editor wrote:
> > Yuri Khan wrote:
> > 
> > >>> If you are thinking 3D, then OpenSCAD might suit
> > >>> you: pametric, script-centric, text-friendly.
> > >>
> > >> No no, 2D, top-view! Like an old school
> > >> engineering drawing, but less detailed. But with
> > >> real units...
> > >
> > > You want 2D, get LibreCAD.
> > 
> > I want to write code (data) and then have it
> > translate into a drawing. See the original post.
> > So no GUI, no actual "drawing". CAD doesn't sound
> > like that, but maybe I'm wrong?
> 
> TiKZ and OpenSCAD qualify, but they cover different areas (the one
> is for (gorgeous!) diagranms and the other is for (dimensional)
> drawings.

Maybe you wish to say 3D dimensional, as if you only mean dimensional,
then anything in this world including any types of graphs are
dimensional.

So if you do mean that OpenSCAD is 3D dimensional, well, it has that
capacity, but nothing prevents you being 2D dimensional.

See here for exporting files:
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/STL_Import_and_Export

For references of the simple drawing language, see here:
http://www.openscad.org/documentation.html?version=2015.03

I am using Emacs to simply write the drawing, then such can easily be
exported. It is possible to configure Emacs, if necessary, to open the
exported file and display it after saving such. So the OpenSCAD window
need not be seen at all.

Just use the automatic preview option in OpenSCAD, edit the file and
OpenSCAD will show the drawing after each saving of the file.

You do not need to launch the OpenSCAD for quick previews, you could
launch it from command line, upon the emacs save hook so that file is
each time generated as you wish.

Try following, adapt the font name.

module logo(logo,size) {
     rotate([90]) {
	  color("gold") text(logo, font = "Impact", size = size, haling = "center", valign = "bottomline");
     }
}

logo("Emacs");


Jean




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-24 15:09           ` Jean Louis
@ 2020-09-24 16:53             ` Leo Butler
  2020-09-24 20:14             ` tomas
  1 sibling, 0 replies; 60+ messages in thread
From: Leo Butler @ 2020-09-24 16:53 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis <bugs@gnu.support> writes:

> ********************************************************
> Caution: This message was sent from outside the University of Manitoba.
> ********************************************************
>
> * tomas@tuxteam.de <tomas@tuxteam.de> [2020-09-01 11:19]:
>> On Mon, Aug 31, 2020 at 10:52:59PM +0200, Emanuel Berg via Users list for the GNU Emacs text editor wrote:
>> > Yuri Khan wrote:
>> > 
>> > >>> If you are thinking 3D, then OpenSCAD might suit
>> > >>> you: pametric, script-centric, text-friendly.
>> > >>
>> > >> No no, 2D, top-view! Like an old school
>> > >> engineering drawing, but less detailed. But with
>> > >> real units...
>> > >
>> > > You want 2D, get LibreCAD.
>> > 
>> > I want to write code (data) and then have it
>> > translate into a drawing. See the original post.
>> > So no GUI, no actual "drawing". CAD doesn't sound
>> > like that, but maybe I'm wrong?
>> 
>> TiKZ and OpenSCAD qualify, but they cover different areas (the one
>> is for (gorgeous!) diagranms and the other is for (dimensional)
>> drawings.
>
> Maybe you wish to say 3D dimensional, as if you only mean dimensional,
> then anything in this world including any types of graphs are
> dimensional.
>
> So if you do mean that OpenSCAD is 3D dimensional, well, it has that
> capacity, but nothing prevents you being 2D dimensional.
>
> See here for exporting files:
> https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/STL_Import_and_Export
>
> For references of the simple drawing language, see here:
> http://www.openscad.org/documentation.html?version=2015.03
>
> I am using Emacs to simply write the drawing, then such can easily be
> exported. It is possible to configure Emacs, if necessary, to open the
> exported file and display it after saving such. So the OpenSCAD window
> need not be seen at all.
>
> Just use the automatic preview option in OpenSCAD, edit the file and
> OpenSCAD will show the drawing after each saving of the file.
>
> You do not need to launch the OpenSCAD for quick previews, you could
> launch it from command line, upon the emacs save hook so that file is
> each time generated as you wish.
>
> Try following, adapt the font name.
>
> module logo(logo,size) {
>      rotate([90]) {
> 	  color("gold") text(logo, font = "Impact", size = size, haling = "center", valign = "bottomline");
>      }
> }
>
> logo("Emacs");
>
>
> Jean

Thanks for the reference. I was unaware of OpenSCAD, but after looking
at the references, it looks quite interesting.

Leo



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: make a drawing with Emacs
  2020-09-24 15:09           ` Jean Louis
  2020-09-24 16:53             ` Leo Butler
@ 2020-09-24 20:14             ` tomas
  1 sibling, 0 replies; 60+ messages in thread
From: tomas @ 2020-09-24 20:14 UTC (permalink / raw)
  To: Jean Louis; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1390 bytes --]

On Thu, Sep 24, 2020 at 06:09:23PM +0300, Jean Louis wrote:
> * tomas@tuxteam.de <tomas@tuxteam.de> [2020-09-01 11:19]:
> > On Mon, Aug 31, 2020 at 10:52:59PM +0200, Emanuel Berg via Users list for the GNU Emacs text editor wrote:
> > > Yuri Khan wrote:
> > > 
> > > >>> If you are thinking 3D, then OpenSCAD might suit
> > > >>> you: pametric, script-centric, text-friendly.
> > > >>
> > > >> No no, 2D, top-view! Like an old school
> > > >> engineering drawing, but less detailed. But with
> > > >> real units...
> > > >
> > > > You want 2D, get LibreCAD.
> > > 
> > > I want to write code (data) and then have it
> > > translate into a drawing. See the original post.
> > > So no GUI, no actual "drawing". CAD doesn't sound
> > > like that, but maybe I'm wrong?
> > 
> > TiKZ and OpenSCAD qualify, but they cover different areas (the one
> > is for (gorgeous!) diagranms and the other is for (dimensional)
> > drawings.
> 
> Maybe you wish to say 3D dimensional, as if you only mean dimensional,
> then anything in this world including any types of graphs are
> dimensional.

Sorry, I was unclear: It didn't mean the 3D capability of OpenScad
(which is there) but the possibility of adding measures to the
features (perhaps "dimensioned drawing" is more accurate).

And yes, OpenScad's "internal" format is also text, thus Emacs-friendly.

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 60+ messages in thread

end of thread, other threads:[~2020-09-24 20:14 UTC | newest]

Thread overview: 60+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-31  3:05 make a drawing with Emacs Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-31  7:36 ` tomas
2020-08-31 20:29   ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-31 20:49     ` Yuri Khan
2020-08-31 20:52       ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-31 21:01         ` Yuri Khan
2020-08-31 21:04           ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-31 22:48             ` Perry Smith
2020-08-31 23:09               ` Ulrich Deiters
2020-09-01  8:22           ` tomas
2020-09-01  8:38             ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-09-01  9:04               ` tomas
2020-09-01 17:22                 ` Marcin Borkowski
2020-09-01 20:48                   ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-09-02  8:25                     ` tomas
2020-09-01 12:22             ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-09-01 14:58               ` tomas
2020-09-01 20:45                 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-09-02 21:10                 ` Tomas Hlavaty
2020-09-02 21:51                   ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-09-03  1:26                     ` Leo Butler
2020-09-02 22:28                   ` Stefan Monnier
2020-09-03  5:13                     ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-09-03  7:34                     ` Tomas Hlavaty
2020-09-03 13:38                       ` Stefan Monnier
2020-09-03 15:21                         ` Tomas Hlavaty
2020-09-03 16:59                           ` Stefan Monnier
     [not found]                             ` <87tuwen4mo.fsf@logand.com>
     [not found]                               ` <jwvimcuiqur.fsf-monnier+emacs@gnu.org>
2020-09-04  8:42                                 ` Tomas Hlavaty
     [not found]                       ` <mailman.2156.1599118473.2469.help-gnu-emacs@gnu.org>
2020-09-03 17:23                         ` Lars Magne Ingebrigtsen
     [not found]                           ` <mailman.2212.1599153847.2469.help-gnu-emacs@gnu.org>
2020-09-03 17:28                             ` Lars Magne Ingebrigtsen
2020-09-03 17:41                               ` Stefan Monnier
     [not found]                                 ` <mailman.2217.1599154928.2469.help-gnu-emacs@gnu.org>
2020-09-03 17:45                                   ` Lars Magne Ingebrigtsen
2020-09-03 18:23                                     ` Tomas Hlavaty
     [not found]                                       ` <mailman.2224.1599157422.2469.help-gnu-emacs@gnu.org>
2020-09-03 19:43                                         ` Lars Magne Ingebrigtsen
2020-09-03 19:50                                           ` Tomas Hlavaty
2020-09-04  8:43                                             ` tomas
2020-09-04  8:59                                               ` Tomas Hlavaty
2020-09-04  9:26                                                 ` tomas
2020-09-04  9:48                                                   ` Tomas Hlavaty
2020-09-03 17:55                               ` Tomas Hlavaty
     [not found]                                 ` <mailman.2221.1599155709.2469.help-gnu-emacs@gnu.org>
2020-09-03 18:04                                   ` Lars Magne Ingebrigtsen
     [not found]                                     ` <mailman.2222.1599156265.2469.help-gnu-emacs@gnu.org>
2020-09-03 18:09                                       ` Lars Magne Ingebrigtsen
2020-09-03 18:29                                         ` Tomas Hlavaty
2020-09-03 18:32                                           ` Tomas Hlavaty
2020-09-03  7:14                   ` tomas
2020-09-03  8:03                     ` Tomas Hlavaty
2020-09-01  8:32           ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-09-01  8:58             ` tomas
2020-09-01  8:18         ` tomas
2020-09-24 15:09           ` Jean Louis
2020-09-24 16:53             ` Leo Butler
2020-09-24 20:14             ` tomas
2020-08-31 17:41 ` Marcin Borkowski
2020-08-31 20:30   ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-31 19:40 ` Carlo Tambuatco
2020-08-31 20:33   ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-31 20:56 ` Gregory Heytings via Users list for the GNU Emacs text editor
2020-08-31 21:00   ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-09-01  8:40     ` Gregory Heytings via Users list for the GNU Emacs text editor
2020-09-01  5:37   ` Peter Münster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).