Emacs tip of the week (was: Behavior ov C-c C-n)

Angel Lopez angel_lul at hotmail.com
Mon May 24 12:25:34 CEST 2004

That tip is cool, and useful too!!
I would welcome a lot receiving a tip about emacs and/or ess
every week. I think it would be a great idea.
Thanks again,

Date: Fri, 21 May 2004 12:31:28 +0100
From: Stephen Eglen <stephen at anc.ed.ac.uk>
Subject: Re: Behavior ov C-c C-n
To: rossini at u.washington.edu, cottenie at nceas.ucsb.edu,
	ess-help at stat.math.ethz.ch
Message-ID: <16557.59536.319886.893551 at bushmills.inf.ed.ac.uk>
Content-Type: text/plain; charset=us-ascii

  > karl cottenie <cottenie at nceas.ucsb.edu> writes:
  > > ps: I wonder how many other nifty solutions to problems I do not ever
  > > realize I have are out there...
  > Lots.  Stephen Eglen pointed out a few for mine a month ago  :-) .

Just if other people are curious, I'll append the "tip" I sent to Tony
a while ago.

  > If we could just get someone to help compile them...

What do people think about some email-based "Emacs tip of the week"?
It would not be ESS specific, and would need many contributors, but it
might work in a more general context.  However, there may already be
relevant forums for this sort of thing, such as the Emacs newsgroups.

Best wishes,


Some of the recent elisp code for starting *R* in a different frame
was borrowed from code I'd written for iswitchb.el.  Iswitchb (which
is short for "interactive switch buffers") is a buffer switching tool
that replaces the standard C-x b.

If you have Emacs 21, just do M-x iswitchb-mode and then try using "C-x
b" ... Further details from the lisp file are appended below.

As you type in a substring, the list of buffers currently matching
the substring is displayed as you type.  The list is ordered so
that the most recent buffers visited come at the start of the list.
The buffer at the start of the list will be the one visited when
you press return.  By typing more of the substring, the list is
narrowed down so that gradually the buffer you want will be at the
top of the list.  Alternatively, you can use C-s and C-r to rotate
buffer names in the list until the one you want is at the top of
the list.  Completion is also available so that you can see what is
common to all of the matching buffers as you type.

This code is similar to a couple of other packages.  Michael R Cook
<cook at sightpath.com> wrote a similar buffer switching package, but
does exact matching rather than substring matching on buffer names.
I also modified a couple of functions from icomplete.el to provide
the completion feedback in the minibuffer.


If I have two buffers called "123456" and "123", with "123456" the
most recent, when I use iswitchb, I first of all get presented with
the list of all the buffers

       iswitch  {123456,123}

If I then press 2:
       iswitch 2[3]{123456,123}

The list in {} are the matching buffers, most recent first (buffers
visible in the current frame are put at the end of the list by
default).  At any time I can select the item at the head of the
list by pressing RET.  I can also bring the put the first element
at the end of the list by pressing C-s, or put the last element at
the head of the list by pressing C-r.  The item in [] indicates
what can be added to my input by pressing TAB.  In this case, I
will get "3" added to my input.  So, press TAB:
	 iswitch 23{123456,123}

At this point, I still have two matching buffers.
If I want the first buffer in the list, I simply press RET.  If I
wanted the second in the list, I could press C-s to move it to the
top of the list and then RET to select it.

However, If I type 4, I only have one match left:
       iswitch 234[123456] [Matched]

Since there is only one matching buffer left, it is given in [] and we
see the text [Matched] afterwards.  I can now press TAB or RET to go
to that buffer.

If however, I now type "a":
       iswitch 234a [No match]
There are no matching buffers.  If I press RET or TAB, I can be
prompted to create a new buffer called "234a".

Of course, where this function comes in really useful is when you
can specify the buffer using only a few keystrokes.  In the above
example, the quickest way to get to the "123456" buffer would be
just to type 4 and then RET (assuming there isn't any newer buffer
with 4 in its name).

To see a full list of all matching buffers in a separate buffer,
hit ? or press TAB when there are no further completions to the
substring.  Repeated TAB presses will scroll you through this
separate buffer.

The buffer at the head of the list can be killed by pressing C-k.
If the buffer needs saving, you will be queried before the buffer
is killed.

If you find that the file you are after is not in a buffer, you can
press C-x C-f to immediately drop into find-file.

More information about the ESS-help mailing list