Mercurial > hg > xemacs-beta
comparison lisp/files.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 | c00528d80f25 |
children | 703228f54913 |
comparison
equal
deleted
inserted
replaced
770:336a418893b5 | 771:943eaba38521 |
---|---|
1 ;;; files.el --- file input and output commands for XEmacs. | 1 ;;; files.el --- file input and output commands for XEmacs. |
2 | 2 |
3 ;; Copyright (C) 1985-1987, 1992-1995, 1997 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1985-1987, 1992-1995, 1997 Free Software Foundation, Inc. |
4 ;; Copyright (C) 1995 Sun Microsystems. | 4 ;; Copyright (C) 1995 Sun Microsystems. |
5 ;; Copyright (C) 2001, 2002 Ben Wing. | |
5 | 6 |
6 ;; Maintainer: XEmacs Development Team | 7 ;; Maintainer: XEmacs Development Team |
7 ;; Keywords: extensions, dumped | 8 ;; Keywords: extensions, dumped |
8 | 9 |
9 ;; This file is part of XEmacs. | 10 ;; This file is part of XEmacs. |
595 (list (cons 'name (symbol-name name))))))) | 596 (list (cons 'name (symbol-name name))))))) |
596 (pop-to-buffer buffer t frame) | 597 (pop-to-buffer buffer t frame) |
597 (make-frame-visible frame) | 598 (make-frame-visible frame) |
598 buffer)) | 599 buffer)) |
599 | 600 |
601 (defun switch-to-next-buffer (&optional n) | |
602 "Switch to the next-most-recent buffer. | |
603 This essentially rotates the buffer list forward. | |
604 N (interactively, the prefix arg) specifies how many times to rotate | |
605 forward, and defaults to 1. Buffers whose name begins with a space | |
606 \(i.e. \"invisible\" buffers) are ignored." | |
607 ;; Here is a different interactive spec. Look up the function | |
608 ;; `interactive' (i.e. `C-h f interactive') to understand how this | |
609 ;; all works. | |
610 (interactive "p") | |
611 (dotimes (n (or n 1)) | |
612 (loop | |
613 do (bury-buffer (car (buffer-list))) | |
614 while (funcall buffers-tab-omit-function (car (buffer-list)))) | |
615 (switch-to-buffer (car (buffer-list))))) | |
616 | |
617 (defun switch-to-previous-buffer (&optional n) | |
618 "Switch to the previously most-recent buffer. | |
619 This essentially rotates the buffer list backward. | |
620 N (interactively, the prefix arg) specifies how many times to rotate | |
621 backward, and defaults to 1. Buffers whose name begins with a space | |
622 \(i.e. \"invisible\" buffers) are ignored." | |
623 (interactive "p") | |
624 (dotimes (n (or n 1)) | |
625 (loop | |
626 do (switch-to-buffer (car (last (buffer-list)))) | |
627 while (funcall buffers-tab-omit-function (car (buffer-list)))))) | |
628 | |
629 (defun switch-to-next-buffer-in-group (&optional n) | |
630 "Switch to the next-most-recent buffer in the current group. | |
631 This essentially rotates the buffer list forward. | |
632 N (interactively, the prefix arg) specifies how many times to rotate | |
633 forward, and defaults to 1. Buffers whose name begins with a space | |
634 \(i.e. \"invisible\" buffers) are ignored." | |
635 (interactive "p") | |
636 (dotimes (n (or n 1)) | |
637 (let ((curbuf (car (buffer-list)))) | |
638 (loop | |
639 do (bury-buffer (car (buffer-list))) | |
640 while (or (funcall buffers-tab-omit-function (car (buffer-list))) | |
641 (not (funcall buffers-tab-selection-function | |
642 curbuf (car (buffer-list))))))) | |
643 (switch-to-buffer (car (buffer-list))))) | |
644 | |
645 (defun switch-to-previous-buffer-in-group (&optional n) | |
646 "Switch to the previously most-recent buffer in the current group. | |
647 This essentially rotates the buffer list backward. | |
648 N (interactively, the prefix arg) specifies how many times to rotate | |
649 backward, and defaults to 1. Buffers whose name begins with a space | |
650 \(i.e. \"invisible\" buffers) are ignored." | |
651 (interactive "p") | |
652 (dotimes (n (or n 1)) | |
653 (let ((curbuf (car (buffer-list)))) | |
654 (loop | |
655 do (switch-to-buffer (car (last (buffer-list)))) | |
656 while (or (funcall buffers-tab-omit-function (car (buffer-list))) | |
657 (not (funcall buffers-tab-selection-function | |
658 curbuf (car (buffer-list))))))))) | |
659 | |
600 (defun find-file (filename &optional codesys) | 660 (defun find-file (filename &optional codesys) |
601 "Edit file FILENAME. | 661 "Edit file FILENAME. |
602 Switch to a buffer visiting file FILENAME, | 662 Switch to a buffer visiting file FILENAME, creating one if none already |
603 creating one if none already exists. | 663 exists. Optional second argument specifies the coding system to use when |
604 Under XEmacs/Mule, optional second argument specifies the | 664 decoding the file. Interactively, with a prefix argument, you will be |
605 coding system to use when decoding the file. Interactively, | 665 prompted for the coding system. |
606 with a prefix argument, you will be prompted for the coding system." | 666 |
667 If you do not explicitly specify a coding system, the coding system | |
668 is determined as follows: | |
669 | |
670 1. `coding-system-for-read', if non-nil. (This is used by Lisp programs to | |
671 temporarily set an overriding coding system and should almost never | |
672 apply here in `find-file'.) | |
673 2. The result of `insert-file-contents-pre-hook', if non-nil. (This is a | |
674 complex interface for handling special cases.) | |
675 3. The matching value for this filename from `file-coding-system-alist', | |
676 if any. (This lets you specify the coding system to be used for | |
677 files with particular extensions, names, etc.) | |
678 4. `buffer-file-coding-system-for-read', if non-nil. (This is the global | |
679 default -- normally `undecided', so the built-in auto-detection | |
680 mechanism can do its thing.) | |
681 5. The coding system 'raw-text. | |
682 | |
683 See `insert-file-contents' for more details about how the process of | |
684 determining the coding system works." | |
607 (interactive "FFind file: \nZCoding system: ") | 685 (interactive "FFind file: \nZCoding system: ") |
608 (if codesys | 686 (if codesys |
609 (let ((coding-system-for-read | 687 (let ((coding-system-for-read |
610 (get-coding-system codesys))) | 688 (get-coding-system codesys))) |
611 (switch-to-buffer (find-file-noselect filename))) | 689 (switch-to-buffer (find-file-noselect filename))) |
612 (switch-to-buffer (find-file-noselect filename)))) | 690 (switch-to-buffer (find-file-noselect filename)))) |
613 | 691 |
614 (defun find-file-other-window (filename &optional codesys) | 692 (defun find-file-other-window (filename &optional codesys) |
615 "Edit file FILENAME, in another window. | 693 "Edit file FILENAME, in another window. |
616 May create a new window, or reuse an existing one. | 694 May create a new window, or reuse an existing one. See the function |
617 See the function `display-buffer'. | 695 `display-buffer'. Optional second argument specifies the coding system to |
618 Under XEmacs/Mule, optional second argument specifies the | 696 use when decoding the file. Interactively, with a prefix argument, you |
619 coding system to use when decoding the file. Interactively, | 697 will be prompted for the coding system." |
620 with a prefix argument, you will be prompted for the coding system." | |
621 (interactive "FFind file in other window: \nZCoding system: ") | 698 (interactive "FFind file in other window: \nZCoding system: ") |
622 (if codesys | 699 (if codesys |
623 (let ((coding-system-for-read | 700 (let ((coding-system-for-read |
624 (get-coding-system codesys))) | 701 (get-coding-system codesys))) |
625 (switch-to-buffer-other-window (find-file-noselect filename))) | 702 (switch-to-buffer-other-window (find-file-noselect filename))) |
626 (switch-to-buffer-other-window (find-file-noselect filename)))) | 703 (switch-to-buffer-other-window (find-file-noselect filename)))) |
627 | 704 |
628 (defun find-file-other-frame (filename &optional codesys) | 705 (defun find-file-other-frame (filename &optional codesys) |
629 "Edit file FILENAME, in a newly-created frame. | 706 "Edit file FILENAME, in a newly-created frame. |
630 Under XEmacs/Mule, optional second argument specifies the | 707 Optional second argument specifies the coding system to use when decoding |
631 coding system to use when decoding the file. Interactively, | 708 the file. Interactively, with a prefix argument, you will be prompted for |
632 with a prefix argument, you will be prompted for the coding system." | 709 the coding system." |
633 (interactive "FFind file in other frame: \nZCoding system: ") | 710 (interactive "FFind file in other frame: \nZCoding system: ") |
634 (if codesys | 711 (if codesys |
635 (let ((coding-system-for-read | 712 (let ((coding-system-for-read |
636 (get-coding-system codesys))) | 713 (get-coding-system codesys))) |
637 (switch-to-buffer-other-frame (find-file-noselect filename))) | 714 (switch-to-buffer-other-frame (find-file-noselect filename))) |
639 | 716 |
640 (defun find-file-read-only (filename &optional codesys) | 717 (defun find-file-read-only (filename &optional codesys) |
641 "Edit file FILENAME but don't allow changes. | 718 "Edit file FILENAME but don't allow changes. |
642 Like \\[find-file] but marks buffer as read-only. | 719 Like \\[find-file] but marks buffer as read-only. |
643 Use \\[toggle-read-only] to permit editing. | 720 Use \\[toggle-read-only] to permit editing. |
644 Under XEmacs/Mule, optional second argument specifies the | 721 Optional second argument specifies the coding system to use when decoding |
645 coding system to use when decoding the file. Interactively, | 722 the file. Interactively, with a prefix argument, you will be prompted for |
646 with a prefix argument, you will be prompted for the coding system." | 723 the coding system." |
647 (interactive "fFind file read-only: \nZCoding system: ") | 724 (interactive "fFind file read-only: \nZCoding system: ") |
648 (if codesys | 725 (if codesys |
649 (let ((coding-system-for-read | 726 (let ((coding-system-for-read |
650 (get-coding-system codesys))) | 727 (get-coding-system codesys))) |
651 (find-file filename)) | 728 (find-file filename)) |
655 | 732 |
656 (defun find-file-read-only-other-window (filename &optional codesys) | 733 (defun find-file-read-only-other-window (filename &optional codesys) |
657 "Edit file FILENAME in another window but don't allow changes. | 734 "Edit file FILENAME in another window but don't allow changes. |
658 Like \\[find-file-other-window] but marks buffer as read-only. | 735 Like \\[find-file-other-window] but marks buffer as read-only. |
659 Use \\[toggle-read-only] to permit editing. | 736 Use \\[toggle-read-only] to permit editing. |
660 Under XEmacs/Mule, optional second argument specifies the | 737 Optional second argument specifies the coding system to use when decoding |
661 coding system to use when decoding the file. Interactively, | 738 the file. Interactively, with a prefix argument, you will be prompted for |
662 with a prefix argument, you will be prompted for the coding system." | 739 the coding system." |
663 (interactive "fFind file read-only other window: \nZCoding system: ") | 740 (interactive "fFind file read-only other window: \nZCoding system: ") |
664 (if codesys | 741 (if codesys |
665 (let ((coding-system-for-read | 742 (let ((coding-system-for-read |
666 (get-coding-system codesys))) | 743 (get-coding-system codesys))) |
667 (find-file-other-window filename)) | 744 (find-file-other-window filename)) |
671 | 748 |
672 (defun find-file-read-only-other-frame (filename &optional codesys) | 749 (defun find-file-read-only-other-frame (filename &optional codesys) |
673 "Edit file FILENAME in another frame but don't allow changes. | 750 "Edit file FILENAME in another frame but don't allow changes. |
674 Like \\[find-file-other-frame] but marks buffer as read-only. | 751 Like \\[find-file-other-frame] but marks buffer as read-only. |
675 Use \\[toggle-read-only] to permit editing. | 752 Use \\[toggle-read-only] to permit editing. |
676 Under XEmacs/Mule, optional second argument specifies the | 753 Optional second argument specifies the coding system to use when decoding |
677 coding system to use when decoding the file. Interactively, | 754 the file. Interactively, with a prefix argument, you will be prompted for |
678 with a prefix argument, you will be prompted for the coding system." | 755 the coding system." |
679 (interactive "fFind file read-only other frame: \nZCoding system: ") | 756 (interactive "fFind file read-only other frame: \nZCoding system: ") |
680 (if codesys | 757 (if codesys |
681 (let ((coding-system-for-read | 758 (let ((coding-system-for-read |
682 (get-coding-system codesys))) | 759 (get-coding-system codesys))) |
683 (find-file-other-frame filename)) | 760 (find-file-other-frame filename)) |
685 (setq buffer-read-only t) | 762 (setq buffer-read-only t) |
686 (current-buffer)) | 763 (current-buffer)) |
687 | 764 |
688 (defun find-alternate-file-other-window (filename &optional codesys) | 765 (defun find-alternate-file-other-window (filename &optional codesys) |
689 "Find file FILENAME as a replacement for the file in the next window. | 766 "Find file FILENAME as a replacement for the file in the next window. |
690 This command does not select that window. | 767 This command does not select that window. Optional second argument |
691 Under XEmacs/Mule, optional second argument specifies the | 768 specifies the coding system to use when decoding the file. Interactively, |
692 coding system to use when decoding the file. Interactively, | |
693 with a prefix argument, you will be prompted for the coding system." | 769 with a prefix argument, you will be prompted for the coding system." |
694 (interactive | 770 (interactive |
695 (save-selected-window | 771 (save-selected-window |
696 (other-window 1) | 772 (other-window 1) |
697 (let ((file buffer-file-name) | 773 (let ((file buffer-file-name) |
700 (and file | 776 (and file |
701 (setq file-name (file-name-nondirectory file) | 777 (setq file-name (file-name-nondirectory file) |
702 file-dir (file-name-directory file))) | 778 file-dir (file-name-directory file))) |
703 (list (read-file-name | 779 (list (read-file-name |
704 "Find alternate file: " file-dir nil nil file-name) | 780 "Find alternate file: " file-dir nil nil file-name) |
705 (if (and current-prefix-arg (featurep 'mule)) | 781 (if current-prefix-arg (read-coding-system "Coding-system: ")))))) |
706 (read-coding-system "Coding-system: ")))))) | |
707 (if (one-window-p) | 782 (if (one-window-p) |
708 (find-file-other-window filename) | 783 (find-file-other-window filename) |
709 (save-selected-window | 784 (save-selected-window |
710 (other-window 1) | 785 (other-window 1) |
711 (find-alternate-file filename codesys)))) | 786 (find-alternate-file filename codesys)))) |
712 | 787 |
713 (defun find-alternate-file (filename &optional codesys) | 788 (defun find-alternate-file (filename &optional codesys) |
714 "Find file FILENAME, select its buffer, kill previous buffer. | 789 "Find file FILENAME, select its buffer, kill previous buffer. |
715 If the current buffer now contains an empty file that you just visited | 790 If the current buffer now contains an empty file that you just visited |
716 \(presumably by mistake), use this command to visit the file you really want. | 791 \(presumably by mistake), use this command to visit the file you really |
717 Under XEmacs/Mule, optional second argument specifies the | 792 want. Optional second argument specifies the coding system to use when |
718 coding system to use when decoding the file. Interactively, | 793 decoding the file. Interactively, with a prefix argument, you will be |
719 with a prefix argument, you will be prompted for the coding system." | 794 prompted for the coding system." |
720 (interactive | 795 (interactive |
721 (let ((file buffer-file-name) | 796 (let ((file buffer-file-name) |
722 (file-name nil) | 797 (file-name nil) |
723 (file-dir nil)) | 798 (file-dir nil)) |
724 (and file | 799 (and file |
725 (setq file-name (file-name-nondirectory file) | 800 (setq file-name (file-name-nondirectory file) |
726 file-dir (file-name-directory file))) | 801 file-dir (file-name-directory file))) |
727 (list (read-file-name | 802 (list (read-file-name |
728 "Find alternate file: " file-dir nil nil file-name) | 803 "Find alternate file: " file-dir nil nil file-name) |
729 (if (and current-prefix-arg (featurep 'mule)) | 804 (if current-prefix-arg (read-coding-system "Coding-system: "))))) |
730 (read-coding-system "Coding-system: "))))) | |
731 (and (buffer-modified-p) (buffer-file-name) | 805 (and (buffer-modified-p) (buffer-file-name) |
732 ;; (not buffer-read-only) | 806 ;; (not buffer-read-only) |
733 (not (yes-or-no-p (format | 807 (not (yes-or-no-p (format |
734 "Buffer %s is modified; kill anyway? " | 808 "Buffer %s is modified; kill anyway? " |
735 (buffer-name)))) | 809 (buffer-name)))) |
1880 ;; #### ?? | 1954 ;; #### ?? |
1881 (run-hooks 'after-set-visited-file-name-hooks)) | 1955 (run-hooks 'after-set-visited-file-name-hooks)) |
1882 | 1956 |
1883 (defun write-file (filename &optional confirm codesys) | 1957 (defun write-file (filename &optional confirm codesys) |
1884 "Write current buffer into file FILENAME. | 1958 "Write current buffer into file FILENAME. |
1885 Makes buffer visit that file, and marks it not modified. | 1959 Makes buffer visit that file, and marks it not modified. If the buffer is |
1886 If the buffer is already visiting a file, you can specify | 1960 already visiting a file, you can specify a directory name as FILENAME, to |
1887 a directory name as FILENAME, to write a file of the same | 1961 write a file of the same old name in that directory. |
1888 old name in that directory. | 1962 |
1889 If optional second arg CONFIRM is non-nil, | 1963 If optional second arg CONFIRM is non-nil, ask for confirmation for |
1890 ask for confirmation for overwriting an existing file. | 1964 overwriting an existing file. |
1891 Under XEmacs/Mule, optional third argument specifies the | 1965 |
1892 coding system to use when encoding the file. Interactively, | 1966 Optional third argument specifies the coding system to use when encoding |
1893 with a prefix argument, you will be prompted for the coding system." | 1967 the file. Interactively, with a prefix argument, you will be prompted for |
1968 the coding system." | |
1894 ;; (interactive "FWrite file: ") | 1969 ;; (interactive "FWrite file: ") |
1895 (interactive | 1970 (interactive |
1896 (list (if buffer-file-name | 1971 (list (if buffer-file-name |
1897 (read-file-name "Write file: " | 1972 (read-file-name "Write file: " |
1898 nil nil nil nil) | 1973 nil nil nil nil) |
1899 (read-file-name "Write file: " | 1974 (read-file-name "Write file: " |
1900 (cdr (assq 'default-directory | 1975 (cdr (assq 'default-directory |
1901 (buffer-local-variables))) | 1976 (buffer-local-variables))) |
1902 nil nil (buffer-name))) | 1977 nil nil (buffer-name))) |
1903 t | 1978 t |
1904 (if (and current-prefix-arg (featurep 'file-coding)) | 1979 (if current-prefix-arg (read-coding-system "Coding system: ")))) |
1905 (read-coding-system "Coding system: ")))) | |
1906 (and (eq (current-buffer) mouse-grabbed-buffer) | 1980 (and (eq (current-buffer) mouse-grabbed-buffer) |
1907 (error "Can't write minibuffer window")) | 1981 (error "Can't write minibuffer window")) |
1908 (or (null filename) (string-equal filename "") | 1982 (or (null filename) (string-equal filename "") |
1909 (progn | 1983 (progn |
1910 ;; If arg is just a directory, | 1984 ;; If arg is just a directory, |
2578 | 2652 |
2579 (defun insert-file (filename &optional codesys) | 2653 (defun insert-file (filename &optional codesys) |
2580 "Insert contents of file FILENAME into buffer after point. | 2654 "Insert contents of file FILENAME into buffer after point. |
2581 Set mark after the inserted text. | 2655 Set mark after the inserted text. |
2582 | 2656 |
2583 Under XEmacs/Mule, optional second argument specifies the | 2657 Optional second argument specifies the coding system to use when decoding |
2584 coding system to use when decoding the file. Interactively, | 2658 the file. Interactively, with a prefix argument, you will be prompted for |
2585 with a prefix argument, you will be prompted for the coding system. | 2659 the coding system. |
2586 | 2660 |
2587 This function is meant for the user to run interactively. | 2661 This function is meant for the user to run interactively. Don't call it |
2588 Don't call it from programs! Use `insert-file-contents' instead. | 2662 from programs! Use `insert-file-contents' instead. \(Its calling sequence |
2589 \(Its calling sequence is different; see its documentation)." | 2663 is different; see its documentation)." |
2590 (interactive "*fInsert file: \nZCoding system: ") | 2664 (interactive "*fInsert file: \nZCoding system: ") |
2591 (if (file-directory-p filename) | 2665 (if (file-directory-p filename) |
2592 (signal 'file-error (list "Opening input file" "file is a directory" | 2666 (signal 'file-error (list "Opening input file" "file is a directory" |
2593 filename))) | 2667 filename))) |
2594 (let ((tem | 2668 (let ((tem |
2599 (insert-file-contents filename)))) | 2673 (insert-file-contents filename)))) |
2600 (push-mark (+ (point) (car (cdr tem)))))) | 2674 (push-mark (+ (point) (car (cdr tem)))))) |
2601 | 2675 |
2602 (defun append-to-file (start end filename &optional codesys) | 2676 (defun append-to-file (start end filename &optional codesys) |
2603 "Append the contents of the region to the end of file FILENAME. | 2677 "Append the contents of the region to the end of file FILENAME. |
2604 When called from a function, expects three arguments, | 2678 When called from a function, expects three arguments, START, END and |
2605 START, END and FILENAME. START and END are buffer positions | 2679 FILENAME. START and END are buffer positions saying what text to write. |
2606 saying what text to write. | 2680 Optional fourth argument specifies the coding system to use when encoding |
2607 Under XEmacs/Mule, optional fourth argument specifies the | 2681 the file. Interactively, with a prefix argument, you will be prompted for |
2608 coding system to use when encoding the file. Interactively, | 2682 the coding system." |
2609 with a prefix argument, you will be prompted for the coding system." | |
2610 (interactive "r\nFAppend to file: \nZCoding system: ") | 2683 (interactive "r\nFAppend to file: \nZCoding system: ") |
2611 (if codesys | 2684 (if codesys |
2612 (let ((buffer-file-coding-system (get-coding-system codesys))) | 2685 (let ((buffer-file-coding-system (get-coding-system codesys))) |
2613 (write-region start end filename t)) | 2686 (write-region start end filename t)) |
2614 (write-region start end filename t))) | 2687 (write-region start end filename t))) |
2796 ;; so that we don't try to lock the file. | 2869 ;; so that we don't try to lock the file. |
2797 (let ((buffer-file-name nil)) | 2870 (let ((buffer-file-name nil)) |
2798 (or auto-save-p | 2871 (or auto-save-p |
2799 (unlock-buffer))) | 2872 (unlock-buffer))) |
2800 (widen) | 2873 (widen) |
2801 (insert-file-contents file-name (not auto-save-p) | 2874 ;; When reading in an autosave, it's encoded using |
2802 nil nil t))) | 2875 ;; `escape-quoted', so we need to use it. (It is always |
2876 ;; safe to specify `escape-quoted': | |
2877 ;; | |
2878 ;; 1. If file-coding but no Mule, `escape-quoted' is | |
2879 ;; aliased to `binary'. | |
2880 ;; 2. If no file-coding, all coding systems devolve into | |
2881 ;; `binary'. | |
2882 ;; 3. ASCII and ISO8859-1 are encoded the same in both | |
2883 ;; `binary' and `escape-quoted', so they will be | |
2884 ;; compatible for the most part.) | |
2885 ;; | |
2886 ;; Otherwise, use coding-system-for-read if explicitly | |
2887 ;; given (e.g. the "Revert Buffer with Specified | |
2888 ;; Encoding" menu entries), or use the coding system | |
2889 ;; that the file was loaded as. | |
2890 (let* ((coding-system-for-read | |
2891 (if auto-save-p 'escape-quoted | |
2892 (or coding-system-for-read | |
2893 buffer-file-coding-system-when-loaded))) | |
2894 ;; If the bfcs wasn't changed from its original | |
2895 ;; value (other than possible EOL change), then we | |
2896 ;; should update it for the new coding system. | |
2897 (should-update-bfcs | |
2898 (eq (coding-system-base | |
2899 buffer-file-coding-system-when-loaded) | |
2900 (coding-system-base | |
2901 buffer-file-coding-system))) | |
2902 (old-bfcs buffer-file-coding-system) | |
2903 ;; But if the EOL was changed, match it in the new | |
2904 ;; value of bfcs. | |
2905 (adjust-eol | |
2906 (and should-update-bfcs | |
2907 (not | |
2908 (eq (get-coding-system | |
2909 buffer-file-coding-system-when-loaded) | |
2910 (get-coding-system | |
2911 buffer-file-coding-system)))))) | |
2912 (insert-file-contents file-name (not auto-save-p) | |
2913 nil nil t) | |
2914 (when should-update-bfcs | |
2915 (setq buffer-file-coding-system old-bfcs) | |
2916 (set-buffer-file-coding-system | |
2917 (if adjust-eol | |
2918 (coding-system-base | |
2919 buffer-file-coding-system-when-loaded) | |
2920 buffer-file-coding-system-when-loaded) | |
2921 (not adjust-eol)))))) | |
2803 (goto-char (min opoint (point-max))) | 2922 (goto-char (min opoint (point-max))) |
2804 ;; Recompute the truename in case changes in symlinks | 2923 ;; Recompute the truename in case changes in symlinks |
2805 ;; have changed the truename. | 2924 ;; have changed the truename. |
2806 ;XEmacs: already done by insert-file-contents | 2925 ;XEmacs: already done by insert-file-contents |
2807 ;;(setq buffer-file-truename | 2926 ;;(setq buffer-file-truename |
2853 (insert-directory file-name "-l"))) | 2972 (insert-directory file-name "-l"))) |
2854 (yes-or-no-p (format "Recover auto save file %s? " file-name))) | 2973 (yes-or-no-p (format "Recover auto save file %s? " file-name))) |
2855 (switch-to-buffer (find-file-noselect file t)) | 2974 (switch-to-buffer (find-file-noselect file t)) |
2856 (let ((buffer-read-only nil)) | 2975 (let ((buffer-read-only nil)) |
2857 (erase-buffer) | 2976 (erase-buffer) |
2858 (insert-file-contents file-name nil)) | 2977 (let ((coding-system-for-read 'escape-quoted)) |
2978 (insert-file-contents file-name nil))) | |
2859 (after-find-file nil nil t)) | 2979 (after-find-file nil nil t)) |
2860 (t (error "Recover-file cancelled."))))))) | 2980 (t (error "Recover-file cancelled."))))))) |
2861 | 2981 |
2862 (defun recover-session () | 2982 (defun recover-session () |
2863 "Recover auto save files from a previous Emacs session. | 2983 "Recover auto save files from a previous Emacs session. |
2901 (unwind-protect | 3021 (unwind-protect |
2902 (save-excursion | 3022 (save-excursion |
2903 ;; Read in the auto-save-list file. | 3023 ;; Read in the auto-save-list file. |
2904 (set-buffer buffer) | 3024 (set-buffer buffer) |
2905 (erase-buffer) | 3025 (erase-buffer) |
2906 (insert-file-contents file) | 3026 (let ((coding-system-for-read 'escape-quoted)) |
3027 (insert-file-contents file)) | |
2907 ;; Loop thru the text of that file | 3028 ;; Loop thru the text of that file |
2908 ;; and get out the names of the files to recover. | 3029 ;; and get out the names of the files to recover. |
2909 (while (not (eobp)) | 3030 (while (not (eobp)) |
2910 (let (thisfile autofile) | 3031 (let (thisfile autofile) |
2911 (if (eolp) | 3032 (if (eolp) |