(defvar file-name-invalid-regexp
(cond ((and (eq system-type 'ms-dos) (not (msdos-long-file-names)))
- (concat "\\(^\\([A-z]:\\)?/?.*:\\)\\|" ; colon except after drive
+ (concat "^\\([^A-Z[-`a-z]\\|..+\\)?:\\|" ; colon except after drive
"[+, ;=|<>\"?*]\\|\\[\\|\\]\\|" ; invalid characters
+ "[\000-\031]|" ; control characters
"\\(/\\.\\.?[^/]\\)\\|" ; leading dots
"\\(/[^/.]+\\.[^/.]*\\.\\)")) ; more than a single dot
((memq system-type '(ms-dos windows-nt))
- (concat "\\(^\\([A-z]:\\)?/?.*:\\)\\|" ; colon except after drive
- "[|<>\"?*]")) ; invalid characters
+ (concat "^\\([^A-Z[-`a-z]\\|..+\\)?:\\|" ; colon except after drive
+ "[|<>\"?*\000-\031]")) ; invalid characters
(t "[\000]"))
"Regexp recognizing file names which aren't allowed by the filesystem.")
t means make numeric backup versions unconditionally.
nil means make them for files that have some already.
`never' means do not make them."
- :type 'boolean
+ :type '(choice (const :tag "Never" never)
+ (const :tag "If existing" nil)
+ (other :tag "Always" t))
:group 'backup
:group 'vc)
If nil, ask confirmation. Any other value prevents any trimming."
:type '(choice (const :tag "Delete" t)
(const :tag "Ask" nil)
- (sexp :tag "Leave" :format "%t\n" other))
+ (other :tag "Leave" other))
:group 'backup)
(defcustom kept-old-versions 2
nil means don't add newlines."
:type '(choice (const :tag "Off" nil)
(const :tag "Add" t)
- (sexp :tag "Ask" :format "%t\n" ask))
+ (other :tag "Ask" ask))
:group 'editing-basics)
(defcustom auto-save-default t
specifications and ignores this variable."
:type '(choice (const :tag "Obey" t)
(const :tag "Ignore" nil)
- (sexp :tag "Query" :format "%t\n" other))
+ (other :tag "Query" other))
:group 'find-file)
+(defvar local-enable-local-variables t
+ "Like `enable-local-variables' but meant for buffer-local bindings.
+If a major mode sets this to nil, buffer-locally, then any local
+variables list in the file will be ignored.")
+
(defcustom enable-local-eval 'maybe
"*Control processing of the \"variable\" `eval' in a file's local variables.
The value can be t, nil or something else.
and ignores this variable."
:type '(choice (const :tag "Obey" t)
(const :tag "Ignore" nil)
- (sexp :tag "Query" :format "%t\n" other))
+ (other :tag "Query" other))
:group 'find-file)
;; Avoid losing in versions where CLASH_DETECTION is disabled.
(or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP") "/tmp"))))
"The directory for writing temporary files.")
+;; The system null device. (Should reference NULL_DEVICE from C.)
+(defvar null-device "/dev/null" "The system null device.")
+
;; This hook function provides support for ange-ftp host name
;; completion. It runs the usual ange-ftp hook, but only for
;; completion operations. Having this here avoids the need
(truename (abbreviate-file-name (file-truename filename)))
(number (nthcdr 10 (file-attributes truename)))
;; Find any buffer for a file which has same truename.
- (other (and (not buf) (find-buffer-visiting filename)))
- error)
+ (other (and (not buf) (find-buffer-visiting filename))))
;; Let user know if there is a buffer with the same truename.
(if other
(progn
(if (or find-file-existing-other-name find-file-visit-truename)
(setq buf other))))
(if buf
+ ;; We are using an existing buffer.
(progn
(or nowarn
(verify-visited-file-modtime buf)
"Save file and revisit non-literally? "))
(progn
(save-buffer)
- (revert-buffer t t))
+ (find-file-noselect-1 buf filename nowarn
+ rawfile truename number))
(if (y-or-n-p (if rawfile
"Discard your edits and revisit file literally? "
"Discard your edits and revisit file non-literally? "))
(find-file-noselect-1 buf filename nowarn
rawfile truename number)
(error (if rawfile "File already visited non-literally"
- "File already visited literally")))))))
- (progn
- (setq buf (create-file-buffer filename))
- (set-buffer-major-mode buf)
- (find-file-noselect-1 buf filename nowarn rawfile truename number)))
- buf)))
+ "File already visited literally"))))))
+ ;; Return the buffer we are using.
+ buf)
+ ;; Create a new buffer.
+ (setq buf (create-file-buffer filename))
+ (set-buffer-major-mode buf)
+ ;; find-file-noselect-1 may use a different buffer.
+ (find-file-noselect-1 buf filename nowarn
+ rawfile truename number)))))
(defun find-file-noselect-1 (buf filename nowarn rawfile truename number)
- (let ((inhibit-read-only t))
+ (let ((inhibit-read-only t)
+ error)
(with-current-buffer buf
(kill-local-variable 'find-file-literally)
- (setq buffer-file-coding-system nil)
+ ;; Needed in case we are re-visiting the file with a different
+ ;; text representation.
+ (kill-local-variable 'buffer-file-coding-system)
(erase-buffer)
(and (default-value 'enable-multibyte-characters)
(not rawfile)
(setq buffer-file-coding-system 'no-conversion)
(make-local-variable 'find-file-literally)
(setq find-file-literally t))
- (after-find-file error (not nowarn))
- (setq buf (current-buffer))))))
+ (after-find-file error (not nowarn)))
+ (current-buffer))))
\f
(defun insert-file-contents-literally (filename &optional visit beg end replace)
"Like `insert-file-contents', but only reads in the file literally.
("\\$CHANGE_LOG\\$\\.TXT" . change-log-mode)
("\\.scm\\.[0-9]*\\'" . scheme-mode)
("\\.[ck]?sh\\'\\|\\.shar\\'\\|/\\.z?profile\\'" . sh-mode)
- ("/\\.\\(bash_profile\\|z?login\\|bash_login\\|z?logout\\)\\'" . sh-mode)
- ("/\\.\\(bash_logout\\|[kz]shrc\\|bashrc\\|t?cshrc\\|esrc\\)\\'" . sh-mode)
- ("/\\.\\([kz]shenv\\|xinitrc\\|startxrc\\|xsession\\)\\'" . sh-mode)
+ ("\\(/\\|\\`)\\.\\(bash_profile\\|z?login\\|bash_login\\|z?logout\\)\\'" . sh-mode)
+ ("\\(/\\|\\`)\\.\\(bash_logout\\|[kz]shrc\\|bashrc\\|t?cshrc\\|esrc\\)\\'" . sh-mode)
+ ("\\(/\\|\\`)\\.\\([kz]shenv\\|xinitrc\\|startxrc\\|xsession\\)\\'" . sh-mode)
;;; The following should come after the ChangeLog pattern
;;; for the sake of ChangeLog.1, etc.
;;; and after the .scm.[0-9] pattern too.
("\\.lex\\'" . c-mode)
("\\.oak\\'" . scheme-mode)
("\\.sgml?\\'" . sgml-mode)
+ ("\\.xml\\'" . sgml-mode)
("\\.dtd\\'" . sgml-mode)
("\\.ds\\(ss\\)?l\\'" . dsssl-mode)
;; .emacs following a directory delimiter
;; in Unix, MSDOG or VMS syntax.
("[]>:/\\]\\..*emacs\\'" . emacs-lisp-mode)
+ ("\\`.*emacs\\'" . emacs-lisp-mode)
;; _emacs following a directory delimiter
;; in MsDos syntax
("[:/]_emacs\\'" . emacs-lisp-mode)
When checking `inhibit-first-line-modes-regexps', we first discard
from the end of the file name anything that matches one of these regexps.")
-(defvar user-init-file
- "" ; set by command-line
- "File name including directory of user's initialization file.")
+(defvar user-init-file nil
+ "File name, including directory, of user's initialization file.")
(defun set-auto-mode (&optional just-from-file-name)
"Select major mode appropriate for current buffer.
(goto-char (point-min))
(skip-chars-forward " \t\n")
(and enable-local-variables
+ local-enable-local-variables
;; Don't look for -*- if this file name matches any
;; of the regexps in inhibit-first-line-modes-regexps.
(let ((temp inhibit-first-line-modes-regexps)
Defaults are 2 old versions and 2 new.
`dired-kept-versions' controls dired's clean-directory (.) command.
If `delete-old-versions' is nil, system will query user
- before trimming versions. Otherwise it does it silently."
+ before trimming versions. Otherwise it does it silently.
+
+See the subroutine `basic-save-buffer' for more information."
(interactive "p")
(let ((modp (buffer-modified-p))
(large (> (buffer-size) 50000))
(defun basic-save-buffer ()
"Save the current buffer in its visited file, if it has been modified.
-After saving the buffer, run `after-save-hook'."
+The hooks `write-contents-hooks', `local-write-file-hooks' and
+`write-file-hooks' get a chance to do the job of saving; if they do not,
+then the buffer is saved in the visited file file in the usual way.
+After saving the buffer, this function runs `after-save-hook'."
(interactive)
(save-current-buffer
;; In an indirect buffer, save its base buffer instead.