specified in a -*- line.")
(defcustom enable-local-eval 'maybe
- "*Control processing of the \"variable\" `eval' in a file's local variables.
+ "Control processing of the \"variable\" `eval' in a file's local variables.
The value can be t, nil or something else.
A value of t means obey `eval' variables;
nil means ignore them; anything else means query."
(string-match "^[a-zA-`]:/$" filename)))))
(setq filename
(concat "~"
- (substring filename (match-beginning 1) (match-end 1))
+ (match-string 1 filename)
(substring filename (match-end 0)))))
filename))
;; hexl-mode.
(not (eq major-mode 'hexl-mode)))
(if (buffer-modified-p)
- (if (y-or-n-p (if rawfile
- "Save file and revisit literally? "
- "Save file and revisit non-literally? "))
+ (if (y-or-n-p
+ (format
+ (if rawfile
+ "The file %s is already visited normally,
+and you have edited the buffer. Now you have asked to visit it literally,
+meaning no coding system handling, format conversion, or local variables.
+Emacs can only visit a file in one way at a time.
+
+Do you want to save the file, and visit it literally instead? "
+ "The file %s is already visited literally,
+meaning no coding system handling, format conversion, or local variables.
+You have edited the buffer. Now you have asked to visit the file normally,
+but Emacs can only visit a file in one way at a time.
+
+Do you want to save the file, and visit it normally instead? ")
+ (file-name-nondirectory filename)))
(progn
(save-buffer)
(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? "))
+ (if (y-or-n-p
+ (format
+ (if rawfile
+ "\
+Do you want to discard your changes, and visit the file literally now? "
+ "\
+Do you want to discard your changes, and visit the file normally now? ")))
(find-file-noselect-1 buf filename nowarn
rawfile truename number)
(error (if rawfile "File already visited non-literally"
"File already visited literally"))))
- (if (y-or-n-p (if rawfile
- "Revisit file literally? "
- "Revisit file non-literally? "))
+ (if (y-or-n-p
+ (format
+ (if rawfile
+ "The file %s is already visited normally.
+You have asked to visit it literally,
+meaning no coding system decoding, format conversion, or local variables.
+But Emacs can only visit a file in one way at a time.
+
+Do you want to revisit the file literally now? "
+ "The file %s is already visited literally,
+meaning no coding system decoding, format conversion, or local variables.
+You have asked to visit it normally,
+but Emacs can only visit a file in one way at a time.
+
+Do you want to revisit the file normally now? ")
+ (file-name-nondirectory filename)))
(find-file-noselect-1 buf filename nowarn
rawfile truename number)
(error (if rawfile "File already visited non-literally"
(kill-buffer buf)
(signal 'file-error (list "File is not readable"
filename)))
- ;; Run find-file-not-found-hooks until one returns non-nil.
+ ;; Run find-file-not-found-functions until one returns non-nil.
(or (run-hook-with-args-until-success 'find-file-not-found-functions)
;; If they fail too, set error.
(setq error t)))))
(not (member logical find-file-not-true-dirname-list)))
(setq buffer-file-name buffer-file-truename))
(if find-file-visit-truename
- (setq buffer-file-name
- (setq filename
- (expand-file-name buffer-file-truename))))
+ (setq buffer-file-name (expand-file-name buffer-file-truename)))
;; Set buffer's default directory to that of the file.
(setq default-directory (file-name-directory buffer-file-name))
;; Turn off backup files for certain file names. Since
(insert " ")))
(princ (car elt) buf)
(insert " : ")
- (if (stringp (cdr elt))
- ;; Make strings with embedded whitespace easier to read.
- (let ((print-escape-newlines t))
- (prin1 (cdr elt) buf))
- (princ (cdr elt) buf))
+ ;; Make strings with embedded whitespace easier to read.
+ (let ((print-escape-newlines t))
+ (prin1 (cdr elt) buf))
(insert "\n"))
(setq prompt
(format "Please type %s%s: "
;; There used to be a downcase here,
;; but the manual didn't say so,
;; and people want to set var names that aren't all lc.
- (let ((key (intern (buffer-substring
- (match-beginning 1)
- (match-end 1))))
+ (let ((key (intern (match-string 1)))
(val (save-restriction
(narrow-to-region (point) end)
(read (current-buffer)))))
(hack-local-variables-confirm
result unsafe-vars risky-vars))
(dolist (elt result)
- (hack-one-local-variable (car elt) (cdr elt))))))
- (run-hooks 'hack-local-variables-hook))))))
+ (hack-one-local-variable (car elt) (cdr elt)))))))
+ (run-hooks 'hack-local-variables-hook)))))
(defun safe-local-variable-p (sym val)
"Non-nil if SYM is safe as a file-local variable with value VAL.
(defun hack-one-local-variable (var val)
"Set local variable VAR with value VAL."
(cond ((eq var 'mode)
- (funcall (intern (concat (downcase (symbol-name val))
- "-mode"))))
+ (funcall (intern (concat (downcase (symbol-name val)) "-mode"))))
((eq var 'eval)
(save-excursion (eval val)))
- (t (make-local-variable var)
- ;; Make sure the string has no text properties.
- ;; Some text properties can get evaluated in various ways,
- ;; so it is risky to put them on with a local variable list.
- (if (stringp val)
- (set-text-properties 0 (length val) nil val))
- (set var val))))
+ (t
+ ;; Make sure the string has no text properties.
+ ;; Some text properties can get evaluated in various ways,
+ ;; so it is risky to put them on with a local variable list.
+ (if (stringp val)
+ (set-text-properties 0 (length val) nil val))
+ (set (make-local-variable var) val))))
\f
(defcustom change-major-mode-with-file-name t
(set-visited-file-modtime old-modtime)))
;; Since we have created an entirely new file,
;; make sure it gets the right permission bits set.
- (setq setmodes (or setmodes (cons (file-modes buffer-file-name)
- buffer-file-name)))
+ (setq setmodes (or setmodes
+ (cons (or (file-modes buffer-file-name)
+ (logand ?\666 umask))
+ buffer-file-name)))
;; We succeeded in writing the temp file,
;; so rename it.
(rename-file tempname buffer-file-name t))
(setq autofile
(buffer-substring-no-properties
(point)
- (save-excursion
- (end-of-line)
- (point))))
+ (line-end-position)))
(setq thisfile
(expand-file-name
(substring