;;; files.el --- file input and output commands for Emacs
-;; Copyright (C) 1985, 86, 87, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002
+;; Copyright (C) 1985,86,87,92,93,94,95,96,97,98,99,2000,01,02,03,2004
;;; Free Software Foundation, Inc.
;; Maintainer: FSF
(defcustom delete-auto-save-files t
"*Non-nil means delete auto-save file when a buffer is saved or killed.
-Note that auto-save file will not be deleted if the buffer is killed
+Note that the auto-save file will not be deleted if the buffer is killed
when it has unsaved changes."
:type 'boolean
:group 'auto-save)
;;;It is not useful to make this a local variable.
;;;(put 'find-file-hooks 'permanent-local t)
-(defvar find-file-hook nil
+(defcustom find-file-hook nil
"List of functions to be called after a buffer is loaded from a file.
The buffer's local variables (if any) will have been processed before the
-functions are called.")
+functions are called."
+ :group 'find-file
+ :type 'hook
+ :options '(auto-insert)
+ :version "21.4")
(defvaralias 'find-file-hooks 'find-file-hook)
(make-obsolete-variable 'find-file-hooks 'find-file-hook "21.4")
the visited file name with \\[set-visited-file-name], but not when you
change the major mode.
-See also `write-contents-functions'.")
+This hook is not run if any of the functions in
+`write-contents-functions' returns non-nil. Both hooks pertain
+to how to save a buffer to file, for instance, choosing a suitable
+coding system and setting mode bits. (See Info
+node `(elisp)Saving Buffers'.) To perform various checks or
+updates before the buffer is saved, use `before-save-hook' .")
(put 'write-file-functions 'permanent-local t)
(defvaralias 'write-file-hooks 'write-file-functions)
(make-obsolete-variable 'write-file-hooks 'write-file-functions "21.4")
`set-visited-file-name' does not clear this variable; but changing the
major mode does clear it.
-See also `write-file-functions'.")
+For hooks that _do_ pertain to the particular visited file, use
+`write-file-functions'. Both this variable and
+`write-file-functions' relate to how a buffer is saved to file.
+To perform various checks or updates before the buffer is saved,
+use `before-save-hook'.")
(make-variable-buffer-local 'write-contents-functions)
(defvaralias 'write-contents-hooks 'write-contents-functions)
(make-obsolete-variable 'write-contents-hooks 'write-contents-functions "21.4")
(defun read-directory-name (prompt &optional dir default-dirname mustmatch initial)
"Read directory name, prompting with PROMPT and completing in directory DIR.
Value is not expanded---you must call `expand-file-name' yourself.
-Default name to DEFAULT-DIRNAME if user enters a null string.
+Default name to DEFAULT-DIRNAME if user exits with the same
+non-empty string that was inserted by this function.
(If DEFAULT-DIRNAME is omitted, the current buffer's directory is used,
except that if INITIAL is specified, that combined with DIR is used.)
+If the user exits with an empty minibuffer, this function returns
+an empty string. (This can only happen if the user erased the
+pre-inserted contents or if `insert-default-directory' is nil.)
Fourth arg MUSTMATCH non-nil means require existing directory's name.
Non-nil and non-t means also require confirmation after completion.
Fifth arg INITIAL specifies text to start with.
-DIR defaults to current buffer's directory default."
+DIR should be an absolute directory name. It defaults to
+the value of `default-directory'."
(unless dir
(setq dir default-directory))
(unless default-dirname
(suffix (concat (regexp-opt (cdr path-and-suffixes) t) "\\'"))
(string-dir (file-name-directory string)))
(dolist (dir (car path-and-suffixes))
+ (unless dir
+ (setq dir default-directory))
(if string-dir (setq dir (expand-file-name string-dir dir)))
(when (file-directory-p dir)
(dolist (file (file-name-all-completions
;; PREV-DIRS can be a cons cell whose car is an alist
;; of truenames we've just recently computed.
- ;; The last test looks dubious, maybe `+' is meant here? --simon.
- (if (or (string= filename "") (string= filename "~")
- (and (string= (substring filename 0 1) "~")
- (string-match "~[^/]*" filename)))
- (progn
- (setq filename (expand-file-name filename))
- (if (string= filename "")
- (setq filename "/"))))
+ (cond ((or (string= filename "") (string= filename "~"))
+ (setq filename (expand-file-name filename))
+ (if (string= filename "")
+ (setq filename "/")))
+ ((and (string= (substring filename 0 1) "~")
+ (string-match "~[^/]*/?" filename))
+ (let ((first-part
+ (substring filename 0 (match-end 0)))
+ (rest (substring filename (match-end 0))))
+ (setq filename (concat (expand-file-name first-part) rest)))))
+
(or counter (setq counter (list 100)))
(let (done
;; For speed, remove the ange-ftp completion handler from the list.
default-coding))
(setq from-coding (read-coding-system
(format "Recode filename %s from: " filename))))
-
+
;; We provide the default coding only when a user is going to
;; change the encoding not from the default coding.
(if (eq from-coding default-coding)
This uses the function `display-buffer' as a subroutine; see its
documentation for additional customization information."
(interactive "BSwitch to buffer in other window: ")
- (let ((pop-up-windows t))
+ (let ((pop-up-windows t)
+ ;; Don't let these interfere.
+ same-window-buffer-names same-window-regexps)
(pop-to-buffer buffer t norecord)))
(defun switch-to-buffer-other-frame (buffer &optional norecord)
This uses the function `display-buffer' as a subroutine; see its
documentation for additional customization information."
(interactive "BSwitch to buffer in other frame: ")
- (let ((pop-up-frames t))
+ (let ((pop-up-frames t)
+ same-window-buffer-names same-window-regexps)
(pop-to-buffer buffer t norecord)
(raise-frame (window-frame (selected-window)))))
:type 'boolean)
(defcustom large-file-warning-threshold 10000000
- "Maximum size of file above which a confirmation is requested."
- :type 'integer)
+ "Maximum size of file above which a confirmation is requested.
+When nil, never request confirmation."
+ :group 'files
+ :group 'find-file
+ :type '(choice integer (const :tag "Never request confirmation" nil)))
(defun find-file-noselect (filename &optional nowarn rawfile wildcards)
"Read file FILENAME into a buffer and return the buffer.
(coding-system-for-read 'no-conversion)
(coding-system-for-write 'no-conversion)
(find-buffer-file-type-function
- (if (fboundp 'find-buffer-file-type)
- (symbol-function 'find-buffer-file-type)
- nil))
- (inhibit-file-name-handlers '(jka-compr-handler image-file-handler))
- (inhibit-file-name-operation 'insert-file-contents))
+ (if (fboundp 'find-buffer-file-type)
+ (symbol-function 'find-buffer-file-type)
+ nil))
+ (inhibit-file-name-handlers
+ (append '(jka-compr-handler image-file-handler)
+ inhibit-file-name-handlers))
+ (inhibit-file-name-operation 'insert-file-contents))
(unwind-protect
- (progn
- (fset 'find-buffer-file-type (lambda (filename) t))
- (insert-file-contents filename visit beg end replace))
+ (progn
+ (fset 'find-buffer-file-type (lambda (filename) t))
+ (insert-file-contents filename visit beg end replace))
(if find-buffer-file-type-function
(fset 'find-buffer-file-type find-buffer-file-type-function)
(fmakunbound 'find-buffer-file-type)))))
(setq buffer-read-only nil))
(t
(setq buffer-read-only nil)
- (if (file-exists-p (file-name-directory (directory-file-name (file-name-directory buffer-file-name))))
- "Use M-x make-directory RET RET to create the directory"
- "Use C-u M-x make-directory RET RET to create directory and its parents")))))
+ "Use M-x make-directory RET RET to create the directory and its parents"))))
(when msg
(message "%s" msg)
- (or not-serious (sit-for 1 nil t))))
+ (or not-serious (sit-for 1 t))))
(when (and auto-save-default (not noauto))
(auto-save-mode t)))
;; Make people do a little extra work (C-x C-q)
(ucs-set-table-for-input)))
(defvar auto-mode-alist
+ ;; Note: The entries for the modes defined in cc-mode.el (c-mode,
+ ;; c++-mode, java-mode and more) are added through autoload
+ ;; directives in that file. That way is discouraged since it
+ ;; spreads out the definition of the initial value.
(mapc
(lambda (elt)
(cons (purecopy (car elt)) (cdr elt)))
'(("\\.te?xt\\'" . text-mode)
- ("\\.c\\'" . c-mode)
- ("\\.h\\'" . c-mode)
("\\.tex\\'" . tex-mode)
("\\.ins\\'" . tex-mode) ;Installation files for TeX packages.
("\\.ltx\\'" . latex-mode)
("\\.dtx\\'" . doctex-mode)
("\\.el\\'" . emacs-lisp-mode)
- ("\\.scm\\'" . scheme-mode)
+ ("\\.\\(scm\\|stk\\|ss\\|sch\\)\\'" . scheme-mode)
("\\.l\\'" . lisp-mode)
("\\.lisp\\'" . lisp-mode)
("\\.f\\'" . fortran-mode)
("\\.ad[bs].dg\\'" . ada-mode)
("\\.\\([pP]\\([Llm]\\|erl\\)\\|al\\)\\'" . perl-mode)
("\\.s?html?\\'" . html-mode)
- ("\\.cc\\'" . c++-mode)
- ("\\.hh\\'" . c++-mode)
- ("\\.hpp\\'" . c++-mode)
- ("\\.C\\'" . c++-mode)
- ("\\.H\\'" . c++-mode)
- ("\\.cpp\\'" . c++-mode)
- ("\\.cxx\\'" . c++-mode)
- ("\\.hxx\\'" . c++-mode)
- ("\\.c\\+\\+\\'" . c++-mode)
- ("\\.h\\+\\+\\'" . c++-mode)
- ("\\.m\\'" . objc-mode)
- ("\\.java\\'" . java-mode)
("\\.mk\\'" . makefile-mode)
("\\(M\\|m\\|GNUm\\)akefile\\'" . makefile-mode)
("\\.am\\'" . makefile-mode) ;For Automake.
("\\.me\\'" . nroff-mode)
("\\.ms\\'" . nroff-mode)
("\\.man\\'" . nroff-mode)
- ("\\.\\(u?lpc\\|pike\\|pmod\\)\\'" . pike-mode)
("\\.TeX\\'" . tex-mode)
("\\.sty\\'" . latex-mode)
("\\.cls\\'" . latex-mode) ;LaTeX 2e class
("\\.indent\\.pro\\'" . fundamental-mode) ; to avoid idlwave-mode
("\\.pro\\'" . idlwave-mode)
("\\.lsp\\'" . lisp-mode)
- ("\\.awk\\'" . awk-mode)
("\\.prolog\\'" . prolog-mode)
("\\.tar\\'" . tar-mode)
("\\.\\(arc\\|zip\\|lzh\\|zoo\\|ear\\|jar\\|war\\)\\'" . archive-mode)
("\\.zone\\'" . zone-mode)
;; some news reader is reported to use this
("\\`/tmp/fol/" . text-mode)
- ("\\.y\\'" . c-mode)
- ("\\.lex\\'" . c-mode)
("\\.oak\\'" . scheme-mode)
("\\.sgml?\\'" . sgml-mode)
("\\.xml\\'" . sgml-mode)
("\\.xsl\\'" . sgml-mode)
("\\.dtd\\'" . sgml-mode)
("\\.ds\\(ss\\)?l\\'" . dsssl-mode)
- ("\\.idl\\'" . idl-mode)
;; .emacs or .gnus or .viper following a directory delimiter in
;; Unix, MSDOG or VMS syntax.
("[]>:/\\]\\..*\\(emacs\\|gnus\\|viper\\)\\'" . emacs-lisp-mode)
("\\.[1-9]\\'" . nroff-mode)
("\\.g\\'" . antlr-mode)
("\\.ses\\'" . ses-mode)
+ ("\\.orig\\'" nil t) ; from patch
("\\.in\\'" nil t)))
"Alist of filename patterns vs corresponding major mode functions.
Each element looks like (REGEXP . FUNCTION) or (REGEXP FUNCTION NON-NIL).
(defvar interpreter-mode-alist
+ ;; Note: The entries for the modes defined in cc-mode.el (awk-mode
+ ;; and pike-mode) are added through autoload directives in that
+ ;; file. That way is discouraged since it spreads out the
+ ;; definition of the initial value.
(mapc
(lambda (l)
(cons (purecopy (car l)) (cdr l)))
("wishx" . tcl-mode)
("tcl" . tcl-mode)
("tclsh" . tcl-mode)
- ("awk" . awk-mode)
- ("mawk" . awk-mode)
- ("nawk" . awk-mode)
- ("gawk" . awk-mode)
("scm" . scheme-mode)
("ash" . sh-mode)
("bash" . sh-mode)
(put 'format-alist 'risky-local-variable t)
(put 'vc-mode 'risky-local-variable t)
(put 'imenu-generic-expression 'risky-local-variable t)
-(put 'imenu-index-alist 'risky-local-variable t)
+(put 'imenu--index-alist 'risky-local-variable t)
(put 'standard-input 'risky-local-variable t)
(put 'standard-output 'risky-local-variable t)
(put 'unread-command-events 'risky-local-variable t)
;; This case is safe because the user gets to check it before it is used.
(put 'compile-command 'safe-local-variable 'stringp)
-(defun risky-local-variable-p (sym val)
+(defun risky-local-variable-p (sym &optional val)
"Non-nil if SYM could be dangerous as a file-local variable with value VAL.
-If VAL is nil, the question is whether any value might be dangerous."
+If VAL is nil or omitted, the question is whether any value might be
+dangerous."
(let ((safep (get sym 'safe-local-variable)))
(or (memq sym ignored-local-variables)
(get sym 'risky-local-variable)
(if (eq system-type 'vax-vms)
(setq new-name (downcase new-name)))
(setq default-directory (file-name-directory buffer-file-name))
+ ;; If new-name == old-name, renaming would add a spurious <2>
+ ;; and it's considered as a feature in rename-buffer.
(or (string= new-name (buffer-name))
(rename-buffer new-name t))))
(setq buffer-backed-up nil)
(progn
(setq buffer-file-truename (abbreviate-file-name truename))
(if find-file-visit-truename
- (setq buffer-file-name buffer-file-truename))))
+ (setq buffer-file-name truename))))
(setq buffer-file-number
(if filename
(nthcdr 10 (file-attributes buffer-file-name))
If you specify just a directory name as FILENAME, that means to use
the default file name but in that directory. You can also yank
-the default file name into the minibuffer to edit it, using M-n.
+the default file name into the minibuffer to edit it, using \\<minibuffer-local-map>\\[next-history-element].
If the buffer is not already visiting a file, the default file name
for the output file is the buffer name.
(not (file-writable-p to-name)))
(delete-file to-name))
(copy-file from-name to-name t t)))
- (set-file-modes to-name (logand modes #o1777)))
+ (and modes
+ (set-file-modes to-name (logand modes #o1777))))
(defun file-name-sans-versions (name &optional keep-backup-version)
"Return file NAME sans backup versions or strings.
(or
;; Test for different drives on DOS/Windows
(and
+ ;; Should `cygwin' really be included here? --stef
(memq system-type '(ms-dos cygwin windows-nt))
- (not (string-equal (substring filename 0 2)
- (substring directory 0 2))))
+ (not (eq t (compare-strings filename 0 2 directory 0 2))))
;; Test for different remote file handlers
(not (eq hf hd))
;; Test for different remote file system identification
(string-match re directory)
(substring directory 0 (match-end 0))))))))
filename
- (unless (eq (aref filename 0) ?/)
- (setq filename (concat "/" filename)))
- (unless (eq (aref directory 0) ?/)
- (setq directory (concat "/" directory)))
(let ((ancestor ".")
(filename-dir (file-name-as-directory filename)))
- (while
- (and
- (not (string-match (concat "^" (regexp-quote directory))
- filename-dir))
- (not (string-match (concat "^" (regexp-quote directory))
- filename)))
+ (while (not
+ (or
+ (eq t (compare-strings filename-dir nil (length directory)
+ directory nil nil case-fold-search))
+ (eq t (compare-strings filename nil (length directory)
+ directory nil nil case-fold-search))))
(setq directory (file-name-directory (substring directory 0 -1))
ancestor (if (equal ancestor ".")
".."
(concat "../" ancestor))))
;; Now ancestor is empty, or .., or ../.., etc.
- (if (string-match (concat "^" (regexp-quote directory)) filename)
+ (if (eq t (compare-strings filename nil (length directory)
+ directory nil nil case-fold-search))
;; We matched within FILENAME's directory part.
;; Add the rest of FILENAME onto ANCESTOR.
- (let ((rest (substring filename (match-end 0))))
+ (let ((rest (substring filename (length directory))))
(if (and (equal ancestor ".") (not (equal rest "")))
;; But don't bother with ANCESTOR if it would give us `./'.
rest
(defvar auto-save-hook nil
"Normal hook run just before auto-saving.")
+(defcustom before-save-hook nil
+ "Normal hook that is run before a buffer is saved to its file."
+ :options '(copyright-update)
+ :type 'hook
+ :group 'files)
+
(defcustom after-save-hook nil
"Normal hook that is run after a buffer is saved to its file."
:options '(executable-make-buffer-file-executable-if-script-p)
The hooks `write-contents-functions' and `write-file-functions' 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'."
+Before and after saving the buffer, this function runs
+`before-save-hook' and `after-save-hook', respectively."
(interactive)
(save-current-buffer
;; In an indirect buffer, save its base buffer instead.
(insert ?\n))))
;; Support VC version backups.
(vc-before-save)
+ (run-hooks 'before-save-hook)
(or (run-hook-with-args-until-success 'write-contents-functions)
(run-hook-with-args-until-success 'local-write-file-hooks)
(run-hook-with-args-until-success 'write-file-functions)
;; ordinary or numeric backups. It might create a directory for
;; backups as a side-effect, according to `backup-directory-alist'.
(let* ((filename (file-name-sans-versions
- (make-backup-file-name filename)))
+ (make-backup-file-name (expand-file-name filename))))
(file (file-name-nondirectory filename))
(dir (file-name-directory filename))
(comp (file-name-all-completions file dir))
That is useful when you have visited a file in a nonexistent directory.
Noninteractively, the second (optional) argument PARENTS says whether
-to create parent directories if they don't exist."
+to create parent directories if they don't exist. Interactively,
+this happens by default."
(interactive
(list (read-file-name "Make directory: " default-directory default-directory
nil nil)
The function you specify is responsible for updating (or preserving) point.")
+(defvar buffer-stale-function nil
+ "Function to check whether a non-file buffer needs reverting.
+This should be a function with one optional argument NOCONFIRM.
+Auto Revert Mode sets NOCONFIRM to t. The function should return
+non-nil if the buffer should be reverted. A return value of
+`fast' means that the need for reverting was not checked, but
+that reverting the buffer is fast. The buffer is current when
+this function is called.
+
+The idea behind the NOCONFIRM argument is that it should be
+non-nil if the buffer is going to be reverted without asking the
+user. In such situations, one has to be careful with potentially
+time consuming operations.")
+
(defvar before-revert-hook nil
"Normal hook for `revert-buffer' to run before reverting.
If `revert-buffer-function' is used to override the normal revert
(if auto-save-p 'emacs-mule-unix
(or coding-system-for-read
buffer-file-coding-system))))
- ;; This force
- ;; after-insert-file-set-buffer-file-coding-system
+ ;; This force after-insert-file-set-coding
;; (called from insert-file-contents) to set
;; buffer-file-coding-system to a proper value.
(kill-local-variable 'buffer-file-coding-system)
(let ((buffer-read-only nil)
;; Keep the current buffer-file-coding-system.
(coding-system buffer-file-coding-system)
- ;; Auto-saved file shoule be read without any code conversion.
- (coding-system-for-read 'emacs-mule-unix))
+ ;; Auto-saved file shoule be read with special coding.
+ (coding-system-for-read 'auto-save-coding))
(erase-buffer)
(insert-file-contents file-name nil)
(set-buffer-file-coding-system coding-system))
;; a "visited file name" from that.
(progn
(forward-line 1)
- (setq autofile
- (buffer-substring-no-properties
- (point)
- (save-excursion
- (end-of-line)
- (point))))
- (setq thisfile
- (expand-file-name
- (substring
- (file-name-nondirectory autofile)
- 1 -1)
- (file-name-directory autofile)))
+ ;; If there is no auto-save file name, the
+ ;; auto-save-list file is probably corrupted.
+ (unless (eolp)
+ (setq autofile
+ (buffer-substring-no-properties
+ (point)
+ (save-excursion
+ (end-of-line)
+ (point))))
+ (setq thisfile
+ (expand-file-name
+ (substring
+ (file-name-nondirectory autofile)
+ 1 -1)
+ (file-name-directory autofile))))
(forward-line 1))
;; This pair of lines is a file-visiting
;; buffer. Use the visited file name.
(point) (progn (end-of-line) (point))))
(forward-line 1)))
;; Ignore a file if its auto-save file does not exist now.
- (if (file-exists-p autofile)
+ (if (and autofile (file-exists-p autofile))
(setq files (cons thisfile files)))))
(setq files (nreverse files))
;; The file contains a pair of line for each auto-saved buffer.
(kill-buffer buffer))))
(defun kill-some-buffers (&optional list)
- "For each buffer in LIST, ask whether to kill it.
-LIST defaults to all existing live buffers."
+ "Kill some buffers. Asks the user whether to kill each one of them.
+Non-interactively, if optional argument LIST is non-`nil', it
+specifies the list of buffers to kill, asking for approval for each one."
(interactive)
(if (null list)
(setq list (buffer-list)))
(save-match-data
(with-temp-buffer
(when (and directory-free-space-program
- (zerop (call-process directory-free-space-program
- nil t nil
- directory-free-space-args
- dir)))
+ (eq 0 (call-process directory-free-space-program
+ nil t nil
+ directory-free-space-args
+ dir)))
;; Usual format is a header line followed by a line of
;; numbers.
(goto-char (point-min))
(defun insert-directory (file switches &optional wildcard full-directory-p)
"Insert directory listing for FILE, formatted according to SWITCHES.
Leaves point after the inserted text.
-SWITCHES may be a string of options, or a list of strings.
+SWITCHES may be a string of options, or a list of strings
+representing individual options.
Optional third arg WILDCARD means treat FILE as shell wildcard.
Optional fourth arg FULL-DIRECTORY-P means file is a directory and
switches do not contain `d', so that a full listing is expected.
This works by running a directory listing program
whose name is in the variable `insert-directory-program'.
-If WILDCARD, it also runs the shell specified by `shell-file-name'."
+If WILDCARD, it also runs the shell specified by `shell-file-name'.
+
+When SWITCHES contains the long `--dired' option, this function
+treats it specially, for the sake of dired. However, the
+normally equivalent short `-D' option is just passed on to
+`insert-directory-program', as any other option."
;; We need the directory in order to find the right handler.
(let ((handler (find-file-name-handler (expand-file-name file)
'insert-directory)))
file))))))))
;; If `insert-directory-program' failed, signal an error.
- (if (/= result 0)
- ;; On non-Posix systems, we cannot open a directory, so
- ;; don't even try, because that will always result in
- ;; the ubiquitous "Access denied". Instead, show the
- ;; command line so the user can try to guess what went wrong.
- (if (and (file-directory-p file)
- (memq system-type '(ms-dos windows-nt)))
- (error
- "Reading directory: \"%s %s -- %s\" exited with status %s"
- insert-directory-program
- (if (listp switches) (concat switches) switches)
- file result)
- ;; Unix. Access the file to get a suitable error.
- (access-file file "Reading directory")
- (error "Listing directory failed but `access-file' worked")))
-
- (when (string-match "--dired\\>" switches)
+ (unless (eq 0 result)
+ ;; Delete the error message it may have output.
+ (delete-region beg (point))
+ ;; On non-Posix systems, we cannot open a directory, so
+ ;; don't even try, because that will always result in
+ ;; the ubiquitous "Access denied". Instead, show the
+ ;; command line so the user can try to guess what went wrong.
+ (if (and (file-directory-p file)
+ (memq system-type '(ms-dos windows-nt)))
+ (error
+ "Reading directory: \"%s %s -- %s\" exited with status %s"
+ insert-directory-program
+ (if (listp switches) (concat switches) switches)
+ file result)
+ ;; Unix. Access the file to get a suitable error.
+ (access-file file "Reading directory")
+ (error "Listing directory failed but `access-file' worked")))
+
+ (when (if (stringp switches)
+ (string-match "--dired\\>" switches)
+ (member "--dired" switches))
(forward-line -2)
(when (looking-at "//SUBDIRED//")
(delete-region (point) (progn (forward-line 1) (point)))
file-name-coding-system
default-file-name-coding-system
'undecided))
+ coding-no-eol
val pos)
(when (and enable-multibyte-characters
(not (memq (coding-system-base coding)
(setq coding (detect-coding-region beg (point) t)))
(if (not (eq (coding-system-base coding) 'undecided))
(save-restriction
+ (setq coding-no-eol
+ (coding-system-change-eol-conversion coding 'unix))
(narrow-to-region beg (point))
(goto-char (point-min))
(while (not (eobp))
val (get-text-property (point) 'dired-filename))
(goto-char (next-single-property-change
(point) 'dired-filename nil (point-max)))
- (decode-coding-region pos (point) coding)
+ ;; Force no eol conversion on a file name, so
+ ;; that CR is preserved.
+ (decode-coding-region pos (point)
+ (if val coding-no-eol coding))
(if val
(put-text-property pos (point)
'dired-filename t)))))))
(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
;;; files.el ends here