Commit a97fbdfc authored by David Byers's avatar David Byers
Browse files

Various bug fixes. Added support for uconf-stats and sed-last-read

server call. New names variable names in filter-edit.el.
parent 66c40ced
No preview for this file type
......@@ -254,7 +254,7 @@ this function shall be with current-buffer the BUFFER."
(/= 0 (length doing)))
(lyskom-format-insert-before-prompt
"%#1M %#2s\n"
persconfstat
personconfstat
(concat (char-to-string (downcase (string-to-char doing)))
(substring doing 1))))))))
......@@ -272,11 +272,14 @@ Args: SENDER: conf-stat for the person issuing the broadcast message or a
of the recipient.
MESSAGE: A string containing the message."
(lyskom-insert-personal-message sender recipient message)
(setq lyskom-last-personal-message-sender (if (stringp sender) sender
(conf-stat->name sender)))
(setq lyskom-last-group-message-recipient (if recipient
(conf-stat->name recipient)
nil))
(setq lyskom-last-personal-message-sender
(if (stringp sender) sender (conf-stat->name sender)))
(setq lyskom-last-group-message-recipient
(if (and recipient
(not (eq (conf-stat->conf-no recipient)
lyskom-pers-no)))
(conf-stat->name recipient)
nil))
(run-hooks 'lyskom-personal-message-hook))
......
......@@ -38,6 +38,40 @@
"$Id$\n"))
;;; ================================================================
;;; UConf-stat cache
(defun cache-get-uconf-stat (conf-no)
"Get uconf-stat for conference CONF-NO, or nil if nothing is cached.
If full conf-stat is cached, construct an uconf-stat from that data and
cache it."
(or (cache-assoc conf-no lyskom-uconf-cache)
(cache-construct-uconf-stat (cache-get-conf-stat conf-no))))
(defun cache-construct-uconf-stat (conf)
"If conf is non-nil, create an uconf-stat from conf and cache it.
Return the new uconf-stat or nil"
(and conf
(cache-add-uconf-stat
(lyskom-create-uconf-stat (conf-stat->conf-no conf)
(conf-stat->name conf)
(conf-stat->conf-type conf)
(+
(conf-stat->first-local-no conf)
(conf-stat->no-of-texts conf))
(conf-stat->garb-nice conf)))))
(defun cache-add-uconf-stat (uconf-stat)
"Insert a UCONF-STAT in the cache."
(cache-add (uconf-stat->conf-no uconf-stat)
uconf-stat
'lyskom-uconf-cache))
(defun cache-del-uconf-stat (conf-no)
"Delete a conf-stat from the cache. Args: CONF-NO."
(cache-del conf-no 'lyskom-uconf-cache)
(cache-del conf-no 'lyskom-conf-cache))
;;; ================================================================
;;; Conf-stat cache.
......@@ -47,7 +81,6 @@
"Get conf-stat for conference CONF-NO, or nil if nothing is cached."
(cache-assoc conf-no lyskom-conf-cache))
(defun cache-add-conf-stat (conf-stat)
"Insert a CONF-STAT in the cache."
(cache-add (conf-stat->conf-no conf-stat) conf-stat 'lyskom-conf-cache))
......@@ -55,7 +88,8 @@
(defun cache-del-conf-stat (conf-no)
"Delete a conf-stat from the cache. Args: CONF-NO."
(cache-del conf-no 'lyskom-conf-cache))
(cache-del conf-no 'lyskom-conf-cache)
(cache-del conf-no 'lyskom-uconf-cache))
......
......@@ -477,8 +477,8 @@ of the person."
(lyskom-format-insert 'unsubscribe-failed
(if self
(lyskom-get-string 'You)
(conf-stat->conf-name pers))
(conf-stat->conf-name conf))
(conf-stat->name pers))
(conf-stat->name conf))
(lyskom-insert-string 'done)
(if (and self
(= (conf-stat->conf-no conf)
......@@ -993,7 +993,6 @@ TYPE is either 'pres or 'motd, depending on what should be changed."
;;; Author: ???
(def-kom-command kom-go-to-conf ()
"Select a certain conference.
The user is prompted for the name of the conference.
......@@ -1003,31 +1002,36 @@ back on lyskom-to-do-list."
(let ((conf (lyskom-read-conf-stat
(lyskom-get-string 'go-to-conf-p)
'all "")))
;; "Go to the conference in CONF. CONF can be conf-no of conf-stat.
;; Allowed conferences are conferences and the mailboxes you are
;; member of."
(let ((membership (lyskom-member-p
(conf-stat->conf-no conf))))
(lyskom-format-insert 'go-to-conf
conf)
(cond
(membership
(lyskom-do-go-to-conf conf membership))
((conf-type->letterbox (conf-stat->conf-type conf))
(lyskom-format-insert 'cant-go-to-his-mailbox
conf))
(t
(progn
(lyskom-format-insert 'not-member-of-conf
conf)
(lyskom-scroll)
(if (lyskom-j-or-n-p (lyskom-get-string 'want-become-member))
(if (lyskom-add-member-by-no (conf-stat->conf-no conf)
lyskom-pers-no)
(lyskom-fixup-and-go-to-conf (conf-stat->conf-no conf))
(lyskom-insert-string 'nope))
(lyskom-insert-string 'no-ok))))))))
(lyskom-go-to-conf conf)))
(defun lyskom-go-to-conf (conf)
"Go to the conference in CONF. CONF can be conf-no of conf-stat.
Allowed conferences are conferences and the mailboxes you are
member of."
(if (numberp conf) (setq conf (blocking-do 'get-conf-stat conf)))
(let ((membership (lyskom-member-p
(conf-stat->conf-no conf))))
(lyskom-format-insert 'go-to-conf
conf)
(cond
(membership
(lyskom-do-go-to-conf conf membership))
((conf-type->letterbox (conf-stat->conf-type conf))
(lyskom-format-insert 'cant-go-to-his-mailbox
conf))
(t
(progn
(lyskom-format-insert 'not-member-of-conf
conf)
(lyskom-scroll)
(if (lyskom-j-or-n-p (lyskom-get-string 'want-become-member))
(if (lyskom-add-member-by-no (conf-stat->conf-no conf)
lyskom-pers-no)
(lyskom-fixup-and-go-to-conf (conf-stat->conf-no conf))
(lyskom-insert-string 'nope))
(lyskom-insert-string 'no-ok)))))))
(defun lyskom-fixup-and-go-to-conf (conf-no)
......@@ -1632,33 +1636,39 @@ footnotes) to it as read in the server."
the user has used a prefix command argument."
(interactive "P")
(lyskom-start-of-command 'kom-add-recipient)
(let ((conf (blocking-do 'get-conf-stat lyskom-last-added-rcpt)))
(lyskom-add-sub-recipient text-no-arg
(lyskom-get-string 'text-to-add-recipient)
'add-rcpt
conf)))
(unwind-protect
(let ((conf (blocking-do 'get-conf-stat lyskom-last-added-rcpt)))
(lyskom-add-sub-recipient text-no-arg
(lyskom-get-string 'text-to-add-recipient)
'add-rcpt
conf))
(lyskom-end-of-command)))
(defun kom-add-copy (text-no-arg)
"Add a cc recipient to a text. If the argument TEXT-NO-ARG is non-nil,
the user has used a prefix command argument."
(interactive "P")
(lyskom-start-of-command 'kom-add-copy)
(let ((conf (blocking-do 'get-conf-stat lyskom-last-added-ccrcpt)))
(lyskom-add-sub-recipient text-no-arg
(lyskom-get-string 'text-to-add-copy)
'add-copy
conf)))
(unwind-protect
(let ((conf (blocking-do 'get-conf-stat lyskom-last-added-ccrcpt)))
(lyskom-add-sub-recipient text-no-arg
(lyskom-get-string 'text-to-add-copy)
'add-copy
conf))
(lyskom-end-of-command)))
(defun kom-sub-recipient (text-no-arg)
"Subtract a recipient from a text. If the argument TEXT-NO-ARG is non-nil,
the user has used a prefix command argument."
(interactive "P")
(lyskom-start-of-command 'kom-sub-recipient)
(let ((conf (blocking-do 'get-conf-stat lyskom-current-conf)))
(lyskom-add-sub-recipient text-no-arg
(lyskom-get-string 'text-to-delete-recipient)
'sub
conf)))
(unwind-protect
(let ((conf (blocking-do 'get-conf-stat lyskom-current-conf)))
(lyskom-add-sub-recipient text-no-arg
(lyskom-get-string 'text-to-delete-recipient)
'sub
conf))
(lyskom-end-of-command)))
(defun lyskom-add-sub-recipient (text-no-arg
prompt
......@@ -1710,7 +1720,7 @@ the user has used a prefix command argument."
(t (lyskom-error "internal error"))))
(cache-del-text-stat text-no)
(lyskom-handle-command-answer result)))
(lyskom-report-command-answer result)))
......@@ -1759,7 +1769,7 @@ DO-ADD: NIL if a comment should be subtracted.
text-no)
(cache-del-text-stat text-no)
(cache-del-text-stat comment-text-no)
(lyskom-handle-command-answer
(lyskom-report-command-answer
(blocking-do (if do-add 'add-comment 'sub-comment)
comment-text-no
text-no))))
......
......@@ -465,19 +465,18 @@ otherwise: the conference is read with lyskom-completing-read."
(lyskom-get-string 'everybody))
'all t
;; Initial string:
(cond ((null kom-send-message-to-last-sender)
nil)
((and (not (eq kom-send-message-to-last-sender 'always))
lyskom-last-group-message-recipient)
(if (string-match "^19" emacs-version)
(cons lyskom-last-group-message-recipient 0)
lyskom-last-group-message-recipient))
(lyskom-last-personal-message-sender
(if (string-match "^19" emacs-version)
(cons lyskom-last-personal-message-sender 0)
lyskom-last-personal-message-sender))
(t
"")))))
(cond
((null kom-send-message-to-last-sender) nil)
((and (not (eq kom-send-message-to-last-sender 'always))
lyskom-last-group-message-recipient)
(if (string-match "^19" emacs-version)
(cons lyskom-last-group-message-recipient 0)
lyskom-last-group-message-recipient))
(lyskom-last-personal-message-sender
(if (string-match "^19" emacs-version)
(cons lyskom-last-personal-message-sender 0)
lyskom-last-personal-message-sender))
(t "")))))
(def-kom-command kom-send-alarm ()
......
......@@ -33,6 +33,10 @@
(defvar filter-edit-currently-edited-filter-entry-list nil
"List of filters currently being edited in a filter editor")
(defvar filter-edit-change-flag nil)
(defvar filter-edit-filter-list nil)
(defvar filter-edit-list-start nil)
(defvar filter-edit-list-end nil)
;;;
;;; Utility functions
......@@ -287,46 +291,48 @@ If NEG is non-nil, the first line will be negated."
(defun lyskom-format-filter-pattern-insert (pat neg)
"Format and insert the first pattern in PAT.
If NEG is non-nil, format the negation."
(insert
(format (if lyskom-emacs19-p
" %s %s %S"
(if (stringp (cdr (car pat)))
" %s %s \"%s\""
" %s %s %s"))
(cdr (assoc (car (car pat))
(if kom-emacs-knows-iso-8859-1
lyskom-filter-what
lyskom-swascii-filter-what)))
(if neg
" != "
" = ")
(cdr (car pat))))
(cond ((or (eq (car (car pat)) 'recipient-no)
(eq (car (car pat)) 'author-no))
(save-excursion
(if (boundp 'lyskom-buffer)
(set-buffer lyskom-buffer))
(setq tmp (blocking-do 'get-conf-stat (cdr (car pat)))))
(insert (format " <%s>" (conf-stat->name tmp)))))
(insert "\n"))
(let (tmp)
(insert
(format (if lyskom-emacs19-p
" %s %s %S"
(if (stringp (cdr (car pat)))
" %s %s \"%s\""
" %s %s %s"))
(cdr (assoc (car (car pat))
(if kom-emacs-knows-iso-8859-1
lyskom-filter-what
lyskom-swascii-filter-what)))
(if neg
" != "
" = ")
(cdr (car pat))))
(cond ((or (eq (car (car pat)) 'recipient-no)
(eq (car (car pat)) 'author-no))
(save-excursion
(if (boundp 'lyskom-buffer)
(set-buffer lyskom-buffer))
(setq tmp (blocking-do 'get-conf-stat (cdr (car pat)))))
(insert (format " <%s>" (conf-stat->name tmp)))))
(insert "\n")))
(defun lyskom-filter-format-entry-header (filter &optional newline action)
"Format the header of a filter entry. FILTER is the filter to format.
If NEWLINE is non-nil, insert a newline after the header."
(setq action (filter->attribute filter 'action)
permanent (null (filter->attribute filter 'expire)))
(insert
(format "--- %s %s"
(cdr
(assq action
(if kom-emacs-knows-iso-8859-1
lyskom-filter-actions
lyskom-swascii-filter-actions)))
(lyskom-get-string
(if permanent 'permanent 'temporary))))
(if newline (insert "\n")))
(let (permanent)
(setq action (filter->attribute filter 'action)
permanent (null (filter->attribute filter 'expire)))
(insert
(format "--- %s %s"
(cdr
(assq action
(if kom-emacs-knows-iso-8859-1
lyskom-filter-actions
lyskom-swascii-filter-actions)))
(lyskom-get-string
(if permanent 'permanent 'temporary))))
(if newline (insert "\n"))))
;;;========================================
......@@ -500,7 +506,7 @@ If NEWLINE is non-nil, insert a newline after the header."
(goto-char (filter-entry->end (elt filter-edit-currently-edited-filter-entry-list
(1- (length filter-edit-currently-edited-filter-entry-list)))))
(insert "\n"))
(goto-char list-end))
(goto-char filter-edit-list-end))
(setq action (completing-read (lyskom-get-string 'filter-edit-filter-how)
rev-actions
......@@ -521,7 +527,7 @@ If NEWLINE is non-nil, insert a newline after the header."
(setcdr (nthcdr (1- (length filter-edit-currently-edited-filter-entry-list)) filter-edit-currently-edited-filter-entry-list)
(cons entry nil))
(setq filter-edit-currently-edited-filter-entry-list (cons entry nil)))
(setq change-flag t)
(setq filter-edit-change-flag t)
(goto-char start)))
......@@ -651,7 +657,7 @@ If NEWLINE is non-nil, insert a newline after the header."
(cons (point-marker)
(nthcdr lineno
(filter-entry->lines entry))))))
(setq change-flag t)))
(setq filter-edit-change-flag t)))
......@@ -686,7 +692,7 @@ Only lines in the current entry will be deleted."
(set-filter->pattern
filter
(cdr (filter->pattern filter)))
(setq change-flag t))
(setq filter-edit-change-flag t))
(progn
(setcdr (nthcdr (1- lineno)
(filter-entry->lines entry))
......@@ -698,7 +704,7 @@ Only lines in the current entry will be deleted."
(nthcdr (1+ lineno)
(filter->pattern
(filter-entry->filter entry))))
(setq change-flag t))))
(setq filter-edit-change-flag t))))
(lyskom-error (lyskom-get-string 'filter-edit-end-of-pattern)))))))))
......@@ -724,10 +730,10 @@ If NOERROR is non-nil, return nil instead of signaling an error."
(1+ (filter-entry->end entry)))
(cond ((= 0 entry-no)
(setq filter-edit-currently-edited-filter-entry-list (cdr filter-edit-currently-edited-filter-entry-list))
(setq change-flag t))
(setq filter-edit-change-flag t))
(t (setcdr (nthcdr (1- entry-no) filter-edit-currently-edited-filter-entry-list)
(nthcdr (1+ entry-no) filter-edit-currently-edited-filter-entry-list))
(setq change-flag t)))
(setq filter-edit-change-flag t)))
(if (= entry-no (length filter-edit-currently-edited-filter-entry-list))
(progn (if (lyskom-filter-edit-prev-entry 1 t)
(setq arg 0)
......@@ -738,7 +744,7 @@ If NOERROR is non-nil, return nil instead of signaling an error."
"Quit filter edit mode and ask to save changes (if any)"
(interactive)
(let ((save nil))
(if change-flag
(if filter-edit-change-flag
(setq save (lyskom-j-or-n-p
(lyskom-get-string 'filter-edit-save-p))))
(if save
......@@ -796,7 +802,7 @@ If NOERROR is non-nil, return nil instead of signaling an error."
(append
(setq kom-permanent-filter-list (nreverse xpermanent-list))
(setq kom-session-filter-list (nreverse xtemporary-list))))))
(setq change-flag nil)
(setq filter-edit-change-flag nil)
(lyskom-message (lyskom-get-string 'filter-edit-saving))
(lyskom-save-options lyskom-buffer
(lyskom-get-string 'filter-edit-saving)
......@@ -807,16 +813,16 @@ If NOERROR is non-nil, return nil instead of signaling an error."
(defun lyskom-filter-edit-revert ()
"Discard changes and restart editing"
(interactive)
(if (or (not change-flag)
(and change-flag
(if (or (not filter-edit-change-flag)
(and filter-edit-change-flag
(lyskom-j-or-n-p (lyskom-get-string 'filter-edit-restart-p))))
(let ((buffer-read-only nil))
(setq filter-edit-currently-edited-filter-entry-list nil)
(delete-region list-start list-end)
(goto-char list-start)
(delete-region filter-edit-list-start filter-edit-list-end)
(goto-char filter-edit-list-start)
(insert "\n")
(lyskom-format-filter-list (copy-filter-list lyskom-filter-list))
(setq change-flag nil)
(setq filter-edit-change-flag nil)
(lyskom-filter-edit-beginning-of-list))))
......@@ -833,7 +839,7 @@ If NOERROR is non-nil, return nil instead of signaling an error."
(not (filter->attribute
(filter-entry->filter entry)
'expire)))
(setq change-flag t)
(setq filter-edit-change-flag t)
(save-excursion
(goto-char (filter-entry->start entry))
(delete-region (point) (save-excursion (end-of-line) (point)))
......@@ -859,7 +865,7 @@ If NOERROR is non-nil, return nil instead of signaling an error."
action-list)
action-list))))
(new-action (or action (car action-list))))
(setq change-flag t)
(setq filter-edit-change-flag t)
(set-filter->attribute (filter-entry->filter entry)
'action
(car new-action))
......@@ -903,14 +909,14 @@ All key bindings:
(interactive)
(kill-all-local-variables)
(make-local-variable 'filter-edit-currently-edited-filter-entry-list)
(make-local-variable 'change-flag)
(make-local-variable 'filter-list)
(make-local-variable 'list-start)
(make-local-variable 'list-end)
(make-local-variable 'filter-edit-change-flag)
(make-local-variable 'filter-edit-filter-list)
(make-local-variable 'filter-edit-list-start)
(make-local-variable 'filter-edit-list-end)
(make-local-variable 'lyskom-buffer)
(make-local-variable 'lyskom-edit-return-to-configuration)
(setq buffer-read-only t)
(setq change-flag nil)
(setq filter-edit-change-flag nil)
(buffer-flush-undo (current-buffer))
(use-local-map lyskom-filter-edit-map)
(setq mode-name "LysKOM Filter Edit")
......@@ -936,13 +942,13 @@ All key bindings:
(lyskom-filter-edit-mode)
(setq lyskom-buffer buf)
(let ((buffer-read-only nil))
(setq filter-list filters)
(setq filter-edit-filter-list filters)
(insert (format (lyskom-get-string 'filter-edit-header)
server-name))
(setq list-start (point-marker))
(setq filter-edit-list-start (point-marker))
(insert "\n")
(lyskom-format-filter-list (copy-filter-list filter-list))
(setq list-end (point-max-marker)))
(lyskom-format-filter-list (copy-filter-list filter-edit-filter-list))
(setq filter-edit-list-end (point-max-marker)))
(setq lyskom-edit-return-to-configuration curwin)
(lyskom-filter-edit-beginning-of-list)))
......
......@@ -645,6 +645,7 @@ the current text"
(progn
(lyskom-insert (lyskom-get-string 'view-filters-header))
(while filters
(goto-char (point-max))
(lyskom-format-filter-pattern (car filters))
(setq filters (cdr filters)))
(lyskom-insert (lyskom-get-string 'view-filters-footer)))))
......
......@@ -318,6 +318,8 @@ If successful then set the buffer not-modified. Else print a warning."
(setcdr (car pos) working)))))
(++ r))
(setq lyskom-filter-list (append kom-permanent-filter-list
kom-session-filter-list))
(setq lyskom-do-when-done (cons kom-do-when-done kom-do-when-done))
;; Remove not found user-areas
(let ((pos lyskom-other-clients-user-areas))
......
......@@ -89,6 +89,49 @@ CONF-NO is a conf-no and CONF-NO-LIST is a conf-no-list."
(setq r (1+ r))))
yes)))
;;; ================================================================
;;; uconf-stat
;;; 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 (cd conf) 4))
;;; Modifiers
;;; You shouldn't need modifiers
;;; ================================================================
;;; conf-stat
......
......@@ -75,15 +75,16 @@
(defun lyskom-mouse-2 (pos window)
(let* ((action nil)
(arg nil))
(select-window window)
(goto-char pos)
(if (setq action (get-text-property pos 'mouse-2-action))
(funcall action pos (get-text-property pos 'mouse-2-arg)))))
(select-window window)
(goto-char pos)
(let* ((action (get-text-property pos 'mouse-2-action))
(arg (get-text-property pos 'mouse-2-arg))
(buf (get-text-property pos 'mouse-2-buffer)))
(cond ((null action) nil)
((and buf (null (get-buffer buf)))
(lyskom-message (lyskom-get-string 'no-such-buffer)))
(t (and buf (set-buffer buf))
(funcall action pos arg)))))
(defun lyskom-button-transform-text (text)
......@@ -103,13 +104,15 @@
(match-beginning 1)
(match-end 1))))
(setq props
(append (list 'mouse-2-action
(elt el 2)
'mouse-2-arg
(elt el 3)
;; Experiment /davidk
'lyskom-button-match-data
(match-data))
'lyskom-button-string
(substring text (match-beginning 0) (<