Commit 409ecf58 authored by David Byers's avatar David Byers
Browse files

More MULE-ification in lyskom-unicase.

Fixed errors added to lyskom-default-collate-table by MULE Emacs
parent 0b35fc88
2000-05-24 David Byers <davby@ida.liu.se>
* utilities.el (lyskom-default-collate-table): Removed \201s added
by MULE Emacs. ELUM ckuF
* compatibility.el (lyskom-encode-coding-char): New set of
compatibility definitions for Gnu Emacs.
* utilities.el (lyskom-unicase): Don't use aset on a string. Make
a vector from the string, use aset and make a string from the
vector.
(string-to-sequence): Stole from Gnu Emacs mule-utils.
(string-to-vector): Also stolen.
2000-05-23 David Byers <davby@ida.liu.se>
* compatibility.el: Detect buggy versions of encode-coding-string
......
......@@ -30,8 +30,6 @@ till funktionen, helst ocks
* SHOWSTOPPERS
** lyskom-unicase använder aset för att sätta element i en sträng.
** I startup.el så görs en get-collate-table. Skydda anropet från
servrar som inte har get-collate-table.
......
......@@ -321,32 +321,35 @@ string to search in."
;;; Decode buggy versions of encode-coding-string and decode-coding-string
;;; such as those provided by APEL (part of TM and often included in XEmacs)
(defun buggy-encode-coding-string (str coding-system) str)
(defun lyskom-buggy-encode-coding-string (str coding-system) str)
(eval-and-compile
(if (let ((test "TEM")) (eq (encode-coding-string test 'raw-text) test))
(progn (fset 'buggy-encode-coding-string
(progn (fset 'lyskom-buggy-encode-coding-string
(symbol-function 'encode-coding-string))
(defun encode-coding-string (str coding-system)
(copy-sequence (buggy-encode-coding-string str coding-system))))))
(copy-sequence (lyskom-buggy-encode-coding-string str coding-system))))))
(defun buggy-decode-coding-string (str coding-system) str)
(defun lyskom-buggy-decode-coding-string (str coding-system) str)
(eval-and-compile
(if (let ((test "TEM")) (eq (decode-coding-string test 'raw-text) test))
(progn (fset 'buggy-decode-coding-string
(progn (fset 'lyskom-buggy-decode-coding-string
(symbol-function 'decode-coding-string))
(defun decode-coding-string (str coding-system)
(copy-sequence (buggy-decode-coding-string str coding-system))))))
(copy-sequence (lyskom-buggy-decode-coding-string str coding-system))))))
;; defmacro lyskom-encode-coding-char in XEmacs so the compiled code
;; is quicker. In Gnu Emacs define it as a function.
(eval-and-compile
(lyskom-xemacs-or-gnu
(defmacro lyskom-encode-coding-char (c system) c)
(defun lyskom-encode-coding-char (c system)
(condition-case nil
(if (fboundp 'encode-coding-char)
(defun lyskom-encode-coding-char (c system)
(let ((s (encode-coding-char c system)))
(if (and s (= (length s) 1))
(elt s 0)))
(error c)))))
(elt s 0))))
(defun lyskom-encode-coding-char (c system) c))))
(eval-and-compile
(lyskom-xemacs-or-gnu
......
......@@ -259,7 +259,8 @@ See lyskom-mode for details."
(version-info->software-version lyskom-server-version-info))
;; FIXME: Only do this if we have the required features!
(setq lyskom-collate-table (blocking-do 'get-collate-table))
(when (lyskom-have-call 85)
(setq lyskom-collate-table (blocking-do 'get-collate-table)))
(if (not (zerop (server-info->motd-of-lyskom
lyskom-server-info)))
(blocking-do-multiple ((text (get-text
......
......@@ -266,6 +266,31 @@ of \(current-time\)."
;;; LysKOM utility functions
;;;
(lyskom-provide-function string-to-sequence (string type)
"Convert STRING to a sequence of TYPE which contains characters in STRING.
TYPE should be `list' or `vector'."
(let ((len (length string))
(i 0)
val)
(cond ((eq type 'list)
(setq val (make-list len 0))
(let ((l val))
(while (< i len)
(setcar l (aref string i))
(setq l (cdr l) i (1+ i)))))
((eq type 'vector)
(setq val (make-vector len 0))
(while (< i len)
(aset val i (aref string i))
(setq i (1+ i))))
(t
(error "Invalid type: %s" type)))
val))
(lyskom-provide-subst string-to-vector (string)
"Return a vector of characters in STRING."
(string-to-sequence string 'vector))
;;;
;;; WARNING!
;;;
......@@ -275,9 +300,11 @@ of \(current-time\)."
;;; you're done, run through the mappings of all 256 characters to
;;; make sure they look OK.
;;;
;;; Make sure your MULE Emacs doesnt fuck it up for you. It did for me.
;;;
(defvar lyskom-default-collate-table
"\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\\OUUUYYށAAAA[]ACEEEEIIIINOOOO\\OUUUYY"
"\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)
......@@ -302,11 +329,12 @@ of \(current-time\)."
(lyskom-save-excursion
(set-buffer lyskom-buffer)
(let ((l (length s))
(s2 (encode-coding-string s lyskom-server-coding-system)))
(s2 (string-to-vector
(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)))
(concat s2))))
(defun lyskom-looking-at (s)
"Version of looking-at that will work in Gnu Emacs 20.3"
......@@ -618,42 +646,45 @@ If optional APPEND is non-nil, add at the end of HOOK."
;;; Printing
;;;
;;; XEmacs princ does not insert text properties. This function is based
;;; on the C code for princ. It only works on strings
;;; on the C code for princ.
;;;
(defun lyskom-princ (string &optional stream)
"Output the printed representation of STRING, any Lisp STRING.
(defun lyskom-princ (object &optional stream)
"Output the printed representation of OBJECT, any Lisp OBJECT.
No quoting characters are used; no delimiters are printed around
the contents of strings. Text properties are retained.
Output stream is STREAM, or value of standard-output, and must be a
buffer or a marker. Function or minibuffer streams are not supported."
(let ((old-point nil)
(start-point nil)
(old-buffer (current-buffer)))
(unwind-protect
(progn
(cond ((bufferp stream) (set-buffer stream))
((markerp stream)
(setq old-point (point))
(set-buffer (marker-buffer stream))
(goto-char stream)
(setq start-point (point)))
((null stream)
(cond ((bufferp standard-output) (set-buffer standard-output))
((markerp standard-output)
(setq old-point (point))
(set-buffer (marker-buffer standard-output))
(goto-char standard-output)
(setq start-point (point))))))
(insert string))
(cond ((markerp stream)
(set-marker stream (point))
(if (>= old-point start-point)
(goto-char (+ old-point (- (point) start-point)))
(goto-char old-point))))
(set-buffer old-buffer))))
buffer or a marker. Function or minibuffer streams are not supported
for strings."
(if (not (stringp object))
(princ object stream)
(let ((old-point nil)
(start-point nil)
(old-buffer (current-buffer)))
(unwind-protect
(progn
(cond ((bufferp stream) (set-buffer stream))
((markerp stream)
(setq old-point (point))
(set-buffer (marker-buffer stream))
(goto-char stream)
(setq start-point (point)))
((null stream)
(cond ((bufferp standard-output) (set-buffer standard-output))
((markerp standard-output)
(setq old-point (point))
(set-buffer (marker-buffer standard-output))
(goto-char standard-output)
(setq start-point (point))))))
(insert object))
(cond ((markerp stream)
(set-marker stream (point))
(if (>= old-point start-point)
(goto-char (+ old-point (- (point) start-point)))
(goto-char old-point))))
(set-buffer old-buffer)))))
;;; ======================================================================
......
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