From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: Re: how to get around deprecated function Date: Fri, 01 May 2015 03:17:08 +0200 Organization: Aioe.org NNTP Server Message-ID: <87y4l9p04r.fsf@debian.uxu> References: <87twvzx252.fsf@debian.uxu> <55426DFE.2050600@nihilo.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1430442920 29525 80.91.229.3 (1 May 2015 01:15:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 1 May 2015 01:15:20 +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 01 03:15:19 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 1YnzXz-00085A-1X for geh-help-gnu-emacs@m.gmane.org; Fri, 01 May 2015 03:15:19 +0200 Original-Received: from localhost ([::1]:46390 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YnzXx-0002EB-UB for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Apr 2015 21:15:17 -0400 Original-Path: usenet.stanford.edu!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 95 Original-NNTP-Posting-Host: feB02bRejf23rfBm51Mt7Q.user.speranza.aioe.org Original-X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-Notice: Filtered by postfilter v. 0.8.2 Cancel-Lock: sha1:bCImeYv7fiE1vPgc4aZx0y0o/k4= Mail-Copies-To: never Original-Xref: usenet.stanford.edu gnu.emacs.help:211832 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:104115 Archived-At: "B. T. Raven" writes: > 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. Well, quoting is an acquired craft. If you have the attitude of learing, let me also advice you to not quote the entire message replied-to but rather just what you wish to provide as context for your latest additions to the thread. > (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"))) > ) You don't have to use `save-excursion' because you don't need `mark-whole-buffer'. You use save-excursion when you move point, which indeed mark-whole-buffer does, but since that isn't required, you don't need save-excursion. In general, try not to move the point from Elisp. But there are many times when it is needed, and then, yes, use save-excursion. > which also "works." Also I may not need > save-excursion even if my current buffer is not > *scratch*. You don't need save-excursion but it doesn't have anything to do with the current buffer. `with-current-buffer' is perhaps (?) misleading - think of it as `do-with-buffer'. This is all you need: (with-current-buffer "test.txt" (append-to-file nil nil "test-log.txt") ) If you are to put it in a hook, you should check there is such a buffer as well. > I used nil nil for start, end maybe unnecessarily if > append-to-file renumbers the argument list. No, that is the right thing to do. In the help for `append-to-file', it says If START is nil, that means to use the entire buffer contents. If START is a string, then output that string to the file instead of any buffer contents; END is ignored. So though it isn't spelled out when "START is nil", I think it is safe to assume "END is ignored" there as well as when "START is a string". Besides, what else could it (not) do? Feel free to verify this by checking out the code. Perhaps it should be added to the docs (one more "END is ignored") to rule out confusion? (If that *isn't* the case that should definitely be spelled out.) > (add-hook 'lisp-interaction-mode-hook (function > (lambda () (setq buffer-offer-save t)))) With `add-hook', you don't need `function' before lambda. Just put the lambda there (unquoted). (add-hook 'lisp-interaction-mode-hook (lambda () ...) But, what are you trying to do? I think you are better of to tell Emacs to automatically save it on exit. By the way, and people probably have different views on this, but I think all that add-hook stuff is confusing. It is better to find out what the hook is. Offen it is empty or consists of a single or but a few items. Examine what is there and decide if you want it. Then set up the hook explicitly, e.g. (setq perl-mode-hook 'enable-line-mode) ; Perl But there is nothing wrong with add-hook and I use it sometimes dynamically. But in init files, I don't see why not setting up the hooks explicitly offers a higher degree of clarity and control. -- underground experts united http://user.it.uu.se/~embe8573