all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* R scratch buffer
@ 2012-07-12 15:48 Benoit G.
  2012-07-12 16:15 ` Pascal J. Bourguignon
  0 siblings, 1 reply; 10+ messages in thread
From: Benoit G. @ 2012-07-12 15:48 UTC (permalink / raw)
  To: help-gnu-emacs

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)

Benoit



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: R scratch buffer
  2012-07-12 15:48 R scratch buffer Benoit G.
@ 2012-07-12 16:15 ` Pascal J. Bourguignon
  2012-07-13  7:52   ` Benoit G.
  2012-07-13  7:56   ` Benoit G.
  0 siblings, 2 replies; 10+ messages in thread
From: Pascal J. Bourguignon @ 2012-07-12 16:15 UTC (permalink / raw)
  To: help-gnu-emacs

"Benoit G." <benoit.goussen@gmail.com> 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 {}.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: R scratch buffer
  2012-07-12 16:15 ` Pascal J. Bourguignon
@ 2012-07-13  7:52   ` Benoit G.
  2012-07-13  7:56   ` Benoit G.
  1 sibling, 0 replies; 10+ messages in thread
From: Benoit G. @ 2012-07-13  7:52 UTC (permalink / raw)
  To: help-gnu-emacs

Le jeudi 12 juillet 2012 18:15:52 UTC+2, Pascal J. Bourguignon a écrit :
> &quot;Benoit G.&quot; writes:
> 
> &gt; Dear all,
> &gt;
> &gt; I am trying to make a second scratch buffer which enable automatically the R-mode.
> &gt; I copy-paste-modified a code I found on the www but this don&#39;t seems to work (the buffer is created but in fundmental mode).
> &gt;
> &gt; Can you help me solving this issue?
> &gt;
> &gt; Here is a part of my .emacs file :
> &gt;
> &gt;    (save-excursion
> &gt;       (set-buffer (get-buffer-create &quot;*scratch-R*&quot;))
> &gt;       (R-mode)
> &gt;       (make-local-variable &#39;kill-buffer-query-functions)
> &gt;       (add-hook &#39;kill-buffer-query-functions &#39;kill-scratch-R-buffer))
> &gt;
> &gt;     (defun kill-scratch-R-buffer ()
> &gt;       ;; The next line is just in case someone calls this manually
> &gt;       (set-buffer (get-buffer-create &quot;*scratch-R*&quot;))
> &gt;       ;; Kill the current (*scratch-R*) buffer
> &gt;       (remove-hook &#39;kill-buffer-query-functions &#39;kill-scratch-R-buffer)
> &gt;       (kill-buffer (current-buffer))
> &gt;       ;; Make a brand new *scratch-R* buffer
> &gt;       (set-buffer (get-buffer-create &quot;*scratch-R*&quot;))
> &gt;       (R-mode)
> &gt;       (make-local-variable &#39;kill-buffer-query-functions)
> &gt;       (add-hook &#39;kill-buffer-query-functions &#39;kill-scratch-R-buffer)
> &gt;       ;; Since we killed it, don&#39;t let caller do that.
> &gt;       nil)
> 
> 
> I&#39;d rather do something like this:
> 
>     (defun r-scratch ()
>       &quot;Create and/or switch to the *R-scratch* buffer.&quot;
>       (interactive)
>       (switch-to-buffer (get-buffer-create &quot;*R-scratch*&quot;))
>       (R-mode)
>       (add-hook &#39;kill-buffer-query-functions &#39;kill-scratch-R-buffer))
> 
> 
>     (defun kill-scratch-R-buffer ()
>        &quot;If the current buffer is the *R-scratch* buffer, then  kill it
>      and recreate a virgin *R-scratch* buffer.&quot;
>        (when (eq (get-buffer &quot;*R-scratch*&quot;) (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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: R scratch buffer
  2012-07-12 16:15 ` Pascal J. Bourguignon
  2012-07-13  7:52   ` Benoit G.
@ 2012-07-13  7:56   ` Benoit G.
  2012-07-13  8:31     ` Pascal J. Bourguignon
  1 sibling, 1 reply; 10+ messages in thread
From: Benoit G. @ 2012-07-13  7:56 UTC (permalink / raw)
  To: help-gnu-emacs

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 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: R scratch buffer
  2012-07-13  7:56   ` Benoit G.
