Put this in your .emacs file. It will cycle
through the buffers as you hit Control Tab.
You may notice, rather than traverse forward
in the buffer list when i get the next buffer,
I traverse backwords. The reason is that when you
are on buffer X and move to buffer Y, it puts buffer
X next in the buffer list after Y, so what happens is
that you would just swap between the two:
ie:
(buffer-list) returns (X Y Z A B C)
switch to Y while on X
(buffer-list) reutrns (Y X Z A B C)
See the problem, the next switch will go to X.
If we go backwards:
(buffer-list) returns (X Y Z A B C)
switch to C while on X
(buffer-list) reutrns (C X Y Z A B)
So, the next call would go to buffer B, then A,
and so forth, eliminating the problem. You can
change this code to avoid other buffers other than
the Minibuf ones (say "*scratch*") by adding or
closes to the if in the get-next-buffer function.
(if (or (string-match ... )
(string-match ... )
(string-match ... ))
(get-next-buffer cbuf)
cbuf)
Here's the code:
(defun get-next-buffer(cbuf)
(let*
((bufs (buffer-list))
(bufslen (length bufs))
(pos (position cbuf bufs)))
(if (eq pos 0)
(setq pos (- bufslen 1))
(setq pos (- pos 1)))
(setq cbuf (nth pos bufs))
(if (string-match ".*Minibuf.*" (buffer-name cbuf))
(get-next-buffer cbuf)
cbuf))
)
(defun next-buffer()
"Switch to the next buffer in the list"
(interactive)
(let*
((cbuf (current-buffer)))
(setq cbuf (get-next-buffer cbuf))
(switch-to-buffer cbuf)
)
)
(global-set-key [C-tab] 'next-buffer)
-----Original Message-----
From: Chris [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 31, 2002 1:09 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: (emacs newbie) Modifying JDE
Hello all,
(Sorry if this is the wrong place to send this)
I'm at a new job where we absolutely have no budget for software, and
have to try and use free everything. For a Java IDE, we first tried
NetBeans, which has many problems, and since I've looked at Forte,
Eclipse, and JBuilder Personal Edition, none of which I love. I've been
messing around with Unix here and there for years, and so in the back of
my mind I've long thought that customizing emacs is naturally the way to
go. Rather than live with a 100 Meg + IDE that doesn't do what you want,
why not take emacs and *build* what you want?
I've used emacs for the last 3 days on a Java project (in plain ol' Java
mode), and while there are some things I like, in general the experience
has been akin to commuting every day in an old car with no power
steering and blown shocks. There's nothing wrong with it, but at the end
of the week you're just ragged out. Now, I also know not to blame emacs
for this -- it would seem that "there are no bad emacs experiences --
just bad modes!" Or rather, modes that aren't quite to one's liking. If
I'm not mistaken there's likely to be nothing I want to do in emacs that
can't be customized. Trouble is I don't know how.
In particular, there are a number of things I'd like to be able to do
that I can do in TextPad, my shareware editor of choice. Here are things
I really miss . . .
- Ctrl-Tab to move among open buffers, just like Alt-Tab moves across
applications. Ctrl-X B <Enter> is clunkier, and not quite the same.
- Shift-Arrow (or Page Up/Down or other navigation keys I'm overlooking
-- ah yes, Home/End) to select, along with Ctrl-Arrow which moves across
words, and <Del> to delete selected text. Ctrl-space, Alt-arrow, Ctrl-W
gets you there but too clunky (see "no power steering" above).
- <Tab> indents a selected region, <Shift-Tab> unindents. Very handy.
- A window that lists open buffers, and lets you click on the one you
wish to edit
- Less heavy-handedness in specifying tabbing. In particular, I don't
ever want to hit <Tab> *and have nothing happen*. (grrr.)
- Ctrl-/ comments a region, Shift-Ctrl-/ uncomments. Very handy.
(Actually a JBuilder treat, not TextPad)
And also source-code browsing would be nice, so I could drilldown into
methods etc. Ant integration also would be nice.
I believe that for most of these, emacs provides simple functions that
need to be key-mapped, and for the rest, the functions can be built from
other functions and then keymapped. (The source browsing would be
trickier but perhaps I can just steal JDE's.) My only question then is
how to get started. I haven't found anything that seems like an "Emacs
for Coders and Other Customizers", though I'm sure things exist. The JDE
install taught me a little I think -- that you make add-to-list
'load-path calls to dirs that contain .el files, and those files will be
loaded and in doing so will add functions to the name space. These
functions I imagine are written using certain Emacs 'primitives' and
other functions. So perhaps it's all pretty simple. But where to start?
Thanks all,
Chris
