Commit 7017e0d9 authored by David Byers's avatar David Byers
Browse files

Added mship-edit.el to the main build.

YMMV
parent 11bdf265
1999-12-05 David Byers <davby@ida.liu.se>
* Makefile (SOURCES): Added mship-edit.el.
1999-12-04 David Byers <davby@ida.liu.se>
* mship-edit.el (lp--maybe-update-entry-for-conf): New function.
(lp--compute-format-string): Properties on unreads.
(lp--maybe-update-unreads): New function.
(lp--update-buffer): Support adding and removing memberships.
* deferred-insert.el (lyskom-replace-deferred): Perform the
deferred insertion in the right buffer.
* view-text.el (lyskom-mark-as-read-callback): New function.
(lyskom-mark-as-read): Call it.
1999-12-03 David Byers <davby@ida.liu.se>
* flags.el: Removed commented kom-edit-options stuff.
* swedish-strings.el (lyskom-sv-mode-map): Fixed remaininig
bindings of swedish characters.
1999-12-03 David Byers <davby@sen2.ida.liu.se>
* swedish-strings.el, english-strings.el (lyskom-command): Removed
......
......@@ -83,6 +83,7 @@ SOURCES = $(LANGUAGE-EL) \
view-text.el \
async.el \
completing-read.el \
mship-edit.el \
prioritize.el \
flags.el \
messages.el \
......
......@@ -3,6 +3,16 @@
Att göra i elisp-klienten
=========================
* SHOWSTOPPERS
** Om man går ur ett möte i en server som inte har set-membership-type
så försöker klienten ändå att göra set-membership-type
(commands1.el, lyskom-sub-member.)
** När man går med i ett möte så sorteras inte medlemskapet in korrekt
i medlemskapslistan.
* MULEification
These items have to be dealt with before the client can be used in a
multibyte environment (where the strings sent from the server are in
......
......@@ -284,14 +284,11 @@ chosen according to this"
(setq lyskom-current-prompt nil)
(lyskom-insert "\n")
(if (and (eq (window-buffer (selected-window))
(current-buffer))
;; (= (point) (point-max))
)
(current-buffer)))
(progn
(if (pos-visible-in-window-p (1- (point-max)))
(goto-char (point-max)))
(sit-for 0)))
; (lyskom-scroll)
(run-hooks 'lyskom-before-command-hook)
(if kom-page-before-command ;Nice with dumb terminals.
(if (or (not (listp kom-page-before-command))
......
......@@ -132,6 +132,8 @@ The insertion will be at (point)."
(defun lyskom-replace-deferred (defer-info &rest replacement-data)
"Replace some defered text."
(save-excursion
(when (marker-buffer (defer-info->pos defer-info))
(set-buffer (marker-buffer (defer-info->pos defer-info))))
(goto-char (defer-info->pos defer-info))
(apply 'lyskom-format-insert-at-point
(defer-info->format defer-info)
......
......@@ -40,201 +40,9 @@
(require 'lyskom-command "command"))
;;; Author: Linus Tolke
;;; Dummy defun of original-user-variable-p to eliminate compiler warning.
;;;; (defun original-user-variable-p (x) nil)
;;;;
;;;; (fset 'original-user-variable-p
;;;; (symbol-function 'user-variable-p))
;;;;
;;;;
;;;; (defun lyskom-user-variable-p (symbol)
;;;; (and (original-user-variable-p symbol)
;;;; (or (string-match "^kom-"
;;;; (symbol-name symbol))
;;;; (string-match "^lyskom-"
;;;; (symbol-name symbol)))))
;;;;
;;;; (defun lyskom-Edit-options-modify (modfun)
;;;; (save-excursion
;;;; (let ((inhibit-read-only t)
;;;; var pos tmp)
;;;; (re-search-backward "^;; \\|\\`")
;;;; (forward-char 3)
;;;; (setq pos (point))
;;;; (save-restriction
;;;; (narrow-to-region pos (progn (end-of-line) (1- (point))))
;;;; (goto-char pos)
;;;; (setq var (read (current-buffer))))
;;;; (goto-char pos)
;;;; (forward-line 1)
;;;; (forward-char 1)
;;;; (save-excursion
;;;; (set var (setq tmp (funcall modfun var)))
;;;; (if (boundp 'lyskom-buffer)
;;;; (set-buffer lyskom-buffer))
;;;; (set var tmp))
;;;; (kill-sexp 1)
;;;; (prin1 (symbol-value var) (current-buffer)))))
;;;;
(defvar lyskom-options-text nil
"Text mass when reading options.")
;;;;
;;;; (def-kom-command kom-save-options ()
;;;; "Save options that have been set somewhere."
;;;; (interactive)
;;;; (lyskom-save-options (or lyskom-buffer
;;;; (current-buffer))
;;;; (lyskom-get-string 'saving-settings)
;;;; (lyskom-get-string 'saving-settings-done)
;;;; (lyskom-get-string 'could-not-save-options)))
;;;;
;;;;
;;;; (lyskom-external-function edit-options)
;;;; (defun kom-edit-options ()
;;;; "Edit options for the lyskom client."
;;;; (interactive)
;;;; (fset 'user-variable-p
;;;; (symbol-function 'lyskom-user-variable-p))
;;;; (let ((buf (current-buffer))
;;;; (curwin (current-window-configuration)))
;;;; (edit-options)
;;;; (fset 'Edit-options-modify
;;;; (symbol-function 'lyskom-Edit-options-modify))
;;;; (make-local-variable 'lyskom-buffer)
;;;; (make-local-variable 'lyskom-edit-return-to-configuration)
;;;; (setq lyskom-buffer buf)
;;;; (setq lyskom-edit-return-to-configuration curwin)
;;;; (local-set-key "\C-c\C-c" 'kom-edit-options-send)
;;;; (local-set-key "\C-c\C-k" 'kom-edit-quit)
;;;; )
;;;; (fset 'user-variable-p
;;;; (symbol-function 'original-user-variable-p)))
;;;;
;;;; ;;;============================================================
;;;; ;;; kom-edit-options-send
;;;; ;;;
;;;; ;;; Finish an edit options session.
;;;; ;;; This function must be kept in sync with lyskom-save-options
;;;; ;;; below.
;;;; ;;;
;;;;
;;;; (defun kom-edit-options-send ()
;;;; "Finishes the edit options and sends the new settings to the server."
;;;; (interactive)
;;;; ; The check for changes is not a very good one.
;;;; (cond
;;;; ((not (eq major-mode 'Edit-options-mode))
;;;; (error "You are not in the correct buffer. (Couldn't fool me this time."))
;;;; ((buffer-modified-p (current-buffer))
;;;; ;lets do it.
;;;; ;lyskom-global-variables is a list of variables in the common block.
;;;; ;lyskom-elisp-variables is a list of varibles in the elisp block.
;;;; (let* ((optbuf (current-buffer))
;;;; (print-readably t)
;;;; (common-block nil)
;;;; (elisp-block nil))
;;;; (save-excursion
;;;; (set-buffer lyskom-buffer)
;;;; (setq
;;;; common-block
;;;; (concat
;;;; (mapconcat (function
;;;; (lambda (var)
;;;; (lyskom-format-objects
;;;; (substring (symbol-name var) 4)
;;;; (if (symbol-value var) "1" "0"))))
;;;; lyskom-global-boolean-variables
;;;; "\n")
;;;; "\n"
;;;; (mapconcat (function
;;;; (lambda (var)
;;;; (lyskom-format-objects
;;;; (substring (symbol-name var) 4)
;;;; (prin1-to-string (symbol-value var)))))
;;;; lyskom-global-non-boolean-variables
;;;; "\n")
;;;; )
;;;; elisp-block
;;;; (mapconcat (function
;;;; (lambda (var)
;;;; (concat (symbol-name var)
;;;; " "
;;;; (let* ((data (prin1-to-string (symbol-value var)))
;;;; (coding
;;;; (lyskom-mime-charset-coding-system
;;;; (lyskom-mime-string-charset data)))
;;;; (val (condition-case nil
;;;; (encode-coding-string data coding)
;;;; (error nil))))
;;;; ;; FIXME
;;;; (if (and val nil)
;;;; (format "%dC%s%dH%s"
;;;; (string-bytes (symbol-name coding))
;;;; (symbol-name coding)
;;;; (string-bytes val)
;;;; val)
;;;; (format "%dH%s"
;;;; (string-bytes data)
;;;; data))))))
;;;; lyskom-elisp-variables
;;;; "\n"))
;;;; (lyskom-start-of-command (lyskom-get-string 'saving-settings) t)
;;;; (lyskom-insert-string 'hang-on)
;;;; (initiate-create-text
;;;; 'options 'lyskom-edit-options-send
;;;; ;;; This is a cludge awaiting prot-B
;;;; (cons 'raw-text
;;;; (apply 'lyskom-format-objects
;;;; (apply 'lyskom-format-objects
;;;; "common"
;;;; "elisp"
;;;; (mapcar
;;;; (function car)
;;;; (cons 'STRING
;;;; (cons 'raw-text
;;;; lyskom-other-clients-user-areas))))
;;;; (cons 'STRING (cons 'raw-text common-block))
;;;; (cons 'STRING (cons 'raw-text elisp-block))
;;;; (mapcar (lambda (el)
;;;; (cons 'STRING (cons 'raw-text (cdr el))))
;;;; lyskom-other-clients-user-areas)))
;;;; (lyskom-create-misc-list)
;;;; nil
;;;; optbuf))))
;;;; (t
;;;; (let ((optbuf (current-buffer)))
;;;; (set-buffer lyskom-buffer)
;;;; (lyskom-start-of-command (lyskom-get-string 'saving-settings) t)
;;;; (lyskom-insert-string 'no-changes)
;;;; (lyskom-edit-options-done t optbuf)))))
;;;;
;;;;
;;;; (defun lyskom-edit-options-send (text-no optbuf)
;;;; "Handles the call after the options text has been sent to the buffer."
;;;; (if text-no
;;;; (initiate-set-user-area 'options 'lyskom-edit-options-done
;;;; lyskom-pers-no text-no optbuf)
;;;; (lyskom-insert-string 'could-not-create-area)
;;;; (lyskom-end-of-command)))
;;;;
;;;;
;;;; (defun lyskom-edit-options-done (success optbuf)
;;;; "Handles the return from the set user area call.
;;;; If successful then set the buffer not-modified. Else print a warning."
;;;; (if success
;;;; (save-excursion
;;;; ;;;+++ This should be done with the asynchronous call instead.
;;;; (cache-del-pers-stat lyskom-pers-no)
;;;; (set-buffer optbuf)
;;;; (not-modified)
;;;; (set-window-configuration lyskom-edit-return-to-configuration))
;;;; (lyskom-format-insert 'could-not-set-user-area lyskom-errno))
;;;; (lyskom-end-of-command))
;;;;
;;;;
(def-kom-var lyskom-options-done nil
"When we have read all options this is turned non-nil."
local)
......
......@@ -61,6 +61,15 @@
;;
;; Done in set-lp--entry-pri-and-pos and lp--update-membership.
;;
;; TODO UNSORTED
;; Keep the unread counter updated. Hook in lyskom-mark-as-read
;; Keep the membership list update. Perhaps in lyskom-add-membership
;; and associated functions to add, lyskom-remove-membership to
;; remove.
;; Endast-function to all marked memberships
;; Uppskjut-function to all marked memberships
;; Remove and add membership functions.
;;
;;; Commentary:
......@@ -88,6 +97,49 @@
;;; ============================================================
;;; Utility functions
(defun lyskom-change-membership-priority (conf-no new-priority)
"Change the priority of memberhip for CONF-NO to NEW-POSITION.
This function does not tell the server about the change."
(let* ((mship (lyskom-get-membership conf-no t))
(old-priority (and mship (membership->priority mship))))
(when mship
(set-membership->priority mship new-priority)
(lyskom-sort-membership)
(cond
((and (>= old-priority lyskom-session-priority)
(>= new-priority lyskom-session-priority))
(lyskom-sort-to-do-list))
((and (< old-priority lyskom-session-priority)
(>= new-priority lyskom-session-priority))
(let ((mship (lyskom-get-membership conf-no t)))
(when mship (lyskom-prefetch-map conf-no mship))))
((and (>= old-priority lyskom-session-priority)
(< new-priority lyskom-session-priority))
(read-list-delete-read-info conf-no lyskom-to-do-list)
(when (eq conf-no lyskom-current-conf)
(lyskom-leave-current-conf))
(lyskom-update-prompt t))
))))
(defun lyskom-change-membership-position (conf-no new-position)
"Change the position of memberhip for CONF-NO to NEW-POSITION.
This function does not tell the server about the change."
;; FIXME: We have to update all positions in the membership
;; list, not just the one we changed.
(let ((mship (lyskom-get-membership conf-no t)))
(when mship
(set-membership->position mship new-position)
(setq lyskom-membership (lyskom-move-in-list mship lyskom-membership new-position))
(lyskom-update-membership-positions)
(lyskom-sort-to-do-list))))
;;; ============================================================
;; Entry drawing
......@@ -120,64 +172,83 @@ only recomputed if the window width changes."
(setq lp--last-window-width (window-width))
(setq lp--last-format-string
(concat "%#1c %=3#2s %#9c %=-" (number-to-string total)
"#3M %=-12#4s %=5#5s %[%#10@%#6c%]%[%#11@%#7c%]%[%#12@%#8c%]")))))
(defun lp--format-entry (entry)
"#3M %=-12#4s %[%#13@%=5#5s%] %[%#10@%#6c%]%[%#11@%#7c%]%[%#12@%#8c%]")))))
(defun lp--format-insert-entry (entry)
"Format ENTRY and insert it into the current buffer at point."
(lyskom-format-insert-at-point
"%#1D"
(lyskom-create-defer-info 'get-conf-stat
(membership->conf-no
(lp--entry->membership entry))
'lp--format-insert-entry-2
(point-marker)
(length lyskom-defer-indicator)
"%#1s"
entry)))
(defun lp--format-insert-entry-2 (conf-stat defer-info)
"Format ENTRY for insertion in a buffer.
Returns a string suitable for insertion in a membership list."
(let ((un (lyskom-find-unread (membership->conf-no
(lp--entry->membership entry))))
(conf-stat (blocking-do 'get-conf-stat
(membership->conf-no
(lp--entry->membership entry)))))
(concat
(lyskom-format (lp--compute-format-string)
(if (lp--entry->selected entry) ?* ?\ )
(if (zerop (membership->priority
(lp--entry->membership entry)))
"-"
(int-to-string (membership->priority
(lp--entry->membership entry))))
conf-stat
(lyskom-return-date-and-time
(membership->last-time-read (lp--entry->membership entry))
'time-yyyy-mm-dd)
(if un (int-to-string un) "")
(lyskom-replace-deferred
defer-info
(lp--format-entry conf-stat (defer-info->data defer-info))))
(defun lp--format-entry (conf-stat entry)
(let* ((un (lyskom-find-unread (membership->conf-no
(lp--entry->membership entry)))))
(concat
(lyskom-format
(lp--compute-format-string)
(if (lp--entry->selected entry) ?* ?\ )
(if (zerop (membership->priority
(lp--entry->membership entry)))
"-"
(int-to-string (membership->priority
(lp--entry->membership entry))))
conf-stat
(lyskom-return-date-and-time
(membership->last-time-read (lp--entry->membership entry))
'time-yyyy-mm-dd)
(if un (int-to-string un) "")
(if (membership-type->invitation (membership->type (lp--entry->membership entry))) ?I ?.)
(if (membership-type->secret (membership->type (lp--entry->membership entry))) ?H ?.)
(if (membership-type->passive (membership->type (lp--entry->membership entry))) ?P ?.)
(if (eq lyskom-pers-no (conf-stat->supervisor conf-stat)) ?O ?\ )
(lyskom-default-button 'prioritize-flag-menu
(list entry 'invitation)
(list "%#1s (%=#2M)"
"Inbjuden"
(membership->conf-no
(lp--entry->membership entry))))
(lyskom-default-button 'prioritize-flag-menu
(list entry 'secret)
(list "%#1s (%=#2M)"
"Hemlig"
(membership->conf-no
(lp--entry->membership entry))))
(lyskom-default-button 'prioritize-flag-menu
(list entry 'passive)
(list "%#1s (%=#2M)"
"Passiv"
(membership->conf-no
(lp--entry->membership entry)))))
(if (or (eq (lp--entry->state entry) 'expanded)
(and (not (eq (membership->created-by (lp--entry->membership entry))
lyskom-pers-no))
(not (eq (membership->created-by (lp--entry->membership entry)) 0))
(not (eq (lp--entry->state entry) 'contracted))))
(lyskom-format "\n %#1s %#2s av %#3P"
(if (membership-type->invitation (membership->type (lp--entry->membership entry)))
"Inbjuden" "Adderad")
(lyskom-return-date-and-time
(membership->created-at (lp--entry->membership entry)))
(membership->created-by (lp--entry->membership entry)))
""))))
(if (membership-type->invitation (membership->type (lp--entry->membership entry))) ?I ?.)
(if (membership-type->secret (membership->type (lp--entry->membership entry))) ?H ?.)
(if (membership-type->passive (membership->type (lp--entry->membership entry))) ?P ?.)
(if (and conf-stat (eq lyskom-pers-no (conf-stat->supervisor conf-stat))) ?O ?\ )
(lyskom-default-button 'prioritize-flag-menu
(list entry 'invitation)
(list "%#1s (%=#2M)"
"Inbjuden"
(membership->conf-no
(lp--entry->membership entry))))
(lyskom-default-button 'prioritize-flag-menu
(list entry 'secret)
(list "%#1s (%=#2M)"
"Hemlig"
(membership->conf-no
(lp--entry->membership entry))))
(lyskom-default-button 'prioritize-flag-menu
(list entry 'passive)
(list "%#1s (%=#2M)"
"Passiv"
(membership->conf-no
(lp--entry->membership entry))))
'(lp--unread t))
(when (or (eq (lp--entry->state entry) 'expanded)
(and (not (eq (membership->created-by (lp--entry->membership entry))
lyskom-pers-no))
(not (eq (membership->created-by (lp--entry->membership entry)) 0))
(not (eq (lp--entry->state entry) 'contracted))))
(lyskom-format-insert-at-point "\n %#1s %#2s av %#3P"
(if (membership-type->invitation (membership->type (lp--entry->membership entry)))
"Inbjuden" "Adderad")
(lyskom-return-date-and-time
(membership->created-at (lp--entry->membership entry)))
(membership->created-by (lp--entry->membership entry)))
))))
(defun lp--print-entry (entry)
"Print the entry ENTRY at the current position in the buffer.
......@@ -186,7 +257,7 @@ The start and end markers of the entry are adjusted"
(insert-before-markers "\n")
(forward-char -1)
(set-lp--entry->start-marker entry (point-marker))
(insert (lp--format-entry entry))
(lp--format-insert-entry entry)
(set-lp--entry->end-marker entry (point-marker))
(forward-char 1)))
......@@ -213,6 +284,42 @@ The start and end markers of the entry are adjusted"
(lp--erase-entry entry)
(lp--print-entry entry)))
(defun lp--perform-in-all-buffers (fn &rest args)
"Perform FN in all prioritization buffers. ARGS are arguments for FN.
Normally there should only be one buffer, but who knows..."
(when lyskom-buffer
(save-excursion
(set-buffer lyskom-buffer)
(let ((prioritize-buffers (lyskom-buffers-of-category 'prioritize)))
(lyskom-traverse buffer prioritize-buffers
(when (buffer-live-p buffer)
(set-buffer buffer)
(apply fn args)))))))
(defun lp--maybe-update-entry-for-conf (conf-no)
(lp--perform-in-all-buffers
(lambda (conf-no)
(let ((entry (lp--conf-no-entry conf-no)))
(when entry (lp--redraw-entry entry))))
conf-no))
(defun lp--maybe-update-unreads (conf-no)
(lp--perform-in-all-buffers
(lambda (conf-no unread)
(let ((entry (lp--conf-no-entry conf-no)))
(when entry
(let ((bounds (next-text-property-bounds
1 (lp--entry->start-marker entry) 'lp--unread)))
(when bounds
(lp--save-excursion
(let ((buffer-read-only nil))
(delete-region (car bounds) (cdr bounds))
(goto-char (car bounds))
(insert (lyskom-format "%#2@%=5#1s"
(if unread (int-to-string unread) "")
'(lp--unread t))))))))))
conf-no (lyskom-find-unread conf-no)))
;;; ============================================================
......@@ -340,8 +447,11 @@ entry priority"
"Move element EL by side effects so it appears at position TO in LIST."
(lp--add-to-list to el (lp--remove-from-list el list)))
(defun lp--add-membership-callback (membership)
(lp--update-buffer (membership->conf-no membership)))
(defun lyskom-prioritize-update-buffer (conf-no)
(defun lp--update-buffer (conf-no)
"Update the entry for CONF-NO in the buffer."
(lp--save-excursion
(let ((buffers (lyskom-buffers-of-category 'prioritize)))
......@@ -349,18 +459,49 @@ entry priority"
(set-buffer buffer)
(let ((entry (lp--conf-no-entry conf-no))
(mship (lyskom-get-membership conf-no t)))
(cond ((null entry)
;; FIXME: Insert a new entry
)
((null mship)
;; FIXME: Delete an entry
)
((/= (lp--entry->priority entry)
(membership->priority mship))
;; FIXME: Move the entry
)
(t (set-lp--entry->membership mship)
(lp--redraw-entry entry)))))
;; A new membership
(cond
((null entry)
(let* ((pos (or (membership->position mship)
(- (length lyskom-membership)
(length (memq mship lyskom-membership)))))
(elem (and pos (lp--get-entry pos)))
(entry (lyskom-create-lp--entry
nil
nil
(membership->priority mship)
mship
nil
'normal)))
(when pos
(save-excursion
(goto-char (lp--entry->start-marker elem))
(lp--set-entry-list
(lp--add-to-list pos entry (lp--all-entries)))
(lp--print-entry entry)))))
;; We have unsubscribed for good
((null mship)
(when entry
(lp--set-entry-list
(lp--remove-from-list (lp--entry-position entry)
(lp--all-entries)))
(lp--erase-entry entry)))
;; The priority or position of a membership has changed
((or (/= (lp--entry->priority entry)
(membership->priority mship))
(/= (lp--entry-position entry)
(membership->position mship)))
;; FIXME: Move the entry
)
(t (set-lp--entry->membership entry mship)
(lp--redraw-entry entry)))))
buffers))))
......@@ -564,29 +705,30 @@ Forces a mode line update"
(defun lp--update-membership (entry old-pri old-pos)
"Update the server and local versions of membership in ENTRY."
(save-excursion
(set-buffer lyskom-buffer)
(let ((mship (lp--entry->membership entry)))
(lyskom-change-membership-position (membership->conf-no mship)
(lp--entry-position entry))
(lyskom-change-membership-priority (membership->conf-no mship)
(lp--entry->priority mship))
(cond ((and (>= old-pri lyskom-session-priority)
(< (membership->priority mship) lyskom-session-priority))
(when (eq lyskom-current-conf (membership->conf-no mship))
(lyskom-leave-current-conf))
(read-list-delete-read-info (membership->conf-no mship)
lyskom-to-do-list)
(lyskom-update-prompt t))
((and (< old-pri lyskom-session-priority)
(>= (membership->priority mship) lyskom-session-priority))
(lyskom-prefetch-map (membership->conf-no mship) mship)))