Commit 912192d1 authored by Kenichi Handa's avatar Kenichi Handa
Browse files

(find-file): Delete the facility of handling a prefix

argument.
(find-file-other-window, find-file-read-only): Likewise.
(find-file-read-only-other-window): Likewise.
(find-file-read-only-other-frame): Likewise.
(find-alternate-file-other-window, find-alternate-file): Likewise.
(write-file, insert-file, append-to-file): Likewise.
parent adfb70a1
......@@ -573,73 +573,57 @@ do not put this buffer at the front of the list of recently selected ones."
(pop-to-buffer buffer t norecord)
(raise-frame (window-frame (selected-window)))))
(defun find-file (filename &optional coding-system)
(defun find-file (filename)
"Edit file FILENAME.
Switch to a buffer visiting file FILENAME,
creating one if none already exists.
A prefix argument enables user to specify the coding-system interactively."
(interactive "FFind file: \nZCoding-system: ")
(if coding-system
(let ((coding-system-for-read coding-system))
(switch-to-buffer (find-file-noselect filename)))
(switch-to-buffer (find-file-noselect filename))))
creating one if none already exists."
(interactive "FFind file: ")
(switch-to-buffer (find-file-noselect filename)))
(defun find-file-other-window (filename &optional coding-system)
(defun find-file-other-window (filename)
"Edit file FILENAME, in another window.
May create a new window, or reuse an existing one.
A prefix argument enables user to specify the coding-system interactively.
See the function `display-buffer'."
(interactive "FFind file in other window: \nZCoding-system: ")
(if coding-system
(let ((coding-system-for-read coding-system))
(switch-to-buffer-other-window (find-file-noselect filename)))
(switch-to-buffer-other-window (find-file-noselect filename))))
(interactive "FFind file in other window: ")
(switch-to-buffer-other-window (find-file-noselect filename)))
(defun find-file-other-frame (filename &optional coding-system)
(defun find-file-other-frame (filename)
"Edit file FILENAME, in another frame.
May create a new frame, or reuse an existing one.
A prefix argument enables user to specify the coding-system interactively.
See the function `display-buffer'."
(interactive "FFind file in other frame: \nZCoding-system: ")
(if coding-system
(let ((coding-system-for-read coding-system))
(switch-to-buffer-other-frame (find-file-noselect filename)))
(switch-to-buffer-other-frame (find-file-noselect filename))))
(interactive "FFind file in other frame: ")
(switch-to-buffer-other-frame (find-file-noselect filename)))
(defun find-file-read-only (filename &optional coding-system)
(defun find-file-read-only (filename)
"Edit file FILENAME but don't allow changes.
Like \\[find-file] but marks buffer as read-only.
A prefix argument enables user to specify the coding-system interactively.
Use \\[toggle-read-only] to permit editing."
(interactive "fFind file read-only: \nZCoding-system: ")
(find-file filename coding-system)
(interactive "fFind file read-only: ")
(find-file filename)
(setq buffer-read-only t)
(current-buffer))
(defun find-file-read-only-other-window (filename &optional coding-system)
(defun find-file-read-only-other-window (filename)
"Edit file FILENAME in another window but don't allow changes.
Like \\[find-file-other-window] but marks buffer as read-only.
A prefix argument enables user to specify the coding-system interactively.
Use \\[toggle-read-only] to permit editing."
(interactive "fFind file read-only other window: \nZCoding-system: ")
(find-file-other-window filename coding-system)
(interactive "fFind file read-only other window: ")
(find-file-other-window filename)
(setq buffer-read-only t)
(current-buffer))
(defun find-file-read-only-other-frame (filename &optional coding-system)
(defun find-file-read-only-other-frame (filename)
"Edit file FILENAME in another frame but don't allow changes.
Like \\[find-file-other-frame] but marks buffer as read-only.
A prefix argument enables user to specify the coding-system interactively.
Use \\[toggle-read-only] to permit editing."
(interactive "fFind file read-only other frame: \nZCoding-system: ")
(find-file-other-frame filename coding-system)
(interactive "fFind file read-only other frame: ")
(find-file-other-frame filename)
(setq buffer-read-only t)
(current-buffer))
(defun find-alternate-file-other-window (filename &optional coding-system)
(defun find-alternate-file-other-window (filename)
"Find file FILENAME as a replacement for the file in the next window.
This command does not select that window.
A prefix argument enables user to specify the coding-system interactively."
This command does not select that window."
(interactive
(save-selected-window
(other-window 1)
......@@ -650,20 +634,17 @@ A prefix argument enables user to specify the coding-system interactively."
(setq file-name (file-name-nondirectory file)
file-dir (file-name-directory file)))
(list (read-file-name
"Find alternate file: " file-dir nil nil file-name)
(if current-prefix-arg
(read-coding-system "Coding-system: "))))))
"Find alternate file: " file-dir nil nil file-name)))))
(if (one-window-p)
(find-file-other-window filename coding-system)
(find-file-other-window filename)
(save-selected-window
(other-window 1)
(find-alternate-file filename coding-system))))
(find-alternate-file filename))))
(defun find-alternate-file (filename &optional coding-system)
(defun find-alternate-file (filename)
"Find file FILENAME, select its buffer, kill previous buffer.
If the current buffer now contains an empty file that you just visited
\(presumably by mistake), use this command to visit the file you really want.
A prefix argument enables user to specify the coding-system interactively."
\(presumably by mistake), use this command to visit the file you really want."
(interactive
(let ((file buffer-file-name)
(file-name nil)
......@@ -672,9 +653,7 @@ A prefix argument enables user to specify the coding-system interactively."
(setq file-name (file-name-nondirectory file)
file-dir (file-name-directory file)))
(list (read-file-name
"Find alternate file: " file-dir nil nil file-name)
(if current-prefix-arg
(read-coding-system "Coding-system: ")))))
"Find alternate file: " file-dir nil nil file-name))))
(and (buffer-modified-p) (buffer-file-name)
;; (not buffer-read-only)
(not (yes-or-no-p (format "Buffer %s is modified; kill anyway? "
......@@ -694,7 +673,7 @@ A prefix argument enables user to specify the coding-system interactively."
(setq buffer-file-name nil)
(setq buffer-file-number nil)
(setq buffer-file-truename nil)
(find-file filename coding-system))
(find-file filename))
(cond ((eq obuf (current-buffer))
(setq buffer-file-name ofile)
(setq buffer-file-number onum)
......@@ -1683,7 +1662,7 @@ the old visited file has been renamed to the new name FILENAME."
(set-auto-mode t))
(error nil)))
(defun write-file (filename &optional confirm coding-system)
(defun write-file (filename &optional confirm)
"Write current buffer into file FILENAME.
Makes buffer visit that file, and marks it not modified.
If the buffer is already visiting a file, you can specify
......@@ -1692,10 +1671,7 @@ old name in that directory.
If optional second arg CONFIRM is non-nil,
ask for confirmation for overwriting an existing file.
Interactively, confirmation is required unless you supply a prefix argument.
A prefix argument also enables user to interactively specify a
coding-system for encoding the file."
Interactively, confirmation is required unless you supply a prefix argument."
;; (interactive "FWrite file: ")
(interactive
(list (if buffer-file-name
......@@ -1705,10 +1681,7 @@ coding-system for encoding the file."
(cdr (assq 'default-directory
(buffer-local-variables)))
nil nil (buffer-name)))
(not current-prefix-arg)
(if current-prefix-arg
(read-coding-system "Coding-system: "))
))
(not current-prefix-arg)))
(or (null filename) (string-equal filename "")
(progn
;; If arg is just a directory,
......@@ -1722,13 +1695,7 @@ coding-system for encoding the file."
(error "Canceled")))
(set-visited-file-name filename (not confirm))))
(set-buffer-modified-p t)
(if coding-system
(let ((coding-system-for-write coding-system))
;; It is convenient to change buffer-file-coding-system to the
;; specified one.
(set-buffer-file-coding-system coding-system)
(save-buffer))
(save-buffer)))
(save-buffer))
(defun backup-buffer ()
"Make a backup of the disk file visited by the current buffer, if appropriate.
......@@ -2271,36 +2238,28 @@ With arg, set read-only iff arg is positive."
(> (prefix-numeric-value arg) 0)))
(force-mode-line-update))
(defun insert-file (filename &optional coding-system)
(defun insert-file (filename)
"Insert contents of file FILENAME into buffer after point.
Set mark after the inserted text.
A prefix argument enables user to specify the coding-system interactively.
This function is meant for the user to run interactively.
Don't call it from programs! Use `insert-file-contents' instead.
\(Its calling sequence is different; see its documentation)."
(interactive "*fInsert file: \nZCoding-system: ")
(interactive "*fInsert file: ")
(if (file-directory-p filename)
(signal 'file-error (list "Opening input file" "file is a directory"
filename)))
(let ((tem
(if coding-system
(let ((coding-system-for-read coding-system))
(insert-file-contents filename))
(insert-file-contents filename))))
(let ((tem (insert-file-contents filename)))
(push-mark (+ (point) (car (cdr tem))))))
(defun append-to-file (start end filename &optional coding-system)
(defun append-to-file (start end filename)
"Append the contents of the region to the end of file FILENAME.
When called from a function, expects three arguments,
START, END and FILENAME. START and END are buffer positions
saying what text to write.
A prefix argument enables user to specify the coding-system interactively."
(interactive "r\nFAppend to file: \nZCoding-system: ")
(if coding-system
(let ((coding-system-for-write coding-system))
(write-region start end filename t))
(write-region start end filename t)))
(interactive "r\nFAppend to file: ")
(write-region start end filename t))
(defun file-newest-backup (filename)
"Return most recent backup file for FILENAME or nil if no backups exist."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment