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

Don't lose unknown settings. Store client version with settings. Perhaps fixed...

Don't lose unknown settings. Store client version with settings. Perhaps fixed bug 744. Better content-type decoding.

Detailed changes:
> 2004-02-29  David Byers  <byers@lysator.liu.se>
>
> 	* macros.el (lyskom-mime-content-type-get): Moved here from
> 	mime.el.
> 	(lyskom-mime-content-type): Moved here from mime.el.
>
> 	Fix bug 744 (I think):
> 	* flags.el (lyskom-save-options): Save unknown variables too.
> 	(lyskom-save-options): Encode variable names too. Despite them
> 	being all ASCII, Emacs will sometimes think one is a multibyte
> 	string, and then convert everything back to multibyte format,
> 	which will break the user area. Refuse to save if any part of the
> 	user area is a multibyte string.
>
> 	Don't throw away contents of unknown variables:
> 	* vars.el.in (lyskom-saved-unknown-variables): New variable.
> 	(lyskom-settings-version): New variable.
>
> 	* flags.el (kom-copy-options): Don't discard unknown variables.
>
> 	* startup.el (kom-start-anew): Tell the user that unknown
> 	variables may be due to changing client versions (if settings were
> 	saved in a different version than we're running right now).
>
> 	* flags.el (kom-save-options): Accept prefix argument to delete
> 	unknown variables.
>
> 	* async.el (lyskom-async-new-user-area): Tell the user when
> 	re-reading settings from the server. Don't discard unknown
> 	variables.
>
> 	* flags.el (lyskom-read-options-eval): The list of ignored
> 	variables is an alist of name and value.
>
> 	* startup.el (kom-start-anew): lyskom-read-flags now returns a
> 	alist for ignored variables. Don't discard unknown variables.
>
> 2004-02-28  David Byers  <byers@lysator.liu.se>
>
> 	Prepare for dealing with format=flowed texts:
> 	* komtypes.el (text->decoded-text-mass): Use new content-type
> 	functions and format.
>
> 	* edit-text.el (lyskom-edit-send): Use new content-type functions
> 	and format.
>
> 	* mime.el (lyskom-mime-decode-content-type): Rewrote to handle
> 	arbitrary parameters to the content type.
> 	(lyskom-mime-content-type): New function.
> 	(lyskom-mime-content-type-get): New function.
>
2a54
> 	Fix bug 1281 and related issues:
parent 65dab22a
2004-02-29 David Byers <byers@lysator.liu.se>
* macros.el (lyskom-mime-content-type-get): Moved here from
mime.el.
(lyskom-mime-content-type): Moved here from mime.el.
Fix bug 744 (I think):
* flags.el (lyskom-save-options): Save unknown variables too.
(lyskom-save-options): Encode variable names too. Despite them
being all ASCII, Emacs will sometimes think one is a multibyte
string, and then convert everything back to multibyte format,
which will break the user area. Refuse to save if any part of the
user area is a multibyte string.
Don't throw away contents of unknown variables:
* vars.el.in (lyskom-saved-unknown-variables): New variable.
(lyskom-settings-version): New variable.
* flags.el (kom-copy-options): Don't discard unknown variables.
* startup.el (kom-start-anew): Tell the user that unknown
variables may be due to changing client versions (if settings were
saved in a different version than we're running right now).
* flags.el (kom-save-options): Accept prefix argument to delete
unknown variables.
* async.el (lyskom-async-new-user-area): Tell the user when
re-reading settings from the server. Don't discard unknown
variables.
* flags.el (lyskom-read-options-eval): The list of ignored
variables is an alist of name and value.
* startup.el (kom-start-anew): lyskom-read-flags now returns a
alist for ignored variables. Don't discard unknown variables.
2004-02-28 David Byers <byers@lysator.liu.se>
Prepare for dealing with format=flowed texts:
* komtypes.el (text->decoded-text-mass): Use new content-type
functions and format.
* edit-text.el (lyskom-edit-send): Use new content-type functions
and format.
* mime.el (lyskom-mime-decode-content-type): Rewrote to handle
arbitrary parameters to the content type.
(lyskom-mime-content-type): New function.
(lyskom-mime-content-type-get): New function.
2004-02-27 David Byers <byers@lysator.liu.se>
Fix bug 1281 and related issues:
* commands1.el (kom-write-comment): Use new def-kom-command
features.
(kom-private-answer): Ditto.
......
......@@ -334,7 +334,12 @@ this function shall be with current-buffer the BUFFER."
(when (and need-reread
new-user-area
(not (zerop new-user-area)))
(initiate-get-text 'follow 'lyskom-read-options-eval new-user-area)))))
(initiate-get-text 'follow (lambda (text)
(when text
(lyskom-format-insert-before-prompt 'reading-settings-from-server)
(setq lyskom-saved-unknown-variables
(lyskom-read-options-eval text))))
new-user-area)))))
(defun lyskom-async-forced-leave-conf (conf-stat conf-no)
......
......@@ -537,8 +537,10 @@ anonymously and take actions to avoid revealing the sender."
(t (concat (or subject "") "\n" message))))
(content-type (lyskom-get-aux-item aux-list 1))
(charset (and content-type
(cdr (lyskom-mime-decode-content-type
(aux-item->data (car content-type))))))
(lyskom-mime-content-type-get
(lyskom-mime-decode-content-type
(aux-item->data (car content-type)))
'charset)))
(mime-charset (lyskom-mime-string-charset full-message)))
;; If the charset isn't already set, encode the string
......
......@@ -1166,6 +1166,15 @@ Alarm from %#1P (%#3s):
; From flags.el:
(saving-settings . "Saving options...")
(saving-settings-done . "Saving options...done")
(save-options-failed-internal . "\
Failed to save options because of an internal error.
Global options: %#1?b%[Encoding failed%]%[OK%]
Elisp client options: %#2?b%[Encoding failed%]%[OK%]
Other client options: %#3?b%[Encoding failed%]%[OK%]
Rapportera grna detta fel till elispklientens utvecklare.
")
(hang-on . "Wait a moment...\n")
(no-changes . "Nothing was saved since no options had been changed.\n")
(could-not-save-options . "Couldn't save options.\n")
......@@ -1176,6 +1185,7 @@ Alarm from %#1P (%#3s):
It was set to \"%#2s\" in the user area. It is set to nil instead.
Send a bug report.\n")
(error-in-options-short . "There was an error in your saved settings. Some settings have not been read.")
(reading-settings-from-server . "Saved settings have changed on the server. Re-reading saved settings.\n")
; From elib-string.el:
; No entries.
......@@ -1852,7 +1862,13 @@ Ignoring the following variables in your settings:
These variables are not registered as LysKOM variables and cannot be
read from the server. You can remove the variables from the server by
giving the command \"Save options\".\n\n")
giving the command \"Save options\".
%#2?b%[%#5F\
Unknown variables may be the result of saving your settings in version
%#3s of the client; this is version %#4s.
%]%[%]")
(unknown-aux-item . "Unknown property")
......
......@@ -49,13 +49,15 @@
"When we have read all options this is turned non-nil."
local)
(def-kom-command kom-save-options ()
(def-kom-command kom-save-options (arg)
"Save all LysKOM settings. This will save settings in the server but
not save anything to your Emacs init file (usually .emacs).
not save anything to your Emacs init file (usually .emacs). With a
prefix argument, remove all unknown settings.
To edit settings, use `kom-customize'. This command can also save
settings to your emacs init file."
(interactive)
(interactive "P")
(when arg (setq lyskom-saved-unknown-variables nil))
(lyskom-save-options (or lyskom-buffer
(current-buffer))
(lyskom-get-string 'saving-settings)
......@@ -84,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)
(lyskom-read-options from-session)
(setq lyskom-saved-unknown-variables (lyskom-read-options from-session))
(lyskom-message (lyskom-get-string 'reading-settings-from-done) from-session)
;; Inline kom-save-options
......@@ -136,43 +138,35 @@ settings and save them to your emacs init file."
"\n")
))
(elisp-block
(mapconcat
(lambda (var)
(concat (format "%dH%s"
(length (symbol-name var))
(symbol-name var))
" "
(let* ((data (lyskom-flag-value-to-string var))
(coding
(lyskom-mime-charset-coding-system
(lyskom-mime-string-charset data)))
(val (condition-case nil
(lyskom-encode-coding-string data coding)
(error nil))))
(lyskom-ignore val)
(if (and val nil)
(format "%dC%s%dH%s"
(lyskom-string-bytes (symbol-name coding))
(symbol-name coding)
(lyskom-string-bytes val)
val)
(setq data
(lyskom-encode-coding-string
data
(or lyskom-server-coding-system 'raw-text)))
(format "%dH%s"
(lyskom-string-bytes data)
data)))))
lyskom-elisp-variables
"\n")))
(save-excursion
(set-buffer kombuf)
(when start-message (lyskom-message "%s" start-message))
(initiate-create-text
'options
'lyskom-save-options-2
(cons 'raw-text
(apply 'lyskom-format-objects
(concat (mapconcat
(lambda (var)
(let ((name (lyskom-encode-coding-string
(symbol-name var)
(or lyskom-server-coding-system 'raw-text)))
(data (lyskom-encode-coding-string
(lyskom-flag-value-to-string var)
(or lyskom-server-coding-system 'raw-text))))
(format "%dH%s %dH%s"
(lyskom-string-bytes name) name
(lyskom-string-bytes data) data)))
lyskom-elisp-variables
"\n")
(mapconcat
(lambda (el)
(let ((var (lyskom-encode-coding-string
(symbol-name (car el))
(or lyskom-server-coding-system 'raw-text)))
(data (lyskom-encode-coding-string
(cdr el)
(or lyskom-server-coding-system 'raw-text))))
(format "\n%dH%s %dH%s"
(lyskom-string-bytes var)
var
(lyskom-string-bytes data)
data)))
lyskom-saved-unknown-variables
"")))
(user-area (apply 'lyskom-format-objects
(apply 'lyskom-format-objects
"common"
"elisp"
......@@ -183,18 +177,54 @@ settings and save them to your emacs init file."
(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)
(list
(lyskom-create-aux-item
0 1 nil nil
(lyskom-create-aux-item-flags nil nil nil nil nil nil nil nil)
0
"x-kom/user-area"))
kombuf
done-message
error-message))))
(cons 'STRING (cons 'raw-text (cdr el))))
lyskom-other-clients-user-areas))))
(if (or (lyskom-multibyte-string-p elisp-block)
(lyskom-multibyte-string-p common-block)
(memq t (mapcar 'lyskom-multibyte-string-p lyskom-other-clients-user-areas)))
(lyskom-save-excursion
(set-buffer kombuf)
(lyskom-format-insert 'save-options-failed-internal
(lyskom-multibyte-string-p common-block)
(lyskom-multibyte-string-p elisp-block)
(memq t (mapcar 'lyskom-multibyte-string-p
lyskom-other-clients-user-areas)))
(when error-message (lyskom-message "%s" error-message)))
(save-excursion
(set-buffer kombuf)
(when start-message (lyskom-message "%s" start-message))
(initiate-create-text
'options
'lyskom-save-options-2
(cons 'raw-text user-area)
(lyskom-create-misc-list)
(list
(lyskom-create-aux-item
0 1 nil nil
(lyskom-create-aux-item-flags nil nil nil nil nil nil nil nil)
0
"x-kom/user-area"))
kombuf
done-message
error-message)))))
;; This was in lyskom-save-options, to encode each string usgin
;; its own coding system
;;
;; (coding
;; (lyskom-mime-charset-coding-system
;; (lyskom-mime-string-charset data)))
;; (val (condition-case nil
;; (lyskom-encode-coding-string data coding)
;; (error nil)))
;; (lyskom-ignore val)
;; (format "%dC%s%dH%s"
;; (lyskom-string-bytes (symbol-name coding))
;; (symbol-name coding)
;; (lyskom-string-bytes val)
;; val)
(defun lyskom-save-options-2 (text-no kombuf done-message error-message)
(if text-no
......@@ -222,8 +252,11 @@ settings and save them to your emacs init file."
(defun lyskom-read-options (&optional buffer)
"Reads the user-area and sets the variables according to the choises.
Returns a list of variables that were ignored. If optional BUFFER is
non-nil, read settings in that buffer."
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 (and lyskom-pers-no
(not (zerop lyskom-pers-no)))
(let ((pers-stat
......@@ -248,7 +281,8 @@ non-nil, read settings in that buffer."
(defun lyskom-read-options-eval (text)
"Handles the call from where we have the text.
Returns a list of variables that were ignored."
Returns a alist of variables that were ignored. See lyskom-read-options
for more information."
(let ((ignored-user-area-vars nil))
(condition-case nil
(when text ;+++ Other error handler
......@@ -299,7 +333,7 @@ Returns a list of variables that were ignored."
(unless (lyskom-maybe-set-var-from-string (elt spec 1) value (elt spec 2))
(setq ignored-user-area-vars
(cons (elt spec 1) 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
;; cannot be performed with '=.
((equal r elisp-no)
......@@ -313,7 +347,7 @@ Returns a list of variables that were ignored."
(set name (funcall (cdr (assq name lyskom-transition-variables))
(symbol-value name))))
(setq ignored-user-area-vars
(cons name ignored-user-area-vars))))))
(cons (cons name value) ignored-user-area-vars))))))
(t
(let ((pos lyskom-other-clients-user-areas))
(while (and pos
......
......@@ -347,11 +347,11 @@ Automatically created with def-komtype" type)
(content-type (and (car item)
(lyskom-mime-decode-content-type
(aux-item->data (car item))))))
(if (cdr content-type)
(lyskom-mime-decode-string str (cdr content-type))
(if (lyskom-mime-content-type-get content-type 'charset)
(lyskom-mime-decode-string str (lyskom-mime-content-type-get content-type 'charset))
str))))
;;; ================================================================
;;; misc-info
......
......@@ -2108,6 +2108,7 @@ Deferred insertions are not supported."
(lyskom-try-require 'latin-unity)
(lyskom-with-external-functions (smiley-region latin-unity-remap-region)
(defun lyskom-format-text-body (text &optional text-stat)
"Format a text for insertion. Does parsing of special markers in the text."
(let* ((ct-item (and text-stat (car (text-stat-find-aux text-stat 1))))
......
......@@ -350,6 +350,9 @@ the current buffer, and its value is copied from the LysKOM buffer."
(when (< lyskom-ref-no 0) (setq lyskom-ref-no 1))))
(defsubst lyskom-mime-content-type (ct) (car ct))
(defsubst lyskom-mime-content-type-get (ct param) (cdr (assq param (cdr ct))))
(eval-and-compile (provide 'lyskom-macros))
;;; Local Variables:
......
......@@ -118,10 +118,25 @@
data)))
(defun lyskom-mime-decode-content-type (data)
(string-match "^\\([^;]*\\)\\(;.*charset=\\([^;]*\\)\\)?" data)
(cons (match-string 1 data)
(if (match-string 3 data)
(intern (match-string 3 data))
nil)))
(let ((content-type nil)
(params nil)
(start 0))
(when (string-match "^[^;]*" data)
(setq content-type (match-string 0 data))
(setq start (match-end 0)))
(while (string-match ";\\([^=;]*\\)\\(=\\([^;]*\\)\\)" data start)
(let ((param-name (intern (match-string 1 data)))
(param-value (match-string 3 data)))
(when (and (memq param-name '(charset format))
param-value)
(setq param-value (intern param-value)))
(setq params (cons (cons param-name (or param-value t)) params)))
(setq start (match-end 0)))
(cons content-type params)))
(provide 'lyskom-mime)
......@@ -559,10 +559,12 @@ All key bindings:
(defvar lyskom-custom-variables-missing '(kom-permanent-filter-list
kom-quit-hook lyskom-last-known-conf-no
kom-quit-hook
lyskom-last-known-conf-no
lyskom-last-known-pers-no
kom-presence-messages
kom-dont-complain-about-missing-presentation)
kom-dont-complain-about-missing-presentation
lyskom-settings-version)
"List of user variables not in lyskom-custom-variables.")
(defvar lyskom-custom-variables
......
......@@ -667,9 +667,14 @@ shown to other users."
(when ignored-user-area-vars
(lyskom-format-insert-before-prompt
'ignored-user-area-var
(mapconcat 'symbol-name
(mapconcat (lambda (x) (symbol-name (car x)))
ignored-user-area-vars
"\n ")))
"\n ")
(lyskom-string= lyskom-clientversion lyskom-settings-version)
lyskom-settings-version
lyskom-clientversion
72)
(setq lyskom-saved-unknown-variables ignored-user-area-vars))
;; Show motd and encourage writing a presentation
......
......@@ -1198,6 +1198,15 @@ Gruppmeddelande till %#3M\nfr
;; From flags.el:
(saving-settings . "Sparar instllningarna...")
(saving-settings-done . "Sparar instllningarna...klart")
(save-options-failed-internal . "\
Det gick inte att spara instllningarna p grund av ett internt fel.
Globala instllningar: %#1?b%[Kodningen misslyckades%]%[OK%]
Elispklientens instllningar: %#2?b%[Kodningen misslyckades%]%[OK%]
Andra klienters instllningar: %#3?b%[Kodningen misslyckades%]%[OK%]
Rapportera grna detta fel till elispklientens utvecklare.
")
(hang-on . "Vnta ett tag...\n")
(no-changes . "Ingenting behvde sparas eftersom inga variabler hade ndrats.\n")
(could-not-save-options . "Kunde ej spara instllningarna.\n")
......@@ -1208,6 +1217,7 @@ Gruppmeddelande till %#3M\nfr
Det stod \"%#2s\" i user-arean. Den stts till nil istllet.
Skicka en bugrapport.\n")
(error-in-options-short . "Det fanns ett fel i dina instllningar. Vissa instllningar har inte lsts in.")
(reading-settings-from-server . "Dina sparade instllningar har ndrats p servern. Lser om instllningarna.\n")
;; From elib-string.el:
;; No entries.
......@@ -1886,7 +1896,13 @@ Ignorerar f
Variablerna r inte registrerade LysKOM-variabler och kan drfr inte
lsas frn servern. Du kan ta bort variablerna frn servern genom att
ge kommandot \"Spara instllningar\".\n\n")
ge kommandot \"Spara instllningar\" med prefixargument.
%#2?b%[%#5F\
Oknda variabler kan bero p att dina instllningar sparades med
version %#3s av elispklienten, medan detta r version %#4s.
%]%[%]")
(unknown-aux-item . "Oknd tillggsinformation")
(text-header-aux-item . "%#1s: <%#2d> \"%#3s\" %#4s")
......
......@@ -3385,6 +3385,10 @@ Users are encouraged to use their best sense of humor."
(defconst lyskom-clientversion "@@CLIENTVERSION@@"
"Version of the LysKOM elisp client.")
(def-kom-var lyskom-settings-version lyskom-clientversion
"Version of saved settings."
server)
(defvar lyskom-max-int 8388607
"The largest int Emacs, and thus this LysKOM client, can handle.")
......@@ -3540,6 +3544,11 @@ This is not buffer-local.")
The area is a pair: name . info (both strings)."
local)
(def-kom-var lyskom-saved-unknown-variables nil
"Variables read from the user area that this client version
knows nothing about and that will be saved back unaltered."
local)
(def-kom-var lyskom-pending-calls nil
"Assoc list of calls to LysKOM server that have not yet completed.
Each element on the list has the format
......
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