On Wed, 2011-03-30 at 10:37 +0200, John Erlandsson wrote: > > (define (test2) > (display "work dammit!") > (newline) > ) If you type ":" to get a scheme prompt, then enter: (display "work dammit!") in gschem, it does indeed print to the console. I wonder if your function was not in scope when you called (test2) I managed to make it work by putting your definition of test2 in my ~/.gEDA/gschemrc file, and then executing (test2) from the guile command prompt in gschem. BTW.. I hope you won't be too upset if in some couple of gEDA versions time we have to change the syntax for placing executable code in various config files. It may mean separating executable bits into a different file explicitly, then referring to them from the (non-executable) config files. The reason is that we expect things like gafrc and gedarc to be sent along with projects, and the fact they support executable code inside them opens the same (if not greater) scope, for malicious code to be hidden inside, similar to macro-viruses to be hidden in gEDA projects which get passed around. Whilst I don't think it is particularly likely that anyone in the community will attempt to do this with the intent to attack any other community member, Peter Brett did write a proof of concept exploit which showed the risk. You can execute bad code without the user taking any action other than opening the schematic file. Btw.. the auto-uref and auto-place attribs functions are wired up to hook calls inside gschem which pass arguments. See hooks defined in gschem/src/g_register.c For example: move_component_hook = create_hook ("move-component-hook", 1); Which is called in gschem/src/o_move.c switch (object->type) { case (OBJ_COMPLEX): case (OBJ_PLACEHOLDER): if (scm_hook_empty_p(move_component_hook) == SCM_BOOL_F && object != NULL) { scm_run_hook(move_component_hook, scm_cons (g_make_attrib_smob_list (w_current, object), SCM_EOL)); } .... The g_make_attrib_smob_list() function creates a list of attribute_smob's corresponding to the attributes of the object being moved. Each attrib_smob has a world pointer (to the TOPLEVEL struct), and a pointer to the text object (which is the particular attribute). To be completely honest, I think our guile API is a real mess. Peter Brett wrote a nicer one, but it hasn't been merged yet. I'm a little sceptical about what can be achieved through the hooks gschem provides. Btw.. I've attached another example hook - one I wrote as a demo, and that I use locally. It removes component numbering (and replaces with a ?) when you copy a component with a refdes already set. You hook it up with this in your gschemrc: (load-from-path "/home/pcjc2/.gEDA/unnumber-refdes.scm") (add-hook! copy-component-hook unnumber-refdes) Best regards, -- Peter Clifton Electrical Engineering Division, Engineering Department, University of Cambridge, 9, JJ Thomson Avenue, Cambridge CB3 0FA Tel: +44 (0)7729 980173 - (No signal in the lab!) Tel: +44 (0)1223 748328 - (Shared lab phone, ask for me)
;; Copyright (C) 2008 Peter Clifton ;; ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2 of the License, or ;; (at your option) any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program; if not, write to the Free Software ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA (use-modules (srfi srfi-13) (srfi srfi-14)) (define (unnumber-refdes attribs) ;; Function to strip digit suffixes (define (strip-digit-suffix string) (string-trim-right string char-set:digit) ) (define (unnumbered-refdes oldrefdes) (if (string-suffix? "?" oldrefdes) oldrefdes (string-append (strip-digit-suffix oldrefdes) "?") ) ) (for-each (lambda (attrib) (let* ((name-value (get-attribute-name-value attrib)) (name (car name-value)) (value (cdr name-value))) (if (string=? name "refdes") (set-attribute-value! attrib (unnumbered-refdes value))) ) ) attribs ) )
Attachment:
signature.asc
Description: This is a digitally signed message part
_______________________________________________ geda-user mailing list geda-user@xxxxxxxxxxxxxx http://www.seul.org/cgi-bin/mailman/listinfo/geda-user