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))
- (unless default-dirname
- (setq default-dirname
- (if initial (concat dir initial) 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)
((null action) (try-completion string names))
(t (test-completion string names))))))
+(defun executable-find (command)
+ "Search for COMMAND in `exec-path' and return the absolute file name.
+Return nil if COMMAND is not found anywhere in `exec-path'."
+ ;; Use 1 rather than file-executable-p to better match the behavior of
+ ;; call-process.
+ (locate-file command exec-path exec-suffixes 1))
+
(defun load-library (library)
"Load the library named LIBRARY.
This is an interface to the function `load'."
in that case, this function acts as if `enable-local-variables' were t."
(interactive)
(or find-file (funcall (or default-major-mode 'fundamental-mode)))
- (report-errors "File mode specification error: %s"
- (set-auto-mode))
- (report-errors "File local-variables error: %s"
- (let ((enable-local-variables (or (not find-file) enable-local-variables)))
+ (let ((enable-local-variables (or (not find-file) enable-local-variables)))
+ (report-errors "File mode specification error: %s"
+ (set-auto-mode))
+ (report-errors "File local-variables error: %s"
(hack-local-variables)))
(if (fboundp 'ucs-set-table-for-input) ; don't lose when building
(ucs-set-table-for-input)))
(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-mode)
- ("\\([Mm]\\|GNUm\\)akep*file\\'" . makefile-mode)
- ("\\.am\\'" . makefile-mode) ;For Automake.
+ ,@(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
;; so more common ones above are found faster.
("\\.texinfo\\'" . texinfo-mode)
("more" . text-mode)
("less" . text-mode)
("pg" . text-mode)
- ("make" . makefile-mode) ; Debian uses this
+ ("make" . makefile-gmake-mode) ; Debian uses this
("guile" . scheme-mode)
("clisp" . lisp-mode)))
"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.
to decide the buffer's major mode.
If FUNCTION is nil, then it is not called. (That is a way of saying
-\"allow `auto-mode-alist' to decide for these files.")
+\"allow `auto-mode-alist' to decide for these files.)")
(defun set-auto-mode (&optional keep-mode-if-same)
"Select major mode appropriate for current buffer.
(goto-char beg)
end))))
+(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))
+ (error
+ ;; If we fail to switch in the selected window,
+ ;; it is probably a minibuffer or dedicated window.
+ ;; So try another window.
+ (let ((pop-up-frames nil))
+ ;; Refrain from popping up frames since it can't
+ ;; be undone by save-window-excursion.
+ (pop-to-buffer (current-buffer)))))
+ (save-excursion
+ (beginning-of-line)
+ (set-window-start (selected-window) (point)))
+ (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.
Ignore any specification for `mode:' and `coding:';
(if mode-only mode-specified
(if (and result
(or mode-only
- (eq enable-local-variables t)
- (and enable-local-variables
- (save-window-excursion
- (condition-case nil
- (switch-to-buffer (current-buffer))
- (error
- ;; If we fail to switch in the selected window,
- ;; it is probably a minibuffer.
- ;; So try another window.
- (condition-case nil
- (switch-to-buffer-other-window (current-buffer))
- (error
- (switch-to-buffer-other-frame (current-buffer))))))
- (y-or-n-p (format "Set local variables as specified in -*- line of %s? "
- (file-name-nondirectory buffer-file-name)))))))
+ (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)))
(search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move)
(when (let ((case-fold-search t))
(and (search-forward "Local Variables:" nil t)
- (or (eq enable-local-variables t)
- mode-only
- (and enable-local-variables
- (save-window-excursion
- (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 at end of %s? "
- (if buffer-file-name
- (file-name-nondirectory
- buffer-file-name)
- (concat "buffer "
- (buffer-name))))))))))
+ (or mode-only
+ (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)))
- (or (eq enable-local-eval t)
- (and enable-local-eval
- (save-window-excursion
- (switch-to-buffer (current-buffer))
- (save-excursion
- (beginning-of-line)
- (set-window-start (selected-window) (point)))
- (setq enable-local-eval
- (y-or-n-p (format "Process `eval' or hook local variables in %s? "
- (if buffer-file-name
- (concat "file " (file-name-nondirectory buffer-file-name))
- (concat "buffer " (buffer-name)))))))))))
+ (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)
(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;
(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))
(define-key ctl-x-5-map "\C-f" 'find-file-other-frame)
(define-key ctl-x-5-map "r" 'find-file-read-only-other-frame)
-;;; arch-tag: bc68d3ea-19ca-468b-aac6-3a4a7766101f
+;; arch-tag: bc68d3ea-19ca-468b-aac6-3a4a7766101f
;;; files.el ends here