[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#17558: 24.4.50; global-subword-mode breaks ERC
From: |
Lars Ingebrigtsen |
Subject: |
bug#17558: 24.4.50; global-subword-mode breaks ERC |
Date: |
Sat, 26 Dec 2015 22:46:18 +0100 |
User-agent: |
Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.1.50 (gnu/linux) |
Dima Kogan <dima@secretsauce.net> writes:
> Hi. Can somebody please apply this patch? ERC from HEAD is completely
> broken without it.
I've got a couple of comments about the code...
> (goto-char (point-min))
> - (upcase-word 1)
> +
> + ;; this is (upcase-word 1), but working even with subword-mode
> + ;; active
> + (skip-syntax-forward "^w")
> + (let*
> + ((word-start (point))
> + (word-end
> + (progn (skip-syntax-forward "w") (point))))
> + (upcase-region word-start word-end))
> +
If you had a function `erc-forward-word' that did all the syntax
skipping, you could basically just say
(upcase-region (point) (erc-forward-word))
> - (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))))
> +
> + ;; ... if the word was empty we're at the end of buffer ...
> + (and (/= word-start word-end)
> +
> + ;; ... otherwise, we do stuff with this word
> + (progn
> + (setq word (buffer-substring-no-properties
> + word-start word-end))
> + (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 word-start word-end
> + fun t (list word)))))))))))
Similarly here, you could use that erc-forward-word to avoid rewriting
this code so much. It would be just
(while (erc-forward-word)
(setq bound-stuff ...)
)
Or something. I think.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
- bug#17558: 24.4.50; global-subword-mode breaks ERC,
Lars Ingebrigtsen <=