Mail Archives: geda-user/2013/08/16/14:50:38
--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Nathan Stewart <therealnathanstewart AT gmail DOT com> writes:
> In your June 30,2011=C2=A0 blog post you mention:
> "It's not currently feasible to create a meaningful new action in
> gschem without writing it mostly in C. "
>
> Unfortunately, gschem development folks aren't real open to outside
> input. (Which explains the xfigian feel I guess)=C2=A0 I'm trying to figu=
re
> out how to add my own new custom action to a component, based on
> attributes, with the presupposition in mind that this will never be
> accepted into core.
Hi Nathan,
Fortunately my old blog post is no longer up-to-date! It is now much
easier to create a meaningful new action.
In the most recent versions of gschem, you can use the new Scheme API to
access quite a lot of the design data (see the `geda-scheme' info
manual or http://geda.peter-b.co.uk/geda-scheme/1.8.1/).
To add a new action, there are a few steps.
1) Write a Scheme file which defines a function with a unique name and
no arguments. For example:
(define (my-action)
...)
2) Load the Scheme file (let's say it's called my-action.scm) from your
gschem startup file. You have two options:
a. Put the Scheme file in one of the directories on your gEDA Scheme
load path. You can get a list of these directories by running:
gaf shell -c '(display %load-path)'
Then add this line to any of your gschemrc files:
(load-from-path "my-action.scm")
b. Put the Scheme file in the same directory as a project-specific
gschemrc file. Then add this line to the project's gschemrc file:
(load "my-action.scm")
3) Next you need to be able to run your action. The simplest way is to
use the command prompt: simply type ":" to show the prompt, and then:
(my-action) <Enter>
to execute it. At the moment, adding things to menus is tricky; you
can edit the menus in the system-gschemrc but not elsewhere. If you
want to try this, search system-gschemrc for "menu-items". However,
it's *much* easier to add a keybinding. For example, to make your
action run whenever you pless "!", add this to any gschemrc file:
(global-set-key "exclam" 'my-action)
I hope this gives you some pointers.
Thanks,
Peter
> What I have in mind is that a Spice-Include component could contain
> both a file and either a source attribute, or alternative use the
> current page. I'd like to add an action to run the netlister on the
> schematic, then run spice on the netlist. I'm new to scheme, but the
> part that puzzles me is adding a new action.=20
>
> It doesn't look like it's currently possible to add anything to
> popup_items in x_menus.c, which is where I think such a new action
> should probably go. Is there another route to add=C2=A0 brand new actions?
> Nathan
=2D-=20
Dr Peter Brett <peter AT peter-b DOT co DOT uk>
--=-=-=
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (GNU/Linux)
iEYEARECAAYFAlIOdGMACgkQZ7Gbq7g7vpooSwCdHS/+6npKOFgo/8GuyOHdD0rT
Z8AAnidC47csBTbyokQzaHCQD4OvlQV2
=6MwZ
-----END PGP SIGNATURE-----
--=-=-=--
- Raw text -