Feature - gschem - Dynamic loading of custom symbols in the component selection tree

Bug #901222 reported by Luigi S. Palese
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gEDA
Fix Released
Wishlist
Unassigned

Bug Description

As attachment a Guile script which extends the (component-library ...) functionality in order to permit to see custom components in the component selection tree grouped by folders.
The syntax of the new functionality is as follow:

into the .gEDA/gafrc file

(component-library-add-tree "prefix" "symbols/folder")

The prefix will be added, as a tag, to the folder description. Actually the script doesn't manage substitution of the environment variables.

If usefull this script could be added to the main stream.

Best Regards,
Luigi

Tags: libgeda
Revision history for this message
Luigi S. Palese (quadword) wrote :
Revision history for this message
Peter TB Brett (peter-b) wrote :

Hi Luigi,

Thank you for submitting this Scheme function. In order to commit it, I would appreciate it if you would make the following changes:

* The license for gEDA/gaf is GPLv2+. Could you please relicense as GPLv2+ instead of GPLv3+?
* The line with "string-trim-right" is not necessary, and prevents you from using directory names that start or end with whitespace (you wouldn't believe some of the things I've seen Windows users do!)
* Please use "substring" instead of "string-copy". This makes it easier to read the code, because it explains what you are doing better. :-)
* We don't use per-file changelogs in gEDA/gaf -- we write useful commit messages for git instead. :-) If this is accepted, the changelog section will need to be removed.

As you are probably aware, we currently have a "component-library-search" function in libgeda, and this behaves in a very similar way. What do you think about putting this in as an improved replacement for "component-library-search", and make the "prefix" argument optional?

  (use-modules (ice-9 optargs))

  (define (component-library-search dirname #:optional prefix)
    <body ...> )

Thanks,

Peter

Changed in geda:
status: New → In Progress
importance: Undecided → Wishlist
tags: added: libgeda
removed: component gschem symbols tree
Revision history for this message
Luigi S. Palese (quadword) wrote :

Hi Peter,
 thanks for your reply.
I made some work to accomplish your specifications. I hope nothing is missing. I'm substituting dirname with dir-name cause i'm using dirname procedure to build the hash-table keys. The new version performs better than the old one :-).
I also added an "Invalid directory" check, to avoid gschem error window to open in case of inexistent directory.
I notice that no internationalization is used for strings in the pure scheme parts of geda, is it ?

Regards,
Luigi

Revision history for this message
Peter TB Brett (peter-b) wrote :

Hi Luigi,

This is a good improvement.

I didn't spot the fact you were using the "dirname" function! Perhaps, to avoid confusion between "dir-name" and "dirname", the argument should be called "rootdir" or "root"?

You have a couple of places where you have something like:

  (if (eq? #f <expr>) ...)

This is actually equivalent to:

  (if (not <expr>) ...)

and I usually write it as:

  (if <expr> ...)

with the branches swapped. This makes it easier to read IMHO.

I'm not sure that I agree with your error message. There seem to be two cases in which an error might get raised:

1) If the root directory passed by the user is not a directory or missing or inaccessible. Surely, in that case, we *want* a message dialog to appear, so that they know there is a problem with their configuration?

2) If there is a problem with one of the files or directories contained by the root directory, then perhaps it would be best to print a warning message but skip the directory without raising an error (and causing a message dialog).

Translatable strings in the Scheme source code is something that I need to make happen before 1.7.3 can be released. I have most of the infrastructure needed already in place; I just need to make sure that everything uses the correct gettext domains etc.

Revision history for this message
Luigi S. Palese (quadword) wrote :

Hi Peter,

rootdir is better for me :-)

About the error messages the code depends on the error information handled by the ftw.
Now an error will be generated if an invalid-stat (means stat failed to obtain information) is returned by ftw (in this case i cannot know if it is a directory or a file).
In the other cases (symlink means a broken symlink or directory-not-readable) simply a Warning text will be displayed. Please can you say me if there is a geda standard way to display warning messages ?

Thanks.

Luigi

Revision history for this message
Peter TB Brett (peter-b) wrote :

Hi Luigi,

This is pretty close to done. I just need to add a function to the Scheme API for expanding environment variables in a string, then I can commit it as a full replacement for "component-library-search".

Thanks,

Peter

Changed in geda:
assignee: nobody → Peter TB Brett (peter-b)
status: In Progress → Confirmed
Peter TB Brett (peter-b)
Changed in geda:
milestone: none → 1.8.0
Revision history for this message
gpleda.org commit robot (gpleda-launchpad-robot) wrote :

Bug was fixed by a commit
git master commit 07de7591c23c93efdb92012304dc7aaee1c66c04
http://git.gpleda.org/?p=gaf.git;a=commit;h=07de7591c23c93efdb92012304dc7aaee1c66c04

commit 07de7591c23c93efdb92012304dc7aaee1c66c04
Author: Peter TB Brett <email address hidden>
Commit: Peter TB Brett <email address hidden>

    libgeda: Improvements to 'component-library-search'.

    Luigi Palese has supplied an improved Scheme version of the
    'component-library-search' function for searching a directory tree for
    symbol libraries.

    The new version:

    - Searches for directories recursively, rather than only searching the
      top level of the provided directory.
    - Only considers directories that actually contain symbol files as
      libraries.
    - Optionally adds a prefix to the library names shown in the gschem
      library window.

    (I have made some adjustments to Luigi's original version of the
    function).

    Closes-bug: lp-901222

Changed in geda:
status: Confirmed → Fix Committed
Peter TB Brett (peter-b)
Changed in geda:
milestone: 1.8.0 → 1.7.2
Peter TB Brett (peter-b)
Changed in geda:
assignee: Peter TB Brett (peter-b) → nobody
Peter TB Brett (peter-b)
Changed in geda:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.