Function: rcirc-format-response-string

rcirc-format-response-string is a byte-compiled function defined in rcirc.el.gz.

Signature

(rcirc-format-response-string PROCESS SENDER RESPONSE TARGET TEXT)

Documentation

Return a formatted response string from SENDER, incorporating TEXT.

The specific formatting used is found by looking up RESPONSE in rcirc-response-formats. PROCESS is the process object used for communication.

Source Code

;; Defined in /usr/src/emacs/lisp/net/rcirc.el.gz
(defun rcirc-format-response-string (process sender response target text)
  "Return a formatted response string from SENDER, incorporating TEXT.
The specific formatting used is found by looking up RESPONSE in
`rcirc-response-formats'.  PROCESS is the process object used for
communication."
  (with-temp-buffer
    (insert (or (cdr (assoc response rcirc-response-formats))
		(cdr (assq t rcirc-response-formats))))
    (goto-char (point-min))
    (let ((start (point-min))
	  (sender (if (or (not sender)
			  (string= (rcirc-server-name process) sender))
		      ""
		    (funcall rcirc-nick-filter sender)))
	  face)
      (while (re-search-forward "%\\(\\(f\\(.\\)\\)\\|\\(.\\)\\)" nil t)
	(rcirc-add-face start (match-beginning 0) face)
	(setq start (match-beginning 0))
	(replace-match
	 (cl-case (aref (match-string 1) 0)
	    (?f (setq face
		      (cl-case (string-to-char (match-string 3))
			(?w 'font-lock-warning-face)
			(?p 'rcirc-server-prefix)
			(?s 'rcirc-server)
			(t nil)))
		"")
	    (?n sender)
	    (?N (let ((my-nick (rcirc-nick process)))
		  (save-match-data
		    (with-syntax-table rcirc-nick-syntax-table
		      (rcirc-facify sender
				    (cond ((string= sender my-nick)
					   'rcirc-my-nick)
					  ((and rcirc-bright-nicks
						(string-match
						 (regexp-opt rcirc-bright-nicks
							     'words)
						 sender))
					   'rcirc-bright-nick)
					  ((and rcirc-dim-nicks
						(string-match
						 (regexp-opt rcirc-dim-nicks
							     'words)
						 sender))
					   'rcirc-dim-nick)
					  (t
					   'rcirc-other-nick)))))))
	    (?m (propertize text 'rcirc-text text))
	    (?r response)
	    (?t (or target ""))
	    (t (concat "UNKNOWN CODE:" (match-string 0))))
	 t t nil 0)
	(rcirc-add-face (match-beginning 0) (match-end 0) face))
      (rcirc-add-face start (match-beginning 0) face))
      (buffer-substring (point-min) (point-max))))