bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#11134: 24.0.94; Mac's Text to Speech stopped working in emacs buffer


From: Jan Djärv
Subject: bug#11134: 24.0.94; Mac's Text to Speech stopped working in emacs buffers when I moved from Snow Leopard to Lion
Date: Sat, 31 Mar 2012 16:34:56 +0200

31 mar 2012 kl. 02:54 skrev YAMAMOTO Mitsuharu:

>>>>>> On Fri, 30 Mar 2012 14:09:45 -0400, Charles Magid <cmmagid@gmail.com> 
>>>>>> said:
> 
>> 1. On Mac OS X Lion go into system preferences.
>> 2. Click on speach
>> 3. Click on text to speech
>> 4. Check Speak selected text when key is pressed
>> 5. click on change key button and select the button you want to use. I
>> use <Alt-'>
>> 6. Got to emacs and Highlight some text in a buffer
>> 7. press the speech key combo for me <Alt-'>
>> 8. The name of the buffer is spoken not the highlighted text.
> 
>> This worked properly in Snow Leapard.
> 
> Lion's "text to speech" seems to use accessibility that the NS port
> doesn't support yet, and that would explain why the name of the buffer
> is spoken.  If you try the Mac port (*) that has experimental
> accessibility support, the selected text will be spoken (and buffer
> text if no selection).
> 
> 

The NS port does not support accessability at all, but if it is the function 
described by YAMAMOTO Mitsuharu above you want, try the patch below.  As we are 
in feature freeze, a proper checkin will have to wait.

        Jan D.


=== modified file 'src/nsterm.m'
--- src/nsterm.m        2012-02-04 15:10:54 +0000
+++ src/nsterm.m        2012-03-31 14:25:59 +0000
@@ -6034,6 +6034,46 @@
 
 @implementation EmacsWindow
 
+- (id)accessibilityAttributeValue:(NSString *)attribute
+{
+  Lisp_Object str = Qnil;
+
+  if ([attribute isEqualToString:NSAccessibilityRoleAttribute])
+    return NSAccessibilityTextFieldRole;
+
+  if ([attribute isEqualToString:NSAccessibilitySelectedTextAttribute] &&
+      ! NILP (BVAR (current_buffer, mark_active)))
+    {
+      str = ns_get_local_selection (QPRIMARY, QUTF8_STRING);
+    }
+  else if ([attribute isEqualToString:NSAccessibilityValueAttribute])
+    {
+      if (! NILP (BVAR (current_buffer, mark_active)))
+        str = ns_get_local_selection (QPRIMARY, QUTF8_STRING);
+      if (NILP (str))
+        str = Fbuffer_string ();
+    }
+  
+  
+  if (! NILP (str)) 
+    {
+      if (CONSP (str) && SYMBOLP (XCAR (str)))
+        {
+          str = XCDR (str);
+          if (CONSP (str) && NILP (XCDR (str)))
+            str = XCAR (str);
+        }
+      if (STRINGP (str))
+        {
+          char *utfStr = SSDATA (str);
+          NSString *nsStr = [NSString stringWithUTF8String: utfStr];
+          return nsStr;
+        }
+    }
+  
+  return [super accessibilityAttributeValue:attribute];
+}
+
 /* If we have multiple monitors, one above the other, we don't want to
    restrict the height to just one monitor.  So we override this.  */
 - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen







reply via email to

[Prev in Thread] Current Thread [Next in Thread]