;;; files.el --- file input and output commands for Emacs
-;; Copyright (C) 1985, 86, 87, 92, 93,
-;; 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 86, 87, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001
+;;; Free Software Foundation, Inc.
;; Maintainer: FSF
:group 'abbrev
:group 'find-file)
-;;; Turn off backup files on VMS since it has version numbers.
+;; Turn off backup files on VMS since it has version numbers.
(defcustom make-backup-files (not (eq system-type 'vax-vms))
"*Non-nil means make a backup of a file the first time it is saved.
This can be done by renaming the file or by copying.
(defun switch-to-buffer-other-window (buffer &optional norecord)
"Select buffer BUFFER in another window.
Optional second arg NORECORD non-nil means
-do not put this buffer at the front of the list of recently selected ones."
+do not put this buffer at the front of the list of recently selected ones.
+
+This uses the function `display-buffer' as a subroutine; see its
+documentation for additional customization information."
(interactive "BSwitch to buffer in other window: ")
(let ((pop-up-windows t))
(pop-to-buffer buffer t norecord)))
(defun switch-to-buffer-other-frame (buffer &optional norecord)
"Switch to buffer BUFFER in another frame.
Optional second arg NORECORD non-nil means
-do not put this buffer at the front of the list of recently selected ones."
+do not put this buffer at the front of the list of recently selected ones.
+
+This uses the function `display-buffer' as a subroutine; see its
+documentation for additional customization information."
(interactive "BSwitch to buffer in other frame: ")
(let ((pop-up-frames t))
(pop-to-buffer buffer t norecord)
(after-insert-file-functions nil)
(coding-system-for-read 'no-conversion)
(coding-system-for-write 'no-conversion)
- (jka-compr-compression-info-list nil)
(find-buffer-file-type-function
(if (fboundp 'find-buffer-file-type)
(symbol-function 'find-buffer-file-type)
- nil)))
+ nil))
+ (inhibit-file-name-handlers '(jka-compr-handler image-file-handler))
+ (inhibit-file-name-operation 'insert-file-contents))
(unwind-protect
(progn
(fset 'find-buffer-file-type (lambda (filename) t))
("\\.p\\'" . pascal-mode)
("\\.pas\\'" . pascal-mode)
("\\.ad[abs]\\'" . ada-mode)
- ("\\.\\([pP][Llm]\\|al\\)\\'" . perl-mode)
+ ("\\.\\([pP]\\([Llm]\\|erl\\)\\|al\\)\\'" . perl-mode)
("\\.s?html?\\'" . html-mode)
("\\.cc\\'" . c++-mode)
("\\.hh\\'" . c++-mode)
("\\.mk\\'" . makefile-mode)
("\\(M\\|m\\|GNUm\\)akefile\\(\\.in\\)?\\'" . makefile-mode)
("\\.am\\'" . makefile-mode) ;For Automake.
-;;; Less common extensions come here
-;;; so more common ones above are found faster.
+ ;; Less common extensions come here
+ ;; so more common ones above are found faster.
("\\.texinfo\\'" . texinfo-mode)
("\\.te?xi\\'" . texinfo-mode)
("\\.s\\'" . asm-mode)
("\\.\\(diffs?\\|patch\\|rej\\)\\'" . diff-mode)
("\\.\\(dif\\|pat\\)\\'" . diff-mode) ; for MSDOG
("\\.[eE]?[pP][sS]\\'" . ps-mode)
- ("configure\\.in\\'" . autoconf-mode)
+ ("configure\\.\\(ac\\|in\\)\\'" . autoconf-mode)
("BROWSE\\'" . ebrowse-tree-mode)
("\\.ebrowse\\'" . ebrowse-tree-mode)
("#\\*mail\\*" . mail-mode)
;; Get rid of any trailing .n.m and try again.
;; This is for files saved by cvs-merge that look like .#<file>.<rev>
- ;; or .#<file>.<rev>-<rev> or VC's <file>.~<rev>~
- ("\\.~?[0-9]+\\.[0-9][-.0-9]*~?\\'" nil t)
-;;; The following should come after the ChangeLog pattern
-;;; for the sake of ChangeLog.1, etc.
-;;; and after the .scm.[0-9] and CVS' <file>.<rev> patterns too.
- ("\\.[12345678]\\'" . nroff-mode)
+ ;; or .#<file>.<rev>-<rev> or VC's <file>.~<rev>~.
+ ;; Using mode nil rather than `ignore' would let the search continue
+ ;; through this list (with the shortened name) rather than start over.
+ ("\\.~?[0-9]+\\.[0-9][-.0-9]*~?\\'" ignore t)
+ ;; The following should come after the ChangeLog pattern
+ ;; for the sake of ChangeLog.1, etc.
+ ;; and after the .scm.[0-9] and CVS' <file>.<rev> patterns too.
+ ("\\.[1-9]\\'" . nroff-mode)
("\\.g\\'" . antlr-mode)))
"Alist of filename patterns vs corresponding major mode functions.
Each element looks like (REGEXP . FUNCTION) or (REGEXP FUNCTION NON-NIL).
(setq backup-info (find-backup-file-name real-file-name)
backupname (car backup-info)
targets (cdr backup-info))
-;;; (if (file-directory-p buffer-file-name)
-;;; (error "Cannot save buffer in directory %s" buffer-file-name))
+ ;; (if (file-directory-p buffer-file-name)
+ ;; (error "Cannot save buffer in directory %s" buffer-file-name))
(if backup-info
(condition-case ()
(let ((delete-old-versions
On MS-DOS filesystems without long names this variable is always
ignored."
:group 'backup
- :type '(repeat (cons (regexp :tag "Regexp macthing filename")
+ :type '(repeat (cons (regexp :tag "Regexp matching filename")
(directory :tag "Backup directory name"))))
(defun make-backup-file-name (file)
(make-backup-files (or (and make-backup-files (not (eq args 0)))
(memq args '(16 64)))))
(and modp (memq args '(16 64)) (setq buffer-backed-up nil))
- (if (and modp large) (message "Saving file %s..." (buffer-file-name)))
+ (if (and modp large (buffer-file-name))
+ (message "Saving file %s..." (buffer-file-name)))
(basic-save-buffer)
(and modp (memq args '(4 64)) (setq buffer-backed-up nil))))
(if (and (eq system-type 'ms-dos)
(not (msdos-long-file-names)))
- (let ((fn (file-name-nondirectory buffer-file-name)))
+ ;; We truncate the file name to DOS 8+3 limits before
+ ;; doing anything else, because the regexp passed to
+ ;; string-match below cannot handle extensions longer than
+ ;; 3 characters, multiple dots, and other atrocities.
+ (let ((fn (dos-8+3-filename
+ (file-name-nondirectory buffer-file-name))))
(string-match "\\`\\([^.]+\\)\\(\\.\\(..?\\)?.?\\|\\)\\'" fn)
(concat (file-name-directory buffer-file-name)
"#" (match-string 1 fn)