@ 2012-07-13  8:31     ` Pascal J. Bourguignon
  2012-07-13  9:22       ` Benoit G.
  0 siblings, 1 reply; 10+ messages in thread
From: Pascal J. Bourguignon @ 2012-07-13  8:31 UTC (permalink / raw)
  To: help-gnu-emacs


"Benoit G." <benoit.goussen@gmail.com> writes:

> 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"

That's what you asked for.   I don't have a R-mode either here, but you
know what you're doing.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: R scratch buffer
  2012-07-13  8:31     ` Pascal J. Bourguignon
@ 2012-07-13  9:22       ` Benoit G.
  2012-07-13 10:12         ` Pascal J. Bourguignon
  0 siblings, 1 reply; 10+ messages in thread
From: Benoit G. @ 2012-07-13  9:22 UTC (permalink / raw)
  To: help-gnu-emacs

Thank you again for this fast answer.

The problem is that calling M-x R-mode under emacs usually works.
But while calling R-mode with .emacs, it don't work anymore. And my R-scratch buffer is still in fundamental mode.

If I find any answer, I will post it.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: R scratch buffer
  2012-07-13  9:22       ` Benoit G.
@ 2012-07-13 10:12         ` Pascal J. Bourguignon
  2012-07-13 12:18           ` Benoit G.
  0 siblings, 1 reply; 10+ messages in thread
From: Pascal J. Bourguignon @ 2012-07-13 10:12 UTC (permalink / raw)
  To: help-gnu-emacs

"Benoit G." <benoit.goussen@gmail.com> writes:

> Thank you again for this fast answer.
>
> The problem is that calling M-x R-mode under emacs usually works.
> But while calling R-mode with .emacs, it don't work anymore. And my R-scratch buffer is still in fundamental mode.
>
> If I find any answer, I will post it.

Perhaps M-x R-mode RET asks for parameters?  Type C-h f R-mode RET and
see what's its usage.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: R scratch buffer
  2012-07-13 10:12         ` Pascal J. Bourguignon
@ 2012-07-13 12:18           ` Benoit G.
  2012-07-13 12:32             ` Pascal J. Bourguignon
  0 siblings, 1 reply; 10+ messages in thread
From: Benoit G. @ 2012-07-13 12:18 UTC (permalink / raw)
  To: help-gnu-emacs

On 13 juil, 12:12, "Pascal J. Bourguignon" <p...@informatimago.com>
wrote:
> "Benoit G." <benoit.gous...@gmail.com> writes:
> > Thank you again for this fast answer.
>
> > The problem is that calling M-x R-mode under emacs usually works.
> > But while calling R-mode with .emacs, it don't work anymore. And my R-scratch buffer is still in fundamental mode.
>
> > If I find any answer, I will post it.
>
> Perhaps M-x R-mode RET asks for parameters?  Type C-h f R-mode RET and
> see what's its usage.
>
> --
> __Pascal Bourguignon__                    http://www.informatimago.com/
> A bad day in () is better than a good day in {}.

C-h f R-mode returns :

"
R-mode is an interactive compiled Lisp function in `ess-r-d.el'.
(R-mode &optional PROC-NAME)
Major mode for editing R source.  See `ess-mode' for more help.
"

and ess-mode returns (first lines) :

"
R-mode is an interactive compiled Lisp function in `ess-r-d.el'.
(R-mode &optional PROC-NAME)
Major mode for editing R source.  See `ess-mode' for more help.
"

I don't think it needed any required argument but I may be wrong...


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: R scratch buffer
  2012-07-13 12:18           ` Benoit G.
@ 2012-07-13 12:32             ` Pascal J. Bourguignon
  2012-07-13 12:46               ` Benoit G.
  0 siblings, 1 reply; 10+ messages in thread
From: Pascal J. Bourguignon @ 2012-07-13 12:32 UTC (permalink / raw)
  To: help-gnu-emacs

