Commit 9e85692c authored by David Byers's avatar David Byers

More MULE fixes

parent d0ccc4dd
1999-11-21 David Byers <davby@ida.liu.se>
* lyskom-rest.el (lyskom-update-prompt): Set rear-nonsticky on
prompt text properties.
* view-text.el (lyskom-format-text-footer): Use string-width, not
length to compute width of author name, width of text number,
flags.
* option-edit.el (lyskom-widget-name-value-create): Use
string-width to compute padding.
(lyskom-widget-command-value-create): Ditto.
(lyskom-widget-kbd-macro-value-create): Same here.
* lyskom-buttons.el (lyskom-keyboard-menu): USe string-width to
get the width of a string.
* completing-read.el (lyskom-read-session-resolve-ambiguity): Use
string-width to get width of a string.
* commands2.el (kom-status-conf): Use string-width, not length, to
get width of string.
* filter.el (lyskom-recompile-filter): New function.
* flags.el (lyskom-read-options-eval-get-holerith): Handle
explicitly coded strings.
(kom-edit-options-send): Output explicit coding for strings in the
elisp area.
(lyskom-read-options-eval): Recompile filters after reading from
user area.
1999-11-20 David Byers <davby@ida.liu.se>
* compatibility.el (lyskom-string-width): New function. Gnu Emacs
......
......@@ -4,10 +4,11 @@ Att g
=========================
Fixa aux-item-data och format-objects så att strängen kodas som
raw-text. Hur hanteras då åäö i den?
raw-text. Hur hanteras då åäö i den? KLART.
Kolla alla användningar av length och substring för att se var man
borde använda string-width och truncate-string-to-width istället.
substring klart.
Kolla alla aset och aref så att de inte använder tecken som nyckel
utan omkodning till iso-8859-1 först.
......
......@@ -327,7 +327,7 @@ chosen according to this"
(discard-input))
;; lyskom-pending-commands should probably be a queue or a stack.
(when lyskom-pending-commands
(let ((command (car lyskom-pending-commands)))
(let ((command (car lyskom-pending-commands)))
(setq lyskom-pending-commands (cdr lyskom-pending-commands))
(if (symbolp command)
(call-interactively command)
......
......@@ -195,7 +195,7 @@ otherwise: the conference is read with lyskom-completing-read."
creator
(if (and
(lyskom-conf-stat-p creator)
(> (length (conf-stat->name creator))
(> (lyskom-string-width (conf-stat->name creator))
(- (lyskom-window-width) 46)))
"\n"
"")))
......@@ -234,7 +234,7 @@ otherwise: the conference is read with lyskom-completing-read."
superconf
(if (and
(lyskom-conf-stat-p superconf)
(> (length (conf-stat->name superconf))
(> (lyskom-string-width (conf-stat->name superconf))
(- (lyskom-window-width) 46)))
"\n"
"")))
......
......@@ -922,7 +922,7 @@ the LysKOM rules of string matching."
(lyskom-insert "\n")
(let* ((s-width (1+ (apply 'max (mapcar (function
(lambda (x)
(length (int-to-string x))))
(string-width (int-to-string x))))
sessions))))
(format-string-s (lyskom-info-line-format-string s-width "s" "s"))
(format-string-p (lyskom-info-line-format-string s-width "P" "M")))
......
......@@ -63,6 +63,12 @@ Optional P and A initialize pattern and attributes, respectively."
(list 'filter (vector p a
(lyskom-create-compile-filter-function p))))
(defun lyskom-recompile-filter (filter)
"Re-compile the filter FILTER"
(set-filter->function filter
(lyskom-create-compile-filter-function
(filter->pattern filter))))
(defun copy-filter (f)
"Create a copy of the filter F"
(make-filter (copy-tree (filter->pattern f))
......
......@@ -160,26 +160,43 @@
elisp-block
(mapconcat (function
(lambda (var)
(lyskom-format-objects (symbol-name var)
(prin1-to-string
(symbol-value 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
(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))
(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
......@@ -250,26 +267,44 @@ If successful then set the buffer not-modified. Else print a warning."
(elisp-block
(mapconcat (function
(lambda (var)
(lyskom-format-objects (symbol-name var)
(prin1-to-string
(symbol-value 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")))
(save-excursion
(set-buffer kombuf)
(lyskom-message "%s" start-message)
(initiate-create-text 'options 'lyskom-save-options-2
(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))
(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)))
(lyskom-create-misc-list)
nil
kombuf
......@@ -387,6 +422,9 @@ If successful then set the buffer not-modified. Else print a warning."
;was stored.
(++ r))
(mapcar 'lyskom-recompile-filter kom-permanent-filter-list)
(mapcar 'lyskom-recompile-filter kom-session-filter-list)
(setq lyskom-filter-list (append kom-permanent-filter-list
kom-session-filter-list))
(setq lyskom-do-when-done (cons kom-do-when-done kom-do-when-done))
......@@ -401,15 +439,32 @@ If successful then set the buffer not-modified. Else print a warning."
(defun lyskom-read-options-eval-get-holerith ()
(while (string-match "\\s-" (substring lyskom-options-text 0 1))
(setq lyskom-options-text (substring lyskom-options-text 1)))
(let ((len (string-to-int lyskom-options-text))
(start (progn (string-match "[0-9]+H" lyskom-options-text)
(match-end 0))))
(let ((name (substring lyskom-options-text start (+ start len))))
(setq lyskom-options-text (substring lyskom-options-text
(+ start len)))
name)))
(let ((coding lyskom-server-coding-system))
(while (string-match "\\s-" (substring lyskom-options-text 0 1))
(setq lyskom-options-text (substring lyskom-options-text 1)))
;; Read the explicit coding, if any
(when (string-match "^[0-9]+C" lyskom-options-text)
(let ((len (string-to-int lyskom-options-text)))
(setq coding (intern
(substring lyskom-options-text
(match-end 0)
(+ (match-end 0) len))))
(setq lyskom-options-text (substring lyskom-options-text
(+ (match-end 0) len)))))
;; Read the string
(let ((len (string-to-int lyskom-options-text))
(start (progn (string-match "[0-9]+H" lyskom-options-text)
(match-end 0))))
(let ((name (substring lyskom-options-text start (+ start len))))
(setq lyskom-options-text (substring lyskom-options-text
(+ start len)))
(condition-case nil
(decode-coding-string name coding)
(error name))))))
(defun lyskom-maybe-set-var-from-string (var string)
"This is a wrapper around lyskom-set-var-from-string that does nothing
......
......@@ -229,12 +229,12 @@ If there is no active area, then do something else."
(e entries)
(completion-ignore-case t))
(while e
(if (> (length (car (car e))) maxlen)
(setq maxlen (length (car (car e)))))
(if (> (lyskom-string-width (car (car e))) maxlen)
(setq maxlen (lyskom-string-width (car (car e)))))
(setq e (cdr e)))
(setq prompt (concat
(substring title 0
(min (length title)
(min (lyskom-string-width title)
(- (window-width (minibuffer-window))
maxlen 3))) ": "))
......
......@@ -1465,12 +1465,13 @@ Note that it is not allowed to use deferred insertions in the text."
(if colon-flag ":" "")
"s")))
(set-defer-info->pos arg oldpos)
;; Note: length is right below. string-width is wrong.
(set-defer-info->del-chars
arg (if pad-length
(if equals-flag
(abs pad-length)
(max (length
lyskom-defer-indicator)
(max (length lyskom-defer-indicator)
(abs pad-length)))
(length lyskom-defer-indicator)))
(set-defer-info->format arg format-element))
......@@ -2392,7 +2393,8 @@ Set lyskom-current-prompt accordingly. Tell server what I am doing."
(beginning-of-line)
(when lyskom-slow-mode
(add-text-properties 0 (length prompt-text)
'(read-only t) prompt-text))
'(read-only t rear-nonsticky t)
prompt-text))
(insert-string prompt-text)
;; Delete the old prompt
(if lyskom-current-prompt
......@@ -2992,7 +2994,7 @@ If MEMBERSHIPs prioriy is 0, it always returns nil."
"Receive replies from LysKOM server."
; (sit-for 0) ; Why? [Doesn't work in XEmacs 19.14]
; (setq lyskom-apo-timeout-log
; (cons lyskom-apo-timeout lyskom-apo-timeout-log))
; (cons (cons (current-time-string) lyskom-apo-timeout) lyskom-apo-timeout-log))
(lyskom-reset-apo-timeout) ; Reset accept-process-output timeout
(let ((old-match-data (match-data))
;; lyskom-filter-old-buffer is also changed when starting to edit
......@@ -3215,7 +3217,7 @@ Other objects are converted correctly."
(int-to-string (aux-item->tag item)) " "
(lyskom-prot-a-format-aux-item-flags (aux-item->flags item)) " "
(int-to-string (aux-item->inherit-limit item)) " "
(lyskom-prot-a-format-raw-string (cons 'STRING (aux-item->data item)))))
(lyskom-prot-a-format-raw-string (cons 'raw-text (aux-item->data item)))))
(defun lyskom-prot-a-format-aux-item-flags (flags)
"Format AUX-ITEM-FLAGS for output to the server."
......@@ -3328,8 +3330,7 @@ One parameter - the prompt string."
(setq input-string
(cond
((eq input-char ?\C-?)
(if (equal (length input-string)
0)
(if (equal (length input-string) 0)
""
(substring input-string 0 -1)))
((eq input-char ?\C-u)
......
......@@ -76,7 +76,8 @@
(defun lyskom-mime-charset-coding-system (charset)
(condition-case nil
(check-coding-system charset)
(and (check-coding-system charset)
charset)
(error 'raw-text)))
(defun lyskom-mime-encode-string (data)
......
......@@ -1127,8 +1127,8 @@ customize buffer but do not save them to the server."
(if (null size)
(insert string)
(insert string)
(if (< (length value) size)
(insert-char ?\ (- size (length value)))))
(if (< (lyskom-string-width value) size)
(insert-char ?\ (- size (lyskom-string-width value)))))
(widget-put widget ':value-from (copy-marker from))
(widget-put widget ':value-to (copy-marker (point)))
......@@ -1195,8 +1195,8 @@ customize buffer but do not save them to the server."
(if (null size)
(insert string)
(insert string)
(if (< (length value) size)
(insert-char ?\ (- size (length value)))))
(if (< (lyskom-string-width value) size)
(insert-char ?\ (- size (lyskom-string-width value)))))
(widget-put widget ':value-from (copy-marker from))
(widget-put widget ':value-to (copy-marker (point)))
......@@ -1322,8 +1322,8 @@ customize buffer but do not save them to the server."
(if (null size)
(insert string)
(insert string)
(if (< (length string) size)
(insert-char ?\ (- size (length string)))))
(if (< (lyskom-string-width string) size)
(insert-char ?\ (- size (lyskom-string-width string)))))
(widget-put widget ':value-from (copy-marker from))
(widget-put widget ':value-to (copy-marker (point)))
......
......@@ -172,6 +172,51 @@ Signal lyskom-protocol-error if the next token is not a string."
(setq lyskom-parse-pos (+ lyskom-parse-pos len))))))))))
(defun lyskom-parse-coding ()
"Parse next token as a raw string.
Signal lyskom-parse-incomplete if the string is not complete.
Signal lyskom-protocol-error if the next token is not a string."
;; Kludge to deal with leading spaces.
(lyskom-parse-nonwhite-char)
(setq lyskom-parse-pos (1- lyskom-parse-pos))
;; End kludge.
(let ((to-parse (lyskom-string-to-parse)))
(cond
((string-match "\\`[0-9]*\\(\\|C\\)\\'" to-parse)
(signal 'lyskom-parse-incomplete nil))
((null (string-match "\\`[0-9]+C" to-parse))
(lyskom-protocol-error 'lyskom-parse-string
"Expected hollerith, got %S"
to-parse)) ;Not a legal string.
(t
(let ((end (match-end 0))
(len (string-to-int to-parse)))
(setq lyskom-parse-pos (+ lyskom-parse-pos end))
(cond
((< (point-max) (+ lyskom-parse-pos len))
(lyskom-setq-default lyskom-string-bytes-missing
(- (+ lyskom-parse-pos len)
(point-max)))
(signal 'lyskom-parse-incomplete nil))
(t
(prog1 (buffer-substring lyskom-parse-pos
(+ lyskom-parse-pos len))
(lyskom-setq-default lyskom-string-bytes-missing 0)
(setq lyskom-parse-pos (+ lyskom-parse-pos len))))))))))
(defun lyskom-parse-coded-string ()
"Parse a string with explicit coding."
(let ((coding (intern (lyskom-parse-coding)))
(data (lyskom-parse-raw-string)))
(condition-case nil
(progn (check-coding-system coding)
(decode-coding-string data coding))
(nil data))))
(defun lyskom-parse-1-or-0 ()
"Parse next nonwhite char and return t if it was 1, nil if it was 0.
Signal lyskom-protocol-error if it was neither 1 nor 0.
......@@ -756,7 +801,7 @@ than 0. Args: ITEMS-TO-PARSE PRE-FETCHED. Returns -1 if ITEMS-TO-PARSE is
(lyskom-parse-time) ; sent-at
(lyskom-parse-aux-item-flags)
(lyskom-parse-num) ; inherit-limit
(lyskom-parse-string) ; data
(lyskom-parse-raw-string) ; data
))
(defun lyskom-parse-aux-item-flags ()
......
......@@ -562,7 +562,7 @@ blocking-do."
(author-name-len nil)
(have-author (and format (string-match "%=?[0-9]*P" format))))
(setq author-name-len (length (or author-name (conf-stat->name author))))
(setq author-name-len (lyskom-string-width (or author-name (conf-stat->name author))))
;; No user-specified format, so output dashes and stuff
......@@ -594,12 +594,12 @@ blocking-do."
""))
(end-dash-chars
(- kom-text-footer-dash-length
(length (int-to-string (text-stat->text-no text)))
(lyskom-string-width (int-to-string (text-stat->text-no text)))
3 ; Parens and space
(if kom-show-author-at-end
(+ author-name-len 2)
0)
(length format-flag-string)))
(string-width format-flag-string)))
(end-dash (if (> end-dash-chars 0)
(make-string end-dash-chars ?-)
"")))
......
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