emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/international/mule.el


From: Richard M. Stallman
Subject: [Emacs-diffs] Changes to emacs/lisp/international/mule.el
Date: Fri, 02 Aug 2002 14:01:33 -0400

Index: emacs/lisp/international/mule.el
diff -c emacs/lisp/international/mule.el:1.157 
emacs/lisp/international/mule.el:1.158
*** emacs/lisp/international/mule.el:1.157      Wed Jul 31 18:01:07 2002
--- emacs/lisp/international/mule.el    Fri Aug  2 14:01:33 2002
***************
*** 1114,1159 ****
          (put alias 'eol-type (make-subsidiary-coding-system alias)))
        (put alias 'eol-type eol-type))))
  
  (defun set-buffer-file-coding-system (coding-system &optional force)
    "Set the file coding-system of the current buffer to CODING-SYSTEM.
  This means that when you save the buffer, it will be converted
  according to CODING-SYSTEM.  For a list of possible values of CODING-SYSTEM,
  use \\[list-coding-systems].
  
! If the buffer's previous file coding-system value specifies end-of-line
! conversion, and CODING-SYSTEM does not specify one, CODING-SYSTEM is
! merged with the already-specified end-of-line conversion.
! 
! If the buffer's previous file coding-system value specifies text
! 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.
  
  This marks the buffer modified so that the succeeding \\[save-buffer]
  surely saves the buffer with CODING-SYSTEM.  From a program, if you
  don't want to mark the buffer modified, just set the variable
  `buffer-file-coding-system' directly."
!   (interactive "zCoding system for visited file (default, nil): \nP")
    (check-coding-system coding-system)
    (if (and coding-system buffer-file-coding-system (null force))
!       (let ((base (coding-system-base buffer-file-coding-system))
!           (eol (coding-system-eol-type 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)))))
    (setq buffer-file-coding-system coding-system)
    (set-buffer-modified-p t)
    (force-mode-line-update))
  
  (defvar default-terminal-coding-system nil
    "Default value for the terminal coding system.
--- 1114,1176 ----
          (put alias 'eol-type (make-subsidiary-coding-system alias)))
        (put alias 'eol-type eol-type))))
  
+ (defun merge-coding-systems (first second)
+   "Fill in any unspecified aspects of coding system FIRST from SECOND.
+ Return the resulting coding system."
+   (let ((base (coding-system-base second))
+       (eol (coding-system-eol-type second)))
+     ;; If FIRST doesn't specify text conversion, merge with that of SECOND.
+     (if (eq (coding-system-base first) 'undecided)
+       (setq first (coding-system-change-text-conversion first base)))
+     ;; If FIRST doesn't specify eol conversion, merge with that of SECOND.
+     (if (and (vectorp (coding-system-eol-type first))
+            (numberp eol) (>= eol 0) (<= eol 2))
+       (setq first (coding-system-change-eol-conversion
+                    first eol)))
+     first))
+ 
  (defun set-buffer-file-coding-system (coding-system &optional force)
    "Set the file coding-system of the current buffer to CODING-SYSTEM.
  This means that when you save the buffer, it will be converted
  according to CODING-SYSTEM.  For a list of possible values of CODING-SYSTEM,
  use \\[list-coding-systems].
  
! If CODING-SYSTEM leaves the text conversion unspecified, or if it
! leaves the end-of-line conversion unspecified, FORCE controls what to
! do.  If FORCE is nil, get the unspecified aspect (or aspects) from the
! buffer's previous `buffer-file-coding-system' value (if it is
! specified there).  Otherwise, levae it unspecified.
  
  This marks the buffer modified so that the succeeding \\[save-buffer]
  surely saves the buffer with CODING-SYSTEM.  From a program, if you
  don't want to mark the buffer modified, just set the variable
  `buffer-file-coding-system' directly."
!   (interactive "zCoding system for saving file (default, nil): \nP")
    (check-coding-system coding-system)
    (if (and coding-system buffer-file-coding-system (null force))
!       (setq coding-system
!           (merge-coding-systems coding-system buffer-file-coding-system)))
    (setq buffer-file-coding-system coding-system)
    (set-buffer-modified-p t)
    (force-mode-line-update))
+ 
+ (defun revert-buffer-with-coding-system (coding-system &optional force)
+   "Visit the current buffer's file again using coding system CODING-SYSTEM.
+ For a list of possible values of CODING-SYSTEM, use \\[list-coding-systems].
+ 
+ If CODING-SYSTEM leaves the text conversion unspecified, or if it
+ leaves the end-of-line conversion unspecified, FORCE controls what to
+ do.  If FORCE is nil, get the unspecified aspect (or aspects) from the
+ buffer's previous `buffer-file-coding-system' value (if it is
+ specified there).  Otherwise, determine it from the file contents as
+ usual for visiting a file."
+   (interactive "zCoding system for visited file (default, nil): \nP")
+   (check-coding-system coding-system)
+   (if (and coding-system buffer-file-coding-system (null force))
+       (setq coding-system
+           (merge-coding-systems coding-system buffer-file-coding-system)))
+   (let ((coding-system-for-read coding-system))
+     (revert-buffer)))
  
  (defvar default-terminal-coding-system nil
    "Default value for the terminal coding system.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]