Is there an emacs game for practicing cursor control? - emacs

So I was wondering if there's a game out there that lets me practice my emacs cursor skills. I just started using emacs and thought that a game letting me control the player with the standard emacs bindings would be an awesome way to get going. When searching for one I stumbled upon this for VIM.
Does anyone know of something similar for emacs?

This is not a game, but I'd suggest installing hardcore-mode (available on Melpa too), and configure it to your liking (here's my configuration if interested). That package when enabled globally will force you to not use the arrow keys and use the C-f, C-b, C-n, C-p bindings instead. So much so that now using those bindings has become a second nature to me.
PS: There's an emacs-dedicated stackexchange site in case you didn't know.

One idea: Have a game mode that shows two buffers, and the goal is to transform the first into the second buffer with the least amount of keystrokes.

Related

What is the correct way to show menu / help screens in Emacs?

When using tools like Org-mode and Magit the mode will sometimes show help menus. For instance, org-mode export will show a nice menu that accept single keys and then executes some command. In Magit, when looking at the status view it will accept tabs to expand the staged and commit areas.
These areas, for both Git and Org, are nicely placed to take up some portion of the emacs frame that is mostly convenient. How does emacs do choose this?
Additionally, these views are read-only, up until the user presses tab in the case of Magit and the status view. Is there a best practice when creating these views which control editing, but allows the mode to edit the file and present alternative text?
Perhaps the answer is take a look at these function A, B, and C. Which is fine, I'm just learning and experimenting on my own.
Magit in particular is not the simplest introduction to popup buffers in Emacs, but it certainly is sophisticated and a good read. Find magit-popup.el on your machine, for example M-x find-function RET magit-popup-mode-setup. To me, that function looks like a good candidate to start reading that file. You can see the macro magit-define-popup in use for example in magit-push-popup in the file magit-remote.el
In the end, it boils down to opening a new buffer in a new window and give it a dedicated major mode which has all the key-bindings.
Another good candidate is the family of temp-buffer-* functions.
Hope, that gives some pointers to start reading.
An easy way to show menus/help screens à la Magit and org-mode is with Hydras:
http://wikemacs.org/wiki/Discoverability#Hydra
https://github.com/abo-abo/hydra/
https://github.com/abo-abo/hydra/wiki
It's a short elisp method to write and it will give you a menu like org-mode. For example:
(defhydra hydra-zoom (global-map "<f2>")
"zoom"
("g" text-scale-increase "in")
("l" text-scale-decrease "out"))
ps: it's not what org-mode and magit use. Magit's system wasn't re-usable until recently and I don't know how it compares with Hydra. A nice feature of Hydras is that you can tell it to not disappear after a keypress, so than you can press many keys in a row.

Emacs hide/show (hs-minor-mode) for imports/includes

