Cake. Can have. Eat too.

A while ago, a friend of mine shared this informative article about why Atom (a new text editor by the Github team, it seems) cannot replace Vim. The author talks about the very useful composability property of Vi(m) and ends his article with this (do read the complete article though, especially if you are quite new to Vi(m)):
A new, shiny, modern editor could one-up Vim by fixing some (or hopefully all) of these issues. But before an editor can replace Vim, it needs to learn everything that 1976 has to teach — not just the lesson of Emacs, but also the lesson of vi.
Well, it might not be very "shiny", and "modern" is, I guess, very subjective, but there is already an editor that both have awesome extensibility and, optionally, strict modal behaviour with a "command" mode.

Which editor it is? Emacs, of course. Just fire up viper-mode, or pick one of the more modern Vi(m) emulation packages like Evil (here is a list of different emulation modes for Emacs) and you can now have your cake and eat it too.

Mmm. Cake.

Keyboard activated favorites menu using "simple menu items"

Some time back I wanted to create a keyboard activated menu with one-key access to some favorite commands that I did not want to give one-key bindings in the global keymap and for which I do not want to type the names on the M-x prompt. I was going to write my own command to read the key for the favorite command. However, it turns out Emacs already had more or less what I wanted in the form of simple menu items.

I chose to use the "apps" key (on keyboards with two Windows keys, it's the key to the right of the right Windows key, with a little menu symbol on it) since I did not use that for anything in Emacs.

Here is how to try this little hack out (FYI the key/command combinations below are just examples and not the actual keys and commands I wanted to use):

(defvar my-favorties-map (make-sparse-keymap "Favorites"))

(define-key global-map (kbd "<apps>") my-favorties-map)

(define-key my-favorties-map (kbd "f") 
  (cons "Find file"

(define-key my-favorties-map (kbd "s")
  (cons "Save current buffer"

(define-key my-favorties-map (kbd "i")
  (cons "Kill buffer"

After evaluating the above, when typing the "apps" key, the following "menu" will be displayed in the echo minibuffer:

 Favorites: i = Kill buffer, Save current buffer, Find file

It does what I want, although it is a little bit peculiar in how it decides for what bindings it will show X = Command for, and not. Seems that if the name of the menu item/command begins with the same letter/key that is bound to the command, it will not show it.

So, there it is, an instant little text based menu for executing favorite commands.



My Emacs launcher makes me happy

Yeah, just wanted to say that.

Okay, maybe I should elaborate "a little" (...) Some time ago (more than four years I see now...) I got the idea to combine the power of Emacs and the excellent Emacs package Anything (as it was called then, now Helm) plus a keyboard shortcut into my own launcher. Before that I had created a couple of simple ones on my own: PyQe, which I used at home, under Ubuntu (but should in theory work on Windows since it uses basic Python stuff), and another one at work called Quick Execute, which is a small VB hack that turned out to be used by one of my colleagues more than me.


So, Emacs, yes! After some fiddling with the necessary elisp needed and dark (but brittle) voodoo magic configuring a bash script that send keystrokes using some tool I cannot remember the name of now, Anything Launcher was born. It turned out to be a big hit, to me at least (I don't know about anyone in the universe using it, although there were a few comment in the EmacsWiki page early on.)

More than four years later I still use it, several times per hour. What do I do with it? Anything! (of course...) I open important web bookmarks with it, I start programs, I open commonly used folders, I start searches in our intranet at work, I find bugs, cases and Jira issues with it and today I added a small hack to create alarms using the Windows scheduler in the background. And everything I do with it is under total control by me. Not only can I "start" predefined list of "things" (bookmarks etc as mentioned earlier), I can interact with it to give arguments to the "commands" in it.

Just as a more detailed example, if I want to open a bug in our in-house bug tracker, I launch the "Bug Search with prompt" command. It asks me for the bug id and opens the web based bug tracker with the correct bug selected. But, and here comes something that is probably not so easy to do in other configurable launchers (not as easily or quickly I would guess, I am very productive in elisp), it also looks at the clipboard and if it finds something like looks like a bug id, it suggests that as the default input. So, when I get some bug id in some e-mail, I copy that text, open my Emacs launcher (which is what I actually call it on my PC) using a keyboard shortcut, type "bu" to match the bug search command, and then press enter. I then press enter again to accept the bug id it found on the clip board (I could probably make it open the bug directly without me pressing enter, but I like to verify that it is in fact a bug id it found on the clipboard).

That type of command (written in elisp, of course, with all the powers that gives me) turns out to be a quite common pattern, so I have similar commands for cases (connected to bugs), Jira issues and other things where I can "guess" what stuff is placed on the clipboard. And, again, since I have full control and access to an implementation of the world most powerful programming language (Lisp, in case you missed that), I of course implement a command to create these commands. Just as an example on how it could look, here is that exact "bug search" command, from the control file to the launcher:

("Bug Search with prompt" . ("http://urltobugtracker?BUG_ID=%s" "Bug ID" "\\w\\([0-9]+\\)\\w"))

That's it! If I want a similar command for some other web site I just give it another URL (with %s as the placeholder for the input I enter), a prompt for me to understand what to do and the last string up there as regexp for matching stuff on clipboard. Bang! I have a new command that lets me open stuff fast.

The control file, by the way, is actually a normal Lisp list, which the launcher then just "reads". The launcher accepts certain type of "commands", from simple strings that are just started like commands in Windows, to lambda expressions which can do everything that Emacs can do, and Emacs can do A LOT together with external tools. The command above, which begins with a command name and contains as the CDR a list with something that looks like an URL, and some more strings, is also a command that the launcher is programmed to support, since it is such a common command type for me.

Since people like screenshots, here is just an example on how it could look while trying to launch something matching the string "ra":

(please don't make fun of the colours, they can be changed easily but I happen to like them)
So, if you also want to reach launcher nirvana, and just happen to have Emacs lying around, have a look at my Anything Launcher page at EmacsWiki. The information there is a bit old and there are no instructions for Windows, but if there is enough interest (comments here or on the wiki, or by sending me an e-mail or twitter thing or whatever) I might take the time to write down my exact current setup.

Oh, and yes. Some people might ask why I am not simply living inside Emacs all day long and starting things from there. Well, that is not far from the truth either, but sometimes I have to leave the safe haven of Emacs and use other scary programs which people (yet) have not integrated in Emacs and which I don't have the time and effort to integrate myself. So, I need it to be something I can start quickly when I am not inside Emacs (where I, of course, also use Anything to find files and buffers).

Happy launching!


An alternative to the Navigator Filter in IFS Enterprise Explorer

Many know about the Navigator Filter in IFS Enterprise Explorer. It’s the little “(…)” thingy (shortcut key Ctrl+Shift+F) at the top of the IFS Applications navigator. It is a great way to quickly find and open some form.

Fewer seems to know about (or use anyway) the similar search functionality available in the Home form of IEE in IFS Applications 8 (which, to boot, is in focus when you start IFS Enterprise Explorer). To me, that feature has one big advantage over the Navigator Filter: it finds the form I want to open and lets me open it as easily as with the navigator filter but it does not filter the navigator. Instead it just opens up the right place in the navigator, keeping all other navigator nodes visible.

For me this is a big win because, most of the time, after having opened the form I wanted, I want to open other forms in the same part of the navigator, but those are often not seen because of the filter (yes, you can clear the filter but that takes more clicks and/or typing). With the search in the home form you get the best of both worlds. …If you really don’t want to filter the navigator items, that is… ;)

It also has another interesting feature in that the searches are part of the navigation history. This means that if you first used it to search for “doc rev” to find some form, and later use it to find some other form, the first search is still in the navigation history (use the navigation arrows at the top of the screen or Alt+left and Alt+right to navigate).

To use the search in the Home form properly using the keyboard, press Alt+Home first to get to the home form and focus the search field, then type what you want to search for, and lastly press the Tab key to move focus to the matching entries. There you can use the arrow keys and enter to open the form or folder you like. So, it’s the same number of keystrokes as with the navigator filter, if you are into that kind of thing ;)

Search feature in the Home form

I use this much more often than the Navigator Filter. The next time you are about to click the Navigator Filter, try clicking the Home icon instead (or us the shortcut key). Maybe you will like it too?

Happy searching!