Function: rcirc-completion-at-point

rcirc-completion-at-point is a byte-compiled function defined in rcirc.el.gz.

Signature

(rcirc-completion-at-point)

Documentation

Function used for completion-at-point-functions in rcirc-mode.

Source Code

;; Defined in /usr/src/emacs/lisp/net/rcirc.el.gz
(defun rcirc-completion-at-point ()
  "Function used for `completion-at-point-functions' in `rcirc-mode'."
  (and (rcirc-looking-at-input)
       (let* ((beg (save-excursion
                     ;; On some networks it is common to message or
                     ;; mention someone using @nick instead of just
                     ;; nick.
		     (if (re-search-backward "[[:space:]@]" rcirc-prompt-end-marker t)
			 (1+ (point))
		       rcirc-prompt-end-marker)))
	      (table (cond
                      ;; No completion before the prompt
                      ((< beg rcirc-prompt-end-marker) nil)
                      ;; Only complete nicks mid-message
                      ((> beg rcirc-prompt-end-marker)
                       (mapcar rcirc-nick-filter
                               (rcirc-channel-nicks
                                (rcirc-buffer-process)
				rcirc-target)))
                      ;; Complete commands at the beginning of the
                      ;; message, when the first character is a dash
                      ((eq (char-after beg) ?/)
                       (mapcar
                        (lambda (cmd) (concat cmd " "))
                        (nconc (sort (copy-sequence rcirc-client-commands)
				     'string-lessp)
			       (sort (copy-sequence rcirc-server-commands)
				     'string-lessp))))
                      ;; Complete usernames right after the prompt by
                      ;; appending a colon after the name
                      ((mapcar
                        (lambda (str) (concat (funcall rcirc-nick-filter str) ": "))
                        (rcirc-channel-nicks (rcirc-buffer-process)
					     rcirc-target))))))
	 (list beg (point)
               (lambda (str pred action)
                 (if (eq action 'metadata)
                     '(metadata (cycle-sort-function . identity))
                   (complete-with-action action table str pred)))))))