Commit 6db1773d authored by David Byers's avatar David Byers
Browse files

Async message filtering, bug fixes

parent 0c71bdc8
1999-06-29 David Byers <davby@ida.liu.se>
* vars.el.in (lyskom-face-schemes): Added kom-warning-face.
(lyskom-faces): Ditto.
* view-text.el (lyskom-format-text-footer): Add the ability to
have properties on the format flags.
* async.el (lyskom-parse-async): Update the uconf-stat cache when
a name changes.
* komtypes.el (uconf-stat): Use def-komtype.
(uconf-stat):
* messages.el (lyskom-filter-message-handler): New message handler
used to filter ignored messages.
* vars.el.in (kom-ignore-message-senders): New variable.
(kom-ignore-message-recipients): New variable.
1999-06-29 David Byers <davby@ida.liu.se>
* edit-text.el (lyskom-edit-send-check-recipients): Passive
......
......@@ -94,9 +94,12 @@ this function shall be with current-buffer the BUFFER."
new-name
(lyskom-default-button 'conf conf-no)))
;; (cache-del-conf-stat conf-no) ;+++Borde {ndra i cachen i st{llet.
(let ((cached-stat (cache-get-conf-stat conf-no)))
(if cached-stat
(set-conf-stat->name cached-stat new-name)))
(let ((cached-stat (cache-get-conf-stat conf-no))
(cached-ustat (cache-get-uconf-stat conf-no)))
(when cached-stat
(set-conf-stat->name cached-stat new-name))
(when cached-ustat
(set-uconf-stat->name cached-ustat new-name)))
(cond
((lyskom-is-in-minibuffer))
((lyskom-show-presence conf-no kom-presence-messages)
......
......@@ -70,7 +70,7 @@
(defun lyskom-aux-item-definition-call (def method &rest args)
(when (aux-item-p def)
(when (lyskom-aux-item-p def)
(setq def (lyskom-find-aux-item-definition def)))
(cond ((listp method)
(let ((result nil))
......@@ -88,7 +88,7 @@
(defun lyskom-aux-item-definition-field (def method)
(when (aux-item-p def)
(when (lyskom-aux-item-p def)
(setq def (lyskom-find-aux-item-definition def)))
(cdr (assq method def)))
......
......@@ -227,7 +227,7 @@ otherwise return nil"
"Get static-session-info for session SESSION, or nil if nothing is cached."
(let ((tx (cache-assoc session lyskom-static-session-info-cache)))
(cond
((static-session-info-p tx) tx))))
((lyskom-static-session-info-p tx) tx))))
(defun cache-add-static-session-info (session info)
......
......@@ -678,13 +678,7 @@ This does lyskom-end-of-command"
"Write a comment to a text.
If optional arg TEXT-NO is present write a comment to that text instead."
(interactive (list
(cond
((null current-prefix-arg) lyskom-current-text)
((integerp current-prefix-arg) current-prefix-arg)
((listp current-prefix-arg)
(lyskom-read-number (lyskom-get-string 'what-comment-no)
(lyskom-text-at-point)))
(t (signal 'lyskom-internal-error '(kom-write-comment))))))
(lyskom-read-text-no-prefix-arg 'what-comment-to)))
(lyskom-start-of-command (concat
(lyskom-command-name 'kom-write-comment)
(if text-no
......@@ -911,18 +905,11 @@ BCCREP is a list of all recipient that are going to be bcc-recipients."
;;; Rewritten using blocking-do by: Linus Tolke
(def-kom-command kom-private-answer (&optional text-no)
(def-kom-command kom-private-answer (text-no)
"Write a private answer to the current text.
If optional arg TEXT-NO is present write a private answer to
that text instead."
(interactive (list
(cond
((null current-prefix-arg) lyskom-current-text)
((integerp current-prefix-arg) current-prefix-arg)
((listp current-prefix-arg)
(lyskom-read-number (lyskom-get-string 'what-private-no)
(lyskom-text-at-point)))
(t (signal 'lyskom-internal-error '(kom-private-answer))))))
(interactive (list (lyskom-read-text-no-prefix-arg 'what-private-no)))
(if text-no
(blocking-do-multiple ((text-stat (get-text-stat text-no))
(text (get-text text-no)))
......
......@@ -2010,24 +2010,17 @@ is alive."
(cache-del-conf-stat objno)))))
(defun lyskom-read-text-no-prefix-arg (prompt command)
"Call in interactive list to read text-no"
(cond
((null current-prefix-arg) lyskom-current-text)
((integerp current-prefix-arg) current-prefix-arg)
((listp current-prefix-arg) (lyskom-read-number prompt))
(t (signal 'lyskom-internal-error (list command)))))
(def-kom-command kom-fast-reply (&optional text-no)
(def-kom-command kom-fast-reply (text-no)
"Add a fast reply to a text."
(interactive (list (lyskom-read-text-no-prefix-arg 'what-fast-reply-no
'kom-fast-reply)))
(lyskom-format-insert 'fast-replying text-no)
(lyskom-fast-reply text-no
(lyskom-read-string
(lyskom-get-string 'fast-reply-prompt)
nil
'lyskom-fast-reply-history)))
(interactive (list (lyskom-read-text-no-prefix-arg 'what-fast-reply-no)))
(if text-no
(progn (lyskom-format-insert 'fast-replying text-no)
(lyskom-fast-reply text-no
(lyskom-read-string
(lyskom-get-string 'fast-reply-prompt)
nil
'lyskom-fast-reply-history)))
(lyskom-insert-string 'confusion-what-to-reply-to)))
......@@ -2041,13 +2034,15 @@ is alive."
(def-kom-command kom-agree (&optional text-no)
"Convenience function to add agreement."
(interactive (list (lyskom-read-text-no-prefix-arg 'what-agree-no
'kom-agree)))
(lyskom-format-insert 'agreeing text-no)
(lyskom-fast-reply text-no
(lyskom-read-string (lyskom-get-string 'agree-prompt)
(lyskom-default-agree-string)
'lyskom-fast-reply-history)))
(interactive (list (lyskom-read-text-no-prefix-arg 'what-agree-no)))
(if text-no
(progn (lyskom-format-insert 'agreeing text-no)
(lyskom-fast-reply text-no
(lyskom-read-string
(lyskom-get-string 'agree-prompt)
(lyskom-default-agree-string)
'lyskom-fast-reply-history)))
(lyskom-insert-string 'confusion-what-to-agree-to)))
(defun lyskom-fast-reply (text-no message)
......
......@@ -37,6 +37,65 @@
(concat lyskom-clientversion-long
"$Id$\n"))
;;; ============================================================
;;; Black magic...
(defmacro def-komtype (type &rest args)
(let ((typename (symbol-name type))
(n 0)
(tmp nil))
;; Constructor
(append
(list 'progn
(list 'defsubst
(intern (concat "lyskom-create-" typename))
args
(concat "Create a `" typename "' from arguments.\n"
"Args: " (upcase (mapconcat
'symbol-name args " ")) "\n"
"Automatically created with def-komtype.")
(list 'cons
(list 'quote (intern (upcase typename)))
(cons 'vector args)))
;; Identifier
(list 'defsubst
(intern (concat "lyskom-" typename "-p"))
(list type)
(concat "Return `t' if " (upcase typename)
" is a " typename ".\n"
"Args: " (upcase typename) "\n"
"Automatically created with def-komtype.")
(list 'and
(list 'consp type)
(list 'eq (list 'car type)
(list 'quote (intern (upcase typename)))))))
;; Selectors/Modifiers
(progn
(while args
(let ((argname (symbol-name (car args))))
;; Selctor
(setq tmp (cons
(list 'defsubst
(intern (concat typename "->" argname))
(list type)
"Automatically created with def-komtype."
(list 'aref (list 'cdr type) n))
tmp))
;; Modifier
(setq tmp (cons
(list 'defsubst
(intern (concat "set-" typename "->" argname))
(list type (car args))
"Automatically created with def-komtype."
(list 'aset (list 'cdr type) n (car args)))
tmp))
(setq n (1+ n)
args (cdr args))))
tmp))))
;;; ================================================================
;;; conf-no-list
......@@ -97,49 +156,8 @@ CONF-NO is a conf-no and CONF-NO-LIST is a conf-no-list."
;;; Constructor:
(defsubst lyskom-create-uconf-stat (conf-no
name
conf-type
highest-local-no
nice)
"Create an uconf-stat from all parameters."
(cons 'UCONF-STAT
(vector conf-no name conf-type highest-local-no nice)))
;;; Selectors:
(defsubst uconf-stat->conf-no (conf)
"Get the conf-no from an uconf-stat"
(elt (cdr conf) 0))
(defsubst uconf-stat->name (conf)
"Get the name of a conference."
(elt (cdr conf) 1))
(defsubst uconf-stat->conf-type (conf)
"Get the type of a conference."
(elt (cdr conf) 2))
(defsubst uconf-stat->highest-local-no (conf)
"Get the highest local number in a conference"
(elt (cdr conf) 3))
(defsubst uconf-stat->garb-nice (conf)
"Get garb-nice from a conference."
(elt (cdr conf) 4))
;;; Modifiers
;;; You shouldn't need modifiers
;;; Predicate
(defsubst lyskom-uconf-stat-p (object)
"Return t if OBJECT is a conf-stat."
(eq (car-safe object) 'UCONF-STAT))
(def-komtype uconf-stat
conf-no name conf-type highest-local-no nice)
;;; ================================================================
;;; conf-stat
......@@ -1058,62 +1076,6 @@ FOOTN-TO or FOOTN-IN."
;;; flags
;;; This is an experiment. Hopefully most of the code can be
;;; automatically generated.
(defmacro def-komtype (type &rest args)
(let ((typename (symbol-name type))
(n 0)
(tmp nil))
;; Constructor
(append
(list 'progn
(list 'defsubst
(intern (concat "lyskom-create-" typename))
args
(concat "Create a `" typename "' from arguments.\n"
"Args: " (upcase (mapconcat
'symbol-name args " ")) "\n"
"Automatically created with def-komtype.")
(list 'cons
(list 'quote (intern (upcase typename)))
(cons 'vector args)))
;; Identifier
(list 'defsubst
(intern (concat typename "-p"))
(list type)
(concat "Return `t' if " (upcase typename)
" is a " typename ".\n"
"Args: " (upcase typename) "\n"
"Automatically created with def-komtype.")
(list 'and
(list 'consp type)
(list 'eq (list 'car type)
(list 'quote (intern (upcase typename)))))))
;; Selectors/Modifiers
(progn
(while args
(let ((argname (symbol-name (car args))))
;; Selctor
(setq tmp (cons
(list 'defsubst
(intern (concat typename "->" argname))
(list type)
"Automatically created with def-komtype."
(list 'aref (list 'cdr type) n))
tmp))
;; Modifier
(setq tmp (cons
(list 'defsubst
(intern (concat "set-" typename "->" argname))
(list type (car args))
"Automatically created with def-komtype."
(list 'aset (list 'cdr type) n (car args)))
tmp))
(setq n (1+ n)
args (cdr args))))
tmp))))
(def-komtype session-flags
invisible user_active_used user_absent
......
......@@ -984,7 +984,7 @@ depending on the value of `kom-lynx-terminal'."
(defun lyskom-button-delete-aux (buf arg text)
(let ((aux nil))
(cond ((aux-item-p arg))
(cond ((lyskom-aux-item-p arg))
((listp arg)
(let ((items (cond ((eq 'text (car arg))
(text-stat->aux-items
......@@ -1017,7 +1017,7 @@ depending on the value of `kom-lynx-terminal'."
(defun lyskom-button-info-aux (buf arg text)
(pop-to-buffer buf)
(let ((aux nil))
(cond ((aux-item-p arg))
(cond ((lyskom-aux-item-p arg))
((listp arg)
(let ((items (cond ((eq 'text (car arg))
(text-stat->aux-items
......
......@@ -48,7 +48,7 @@ recipient or zero for common messages.
The functions may use the lyskom-set-current-message-text function to
modify the message text. A non-nil return value from the function
indicates that the message was handlerd and no other handlers need to
indicates that the message was handled and no other handlers need to
be called and a nil return value means that the message was not
handled and should be sent to the next handler.")
......@@ -146,8 +146,21 @@ on the value of PLACE. If PLACE is nil, 'after is assumed."
t)
nil))
(defun lyskom-filter-message-handler (message-type sender recipient text)
"Optionally kill messages from certain senders or to certain recipients.
See the documentation for kom-ignore-message-recipients and
kom-ignore-message-senders for more information."
(condition-case nil
(or (memq (cond ((lyskom-conf-stat-p sender) (conf-stat->conf-no sender))
((lyskom-uconf-stat-p sender) (uconf-stat->conf-no sender))
(t sender)) kom-ignore-message-senders)
(memq (cond ((lyskom-conf-stat-p sender) (conf-stat->conf-no recipient))
((lyskom-uconf-stat-p sender) (uconf-stat->conf-no recipient))
(t recipient)) kom-ignore-message-recipients))
(error nil)))
(lyskom-add-personal-message-handler 'lyskom-filter-message-handler 'before)
(lyskom-add-personal-message-handler 'lyskom-info-request-handler 'before)
(eval-and-compile (provide 'lyskom-messages))
......
......@@ -262,6 +262,8 @@ Skicka ett brev till %#2P f
(secret-members-allowed . "Fr man g med som hemlig medlem? ")
(what-comment-no . "Kommentera text nummer: ")
(what-footnote-no . "Fotnotera text nummer: ")
(confusion-what-to-reply-to . "Jag frstr inte vilken text du vill skriva en kort replik till.\n")
(confusion-what-to-agree-to . "Jag frstr inte vilken text du vill hlla med om.\n")
(confusion-what-to-comment . "Jag frstr inte vilken text du vill kommentera.\n")
(confusion-what-to-footnote . "Jag frstr inte vilken text du vill skriva en fotnot till.\n")
......@@ -943,6 +945,7 @@ Skicka en bugrapport.\n")
(mode-line-unread . " Olsta ")
(mode-line-letters . "brev ")
(bad-text-no-prefix . "Kan inte verstta prefix `%s' till inlggsnummer")
(error-code . "Felkod %#2d: %#1s.\n")
(error-in-kom-do-when-done . "Variabeln kom-do-when-done har ett felaktigt v.
Du br stta den till ett bttre vrde.\n")
......@@ -1279,7 +1282,7 @@ Inneh
(conference-no . "mte <%#1m> %#1M")
(text-no . "inlgg %#1n")
(what-fast-reply-no . "Snabb replik till vilket inlgg? ")
(what-fast-reply-no . "Kort replik till vilket inlgg? ")
(fast-reply-prompt . "Replik: ")
(agree-prompt . "Text: ")
(default-agree-string . "Hller med")
......@@ -1456,7 +1459,7 @@ Du m
(kom-calculate . "Berkna")
(kom-list-marks . "Lista markeringar")
(kom-where-is . "Var finns kommandot")
(kom-fast-reply . "Snabb replik")
(kom-fast-reply . "Kort replik")
(kom-agree . "Hlla med")
(kom-add-faq . "Addera FAQ")
(kom-del-faq . "Ta bort FAQ")
......
......@@ -299,6 +299,21 @@ The value is actually the element of LIST whose car equals KEY."
(and (boundp sym) (symbol-value sym))))
;;; ============================================================
;;; Prefix arguments
(defun lyskom-read-text-no-prefix-arg (prompt &optional command)
"Call in interactive list to read text-no"
(cond
((null current-prefix-arg) lyskom-current-text)
((integerp current-prefix-arg) current-prefix-arg)
((listp current-prefix-arg)
(lyskom-read-number prompt (lyskom-text-at-point)))
(t (lyskom-error (lyskom-get-string 'bad-text-no-prefix)
current-prefix-arg))))
;;; ======================================================================
;;; Display device management
;;;
......
......@@ -528,24 +528,33 @@ function to call."
server)
(def-kom-var kom-ding-on-common-messages 0
"*Non-nil means ding as common messages arrive.
A number means the number of times to ding. A string is an argument for the
program named by kom-audio-player. A symbol is interpreted as a function to
call."
"*Non-nil means ding as alarm messages arrive.
A number means the number of times to ding. A string is an argument
for the program named by kom-audio-player. A symbol is interpreted as
a function to call. A list consisting of pairs (KEY . VALUE) is used
for fine-grained control. The list is searched for a pair where KEY
matches the sender identity. The corresponding VALUE is used as the
specification on how to beep."
server)
(def-kom-var kom-ding-on-group-messages 1
"*Non-nil means ding as group messages arrive.
A number means the number of times to ding. A string is an argument for the
program named by kom-audio-player. A symbol is interpreted as a function
to call."
A number means the number of times to ding. A string is an argument
for the program named by kom-audio-player. A symbol is interpreted as
a function to call. A list consisting of pairs (KEY . VALUE) is used
for fine-grained control. The list is searched for a pair where KEY
matches the recipient identity. The corresponding VALUE is used as the
specification on how to beep."
server)
(def-kom-var kom-ding-on-personal-messages 2
"*Non-nil means ding as personal messages arrive.
A number means the number of times to ding. A string is an argument for the
program named by kom-audio-player. A symbol is interpreted as a function
to call."
A number means the number of times to ding. A string is an argument
for the program named by kom-audio-player. A symbol is interpreted as
a function to call. A list consisting of pairs (KEY . VALUE) is used
for fine-grained control. The list is searched for a pair where KEY
matches the sender identity. The corresponding VALUE is used as the
specification on how to beep."
server)
......@@ -562,6 +571,14 @@ to call."
server)
(def-kom-var kom-ignore-message-senders nil
"*List of senders whose personal, group and alarm messages are ignored."
server)
(def-kom-var kom-ignore-message-recipients nil
"*List of recipients you do not want group messages to."
server)
(def-kom-var kom-default-message-recipient 'group
"*Determines default recipient of personal messages.
......@@ -1906,7 +1923,7 @@ the value of kom-tell-phrases for fun.")
'(kom-active-face kom-url-face kom-me-face kom-highlight-face
kom-text-face kom-subject-face kom-text-no-face
kom-friends-face kom-presence-face
kom-first-line-face kom-mark-face)
kom-first-line-face kom-warning-face kom-mark-face)
"This is a list of the faces that LysKOM uses.")
(def-kom-var lyskom-face-schemes
......@@ -1921,6 +1938,7 @@ the value of kom-tell-phrases for fun.")
(kom-friends-face default "blue3" "lavender")
(kom-presence-face italic "dim gray" nil)
(kom-mark-face bold "blue3" "lavender")
(kom-warning-face bold "red" nil)
(kom-first-line-face default nil nil))
(inverse
(kom-active-face default "lightblue" nil)
......@@ -1933,6 +1951,7 @@ the value of kom-tell-phrases for fun.")
(kom-friends-face default "red" nil)
(kom-presence-face italic "grey" nil)
(kom-mark-face default "gold" "black")
(kom-warning-face bold "red" nil)
(kom-first-line-face default nil nil))
(monochrome
(kom-active-face default nil nil)
......@@ -1945,6 +1964,7 @@ the value of kom-tell-phrases for fun.")
(kom-friends-face underline nil nil)
(kom-presence-face italic nil nil)
(kom-mark-face bold nil "black")
(kom-warning-face bold nil nil)
(kom-first-line-face default nil nil))
(minimal
(kom-active-face default nil nil)
......@@ -1957,6 +1977,7 @@ the value of kom-tell-phrases for fun.")
(kom-friends-face default nil "alice blue")
(kom-presence-face italic "dim gray" nil)
(kom-mark-face default nil "black")
(kom-warning-face bold nil nil)
(kom-first-line-face default nil nil))
(highlight
(kom-active-face default nil "aliceblue")
......@@ -1969,6 +1990,7 @@ the value of kom-tell-phrases for fun.")
(kom-subject-face default nil nil)
(kom-presence-face italic "dim gray" nil)
(kom-mark-face bold "darkblue" "thistle")
(kom-warning-face bold "yellow" "red")
(kom-first-line-face default nil "lavender")))
"Face schemes for LysKOM.
......
......@@ -482,15 +482,24 @@ blocking-do."
(let ((first-flag t))
(concat
"("
(mapconcat (function
(lambda (str)
(cond
(first-flag
(setq first-flag nil)
(upcase-initials (lyskom-get-string str)))
(t (lyskom-get-string str)))))
format-flags ", ")
(mapconcat
(lambda (str)
(let ((face nil))
;; If it's a cons, the cdr is property list
(when (consp str)
(setq face (cdr str)
str (car str)))
;; Get the string
(setq str (lyskom-get-string str))
;; Upcase the first in the list
(when first-flag
(setq first-flag nil str (upcase-initials str)))
;; If we have a plist, apply it
(when face
(add-text-properties 0 (length str) face str))
;; Return the string
str))
format-flags ", ")
")"))
""))
(end-dash-chars
......@@ -647,8 +656,9 @@ Args: TEXT-STAT TEXT MARK-AS-READ TEXT-NO FLAT-REVIEW."
;; Indicate that the text was truncated
(if truncated
(setq lyskom-last-text-format-flags
(cons 'reformat-truncated lyskom-last-text-format-flags)))
(lyskom-signal-reformatted-text
'(reformat-truncated . (face kom-warning-face))))
;; (setq t2 (point-max))
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment