[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: gaf.git: branch: master updated (1.6.1-20100214-219-gca2741e)
The branch, master has been updated
via ca2741e817c3f8b16e396de9eae1676bc1c612c1 (commit)
via 53185307c7a707b0ab6ff7a9bf73c3d83bf8d988 (commit)
via 5dcaa34495465cfc413b9d2cf3bbd217c1b8c6a3 (commit)
via 0881305f47b16bb530983604a55abe4fe4fbd1b3 (commit)
via c3193a03970dfe1b19a595a6d7f86be445c3bb70 (commit)
via 69e7af1d627a4ce4e307b33b509715821d830412 (commit)
from 92bbcfafd4e8e6cc53e02d15b4574e0a5bdb2209 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
=========
Summary
=========
NEWS | 22 +++++++++++--
gnetlist/docs/gnetlist.1 | 4 ++
gnetlist/include/globals.h | 5 ++-
gnetlist/src/globals.c | 13 +++++---
gnetlist/src/gnetlist.c | 43 ++++++---------------------
gnetlist/src/parsecmd.c | 45 ++++++++++++++++++++++++++--
gschem/docs/gschem.1 | 7 ++++
gschem/include/globals.h | 1 -
gschem/src/globals.c | 1 -
gschem/src/gschem.c | 16 ++++++----
gschem/src/parsecmd.c | 60 ++++++++++++++++++++++++++++++++++++-
libgeda/include/prototype_priv.h | 1 +
libgeda/lib/system-gafrc | 14 ++++++---
libgeda/src/g_register.c | 15 +++++++++
libgeda/src/libgeda.c | 1 +
15 files changed, 184 insertions(+), 64 deletions(-)
=================
Commit Messages
=================
commit ca2741e817c3f8b16e396de9eae1676bc1c612c1
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
gnetlist: Add `-L' option for adding to Guile load path.
:100644 100644 da91c82... 2c7a82b... M NEWS
:100644 100644 48ce082... eb6b847... M gnetlist/docs/gnetlist.1
:100644 100644 67a6404... 0fdb54e... M gnetlist/include/globals.h
:100644 100644 3a28342... 8514b66... M gnetlist/src/globals.c
:100644 100644 f47b9f2... a4df542... M gnetlist/src/gnetlist.c
:100644 100644 04b478e... d5dda61... M gnetlist/src/parsecmd.c
commit 53185307c7a707b0ab6ff7a9bf73c3d83bf8d988
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
gnetlist: Build Scheme expressions instead of listing Scheme scripts.
Instead of making lists of Scheme scripts to load from the `-l' and
`-m' command-line options, build Scheme expressions which do the same
thing.
:100644 100644 cde0f64... 67a6404... M gnetlist/include/globals.h
:100644 100644 cd56583... 3a28342... M gnetlist/src/globals.c
:100644 100644 56cf008... f47b9f2... M gnetlist/src/gnetlist.c
:100644 100644 0fef29d... 04b478e... M gnetlist/src/parsecmd.c
commit 5dcaa34495465cfc413b9d2cf3bbd217c1b8c6a3
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
gschem: Add `-c EXPR' to evaluate Scheme EXPR on load.
Adds a `-c' option to gschem, which allows a Scheme expression to be
evaluated on gschem load. Multiple `-s' and `-c' options can be
specified, and they are applied in order.
:100644 100644 021d90f... da91c82... M NEWS
:100644 100644 b6acc71... 153b884... M gschem/docs/gschem.1
:100644 100644 e8eaa5a... 53aa38a... M gschem/src/parsecmd.c
commit 0881305f47b16bb530983604a55abe4fe4fbd1b3
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
gschem: Allow multiple `-s' scripts to be specified.
:100644 100644 7b780c5... 021d90f... M NEWS
:100644 100644 49dcd39... 0f0fd21... M gschem/include/globals.h
:100644 100644 7a4e7ad... 14da9db... M gschem/src/globals.c
:100644 100644 ea3b086... fec69c0... M gschem/src/gschem.c
:100644 100644 645cd1d... e8eaa5a... M gschem/src/parsecmd.c
commit c3193a03970dfe1b19a595a6d7f86be445c3bb70
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
gschem: Add `-L' option for adding to Guile load path.
:100644 100644 d63d240... 7b780c5... M NEWS
:100644 100644 9c4d184... b6acc71... M gschem/docs/gschem.1
:100644 100644 8af89b8... ea3b086... M gschem/src/gschem.c
:100644 100644 d5c765b... 645cd1d... M gschem/src/parsecmd.c
commit 69e7af1d627a4ce4e307b33b509715821d830412
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
libgeda: Always add gEDA default Scheme directory to search path.
Make sure that the default directory for gEDA Scheme files is added to
the Guile %load-path during libgeda initialisation. This ensures that
even if there is a problem loading system-gafrc (for some reason),
gEDA Scheme code can still be found.
Remove the current `scheme-directory' directive from system-gafrc, and
replace it with a commented-out example of its use.
:100644 100644 1b62ff7... e3dad86... M libgeda/include/prototype_priv.h
:100644 100644 cff8371... 9aafe85... M libgeda/lib/system-gafrc
:100644 100644 b69b9d5... cabbf18... M libgeda/src/g_register.c
:100644 100644 ea11b92... f57d635... M libgeda/src/libgeda.c
=========
Changes
=========
commit ca2741e817c3f8b16e396de9eae1676bc1c612c1
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
gnetlist: Add `-L' option for adding to Guile load path.
diff --git a/NEWS b/NEWS
index da91c82..2c7a82b 100644
--- a/NEWS
+++ b/NEWS
@@ -47,11 +47,16 @@ Notable changes in gEDA/gaf 1.7.0
* Special characters, including commas, are now escaped or quoted
appropriately in `gattrib' CSV output.
-* `gnetlist' now provides a `-V' or `--version' option, which displays
- version information.
+* Several changes to `gnetlist' command-line options:
-* When run with invalid command-line arguments, `gnetlist' now exits
- with non-zero exit status.
+ - A new `-L' option is available, which adds a directory to the
+ Scheme load path.
+
+ - A new `-V' or `--version' option is available, which displays
+ version information.
+
+ - When run with invalid command-line arguments, `gnetlist' now exits
+ with non-zero exit status.
* Several `gnetlist' backends have now been fixed so that it should no
longer be necessary to set an expanded Guile stack in gEDA's config
diff --git a/gnetlist/docs/gnetlist.1 b/gnetlist/docs/gnetlist.1
index 48ce082..eb6b847 100644
--- a/gnetlist/docs/gnetlist.1
+++ b/gnetlist/docs/gnetlist.1
@@ -32,6 +32,10 @@ Quiet mode. Turns off all warnings/notes/messages.
\fB-v\fR, \fB--verbose\fR
Verbose mode. Output all diagnostic information.
.TP 8
+\fB-L\fR \fIDIRECTORY\fR
+Prepend \fIDIRECTORY\fR to the list of directories to be searched for
+Scheme files.
+.TP 8
\fB-g\fR \fIBACKEND\fR
Specify the backend to be used. Use `\-g help' to display a list of
available backends.
diff --git a/gnetlist/include/globals.h b/gnetlist/include/globals.h
index 67a6404..0fdb54e 100644
--- a/gnetlist/include/globals.h
+++ b/gnetlist/include/globals.h
@@ -37,6 +37,7 @@ extern int sort_mode;
extern int embedd_mode;
extern int nomunge_mode;
extern char *output_filename;
+extern SCM pre_rc_list; /* before rc loaded */
extern SCM pre_backend_list; /* before backend loaded */
extern SCM post_backend_list; /* after backend loaded, before execute */
extern GSList *backend_params; /* Parameters passed to the backend from the command line */
diff --git a/gnetlist/src/globals.c b/gnetlist/src/globals.c
index 3a28342..8514b66 100644
--- a/gnetlist/src/globals.c
+++ b/gnetlist/src/globals.c
@@ -56,6 +56,9 @@ int nomunge_mode = FALSE;
int netlist_mode=gEDA;
char *output_filename=NULL;
+/* scheme expression to evaluate before loading of rc files */
+SCM pre_rc_list = SCM_EOL;
+
/* scheme expression to evaluate before loading of the backend */
SCM pre_backend_list = SCM_EOL;
diff --git a/gnetlist/src/gnetlist.c b/gnetlist/src/gnetlist.c
index f47b9f2..a4df542 100644
--- a/gnetlist/src/gnetlist.c
+++ b/gnetlist/src/gnetlist.c
@@ -184,6 +184,11 @@ void main_prog(void *closure, int argc, char *argv[])
g_register_funcs();
pr_current = s_toplevel_new ();
+
+ /* Evaluate Scheme expressions that need to be run before rc files
+ * are loaded. */
+ g_scm_eval_protected (pre_rc_list, scm_current_module ());
+
g_rc_parse(pr_current, "gnetlistrc", rc_filename);
/* immediately setup user params */
i_vars_set (pr_current);
diff --git a/gnetlist/src/parsecmd.c b/gnetlist/src/parsecmd.c
index 04b478e..d5dda61 100644
--- a/gnetlist/src/parsecmd.c
+++ b/gnetlist/src/parsecmd.c
@@ -42,7 +42,7 @@
#include <dmalloc.h>
#endif
-#define OPTIONS "o:qieIhvsg:c:l:m:O:nV"
+#define OPTIONS "c:eg:hiIl:L:m:o:O:nqsvV"
#ifndef OPTARG_IN_UNISTD
extern char *optarg;
@@ -77,6 +77,7 @@ void usage(char *cmd)
"General options:\n"
" -q Quiet mode.\n"
" -v, --verbose Verbose mode.\n"
+" -L DIR Add DIR to Scheme search path.\n"
" -g BACKEND Specify netlist backend to use.\n"
" -O STRING Pass an option string to backend.\n"
" -l FILE Load Scheme file before loading backend.\n"
@@ -136,7 +137,10 @@ parse_commandline (int argc, char *argv[])
{
int ch;
SCM sym_begin = scm_from_locale_symbol ("begin");
+ SCM sym_cons = scm_from_locale_symbol ("cons");
SCM sym_load = scm_from_locale_symbol ("load");
+ SCM sym_set_x = scm_from_locale_symbol ("set!");
+ SCM sym_load_path = scm_from_locale_symbol ("%load-path");
#ifdef HAVE_GETOPT_LONG
/* int option_index = 0; */
@@ -172,6 +176,19 @@ parse_commandline (int argc, char *argv[])
quiet_mode = TRUE;
break;
+ case 'L':
+ /* Argument is a directory to add to the Scheme load path.
+ * Add the necessary expression to be evaluated before rc file
+ * loading. */
+ pre_rc_list =
+ scm_cons (scm_list_3 (sym_set_x,
+ sym_load_path,
+ scm_list_3 (sym_cons,
+ scm_from_locale_string (optarg),
+ sym_load_path)),
+ pre_rc_list);
+ break;
+
case 'g':
guile_proc = g_strdup(optarg);
break;
@@ -254,6 +271,9 @@ parse_commandline (int argc, char *argv[])
}
/* Make sure Scheme expressions can be passed straight to eval */
+ pre_rc_list = scm_cons (sym_begin,
+ scm_reverse_x (pre_rc_list, SCM_UNDEFINED));
+ scm_gc_protect_object (pre_rc_list);
pre_backend_list = scm_cons (sym_begin,
scm_reverse_x (pre_backend_list, SCM_UNDEFINED));
scm_gc_protect_object (pre_backend_list);
commit 53185307c7a707b0ab6ff7a9bf73c3d83bf8d988
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
gnetlist: Build Scheme expressions instead of listing Scheme scripts.
Instead of making lists of Scheme scripts to load from the `-l' and
`-m' command-line options, build Scheme expressions which do the same
thing.
diff --git a/gnetlist/include/globals.h b/gnetlist/include/globals.h
index cde0f64..67a6404 100644
--- a/gnetlist/include/globals.h
+++ b/gnetlist/include/globals.h
@@ -37,6 +37,6 @@ extern int sort_mode;
extern int embedd_mode;
extern int nomunge_mode;
extern char *output_filename;
-extern GSList *pre_backend_list; /* before backend loaded */
-extern GSList *post_backend_list; /* after backend loaded, before execute */
+extern SCM pre_backend_list; /* before backend loaded */
+extern SCM post_backend_list; /* after backend loaded, before execute */
extern GSList *backend_params; /* Parameters passed to the backend from the command line */
diff --git a/gnetlist/src/globals.c b/gnetlist/src/globals.c
index cd56583..3a28342 100644
--- a/gnetlist/src/globals.c
+++ b/gnetlist/src/globals.c
@@ -56,12 +56,12 @@ int nomunge_mode = FALSE;
int netlist_mode=gEDA;
char *output_filename=NULL;
-/* list of filenames to load before loading of the backend */
-GSList *pre_backend_list=NULL;
+/* scheme expression to evaluate before loading of the backend */
+SCM pre_backend_list = SCM_EOL;
-/* list of filenames to load after loading of the backend but before the */
-/* execution of the backend procedure */
-GSList *post_backend_list=NULL;
+/* scheme expression to evaluate after loading of the backend but
+ * before the execution of the backend procedure */
+SCM post_backend_list = SCM_EOL;
/* Parameters passed to the backend from the command line */
GSList *backend_params = NULL;
diff --git a/gnetlist/src/gnetlist.c b/gnetlist/src/gnetlist.c
index 56cf008..f47b9f2 100644
--- a/gnetlist/src/gnetlist.c
+++ b/gnetlist/src/gnetlist.c
@@ -137,7 +137,6 @@ void main_prog(void *closure, int argc, char *argv[])
int i;
int argv_index;
char *cwd;
- GSList *list_pnt;
gchar *str;
gchar *filename;
@@ -198,22 +197,9 @@ void main_prog(void *closure, int argc, char *argv[])
}
}
- /* Load the first set of scm files before we load any schematic files */
- list_pnt = pre_backend_list;
- while (list_pnt) {
- if (g_read_file(pr_current, list_pnt->data) != -1) {
- s_log_message("Read scm file [%s]\n",
- (char *) list_pnt->data);
- } else {
- s_log_message("Failed to read scm file [%s]\n",
- (char *) list_pnt->data);
- fprintf(stderr, "Failed to read scm file [%s]\n",
- (char *) list_pnt->data);
- }
- list_pnt = g_slist_next(list_pnt);
- }
- /* Free now the list of configuration files */
- g_slist_free(pre_backend_list);
+ /* Evaluate the first set of Scheme expressions before we load any
+ * schematic files */
+ g_scm_eval_protected (pre_backend_list, scm_current_module ());
i = argv_index;
while (argv[i] != NULL) {
@@ -273,22 +259,8 @@ void main_prog(void *closure, int argc, char *argv[])
scm_primitive_load_path (scm_from_locale_string (str));
g_free (str);
- /* Load second set of scm files */
- list_pnt = post_backend_list;
- while (list_pnt) {
- if (g_read_file(pr_current, list_pnt->data) != -1) {
- s_log_message("Read scm file [%s]\n",
- (char *) list_pnt->data);
- } else {
- s_log_message("Failed to read scm file [%s]\n",
- (char *) list_pnt->data);
- fprintf(stderr, "Failed to read scm file [%s]\n",
- (char *) list_pnt->data);
- }
- list_pnt = g_slist_next(list_pnt);
- }
- /* Free now the list of configuration files */
- g_slist_free(post_backend_list);
+ /* Evaluate second set of Scheme expressions. */
+ g_scm_eval_protected (post_backend_list, scm_current_module ());
}
s_traverse_init();
diff --git a/gnetlist/src/parsecmd.c b/gnetlist/src/parsecmd.c
index 0fef29d..04b478e 100644
--- a/gnetlist/src/parsecmd.c
+++ b/gnetlist/src/parsecmd.c
@@ -135,8 +135,9 @@ int
parse_commandline (int argc, char *argv[])
{
int ch;
+ SCM sym_begin = scm_from_locale_symbol ("begin");
+ SCM sym_load = scm_from_locale_symbol ("load");
- /* Converted to getopt_long by SDB 3.3.2006 */
#ifdef HAVE_GETOPT_LONG
/* int option_index = 0; */
@@ -176,11 +177,19 @@ parse_commandline (int argc, char *argv[])
break;
case 'l':
- pre_backend_list = g_slist_append(pre_backend_list, optarg);
+ /* Argument is filename of a Scheme script to be run before
+ * loading gnetlist backend. */
+ pre_backend_list =
+ scm_cons (scm_list_2 (sym_load, scm_from_locale_string (optarg)),
+ pre_backend_list);
break;
case 'm':
- post_backend_list = g_slist_append(post_backend_list, optarg);
+ /* Argument is filename of a Scheme script to be run after
+ * loading gnetlist backend. */
+ post_backend_list =
+ scm_cons (scm_list_2 (sym_load, scm_from_locale_string (optarg)),
+ post_backend_list);
break;
case 'n':
@@ -244,5 +253,13 @@ parse_commandline (int argc, char *argv[])
verbose_mode = FALSE;
}
+ /* Make sure Scheme expressions can be passed straight to eval */
+ pre_backend_list = scm_cons (sym_begin,
+ scm_reverse_x (pre_backend_list, SCM_UNDEFINED));
+ scm_gc_protect_object (pre_backend_list);
+ post_backend_list = scm_cons (sym_begin,
+ scm_reverse_x (post_backend_list, SCM_UNDEFINED));
+ scm_gc_protect_object (post_backend_list);
+
return (optind);
}
commit 5dcaa34495465cfc413b9d2cf3bbd217c1b8c6a3
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
gschem: Add `-c EXPR' to evaluate Scheme EXPR on load.
Adds a `-c' option to gschem, which allows a Scheme expression to be
evaluated on gschem load. Multiple `-s' and `-c' options can be
specified, and they are applied in order.
diff --git a/NEWS b/NEWS
index 021d90f..da91c82 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,9 @@ Notable changes in gEDA/gaf 1.7.0
- The `-s' option can now be used to run multiple Scheme scripts
during `gschem' startup.
+ - A new `-c' option is available, which runs a Scheme expression
+ during `gschem' startup.
+
- A new `-L' option is available, which adds a directory to the
Scheme load path.
diff --git a/gschem/docs/gschem.1 b/gschem/docs/gschem.1
index b6acc71..153b884 100644
--- a/gschem/docs/gschem.1
+++ b/gschem/docs/gschem.1
@@ -44,6 +44,9 @@ Scheme files.
\fB-s\fR \fIFILE\fR
Specify a Scheme script to be executed at startup.
.TP 8
+\fB-c\fR \fIEXPR\fR
+Specify a Scheme expression to be evaluated at startup.
+.TP 8
\fB-o\fR, \fB--output\fR=\fIFILE\fR
Specify a filename for PostScript output. This command line argument
is useful when running \fBgschem\fR from a shell script and with a
diff --git a/gschem/src/parsecmd.c b/gschem/src/parsecmd.c
index e8eaa5a..53aa38a 100644
--- a/gschem/src/parsecmd.c
+++ b/gschem/src/parsecmd.c
@@ -32,7 +32,7 @@
#include <dmalloc.h>
#endif
-#define GETOPT_OPTIONS "hL:o:pqr:s:vV"
+#define GETOPT_OPTIONS "c:hL:o:pqr:s:vV"
#ifndef OPTARG_IN_UNISTD
extern char *optarg;
@@ -89,6 +89,7 @@ usage(char *cmd)
" -v, --verbose Verbose mode.\n"
" -r, --config-file=FILE Additional configuration file to load.\n"
" -L DIR Add DIR to Scheme search path.\n"
+" -c EXPR Scheme expression to run at startup.\n"
" -s FILE Scheme script to run at startup.\n"
" -o, --output=FILE Output filename (for printing).\n"
" -p Automatically place the window.\n"
@@ -139,6 +140,7 @@ parse_commandline(int argc, char *argv[])
SCM sym_load_path = scm_from_locale_symbol ("%load-path");
SCM sym_begin = scm_from_locale_symbol ("begin");
SCM sym_load = scm_from_locale_symbol ("load");
+ SCM sym_eval_string = scm_from_locale_symbol ("eval-string");
#ifdef HAVE_GETOPT_LONG
while ((ch = getopt_long (argc, argv, GETOPT_OPTIONS, long_options, NULL)) != -1) {
@@ -168,6 +170,16 @@ parse_commandline(int argc, char *argv[])
s_post_load_expr);
break;
+ case 'c':
+ /* Argument is a Scheme expression to be evaluated on gschem
+ * load. Add the necessary expression to be evaluated after
+ * loading. */
+ s_post_load_expr =
+ scm_cons (scm_list_2 (sym_eval_string,
+ scm_from_locale_string (optarg)),
+ s_post_load_expr);
+ break;
+
case 'o':
output_filename = g_strdup (optarg);
break;
commit 0881305f47b16bb530983604a55abe4fe4fbd1b3
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
gschem: Allow multiple `-s' scripts to be specified.
diff --git a/NEWS b/NEWS
index 7b780c5..021d90f 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,9 @@ Notable changes in gEDA/gaf 1.7.0
- Several command-line options now support a long-form alternative.
+ - The `-s' option can now be used to run multiple Scheme scripts
+ during `gschem' startup.
+
- A new `-L' option is available, which adds a directory to the
Scheme load path.
diff --git a/gschem/include/globals.h b/gschem/include/globals.h
index 49dcd39..0f0fd21 100644
--- a/gschem/include/globals.h
+++ b/gschem/include/globals.h
@@ -35,7 +35,6 @@ extern GdkColor white;
extern GdkColor black;
extern char *rc_filename;
-extern char *script_filename;
extern char *output_filename;
diff --git a/gschem/src/globals.c b/gschem/src/globals.c
index 7a4e7ad..14da9db 100644
--- a/gschem/src/globals.c
+++ b/gschem/src/globals.c
@@ -37,7 +37,6 @@ GSCHEM_TOPLEVEL *global_window_current = NULL;
GList *global_window_list = NULL;
char *rc_filename = NULL;
-char *script_filename = NULL;
char *output_filename = NULL;
/* colors */
diff --git a/gschem/src/gschem.c b/gschem/src/gschem.c
index ea3b086..fec69c0 100644
--- a/gschem/src/gschem.c
+++ b/gschem/src/gschem.c
@@ -318,13 +318,6 @@ void main_prog(void *closure, int argc, char *argv[])
/* Run post-load expressions */
g_scm_eval_protected (s_post_load_expr, scm_current_module ());
- /* Execute a script if it exists */
- if (script_filename) {
- s_log_message(_("Executing guile script [%s]\n"),
- script_filename);
- g_read_file(w_current->toplevel, script_filename);
- }
-
/* open up log window on startup */
if (w_current->log_window == MAP_ON_STARTUP) {
x_log_open ();
diff --git a/gschem/src/parsecmd.c b/gschem/src/parsecmd.c
index 645cd1d..e8eaa5a 100644
--- a/gschem/src/parsecmd.c
+++ b/gschem/src/parsecmd.c
@@ -138,6 +138,7 @@ parse_commandline(int argc, char *argv[])
SCM sym_set_x = scm_from_locale_symbol ("set!");
SCM sym_load_path = scm_from_locale_symbol ("%load-path");
SCM sym_begin = scm_from_locale_symbol ("begin");
+ SCM sym_load = scm_from_locale_symbol ("load");
#ifdef HAVE_GETOPT_LONG
while ((ch = getopt_long (argc, argv, GETOPT_OPTIONS, long_options, NULL)) != -1) {
@@ -158,7 +159,13 @@ parse_commandline(int argc, char *argv[])
break;
case 's':
- script_filename = g_strdup (optarg);
+ /* Argument is filename of a Scheme script to be run on gschem
+ * load. Add the necessary expression to be evaluated after
+ * loading. */
+ s_post_load_expr =
+ scm_cons (scm_list_2 (sym_load,
+ scm_from_locale_string (optarg)),
+ s_post_load_expr);
break;
case 'o':
commit c3193a03970dfe1b19a595a6d7f86be445c3bb70
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
gschem: Add `-L' option for adding to Guile load path.
diff --git a/NEWS b/NEWS
index d63d240..7b780c5 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,9 @@ Notable changes in gEDA/gaf 1.7.0
- Several command-line options now support a long-form alternative.
+ - A new `-L' option is available, which adds a directory to the
+ Scheme load path.
+
- A new `-V' or `--version' option is available, which displays
version information.
diff --git a/gschem/docs/gschem.1 b/gschem/docs/gschem.1
index 9c4d184..b6acc71 100644
--- a/gschem/docs/gschem.1
+++ b/gschem/docs/gschem.1
@@ -37,6 +37,10 @@ current working directory. This option allows the user to specify an
additional rc file which is read after all the other rc files have
been are read.
.TP 8
+\fB-L\fR \fIDIRECTORY\fR
+Prepend \fIDIRECTORY\fR to the list of directories to be searched for
+Scheme files.
+.TP 8
\fB-s\fR \fIFILE\fR
Specify a Scheme script to be executed at startup.
.TP 8
diff --git a/gschem/src/gschem.c b/gschem/src/gschem.c
index 8af89b8..ea3b086 100644
--- a/gschem/src/gschem.c
+++ b/gschem/src/gschem.c
@@ -40,6 +40,10 @@
#include <locale.h>
#endif
+/* These are generated by parse_commandline() */
+extern SCM s_pre_load_expr;
+extern SCM s_post_load_expr;
+
typedef struct {
gschem_atexit_func func;
gpointer arg;
@@ -237,6 +241,9 @@ void main_prog(void *closure, int argc, char *argv[])
(ChangeNotifyFunc) o_invalidate,
(ChangeNotifyFunc) o_invalidate, w_current);
+ /* Run pre-load Scheme expressions */
+ g_scm_eval_protected (s_pre_load_expr, scm_current_module ());
+
/* Now read in RC files. */
g_rc_parse_gtkrc();
g_rc_parse(w_current->toplevel, "gschemrc", rc_filename);
@@ -308,6 +315,8 @@ void main_prog(void *closure, int argc, char *argv[])
scm_c_eval_string ("(display \"hello guile\n\")");
#endif
+ /* Run post-load expressions */
+ g_scm_eval_protected (s_post_load_expr, scm_current_module ());
/* Execute a script if it exists */
if (script_filename) {
diff --git a/gschem/src/parsecmd.c b/gschem/src/parsecmd.c
index d5c765b..645cd1d 100644
--- a/gschem/src/parsecmd.c
+++ b/gschem/src/parsecmd.c
@@ -32,7 +32,7 @@
#include <dmalloc.h>
#endif
-#define GETOPT_OPTIONS "hqvr:s:o:pV"
+#define GETOPT_OPTIONS "hL:o:pqr:s:vV"
#ifndef OPTARG_IN_UNISTD
extern char *optarg;
@@ -56,6 +56,17 @@ struct option long_options[] =
};
#endif
+/*! Contains a Scheme expression arising from command-line arguments.
+ * This is evaluated after initialising gschem, but before loading
+ * any rc files. */
+SCM s_pre_load_expr = SCM_EOL;
+
+/*! Contains a Scheme expression arising from command-line arguments.
+ * This is evaluated after loading gschem and any schematic
+ * files specified on the command-line.
+ */
+SCM s_post_load_expr = SCM_EOL;
+
/*! \brief Print brief help message and exit.
* \par Function Description
* Print brief help message describing gschem usage & command-line
@@ -77,6 +88,7 @@ usage(char *cmd)
" -q, --quiet Quiet mode.\n"
" -v, --verbose Verbose mode.\n"
" -r, --config-file=FILE Additional configuration file to load.\n"
+" -L DIR Add DIR to Scheme search path.\n"
" -s FILE Scheme script to run at startup.\n"
" -o, --output=FILE Output filename (for printing).\n"
" -p Automatically place the window.\n"
@@ -122,6 +134,11 @@ int
parse_commandline(int argc, char *argv[])
{
int ch;
+ SCM sym_cons = scm_from_locale_symbol ("cons");
+ SCM sym_set_x = scm_from_locale_symbol ("set!");
+ SCM sym_load_path = scm_from_locale_symbol ("%load-path");
+ SCM sym_begin = scm_from_locale_symbol ("begin");
+
#ifdef HAVE_GETOPT_LONG
while ((ch = getopt_long (argc, argv, GETOPT_OPTIONS, long_options, NULL)) != -1) {
#else
@@ -152,6 +169,19 @@ parse_commandline(int argc, char *argv[])
auto_place_mode = TRUE;
break;
+ case 'L':
+ /* Argument is a directory to add to the Scheme load path.
+ * Add the necessary expression to be evaluated before rc file
+ * loading. */
+ s_pre_load_expr =
+ scm_cons (scm_list_3 (sym_set_x,
+ sym_load_path,
+ scm_list_3 (sym_cons,
+ scm_from_locale_string (optarg),
+ sym_load_path)),
+ s_pre_load_expr);
+ break;
+
case 'h':
usage(argv[0]);
break;
@@ -185,5 +215,12 @@ parse_commandline(int argc, char *argv[])
verbose_mode = FALSE;
}
+ /* Make sure Scheme expressions can be passed straight to eval */
+ s_pre_load_expr = scm_cons (sym_begin,
+ scm_reverse_x (s_pre_load_expr, SCM_UNDEFINED));
+ scm_gc_protect_object (s_pre_load_expr);
+ s_post_load_expr = scm_cons (sym_begin,
+ scm_reverse_x (s_post_load_expr, SCM_UNDEFINED));
+ scm_gc_protect_object (s_post_load_expr);
return(optind);
}
commit 69e7af1d627a4ce4e307b33b509715821d830412
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
libgeda: Always add gEDA default Scheme directory to search path.
Make sure that the default directory for gEDA Scheme files is added to
the Guile %load-path during libgeda initialisation. This ensures that
even if there is a problem loading system-gafrc (for some reason),
gEDA Scheme code can still be found.
Remove the current `scheme-directory' directive from system-gafrc, and
replace it with a commented-out example of its use.
diff --git a/libgeda/include/prototype_priv.h b/libgeda/include/prototype_priv.h
index 1b62ff7..e3dad86 100644
--- a/libgeda/include/prototype_priv.h
+++ b/libgeda/include/prototype_priv.h
@@ -36,6 +36,7 @@ SCM g_rc_print_color_map (SCM scm_map);
/* g_register.c */
void g_register_libgeda_funcs(void);
void g_register_libgeda_vars (void);
+void g_register_libgeda_dirs (void);
/* g_smob.c */
void g_init_attrib_smob(void);
diff --git a/libgeda/lib/system-gafrc b/libgeda/lib/system-gafrc
index cff8371..9aafe85 100644
--- a/libgeda/lib/system-gafrc
+++ b/libgeda/lib/system-gafrc
@@ -14,11 +14,6 @@
(debug-enable 'backtrace)
(read-enable 'positions)
-;; The directory containing gaf Scheme code.
-(define geda-scheme-path (string-append geda-data-path path-sep "scheme"))
-; We need to add gaf's scheme library to the Guile load path.
-(scheme-directory geda-scheme-path)
-
; The libgeda Scheme library provides a number of useful functions for
; writing Scheme code for embedding in gaf.
(load-from-path "geda.scm")
@@ -32,6 +27,15 @@
; before the main script.
(postscript-prolog (build-path geda-data-path "prolog.ps"))
+; scheme-directory dir
+;
+; This keyword allows additional directories to be added to the list
+; of directories which are used by gEDA to load Scheme code.
+; Environment variables in 'dir' are expanded. By default,
+; '${GEDADATA}/scheme' is in the load path, as are all of the standard
+; Guile Scheme libraries.
+;(scheme-directory "${HOME}/.gEDA/scheme")
+
;
; Start of attribute promotion keywords
;
diff --git a/libgeda/src/g_register.c b/libgeda/src/g_register.c
index b69b9d5..cabbf18 100644
--- a/libgeda/src/g_register.c
+++ b/libgeda/src/g_register.c
@@ -116,3 +116,18 @@ void g_register_libgeda_vars (void)
scm_c_define("OBJ_PLACEHOLDER", SCM_MAKE_CHAR((unsigned char) OBJ_PLACEHOLDER));
scm_c_define("OBJ_PATH", SCM_MAKE_CHAR((unsigned char) OBJ_PATH));
}
+
+/*! \brief Register some libgeda directories with Scheme.
+ * \par Function Description
+ * Ensures that the default gEDA Scheme directory is added to the
+ * Guile load path.
+ */
+void
+g_register_libgeda_dirs (void)
+{
+ char *scheme_dir;
+
+ scheme_dir = g_build_filename (s_path_sys_data (), "scheme", NULL);
+ g_rc_scheme_directory (scm_from_locale_string (scheme_dir));
+ g_free (scheme_dir);
+}
diff --git a/libgeda/src/libgeda.c b/libgeda/src/libgeda.c
index ea11b92..f57d635 100644
--- a/libgeda/src/libgeda.c
+++ b/libgeda/src/libgeda.c
@@ -61,6 +61,7 @@ void libgeda_init(void)
g_register_libgeda_funcs();
g_register_libgeda_vars();
+ g_register_libgeda_dirs();
g_init_object_smob();
g_init_attrib_smob();
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs