• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/emacs-93/emacs/lisp/

Lines Matching +defs:file +defs:name

9 ;; This file is part of GNU Emacs.
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
37 (cons 'file-name-history minibuffer-history-case-insensitive-variables))
42 ;; For distinguishing file types based upon suffixes.
43 (defvar file-name-buffer-file-type-alist
58 ("[:/]tags$" . nil) ; emacs TAGS file
62 against the file name, and TYPE is nil for text, t for binary.")
64 ;; Return the pair matching filename on file-name-buffer-file-type-alist,
66 (defun find-buffer-file-type-match (filename)
67 (let ((alist file-name-buffer-file-type-alist)
70 (setq filename (file-name-sans-versions filename))
78 (defvar default-buffer-file-type)
80 ;; Don't check for untranslated file systems here.
81 (defun find-buffer-file-type (filename)
82 (let ((match (find-buffer-file-type-match filename))
85 default-buffer-file-type
91 (setq-default buffer-file-coding-system 'undecided-dos)
93 (defun find-buffer-file-type-coding-system (command)
94 "Choose a coding system for a file operation in COMMAND.
97 If operation is `insert-file-contents', the coding system is chosen based
99 of `untranslated-filesystem-list' and `file-name-buffer-file-type-alist',
100 and whether the file exists:
103 If the file exists: `undecided'
104 If the file does not exist: `undecided-unix'
105 If it matches in `file-name-buffer-file-type-alist':
109 If the file exists: `undecided'
110 If the file does not exist: default-buffer-file-coding-system
112 Note that the CAR of arguments to `insert-file-contents' operation could
114 into which the file's contents were already read, but not yet decoded.
117 the value of `buffer-file-coding-system' and `buffer-file-type'. If
118 `buffer-file-coding-system' is non-nil, its value is used. If it is
119 nil and `buffer-file-type' is t, the coding system is `no-conversion'.
124 `untranslated-filesystem-list' and `file-name-buffer-file-type-alist'.
126 the file is read in the DOS case, the coding system will be changed to
127 `undecided-dos' as CR/LFs are detected. As the file is read in the
129 LFs are detected. In both cases, `buffer-file-coding-system' will be
131 `buffer-file-coding-system' will be used when writing the file."
137 (cond ((eq op 'insert-file-contents)
140 ;; where BUFFER is a buffer into which the file was already read,
143 ;; doesn't care about the contents, it only looks at the file's
144 ;; name, which is the CAR of the cons cell.
146 ;; First check for a file name that indicates
148 (setq binary (find-buffer-file-type target))
151 ((find-buffer-file-type-match target)
153 ;; For any other existing file, decide based on contents.
154 ((file-exists-p target)
156 ;; Next check for a non-DOS file system.
157 ((untranslated-file-p target)
163 (t (cons default-buffer-file-coding-system
164 default-buffer-file-coding-system))))
166 (if buffer-file-coding-system
167 (cons buffer-file-coding-system
168 buffer-file-coding-system)
169 ;; Normally this is used only in a non-file-visiting
170 ;; buffer, because normally buffer-file-coding-system is non-nil
171 ;; in a file-visiting buffer.
172 (if buffer-file-type
176 (modify-coding-system-alist 'file "" 'find-buffer-file-type-coding-system)
178 (defun find-file-binary (filename)
179 "Visit file FILENAME and treat it as binary."
180 (interactive "FFind file binary: ")
181 (let ((file-name-buffer-file-type-alist '(("" . t))))
182 (find-file filename)))
184 (defun find-file-text (filename)
185 "Visit file FILENAME and treat it as a text file."
186 (interactive "FFind file text: ")
187 (let ((file-name-buffer-file-type-alist '(("" . nil))))
188 (find-file filename)))
190 (defun find-file-not-found-set-buffer-file-coding-system ()
193 (let ((coding buffer-file-coding-system))
194 ;; buffer-file-coding-system is already set by
196 ;; insert-file-contents. All that's left is to change
200 (untranslated-file-p (buffer-file-name))))
202 (setq buffer-file-coding-system coding))
203 (setq buffer-file-type (eq buffer-file-coding-system 'no-conversion)))))
206 (add-hook 'find-file-not-found-functions
207 'find-file-not-found-set-buffer-file-coding-system)
215 (defun untranslated-canonical-name (filename)
221 (let ((name nil))
222 (setq name (mapconcat
228 ;; Use expand-file-name to canonicalize directory separators, except
232 (if (or (string-match "^.:$" name)
233 (string-match "^/[^/:]+:" name))
234 name
235 (expand-file-name name)))
238 (defun untranslated-file-p (filename)
241 (let ((fs (untranslated-canonical-name filename))
256 ;; with a directory, but RET returns the current buffer's file, not
258 (interactive "DUntranslated file system: ")
259 (let ((fs (untranslated-canonical-name filesystem)))
270 (interactive "fUntranslated file system: ")
272 (delete (untranslated-canonical-name filesystem)
289 ;; Convert / to \ in printer name, for sake of external programs.
297 (while (not (file-attributes (car safe-dirs)))
303 (make-temp-name
304 (expand-file-name "EP" temporary-file-directory))))
307 ;; It seems that we must be careful about the directory name that
308 ;; gets added to the printer port name by write-region when using
311 ;; asking command.com to copy the file.
313 ;; because `expand-file-name' doesn't support UNC names on MS-DOS.
316 (subst-char-in-string ?/ ?\\ (expand-file-name printer safe-dir))))
321 ((string-match "^nprint\\(\\.exe\\)?$" (file-name-nondirectory lpr-prog))
326 ((string-match "^print\\(\\.exe\\)?$" (file-name-nondirectory lpr-prog))
350 ;; we are supposed to append to an existing (non-empty) file,
357 ;; file-attributes fails on LPT ports on Windows 9x but
359 (eq (or (nth 7 (file-attributes printer)) 0) 0))
368 (if (file-exists-p tempfile)
369 (delete-file tempfile)))))
371 (defvar printer-name)
378 Writes the region to the device or file which is a value of
379 `printer-name' \(which see\), unless the value of `lpr-command'
389 ;; paper if the file ends with a form-feed already.
399 printer-name
400 (default-printer-name))))
419 (defvar ps-printer-name)
426 Writes the region to the device or file which is a value of
427 `ps-printer-name' \(which see\), unless the value of `ps-lpr-command'
433 ps-printer-name
434 (default-printer-name))))