/[emacs]/emacs/lisp/international/mule.el
ViewVC logotype

Diff of /emacs/lisp/international/mule.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.157 by rms, Wed Jul 31 22:01:07 2002 UTC revision 1.158 by rms, Fri Aug 2 18:01:33 2002 UTC
# Line 1114  a value of `safe-charsets' in PLIST." Line 1114  a value of `safe-charsets' in PLIST."
1114            (put alias 'eol-type (make-subsidiary-coding-system alias)))            (put alias 'eol-type (make-subsidiary-coding-system alias)))
1115        (put alias 'eol-type eol-type))))        (put alias 'eol-type eol-type))))
1116    
1117    (defun merge-coding-systems (first second)
1118      "Fill in any unspecified aspects of coding system FIRST from SECOND.
1119    Return the resulting coding system."
1120      (let ((base (coding-system-base second))
1121            (eol (coding-system-eol-type second)))
1122        ;; If FIRST doesn't specify text conversion, merge with that of SECOND.
1123        (if (eq (coding-system-base first) 'undecided)
1124            (setq first (coding-system-change-text-conversion first base)))
1125        ;; If FIRST doesn't specify eol conversion, merge with that of SECOND.
1126        (if (and (vectorp (coding-system-eol-type first))
1127                 (numberp eol) (>= eol 0) (<= eol 2))
1128            (setq first (coding-system-change-eol-conversion
1129                         first eol)))
1130        first))
1131    
1132  (defun set-buffer-file-coding-system (coding-system &optional force)  (defun set-buffer-file-coding-system (coding-system &optional force)
1133    "Set the file coding-system of the current buffer to CODING-SYSTEM.    "Set the file coding-system of the current buffer to CODING-SYSTEM.
1134  This means that when you save the buffer, it will be converted  This means that when you save the buffer, it will be converted
1135  according to CODING-SYSTEM.  For a list of possible values of CODING-SYSTEM,  according to CODING-SYSTEM.  For a list of possible values of CODING-SYSTEM,
1136  use \\[list-coding-systems].  use \\[list-coding-systems].
1137    
1138  If the buffer's previous file coding-system value specifies end-of-line  If CODING-SYSTEM leaves the text conversion unspecified, or if it
1139  conversion, and CODING-SYSTEM does not specify one, CODING-SYSTEM is  leaves the end-of-line conversion unspecified, FORCE controls what to
1140  merged with the already-specified end-of-line conversion.  do.  If FORCE is nil, get the unspecified aspect (or aspects) from the
1141    buffer's previous `buffer-file-coding-system' value (if it is
1142  If the buffer's previous file coding-system value specifies text  specified there).  Otherwise, levae it unspecified.
 conversion, and CODING-SYSTEM does not specify one, CODING-SYSTEM is  
 merged with the already-specified text conversion.  
   
 However, if the optional prefix argument FORCE is non-nil, then  
 CODING-SYSTEM is used exactly as specified.  
1143    
1144  This marks the buffer modified so that the succeeding \\[save-buffer]  This marks the buffer modified so that the succeeding \\[save-buffer]
1145  surely saves the buffer with CODING-SYSTEM.  From a program, if you  surely saves the buffer with CODING-SYSTEM.  From a program, if you
1146  don't want to mark the buffer modified, just set the variable  don't want to mark the buffer modified, just set the variable
1147  `buffer-file-coding-system' directly."  `buffer-file-coding-system' directly."
1148    (interactive "zCoding system for visited file (default, nil): \nP")    (interactive "zCoding system for saving file (default, nil): \nP")
1149    (check-coding-system coding-system)    (check-coding-system coding-system)
1150    (if (and coding-system buffer-file-coding-system (null force))    (if (and coding-system buffer-file-coding-system (null force))
1151        (let ((base (coding-system-base buffer-file-coding-system))        (setq coding-system
1152              (eol (coding-system-eol-type buffer-file-coding-system)))              (merge-coding-systems coding-system buffer-file-coding-system)))
         ;; If CODING-SYSTEM doesn't specify text conversion, merge  
         ;; with that of buffer-file-coding-system.  
         (if (eq (coding-system-base coding-system) 'undecided)  
             (setq coding-system (coding-system-change-text-conversion  
                                  coding-system base)))  
         ;; If CODING-SYSTEM doesn't specify eol conversion, merge with  
         ;; that of buffer-file-coding-system.  
         (if (and (vectorp (coding-system-eol-type coding-system))  
                  (numberp eol) (>= eol 0) (<= eol 2))  
             (setq coding-system (coding-system-change-eol-conversion  
                                  coding-system eol)))))  
1153    (setq buffer-file-coding-system coding-system)    (setq buffer-file-coding-system coding-system)
1154    (set-buffer-modified-p t)    (set-buffer-modified-p t)
1155    (force-mode-line-update))    (force-mode-line-update))
1156    
1157    (defun revert-buffer-with-coding-system (coding-system &optional force)
1158      "Visit the current buffer's file again using coding system CODING-SYSTEM.
1159    For a list of possible values of CODING-SYSTEM, use \\[list-coding-systems].
1160    
1161    If CODING-SYSTEM leaves the text conversion unspecified, or if it
1162    leaves the end-of-line conversion unspecified, FORCE controls what to
1163    do.  If FORCE is nil, get the unspecified aspect (or aspects) from the
1164    buffer's previous `buffer-file-coding-system' value (if it is
1165    specified there).  Otherwise, determine it from the file contents as
1166    usual for visiting a file."
1167      (interactive "zCoding system for visited file (default, nil): \nP")
1168      (check-coding-system coding-system)
1169      (if (and coding-system buffer-file-coding-system (null force))
1170          (setq coding-system
1171                (merge-coding-systems coding-system buffer-file-coding-system)))
1172      (let ((coding-system-for-read coding-system))
1173        (revert-buffer)))
1174    
1175  (defvar default-terminal-coding-system nil  (defvar default-terminal-coding-system nil
1176    "Default value for the terminal coding system.    "Default value for the terminal coding system.
1177  This is normally set according to the selected language environment.  This is normally set according to the selected language environment.

Legend:
Removed from v.1.157  
changed lines
  Added in v.1.158

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26