From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: How to modify 'write-file' Date: Thu, 06 May 2010 18:02:38 -0600 Message-ID: References: <87ochrgpbd.fsf@galatea.lan.informatimago.com> <9f65fba7-3fba-40b6-ad86-75aa4f336b91@g11g2000yqe.googlegroups.com> <87bpdpftpa.fsf@galatea.lan.informatimago.com> <9345ad4d-220c-4319-9e2f-d5acfa340d27@35g2000yqm.googlegroups.com> <87mxx698dq.fsf@galatea.lan.informatimago.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1273190689 1723 80.91.229.12 (7 May 2010 00:04:49 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 7 May 2010 00:04:49 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri May 07 02:04:47 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 1OAB3M-0007Ny-JU for geh-help-gnu-emacs@m.gmane.org; Fri, 07 May 2010 02:04:46 +0200 Original-Received: from localhost ([127.0.0.1]:56963 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OAB35-0000qP-PB for geh-help-gnu-emacs@m.gmane.org; Thu, 06 May 2010 20:04:11 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1OAB2e-0000mw-8Q for help-gnu-emacs@gnu.org; Thu, 06 May 2010 20:03:44 -0400 Original-Received: from [140.186.70.92] (port=46805 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OAB1t-0007gH-Mo for help-gnu-emacs@gnu.org; Thu, 06 May 2010 20:03:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OAB1g-00069t-Ez for help-gnu-emacs@gnu.org; Thu, 06 May 2010 20:02:45 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:55056) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OAB1g-00069T-0U for help-gnu-emacs@gnu.org; Thu, 06 May 2010 20:02:44 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OAB1b-000713-UR for help-gnu-emacs@gnu.org; Fri, 07 May 2010 02:02:39 +0200 Original-Received: from c-71-237-24-138.hsd1.co.comcast.net ([71.237.24.138]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 07 May 2010 02:02:39 +0200 Original-Received: from kevin.d.rodgers by c-71-237-24-138.hsd1.co.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 07 May 2010 02:02:39 +0200 X-Injected-Via-Gmane: http://gmane.org/ connect(): No such file or directory Original-Lines: 56 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: c-71-237-24-138.hsd1.co.comcast.net User-Agent: Thunderbird 2.0.0.24 (Macintosh/20100228) In-Reply-To: <87mxx698dq.fsf@galatea.lan.informatimago.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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:73536 Archived-At: 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