help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to modify 'write-file'


From: richard.christensen
Subject: Re: How to modify 'write-file'
Date: Tue, 04 May 2010 15:44:29 -0000
User-agent: G2/1.0

Hi Pascal,

I am sorry for being thick.  I have tried several things and have
tried to do some
reading about how to implement this code.  I can't get anything to
work. I can
see what appears to be the correct words on the minibuffer, but upon
hitting enter,
either nothing happens or I get an error about wrong number of
arguments.

Should I be doing this (defun write-file (arg) or should I be creating
a new function?
I see that a list is created but I am sure the write-file does not
want the "Write file:" text
to be part of the operation.  So, some how I need to re-direct the
path and file name from the list
back to the write-function.  Am I missing anything else?

Richard.

On Apr 11, 5:36 pm, p...@informatimago.com (Pascal J. Bourguignon)
wrote:
> "richard.christensen" <richard.christen...@avagotech.com> writes:
> > On Apr 10, 12:00 pm, p...@informatimago.com (Pascal J. Bourguignon)
> > wrote:
> >> "richard.christensen" <richard.christen...@avagotech.com> writes:
> >> > Hi,  I write and modify many files with long names in which I need to
> >> > save the changed file to a similar name as the original but with a few
> >> > letters or numbers changed. A useful modification to write-file would
> >> > be to have the current file name to be placed in the minibuffer along
> >> > with the path when write-file is called. Then modifying the name would
> >> > be simple.  How would I do this?  Ideas?
>
> >> Add the (buffer-name) as initial value to the first call to
> >> read-file-name:
>
> >>   (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)))
> >> --
> >> __Pascal Bourguignon__
>
> > Hi,  I am missing something.  When I C-x w on a buffer, I see no
> > different behavior.  The current path is there but not the buffer
> > name. I did eval-region first.
>
> You have to replace the interactive form in the write-file definition
> and eval-region the write-file defun.
>
> interactive alone doesn't do anything.
>
> --
> __Pascal Bourguignon__



reply via email to

[Prev in Thread] Current Thread [Next in Thread]