Commit 0cf739fc authored by David Byers's avatar David Byers
Browse files

Fixed a bunch of compatibility issues.

Detailed changes:
> 	Deal with changes in 21.4 widget package:
> 	* option-edit.el (lyskom-create-widget): Don't mask errors when
> 	creating the storage widget. Changed args for the storage widget
> 	to a list.
> 	(lyskom-widget-number-value-to-external): Convert from pretty much
> 	anything to numbers.
> 	(lyskom-widget-number-value-to-internal): Convert from pretty much
> 	anything to strings.
> 	(lyskom-ding-widget): Set values to numbers, not strings.
> 	(lyskom-number-widget): Provide a default value.
>
> 	Deal with Gnu Emacs 19.34:
> 	* menus.el (lyskom-define-menu-gnu): Use
> 	lyskom-encode-coding-string instead of encode-coding-string.
>
> 	Eliminate warnings when compiling with Gnu Emacs 21.4:
> 	* compatibility.el (function-obsolete-p): New alias.
> 	(set-process-query-on-exit-flag): New alias.
> 	(make-local-hook): New alias.
> 	(lyskom-make-self-evaluating): New implementation that works in
> 	all Emacsen yet doesn't generate warnings in 21.4
>
> 	* startup.el (lyskom): Use lyskom-set-process-query-on-exit
> 	instead of process-kill-without-query.
> 	(lyskom-setup-ssh-relay): Same here.
>
> 	* defvar.el (lyskom-clientversion-long): We don't treat
> 	lyskom-clientversion-long as a constant in the rest of the code,
> 	so let's not pretend that it is one, shall we?
>
> 	Work on porting kom-handle-membership to new membership cache:
> 	* mship-edit.el (lyskom-change-membership-priority): Don't attempt
> 	to sort the membership list. Just replace the membership in the
> 	cache to put it in the correct position. Explicitly sort the to-do
> 	list since we no longer call lyskom-sort-membership.
> 	(lyskom-change-membership-position): Use lyskom-replace-membership
> 	to move the membership in the membership list.
>
> 	* macros.el (lyskom-traverse-membership): Ensure that we get
> 	lyskom-mship-cache from the right buffer.
>
> 	* prioritize.el: Removed lyskom-prioritize-add-membership,
> 	lyskom-prioritize-remove-membership and
> 	lyskom-prioritize-replace-membership. As a result the prioritize
> 	buffer can no longer deal with new, removed and altered
> 	memberships.
>
parent 5a302db8
2004-07-12 David Byers <byers@lysator.liu.se>
Deal with changes in 21.4 widget package:
* option-edit.el (lyskom-create-widget): Don't mask errors when
creating the storage widget. Changed args for the storage widget
to a list.
(lyskom-widget-number-value-to-external): Convert from pretty much
anything to numbers.
(lyskom-widget-number-value-to-internal): Convert from pretty much
anything to strings.
(lyskom-ding-widget): Set values to numbers, not strings.
(lyskom-number-widget): Provide a default value.
Deal with Gnu Emacs 19.34:
* menus.el (lyskom-define-menu-gnu): Use
lyskom-encode-coding-string instead of encode-coding-string.
Eliminate warnings when compiling with Gnu Emacs 21.4:
* compatibility.el (function-obsolete-p): New alias.
(set-process-query-on-exit-flag): New alias.
(make-local-hook): New alias.
(lyskom-make-self-evaluating): New implementation that works in
all Emacsen yet doesn't generate warnings in 21.4
* startup.el (lyskom): Use lyskom-set-process-query-on-exit
instead of process-kill-without-query.
(lyskom-setup-ssh-relay): Same here.
* defvar.el (lyskom-clientversion-long): We don't treat
lyskom-clientversion-long as a constant in the rest of the code,
so let's not pretend that it is one, shall we?
Work on porting kom-handle-membership to new membership cache:
* mship-edit.el (lyskom-change-membership-priority): Don't attempt
to sort the membership list. Just replace the membership in the
cache to put it in the correct position. Explicitly sort the to-do
list since we no longer call lyskom-sort-membership.
(lyskom-change-membership-position): Use lyskom-replace-membership
to move the membership in the membership list.
* macros.el (lyskom-traverse-membership): Ensure that we get
lyskom-mship-cache from the right buffer.
* prioritize.el: Removed lyskom-prioritize-add-membership,
lyskom-prioritize-remove-membership and
lyskom-prioritize-replace-membership. As a result the prioritize
buffer can no longer deal with new, removed and altered
memberships.
* clienttypes.el (read-list-enter-read-info): When checking
whether to append texts to an existing read-list item, don't check
that conf-stats are eq. Just check that the conf-nos are the same.
......
......@@ -576,7 +576,7 @@ Returns the window displaying BUFFER."
(make-local-variable 'lyskom-saved-window-configuration)
(setq lyskom-saved-window-configuration
saved-window-configuration)
(make-local-hook 'kill-buffer-hook)
(lyskom-make-local-hook 'kill-buffer-hook)
(add-hook 'kill-buffer-hook
'lyskom-undisplay-buffer-hook nil t)
(put 'kill-buffer-hook 'permanent-local t)
......
......@@ -589,45 +589,64 @@ Emacsen."
;; This code looks the way it does in order to avoid warnings in
;; Emacs 21.
(eval-when-compile
(if (boundp ':lyskom-is-this-self-evaluating)
(defmacro lyskom-make-self-evaluating (var))
(defmacro lyskom-make-self-evaluating (var)
`(eval-and-compile (set ',var ',var)))))
(lyskom-make-self-evaluating :default)
(lyskom-make-self-evaluating :mime-charset)
(lyskom-make-self-evaluating :default-help-echo)
(lyskom-make-self-evaluating :group)
(lyskom-make-self-evaluating :automatic)
(lyskom-make-self-evaluating :read-only)
(lyskom-make-self-evaluating :filter)
(lyskom-make-self-evaluating :filter-args)
(lyskom-make-self-evaluating :constraint)
(lyskom-make-self-evaluating :save)
(lyskom-make-self-evaluating :refer)
(lyskom-make-self-evaluating :width)
(lyskom-make-self-evaluating :prompt)
(lyskom-make-self-evaluating :align)
(lyskom-make-self-evaluating :format)
(lyskom-make-self-evaluating :output)
(lyskom-make-self-evaluating :subject-mode)
(lyskom-make-self-evaluating :subject-indent)
(lyskom-make-self-evaluating :text)
(lyskom-make-self-evaluating :text-stat)
(lyskom-make-self-evaluating :text-no)
(lyskom-make-self-evaluating :subjects)
(lyskom-make-self-evaluating :subject-last)
(lyskom-make-self-evaluating :comment-order)
(lyskom-make-self-evaluating :unique)
(lyskom-make-self-evaluating :weight)
(lyskom-make-self-evaluating :prompt-format)
(lyskom-make-self-evaluating :dead-ok)
(lyskom-make-self-evaluating :mark)
(lyskom-make-self-evaluating :test)
(lyskom-make-self-evaluating :size)
(lyskom-make-self-evaluating :may-interrupt)
;;; ================================================================
;;; Emacs 21.4 stuff
(lyskom-function-alias function-obsolete-p (function)
"Return non-nil if FUNCTION is obsolete"
(get function 'byte-obsolete-info))
(eval-and-compile
(defmacro lyskom-make-self-evaluating (var)
`(condition-case nil
(setq lyskom-dummy-variable-to-fool-the-byte-compiler
(symbol-value ',var))
(error (set ',var ',var))))
(lyskom-make-self-evaluating :default)
(lyskom-make-self-evaluating :mime-charset)
(lyskom-make-self-evaluating :default-help-echo)
(lyskom-make-self-evaluating :group)
(lyskom-make-self-evaluating :automatic)
(lyskom-make-self-evaluating :read-only)
(lyskom-make-self-evaluating :filter)
(lyskom-make-self-evaluating :filter-args)
(lyskom-make-self-evaluating :constraint)
(lyskom-make-self-evaluating :save)
(lyskom-make-self-evaluating :refer)
(lyskom-make-self-evaluating :width)
(lyskom-make-self-evaluating :prompt)
(lyskom-make-self-evaluating :align)
(lyskom-make-self-evaluating :format)
(lyskom-make-self-evaluating :output)
(lyskom-make-self-evaluating :subject-mode)
(lyskom-make-self-evaluating :subject-indent)
(lyskom-make-self-evaluating :text)
(lyskom-make-self-evaluating :text-stat)
(lyskom-make-self-evaluating :text-no)
(lyskom-make-self-evaluating :subjects)
(lyskom-make-self-evaluating :subject-last)
(lyskom-make-self-evaluating :comment-order)
(lyskom-make-self-evaluating :unique)
(lyskom-make-self-evaluating :weight)
(lyskom-make-self-evaluating :prompt-format)
(lyskom-make-self-evaluating :dead-ok)
(lyskom-make-self-evaluating :mark)
(lyskom-make-self-evaluating :test)
(lyskom-make-self-evaluating :size)
)
(if (and (lyskom-function-obsolete-p 'process-kill-without-query)
(fboundp 'set-process-query-on-exit-flag))
(fset 'lyskom-set-process-query-on-exit-flag 'set-process-query-on-exit-flag)
(fset 'lyskom-set-process-query-on-exit-flag 'process-kill-without-query)))
(eval-and-compile
(if (lyskom-function-obsolete-p 'make-local-hook)
(defun lyskom-make-local-hook (hook))
(fset 'lyskom-make-local-hook 'make-local-hook)))
;;; ================================================================
......
......@@ -33,7 +33,7 @@
;;;;
(defconst lyskom-clientversion-long
(defvar lyskom-clientversion-long
"$Id$\n"
"Version for every file in the client.")
......
......@@ -75,7 +75,7 @@ Value returned is always nil."
Variable VAR is bound to each membership, in turn, and FORMS are evaluated."
`(catch 'lyskom-traverse
(lyskom-avltree-traverse
(lambda (,var) ,@forms) (lyskom-mship-cache-data))))
(lambda (,var) ,@forms) (lyskom-with-lyskom-buffer (lyskom-mship-cache-data)))))
(defmacro lyskom-traverse-aux (atom sequence &rest body)
"Bind ATOM to each element in SEQUENCE and execute BODY.
......
......@@ -498,7 +498,7 @@
" "))))
(if shortcut
(progn (when (memq window-system '(win32 mswindows w32))
(setq shortcut (encode-coding-string shortcut 'iso-8859-1)))
(setq shortcut (lyskom-encode-coding-string shortcut 'iso-8859-1)))
(define-key map (vector symbol)
`(menu-item ,(lyskom-get-menu-string symbol) ,symbol
:keys ,shortcut)))
......
......@@ -159,12 +159,11 @@ This function does not tell the server about the change."
(old-priority (and mship (membership->priority mship))))
(when mship
(set-membership->priority mship new-priority)
(lyskom-sort-membership)
(lyskom-replace-membership mship)
(cond
((and (>= old-priority lyskom-session-priority)
(>= new-priority lyskom-session-priority))
; Don't (lyskom-sort-to-do-list) since lyskom-sort-membership will.
)
(lyskom-sort-to-do-list))
((and (< old-priority lyskom-session-priority)
(>= new-priority lyskom-session-priority))
......@@ -182,14 +181,10 @@ This function does not tell the server about the change."
(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
;; FIXME: 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-replace-membership mship)
(lyskom-update-membership-positions))))
......@@ -665,9 +660,7 @@ If optional NEW-MSHIP is non-nil, then get the membership again."
(cond
((null entry)
(let* ((pos (or (membership->position mship)
(- (length lyskom-membership)
(length (memq mship lyskom-membership)))))
(let* ((pos (lyskom-membership-position mship))
(elem (and pos (lp--get-entry pos)))
(entry (lyskom-create-lp--entry
nil
......@@ -1578,9 +1571,8 @@ Entry to this mode runs lyskom-prioritize-mode-hook."
(setq lp--list-start-marker (point-marker))
(goto-char (point-max))
(lyskom-sort-membership)
(lyskom-display-buffer buf)
(lyskom-traverse mship (lyskom-default-value 'lyskom-membership)
(lyskom-traverse-membership mship
(let ((entry (lyskom-create-lp--entry nil ; Start
nil ; End
(membership->priority mship)
......
......@@ -954,17 +954,15 @@ All key bindings:
(lyskom-ignore value help-sym dummy) ; Are they ever used?
(setq storage-widget
(condition-case nil
(prog1
(widget-create 'checkbox
':value (and (not (memq variable kom-dont-read-saved-variables))
(or (memq variable lyskom-elisp-variables)
(lyskom-flag-global-variable-from-elisp variable)))
':args variable
':format "%[%v%]"
':help-echo (lyskom-custom-string 'variable-type-help))
(widget-insert " "))
(error nil)))
(prog1
(widget-create 'checkbox
':value (and (not (memq variable kom-dont-read-saved-variables))
(or (memq variable lyskom-elisp-variables)
(lyskom-flag-global-variable-from-elisp variable)))
':args (list variable)
':format "%[%v%]"
':help-echo (lyskom-custom-string 'variable-type-help))
(widget-insert " ")))
(setq spec
(cons (car spec)
......@@ -1290,7 +1288,7 @@ All key bindings:
(list 'lyskom-number
':tag (lyskom-custom-string 'number-of-times)
':help-echo (lyskom-custom-string 'select-number)
':value "1"
':value 1
':format "%[%t%]: (%v)"
':size 0
':min-value 1
......@@ -1329,7 +1327,7 @@ All key bindings:
:match (lambda (w v) (or (null v) (eq v 0))))
(lyskom-number :tag ,(lyskom-custom-string 'number-of-times)
:help-echo ,(lyskom-custom-string 'select-number)
:value "1"
:value 1
:format "%[%t%]: (%v)"
:size 0
:min-value 1
......@@ -1423,11 +1421,12 @@ All key bindings:
'lyskom-number
(list ':min-value (elt args 0)
':max-value (elt args 1)
':value 0
':size 0)
propl)
(lyskom-build-simple-widget-spec
'lyskom-number
(list ':size 0)
(list ':size 0 ':value 0)
propl)))
;;;
......@@ -1699,10 +1698,16 @@ All key bindings:
(widget-setup)))
(defun lyskom-widget-number-value-to-external (widget value)
(string-to-int value))
(cond ((stringp value) (string-to-int value))
((numberp value) value)
((null value) 0)
(t (error "unable to convert settings value"))))
(defun lyskom-widget-number-value-to-internal (widget value)
(format "% 4d " value))
(cond ((stringp value) value)
((numberp value) (format "% 4d" value))
((null value) "")
(t (format "%S" value))))
(defun lyskom-widget-number-validate (widget)
(if (numberp (widget-value widget))
......
......@@ -204,89 +204,6 @@
"\n"))))
lyskom-prioritize-entry-list))))
(defun lyskom-prioritize-add-membership (membership)
(condition-case nil
(let ((buffer (car (lyskom-buffers-of-category 'prioritize))))
(if (buffer-live-p buffer)
(save-excursion
(set-buffer buffer)
(let ((tmp (lyskom-prioritize-get-entry-from-no
(membership->conf-no membership))))
(if tmp (lyskom-prioritize-replace-membership
membership
(lyskom-default-value 'lyskom-membership))
(let* ((entry (lyskom-prioritize-get-entry-from-priority
(membership->priority membership) t))
(no (lyskom-prioritize-get-no-from-entry entry)))
(setq lyskom-prioritize-entry-list
(lyskom-prioritize-add-to-list
(1- no )
(lyskom-create-prioritize-entry
(membership->priority membership)
(blocking-do 'get-conf-stat
(membership->conf-no membership))
membership)
lyskom-prioritize-entry-list))
(goto-line (+ no lyskom-prioritize-header-lines))
(let ((buffer-read-only nil))
(open-line 1)
(lyskom-prioritize-redraw-entry
(lyskom-prioritize-get-entry-from-no no)))))))
(lyskom-remove-hook 'lyskom-add-membership-hook
'lyskom-prioritize-add-membership)))
(error (message "Problem maintaining prioritize buffer. Recovering."))))
(defun lyskom-prioritize-remove-membership (conf-no membership-list)
(condition-case nil
(let ((buffer (car (lyskom-buffers-of-category 'prioritize))))
(if (buffer-live-p buffer)
(save-excursion
(set-buffer buffer)
(let ((entry (lyskom-prioritize-find-entry-from-conf conf-no)))
(lyskom-prioritize-goto-entry entry)
(let ((buffer-read-only nil))
(delete-region (save-excursion (beginning-of-line) (point))
(save-excursion (end-of-line) (point)))
(delete-char 1))
(setq lyskom-prioritize-entry-list
(lyskom-prioritize-remove-from-list
(1- (lyskom-prioritize-get-no-from-entry entry))
lyskom-prioritize-entry-list))))
(lyskom-remove-hook 'lyskom-remove-membership-hook
'lyskom-prioritize-remove-membership)))
(error (message "Problem maintaining prioritize buffer. Recovering."))))
(defun lyskom-prioritize-replace-membership (membership membership-list)
(condition-case nil
(let ((buffer (car (lyskom-buffers-of-category 'prioritize))))
(if (buffer-live-p buffer)
(save-excursion
(set-buffer buffer)
(let* ((entry (lyskom-prioritize-find-entry-from-conf
(membership->conf-no membership)))
(target-priority (membership->priority membership))
(entry-priority (prioritize-entry->priority entry))
(move-up (> target-priority entry-priority))
(target-entry
(lyskom-prioritize-get-entry-from-priority
target-priority
(not move-up))))
(when (not (eq target-priority entry-priority))
(set-prioritize-entry->priority entry target-priority)
(lyskom-prioritize-move-entry
(lyskom-prioritize-get-no-from-entry entry)
(+ (lyskom-prioritize-get-no-from-entry target-entry)
(cond ((and move-up (= (prioritize-entry->priority
target-entry)
target-priority)) 1)
((not move-up) -1)
(t 0)))
t t))))
(lyskom-remove-hook 'lyskom-replace-membership-hook
'lyskom-prioritize-replace-membership)))
(error (message "Problem maintaining prioritize buffer. Recovering."))))
(defun lyskom-prioritize-move-entry (from to &optional dontset forceup)
"Move entry from position FROM to position TO.
......@@ -793,15 +710,6 @@ Entry to this mode runs lyskom-prioritize-mode-hook."
(lyskom-prioritize-update-mode-line)
(setq buffer-read-only t)
(lyskom-use-local-map lyskom-prioritize-mode-map)
(lyskom-add-hook 'lyskom-add-membership-hook
'lyskom-prioritize-add-membership
t)
(lyskom-add-hook 'lyskom-remove-membership-hook
'lyskom-prioritize-remove-membership
t)
(lyskom-add-hook 'lyskom-replace-membership-hook
'lyskom-prioritize-replace-membership
t)
(run-hooks 'lyskom-prioritize-mode-hook))
......
......@@ -203,7 +203,7 @@ clients of the event. See lyskom-mode for details on lyskom."
(setq lyskom-www-proxy-connect-phase 1)
(set-process-filter proc
'lyskom-www-proxy-connect-filter)
(process-kill-without-query proc nil)
(lyskom-set-process-query-on-exit-flag proc nil)
(lyskom-process-send-string
proc
......@@ -245,7 +245,7 @@ clients of the event. See lyskom-mode for details on lyskom."
(lyskom-insert
(lyskom-format 'try-connect lyskom-clientversion host))
(set-process-filter proc 'lyskom-connect-filter)
(process-kill-without-query proc nil)
(lyskom-set-process-query-on-exit-flag proc nil)
(lyskom-process-send-string
proc
(concat "A"
......@@ -438,7 +438,7 @@ clients of the event. See lyskom-mode for details on lyskom."
kom-ssh-relay-host
"sh -c \"while :; do echo ok; sleep 600; done\"")))
(setenv "LC_ALL" old-lc-all)))
(process-kill-without-query proc))
(lyskom-set-process-query-on-exit-flag proc nil))
(while (progn
(goto-char (point-max))
(re-search-backward "^--- .* ---$" nil t)
......
......@@ -79,7 +79,7 @@ Inheritance only works with the LysKOM buffer handling functions."
(defun lyskom-setup-local-variables ()
"Set up all globally defined local variables in the current buffer."
(mapcar 'make-local-variable lyskom-local-variables)
(mapcar 'make-local-hook lyskom-local-hooks))
(mapcar 'lyskom-make-local-hook lyskom-local-hooks))
(defvar lyskom-is-loaded nil
"Non-nil when lyskom has been loaded.")
......
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