[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.5.1 Overview

When you make a new `shimbun' module `foobar' for reading contents of http://www.foobar.net, what you have to do first is to put the following S expressions in the first part of the `sb-foobar.el' file:

 
(require 'shimbun)
(luna-define-class shimbun-foobar (shimbun) ())

We will explain what they are below, so you can understand they are just incantations now. You have to use the same suffix `foobar' in the file name (`sb-foobar.el') and the class name (`shimbun-foobar') as the second argument for the luna-define-class macro.

Major jobs of the `shimbun-foobar' module can be classified broadly into the following four categories (note that you may rephrase "folder" with "group" if you are a Gnus user):

  1. Getting a page source from http://www.foobar.net in order to gather articles' subjects etc. when a MUA opens the `foobar' folder.

  2. Gathering subjects and other necessary informations from the page source in order to make headlines of articles and returning them as the structured list called headers.

  3. Getting a page source for an article from the web site, for example, http://www.foobar.net/053003.html, when MUA requires to display an article in the `foobar' folder, and

  4. Removing cruft, e.g. advertisements, from the page source and formatting a raw article.

shimbun-headers of `shimbun.el' does the first job, shimbun-get-headers does the second, shimbun-article does the third and shimbun-make-contents does the last.

The shimbun-headers method does the first job, the shimbun-get-headers method does the second, the shimbun-article method does the third and the shimbun-make-contents method does the last thing. The default methods for those categories are defined in the `shimbun.el' module.

Open the `shimbun.el' file. You may see unfamiliar definitions like luna-define-generic or luna-define-method there. Hm, they look like defun, don't you? You may also see there's just a doc-string in the former definition and the same symbol is declared again in the later form. And further, there are some symbols only declared by the luna-define-generic form, not by the luna-define-method form. What on earth are we seeing? Isn't the program not written in the Emacs-Lisp language?

The truth is that the `shimbun' modules use the `luna.el' module provided by FLIM which enables you to write object oriented programs in the Emacs-Lisp language.

There are method programs defined rigidly for the specific purposes in the `shimbun.el' module. The shimbun-headers method gets a page source from a certain URL, the shimbun-get-headers method gathers subjects and other informations, etc... (see above). They do routine works, so they cannot take proper method to meet various web contents in the world. Eh? Oh, you shouldn't believe in a heresy!

The `shimbun.el' module only provides the default method functions. Remember the defadvice feature. There are three ways to modify the behavior of a function: :before, :around and :after. Similarly, each default `shimbun' method function can be modified for a certain purpose (note that the :around method-qualifier can be omitted). And it should be written specially that the modification will be effective only when the specified `shimbun' module is selected.

Now as you may have understood that the luna-define-generic form provides only a husk in a sense, the luna-define-method form defines an actual function which can be different for each `shimbun' module, and the luna-define-class form declares the `shimbun' class in the first part of the `sb-foobar.el' module.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by TSUCHIYA Masatoshi on November, 3 2005 using texi2html