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

Patch: Allow Emacspeak to work with 8-bit characters



坂本です。

さっき渡辺さんと井上さんあてに送った(つもり?)なのですが、贈れてないかも
知れないので、こちらにも贈ります。

どうもタイトルのようなパッチが本家で流れているようです。
これって、emacspeakをマルチバイト対応にするパッチですよね?


In the Free-b-software project, we have problems with handling 8-bit
characters in Emacspeak.  I suggest the following patch (attached below)
to solve the problems.

The patch does basically the following things:

- It defines a new variable `emacspeak-unibyte-p' that is initially set
  to nil if your language environment is English or to t otherwise.

- Depending on the value of the variable, Emacs tries to work in either
  unibyte with 8-bit characters disabled (as it did before) or in
  multibyte handling the 8-bit characters properly.

With that patch, you should be able to run Emacspeak in the multibyte
mode with your 8-bit language environment without problems.  The only
problem I know of is that if you're using a system keyboard (not the
Emacs one based on Quail), then Emacspeak speaks the 8-bit character
being input in its octal representation.

Note: To run Emacspeak in the 8-bit mode, it's necessary NOT to run it
via the `emacspeak' shell script or you must run the script with the
`--multibyte' option.
diff -cr emacspeak-14.0.orig/lisp/dtk-tcl.el emacspeak-14.0/lisp/dtk-tcl.el
*** emacspeak-14.0.orig/lisp/dtk-tcl.el	Fri May  4 16:36:43 2001
--- emacspeak-14.0/lisp/dtk-tcl.el	Wed Jun 13 21:37:21 2001
***************
*** 301,307 ****
    "Handle control characters in speech stream."
    (declare (special dtk-character-to-speech-table
                      dtk-speak-nonprinting-chars))
!   (let ((specials "[\000-\037\177-\377]")
          (char nil))
      (goto-char (point-min ))
      (when  dtk-speak-nonprinting-chars
--- 301,309 ----
    "Handle control characters in speech stream."
    (declare (special dtk-character-to-speech-table
                      dtk-speak-nonprinting-chars))
!   (let ((specials (if emacspeak-unibyte-p
! 		      "[\000-\037\177-\377]"
! 		    "[\000-\037]"))
          (char nil))
      (goto-char (point-min ))
      (when  dtk-speak-nonprinting-chars
diff -cr emacspeak-14.0.orig/lisp/emacspeak-advice.el emacspeak-14.0/lisp/emacspeak-advice.el
*** emacspeak-14.0.orig/lisp/emacspeak-advice.el	Fri May  4 16:36:43 2001
--- emacspeak-14.0/lisp/emacspeak-advice.el	Wed Jun 13 23:49:53 2001
***************
*** 825,839 ****
                             (dtk-speak (format "%s" ad-return-value)))
      ad-return-value))
  
  (defadvice read-key-sequence(around emacspeak pre act )
    "Prompt using speech as well. "
!   (let ((prompt (ad-get-arg 0)))
!     (when prompt
        (tts-with-punctuations "all"
                               (dtk-speak prompt)))
      ad-do-it
!     (tts-with-punctuations "all"
!                            (dtk-speak (format "%s" ad-return-value)))
      ad-return-value))
  
  (defadvice read-string(around emacspeak pre act )
--- 825,842 ----
                             (dtk-speak (format "%s" ad-return-value)))
      ad-return-value))
  
+ (defvar quail-translating nil)
  (defadvice read-key-sequence(around emacspeak pre act )
    "Prompt using speech as well. "
!   (let ((prompt (ad-get-arg 0))
! 	(in-quail-p quail-translating))
!     (when (and prompt (not in-quail-p))
        (tts-with-punctuations "all"
                               (dtk-speak prompt)))
      ad-do-it
!     (unless in-quail-p
!       (tts-with-punctuations "all"
! 			     (dtk-speak (format "%s" ad-return-value))))
      ad-return-value))
  
  (defadvice read-string(around emacspeak pre act )
diff -cr emacspeak-14.0.orig/lisp/emacspeak.el emacspeak-14.0/lisp/emacspeak.el
*** emacspeak-14.0.orig/lisp/emacspeak.el	Fri May  4 16:36:59 2001
--- emacspeak-14.0/lisp/emacspeak.el	Wed Jun 13 21:39:24 2001
***************
*** 87,92 ****
--- 87,97 ----
  (defvar emacspeak-startup-hook nil
    "Hook to run after starting emacspeak." )
  
+ (defvar emacspeak-unibyte-p (string= (downcase current-language-environment)
+ 				     "english")
+   "If non-nil, Emacspeak will use unibyte mode.
+ It also won't send non-ASCII characters to the speach device directly.")
+ 
  ;;}}}
  ;;{{{ Emacspeak:
  
***************
*** 262,267 ****
--- 267,274 ----
                      emacspeak-play-program
                      emacspeak-sounds-directory
                      emacspeak-emacs-commands-to-fix))
+   ;; set unibyte or multibyte
+   (setq default-enable-multibyte-characters (not emacspeak-unibyte-p))
    (emacspeak-export-environment)
    (require 'dtk-speak)
    (dtk-initialize)
***************
*** 282,289 ****
            emacspeak-emacs-commands-to-fix)
    (run-hooks 'emacspeak-startup-hook)
    (emacspeak-dtk-sync)
-     ;;; force unibyte
-   (setq default-enable-multibyte-characters nil)
    (emacspeak-setup-programming-modes)
    (message
     (format "  Press %s to get an   overview of emacspeak  %s \
--- 289,294 ----
***************
*** 618,624 ****
    (declare (special emacspeak-directory
                      emacspeak-play-program
                      emacspeak-sounds-directory))
!   (setenv "EMACS_UNIBYTE" "1")
    (setenv "EMACSPEAK_DIR" emacspeak-directory)
    (setenv "EMACSPEAK_SOUNDS_DIR" emacspeak-sounds-directory)
    (setenv "EMACSPEAK_PLAY_PROGRAM" emacspeak-play-program)
--- 623,630 ----
    (declare (special emacspeak-directory
                      emacspeak-play-program
                      emacspeak-sounds-directory))
!   (when emacspeak-unibyte-p
!     (setenv "EMACS_UNIBYTE" "1"))
    (setenv "EMACSPEAK_DIR" emacspeak-directory)
    (setenv "EMACSPEAK_SOUNDS_DIR" emacspeak-sounds-directory)
    (setenv "EMACSPEAK_PLAY_PROGRAM" emacspeak-play-program)

Milan Zamazal

-- 
When you're in a fight with an idiot, it's difficult for other people to tell
which one the idiot is.                       -- Bruce Perens in debian-devel




this patch does not solve the underlying reason why 
emacspeak goes through the trouble of making sure the user
doesn't run emacs in multibyte mode.

1) TTS engines barf on multibyte input  at present.
2) There are portions of emacspeak s own 
internals (modules emacspeak-speak.el, dtk-speak.el and
dtk-tcl.el)
that have unibyte dependencies  

Without the above being fixed --(and I dont plan to spend
energy fixing 2 while there is no solution to 1)--
there is no point in allowing the average user to run emacspeak
under multibyte emacs.

For cases where the user actually knows what he is doing,
e.g., Japanese Emacspeak --which I assumes handles
multibyte,
I expect  that those versions will invoke emacs in multibyte
mode.

So the patch below is mostly meaningless since all it does
is to carefully undo the protection that was put into
emacspeak to avoid problems mentioned with running speech
with multibyte.

>>>>> "Milan" == Milan Zamazal <pdm@...> writes:

    Milan> In the Free-b-software project, we have problems
    Milan> with handling 8-bit characters in Emacspeak.  I
    Milan> suggest the following patch (attached below) to
    Milan> solve the problems.

    Milan> The patch does basically the following things:

    Milan> - It defines a new variable `emacspeak-unibyte-p'
    Milan> that is initially set to nil if your language
    Milan> environment is English or to t otherwise.

    Milan> - Depending on the value of the variable, Emacs
    Milan> tries to work in either unibyte with 8-bit
    Milan> characters disabled (as it did before) or in
    Milan> multibyte handling the 8-bit characters properly.

    Milan> With that patch, you should be able to run
    Milan> Emacspeak in the multibyte mode with your 8-bit
    Milan> language environment without problems.  The only
    Milan> problem I know of is that if you're using a
    Milan> system keyboard (not the Emacs one based on
    Milan> Quail), then Emacspeak speaks the 8-bit character
    Milan> being input in its octal representation.

    Milan> Note: To run Emacspeak in the 8-bit mode, it's
    Milan> necessary NOT to run it via the `emacspeak' shell
    Milan> script or you must run the script with the
    Milan> `--multibyte' option.

    Milan> diff -cr emacspeak-14.0.orig/lisp/dtk-tcl.el
    Milan> emacspeak-14.0/lisp/dtk-tcl.el ***
    Milan> emacspeak-14.0.orig/lisp/dtk-tcl.el Fri May 4
    Milan> 16:36:43 2001 --- emacspeak-14.0/lisp/dtk-tcl.el
    Milan> Wed Jun 13 21:37:21 2001 *************** ***
    Milan> 301,307 **** "Handle control characters in speech
    Milan> stream."  (declare (special
    Milan> dtk-character-to-speech-table
    Milan> dtk-speak-nonprinting-chars)) !  (let ((specials
    Milan> "[\000-\037\177-\377]") (char nil)) (goto-char
    Milan> (point-min )) (when dtk-speak-nonprinting-chars
    Milan> --- 301,309 ---- "Handle control characters in
    Milan> speech stream."  (declare (special
    Milan> dtk-character-to-speech-table
    Milan> dtk-speak-nonprinting-chars)) !  (let ((specials
    Milan> (if emacspeak-unibyte-p !  "[\000-\037\177-\377]"
    Milan> !  "[\000-\037]")) (char nil)) (goto-char
    Milan> (point-min )) (when dtk-speak-nonprinting-chars
    Milan> diff -cr
    Milan> emacspeak-14.0.orig/lisp/emacspeak-advice.el
    Milan> emacspeak-14.0/lisp/emacspeak-advice.el ***
    Milan> emacspeak-14.0.orig/lisp/emacspeak-advice.el Fri
    Milan> May 4 16:36:43 2001 ---
    Milan> emacspeak-14.0/lisp/emacspeak-advice.el Wed Jun
    Milan> 13 23:49:53 2001 *************** *** 825,839 ****
    Milan> (dtk-speak (format "%s" ad-return-value)))
    Milan> ad-return-value))
  
    Milan>   (defadvice read-key-sequence(around emacspeak
    Milan> pre act ) "Prompt using speech as well. " !  (let
    Milan> ((prompt (ad-get-arg 0))) !  (when prompt
    Milan> (tts-with-punctuations "all" (dtk-speak prompt)))
    Milan> ad-do-it !  (tts-with-punctuations "all" !
    Milan> (dtk-speak (format "%s" ad-return-value)))
    Milan> ad-return-value))
  
    Milan>   (defadvice read-string(around emacspeak pre act
    Milan> ) --- 825,842 ---- (dtk-speak (format "%s"
    Milan> ad-return-value))) ad-return-value))
  
    Milan> + (defvar quail-translating nil) (defadvice
    Milan> read-key-sequence(around emacspeak pre act )
    Milan> "Prompt using speech as well. " !  (let ((prompt
    Milan> (ad-get-arg 0)) !  (in-quail-p
    Milan> quail-translating)) !  (when (and prompt (not
    Milan> in-quail-p)) (tts-with-punctuations "all"
    Milan> (dtk-speak prompt))) ad-do-it !  (unless
    Milan> in-quail-p !  (tts-with-punctuations "all" !
    Milan> (dtk-speak (format "%s" ad-return-value))))
    Milan> ad-return-value))
  
    Milan>   (defadvice read-string(around emacspeak pre act
    Milan> ) diff -cr emacspeak-14.0.orig/lisp/emacspeak.el
    Milan> emacspeak-14.0/lisp/emacspeak.el ***
    Milan> emacspeak-14.0.orig/lisp/emacspeak.el Fri May 4
    Milan> 16:36:59 2001 ---
    Milan> emacspeak-14.0/lisp/emacspeak.el Wed Jun 13
    Milan> 21:39:24 2001 *************** *** 87,92 **** ---
    Milan> 87,97 ---- (defvar emacspeak-startup-hook nil
    Milan> "Hook to run after starting emacspeak." )
  
    Milan> + (defvar emacspeak-unibyte-p (string= (downcase
    Milan> current-language-environment) + "english") + "If
    Milan> non-nil, Emacspeak will use unibyte mode.  + It
    Milan> also won't send non-ASCII characters to the
    Milan> speach device directly.")  + ;;}}} ;;{{{
    Milan> Emacspeak:
  
    Milan> *************** *** 262,267 **** --- 267,274 ----
    Milan> emacspeak-play-program emacspeak-sounds-directory
    Milan> emacspeak-emacs-commands-to-fix)) + ;; set
    Milan> unibyte or multibyte + (setq
    Milan> default-enable-multibyte-characters (not
    Milan> emacspeak-unibyte-p))
    Milan> (emacspeak-export-environment) (require
    Milan> 'dtk-speak) (dtk-initialize) *************** ***
    Milan> 282,289 **** emacspeak-emacs-commands-to-fix)
    Milan> (run-hooks 'emacspeak-startup-hook)
    Milan> (emacspeak-dtk-sync) - ;;; force unibyte - (setq
    Milan> default-enable-multibyte-characters nil)
    Milan> (emacspeak-setup-programming-modes) (message
    Milan> (format " Press %s to get an overview of
    Milan> emacspeak %s \ --- 289,294 ---- ***************
    Milan> *** 618,624 **** (declare (special
    Milan> emacspeak-directory emacspeak-play-program
    Milan> emacspeak-sounds-directory)) !  (setenv
    Milan> "EMACS_UNIBYTE" "1") (setenv "EMACSPEAK_DIR"
    Milan> emacspeak-directory) (setenv
    Milan> "EMACSPEAK_SOUNDS_DIR"
    Milan> emacspeak-sounds-directory) (setenv
    Milan> "EMACSPEAK_PLAY_PROGRAM" emacspeak-play-program)
    Milan> --- 623,630 ---- (declare (special
    Milan> emacspeak-directory emacspeak-play-program
    Milan> emacspeak-sounds-directory)) !  (when
    Milan> emacspeak-unibyte-p !  (setenv "EMACS_UNIBYTE"
    Milan> "1")) (setenv "EMACSPEAK_DIR"
    Milan> emacspeak-directory) (setenv
    Milan> "EMACSPEAK_SOUNDS_DIR"
    Milan> emacspeak-sounds-directory) (setenv
    Milan> "EMACSPEAK_PLAY_PROGRAM" emacspeak-play-program)

    Milan> Milan Zamazal

    Milan> -- When you're in a fight with an idiot, it's
    Milan> difficult for other people to tell which one the
    Milan> idiot is.  -- Bruce Perens in debian-devel

-- 
Best Regards,
--raman

      
Email:  raman@...
WWW: http://www.cs.cornell.edu/home/raman/             
PGP:    http://www.cs.cornell.edu/home/raman/raman.asc 

-----------------------------------------------------------------------------
To unsubscribe from the emacspeak list or change your address on the
emacspeak list send mail to "emacspeak-request@cs.vassar.edu" with a
subject of "unsubscribe" or "help"