;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Commentary:
This means to guarantee valid names and perhaps to canonicalize
certain patterns.
+FILENAME should be an absolute file name since the conversion rules
+sometimes vary depending on the position in the file name. E.g. c:/foo
+is a valid DOS file name, but c:/bar/c:/foo is not.
+
This function's standard definition is trivial; it just returns
the argument. However, on Windows and DOS, replace invalid
characters. On DOS, make sure to obey the 8.3 limitations. On
the value of `default-directory'."
(unless dir
(setq dir default-directory))
- (read-file-name prompt dir (or default-dirname
+ (read-file-name prompt dir (or default-dirname
(if initial (expand-file-name initial dir)
dir))
mustmatch initial
(defun locate-file-completion (string path-and-suffixes action)
"Do completion for file names passed to `locate-file'.
-PATH-AND-SUFFIXES is a pair of lists (DIRECTORIES . SUFFIXES)."
+PATH-AND-SUFFIXES is a pair of lists, (DIRECTORIES . SUFFIXES)."
(if (file-name-absolute-p string)
(read-file-name-internal string nil action)
(let ((names nil)
(mapc
(lambda (elt)
(cons (purecopy (car elt)) (cdr elt)))
- '(;; do this first, so that .html.pl is Polish html, not Perl
+ `(;; do this first, so that .html.pl is Polish html, not Perl
("\\.s?html?\\(\\.[a-zA-Z_]+\\)?\\'" . html-mode)
("\\.te?xt\\'" . text-mode)
("\\.[tT]e[xX]\\'" . tex-mode)
("\\.ad[abs]\\'" . ada-mode)
("\\.ad[bs].dg\\'" . ada-mode)
("\\.\\([pP]\\([Llm]\\|erl\\|od\\)\\|al\\)\\'" . perl-mode)
- ("\\.mk\\'" . makefile-gmake-mode) ; Might be any make, give Gnu the host advantage
- ("[Mm]akefile\\'" . makefile-mode)
- ("GNUmakefile\\'" . makefile-gmake-mode)
+ ,@(if (memq system-type '(berkeley-unix next-mach darwin))
+ '(("\\.mk\\'" . makefile-bsdmake-mode)
+ ("GNUmakefile\\'" . makefile-gmake-mode)
+ ("[Mm]akefile\\'" . makefile-bsdmake-mode))
+ '(("\\.mk\\'" . makefile-gmake-mode) ; Might be any make, give Gnu the host advantage
+ ("[Mm]akefile\\'" . makefile-gmake-mode)))
("Makeppfile\\'" . makefile-makepp-mode)
("\\.am\\'" . makefile-automake-mode)
;; Less common extensions come here
"Alist mapping interpreter names to major modes.
This is used for files whose first lines match `auto-mode-interpreter-regexp'.
Each element looks like (INTERPRETER . MODE).
-The car of each element is compared with
+The car of each element, a regular expression, is compared with
the name of the interpreter specified in the first line.
If it matches, mode MODE is selected.
(defvar auto-mode-interpreter-regexp
"#![ \t]?\\([^ \t\n]*\
/bin/env[ \t]\\)?\\([^ \t\n]+\\)"
- "Regular expression matching interpreters, for file mode determination.
+ "Regexp matching interpreters, for file mode determination.
This regular expression is matched against the first line of a file
-to determine the file's mode in `set-auto-mode' when Emacs can't deduce
-a mode from the file's name. If it matches, the file is assumed to
-be interpreted by the interpreter matched by the second group of the
-regular expression. The mode is then determined as the mode associated
-with that interpreter in `interpreter-mode-alist'.")
+to determine the file's mode in `set-auto-mode'. If it matches, the file
+is assumed to be interpreted by the interpreter matched by the second group
+of the regular expression. The mode is then determined as the mode
+associated with that interpreter in `interpreter-mode-alist'.")
(defvar magic-mode-alist
`(;; The < comes before the groups (but the first) to reduce backtracking.
(goto-char beg)
end))))
-(defun hack-local-variables-confirm ()
- (or (eq enable-local-variables t)
- (and enable-local-variables
+(defun hack-local-variables-confirm (string flag-to-check)
+ (or (eq flag-to-check t)
+ (and flag-to-check
(save-window-excursion
(condition-case nil
(switch-to-buffer (current-buffer))
(save-excursion
(beginning-of-line)
(set-window-start (selected-window) (point)))
- (y-or-n-p (format "Set local variables as specified in -*- line of %s? "
- (file-name-nondirectory buffer-file-name)))))))
+ (y-or-n-p (format string
+ (if buffer-file-name
+ (file-name-nondirectory buffer-file-name)
+ (concat "buffer " (buffer-name)))))))))
(defun hack-local-variables-prop-line (&optional mode-only)
"Set local variables specified in the -*- line.
(if mode-only mode-specified
(if (and result
(or mode-only
- (hack-local-variables-confirm)))
+ (hack-local-variables-confirm
+ "Set local variables as specified in -*- line of %s? "
+ enable-local-variables)))
(let ((enable-local-eval enable-local-eval))
(while result
(hack-one-local-variable (car (car result)) (cdr (car result)))
(when (let ((case-fold-search t))
(and (search-forward "Local Variables:" nil t)
(or mode-only
- (hack-local-variables-confirm))))
+ (hack-local-variables-confirm
+ "Set local variables as specified at end of %s? "
+ enable-local-variables))))
(skip-chars-forward " \t")
(let ((enable-local-eval enable-local-eval)
;; suffix is what comes after "local variables:" in its line.
(hack-one-local-variable-eval-safep val))
;; Permit eval if not root and user says ok.
(and (not (zerop (user-uid)))
- (hack-local-variables-confirm)))
+ (hack-local-variables-confirm
+ "Process `eval' or hook local variables in %s? "
+ enable-local-eval)))
(if (eq var 'eval)
(save-excursion (eval val))
(make-local-variable var)
(setq truename (file-truename filename))
(if find-file-visit-truename
(setq filename truename))))
+ (if filename
+ (let ((new-name (file-name-nondirectory filename)))
+ (if (string= new-name "")
+ (error "Empty file name"))))
(let ((buffer (and filename (find-buffer-visiting filename))))
(and buffer (not (eq buffer (current-buffer)))
(not no-query)
(setq buffer-file-name filename)
(if filename ; make buffer name reflect filename.
(let ((new-name (file-name-nondirectory buffer-file-name)))
- (if (string= new-name "")
- (error "Empty file name"))
(if (eq system-type 'vax-vms)
(setq new-name (downcase new-name)))
(setq default-directory (file-name-directory buffer-file-name))
(defcustom make-backup-file-name-function nil
"A function to use instead of the default `make-backup-file-name'.
-A value of nil gives the default `make-backup-file-name' behaviour.
+A value of nil gives the default `make-backup-file-name' behavior.
This could be buffer-local to do something special for specific
files. If you define it, you may need to change `backup-file-name-p'
the index in the name where the version number begins."
(if (and (string-match "[0-9]+~$" fn backup-extract-version-start)
(= (match-beginning 0) backup-extract-version-start))
- (string-to-int (substring fn backup-extract-version-start -1))
+ (string-to-number (substring fn backup-extract-version-start -1))
0))
;; I believe there is no need to alter this behavior for VMS;
(while list
(let* ((buffer (car list))
(name (buffer-name buffer)))
- (and (not (string-equal name ""))
+ (and name ; Can be nil for an indirect buffer
+ ; if we killed the base buffer.
+ (not (string-equal name ""))
(/= (aref name 0) ? )
(yes-or-no-p
(format "Buffer %s %s. Kill? "
(if (string-match "ls (.*utils) \\([0-9.]*\\)$" version-out)
(let* ((version (match-string 1 version-out))
(split (split-string version "[.]"))
- (numbers (mapcar 'string-to-int split))
+ (numbers (mapcar 'string-to-number split))
(min '(5 2 1))
comparison)
(while (and (not comparison) (or numbers min))