Mercurial > hg > xemacs-beta
comparison lisp/prim/subr.el @ 189:489f57a838ef r20-3b21
Import from CVS: tag r20-3b21
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:57:07 +0200 |
parents | b405438285a2 |
children | acd284d43ca1 |
comparison
equal
deleted
inserted
replaced
188:e29a8e7498d9 | 189:489f57a838ef |
---|---|
596 This makes or adds to an entry on `after-load-alist'. | 596 This makes or adds to an entry on `after-load-alist'. |
597 FILE should be the name of a library, with no directory name." | 597 FILE should be the name of a library, with no directory name." |
598 (eval-after-load file (read))) | 598 (eval-after-load file (read))) |
599 (make-compatible 'eval-next-after-load "") | 599 (make-compatible 'eval-next-after-load "") |
600 | 600 |
601 (defun string-to-sequence (string type) | |
602 "Convert STRING to a sequence of TYPE which contains characters in STRING. | |
603 TYPE should be `list' or `vector'. | |
604 Multibyte characters are concerned." | |
605 (cond ((eq type 'list) | |
606 (mapcar #'identity string)) | |
607 ((eq type 'vector) | |
608 (mapcar #'identity string)) | |
609 (t | |
610 (error "Type must be `list' or `vector'")))) | |
611 | |
612 (defun string-to-list (string) | |
613 "Return a list of characters in STRING." | |
614 (mapcar #'identity string)) | |
615 | |
616 (defun string-to-vector (string) | |
617 "Return a vector of characters in STRING." | |
618 (mapvector #'identity string)) | |
619 | |
620 (defun store-substring (string idx obj) | |
621 "Embed OBJ (string or character) at index IDX of STRING." | |
622 (let* ((str (cond ((stringp obj) obj) | |
623 ((characterp obj) (char-to-string obj)) | |
624 (t (error | |
625 "Invalid argument (should be string or character): %s" | |
626 obj)))) | |
627 (string-len (length string)) | |
628 (len (length str)) | |
629 (i 0)) | |
630 (while (and (< i len) (< idx string-len)) | |
631 (aset string idx (aref str i)) | |
632 (setq idx (1+ idx) i (1+ i))) | |
633 string)) | |
634 | |
635 ;;; ### Check compatibility with FSF | |
636 ;; The FSF version of this function does complex things to make each | |
637 ;; multibyte character behave as one "column". We don't need any of | |
638 ;; it. | |
639 (defun truncate-string-to-width (str width &optional start-column padding) | |
640 "Truncate string STR to fit in WIDTH columns. | |
641 Optional 1st arg START-COLUMN if non-nil specifies the starting column. | |
642 Optional 2nd arg PADDING if non-nil is a padding character to be padded at | |
643 the head and tail of the resulting string to fit in WIDTH if necessary. | |
644 If PADDING is nil, the resulting string may be narrower than WIDTH." | |
645 (or start-column | |
646 (setq start-column 0)) | |
647 (if (< (+ start-column width) (length str)) | |
648 (substring str start-column (+ start-column width)) | |
649 (concat (substring str start-column) | |
650 (if padding | |
651 (make-string (- width (length str) start-column) padding))))) | |
652 (defalias 'truncate-string 'truncate-string-to-width) | |
653 (make-obsolete 'truncate-string 'truncate-string-to-width) | |
654 | |
655 ; alternate names (not obsolete) | 601 ; alternate names (not obsolete) |
656 (if (not (fboundp 'mod)) (define-function 'mod '%)) | 602 (if (not (fboundp 'mod)) (define-function 'mod '%)) |
657 (define-function 'move-marker 'set-marker) | 603 (define-function 'move-marker 'set-marker) |
658 (define-function 'beep 'ding) ; preserve lingual purity | 604 (define-function 'beep 'ding) ; preserve lingual purity |
659 (define-function 'indent-to-column 'indent-to) | 605 (define-function 'indent-to-column 'indent-to) |