[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to modify 'write-file'
From: |
Kevin Rodgers |
Subject: |
Re: How to modify 'write-file' |
Date: |
Thu, 06 May 2010 18:02:38 -0600 |
User-agent: |
Thunderbird 2.0.0.24 (Macintosh/20100228) |
Pascal J. Bourguignon wrote:
...
Sorry, I assumed you were already a seasoned emacs lisp programmer.
Here are detailed instructions:
1- Find the sources of write-file, type:
C-h f write-file RET C-x o TAB RET
2- Copy and paste the defun write-file form to the *scratch* buffer:
C-SPC C-M-f M-w C-x b *scratch* RET RET C-y C-M-b
You get this in the *scratch* buffer:
...
3- Replace the interactive form in this defun by the one I provided:
(interactive
(list (if buffer-file-name
(read-file-name "Write file: " default-directory
(expand-file-name
(file-name-nondirectory (buffer-name))
default-directory)
nil
(buffer-name))
(read-file-name "Write file: " default-directory
(expand-file-name
(file-name-nondirectory (buffer-name))
default-directory)
nil nil))
(not current-prefix-arg)))
so that you get:
...
4- Evaluate this defun, for example positionning the cursor after it,
and typing C-x C-e.
5- Use the new write-file.
If you want to keep this version of write-file, you can copy-and-paste
it into your ~/.emacs file.
(defadvice write-file (before interactive-default activate)
"Insert the default in the minibuffer when reading FILENAME."
(interactive
(let ((default-filename (or buffer-file-name
(expand-file-name
(file-name-nondirectory (buffer-name))
default-directory))))
(list (read-file-name "Write file: "
default-directory default-filename nil
(file-name-nondirectory default-filename) nil)
(not current-prefix-arg)))))
--
Kevin Rodgers
Denver, Colorado, USA
- How to modify 'write-file', richard.christensen, 2010/05/04
- Re: How to modify 'write-file', Pascal J. Bourguignon, 2010/05/04
- Re: How to modify 'write-file', richard.christensen, 2010/05/04
- Re: How to modify 'write-file', richard.christensen, 2010/05/04
- Re: How to modify 'write-file', Pascal J. Bourguignon, 2010/05/04
- Re: How to modify 'write-file', richard.christensen, 2010/05/04
- Re: How to modify 'write-file', Pascal J. Bourguignon, 2010/05/04
- Re: How to modify 'write-file', richard.christensen, 2010/05/04
- Re: How to modify 'write-file',
Kevin Rodgers <=
- Re: How to modify 'write-file', Thierry Volpiatto, 2010/05/07
Re: How to modify 'write-file', Andreas Politz, 2010/05/04