hs-minor-mode in Emacs makes it possible to hide the cumbersome initial comment block so that one can get quickly to the code.
Is there a way to duplicate in Emacs what Eclipse (and other) IDEs do to the initial import blocks? A solution that works for C++ includes as well as for Java imports would be nice.
Have a look at the various folding modes and HideShow mode in Emacs. The original Emacs folding-mode has the downside that it requires you to add some additional markers to the code, which I find cumbersome and they don't really help with readability IMHO.
CEDET has a semantic folding mode that will probably be able to do what you want (I haven't looked at it for a while but CEDET/semantic is pretty good at this sort of functionality).

How to achieve this in Emacs?

I saw the feature shown and described below in Sublime Text and was curious to know how does one achieve it in Emacs?
A brief description of the feature:
Have a condensed view of the entire code/text file currently opened and highlight the region, in the very same condensed view, which is currently being viewed. Clicking on any part of the condensed view would bring that part in focus.
Although I know, almost certainly, that I would rarely use this feature since it would be, in my view, a estate hog, considering the fact that I have even had my scroll-mode disabled, but still I am curious to know how it can be done in Emacs.
And yeah I went through(skimmed) Sublime's feature list to find the name of the feature, so that I could then try to find it for Emacs, but couldn't. Therefore, another question: What's this feature called?
Original source of the image above.
There is MiniMap package. From EmacsWiki:
Put minimap.el in your load path.
(require 'minimap)
Use M-x minimap-create in a buffer you’re currently editing.
Use M-x minimap-kill to kill the minimap.
Use M-x customize-groupRETminimap RET to adapt minimap to your needs.

Advice for emacs with Dvorak keyboard layout

There are lots of good discussions of emacs or of the Dvorak layout. There is even some discussion that touches on the combination, but I think it's worth pulling this into one thread so those of us using Dvorak and emacs don't have to read through dozens of pages.
I'm looking for specific pointers or general advice on using emacs with Dvorak. Emacs is extremely configurable, so I think there have to be some great tricks. What are others doing? Re-binding keys in emacs? Re-binding keys everywhere? Changing shortcuts in emacs?
Consider that many of us on Dvorak came from qwerty and some of us may go back in the future. In my case, I still have some familiarity with emacs on qwerty and I sometimes use qwerty, but not currently for emacs - muscle memory has outlasted explicit memory and my fingers sometimes go to the qwerty keys when thinking of emacs shortcuts. (Thank goodness for undo!)
My favorite thing about emacs was the many keyboard shortcuts (such as Ctl -f, -b, -p, -n, -d, etc.) and I have fully learned to touch-type Dvorak at ~ my old speed, but my brain seems to rebel at emacs shortcuts on dvorak. I learned emacs when I coded regularly ~10 years ago, but I stopped coding regularly ~5 years ago, and then I switched to Dvorak. There's good discussion of switching to Dvorak at is-the-switch-to-dvorak-worth-it, but my reason was that I wanted to a) slow myself down for a while because I was suffering from repetitive strain, and b) because I saw mixed reviews of the ergonomics of Dvorak and I wanted to give it a try. For me, it has worked really well - I recovered while slow and after getting back up to approximate full speed (~80 wpm) I can type more, longer without pain - but now that I want to code again I want to make reclaim emacs and I'm not giving up Dvorak.
Just found this question while searching for similar information. I'm a new Dvorak typist, but I've been using Emacs for a few years. The chords are burned into my brain, and I'd rather not retrain myself.
What I've found quite workable is C-\ english-dvorak (set-input-method). The keyboard is remapped to Dvorak, but the chords remain the same (that is, C-x C-f is C-(second key from l-shift) C-(fourth key from caps)). This is a very convenient middleground, giving me the option to remap keybindings in the future, but not forcing me to learn two new systems at once.
If you set the variable default-input-method to english-dvorak, you can just hit C-\ to activate it. This doesn't work if your system keyboard is also mapped to Dvorak, but it's worked for me because I do mostly everything in emacs.
I'm programming every day with Emacs on Dvorak, and I have kept the original key bindings. My main reason for not changing is to be able to use one colleague's Emacs, or start it up on an account I don't want to mess around with. I grew very accustomed of it, so I'm pretty happy with them now.
Obviously, a few one-handed short cuts became two-handed, such as C-x C-s or C-x C-c, but as Dvorak users are generally touch-typing anyway, we always have our two hands on the keyboard.
So, I can only suggest to keep trying, maybe concentrating on fewer commands at the time, and then building back?
I used Emacs for years on Qwerty, and for four years since my switch to Dvorak. I don't make any changes to the default Emacs bindings to accommodate Dvorak...I find that everything works fine as is (although I thought I might have to do something about C-f for a while, but it hasn't turned out to be a problem - that's more because of how I hold my hands than because of the keyboard layout).
On the topic of muscle memory, I don't recommend trying to rebind everything for the new layout - it's a lot of work, and it's often just much easier to change someone else's Qwerty into a Dvorak layout than it is to modify an Emacs init to suit a whole set of bindings for Dvorak, which, IMHO, isn't necessary.
While not specific to Dvorak, I just discovered the "At home modifier":
It allows keys to serve dual functions. For example, when I press space, I get a space; but if I press space in conjunction with another key, it functions as ctrl.
This makes some of the more awkward combos a bit easier to type.
I'm using mostly the default key bindings, but I found that combos starting with C-x are much more comfortable to type with this:
(keyboard-translate ?\C-t ?\C-x)
(keyboard-translate ?\C-x ?\C-t)
I only have one left Ctrl key at the Caps Lock position (since reprogramming the Truly Ergonomic keyboard to Dvorak turned right Ctrl into a dash) and C-x is a rather uncomfortable stretch.
I have used dvorak for a few years now (6-7 years), used it long before I used Emacs for 'real'. So I learned the combos in their original forms, I think they are usually ok, the biggest problem is the combos beginning with C-c, since I only have one Ctrl-key it gets kind of awkward. I have to stretch out across the keyboard.
Recently I found out about (keyboard-translate FROM TO), so I rebound my C-j to C-c, and C-c to C-j. I'm not too sure what I think about it yet - it messes with your head and your fingers, but it's a bit more convenient than the old C-c. Try it out.
(keyboard-translate ?\C-j ?\C-c)

Better control over Emacs windows

I spend a lot of my time in emacs, and for the most part it's wonderful. But one thing really drives me nuts when I'm deep in it, and that's control over which window various new buffers are opened in. When I do find-file, it always opens in the current window, and this is what I like. But tons of other modes like to split my windows for me, change the layout, and do various other things that annoy me. For example running M-x manual-entry seems to have no rhyme or reason about where it opens the manpage, and various org-mode commands do the same thing, closing windows I want to keep open, etc. I don't like having to redo my layout everytime I want to look at my org agenda or open a manpage.
In short, is there anyway to globally control which windows are used for modes that want to open in a window other than the current one? Can I direct them more easily? Or will I have to hack each mode to act the way I want it to?
Try Winner mode:
http://www.emacswiki.org/emacs/WinnerMode
It provides an undo/redo for changes to the window configuration.
This question has always bugged me too. I found this:
http://www.gnu.org/software/emacs/elisp/html_node/Choosing-Window.html
It looks like you can use (setf pop-up-frames t) to make stuff show up in a new frame.
Also, it looks like you can use display-buffer-function to override the display function (how buffers are chosen.) Of course, you'd have to be good at elisp.