aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1997-09-17 06:41:41 +0000
committerRichard M. Stallman1997-09-17 06:41:41 +0000
commitb685f8d6b59c9bcb2850211f5bce3768ca8d9577 (patch)
treecc7cb7e8c2c82d38e0fe1b0120eb833185fc8fbb
parente3ee748781bf7a4f3060245cb5ef5391e3905cf1 (diff)
downloademacs-b685f8d6b59c9bcb2850211f5bce3768ca8d9577.tar.gz
emacs-b685f8d6b59c9bcb2850211f5bce3768ca8d9577.zip
(find-new-buffer-file-coding-system): Reflectemacs-20.1
text coding part of default-buffer-file-coding-system to buffer-file-coding-system when buffer-file-coding-system is not locally set and ASCII only text is read.
-rw-r--r--lisp/international/mule.el65
1 files changed, 39 insertions, 26 deletions
diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index 66e82575ec4..9eeeb30d659 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -728,30 +728,27 @@ The local variable `buffer-file-coding-system' of the current buffer
728is set to the returned value. 728is set to the returned value.
729Return nil if there's no need of setting new buffer-file-coding-system." 729Return nil if there's no need of setting new buffer-file-coding-system."
730 (let (local-coding local-eol 730 (let (local-coding local-eol
731 found-eol 731 found-coding found-eol
732 new-coding new-eol) 732 new-coding new-eol)
733 (if (null coding) 733 (if (null coding)
734 ;; Nothing found about coding. 734 ;; Nothing found about coding.
735 nil 735 nil
736 736
737 ;; Get information of the current local value of 737 ;; Get information of `buffer-file-coding-system' in LOCAL-EOL
738 ;; `buffer-file-coding-system' in LOCAL-EOL and LOCAL-CODING. 738 ;; and LOCAL-CODING.
739 (if (local-variable-p 'buffer-file-coding-system) 739 (setq local-eol (coding-system-eol-type buffer-file-coding-system))
740 ;; Something already set locally. 740 (if (null (numberp local-eol))
741 (progn 741 ;; But eol-type is not yet set.
742 (setq local-eol (coding-system-eol-type buffer-file-coding-system)) 742 (setq local-eol nil))
743 (if (null (numberp local-eol)) 743 (when (and buffer-file-coding-system
744 ;; But eol-type is not yet set. 744 (not (eq (coding-system-type buffer-file-coding-system) t)))
745 (setq local-eol nil)) 745 ;; This is not `undecided'.
746 (if (null (eq (coding-system-type buffer-file-coding-system) t)) 746 (setq local-coding buffer-file-coding-system)
747 ;; This is not `undecided'. 747 (while (symbolp (get local-coding 'coding-system))
748 (progn 748 (setq local-coding (get local-coding 'coding-system))))
749 (setq local-coding buffer-file-coding-system) 749
750 (while (symbolp (get local-coding 'coding-system)) 750 (if (and (local-variable-p 'buffer-file-coding-system)
751 (setq local-coding (get local-coding 'coding-system)))) 751 local-eol local-coding)
752 )))
753
754 (if (and local-eol local-coding)
755 ;; The current buffer has already set full coding-system, we 752 ;; The current buffer has already set full coding-system, we
756 ;; had better not change it. 753 ;; had better not change it.
757 nil 754 nil
@@ -760,15 +757,31 @@ Return nil if there's no need of setting new buffer-file-coding-system."
760 (if (null (numberp found-eol)) 757 (if (null (numberp found-eol))
761 ;; But eol-type is not found. 758 ;; But eol-type is not found.
762 (setq found-eol nil)) 759 (setq found-eol nil))
760 (unless (eq (coding-system-type coding) t)
761 ;; This is not `undecided'.
762 (setq found-coding coding)
763 (while (symbolp (get found-coding 'coding-system))
764 (setq found-coding (get found-coding 'coding-system))))
763 765
764 ;; The local setting takes precedence over the found one. 766 ;; The local setting takes precedence over the found one.
765 (setq new-coding (or local-coding coding)) 767 (setq new-coding (or (and (local-variable-p 'buffer-file-coding-system)
766 (setq new-eol (or local-eol found-eol)) 768 local-coding)
767 (if (and (numberp new-eol) 769 found-coding
768 (vectorp (coding-system-eol-type new-coding))) 770 local-coding))
769 (setq new-coding 771 (setq new-eol (or (and (local-variable-p 'buffer-file-coding-system)
770 (aref (coding-system-eol-type new-coding) new-eol))) 772 local-eol)
771 new-coding)))) 773 found-eol
774 local-eol))
775 (when (numberp new-eol)
776 (or new-coding
777 (setq new-coding 'undecided))
778 (if (vectorp (coding-system-eol-type new-coding))
779 (setq new-coding
780 (aref (coding-system-eol-type new-coding) new-eol))))
781 ;; Return a new coding system only when it is different from
782 ;; the current one.
783 (if (not (eq buffer-file-coding-system new-coding))
784 new-coding)))))
772 785
773(defun modify-coding-system-alist (target-type regexp coding-system) 786(defun modify-coding-system-alist (target-type regexp coding-system)
774 "Modify one of look up tables for finding a coding system on I/O operation. 787 "Modify one of look up tables for finding a coding system on I/O operation.