From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Benoit G." Newsgroups: gmane.emacs.help Subject: Re: R scratch buffer Date: Fri, 13 Jul 2012 00:52:01 -0700 (PDT) Organization: http://groups.google.com Message-ID: <1d26d955-7a86-42a2-96e8-75e224f52695@googlegroups.com> References: <87txxd6jlz.fsf@kuiper.lan.informatimago.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1342166116 32094 80.91.229.3 (13 Jul 2012 07:55:16 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 13 Jul 2012 07:55:16 +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 Jul 13 09:55:13 2012 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 1SpaiX-0000uj-3J for geh-help-gnu-emacs@m.gmane.org; Fri, 13 Jul 2012 09:55:13 +0200 Original-Received: from localhost ([::1]:43456 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpaiW-0002Ze-FL for geh-help-gnu-emacs@m.gmane.org; Fri, 13 Jul 2012 03:55:12 -0400 Original-Path: usenet.stanford.edu!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 71 Original-NNTP-Posting-Host: 194.254.175.14 Original-X-Trace: posting.google.com 1342165922 12508 127.0.0.1 (13 Jul 2012 07:52:02 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Fri, 13 Jul 2012 07:52:02 +0000 (UTC) In-Reply-To: <87txxd6jlz.fsf@kuiper.lan.informatimago.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=194.254.175.14; posting-account=lsrZwgoAAADDjpU1Q0FkITe-H25pPMZY User-Agent: G2/1.0 Original-Xref: usenet.stanford.edu gnu.emacs.help:193446 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:85830 Archived-At: Le jeudi 12 juillet 2012 18:15:52 UTC+2, Pascal J. Bourguignon a =E9crit=A0= : > "Benoit G." writes: >=20 > > Dear all, > > > > I am trying to make a second scratch buffer which enable automatical= ly the R-mode. > > I copy-paste-modified a code I found on the www but this don't s= eems to work (the buffer is created but in fundmental mode). > > > > Can you help me solving this issue? > > > > Here is a part of my .emacs file : > > > > (save-excursion > > (set-buffer (get-buffer-create "*scratch-R*")) > > (R-mode) > > (make-local-variable 'kill-buffer-query-functions) > > (add-hook 'kill-buffer-query-functions 'kill-scratch-R= -buffer)) > > > > (defun kill-scratch-R-buffer () > > ;; The next line is just in case someone calls this manually > > (set-buffer (get-buffer-create "*scratch-R*")) > > ;; Kill the current (*scratch-R*) buffer > > (remove-hook 'kill-buffer-query-functions 'kill-scratc= h-R-buffer) > > (kill-buffer (current-buffer)) > > ;; Make a brand new *scratch-R* buffer > > (set-buffer (get-buffer-create "*scratch-R*")) > > (R-mode) > > (make-local-variable 'kill-buffer-query-functions) > > (add-hook 'kill-buffer-query-functions 'kill-scratch-R= -buffer) > > ;; Since we killed it, don't let caller do that. > > nil) >=20 >=20 > I'd rather do something like this: >=20 > (defun r-scratch () > "Create and/or switch to the *R-scratch* buffer." > (interactive) > (switch-to-buffer (get-buffer-create "*R-scratch*")) > (R-mode) > (add-hook 'kill-buffer-query-functions 'kill-scratch-R-buff= er)) >=20 >=20 > (defun kill-scratch-R-buffer () > "If the current buffer is the *R-scratch* buffer, then kill = it > and recreate a virgin *R-scratch* buffer." > (when (eq (get-buffer "*R-scratch*") (current-buffer)) > (kill-buffer (current-buffer)) > (r-scratch)) > nil) > =20 >=20 > --=20 > __Pascal Bourguignon__ http://www.informatimago.com/ > A bad day in () is better than a good day in {}. Thank you for answering. I still have a problem with this function. Indeed, while calling r-scratch in my .emacs, this error occurs : "Symbol's function definition is void: R-mode" Benoit