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

Patch: emacspeak-jabber.el



Hi,
I’m going to paste the patch at the end of this email. First, though, I’m going to give a brief explanation of my changes:
1. I assumed that we want to play the ‘warn-user’ sound icon and re-read the first/last message when there are no more messages to speak.
2. I forced the cursor to go to the beginning of the message, no matter which way we’re moving (i.e. it used to go to the end of the  message when reading the next message). This serves two purposes. First, you can always assume that you’re on the beginning of a message, which means you can confidently set the mark or start reading. Secondly, it fixes a bug where lines saying “Person <JID> has joined/left the chatroom.” messed up the previous/next message navigation, and made the current message be read twice (I can provide steps to reproduce if required).
3. I removed the calls to `goto-char` where I thought it’s not required.

Remember, to apply this patch use `git apply`, because it’s been created with git:

diff --git a/lisp/emacspeak-jabber.el b/lisp/emacspeak-jabber.el
index 5197ab2f1..3f28ef5d6 100644
--- a/lisp/emacspeak-jabber.el
+++ b/lisp/emacspeak-jabber.el
@@ -242,28 +242,34 @@ Return nil if no message at point."
       (unless (looking-at "^\\[")
         (re-search-backward "^\\[" nil t))
       (setq start
-            (goto-char
-             (next-single-property-change (point) 'face)))
+            (next-single-property-change (point) 'face))
+
       (setq end
-            (goto-char
-             (next-single-property-change (point) 'face)))
+            (next-single-property-change start 'face))
+      (unless end
+        (search-forward "\n---\n")
+        (setq end (match-beginning 0)))
+
       (cond
        ((and start end)
         (emacspeak-speak-region start end)
         (cons start end))
-       (t (message "No more messages to speak")
-          nil)))))
+       (t
+      nil)))))
 
 (defun emacspeak-jabber-chat-next-message ()
   "Move forward to and speak the next message in this chat session."
   (interactive)
   (unless (eq major-mode 'jabber-chat-mode)
     (error "Not in a Jabber chat buffer."))
-  (re-search-forward "^\\["nil t)
-  (let ((extent (emacspeak-jabber-chat-speak-this-message)))
-    (emacspeak-auditory-icon 'large-movement)
+  (let (extent)
+    (if (re-search-forward "^\\["nil t)
+        (emacspeak-auditory-icon 'large-movement)
+      (emacspeak-auditory-icon 'warn-user))
+
+    (setq extent (emacspeak-jabber-chat-speak-this-message))
     (when extent
-      (goto-char (cdr extent)))))
+      (goto-char (car extent)))))
 
 (defun emacspeak-jabber-chat-previous-message ()
   "Move backward to and speak the previous message in this chat
@@ -271,11 +277,15 @@ session."
   (interactive)
   (unless (eq major-mode 'jabber-chat-mode)
     (error "Not in a Jabber chat buffer."))
-  (forward-line 0)
-  (re-search-backward "^\\["nil t)
-  (let ((extent (emacspeak-jabber-chat-speak-this-message)))
-    (emacspeak-auditory-icon 'large-movement)
-    (goto-char (car extent))))
+  (let (extent)
+    (forward-line 0)
+    (if (re-search-backward "^\\["nil t)
+        (emacspeak-auditory-icon 'large-movement)
+      (emacspeak-auditory-icon 'warn-user))
+
+    (setq extent (emacspeak-jabber-chat-speak-this-message))
+    (when extent
+      (goto-char (car extent)))))
 
 (when (boundp 'jabber-chat-mode-map)
   (cl-loop for k in



|All Past Years |Current Year|


If you have questions about this archive or had problems using it, please contact us.

Contact Info Page