Gwene

GmaneGmane is by now a very important piece of my Emacs life. It allows me to get postings to lots of mailing lists using NNTP, i.e., using Gnus, i.e., in a way fully integrated with the “information retrieval and massaging” engine i’ve built around a handful of Emacs packages and elisp snippets (one central actor among them being org-mode).

Another important (if only due to its volume) source of incoming information are RSS subscriptions, to which i have a mild addiction. After trying several options, i had settled on rss2email to read my feeds and channel them to Gnus, with the help of some filtering rules. Although it works pretty well, i wasn’t totally satisfied with this arrangement because it depends on an external program over which (as i don’t like hacking in Python) have less control than i’d wish.

But now, thanks to Gmane’s creator,Lars Magne Ingebrigtsen, i’m nearing the RSS nirvana: he’s created a new service, Gwene, which works like Gmane, but for RSS feeds instead of mailing lists. The interface is damn simple: you just enter the URL of the feed you wanna read, give it a name, and its contents is available over NNTP and updated every thirty minutes. All that is left is to add news.gwene.org to your list of NNTP servers in Gnus (or, in my case, leafnode) and subscribe to the corresponding group.

Any group you add will be available to everyone (for instance, i found this blog already there as gwene.com.wordpress.emacs.feed), and i’d bet Lars will keep adding features in the future. To me, it’s already extremely useful as it stands today!

Posted in Gnus, TEOS. 10 Comments »

Weblogger

Here i am, finally using Emacs for real to edit posts, thanks to weblogger.

