• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/erc/

Lines Matching +defs:erc +defs:current +defs:nick +defs:face

0 ;;; erc-match.el --- Highlight messages matching certain regexps
30 ;; you were used to customizing erc-fools, erc-keywords, erc-pals,
31 ;; erc-dangerous-hosts and the like, this file contains these
35 ;; Put (erc-match-mode 1) into your ~/.emacs file.
39 (require 'erc)
44 (defgroup erc-match nil
48 :group 'erc)
50 ;;;###autoload (autoload 'erc-match-mode "erc-match")
51 (define-erc-module match nil
54 `erc-pals', `erc-fools', `erc-keywords', `erc-dangerous-hosts', and
55 `erc-current-nick-highlight-type'. For all these highlighting types,
56 you can decide whether the entire message or only the sending nick is
58 ((add-hook 'erc-insert-modify-hook 'erc-match-message 'append))
59 ((remove-hook 'erc-insert-modify-hook 'erc-match-message)))
63 (defcustom erc-pals nil
65 :group 'erc-match
68 (defcustom erc-fools nil
70 :group 'erc-match
73 (defcustom erc-keywords nil
76 regexp in the car and the face to use in the cdr. If no face is
77 specified, `erc-keyword-face' is used."
78 :group 'erc-match
80 (list regexp face))))
82 (defcustom erc-dangerous-hosts nil
85 :group 'erc-match
88 (defcustom erc-current-nick-highlight-type 'keyword
89 "*Determines how to highlight text in which your current nickname appears
95 'keyword - highlight all instances of current nickname in message
96 'nick - highlight the nick of the user who typed your nickname
97 'nick-or-keyword - highlight the nick of the user who typed your nickname,
98 or all instances of the current nickname if there was
100 'all - highlight the entire message where current nickname occurs
102 Any other value disables highlighting of current nickname altogether."
103 :group 'erc-match
105 (const nick)
107 (const nick-or-keyword)
110 (defcustom erc-pal-highlight-type 'nick
112 See `erc-pals'.
117 'nick - highlight pal's nickname only
121 :group 'erc-match
123 (const nick)
126 (defcustom erc-fool-highlight-type 'nick
128 See `erc-fools'.
133 'nick - highlight fool's nickname only
137 :group 'erc-match
139 (const nick)
142 (defcustom erc-keyword-highlight-type 'keyword
144 See variable `erc-keywords'.
152 :group 'erc-match
157 (defcustom erc-dangerous-host-highlight-type 'nick
159 See `erc-dangerous-hosts'.
163 'nick - highlight nick from dangerous-host only
167 :group 'erc-match
169 (const nick)
173 (defcustom erc-log-matches-types-alist '((keyword . "ERC Keywords"))
180 - current-nick
184 :group 'erc-match
190 (const current-nick))
193 (defcustom erc-log-matches-flag 'away
198 :group 'erc-match
203 (defcustom erc-log-match-format "%t<%n:%c> %m"
208 %t Timestamp (uses `erc-timestamp-format' if non-nil or \"[%Y-%m-%d %H:%M] \")
213 :group 'erc-match
216 (defcustom erc-beep-match-types '(current-nick)
218 The function `erc-beep-on-match' needs to be added to `erc-text-matched-hook'
220 :group 'erc-match
222 (const current-nick)
229 (defcustom erc-text-matched-hook '(erc-log-matches)
232 \(match-type nick!user@host message) where MATCH-TYPE is a symbol of:
233 current-nick, keyword, pal, dangerous-host, fool"
234 :options '(erc-log-matches erc-hide-fools erc-beep-on-match)
235 :group 'erc-match
240 ;; This is exactly the same as erc-button-syntax-table. Should we
241 ;; just put it in erc.el
242 (defvar erc-match-syntax-table
259 This syntax table should make all the legal nick characters word
264 (defface erc-current-nick-face '((t (:bold t :foreground "DarkTurquoise")))
265 "ERC face for occurrences of your current nickname."
266 :group 'erc-faces)
268 (defface erc-dangerous-host-face '((t (:foreground "red")))
269 "ERC face for people on dangerous hosts.
270 See `erc-dangerous-hosts'."
271 :group 'erc-faces)
273 (defface erc-pal-face '((t (:bold t :foreground "Magenta")))
274 "ERC face for your pals.
275 See `erc-pals'."
276 :group 'erc-faces)
278 (defface erc-fool-face '((t (:foreground "dim gray")))
279 "ERC face for fools on the channel.
280 See `erc-fools'."
281 :group 'erc-faces)
283 (defface erc-keyword-face '((t (:bold t :foreground "pale green")))
284 "ERC face for your keywords.
285 Note that this is the default face to use if
286 `erc-keywords' does not specify another."
287 :group 'erc-faces)
291 (defun erc-add-entry-to-list (list prompt &optional completions)
300 (not (erc-member-ignore-case (car x) (symbol-value list)))))))
301 (if (erc-member-ignore-case entry (symbol-value list))
305 (defun erc-remove-entry-from-list (list prompt)
320 (if (erc-member-ignore-case entry (symbol-value list))
328 (defun erc-add-pal ()
329 "Add pal interactively to `erc-pals'."
331 (erc-add-entry-to-list 'erc-pals "Add pal: " (erc-get-server-nickname-alist)))
334 (defun erc-delete-pal ()
335 "Delete pal interactively to `erc-pals'."
337 (erc-remove-entry-from-list 'erc-pals "Delete pal: "))
340 (defun erc-add-fool ()
341 "Add fool interactively to `erc-fools'."
343 (erc-add-entry-to-list 'erc-fools "Add fool: "
344 (erc-get-server-nickname-alist)))
347 (defun erc-delete-fool ()
348 "Delete fool interactively to `erc-fools'."
350 (erc-remove-entry-from-list 'erc-fools "Delete fool: "))
353 (defun erc-add-keyword ()
354 "Add keyword interactively to `erc-keywords'."
356 (erc-add-entry-to-list 'erc-keywords "Add keyword: "))
359 (defun erc-delete-keyword ()
360 "Delete keyword interactively to `erc-keywords'."
362 (erc-remove-entry-from-list 'erc-keywords "Delete keyword: "))
365 (defun erc-add-dangerous-host ()
366 "Add dangerous-host interactively to `erc-dangerous-hosts'."
368 (erc-add-entry-to-list 'erc-dangerous-hosts "Add dangerous-host: "))
371 (defun erc-delete-dangerous-host ()
372 "Delete dangerous-host interactively to `erc-dangerous-hosts'."
374 (erc-remove-entry-from-list 'erc-dangerous-hosts "Delete dangerous-host: "))
376 (defun erc-match-current-nick-p (nickuserhost msg)
377 "Check whether the current nickname is in MSG.
379 (with-syntax-table erc-match-syntax-table
382 (regexp-quote (erc-current-nick))
386 (defun erc-match-pal-p (nickuserhost msg)
387 "Check whether NICKUSERHOST is in `erc-pals'.
390 (erc-list-match erc-pals nickuserhost)))
392 (defun erc-match-fool-p (nickuserhost msg)
393 "Check whether NICKUSERHOST is in `erc-fools' or MSG is directed at a fool."
395 (or (erc-list-match erc-fools nickuserhost)
396 (erc-match-directed-at-fool-p msg))))
398 (defun erc-match-keyword-p (nickuserhost msg)
399 "Check whether any keyword of `erc-keywords' matches for MSG.
402 (erc-list-match
407 erc-keywords)
410 (defun erc-match-dangerous-host-p (nickuserhost msg)
411 "Check whether NICKUSERHOST is in `erc-dangerous-hosts'.
414 (erc-list-match erc-dangerous-hosts nickuserhost)))
416 (defun erc-match-directed-at-fool-p (msg)
418 In order to do this, every entry in `erc-fools' will be used.
425 erc-fools))
428 erc-fools)))
429 (or (erc-list-match fools-beg msg)
430 (erc-list-match fools-end msg))))
432 (defun erc-match-message ()
434 Use this defun with `erc-insert-modify-hook'."
437 (let* ((to-match-nick-dep '("pal" "fool" "dangerous-host"))
438 (to-match-nick-indep '("keyword" "current-nick"))
439 (vector (erc-get-parsed-vector (point-min)))
440 (nickuserhost (erc-get-parsed-vector-nick vector))
442 (nth 0 (erc-parse-user nickuserhost))))
444 (nick-beg (and nickname
448 (nick-end (when nick-beg
450 (message (buffer-substring (if (and nick-end
451 (<= (+ 2 nick-end) (point-max)))
452 (+ 2 nick-end)
459 (let* ((match-prefix (concat "erc-" match-type))
460 (match-pred (intern (concat "erc-match-" match-type "-p")))
463 (match-regex (if (string= match-type "current-nick")
464 (regexp-quote (erc-current-nick))
466 (match-face (intern (concat match-prefix "-face"))))
469 ;; Highlight the nick of the message
470 ((and (eq match-htype 'nick)
471 nick-end)
472 (erc-put-text-property
473 nick-beg nick-end
474 'face match-face (current-buffer)))
475 ;; Highlight the nick of the message, or the current
476 ;; nick if there's no nick in the message (e.g. /NAMES
478 ((and (string= match-type "current-nick")
479 (eq match-htype 'nick-or-keyword))
480 (if nick-end
481 (erc-put-text-property
482 nick-beg nick-end
483 'face match-face (current-buffer))
484 (goto-char (+ 2 (or nick-end
487 (erc-put-text-property (match-beginning 0) (match-end 0)
488 'face match-face))))
491 (erc-put-text-property
493 'face match-face (current-buffer)))
500 (face match-face))
503 face (cdr elt)))
504 (goto-char (+ 2 (or nick-end
507 (erc-put-text-property
509 'face face))))
511 ;; Highlight all occurrences of our nick.
512 ((and (string= match-type "current-nick")
514 (goto-char (+ 2 (or nick-end
517 (erc-put-text-property (match-beginning 0) (match-end 0)
518 'face match-face)))
522 'erc-text-matched-hook
525 (concat "Server:" (erc-get-parsed-vector-type vector)))
528 (append to-match-nick-dep to-match-nick-indep)
529 to-match-nick-indep)))))
531 (defun erc-log-matches (match-type nickuserhost message)
534 `erc-log-matches-types-alist' and `erc-log-matches-flag'. Specify the
537 `erc-log-match-format'."
539 erc-log-matches-types-alist)))
540 (nick (nth 0 (erc-parse-user nickuserhost))))
542 (or (eq erc-log-matches-flag t)
543 (and (eq erc-log-matches-flag 'away)
544 (erc-away-time)))
546 (let ((line (format-spec erc-log-match-format
548 ?n nick
550 (or (and (boundp 'erc-timestamp-format)
551 erc-timestamp-format)
553 ?c (or (erc-default-target) "")
556 (with-current-buffer (erc-log-matches-make-buffer match-buffer-name)
561 (defun erc-log-matches-make-buffer (name)
566 (with-current-buffer buffer
569 (erc-view-mode-enter nil (lambda (buffer)
574 (defun erc-log-matches-come-back (proc parsed)
576 (when (and (erc-away-time)
577 (eq erc-log-matches-flag 'away))
583 (let* ((last-msg-time (erc-emacs-time-to-erc-time
584 (with-current-buffer buffer
587 (away-time (erc-emacs-time-to-erc-time (erc-away-time))))
589 (erc-time-gt last-msg-time away-time))
590 (erc-display-message
594 (erc-display-message
598 erc-log-matches-types-alist))
601 ; This handler must be run _before_ erc-process-away is.
602 (add-hook 'erc-server-305-functions 'erc-log-matches-come-back nil)
604 (defun erc-go-to-log-matches-buffer ()
605 "Interactively open an erc-log-matches buffer."
610 erc-log-matches-types-alist)
615 (define-key erc-mode-map "\C-c\C-k" 'erc-go-to-log-matches-buffer)
617 (defun erc-hide-fools (match-type nickuserhost message)
619 This function should be called from `erc-text-matched-hook'."
621 (erc-put-text-properties (point-min) (point-max)
623 (current-buffer))))
625 (defun erc-beep-on-match (match-type nickuserhost message)
627 This function is meant to be called from `erc-text-matched-hook'."
628 (when (member match-type erc-beep-match-types)
631 (provide 'erc-match)
633 ;;; erc-match.el ends here