comparison lisp/obsolete.el @ 771:943eaba38521

[xemacs-hg @ 2002-03-13 08:51:24 by ben] The big ben-mule-21-5 check-in! Various files were added and deleted. See CHANGES-ben-mule. There are still some test suite failures. No crashes, though. Many of the failures have to do with problems in the test suite itself rather than in the actual code. I'll be addressing these in the next day or so -- none of the test suite failures are at all critical. Meanwhile I'll be trying to address the biggest issues -- i.e. build or run failures, which will almost certainly happen on various platforms. All comments should be sent to ben@xemacs.org -- use a Cc: if necessary when sending to mailing lists. There will be pre- and post- tags, something like pre-ben-mule-21-5-merge-in, and post-ben-mule-21-5-merge-in.
author ben
date Wed, 13 Mar 2002 08:54:06 +0000
parents 29e4e3036b4e
children e65d9cf16707
comparison
equal deleted inserted replaced
770:336a418893b5 771:943eaba38521
315 315
316 ;; Two loser functions which shouldn't be used. 316 ;; Two loser functions which shouldn't be used.
317 (make-obsolete 'following-char 'char-after) 317 (make-obsolete 'following-char 'char-after)
318 (make-obsolete 'preceding-char 'char-before) 318 (make-obsolete 'preceding-char 'char-before)
319 319
320
321 ;; The following several functions are useful in GNU Emacs 20 because
322 ;; of the multibyte "characters" the internal representation of which
323 ;; leaks into Lisp. In XEmacs/Mule they are trivial and unnecessary.
324 ;; We provide them for compatibility reasons solely.
325
326 (defun string-to-sequence (string type)
327 "Convert STRING to a sequence of TYPE which contains characters in STRING.
328 TYPE should be `list' or `vector'.
329 Multibyte characters are concerned."
330 (ecase type
331 (list
332 (mapcar #'identity string))
333 (vector
334 (mapvector #'identity string))))
335
336 (defun string-to-list (string)
337 "Return a list of characters in STRING."
338 (mapcar #'identity string))
339
340 (defun string-to-vector (string)
341 "Return a vector of characters in STRING."
342 (mapvector #'identity string))
343
344 (defun store-substring (string idx object)
345 "Embed OBJECT (string or character) at index IDX of STRING."
346 (let* ((str (cond ((stringp object) object)
347 ((characterp object) (char-to-string object))
348 (t (error
349 "Invalid argument (should be string or character): %s"
350 object))))
351 (string-len (length string))
352 (len (length str))
353 (i 0))
354 (while (and (< i len) (< idx string-len))
355 (aset string idx (aref str i))
356 (setq idx (1+ idx) i (1+ i)))
357 string))
358
359 ;; #### This function is not compatible with FSF in some cases. Hard
360 ;; to fix, because it is hard to trace the logic of the FSF function.
361 ;; In case we need the exact behavior, we can always copy the FSF
362 ;; version, which is very long and does lots of unnecessary stuff.
363 (defun truncate-string-to-width (str end-column &optional start-column padding)
364 "Truncate string STR to end at column END-COLUMN.
365 The optional 2nd arg START-COLUMN, if non-nil, specifies
366 the starting column; that means to return the characters occupying
367 columns START-COLUMN ... END-COLUMN of STR.
368
369 The optional 3rd arg PADDING, if non-nil, specifies a padding character
370 to add at the end of the result if STR doesn't reach column END-COLUMN,
371 or if END-COLUMN comes in the middle of a character in STR.
372 PADDING is also added at the beginning of the result
373 if column START-COLUMN appears in the middle of a character in STR.
374
375 If PADDING is nil, no padding is added in these cases, so
376 the resulting string may be narrower than END-COLUMN."
377 (or start-column
378 (setq start-column 0))
379 (let ((len (length str)))
380 (concat (substring str (min start-column len) (min end-column len))
381 (and padding (> end-column len)
382 (make-string (- end-column len) padding)))))
383
384 (defalias 'truncate-string 'truncate-string-to-width)
385 (make-obsolete 'truncate-string 'truncate-string-to-width)
386
387 ;; Keywords already do The Right Thing in XEmacs 320 ;; Keywords already do The Right Thing in XEmacs
388 (make-compatible 'define-widget-keywords "Just use them") 321 (make-compatible 'define-widget-keywords "Just use them")
389 322
390 (make-obsolete 'function-called-at-point 'function-at-point) 323 (make-obsolete 'function-called-at-point 'function-at-point)
391 324