From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "richard.christensen" Newsgroups: gmane.emacs.help Subject: Re: How to modify 'write-file' Date: Tue, 13 Apr 2010 07:43:40 -0700 (PDT) Organization: http://groups.google.com Message-ID: <9345ad4d-220c-4319-9e2f-d5acfa340d27@35g2000yqm.googlegroups.com> References: <87ochrgpbd.fsf@galatea.lan.informatimago.com> <9f65fba7-3fba-40b6-ad86-75aa4f336b91@g11g2000yqe.googlegroups.com> <87bpdpftpa.fsf@galatea.lan.informatimago.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1273059990 9278 80.91.229.12 (5 May 2010 11:46:30 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 5 May 2010 11:46:30 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed May 05 13:46:28 2010 connect(): No such file or directory Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1O9d3Z-00039J-GR for geh-help-gnu-emacs@m.gmane.org; Wed, 05 May 2010 13:46:25 +0200 Original-Received: from localhost ([127.0.0.1]:33156 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O9d3Y-0005vH-TF for geh-help-gnu-emacs@m.gmane.org; Wed, 05 May 2010 07:46:24 -0400 Original-Path: usenet.stanford.edu!postnews.google.com!35g2000yqm.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 80 Original-NNTP-Posting-Host: 199.3.246.231 Original-X-Trace: posting.google.com 1271169821 13131 127.0.0.1 (13 Apr 2010 14:43:41 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 13 Apr 2010 14:43:41 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 35g2000yqm.googlegroups.com; posting-host=199.3.246.231; posting-account=1ibdcgoAAABow1tT8596gBIVrwKkiml- User-Agent: G2/1.0 X-HTTP-Via: 1.1 ftcwebcache2.ame.avagotech.net:8088 (IronPort-WSA/6.3.0-523) X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729), gzip(gfe) Original-Xref: usenet.stanford.edu gnu.emacs.help:177690 X-Mailman-Approved-At: Tue, 04 May 2010 16:53:39 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:73396 Archived-At: 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=A0pm, p...@informatimago.com (Pascal J. Bourguignon) wrote: > "richard.christensen" writes: > > On Apr 10, 12:00=A0pm, p...@informatimago.com (Pascal J. Bourguignon) > > wrote: > >> "richard.christensen" writes: > >> > Hi, =A0I 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 f= ew > >> > letters or numbers changed. A useful modification to write-file woul= d > >> > be to have the current file name to be placed in the minibuffer alon= g > >> > with the path when write-file is called. Then modifying the name wou= ld > >> > be simple. =A0How would I do this? =A0Ideas? > > >> Add the (buffer-name) as initial value to the first call to > >> read-file-name: > > >> =A0 (interactive > >> =A0 =A0(list (if buffer-file-name > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0(read-file-name "Write file: " default-dire= ctory > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(expand-fil= e-name > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (file-name= -nondirectory (buffer-name)) > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 default-di= rectory) > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0nil > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (buffer-na= me)) > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0(read-file-name "Write file: " default-dire= ctory > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(expand-fil= e-name > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (file-name= -nondirectory (buffer-name)) > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 default-di= rectory) > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0nil nil)) > >> =A0 =A0 =A0 =A0 =A0(not current-prefix-arg))) > >> -- > >> __Pascal Bourguignon__ > > > Hi, =A0I am missing something. =A0When I C-x w on a buffer, I see no > > different behavior. =A0The 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__