Subject: Re: bug#17558: 24.4.50; global-subword-mode breaks ERC

From: Lars Magne Ingebrigtsen <[email-masked]>
Date: Sat, 09 Jan 2016 10:04:03 +0100

Dima Kogan <[email-masked]> writes:

> That would be nice, but no. This chunk of code was affected by
> subword-mode in two ways:
>
> 1. (forward-word 1)
> 2. (bounds-of-thing-at-point 'word)
>
> The proposed change only takes care of #1, and I don't see an obvious
> way to make it take care of both. I can do (while (erc-forward-word)
> ...), but then to get the word, I'd need to backtrack to the previous
> word marker, and it's not obvious to me that this would be an
> improvement over the existing change in the patch.
>
> The attached patch thus has no changes to this hunk. Let me know if you
> think of a nicer way to do this.

[...]

> -      (while (forward-word 1)
> -        (setq bounds (bounds-of-thing-at-point 'word))
> -        (setq word (buffer-substring-no-properties
> -                    (car bounds) (cdr bounds)))
> -        (when (or (and (erc-server-buffer-p) (erc-get-server-user word))
> -                  (and erc-channel-users (erc-get-channel-user word)))
> -          (erc-button-add-button (car bounds) (cdr bounds)
> -                                 fun t (list word)))))))
> +
> +      (while
> +          (progn
> +
> +            ;; I move forward a word (independent of subword-mode) ...
> +            (skip-syntax-forward "^w")
> +            (let*
> +                ((word-start (point))
> +                 (word-end
> +                  (progn (skip-syntax-forward "w") (point))))
> +

This still seems very difficult to understand.  The old version has a
clear loop condition

> -      (while (forward-word 1)

while in the new version everything is inside a progn, making it kinda
difficult to follow.  Would it be possible to write a version of
(bounds-of-thing-at-point 'word) that's subword-mode agostic
(erc-word-at-point) to preserve the logic?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no