[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
find-file-literally (was: find-file-read-args)
From: |
Juri Linkov |
Subject: |
find-file-literally (was: find-file-read-args) |
Date: |
Mon, 23 Nov 2009 23:17:12 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) |
> So, I like it. But I have some more questions:
>
>> ***************
>> *** 2020,2026 ****
>> In a Lisp program, if you want to be sure of accessing a file's
>> contents literally, you should create a temporary buffer and then read
>> the file contents into it using `insert-file-contents-literally'."
>> ! (interactive "FFind file literally: ")
>> (switch-to-buffer (find-file-noselect filename nil t)))
>>
>> (defvar after-find-file-from-revert-buffer nil)
>> --- 2012,2021 ----
>> In a Lisp program, if you want to be sure of accessing a file's
>> contents literally, you should create a temporary buffer and then read
>> the file contents into it using `insert-file-contents-literally'."
>> ! (interactive
>> ! (list (read-file-name
>> ! "Find file literally: " nil default-directory
>> ! (confirm-nonexistent-file-or-buffer))))
>> (switch-to-buffer (find-file-noselect filename nil t)))
>>
>> (defvar after-find-file-from-revert-buffer nil)
>
> Good change, thank you.
Please note that this change would be unnecessary if following lines
were removed from `read-file-name':
(unless default-filename
(setq default-filename (if initial (expand-file-name initial dir)
buffer-file-name)))
That's because (interactive "FFind file literally: ") calls
`read-file-name' with `default-filename' = nil:
case 'F': /* Possibly nonexistent file name. */
args[i] = Fread_file_name (callint_message,
Qnil, Qnil, Qnil, Qnil, Qnil);
and `read-file-name' sets `default-filename' to `buffer-file-name'.
IMHO, it's dangerous when the user types RET on the directory name
(in the initial input) not expecting that buffer-file-name will be
really used as the default.
Fortunately, there are not many places where that call `read-file-name'
with `default-filename' = nil. Most commands call `read-file-name'
with `default-filename' = default directory.
--
Juri Linkov
http://www.jurta.org/emacs/
- Re: find-file-read-args, (continued)
- Re: find-file-read-args, Juri Linkov, 2009/11/17
- dired-dwim-target-directory (was: find-file-read-args), Juri Linkov, 2009/11/17
- dired-dwim-target-directory (was: find-file-read-args), Juri Linkov, 2009/11/17
- Re: find-file-read-args, Stefan Monnier, 2009/11/22
- Re: find-file-read-args, Juri Linkov, 2009/11/23
- Re: find-file-read-args, Stefan Monnier, 2009/11/23
- Re: find-file-read-args, Juri Linkov, 2009/11/23
- Re: find-file-read-args, Stefan Monnier, 2009/11/23
- Re: find-file-read-args, Juri Linkov, 2009/11/24
- Re: find-file-read-args, Stefan Monnier, 2009/11/24
- find-file-literally (was: find-file-read-args),
Juri Linkov <=
- Re: find-file-literally, Stefan Monnier, 2009/11/24
- M-! M-n should fetch filename (Re: FFAP), Juri Linkov, 2009/11/09
- Re: M-! M-n should fetch filename (Re: FFAP), Stefan Monnier, 2009/11/09
- Re: M-! M-n should fetch filename (Re: FFAP), Juri Linkov, 2009/11/09
- Re: M-! M-n should fetch filename (Re: FFAP), Stefan Monnier, 2009/11/10
- Re: M-! M-n should fetch filename (Re: FFAP), Juri Linkov, 2009/11/10
- dired-dwim-target (was: FFAP), Juri Linkov, 2009/11/15
- dired-dwim-target-defaults (was: dired-dwim-target), Juri Linkov, 2009/11/23
Re: find-file-literally-at-point, Juri Linkov, 2009/11/08