"Benoit G." <benoit.goussen@gmail.com> writes:

> On 13 juil, 12:12, "Pascal J. Bourguignon" <p...@informatimago.com>
> wrote:
>> "Benoit G." <benoit.gous...@gmail.com> writes:
>> > Thank you again for this fast answer.
>>
>> > The problem is that calling M-x R-mode under emacs usually works.
>> > But while calling R-mode with .emacs, it don't work anymore. And my R-scratch buffer is still in fundamental mode.
>>
>> > If I find any answer, I will post it.
>>
>> Perhaps M-x R-mode RET asks for parameters?  Type C-h f R-mode RET and
>> see what's its usage.
>
> C-h f R-mode returns :
>
> "
> R-mode is an interactive compiled Lisp function in `ess-r-d.el'.
> (R-mode &optional PROC-NAME)
> Major mode for editing R source.  See `ess-mode' for more help.
> "
>
> and ess-mode returns (first lines) :
>
> "
> R-mode is an interactive compiled Lisp function in `ess-r-d.el'.
> (R-mode &optional PROC-NAME)
> Major mode for editing R source.  See `ess-mode' for more help.
> "
>
> I don't think it needed any required argument but I may be wrong...

Indeed, (R-mode) should work.

M-x toggle-debug-on-error RET
and try again.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: R scratch buffer
  2012-07-13 12:32             ` Pascal J. Bourguignon
@ 2012-07-13 12:46               ` Benoit G.
  0 siblings, 0 replies; 10+ messages in thread
From: Benoit G. @ 2012-07-13 12:46 UTC (permalink / raw)
  To: help-gnu-emacs

On 13 juil, 14:32, "Pascal J. Bourguignon" <p...@informatimago.com>
wrote:
> "Benoit G." <benoit.gous...@gmail.com> writes:
> > On 13 juil, 12:12, "Pascal J. Bourguignon" <p...@informatimago.com>
> > wrote:
> >> "Benoit G." <benoit.gous...@gmail.com> writes:
> >> > Thank you again for this fast answer.
>
> >> > The problem is that calling M-x R-mode under emacs usually works.
> >> > But while calling R-mode with .emacs, it don't work anymore. And my R-scratch buffer is still in fundamental mode.
>
> >> > If I find any answer, I will post it.
>
> >> Perhaps M-x R-mode RET asks for parameters?  Type C-h f R-mode RET and
> >> see what's its usage.
>
> > C-h f R-mode returns :
>
> > "
> > R-mode is an interactive compiled Lisp function in `ess-r-d.el'.
> > (R-mode &optional PROC-NAME)
> > Major mode for editing R source.  See `ess-mode' for more help.
> > "
>
> > and ess-mode returns (first lines) :
>
> > "
> > R-mode is an interactive compiled Lisp function in `ess-r-d.el'.
> > (R-mode &optional PROC-NAME)
> > Major mode for editing R source.  See `ess-mode' for more help.
> > "
>
> > I don't think it needed any required argument but I may be wrong...
>
> Indeed, (R-mode) should work.
>
> M-x toggle-debug-on-error RET
> and try again.
>
> --
> __Pascal Bourguignon__                    http://www.informatimago.com/
> A bad day in () is better than a good day in {}.

The problem seems to be solved.
I added (require 'ess-site) in the .emacs file and the code you
published in the second message and the R-scratch buffer is
automatically created in R-mode while opening emacs. I guess this
solve the problem.

Thank you for helping !


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-07-13 12:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-12 15:48 R scratch buffer Benoit G.
2012-07-12 16:15 ` Pascal J. Bourguignon
2012-07-13  7:52   ` Benoit G.
2012-07-13  7:56   ` Benoit G.
2012-07-13  8:31     ` Pascal J. Bourguignon
2012-07-13  9:22       ` Benoit G.
2012-07-13 10:12         ` Pascal J. Bourguignon
2012-07-13 12:18           ` Benoit G.
2012-07-13 12:32             ` Pascal J. Bourguignon
2012-07-13 12:46               ` Benoit G.

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.