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

A Possible Fix for emacspeak-jabber.el



Hi,
I looked around at the emacspeak-jabber.el file, because the latest changes (which were done per my suggestion) didn’t fix anything. It turns out I was wrong, and I verified it by playing around.
First of all, sorry for the wrong information – I know T.V. Raman committed that change based on what I said, and I was wrong.
Here is the thing. The call to (next-single-property-change (point) ‘face) returns `nil` when the current message is the last message. Also, (goto-char) doesn’t expect nil as its argument, hence the error about the argument not being a marker or an integer.
I’m not really sure why the calls for `goto-char` are there, considering that as I understand this, `save-excursion` will revert the cursor to where it was anyway. 
So, what I did was the following:
- I removed all the `goto-char` calls, making the code a bit simpler.
- I added two ways of finding out the `end` variable: if the face changes, great. If not, search for `\n---\n`, and then you’ll get the end of the message.
- This makes the condition that has been added to the end of the defun a bit obsolete, so I removed it, Also, the message i previously suggested (“No more messages to speak”) is technically not correct, because this function gets called when speaking the previous message, the current message, and the next message. So, it’s weird when I press M-SPC (bound to emacspeak-jabber-speak-current-message) and hear, “No more messages to speak.”.
The changed function also fixes another error I was facing, namely the fact that I was pressing M-SPC and I wasn’t hearing anything. This now correctly reads the current message, no matter where I am.
I believe the point where we do something when the current message is the first or the last message should be handled in `emacspeak-jabber-chat-previous-message` and `emacspeak-jabber-chat-next-message` respectively. Each of them has a line like `(re-search-backward "^\\["nil t)` and `(re-search-forward "^\\["nil t)`. Simply checking if these return `nil` tells us if there is a message to be spoken in the first place.
I’m not sure how to handle those cases (do we want to play a sound? Speak a message? Play a sound and keep the current behavior which is re-speak the first/last message?) So I didn’t change those two functions. However, i changed emacspeak-jabber-speak-current-message which fixes the bugs I mentioned.
So, here is my revised copy of this defun. Please give me feedback, or improve it if you find anything I could do better – I’m an elisp beginner. :-)
(defun emacspeak-jabber-chat-speak-this-message ()
  "Speaks message starting on current line.
Assumes point is at the front of the message.
Returns a cons (start . end) that delimits the message."
  (interactive)
  (unless (eq major-mode 'jabber-chat-mode)
    (error "Not in a Jabber chat buffer."))
  (let ((start nil)
        (end nil))
    (save-excursion
      (unless (looking-at "^\\[")
        (re-search-backward "^\\[" nil t))
      (setq start
            (next-single-property-change (point) 'face))

      (setq end
            (next-single-property-change (point) 'face))
      (unless end
        (search-forward "\n---\n")
        (setq end (match-beginning 0)))

      (emacspeak-speak-region start end)
        (cons start end))))


|All Past Years |Current Year|


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

Contact Info Page