From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "B. T. Raven" Newsgroups: gmane.emacs.help Subject: Re: Why won't this command kill a buffer? Date: Fri, 11 Feb 2011 22:15:07 -0600 Message-ID: <-vCdnWMUI_zQlMvQnZ2dnUVZ_sOdnZ2d@sysmatrix.net> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1297485651 5074 80.91.229.12 (12 Feb 2011 04:40:51 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 12 Feb 2011 04:40:51 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Feb 12 05:40:41 2011 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 1Po7Hj-0004tQ-V2 for geh-help-gnu-emacs@m.gmane.org; Sat, 12 Feb 2011 05:40:40 +0100 Original-Received: from localhost ([127.0.0.1]:45868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Po7Hj-00027X-CD for geh-help-gnu-emacs@m.gmane.org; Fri, 11 Feb 2011 23:40:39 -0500 Original-Path: usenet.stanford.edu!postnews.google.com!news2.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.sysmatrix.net!news.sysmatrix.net.POSTED!not-for-mail Original-NNTP-Posting-Date: Fri, 11 Feb 2011 22:15:09 -0600 User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) Original-Newsgroups: gnu.emacs.help In-Reply-To: X-No-Archive: yes Original-Lines: 54 X-Usenet-Provider: http://www.giganews.com Original-NNTP-Posting-Host: 12.73.129.51 Original-X-Trace: sv3-8PgmBwZk2+fiy3G2TF2h9JKlgAPiHpQsDqbRqVy6aRJGVHhoBlinG+T5OFMeDxuOIOit52Sgej7QjJe!xvJVEYHuHnEAS1jppA168lIjLdKn08kCzKZ/bFHjkK5Qqav1uDcpXhUXGyrqTUCxiOPacNJfjTDc!kLczetivI1uTy1jSe3DxkDG5wC8a/A== Original-X-Complaints-To: abuse@sysmatrix.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3011 Original-Xref: usenet.stanford.edu gnu.emacs.help:184900 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 X-Gmane-Expiry: 2011-02-26 Xref: news.gmane.org gmane.emacs.help:79074 Archived-At: Joe Fineman wrote: > I am using Emacs 22.3.1 under Windows XP. I have used the following > kluge for many years: > > (defun marklog () > "Insert a backslash into the Log file for the current directory, and into Today if it is in /b." > (interactive) > (save-window-excursion > (let ((dir default-directory) > (require-final-newline)) > (find-file "~/timing/Logmark") > (write-region 1 2 (concat dir "Log") t 0) > (if (equal (substring dir 0 15) "c:/usr/own/f/b/") > (write-region 1 2 "~/b/Today" t 0)) > (kill-this-buffer)) > )) > > The Logmark file consists of a single backslash. > > The command kill-this-buffer does not work, and neither do attempts to > use kill-buffer with an argument. The buffer hangs around and is > sometimes a nuisance. > > And, incidentally, is there any simpler way to tell Emacs to append a > character to a file? If you really mean "append" (put at the end) then this works (on msw2000 with Emacs 22.3): " append-to-file is an interactive compiled Lisp function in `files.el'. It is bound to . (append-to-file START END FILENAME) Append the contents of the region to the end of file FILENAME. When called from a function, expects three arguments, START, END and FILENAME. START and END are buffer positions saying what text to write. " Interactively I had bound this function to f4 in .emacs (define-key global-map [f4] 'append-to-file) I made a test file with a few chars in it and saved it. Inserted backspace into buffer with C-q *backspacekey* and then made that single character (shows as ^?) the region and pressed f4. Inspection of the last character of the file appended to shows: Char: DEL (127, #o177, #x7f) point=5 of 5 (80%) column=0 I assume that what can be done interactively can also be done programmatically. Ed