help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: R scratch buffer


From: Benoit G.
Subject: Re: R scratch buffer
Date: Fri, 13 Jul 2012 00:52:01 -0700 (PDT)
User-agent: G2/1.0

Le jeudi 12 juillet 2012 18:15:52 UTC+2, Pascal J. Bourguignon a écrit :
> "Benoit G." writes:
> 
> > Dear all,
> >
> > I am trying to make a second scratch buffer which enable automatically 
> the R-mode.
> > I copy-paste-modified a code I found on the www but this don't seems 
> 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-scratch-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)
> 
> 
> I'd rather do something like this:
> 
>     (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-buffer))
> 
> 
>     (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)
>    
> 
> -- 
> __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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]