summaryrefslogtreecommitdiff
path: root/lisp/erc
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/erc')
-rw-r--r--lisp/erc/erc-backend.el28
-rw-r--r--lisp/erc/erc-button.el16
-rw-r--r--lisp/erc/erc-pcomplete.el8
-rw-r--r--lisp/erc/erc-track.el3
-rw-r--r--lisp/erc/erc.el21
5 files changed, 57 insertions, 19 deletions
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index 4a2a12dd403..b413ee5a547 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'."
nil t))
(split-string (buffer-string) "\n"))))
+(defun erc-forward-word ()
+ "Moves forward one word, ignoring any subword settings. If no
+subword-mode is active, then this is (forward-word)."
+ (skip-syntax-forward "^w")
+ (> (skip-syntax-forward "w") 0))
+
+(defun erc-word-at-arg-p (pos)
+ "Reports whether the char after a given POS has word syntax.
+If POS is out of range, the value is nil."
+ (let ((c (char-after pos)))
+ (if c
+ (eq ?w (char-syntax c))
+ nil)))
+
+(defun erc-bounds-of-word-at-point ()
+ "Returns the bounds of a word at point, or nil if we're not at
+a word. If no subword-mode is active, then this
+is (bounds-of-thing-at-point 'word)."
+ (if (or (erc-word-at-arg-p (point))
+ (erc-word-at-arg-p (1- (point))))
+ (save-excursion
+ (let* ((start (progn (skip-syntax-backward "w") (point)))
+ (end (progn (skip-syntax-forward "w") (point))))
+ (cons start end)))
+ nil))
+
;; Used by CTCP functions
(defun erc-upcase-first-word (str)
"Upcase the first word in STR."
(with-temp-buffer
(insert str)
(goto-char (point-min))
- (upcase-word 1)
+ (upcase-region (point) (progn (erc-forward-word) (point)))
(buffer-string)))
(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'."
(when (or (eq t form)
(eval form))
(goto-char (point-min))
- (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 (erc-forward-word)
+ (when (setq bounds (erc-bounds-of-word-at-point))
+ (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))))))))
(defun erc-button-add-buttons-1 (regexp entry)
"Search through the buffer for matches to ENTRY and add buttons."
diff --git a/lisp/erc/erc-pcomplete.el b/lisp/erc/erc-pcomplete.el
index cf3f51ba3f6..9f572396de8 100644
--- a/lisp/erc/erc-pcomplete.el
+++ b/lisp/erc/erc-pcomplete.el
@@ -238,10 +238,12 @@ If optional argument IGNORE-SELF is non-nil, don't return the current nick."
"Returns a list of all nicks on the current server."
(let (nicks)
(erc-with-server-buffer
- (maphash (lambda (nick _user)
- (setq nicks (cons (concat nick postfix) nicks)))
+ (maphash (lambda (_nick user)
+ (setq nicks (cons
+ (concat (erc-server-user-nickname user) postfix)
+ nicks)))
erc-server-users))
- nicks))
+ nicks))
(defun pcomplete-erc-channels ()
"Returns a list of channels associated with the current server."
diff --git a/lisp/erc/erc-track.el b/lisp/erc/erc-track.el
index 1750cb77845..4d8feb52759 100644
--- a/lisp/erc/erc-track.el
+++ b/lisp/erc/erc-track.el
@@ -971,7 +971,8 @@ is in `erc-mode'."
"Return a list of all faces used in STR."
(let ((i 0)
(m (length str))
- (faces (erc-list (get-text-property 0 'face str)))
+ (faces (let ((face1 (get-text-property 0 'face str)))
+ (when face1 (list face1))))
cur)
(while (and (setq i (next-single-property-change i 'face str m))
(not (= i m)))
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index b7f40a878a9..98ea594e164 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -1141,7 +1141,7 @@ which the local user typed."
(define-key map "\C-c\C-u" 'erc-kill-input)
(define-key map "\C-c\C-x" 'erc-quit-server)
(define-key map "\M-\t" 'ispell-complete-word)
- (define-key map "\t" 'completion-at-point)
+ (define-key map "\t" 'erc-completion-at-point)
;; Suppress `font-lock-fontify-block' key binding since it
;; destroys face properties.
@@ -3996,6 +3996,13 @@ Prompt for one if called interactively."
(format "MODE %s +k %s" tgt key)
(format "MODE %s -k" tgt)))))
+(defun erc-completion-at-point ()
+ "Perform complection on the text around point case-insentitively.
+See `completion-at-point'."
+ (interactive)
+ (let ((completion-ignore-case t))
+ (completion-at-point)))
+
(defun erc-quit-server (reason)
"Disconnect from current server after prompting for REASON.
`erc-quit-reason' works with this just like with `erc-cmd-QUIT'."
@@ -6088,13 +6095,15 @@ If it doesn't exist, create it."
(or (file-accessible-directory-p dir) (error "Cannot access %s" dir)))
(defun erc-kill-query-buffers (process)
- "Kill all buffers of PROCESS."
+ "Kill all buffers of PROCESS.
+Does nothing if PROCESS is not a process object."
;; here, we only want to match the channel buffers, to avoid
;; "selecting killed buffers" b0rkage.
- (erc-with-all-buffers-of-server process
- (lambda ()
- (not (erc-server-buffer-p)))
- (kill-buffer (current-buffer))))
+ (when (processp process)
+ (erc-with-all-buffers-of-server process
+ (lambda ()
+ (not (erc-server-buffer-p)))
+ (kill-buffer (current-buffer)))))
(defun erc-nick-at-point ()
"Give information about the nickname at `point'.