From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: How to modify 'write-file'
Date: Fri, 07 May 2010 07:30:55 +0200 [thread overview]
Message-ID: <87bpcs8ei8.fsf@tux.homenetwork> (raw)
In-Reply-To: hrvlan$1b2$1@dough.gmane.org
Kevin Rodgers <kevin.d.rodgers@gmail.com> writes:
> 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)))))
See also `anything-write-file' that is included in anything-config.el.
--
Thierry Volpiatto
Gpg key: http://pgp.mit.edu/
next prev parent reply other threads:[~2010-05-07 5:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-10 17:17 How to modify 'write-file' richard.christensen
2010-04-10 18:00 ` Pascal J. Bourguignon
2010-04-11 18:16 ` richard.christensen
2010-04-11 23:29 ` richard.christensen
2010-04-11 23:36 ` Pascal J. Bourguignon
2010-04-13 14:43 ` richard.christensen
2010-04-14 0:37 ` Pascal J. Bourguignon
2010-04-14 23:35 ` richard.christensen
2010-05-07 0:02 ` Kevin Rodgers
2010-05-07 5:30 ` Thierry Volpiatto [this message]
2010-04-10 18:19 ` Andreas Politz
2010-04-11 18:17 ` richard.christensen
2010-04-11 22:43 ` Andreas Politz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bpcs8ei8.fsf@tux.homenetwork \
--to=thierry.volpiatto@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).