aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDima Kogan2016-02-04 14:24:18 +1100
committerLars Ingebrigtsen2016-02-04 14:24:18 +1100
commit66b315c9c94c871de2c70b92ac69ef86f19d8a2f (patch)
treed239619098b1d7d137ec7eb2b18da6a7314d6049
parent255b68f00ba74dbe2f6014b38cf17c8390be6561 (diff)
downloademacs-66b315c9c94c871de2c70b92ac69ef86f19d8a2f.tar.gz
emacs-66b315c9c94c871de2c70b92ac69ef86f19d8a2f.zip
Make erc work when subword-mode is switched on
* lisp/erc/erc-backend.el (erc-forward-word, erc-word-at-arg-p) (erc-bounds-of-word-at-point): New functions to do word-based things when subword-mode is switched on. * lisp/erc/erc-button.el (erc-button-add-nickname-buttons): Use them (bug#17558).
-rw-r--r--lisp/erc/erc-backend.el28
-rw-r--r--lisp/erc/erc-button.el16
2 files changed, 35 insertions, 9 deletions
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index 694f66eb050..6d508e203f4 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -474,13 +474,39 @@ Currently this is called by `erc-send-input'."
474 nil t)) 474 nil t))
475 (split-string (buffer-string) "\n")))) 475 (split-string (buffer-string) "\n"))))
476 476
477(defun erc-forward-word ()
478 "Moves forward one word, ignoring any subword settings. If no
479subword-mode is active, then this is (forward-word)."
480 (skip-syntax-forward "^w")
481 (> (skip-syntax-forward "w") 0))
482
483(defun erc-word-at-arg-p (pos)
484 "Reports whether the char after a given POS has word syntax.
485If POS is out of range, the value is nil."
486 (let ((c (char-after pos)))
487 (if c
488 (eq ?w (char-syntax c))
489 nil)))
490
491(defun erc-bounds-of-word-at-point ()
492 "Returns the bounds of a word at point, or nil if we're not at
493a word. If no subword-mode is active, then this
494is (bounds-of-thing-at-point 'word)."
495 (if (or (erc-word-at-arg-p (point))
496 (erc-word-at-arg-p (1- (point))))
497 (save-excursion
498 (let* ((start (progn (skip-syntax-backward "w") (point)))
499 (end (progn (skip-syntax-forward "w") (point))))
500 (cons start end)))
501 nil))
502
477;; Used by CTCP functions 503;; Used by CTCP functions
478(defun erc-upcase-first-word (str) 504(defun erc-upcase-first-word (str)
479 "Upcase the first word in STR." 505 "Upcase the first word in STR."
480 (with-temp-buffer 506 (with-temp-buffer
481 (insert str) 507 (insert str)
482 (goto-char (point-min)) 508 (goto-char (point-min))
483 (upcase-word 1) 509 (upcase-region (point) (progn (erc-forward-word) (point)))
484 (buffer-string))) 510 (buffer-string)))
485 511
486(defun erc-server-setup-periodical-ping (buffer) 512(defun erc-server-setup-periodical-ping (buffer)
diff --git a/lisp/erc/erc-button.el b/lisp/erc/erc-button.el
index e1ccea90dd1..7d509196330 100644
--- a/lisp/erc/erc-button.el
+++ b/lisp/erc/erc-button.el
@@ -300,14 +300,14 @@ specified by `erc-button-alist'."
300 (when (or (eq t form) 300 (when (or (eq t form)
301 (eval form)) 301 (eval form))
302 (goto-char (point-min)) 302 (goto-char (point-min))
303 (while (forward-word 1) 303 (while (erc-forward-word)
304 (setq bounds (bounds-of-thing-at-point 'word)) 304 (when (setq bounds (erc-bounds-of-word-at-point))
305 (setq word (buffer-substring-no-properties 305 (setq word (buffer-substring-no-properties
306 (car bounds) (cdr bounds))) 306 (car bounds) (cdr bounds)))
307 (when (or (and (erc-server-buffer-p) (erc-get-server-user word)) 307 (when (or (and (erc-server-buffer-p) (erc-get-server-user word))
308 (and erc-channel-users (erc-get-channel-user word))) 308 (and erc-channel-users (erc-get-channel-user word)))
309 (erc-button-add-button (car bounds) (cdr bounds) 309 (erc-button-add-button (car bounds) (cdr bounds)
310 fun t (list word))))))) 310 fun t (list word))))))))
311 311
312(defun erc-button-add-buttons-1 (regexp entry) 312(defun erc-button-add-buttons-1 (regexp entry)
313 "Search through the buffer for matches to ENTRY and add buttons." 313 "Search through the buffer for matches to ENTRY and add buttons."