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: how to get around deprecated function Date: Thu, 30 Apr 2015 13:01:34 -0500 Organization: NewsGuy - Unlimited Usenet $23.95 Message-ID: <55426DFE.2050600@nihilo.net> References: <87twvzx252.fsf@debian.uxu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1430417122 1938 80.91.229.3 (30 Apr 2015 18:05:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 30 Apr 2015 18:05:22 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Apr 30 20:05:22 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ynspr-0005Cd-L0 for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Apr 2015 20:05:19 +0200 Original-Received: from localhost ([::1]:45156 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ynspr-0003sW-3q for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Apr 2015 14:05:19 -0400 Original-Path: usenet.stanford.edu!news.glorb.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!spln!extra.newsguy.com!newsp.newsguy.com!news4 Original-Newsgroups: gnu.emacs.help Original-Lines: 76 Original-NNTP-Posting-Host: p5c19ae42a2b1d91b195dec74048ade5816a3e76c8ef28218.newsdawg.com User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 In-Reply-To: <87twvzx252.fsf@debian.uxu> X-Received-Bytes: 3446 X-Received-Body-CRC: 925503239 Original-Xref: usenet.stanford.edu gnu.emacs.help:211819 X-Originally-To: Emanuel Berg X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:104102 Archived-At: Die Tue Apr 28 2015 18:29:45 GMT-0500 (Central Daylight Time) Emanuel Berg scripsit: > B. T. Raven writes: > >> I am constantly losing short pieces of text left in >> *scratch* and I wrote this interactive function >> [...] >> >> It "works" but according to the docs >> mark-whole-buffer shouldn't be used this way. >> Is there an understandable (to me) right way of >> doing this or doing something else that can be >> invoked as easily? > > In the help for `append-to-file', it says > > (append-to-file START END FILENAME) ... If START > is nil, that means to use the entire > buffer contents. > > Also, instead of using `switch-to-buffer', use > `with-current-buffer'. And, instead of using `setq', > use `let'. Or - as the data doesn't reappear - you > might as well put the function invocations in the > append-to-file invocation itself. > > Use the Emacs byte-compiler to get suggestions such as > these. You already found out they are in the help, but > the byte-compiler can be a way of not having to check > the help for every function used... > > Meta hint: Don't quote things that haven't appeared in > the thread with the angle brackets. Either just yank > it or make it look like this if it appeals to you: > > Meta hint: don't quote things that haven't > appeared in the thread with the angle brackets. > Either just yank it or make it look like this if > it appeals to you. > > Dig deep! > Thanks, Emanuel and Rusi. GT signs are there because I copypasted out of gnus.help where I posted by mistake. I should have stripped them. I now have: Not exactly what you do but for the same reason I have: (defun save-scratchtemp ();; M-x sch (interactive) (save-excursion (with-current-buffer "*scratch*" (mark-whole-buffer) ;;(setq start (point) end (mark)) (append-to-file nil nil "c:/mydocu~1/scratchtemp.txt"))) ) which also "works." Also I may not need save-excursion even if my current buffer is not *scratch*. I used nil nil for start, end maybe unnecessarily if append-to-file renumbers the argument list. I think that the add-hook won't work for me: (add-hook 'lisp-interaction-mode-hook (function (lambda () (setq buffer-offer-save t)))) because *scratch* would have to be associated with a file name which would replace the *scratch* buffer. My kludge is pretty hokey but at least I understand it and the multiple copies of the same -short stretches of text won't be a cumulative problem if I just delete the scratchtemp.txt file now and then. Ed