Commit 11a4722b authored by David Byers's avatar David Byers

Further MULEification

parent 53dd2a58
1999-11-19 David Byers <davby@ida.liu.se>
* utilities.el (lyskom-truncate-string-to-width): New function
copied from Gnu Emacs.
* Changed file coding of all files to iso-8859-1 since we now have
the ambition to deal with multibyte text.
* lyskom-rest.el (lyskom-format-aux-help): Use
lyskom-truncate-string-to-width instead of substring.
(lyskom-format-aux-help): Use string-width instead of length.
(lyskom-format-aux-help): Same here.
(lyskom-fill-message-line-length): Use current-column instead of
point to calculate current line width.
(lyskom-is-loaded): Encode lyskom-line-start-chars-string in
ISO-8859-1 before using it.
(silent-read): Don't disable multibyte characters.
* defvar.el (lyskom-setup-minibuffer-variables): Don't disable
multibyte characters.
* buffers.el (lyskom-generate-new-buffer): Don't disable multibyte
characters.
(lyskom-get-buffer-create): Same here.
* mime.el (lyskom-mime-string-charset): Use find-charset-string.
* compatibility.el (check-coding-system): Provide dummy
check-coding-system.
* mime.el (lyskom-mime-charset-coding-system): Use
check-coding-system.
* startup.el (lyskom): Decode the motd text mass and format it as
a text.
......
......@@ -3,6 +3,12 @@
Att göra i elisp-klienten
=========================
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.
Kolla alla aset och aref så att de inte använder tecken som nyckel
utan omkodning till iso-8859-1 först.
MULEifiera hanteringen av user-arean.
Kolla att spara text sparar med en vettig kodning.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......@@ -290,8 +290,7 @@ categories")
(defun lyskom-generate-new-buffer (name)
(let ((buf (generate-new-buffer name)))
(save-excursion
(set-buffer buf)
(set-buffer-multibyte nil))
(set-buffer buf))
buf))
(defun lyskom-get-buffer-create (category name &optional unique)
......@@ -321,8 +320,7 @@ The created buffer is made a child of the current buffer."
(lyskom-set-buffer-parent buffer (current-buffer))
(lyskom-update-inherited-variables buffer)
(save-excursion (set-buffer buffer)
(setq lyskom-buffer-category category)
(set-buffer-multibyte nil))
(setq lyskom-buffer-category category))
buffer))
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1996 Lysator Academic Computer Association.
......@@ -285,6 +285,10 @@ string to search in."
(lyskom-provide-function encode-coding-string (str coding-system) str)
(lyskom-provide-function decode-coding-string (str coding-system) str)
(lyskom-provide-function string-bytes (str) (length str))
(lyskom-provide-function check-coding-system (name) nil)
(lyskom-provide-function string-width (str) (length str))
(lyskom-provide-function char-width (c) 1)
(lyskom-provide-function find-charset-string (str) '(ascii))
(lyskom-provide-function last (x &optional n)
"Returns the last link in the list LIST.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......@@ -119,8 +119,7 @@ is saved before executing FORMS and restored when FORMS have finished."
(make-local-variable (car syms))
(set (car syms) (car vals))
(setq syms (cdr syms)
vals (cdr vals)))
(set-buffer-multibyte nil)))
vals (cdr vals)))))
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;; $Id$
;;;; This file contains some miscellaneous string functions
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1994, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......@@ -1495,19 +1495,20 @@ Note that it is not allowed to use deferred insertions in the text."
(cond ((or (null pad-length)
(null result)) nil)
((> abs-length (length result))
(let ((padstring (make-string (- abs-length (length result))
((> abs-length (string-width result))
(let ((padstring (make-string (- abs-length (string-width result))
pad-letter)))
(if (< pad-length 0) ; LEFT justify
(progn
(setq prop-adjust-end (- (- abs-length (length result))))
(setq prop-adjust-end (- (- abs-length (string-width
result))))
(setq result (concat result padstring)))
(progn
(setq prop-adjust-start (- abs-length (length result)))
(setq prop-adjust-start (- abs-length (string-width result)))
(setq result (concat padstring result))))))
((and equals-flag
(< abs-length (length result)))
(setq result (substring result 0 abs-length))))
(< abs-length (string-width result)))
(setq result (lyskom-truncate-string-to-width result abs-length))))
(if result
(progn
......@@ -2101,7 +2102,7 @@ in lyskom-messages."
(defun lyskom-fill-message-line-length ()
(- (save-excursion (end-of-line)
(skip-chars-backward " \t")
(point)) (point)))
(current-column)) (current-column)))
;;; ============================================================
......@@ -3312,7 +3313,6 @@ One parameter - the prompt string."
(let ((input-string "")
(input-char)
(cursor-in-echo-area t))
(set-buffer-multibyte nil)
(while (not (or (eq (setq input-char
(condition-case err
(read-char-exclusive)
......@@ -3391,7 +3391,7 @@ One parameter - the prompt string."
(function
(lambda (x)
(aset tmp (char-to-int x) t)))
lyskom-line-start-chars-string)
(encode-coding-string lyskom-line-start-chars-string 'iso-8859-1))
tmp))
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......@@ -65,7 +65,7 @@
(defun lyskom-mime-string-charset (data)
(let ((cs (charsets-in-string data))
(let ((cs (find-charset-string data))
(tmp lyskom-charset-alist)
(system 'us-ascii))
(while tmp
......@@ -76,7 +76,7 @@
(defun lyskom-mime-charset-coding-system (charset)
(condition-case nil
(get-coding-system charset)
(check-coding-system charset)
(error 'raw-text)))
(defun lyskom-mime-encode-string (data)
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;; Included from fields.el
;; (provide 'fields)
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1991, 1996 Lysator Academic Computer Association.
......
;;;;; -*-coding: raw-text;-*-
;;;;; -*-coding: iso-8859-1;-*-
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1996 Lysator Academic Computer Association.
......@@ -279,19 +279,76 @@ of \(current-time\)."
(defsubst lyskom-unicase-char (c)
"Smash case and diacritical marks on c."
(aref lyskom-collate-table (char-to-int c)))
(if (< (char-to-int c) (length lyskom-default-collate-table))
(aref lyskom-collate-table (char-to-int c))
c))
(defun lyskom-unicase (s)
"Smash case and diacritical marks of all chars in s."
(lyskom-save-excursion
(set-buffer lyskom-buffer)
(let ((l (length s))
(s2 (copy-sequence s)))
(s2 (encode-coding-string s lyskom-server-coding-system)))
(while (> l 0)
(setq l (1- l))
(aset s2 l (lyskom-unicase-char (aref s2 l))))
s2)))
;; Stolen from Gnu Emacs
(defun lyskom-truncate-string-to-width (str end-column &optional start-column padding)
"Truncate string STR to end at column END-COLUMN.
The optional 2nd arg START-COLUMN, if non-nil, specifies
the starting column; that means to return the characters occupying
columns START-COLUMN ... END-COLUMN of STR.
The optional 3rd arg PADDING, if non-nil, specifies a padding character
to add at the end of the result if STR doesn't reach column END-COLUMN,
or if END-COLUMN comes in the middle of a character in STR.
PADDING is also added at the beginning of the result
if column START-COLUMN appears in the middle of a character in STR.
If PADDING is nil, no padding is added in these cases, so
the resulting string may be narrower than END-COLUMN."
(or start-column
(setq start-column 0))
(let ((len (length str))
(idx 0)
(column 0)
(head-padding "") (tail-padding "")
ch last-column last-idx from-idx)
(condition-case nil
(while (< column start-column)
(setq ch (aref str idx)
column (+ column (char-width ch))
idx (1+ idx)))
(args-out-of-range (setq idx len)))
(if (< column start-column)
(if padding (make-string end-column padding) "")
(if (and padding (> column start-column))
(setq head-padding (make-string (- column start-column) padding)))
(setq from-idx idx)
(if (< end-column column)
(setq idx from-idx)
(condition-case nil
(while (< column end-column)
(setq last-column column
last-idx idx
ch (aref str idx)
column (+ column (char-width ch))
idx (1+ idx)))
(args-out-of-range (setq idx len)))
(if (> column end-column)
(setq column last-column idx last-idx))
(if (and padding (< column end-column))
(setq tail-padding (make-string (- end-column column) padding))))
(setq str (substring str from-idx idx))
(if padding
(concat head-padding str tail-padding)
str))))
(defun lyskom-string-assoc (key list)
"Return non-nil if KEY is the same string as the car of an element of LIST.
The value is actually the element of LIST whose car equals KEY."
......
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