Commit 11bdf265 authored by David Byers's avatar David Byers
Browse files

Corrected string encoding of user-area

parent b1097670
1999-12-03 David Byers <davby@sen2.ida.liu.se>
* swedish-strings.el, english-strings.el (lyskom-command): Removed
kom-edit-options.
* flags.el: Commented out all the kom-edit-options stuff.
(lyskom-save-options): Fix string encoding of user area
(it was really messed up.)
1999-12-03 David Byers <davby@ida.liu.se>
* command.el (lyskom-read-extended-command): Use
lyskom-maybe-recode-string in place of last patch.
* buffers.el (lyskom-generate-new-buffer): Use
lyskom-maybe-recode-string to maybe recode the buffer name.
(lyskom-get-buffer-create): Here too.
* utilities.el (lyskom-maybe-recode-string): New function.
1999-12-03 David Byers <davby@sen2.ida.liu.se>
* command.el (lyskom-read-extended-command): Patch in order to do
......
......@@ -305,7 +305,16 @@ categories")
(add-hook 'kill-buffer-query-functions 'lyskom-quit-query)
(add-hook 'kill-emacs-query-functions 'lyskom-quit-query)
(defun lyskom-fix-buffer-name (name)
"Encode NAME according to the language coding system if we have
no multibyte character support"
(if enable-multibyte-characters
name
(encode-coding-string name (or (lyskom-language-coding lyskom-language)
'raw-text))))
(defun lyskom-generate-new-buffer (name)
(setq name (lyskom-maybe-recode-string name))
(let ((buf (generate-new-buffer name)))
(save-excursion
(set-buffer buf))
......@@ -317,6 +326,7 @@ If UNIQUE is non-nil, re-use the first existing buffer of category
CATEGORY, renaming it and killing its local variables.
The created buffer is made a child of the current buffer."
(setq name (lyskom-maybe-recode-string name))
(let ((buffers (lyskom-buffers-of-category category))
(buffer nil))
(if (and unique buffers)
......
......@@ -186,12 +186,7 @@
(alternatives (mapcar
(lambda (pair)
(cons
(if enable-multibyte-characters
(cdr pair)
(encode-coding-string
(cdr pair)
(or (lyskom-language-coding lyskom-language)
'raw-text)))
(lyskom-maybe-recode-string (cdr pair))
(car pair)))
(lyskom-get-strings lyskom-commands
'lyskom-command)))
......
......@@ -954,6 +954,7 @@ Group message to %#3M\nfrom %#2P (%#4s):
(error-in-options . "There was an error in one of your variables (%#1s)
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.")
; From elib-string.el:
; No entries.
......@@ -1479,7 +1480,6 @@ You must become an active member of the conference to enter it.\n")
(kom-unset-conf-motd . "Remove notice")
(kom-save-text . "Archive text (in file)")
(kom-save-text-body . "Save text body (in file)")
(kom-edit-options . "Change options")
(kom-save-options . "Save options")
(kom-shutdown-server . "Shut down (server)")
(kom-sync-database . "Save (the) database")
......
......@@ -44,194 +44,197 @@
;;; 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)))))
;;;; (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)
lyskom-other-clients-user-areas))
common-block
elisp-block
(mapcar (function cdr)
lyskom-other-clients-user-areas)))
; (concat common-block "----------\n" elisp-block)
(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-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)
......@@ -259,52 +262,59 @@ If successful then set the buffer not-modified. Else print a warning."
(mapconcat (function
(lambda (var)
(lyskom-format-objects
(substring (symbol-name var) 4)
(substring (symbol-name var) 4)
(prin1-to-string (symbol-value var)))))
lyskom-global-non-boolean-variables
"\n")
))
(elisp-block
(mapconcat (function
(lambda (var)
(concat (format "%dH%s"
(length (symbol-name var))
(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))))
(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")))
(mapconcat
(lambda (var)
(concat (format "%dH%s"
(length (symbol-name var))
(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))))
(if (and val nil)
(format "%dC%s%dH%s"
(string-bytes (symbol-name coding))
(symbol-name coding)
(string-bytes val)
val)
(setq data
(encode-coding-string
data
(or lyskom-server-coding-system 'raw-text)))
(format "%dH%s"
(string-bytes data)
data)))))
lyskom-elisp-variables
"\n")))
(save-excursion
(set-buffer kombuf)
(lyskom-message "%s" start-message)
(initiate-create-text 'options 'lyskom-save-options-2
(cons 'raw-text
(apply 'lyskom-format-objects
(apply 'lyskom-format-objects
"common"
"elisp"
(mapcar
(function car)
lyskom-other-clients-user-areas))
common-block
elisp-block
(mapcar (function cdr)
lyskom-other-clients-user-areas)))
(initiate-create-text
'options 'lyskom-save-options-2
(cons 'raw-text
(apply 'lyskom-format-objects
(apply 'lyskom-format-objects
"common"
"elisp"
(mapcar
(lambda (el)
(cons 'STRING (cons 'raw-text (car el))))
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
kombuf
......@@ -436,8 +446,7 @@ If successful then set the buffer not-modified. Else print a warning."
(while (stringp (cdr (car (cdr pos))))
(setq pos (cdr pos)))
(setcdr pos nil))))))
(error (lyskom-message (lyskom-get-string 'error-in-options)
(lyskom-get-string 'cancelled))))
(error (lyskom-message (lyskom-get-string 'error-in-options-short))))
(setq lyskom-options-done t))
......
......@@ -959,6 +959,7 @@ Gruppmeddelande till %#3M\nfr
(error-in-options . "Det fanns ett fel i en av dina variabler (%#1s)
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.")
;; From elib-string.el:
;; No entries.
......@@ -1487,7 +1488,6 @@ Du m
(kom-unset-conf-motd . "Ta bort lapp p drren")
(kom-save-text . "Arkivera inlgg (till fil)")
(kom-save-text-body . "Spara inlggstext (p fil)")
(kom-edit-options . "ndra variabler")
(kom-save-options . "Spara variabler")
(kom-shutdown-server . "Stng av servern")
(kom-sync-database . "Spara databasen")
......
......@@ -277,6 +277,14 @@ of \(current-time\)."
"\000\001\002\003\004\005\006\007\010 \012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]~!AAAA[]ACEEEEIIIINOOOO\\OUUUYYAAAA[]ACEEEEIIIINOOOO\\OUUUYY"
"String mapping lowercase to uppercase and equivalents to each others.")
(defsubst lyskom-maybe-recode-string (s)
"Change the encoding of S when multibyte characters are not supported"
(if enable-multibyte-characters
s
(encode-coding-string s (or (and lyskom-language
(lyskom-language-coding lyskom-language))
'raw-text))))
(defsubst lyskom-unicase-char (c)
"Smash case and diacritical marks on c."
(if (< (char-to-int c) (length lyskom-default-collate-table))
......
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