Commit 98e1cf5b authored by David Byers's avatar David Byers
Browse files

Fixed bugs 1638, 1542.

parent 6c0554cf
2007-07-07 <David Byers@GULAG>
* commands2.el (kom-delete-user-area): New command.
Fix bug 1542:
* flags.el (kom-copy-options): Pass portable-only to
lyskom-read-options.
(lyskom-copy-indirect-assq): New function.
* command.el (lyskom-start-of-command): Don't mess up
lyskom-default-user-name when reconnecting.
* vars.el.in: Marked a bunch of non-portable variables as such.
Marked some indirect assqs for copy-transition.
* flags.el (lyskom-read-options): Added portable-only argument.
(lyskom-read-options-eval): Same here.
(lyskom-maybe-set-var-from-string): Same here, and convert
variables when portable-only as requested.
* defvar.el (lyskom-save-variables): Cleaned up old backquote
syntax.
(lyskom-with-lyskom-minibuffer): Same here.
(def-kom-var): Same here.
(lyskom-non-portable-server-variables): New variable.
(def-kom-var): Support non-portable and copy-transition variable
specs.
Fix bug 1638:
* review.el (lyskom-maybe-run-mouse-2): New function to run unread
mouse-2 event under certain circumstances.
(kom-toggle-mark-as-read-prefix): Use lyskom-maybe-run-mouse-2
(kom-toggle-cache-prefix): Here too.
2007-07-07 David Byers <davby@sysinst-gw.sysinst.ida.liu.se>
* edit-text.el (lyskom-edit-insert-buglist): Don't use interactive
......
......@@ -594,13 +594,14 @@ chosen according to this"
(if (or (eq t kom-relogin-behaviour)
(and (eq 'ask kom-relogin-behaviour)
(lyskom-j-or-n-p (lyskom-get-string 'resurrect-session))))
(lyskom (if (= 4894 lyskom-server-port) ; Should we do this different?
lyskom-server-name
(concat lyskom-server-name
":"
(int-to-string lyskom-server-port)))
lyskom-pers-no
lyskom-default-password)
(let ((lyskom-default-user-name lyskom-default-user-name))
(lyskom (if (= 4894 lyskom-server-port) ; Should we do this different?
lyskom-server-name
(concat lyskom-server-name
":"
(int-to-string lyskom-server-port)))
lyskom-pers-no
lyskom-default-password))
(lyskom-error "%s" (lyskom-get-string 'dead-session)))))
(if (and lyskom-is-waiting
......
......@@ -1843,6 +1843,24 @@ primarily intended for use by developers."
nil nil nil nil nil)
(lyskom-wait-queue 'main)))
(def-kom-command kom-delete-user-area ()
"Remove the user area of the current person. The user area
is where all settings are stored. Deleting it means all settings
are lost. Do not delete the user area unless you're sure you really
want to."
(interactive)
(lyskom-format-insert 'delete-user-area-warning
`(face ,kom-warning-face))
(when (lyskom-ja-or-nej-p (lyskom-get-string 'delete-user-area-confirm))
(let* ((pers-stat (blocking-do 'get-pers-stat lyskom-pers-no))
(user-area (pers-stat->user-area pers-stat)))
(lyskom-insert 'deleting-user-area)
(lyskom-report-command-answer (blocking-do 'delete-text user-area))
(lyskom-insert 'removing-user-area)
(lyskom-report-command-answer (blocking-do 'set-user-area lyskom-pers-no 0))
)))
;;;============================================================
;;; Bli anonym
......
......@@ -395,7 +395,10 @@ visible in the event's window."
(lyskom-function-alias event-closest-point (e)
"Return the character position closest to the mouse event EVENT."
(car (cdr (event-start e)))))
(car (cdr (event-start e))))
(lyskom-function-alias event-type (e)
(event-basic-type e)))
;;; ======================================================================
......
......@@ -63,6 +63,9 @@ These are the flags that are saved in the elisp-client part of the server.")
"Tells the client what variables are not to be saved in the server, but
are to be read from the server. This is for transitioning.")
(defvar lyskom-copy-transition-variables nil
"Tells the client about variables that need transforming when copying.")
(defvar lyskom-minibuffer-variables nil
"These are variables that should be set in the minibuffer by
lyskom-with-lyskom-minibuffer.")
......@@ -75,6 +78,9 @@ lyskom-with-lyskom-minibuffer.")
Don't change these. They are defined by the protocol.")
(defvar lyskom-non-portable-server-variables nil
"List of variables that should not be copied from server to server.")
(defmacro lyskom-save-variables (var-list &rest forms)
"Save the values and property list of symbols in VAR-LIST and execute FORMS
......@@ -84,38 +90,37 @@ is saved before executing FORMS and restored when FORMS have finished."
(sym2 (make-symbol "lyskom-saved-symbols"))
(sym3 (make-symbol "lyskom-saved-local"))
(sym4 (make-symbol "lyskom-saved-plist")))
(` (let* (((, sym2) (quote (, var-list)))
((, sym1) (mapcar 'symbol-value (, sym2)))
((, sym4) (mapcar 'symbol-plist (, sym2)))
((, sym3) (mapcar (function
(lambda (v)
(local-variable-p v (current-buffer))))
(, sym2))))
`(let* ((,sym2 (quote ,var-list))
(,sym1 (mapcar 'symbol-value ,sym2))
(,sym4 (mapcar 'symbol-plist ,sym2))
(,sym3 (mapcar (lambda (v)
(local-variable-p v (current-buffer)))
,sym2)))
(unwind-protect
(progn (,@ forms))
(while (, sym1)
(if (car (, sym3)) (make-local-variable (car (, sym2))))
(set (car (, sym2)) (car (, sym1)))
(setplist (car (, sym2)) (car (, sym4)))
(setq (, sym1) (cdr (, sym1))
(, sym2) (cdr (, sym2))
(, sym3) (cdr (, sym3))
(, sym4) (cdr (, sym4)))))))))
(progn ,@forms)
(while ,sym1
(when (car ,sym3) (make-local-variable (car ,sym2)))
(set (car ,sym2) (car ,sym1))
(setplist (car ,sym2) (car ,sym4))
(setq ,sym1 (cdr ,sym1)
,sym2 (cdr ,sym2)
,sym3 (cdr ,sym3)
,sym4 (cdr ,sym4)))))))
(put 'lyskom-save-variables 'edebug-form-spec
'(sexp body))
(defmacro lyskom-with-lyskom-minibuffer (&rest forms)
"Run FORMS after ensuring that LysKOM minibuffer variables will be set."
(` (let* ((lyskom-minibuffer-values
(mapcar 'symbol-value lyskom-minibuffer-variables)))
(unwind-protect
(progn
(add-hook 'minibuffer-setup-hook
'lyskom-setup-minibuffer-variables)
(,@ forms))
(remove-hook 'minibuffer-setup-hook
'lyskom-setup-minibuffer-variables)))))
`(let* ((lyskom-minibuffer-values
(mapcar 'symbol-value lyskom-minibuffer-variables)))
(unwind-protect
(progn
(add-hook 'minibuffer-setup-hook
'lyskom-setup-minibuffer-variables)
,@forms)
(remove-hook 'minibuffer-setup-hook
'lyskom-setup-minibuffer-variables))))
(put 'lyskom-with-lyskom-minibuffer 'edebug-form-spec
'(body))
......@@ -153,10 +158,12 @@ language-force A language-variable whose value is to be forced."
(protected nil)
(elisp-block nil)
(transition-block nil)
(copy-transition-block nil)
(buffer-local nil)
(widget-spec nil)
(doc-string nil)
(minibuffer nil)
(non-portable nil)
(local-hook-doc nil)
(local-var-doc nil)
(server-doc nil)
......@@ -167,16 +174,15 @@ language-force A language-variable whose value is to be forced."
(cond ((stringp (car arglist)) (setq doc-string (car arglist)))
((consp (car arglist))
(setq widget-spec
(` ((setq lyskom-custom-variables
(cons (quote (, (list name
(car arglist))))
lyskom-custom-variables))))))
`((setq lyskom-custom-variables
(cons (quote ,(list name (car arglist)))
lyskom-custom-variables)))))
((symbolp (car arglist))
(cond ((eq (car arglist) 'server)
(setq local-var-doc t server-doc t)
(setq elisp-block
`((add-to-list 'lyskom-elisp-variables ', name)
(add-to-list 'lyskom-local-variables ', name))))
`((add-to-list 'lyskom-elisp-variables ',name)
(add-to-list 'lyskom-local-variables ',name))))
((eq (car arglist) 'common)
(setq local-var-doc t server-doc t)
......@@ -197,50 +203,52 @@ language-force A language-variable whose value is to be forced."
'(,name . ,converter))
(add-to-list 'lyskom-local-variables ',name)))))
((eq (car arglist) 'copy-transition)
(let ((converter (car (cdr arglist))))
(setq arglist (cdr arglist))
(setq local-var-doc t server-doc t)
(setq copy-transition-block
`((add-to-list 'lyskom-copy-transition-variables
'(,name . ,converter))))))
((eq (car arglist) 'server-hook)
(setq local-hook-doc t server-doc t)
(setq elisp-block
(` ((add-to-list 'lyskom-elisp-variables
(quote (, name)))
(add-to-list 'lyskom-local-hooks
(quote (, name)))))))
`((add-to-list 'lyskom-elisp-variables ',name)
(add-to-list 'lyskom-local-hooks ',name))))
((eq (car arglist) 'protected)
(setq local-var-doc t)
(setq protected
(` ((put (quote (, name)) 'permanent-local t)
(add-to-list 'lyskom-protected-variables
(quote (, name)))
(add-to-list 'lyskom-local-variables
(quote (, name)))))))
`((put ',name 'permanent-local t)
(add-to-list 'lyskom-protected-variables ',name)
(add-to-list 'lyskom-local-variables ',name))))
((eq (car arglist) 'inherited)
(setq local-var-doc t)
(setq inherited
(` ((add-to-list 'lyskom-inherited-variables
(quote (, name)))
(put (quote (, name)) 'permanent-local t)
(add-to-list 'lyskom-protected-variables
(quote (, name)))
(add-to-list 'lyskom-local-variables
(quote (, name)))))))
`((add-to-list 'lyskom-inherited-variables ',name)
(put ',name 'permanent-local t)
(add-to-list 'lyskom-protected-variables ',name)
(add-to-list 'lyskom-local-variables ',name))))
((eq (car arglist) 'local)
(setq local-var-doc t)
(setq buffer-local
(` ((add-to-list 'lyskom-local-variables
(quote (, name)))))))
`((add-to-list 'lyskom-local-variables ',name))))
((eq (car arglist) 'local-hook)
(setq local-hook-doc t)
(setq buffer-local
(` ((add-to-list 'lyskom-local-hooks
(quote (, name)))))))
`((add-to-list 'lyskom-local-hooks ',name))))
((eq (car arglist) 'non-portable)
(setq non-portable
`((add-to-list 'lyskom-non-portable-server-variables ',name))))
((eq (car arglist) 'minibuffer)
(setq minibuffer
(` ((add-to-list 'lyskom-minibuffer-variables
(quote (, name)))))))
`((add-to-list 'lyskom-minibuffer-variables ',name))))
((eq (car arglist) 'language-force)
(setq language-force
......@@ -273,23 +281,24 @@ This variable is normally stored on a per-session basis in the
LysKOM server, but can be set in your .emacs simply by setting
it using setq or defvar.")))
(` (progn (dont-compile (if (and (boundp (quote (, name)))
(or (not (boundp lyskom-is-loaded))
(not lyskom-is-loaded))
(listp kom-dont-read-saved-variables))
(add-to-list 'kom-dont-read-saved-variables
(quote (, name)))))
(defvar (, name) (, value) (, doc-string))
(,@ (apply 'append
(list inherited
protected
elisp-block
transition-block
buffer-local
minibuffer
widget-spec
language-force
)))))))
`(progn (dont-compile (if (and (boundp ',name)
(or (not (boundp lyskom-is-loaded))
(not lyskom-is-loaded))
(listp kom-dont-read-saved-variables))
(add-to-list 'kom-dont-read-saved-variables ',name)))
(defvar ,name ,value ,doc-string)
,@(apply 'append
(list inherited
protected
elisp-block
transition-block
copy-transition-block
buffer-local
minibuffer
non-portable
widget-spec
language-force
)))))
(put 'def-kom-var 'edebug-form-spec
......@@ -298,6 +307,3 @@ it using setq or defvar.")))
(eval-and-compile (provide 'lyskom-defvar))
......@@ -2063,6 +2063,21 @@ written a presentation.%]
")
(delete-user-area-warning . "\
%#1@\
========================================================================
If you delete your user area, all your saved settings will be lost. You
can restore the user area by saving your current settings, but any
saved settings from other clients will still be lost.
Are you completely certain that you know what you are doing and that
you really want to delete your user area?
========================================================================
")
(delete-user-area-confirm . "Delete your user area and all saved settings? ")
(removing-user-area . "Removing reference to user area from person status...")
(deleting-user-area . "Deleting the user area...")
(status-server-stats . "Server statistics:\n\n")
(current-average . "current")
......
......@@ -86,7 +86,7 @@ settings and save them to your emacs init file."
completions
nil t)))
(lyskom-message (lyskom-get-string 'reading-settings-from) from-session)
(setq lyskom-saved-unknown-variables (lyskom-read-options from-session))
(setq lyskom-saved-unknown-variables (lyskom-read-options from-session t))
(lyskom-message (lyskom-get-string 'reading-settings-from-done) from-session)
;; Inline kom-save-options
......@@ -96,6 +96,18 @@ settings and save them to your emacs init file."
(lyskom-get-string 'could-not-save-options))
))
(defun lyskom-copy-indirect-assq (val)
"Attempt to filter out non-portable stuff from an indirect assq"
(cond ((eq val t) t)
((eq val nil) nil)
(t (delq nil
(mapcar (lambda (el)
(cond ((numberp el) nil)
((atom el) el)
((and (consp el) (symbolp (car el))) el)
(t nil)))
val)))))
;;;============================================================
;;; lyskom-save-options
......@@ -252,13 +264,15 @@ settings and save them to your emacs init file."
(lyskom-format-insert 'could-not-set-user-area lyskom-errno)
(when error-message (lyskom-message "%s" error-message)))))
(defun lyskom-read-options (&optional buffer)
(defun lyskom-read-options (&optional buffer portable-only)
"Reads the user-area and sets the variables according to the choises.
Returns a association list of variables that were ignored. Each list
element is a cons (NAME . VALUE), where NAME is the name of the variable
and VALUE is the unparsed value (i.e. it is always a string).
If optional BUFFER is non-nil, read settings in that buffer."
If optional BUFFER is non-nil, read settings in that buffer.
If optional PORTABLE-ONLY is non-nil, skip variables marked non-portable."
(if (and lyskom-pers-no
(not (zerop lyskom-pers-no)))
(let ((pers-stat
......@@ -278,13 +292,16 @@ If optional BUFFER is non-nil, read settings in that buffer."
(save-excursion
(when buffer (set-buffer buffer))
(blocking-do 'get-text
(pers-stat->user-area pers-stat)))))))
(pers-stat->user-area pers-stat)))
portable-only))))
nil))
(defun lyskom-read-options-eval (text)
(defun lyskom-read-options-eval (text &optional portable-only)
"Handles the call from where we have the text.
Returns a alist of variables that were ignored. See lyskom-read-options
for more information."
for more information.
If optional PORTABLE-ONLY is non-nil, skip variables marked non-portable."
(let ((ignored-user-area-vars nil))
(condition-case nil
(when text ;+++ Other error handler
......@@ -333,7 +350,7 @@ for more information."
(cons tmp lyskom-global-variables))
tmp))))
(unless (lyskom-maybe-set-var-from-string (elt spec 1) value (elt spec 2))
(unless (lyskom-maybe-set-var-from-string (elt spec 1) value (elt spec 2) portable-only)
(setq ignored-user-area-vars
(cons (cons (elt spec 1) value) ignored-user-area-vars))))))
;; Note that elisp-no may be nil here, so the comparison
......@@ -344,7 +361,7 @@ for more information."
(while (> (length lyskom-options-text) 2)
(setq name (intern (lyskom-read-options-eval-get-holerith)))
(setq value (lyskom-read-options-eval-get-holerith))
(if (lyskom-maybe-set-var-from-string name value)
(if (lyskom-maybe-set-var-from-string name value nil portable-only)
(when (functionp (cdr (assq name lyskom-transition-variables)))
(set name (funcall (cdr (assq name lyskom-transition-variables))
(symbol-value name))))
......@@ -442,17 +459,22 @@ If optional NO-CODING is set, assume the string has internal coding."
(cons (lyskom-decode-coding-string name coding) string)
(error (cons name string)))))))
(defun lyskom-maybe-set-var-from-string (var string &optional type)
(defun lyskom-maybe-set-var-from-string (var string &optional type portable-only)
"This is a wrapper around lyskom-set-var-from-string that does nothing
if the variable is in kom-dont-read-saved-variables.
Return non-nil if the variable shouldn't have been set in the first place."
(cond ((eq kom-dont-read-saved-variables t) t)
((memq var kom-dont-read-saved-variables) t)
((not (or (memq var lyskom-elisp-variables)
(assq var lyskom-transition-variables)
(lyskom-flag-global-variable-from-elisp var))) nil)
(t (lyskom-set-var-from-string var string type) t)))
(prog1
(cond ((eq kom-dont-read-saved-variables t) t)
((memq var kom-dont-read-saved-variables) t)
((and portable-only (memq var lyskom-non-portable-server-variables)) nil)
((not (or (memq var lyskom-elisp-variables)
(assq var lyskom-transition-variables)
(lyskom-flag-global-variable-from-elisp var))) nil)
(t (lyskom-set-var-from-string var string type) t))
(when (and portable-only (assq var lyskom-copy-transition-variables))
(set var (funcall (cdr (assq var lyskom-copy-transition-variables))
(symbol-value var))))))
(defun lyskom-set-var-from-string (var string &optional type)
"This is a wrapper aroud read-from-string.
......
......@@ -95,6 +95,22 @@
;;; ================================================================
;;; Temoporary change of mark-as-read
(defun lyskom-maybe-run-mouse-2 (command)
(lyskom-xemacs-or-gnu
nil
(when (and (eq command 'mouse-drag-region)
unread-command-events
(eventp (car unread-command-events))
(eq (lyskom-event-type
(car unread-command-events)) 'mouse-2))
(let* ((sequence (vector (car unread-command-events)))
(command (or (lookup-key (current-local-map)
sequence)
(lookup-key global-map sequence))))
(setq unread-command-events (cdr unread-command-events))
(when (commandp command)
(call-interactively command))))))
(defun kom-toggle-mark-as-read-prefix ()
"Read one key sequence and run one command with state of
kom-review-marks-texts-as-read toggled."
......@@ -113,7 +129,8 @@ kom-review-marks-texts-as-read toggled."
(setq command (or (lookup-key (current-local-map) sequence)
(lookup-key global-map sequence))))
(when (commandp command)
(call-interactively command))))
(call-interactively command))
(lyskom-maybe-run-mouse-2 command)))
(defun kom-toggle-cache-prefix ()
"Read one key sequence and run one command with state of
......@@ -128,7 +145,8 @@ kom-review-marks-texts-as-read toggled."
'review-not-using-cache)))))
(command (lookup-key (current-local-map) sequence)))
(when (commandp command)
(call-interactively command))))
(call-interactively command))
(lyskom-maybe-run-mouse-2 command)))
;; (defun kom-toggle-topic-prefix ()
;; "Read one key sequence and run one command with the review
......
......@@ -2108,6 +2108,22 @@ att upprepas d
")
(delete-user-area-warning . "\
%#1@\
========================================================================
Om du raderar user-arean s kommer alla dina sparade instllningar att
frsvinna. Du kan naturligtvis spara dina aktuella instllningar, och
d kommer en ny user-area att skapas med elispklientens (men inga andra
klienters) instllningar.
r du helt sker p att du vet var du hller p med och att du verkligen
vill radera din user-area?
========================================================================
")
(delete-user-area-confirm . "Radera din user-area och alla sparade instllningar? ")
(removing-user-area . "Tar bort hnvisningen till user-arean frn din personstatus...")
(deleting-user-area . "Raderar din user-area...")
(status-server-stats . "Statistik om servern:\n\n")
(current-average . "nu")
......@@ -2351,6 +2367,7 @@ Nuvarande r
(kom-filter-edit . "ndra filter")
(kom-list-filters . "Lista filter")
(kom-show-user-area . "Visa user-arean")
(kom-delete-user-area . "Ta bort user-arean")
(kom-change-conf-type . "ndra mtestyp")
(kom-change-auto-reply . "ndra svarsmeddelande")
......
......@@ -1524,7 +1524,8 @@ If you want the messages in the buffer, set the variable
`kom-presence-messages-in-buffer'.
Values other than those listed are reserved for future use."
server)
server
copy-transition lyskom-copy-indirect-assq)
(def-kom-var kom-presence-messages-in-buffer nil
"**Controls display of presence messages in the LysKOM buffer.
......@@ -1535,7 +1536,8 @@ prompt.
See `kom-presence-messages-in-echo-area for a list of permitted
values."
server)
server
copy-transition lyskom-copy-indirect-assq)
(def-kom-var kom-unread-mode-line-type nil
"**Controls how information about unread sessions is shown in the mode line.
......@@ -1795,7 +1797,8 @@ This variable contains the name of the current LysKOM session (a string)
or `nil'. If set, it will be used as the nickname for this LysKOM session.
See also `kom-server-aliases' and `kom-builtin-server-aliases'."
server)
server
non-portable)
(def-kom-var kom-view-text-hook nil
"**Hook that is called before a text is shown.
......@@ -2175,7 +2178,8 @@ group and alarm messages sent by users in this list will be silently
ignored.
Values other than those listed are reserved for future use."
server)
server
copy-transition lyskom-copy-indirect-assq)
(def-kom-var kom-ignore-message-recipients nil
"**List of recipients you do not want group messages to.
......@@ -2184,7 +2188,8 @@ The value of this variable must be a list of conference numbers.
Messages sent to a recipient listed will be silently ignored.
Values other than those listed are reserved for future use."
server)
server
copy-transition lyskom-copy-indirect-assq)
(def-kom-var kom-show-personal-message-date t
"**Controls display of date on personal messages.
......@@ -2280,7 +2285,8 @@ will vary depending on how it is printed. Functions should be written
so they work regardless of what is passed to them.
All other values are reserved for future use."
server)
server
copy-transition lyskom-copy-indirect-assq)
(def-kom-var kom-person-list-1 nil
"**General list of persons.
......@@ -2288,7 +2294,8 @@ All other values are reserved for future use."
This variable has no predefined meanind and is intended for use
in variables such as `kom-presence-messages-in-buffer' and
`kom-highlight-conferences'."
server)
server
non-portable)
(def-kom-var kom-person-list-2 nil
"**General list of persons.
......@@ -2296,7 +2303,8 @@ in variables such as `kom-presence-messages-in-buffer' and
This variable has no predefined meanind and is intended for use
in variables such as `kom-presence-messages-in-buffer' and
`kom-highlight-conferences'."
server)
server
non-portable)
(def-kom-var kom-person-list-3 nil
"**General list of persons.
......@@ -2304,7 +2312,8 @@ in variables such as `kom-presence-messages-in-buffer' and
This variable has no predefined meanind and is intended for use
in variables such as `kom-presence-messages-in-buffer' and