Xah Emacs Blog Archive 2012-01 to 2012-01
Emacs on G+ is Useful!
Google+ is actually quite useful. Blogs is going the ways of dinosaur. In social networks, you can write, interact with people, immediately, post pictures, hangout (real-time text chat, voice chat, video chat). And it's all much easier than running a blog. If you follow web tech communities (For example, TechCrunch, etc.), you know that death of blogs have been written on the wall for a few years. With few exceptions, such as professional blogger. (for a fun intro of g+, see: What is Google Plus and Google+ Songs (humor).)
Anyway, i wanted to say that running a emacs page on g+ have already been useful to me, even just after a few days. I learned emacs tips. Here's today's post.
Some slightly advanced emacs tips.
① I just learned about Keyboard Macro Ring today after 10+ years emacs using. (Thanks to Jorge A Alfaro Murillo.)
② A info doc node in emacs can be referenced by a elisp expression. For example:
(info "(emacs) Keyboard Macro Ring"). Put cursor at end of paren then call
eval-last-sexp【Ctrl+x Ctrl+e】. That'll take you to the emacs doc. The argument to
infois string of the node's name.
③ When browsing emacs info doc inside emacs, you can get the node's name by calling “Info-copy-current-node-name” 【c】.
keyboard macro is a time saver. If you don't know the basics, see: Emacs: Keyboard Macro.
My emacs g+ and Twitter pages can be found at: Xah Lee Feeds. Please Subscribe! I will still write blogs. But it's more for heavy weight tutorials, and will be focused on elisp. (because, after a few years, all emacs tips all seem to be repetitions) Brief practical daily tips goes to @ErgoEmacs Twitter and ErgoEmacs g+. Thank you for reading.
My Emacs Online Feeds
For Twitter users, now all my emacs related tweets will be from @ErgoEmacs. This way, those who just want emacs tips can stay focused.
For Google+ users, you might join g+ emacs page. There, i post one or two short emacs tip a day.
For a complete list of feeds of available topics, please see: Subscribe to XahLee.org Site Feed.
Thank you very much for reading!
Xah's Emacs Tutorial Update 2012-01-20
I have a new version of my emacs tutorial ready.
If you've bought it before, please just email to firstname.lastname@example.org with subject “emacs tutorial upgrade”. I'll email you the download location. Sorry i don't have a automatic update system. So just send the email please if you would like the updated version.
If you haven't bought it, you can get it for just $10. See: Buy Xah Emacs Tutorial. As far as i know it's more complete and detailed tutorial than any emacs book, printed or not, especially the elisp section.
Thank you for support!
Emacs Tip: a Hotkey for “repeat-complex-command”
There's a emacs command
I actually never used it. But in a recent post by Dan Espen (Source groups.google.com), it seems useful.
To make it useful, you should give it a easy hotkey, such as F5.
I'm already starting to use it and found it useful.
Here's why it's useful. In many emacs commands, after you call the command, you have to give arguments. For example, the
query-replace. To do the same replacement again, you have to call it again, then use ↑ to go back to previous arg, Enter, then same for replacement.
repeat-complex-command, you don't have to input the args again.
In some ancient keyboard such as
Sun Microsystem's Type 6 Keyboard, there's a key labeled “Again” that is bound to
repeat-complex-command. But that key doesn't exist on PC keyboard today. So, you can bind it to F5 for example, or a single key on the number pad.
If you don't know how to set keys, see: Emacs: How to Define Keys.
Emacs Page on G+, Today's Tip: Hotkeys
i started a g+ emacs stream at https://plus.google.com/113859563190964307534/ . You might want to join. Here's today's post.
in emacs, once you got on the train and know all the basic concepts, there's 1 most important aspect of increasing efficiency. That is, keyboard shorts (keybindings).
emacs has 3k commands out of the box. Everything is a command, including when you type “a” (self-insert-command). For most frequently used commands, there's a key assigned for it.
by default emacs has 1.3k keybindings!
If we take away ancient impractical ones (for obsolete lisp keyboards), there are few hundred keybindings that are actually useful. Most of us probably use around a hundred or 2.
ok. what i want to say is that for daily operation, assigning keys to commands is probably the most useful in creasing your productivity. Emacs is too big. Everyone has different set of commands that each use frequently. So, if you find yourself typing Meta+x to call a particular command often in past weeks, it's time to give it a hotkey! (if it doesn't already have one; or if you find yourself bending your fingers on the default key sequence.)
All your F1…F12 should be used. And some of those 【Ctrl+x Ctrl+…】 and 【Ctrl+c Ctrl+…】 you use often probably should have a shorter key.
if you don't know how to set keys, see:
here's related tips on keys
- Emacs's Keybinding Layout Diagram
- Emacs: Change Minor Mode Keys
- Emacs: How to define Super/Hyper Keys
- Emacs: Add Custom Keys to Enhance Productivity
- List of Emacs Default Keybinding
List Matching Lines in Emacs
learned 2 new commands from a emacs hacker friend Jon Snader (jcs):
See his blog about several ways of listing matching lines:
- Working With Matching Lines In Emacs By Jon Snader. At http://irreal.org/blog/?p=635
there, he covered several ways to list matching lines in current buffer or existing buffers.
if you are new to emacs, you might think “i'll just call unix grep; one less thing to learn”. Actually, the emacs commands are much more convenient. I use them several times everyday for past years.
if you want to know the ways to find matching lines in files (as opposed to already opened files), see also: Emacs: Search Text in Files.
Elisp: Testing Equality of Symbol Variables
elisp manual (info "(elisp) System Environment") says the var system-type's value is a symbol. However, why does the following work?
(string-equal system-type "windows-nt")
It appears, any symbol can be tested as if it is a string. For example:
(string-equal 'x 'x) ; ⇒ t (string-equal 'x 'y) ; ⇒ nil (setq myVar 'tt ) (string-equal myVar "tt") ; ⇒ t
Ted Zlatanov, a emacs dev, comes to the rescue on the why!
From the docstring:
string-equal is a built-in function in `C source code'. (string-equal S1 S2) Return t if two strings have identical contents. Case is significant, but text properties are ignored. Symbols are also allowed; their print names are used instead.
Emacs: Getting Environment Variable When Launching Emacs from GUI
How to get emacs to inherit environment variables from desktop?
On Windows, you need to set them in Registry. You can do that using command line (
setx in “cmd.exe”).
On Mac, you need to set a file
thx to Adam Jiang for asking.
There's a subword-mode that lets you move by camelCase. New in emacs 23, but isn't mentioned in emacs NEWS file. See: Source debbugs.gnu.org bug#6614
Emacs Pinky and RSI
someone on stackoverflow is asking about how to avoid the emacs pinky. See: Source stackoverflow.com
the guy already developed emacs pinky.
Note that this is quite a frequently asked question. People ask about it year round all over. On Reddit, Hacker News, Quara, StackOverflow …, and on lots personal blogs. Many already got RSI. Here's a example of another post about it: Source superuser.com.
On StackOverflow itself, the topics comes up frequently. Sometimes in the name of “what's the best emacs keyboard”.
Here's my take, old article but popular: How to Avoid the Emacs Pinky Problem.
This article is probably one of the top ten most valuable in my ~300 HTML pages emacs/elisp tutorial: How to Write a Emacs Major Mode for Syntax Coloring.
Updated with new code: Elisp: Change URL into HTML Link.
Updated: What's NKRO, N-key Rollover? . This is relevant to emacs if you define Hyper and Super. See bottom of the article.
2 Songs for Emacs Hacking
I must offer you emacs coders 2 songs today. The first one is Pulse. Let the tranquil beat accompany you in your hackathon.
Now, the second song i offer is Information High. This is when you are hyper, such as emacs's Hyper key. When you are high. When your thoughts run faster can you can type.
More Keyboard Geeking
Updated: Guide to Keyboard Key Switch Mechanisms.
Or Buy Xah Emacs Tutorial
Or buy a nice keyboard: Best Keyboard for Emacs
Ask me question on patreon