unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Dima Kogan <dima@secretsauce.net>
Cc: 17558@debbugs.gnu.org
Subject: bug#17558: 24.4.50; global-subword-mode breaks ERC
Date: Thu, 01 Jan 2015 11:42:56 -0500	[thread overview]
Message-ID: <jwv8uhma26x.fsf-monnier+emacsbugs@gnu.org> (raw)
In-Reply-To: <87a924mbuk.fsf@secretsauce.net> (Dima Kogan's message of "Wed, 31 Dec 2014 01:01:35 -0800")

>> Thanks for the repro. This bug is probably due to my changing how
>> subword-mode works: now, forward-word will stop at subword boundaries,
>> and I'm guessing ERC was relying on the old behavior. I can try to take
>> a look at it if nobody who knows ERC better wants to try first.

Indeed, with the new implementation of subword-mode, most of the
word-operating commands should be marked as "interactive use only",
since their behavior is too unreliable for use in Lisp code.

> -    (upcase-word 1)
> +
> +    ;; If we're in subword-mode then functions operating on words act
> +    ;; differently. Here I temporarily disable subword-mode before
> +    ;; touching the words
> +    (let ((find-word-boundary-function-table
> +           (if (boundp 'subword-empty-char-table)
> +               subword-empty-char-table find-word-boundary-function-table)))
> +      (upcase-word 1))

Yuck.  I suggest you use upcase-region instead (and probably something
like skip-char-forward to find the word's boundaries).

> -      (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)))))))
> +
> +      ;; If we're in subword-mode then functions operating on words
> +      ;; act differently. Here I temporarily disable subword-mode
> +      ;; before touching the words
> +      (let ((find-word-boundary-function-table
> +             (if (boundp 'subword-empty-char-table)
> +                 subword-empty-char-table find-word-boundary-function-table)))
> +        (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))))))))
 
Similarly here, we should use "word" operations at all.
Maybe forward-sexp can be used instead of forward-word, or else
skip-syntax-forward or skip-chars-forward.

The call to (bounds-of-thing-at-point 'word) should be avoided as well
(we already know the end of the bounds is (point) anyway and we can
probably find the other bound at the same time as we skip-chars-forward.


        Stefan





  reply	other threads:[~2015-01-01 16:42 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-23  9:19 bug#17558: 24.4.50; global-subword-mode breaks ERC Dima Kogan
2014-05-23 20:51 ` Daniel Colascione
2014-12-31  8:46   ` Dima Kogan
2014-12-31  9:01   ` Dima Kogan
2015-01-01 16:42     ` Stefan Monnier [this message]
2015-01-01 21:47       ` Dima Kogan
2015-04-27 20:03       ` Glenn Morris
2015-04-27 22:31         ` Daniel Colascione
2015-04-27 23:24           ` Drew Adams
2015-04-27 23:30             ` Daniel Colascione
2015-04-27 23:59               ` Drew Adams
2015-04-28 16:50           ` Glenn Morris
2015-04-29  1:50             ` Stefan Monnier
2015-04-29  2:31             ` Daniel Colascione
2015-07-15  3:37               ` Dima Kogan
2015-12-26 21:46                 ` Lars Ingebrigtsen
2015-12-27 21:16                   ` Dima Kogan
2015-12-27 21:38                     ` Lars Ingebrigtsen
2016-01-08 18:54                   ` Dima Kogan
2016-01-09  9:04                     ` Lars Magne Ingebrigtsen
2016-01-09 18:14                       ` Dima Kogan
2016-01-26  8:07                         ` Dima Kogan
2016-02-04  3:21                         ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv8uhma26x.fsf-monnier+emacsbugs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=17558@debbugs.gnu.org \
    --cc=dima@secretsauce.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).