;;; -*- Mode:LISP; Package:TV; Base:10 -*- ;;; NOTIFY-OFF-ON ;;; Provides a way to specify notifications (e.g. from TV:NOTIFY) to be ;;; ignored -- that is, they are not displayed. ;;; EXAMPLE: turn off "Spooling to " notifications from TIGER server ;;; (TV:NOTIFY-SELECTIVELY T) ;;; (TV:ADD-IGNORE-NOTIFICATION "Spooling to") ;;; A flag indicating whether to check notifications (defvar *notify-selectively* nil) ;;; A list of notification strings (partially matched) to be ignored (defvar *notification-strings-to-ignore* nil) ;;; A standard way to set the selectivity flag (defun notify-selectively(flag) (setq *notify-selectively* (not(null flag)))) ;;; A standard way to put ignored notification strings on the ;;; ignore-list. (defun add-ignore-notification(str) (push (string str) *notification-strings-to-ignore*)) ;;; A standard way to remove ignored notification strings on the ;;; ignore-list. The input string must be EQUAL (respecting case!) to ;;; the target notification string to be removed from the list. (defun remove-ignore-notification(str) (setq *notification-strings-to-ignore* (remove str *notification-strings-to-ignore*))) ;;; A standard predicate for determining partial (index 0) matches (defun match-notification-string(s1 s2) (zerop(or(string-search s2 s1) -1))) ;;; A daemon method around the :PRINT-NOTIFICATION method which checks ;;; the input notification string. If we're selectively notifying and ;;; the input string matches (all, or the beginning of) an ignored ;;; notification, we don't call the continuation of the primary method. (defmethod (notification-mixin :around :print-notification) (continuation mapping-table original-argument-list ignore string ignore) "Method to allow specification of notification messages to be ignored. Strings on the list *NOTIFICATION-STRINGS-TO-IGNORE* are partially matched against the notification string (the match must be from index 0 of the strings)." ;;Call primary method if either: (when (or (null *notify-selectively*) ;we're not selectively notifying, or (null(mem #'match-notification-string string ;string is not present in list *notification-strings-to-ignore*))) (lexpr-funcall-with-mapping-table continuation mapping-table original-argument-list)))