[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: program args to dtk-program



I prepared a full patch that allows for passing arbitrary command line parameters to server program. It's quite short in implementation. Details (the documentation string) are below, under my signature.

Current version, r8407, which works fine with single arguments is sufficient for my current needs, so there is no need to hurry with the patch.

Jarek

Documentation:

Arguments passed to the dtk-program.
Usually SPACE is used to separate arguments, so the following string is
considered to be a list of 3 arguments:

-v eu -s

In case where SPACE character must be inside an argument, the argument
separator may be changed. To do this prefix argument string with
",<SEP>". This makes <SEP> the argument separator (could be also SPACE).
For example this is one argument invocation:

,,C:\Program Files\dir

And this is 3 argument invocation, with underline used as the separator:

,_the first arg_the second arg_thethird

Index: lisp/dtk-speak.el
===================================================================
--- lisp/dtk-speak.el	(revision 8407)
+++ lisp/dtk-speak.el	(working copy)
@@ -77,9 +77,24 @@
 The default is dtk-exp.")
 
 (defvar dtk-program-args
-  (or (getenv "DTK_PROGRAM_ARGS") nil)
-  "Arguments passed to the dtk-program")
+  (or (getenv "DTK_PROGRAM_ARGS") "")
+  "Arguments passed to the dtk-program.
+Usually SPACE is used to separate arguments, so the following string is
+considered to be a list of 3 arguments:
 
+-v eu -s
+
+In case where SPACE character must be inside an argument, the argument
+separator may be changed. To do this prefix argument string with
+\",<SEP>\". This makes <SEP> the argument separator (could be also SPACE).
+For example this is one argument invocation:
+
+,,C:\\Program Files\\dir
+
+And this is 3 argument invocation, with underline used as the separator:
+
+,_the first arg_the second arg_thethird")
+
 (defvar emacspeak-pronounce-pronunciation-table)
 (defvar emacspeak-ssh-tts-server )
 (defvar emacspeak-auditory-icon-function )
@@ -1712,16 +1727,24 @@
                     dtk-startup-hook emacspeak-servers-directory))
   (let ((new-process nil)
         (process-connection-type  nil)
-        (prog-file-name
-         (if (file-name-absolute-p dtk-program)
-             dtk-program
-           (expand-file-name dtk-program emacspeak-servers-directory))))
-    (setq new-process
-          (start-process
-           "speaker"
-           (and dtk-debug tts-debug-buffer)
-           prog-file-name
-           (or dtk-program-args "")))
+        ;; args-sep separator for program arguments, usually " ", but
+        ;; may be changed using "," prefix for arguments string
+        (arg-sep (if (string-match "^,." dtk-program-args)
+                      (string (aref dtk-program-args 1)) " "))
+        ;; dtk-program-args-2 argument without the optional "," prefix
+        (dtk-program-args-2 (if (string-match "^,." dtk-program-args)
+                               (substring dtk-program-args 2) dtk-program-args))
+        (proc-fun-args (list
+          "speaker"
+          (and dtk-debug tts-debug-buffer)
+          (expand-file-name dtk-program emacspeak-servers-directory))))
+    ;; some characters must be escaped by \\ to be used in regexp
+    (if (string-match "^[$^.[\\]$" arg-sep)
+      (set 'arg-sep (concat "\\" arg-sep)))
+    (if (> (string-width dtk-program-args) 0)
+      (setq proc-fun-args
+        (append proc-fun-args (split-string dtk-program-args-2 arg-sep))))
+    (setq new-process (apply 'start-process proc-fun-args))
     (setq dtk-speak-server-initialized
           (or (eq 'run (process-status new-process ))
               (eq 'open (process-status new-process))))


If you have questions about this archive or had problems using it, please send mail to:

priestdo@cs.vassar.edu No Soliciting!

Emacspeak List Archive | 2010 | 2009 | 2008 | 2007 | 2006 | 2005 | 2004 | 2003 | 2002 | 2001 | 2000 | 1999 | 1998 | Pre 1998

Emacspeak Files | Emacspeak Blog | Search the archive