Mail Archives: geda-user/2013/09/08/09:11:53
Hi All,
Unless someone provides a convincing argument against, I'm intending to
revert the following:
commit 7dafcd5e30e957dc1fffbb2eedae5d1a555a6552
Author: Edward Hennessy <ehennes AT sbcglobal DOT net>
Date: Fri Jul 5 14:53:36 2013 -0700
Reset refdes number to the question mark when parts are copied
This change helps ensure no duplicate refdes get inadvertenly
created. When parts are copied and pasted, the refdes number is
reset to the question mark. When parts are cut and pasted, the
refdes number is preserved.
In the course of normal copy+paste work on my schematic (where I was
re-organising some parts between sheets), this change has has just
caused me to loose a lot of data :(
(I did not notice the loss of refdes information straight away!)
The code in question is very "policy" oriented, and I don't think it
should not live in gschem or libgeda.
FWIW, I already implemented the functionality Ed wanted as a very short
scheme script, requiring no nasty special case code in libgeda... (IE..
The "?" refdes suffix is a hack, and I would prefer not to hard-code it
further into the core of our software!)
gschemrc:
(load-from-path "/home/pcjc2/.gEDA/unnumber-refdes.scm")
(add-hook! copy-component-hook unnumber-refdes)
unnumber-refdes.scm:
(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
)
)
--
Peter Clifton <peter DOT clifton AT clifton-electronics DOT co DOT uk>
Clifton Electronics
- Raw text -