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

Made kom-handle-membership (maybe) work again.

Detailed changes:
> 	Make kom-handle-membership work again:
> 	* reading.el (lyskom-replace-membership): Turned this into a macro
> 	so the membership can be altered while replacing it.
>
> 	* mship-edit.el (lyskom-change-membership-priority): Use
> 	lyskom-replace-membership properly.
> 	(lyskom-change-membership-position): Ditto.
> 	(lp--set-entry-pri-and-pos): Ditto. Also inhibit buffer updates to
> 	avoid infinite recursion due to calling lp--update-buffer from
> 	within lyskom-replace-membership.
>
parent 0cf739fc
2004-07-12 David Byers <byers@lysator.liu.se> 2004-07-12 David Byers <byers@lysator.liu.se>
Make kom-handle-membership work again:
* reading.el (lyskom-replace-membership): Turned this into a macro
so the membership can be altered while replacing it.
* mship-edit.el (lyskom-change-membership-priority): Use
lyskom-replace-membership properly.
(lyskom-change-membership-position): Ditto.
(lp--set-entry-pri-and-pos): Ditto. Also inhibit buffer updates to
avoid infinite recursion due to calling lp--update-buffer from
within lyskom-replace-membership.
Deal with changes in 21.4 widget package: Deal with changes in 21.4 widget package:
* option-edit.el (lyskom-create-widget): Don't mask errors when * option-edit.el (lyskom-create-widget): Don't mask errors when
creating the storage widget. Changed args for the storage widget creating the storage widget. Changed args for the storage widget
......
...@@ -127,6 +127,7 @@ access this variable directly.") ...@@ -127,6 +127,7 @@ access this variable directly.")
(defvar lp--selected-entry-list nil) (defvar lp--selected-entry-list nil)
(defvar lp--buffer-done nil) (defvar lp--buffer-done nil)
(defvar lp--conf-name-width nil) (defvar lp--conf-name-width nil)
(defvar lp--inhibit-update nil)
;;; ============================================================ ;;; ============================================================
...@@ -158,8 +159,9 @@ This function does not tell the server about the change." ...@@ -158,8 +159,9 @@ This function does not tell the server about the change."
(let* ((mship (lyskom-get-membership conf-no t)) (let* ((mship (lyskom-get-membership conf-no t))
(old-priority (and mship (membership->priority mship)))) (old-priority (and mship (membership->priority mship))))
(when mship (when mship
(set-membership->priority mship new-priority) (lyskom-replace-membership mship
(lyskom-replace-membership mship) (set-membership->priority mship new-priority))
(cond (cond
((and (>= old-priority lyskom-session-priority) ((and (>= old-priority lyskom-session-priority)
(>= new-priority lyskom-session-priority)) (>= new-priority lyskom-session-priority))
...@@ -183,8 +185,8 @@ This function does not tell the server about the change." ...@@ -183,8 +185,8 @@ This function does not tell the server about the change."
This function does not tell the server about the change." This function does not tell the server about the change."
(let ((mship (lyskom-get-membership conf-no t))) (let ((mship (lyskom-get-membership conf-no t)))
(when mship (when mship
(set-membership->position mship new-position) (lyskom-replace-membership mship
(lyskom-replace-membership mship) (set-membership->position mship new-position))
(lyskom-update-membership-positions)))) (lyskom-update-membership-positions))))
...@@ -642,72 +644,69 @@ entry priority" ...@@ -642,72 +644,69 @@ entry priority"
"Move element EL by side effects so it appears at position TO in LIST." "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))) (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 lp--update-buffer (conf-no) (defun lp--update-buffer (conf-no)
"Update the entry for CONF-NO in the buffer. "Update the entry for CONF-NO in the buffer.
If optional NEW-MSHIP is non-nil, then get the membership again." If optional NEW-MSHIP is non-nil, then get the membership again."
(lp--save-excursion (unless lp--inhibit-update
(let ((buffers (lyskom-buffers-of-category 'prioritize))) (lp--save-excursion
(mapcar (lambda (buffer) (let ((buffers (lyskom-buffers-of-category 'prioritize)))
(set-buffer buffer) (mapcar (lambda (buffer)
(let ((entry (lp--conf-no-entry conf-no)) (set-buffer buffer)
(mship (lyskom-get-membership conf-no t))) (let ((entry (lp--conf-no-entry conf-no))
(mship (lyskom-get-membership conf-no t)))
;; A new membership
;; A new membership
(cond
((null entry) (cond
(let* ((pos (lyskom-membership-position mship)) ((null entry)
(elem (and pos (lp--get-entry pos))) (let* ((pos (lyskom-membership-position mship))
(entry (lyskom-create-lp--entry (elem (and pos (lp--get-entry pos)))
nil (entry (lyskom-create-lp--entry
nil nil
(membership->priority mship) nil
mship (membership->priority mship)
nil mship
(if (memq (membership->created-by mship) nil
(list lyskom-pers-no 0)) (if (memq (membership->created-by mship)
'contracted (list lyskom-pers-no 0))
'expanded) 'contracted
t 'expanded)
nil))) t
(when pos nil)))
(save-excursion (when pos
(goto-char (if elem (save-excursion
(lp--entry->start-marker elem) (goto-char (if elem
lp--list-end-marker)) (lp--entry->start-marker elem)
(lp--set-entry-list lp--list-end-marker))
(lp--add-to-list pos entry (lp--all-entries))) (lp--set-entry-list
(lp--print-entry entry))))) (lp--add-to-list pos entry (lp--all-entries)))
(lp--print-entry entry)))))
;; We have unsubscribed for good
;; We have unsubscribed for good
((null mship)
(when entry ((null mship)
(lp--set-entry-list (when entry
(lp--remove-from-list (lp--entry-position entry) (lp--set-entry-list
(lp--all-entries))) (lp--remove-from-list (lp--entry-position entry)
(lp--erase-entry entry))) (lp--all-entries)))
(lp--erase-entry entry)))
;; The priority or position of a membership has changed
;; The priority or position of a membership has changed
((or (/= (lp--entry->priority entry)
(membership->priority mship)) ((or (/= (lp--entry->priority entry)
(/= (lp--entry-position entry) (membership->priority mship))
(membership->position mship))) (/= (lp--entry-position entry)
(let ((new-pos (lp--entry-position (membership->position mship)))
(lp--find-new-position (let ((new-pos (lp--entry-position
entry (membership->priority mship))))) (lp--find-new-position
(lp--set-entry-pri-and-pos entry (membership->priority mship)))))
entry (membership->priority mship) new-pos) (lp--set-entry-pri-and-pos
(set-lp--entry->membership entry mship))) entry (membership->priority mship) new-pos)
(set-lp--entry->membership entry mship)))
(t (set-lp--entry->membership entry mship)
(lp--redraw-entry entry))))) (t (set-lp--entry->membership entry mship)
buffers)))) (lp--redraw-entry entry)))))
buffers)))))
...@@ -1083,14 +1082,16 @@ If the position changes, lp--move-entry is called. ...@@ -1083,14 +1082,16 @@ If the position changes, lp--move-entry is called.
lp--update-membership is called automatically before this function exits." lp--update-membership is called automatically before this function exits."
(let ((old-pri (lp--entry->priority entry)) (let ((old-pri (lp--entry->priority entry))
(old-pos (lp--entry-position entry)) (old-pos (lp--entry-position entry))
(lp--inhibit-update t)
(need-redraw nil)) (need-redraw nil))
(when (and priority (not (eq priority old-pri))) (lyskom-replace-membership (lp--entry->membership entry)
(set-lp--entry->priority entry priority) (when (and priority (not (eq priority old-pri)))
(set-membership->priority (lp--entry->membership entry) priority) (set-lp--entry->priority entry priority)
(setq need-redraw t)) (set-membership->priority (lp--entry->membership entry) priority)
(when (and position (not (eq position old-pos))) (setq need-redraw t))
(lp--move-entry entry position) (when (and position (not (eq position old-pos)))
(setq need-redraw nil)) (lp--move-entry entry position)
(setq need-redraw nil)))
(sit-for 0) (sit-for 0)
(lp--update-membership entry old-pri old-pos) (lp--update-membership entry old-pri old-pos)
(when need-redraw (lp--redraw-entry entry)))) (when need-redraw (lp--redraw-entry entry))))
......
...@@ -162,15 +162,28 @@ lyskom-membership list then this item is not entered." ...@@ -162,15 +162,28 @@ lyskom-membership list then this item is not entered."
(lyskom-update-membership-positions) (lyskom-update-membership-positions)
(lp--update-buffer (membership->conf-no mship)))) (lp--update-buffer (membership->conf-no mship))))
(defun lyskom-replace-membership (mship) (defmacro lyskom-replace-membership (mship &rest body)
"Find the membership for the same conference as MSHIP, and "Replace the membership MSHIP while evaluating BODY.
replace it with MSHIP into lyskom-membership."
(lyskom-with-lyskom-buffer This function should be used when altering the priority or position of
(when (lyskom-mship-cache-get (membership->conf-no mship)) a membership. The membership is removed from the cache, then BODY is
(lyskom-mship-cache-del (membership->conf-no mship))) evaluated and finally the membership is inserted into the cache again.
(lyskom-mship-cache-put mship)
(lyskom-update-membership-positions) Note that altering the priority or position without first removing the
(lp--update-buffer (membership->conf-no mship)))) membership from the cache may render it impossible to remove it later."
`(progn
(lyskom-with-lyskom-buffer
(when (lyskom-mship-cache-get (membership->conf-no ,mship))
(lyskom-mship-cache-del (membership->conf-no ,mship))))
,@body
(lyskom-with-lyskom-buffer
(lyskom-mship-cache-put ,mship)
(lyskom-update-membership-positions)
(lp--update-buffer (membership->conf-no ,mship)))))
(put 'lyskom-replace-membership 'lisp-indent-hook 1)
(put 'lyskom-replace-membership 'edebug-form-spec '(sexp body))
(defun lyskom-remove-membership (conf-no) (defun lyskom-remove-membership (conf-no)
"Remove the membership for CONF-NO from lyskom-membership." "Remove the membership for CONF-NO from lyskom-membership."
......
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