2013, Emacs, Mac, March

Poor man’s Everything on Mac OSX, and integration with Emacs

Since I moved from Windows to a Mac last year, one of the tools I have missed is the file search tool, Everything. IMO Everything is a brilliant search tool, since it is very light on resources and it just does what it advertises with a simple user interface.

It also worked well with the way I typically name my directory structure, area of work -> project -> subproject -> … So if I was looking for the architecture charts, say architecture.ppt for a project, in Everything, I could pop-up the window and simply type “work”, “project”, “subproject”, “architecture”, “ppt” in any order and have it show the file I was looking for.

On Macs, we have the default Spotlight search engine but I haven’t been able to figure out how to make it work well for my needs.

Everything script for Mac OSX

So, I came up with the following bit of shell-script to do the same. It is of course based on locate functionality.

#!/bin/bash

cmd="locate -i $1"
while [ $# -gt 0 ];
do
    cmd="$cmd | grep -i $1";
    shift;
done

eval $cmd

Save the above in ~/bin/everything, and you can use it as following:

haider@thinkhr(555) % everything readme applescripts
/Users/haider/MyDocs/org/tools/applescripts-readme.org
/Users/haider/tools/AppleScripts/README.org
/Users/haider/tools/AppleScripts/README.org~

Integration with Emacs

As I said earlier I am trying to use Emacs for all things I can. For now, the only things I have to move away to are for work email (IBM/Lotus Notes) and presentations (with Powerpoint). Net effect is that I am spending more and more time inside Emacs.

Inside Emacs I use the brilliant Helm mode for finding all kinds of files. I started on that after reading Sacha Chua's post about anything, anything was a pre-cursor to Helm mode.

I have setup F1 key as follows:

(global-set-key (kbd "<f1>")
                (lambda() (interactive)
                  (helm
                   :prompt "Switch to: "
                   :candidate-number-limit 10                 ;; up to 10 of each 
                   :sources
                   '(helm-c-source-ffap-line
                     helm-c-source-ffap-guesser
                     helm-c-source-buffers-list               ;; buffers 
                     helm-c-source-recentf               ;; recent files 
                     helm-c-source-bookmarks             ;; bookmarks
                     helm-c-source-file-cache
                     helm-c-source-files-in-current-dir  ;; current dir
                     helm-c-source-locate))))            ;; use 'locate'

Here is how the previously described everything script comes in handy:

(setq helm-c-locate-command "~/bin/everything %.0s %s")

Using openwith for non-textual files

The above works perfectly for any files that are textual in nature, I can press F1, type in the search words and press enter to open it in Emacs.

Of course, I wanted to do the same for any other file and open it with the right application. That's where Markus Triska's openwith package comes in handy. Download and install it, and set it up as follows:

;; openwith setup to help in find-file, etc. for common file types
(require 'openwith)
(openwith-mode t)
(setq openwith-associations
      (quote (("\\.pdf\\'"  "open" (file))
              ("\\.svg\\'"  "open" (file))
              ("\\.\\(?:mpe?g\\|avi\\|wmv\\)\\'" "open -a vlc" (file))
              ("\\.\\(?:jp?g\\|png\\)\\'" "open" (file))
              ("\\.ppt[x]*\\'"  "open" (file))
              ("\\.doc[x]*\\'"  "open" (file))
              ("\\.xls[x]*\\'"  "open" (file))
              )))

Summary

This is what I love about the Unix and Emacs ecosystems. You can combine and use a number of tools to provide a missing functionality, and build something very useful.

As I said at the start, I was missing Everything functionality when I moved to Mac. I googled around but couldn't find anything perfect for my needs. Hope this helps someone else looking for same.

Standard
2012, Emacs, Mac, October, Quicksilver

My experiments with OSX, Emacs and Quicksilver

I have recently moved from a Windows-based laptop (Thinkpad) to a
MacBook Pro. Since then, I have rekindled my love for using Emacs for
anything that I can use it for :-) I have also been learning to use
Quicksilver and make it a core part of
my day-to-day work.

I am also trying to get started with blogging regularly (or should
say, finally get going, since this blog was created a few years ago!)
Towards that end, and the rekindled Emacs-everywhere thinking, I am
trying to setup so I can blog from within Emacs.

There are a couple of wonderful Emacs packages, weblogger and
org2blog, that can help in this endeavour. I am writing and posting
this blog post from weblogger. Had some issues with org2blog that I haven’t been able to solve yet. I’d prefer to get the org2blog working, since I have also started using org-mode for all my note-taking at work.

Setup for weblogger

Download weblogger (and xml-rpc), may be using elpa (M-x
package-list-packages). Setup for the blog is pretty easy.

(require 'weblogger)
(add-to-list 'weblogger-config-alist
 '("wp-blog" "http://harizvi.wordpress.com/xmlrpc.php"
 "userid" "" ""))

You can do the same with:

M-x weblogger-setup-weblog
Standard
Uncategorized

First post with Qumana

Testing Qumana as my blogging software.

This color doesn’t look very good with my black background.

I should try to post a picture to see if it works reasonably well. Here is a picture of K2′s north side, not taken by me. I’ll have to dig into where I got that picture from. I should be able to write around it, given that I have it marked for right side.

Wonder if it works well, does it or does it not.

Anyway, it seems this may work out better than blogspot where Qumana is not working at all for some reason.

Tags:

Standard