Installing it cannot be easier: download the file, and its only dependency, xml-rpc. Put both of them in your load path, require weblogger (e.g. using M-x load-library and call M-x weblogger-setup-weblog, providing the required information.

For instance, i’ve set up this blog using https://emacs.wordpress.com/xmlrpc.php for the ‘end point’. You can add more than one account, which is kind of nice.

If you then invoke M-x weblogger-fetch-entries, you’ll be presented a collection of your posts, as if they were emails (which i like quite a bit), and there’re are commands to browse and modify them, create new ones, save drafts and, of course, publish new entries. Just check the file header, or the menu, for a list of available commands.

There’s also support for simple templates, and for editing your posts using nxml-mode.

The only capability i’m missing is setting categories in WordPress. Perhaps it’s time to roll-up my sleeves! 🙂

Happy blogging!

Livin’ La Vida

Here’s Sacha telling us how she uses emacs:

And don’t miss her behind the scenes writeup!

Tidying up for TEOS

As part of a general migration from darcs to git as my default SCM system (a migration whose reasons include magit being so much better than darcsum), i’ve been tidying up a bit my emacs configuration files and factoring out a small set of libraries that people may find useful.

The new git repository, clonable from http://git.hacks-galore.org/jao/emacs.git and browsable online here, contains a subdirectory called lib with the code i’ve factored out so far:

  • emms contains add-ons for the Emacs multimedia system, including OSD notifications, lyrics retrieval and a play-random-album facility.
  • net is a handbag of networkish utilites: mailbox query and display, emacs-w3m sessions and a weather info fetcher.
  • themes is my own color theme engine, implemented on top of the custom-themes package included in Emacs 23. Defining new color themes is, i think, short and sweet.
  • skels contains a collection of skeletons and related utilities that i use to insert templates in new files.
  • sys is a set of system utilities, most of them from my times as a Mac aficionado and, therefore, probably bit-rotten. Except for jao-osd, which gives you (very rudimentary) access to aosd notifications within emacs.
  • org contains an assortment of extensions for org-mode.
  • tracker is actually a C program that i use to query the tracker daemon that indexes all my documents. The actual queries are performed and displayed in emacs by an Anything extension of mine that i haven’t yet extracted from my configuration as a separate library, and that can be found there.
  • bmk is a (web) bookmark manager that i don’t use anymore (all my bookmarks are kept in org files these days).

There’s also a directory called external with other emacs packages that i use unmodified.

As i said, the idea is that the libraries above should be usable independently of my specific configuration bits, which are contained in the custom folder. The files in that folder will give you additional hints on how to customize the libraries.

With very few exceptions, all these packages are anything but well-documented, but perhaps you’ll find some bits useful. A long delayed project of mine is to use this blog to go through all of them in a series of posts that we could call TEOS, The Emacs Operating System. They would be not only about how the individual libraries work together, but, most importantly, about how they integrate with each other and with other stock Emacs packages to provide an operating environment that, in my humble opinion, surpasses any other commonly used operating system in terms of productivity and extensibility. An Elisp Machine where you are in control and have all the fun.

I’ve been playing with the idea of joining PragProWriMo and make this part of a book writing project that would explore in detail TEOS, with intermediate Emacs users in mind. If i finally go for it, you may consider this post as the first in the series, but i haven’t made up my mind yet.

Be it as it may, i hope you’ll find some elisp snippets above worth stealing for your own Emacs Operation System.

Babel

Every now and then i need to translate a word or a phrase, and switching to emacs-w3m to use one of the on-line translation services is a bit of a chore. Thanks to Juergen Hoetzel’s babel, life is easier now.

Keeping your secrets secret

As much as i try to avoid it, i always end up with lots of usernames and passwords to remember, not to mention a couple of bank accounts and a credit card number for on-line shopping. There’s no way i’m going to remember any of them—why, i even need to keep track of my telephone number. Time to write down a tidy nice little list, that is, time to look for and set up an adequate emacs mode or two.

When it comes to keeping lists, the table editor of org-mode is what you need. Org-mode is included in emacs 22, but Carsten &co. keep adding new stuff and fixing bugs, so it won’t hurt you to get the unstable version from its website. It comes with a nice manual and installing it is a freeze. You enter table mode by typing a vertical bar (|) to separate columns:

  * Bank accounts
    |Account | Credit card | Expiry date | Password |
    |-

From there TAB and RET are your friends: new rows are created and column widths adjusted automagically. You can also add separators by starting a line with |- (as i did above) and typing TAB. In no time you’ll have something like this:

* Banks

  |-----------------+------------------+----------|
  | Account         | Credit card      | password |
  |-----------------+------------------+----------|
  | The credit box  | 8180819999999333 | fooo     |
  | GNU Free Credit | 6969696969696969 | boobarp  |
  | Engineering Safe| 0000000111111111 | passwdd  |
  | paypal          |                  | paaassss |
  |-----------------+------------------+----------|

* Sites

  |-------------------------------+------------------------+
  | site                          | user        | password |
  |-------------------------------+------------------------+
  | http://www.gnu.org            | a user name | password |
  | http://journals.foo.org       | a user name | password |
  | http://philosophy.org         | a user name | password |
  | http://linkedin.com           | a user name | password |
  | http://www.pragpro.com        | a user name | password |
  | http://www.tug.org/members    | a user name | password |
  |-------------------------------+------------------------+

* Source code repositories...

All in conveniently foldable sections, so that you can expand only the interesting section.

But, of course, you don’t want to save this as a regular file (let alone publish it on the internet). Even on a Unix machine, protecting it via file permissions is very weak. Nah, what you want is to encrypt the thing. To that end, one can use public key cryptography.

In a nutshell, you generate a pair of keys: one of them is private, only for your eyes, and therefore should be protected by a solid password; the other one is public: you make it available to anyone that wants to communicate with you. People then write their secret text and encrypt it using the public key. When that’s done, only your secret key (barring the NSA) can decipher the text. Of course, nothing prevents you from using the same device to encrypt and decrypt your passwords file.

This being an emacs blog, i won’t delve into the details of using GnuPG to create a key pair if you don’t already have it. But you being an emacs user, i’m sure you’ll be quite able to run gpg --key-gen to generate your keys.

You could now use gpg to manually cipher and decipher the passwords file, but, you know, one uses emacs because it can do almost any thing for you. In this case, EasyPG will take care of the chore of decrypting the file every time you open it and encrypting it back when it goes to disk. The EasyPG package comes bundled with emacs 23, and, again, it is very easy to install if you are using previous emacs versions. This is the configuration i use for this package:

;; Emacs 23: bundled EasyPG
(require 'epa)
(epa-file-enable)

or, if you installed it externally:

;; EasyPG installed in path/to/epg
(add-to-list 'load-path "path/to/epg")
(require 'epa-setup)
(epa-file-enable)

(Yeah, it’s called easy for a reason!) With this magic incantation in place, every time you open a file with the extension .gpg, EasyPG will do the work for you.

So, all that is left to do is to save our file as, say, dobeedoo.gpg and inform emacs that we want to open it as an org-mode file by adding the following first line to it:

-*- mode: org -*- -*- epa-file-encrypt-to: ("my_key_email@foo.org") -*-

As you can see, we’re also telling EasyPG what key it should use for its cryptographic activities.

That’s it. No rocket science here, but very handy nonetheless, and a very nice example of how different major (org) and minor (org-table, epa) emacs modes can work together for you. A perfect use case of minor modes providing functionality orthogonal to that in the major mode, which is caring about the actual file contents. Personally, this is also the use case that got me started with org-mode: may it enlighten you too 🙂

Happy encrypting!

(BTW, now that you have EasyPG installed, try M-x epa-list-keys, a nice keyring browser, if you ask me.)

Org from the horse’s mouth

After many years using Muse for organising my notes, some moths ago i finally moved to Org for all my planning and note taking. I have some posts in the pipeline with some tricks i used, but i cannot think of a better way to get started than this recent talk by Carsten Dominik, the creator of Org himself:

Enjoy!

Two Gnus tricks

I’ve added a couple of tweaks to my Gnus config lately. Nothing earth-shattering, but in both cases i was writing my own elisp for something that was already in there. So, i’ve thought i’d share them and, maybe, save you the trouble.

The first one is a quickie, and you probably know about it; but for some reason it took me ages to discover the correct configuration knob. When you reply a mail, emacs will use the value of user-mail-address to compose the From: header. One can also tweak gnus-posting-styles to change the address on a per group basis. But what i really wanted was to use the address in the mail i was replying to. I was writing a hook to that effect when i found the variable to set to accomplish it: message-alternative-mails. Here’s how i set it up:

    (setq message-alternative-emails
        (regexp-opt '("jao@gnu.org" "jaortega@goodmail.com" "jao@member.fsf.org")))

Worked like a charm. Now for the second one.

As i’ve mentioned in some post before, Gnus let’s you customise the summary line to your heart’s content by tweaking the variable gnus-summary-line-format. I normally use emacs in a maximized urxvt terminal, so i’ve got plenty of room in my summary lines. One thing i wanted to add is the message’s date in a) my time zone and b) human readable form (you know, something like ‘Today, 22:33’ or ‘Yesterday, 02:44’). I only knew two format directives showing a date (%d and %D), but neither fulfilled my wishes. So i started coding my own, but halfway discovered that Gnus already comes with a custom one, called user-date. You use it by inserting %&user-date; in the line format string. It works in conjunction with a configuration stored in gnus-user-date-format-alist, which contains a lists of pairs. The first member of the pair is the age of the message, the second a time format string for displaying the date of messages that old. You’ll understand it better with an example, taken from my current configuration:

    (setq gnus-user-date-format-alist
          '(((gnus-seconds-today) . "Today, %H:%M")
            ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
            (604800 . "%A %H:%M") ;;that's one week
            ((gnus-seconds-month) . "%A %d")
            ((gnus-seconds-year) . "%B %d")
            (t . "%B %d '%y"))) ;;this one is used when no other does match

    (setq gnus-summary-line-format
      (concat "%U%R %~(pad-right 2)t%* %uj %B%~(max-right 30)~(pad-right 30)n  "
              "%~(max-right 90)~(pad-right 90)s %-135=%&user-date;\n"))

I’ve copied my whole line format so that you can see, in addition, how i manage to keep things aligned in a frame around 180 columns wide. For details on the %uj directive, see this previous post.

Posted in Gnus. 2 Comments »

Numbered links in emacs-w3m

I’ve been trying conkeror as my secondary browser for a while, and i really like it. It has a much smaller memory footprint than Firefox, and it doesn’t take ages to start up. It’s also nicely hackable and extensible (using javascript), and it comes with some interesting functionality, available out of the box. For instance, external editor support or link numbering: pressing ‘f’ numbers all links in the page and you enter a link number to follow it.

As it happens, recent (as in CVS 1.4.4) versions of emacs-w3m offer a similar functionality in the w3m-lnum package. M-x w3m-link-numbering-mode toggles a minor mode showing link numbers on an overlay, and M-n M-x w3m-move-numbered-anchor, where n is the link number, moves the pointer to the desired link. Providing conkeror’s
more handy functionality is then a matter of a few elisp lines:

  
  (require 'w3m-lnum)
  (defun jao-w3m-go-to-linknum ()
    "Turn on link numbers and ask for one to go to."
    (interactive)
    (let ((active w3m-link-numbering-mode))
      (when (not active) (w3m-link-numbering-mode))
      (unwind-protect
          (w3m-move-numbered-anchor (read-number "Anchor number: "))
        (when (not active) (w3m-link-numbering-mode)))))

  (define-key w3m-mode-map "f" 'jao-w3m-go-to-linknum)

Happy browsing!

Map of Emacs Users

Add yourself to the Map of Emacs Users around the world… and leave a note with the emacsen version(s) you use, just for the fun of it! You can also take a look at Emacs google trends (or the Emacs vs. that other editor one), the EmacsUserLocations page or this Emacs Screenshots flickr group.

Posted in Fun. 2 Comments »