www.delorie.com/archives/browse.cgi   search  
Mail Archives: geda-user/2013/09/08/09:11:53

X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f
X-Recipient: geda-user AT delorie DOT com
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/
Message-ID: <1378645856.7052.5.camel@pcjc2lap>
Subject: [geda-user] Revert "Reset refdes number to the question mark when parts are
copied"
From: Peter Clifton <pcjc2 AT cam DOT ac DOT uk>
To: geda-user AT delorie DOT com
Cc: ehennes AT sbcglobal DOT net
Date: Sun, 08 Sep 2013 14:10:56 +0100
X-Mailer: Evolution 3.8.4-0ubuntu1
Mime-Version: 1.0
Reply-To: geda-user AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019