Emacs blog

20111215: bbdb spell v1.2

Mark Simpson reported that version 1.1 did not work with BBDB 2.35. Version 1.2 fixes that. You can download it here. If you are running BBDB 3.0 you don't need to do anything as Roland Winkler has added the file in git.

20111209: bbdb spell v1.1

After many constructive criticism by Roland Winkler I am please to release bbdb spell version 1.1. It's available here.

20111202: Export bbdb name to aspell personal dictionary

I got tired of people's name being highlighted red when composing e-mail with flyspell. So this bit of code does an export of peoples first and last name from bbdb to aspell custom dictionaries.

You need to set the variable ivan-bbdb-aspell-dictionary to a list of personal dictionaries. Then run M-x ivan-bbdb-export-aspell.

20111116: Stopwatch

Emacs doesn't have a precise stopwatch so I wrote one. It has millisecond accuracy.

20111011: Nterm 0.5

I have managed to squeeze some time to work on nterm. So this new version is much faster. All drawing characters are now bitmap.

20110903: The Land Of Lisp music video

Lovely http://www.youtube.com/watch?v=HM1Zb3xmvMc, it reminds me I have to buy the book.

20110831: Handling multiple SMTP servers

Here's how I deal with multiple SMTP servers. I have a function that runs just before sending an e-mail (after hitting C-c C-c in the message buffer). It asks where the e-mail is coming from and sets the right SMTP server.

In the example below inputting google will pick the google SMTP server. Everything else will be sent via kanis.fr.

The last setq removes the "From" header when composing an e-mail. This is required since I query this value just before sending the message. Using the default value would send the wrong header.

(defun private-gnus-prompt-address ()
  "Prompt for sender address before sending e-mail
  Optionally cover address name to avoid spam"
  (interactive)

  ;; never user agent for e-mail
  (setq message-send-mail-real-function nil)

  (setq user-mail-address (read-string "From: " "google")
  (cond
   ((string= user-mail-address "google")
    (setq
     user-mail-address "ivan.kanis@googlemail.com"
     smtpmail-smtp-server "smtp.gmail.com"
     smtpmail-smtp-service 587))
   (t
    (setq
     smtpmail-smtp-server "kanis.fr"
     smtpmail-smtp-service 2525
     mail-host-address "kanis.fr")))
  (if (not (string-match "@" user-mail-address))
      (setq user-mail-address
            (concat user-mail-address "@" mail-host-address))))

(add-hook 'message-send-hook 'private-gnus-prompt-address)

(setq
  ;; Prevent "From" headers when composing
  message-required-mail-headers
  '(Subject Date (optional . In-Reply-To) Message-ID (optional . User-Agent))
  message-required-headers '((optional . References)))

20110827: My gnus setup

The file ivan-gnus.el contains all the code I have written on top of gnus. Here is an example of how I setup my mail accounts. The last entry is a file that I use with getmail.

;; POP
(setq
 mail-sources '((pop :server "kanis.fr"
                      :port 995
                      :user "bob"
                      :connection ssl
                      :password "3l33t")
                (pop :server "pop.gmail.com"
                     :port 995
                     :connection ssl
                     :user "foo.bar@googlemail.com"
                     :password "more3l33t")
                (file :path "~/tmp/ivan.mbox")))
(setq
  gnus-select-method '(nntp "news.gmane.org")
  gnus-secondary-select-methods '((nnml ""))
  user-mail-address "foo.bar@googlemail.com"
  smtpmail-smtp-server "smtp.gmail.com"
  smtpmail-smtp-service 587)

20110823: Remap left key

C-b is too hard for me to type. I don't use the right control key because it's too hard to reach. So I use the left key which makes me leave the home row. I believe it's a waste of time.

Maybe if I had a Kinesis keyboard it would be different but I am not willing to shell out $$$ for work and home. Beside it wouldn't work when I am on a laptop.

I had a heretic idea. Why not map C-h for left a bit like vim? I have done that today for zsh and emacs. I have unmapped the left arrow so I get into the habit of using it. I will see how it goes.

20110805: Emacs Expert Kit

The emacs expert kit is for people who wants to experience an advance setup of emacs.

20110416: Pomodoro Technique for emacs

I read about the Pomodoro Technique on the org mode mailing list. I have decided to try it out and have noticed a definite gain in productivity.

I naturally take breaks such as browsing the web or chatting... The pomodoro mode gives me a precise slice of time for such breaks. I am always surprised how quickly a five minutes break just flies by. The other gain is that I am tracking my time better.

Since I use it so much I decided to write write code to integrate it with emacs.

In the screen shot above the modeline indicates that I am on my second set of work. The number indicates I have 22 minutes left and it decreases each minute. The pomodoro buffer pops up in between break and work. At that time the emacs windows will be raised in front so that I don't miss it when I am working outside emacs.

20110410: Org camp Paris 2, my impressions

We started with a talk by the current org maintainer Bastien. I think the most promising feature he is working on is org-bot. It's a way for someone to manipulate somebody else org file via ERC. I think it's quite exciting: this may lead the way for org to become multi user.

I gave a short talk in the beginning of the afternoon on how I implement GTD with org. We then split up in small group. Isabelle, Thierry and Vincent-Xavier took care of translating the reference card in french. I heard that Bastien and Julien specified how to implement numbered lists. Kaze, Kinouchou and others were working on usage and workflow. I showed Bernard, Mohamed and Vivien how fun it was to program in elisp.

We then went to a restaurant and had a good time. I think everyone involved felt that their time was put to good use. I hope we will do this again.

20101216: Winpack works with Windows XP SP3

I noticed winpack didn't work very well with Windows XP service pack 3. I have removed gnuwin32 in favor of msys/mingw. I updated hg and vim while I was at it.

20100915: Diary block without week-end

I have written a diary block function without weekend. To use it put the following line in your diary or org file

%%(diary-block-no-week-end 15 9 2010 30 10 2010) block without week-end

(defun diary-block-no-week-end (m1 d1 y1 m2 d2 y2 &optional mark)
  "Block diary entry.
Entry applies if date is between two dates and not in the
weekend."
  (let ((date1 (calendar-absolute-from-gregorian
                (diary-make-date m1 d1 y1)))
        (date2 (calendar-absolute-from-gregorian
                (diary-make-date m2 d2 y2)))
        (day (calendar-day-of-week date))
        (d (calendar-absolute-from-gregorian date)))
    (and (<= date1 d) (<= d date2) (not (= day 6)) (not (= day 0))
         (cons mark entry))))

20100914: Verbiste

I have written a new interface for verbiste. It shows french conjugation for a word near the point. If you want this feature download verbiste.el and put it somewhere in your load path.

20100829: IRC with furigana

Today I have written code that displays kanji reading in Japanese while chatting on IRC. I often know the meaning of the character but forget the pronunciation. Other people who go to Japanese channel might find this hack helpful.

;; lisp/emacs.d/ivan-erc.el

(defvar ivan-erc-japanese-channel
  "#japanese\\|#nihongo"
  "Regexp of channels that are in Japanese")

(defun ivan-erc-furigana ()
  "Display furigana when receiving a message in Japanese"
  (let ((string (buffer-substring-no-properties
                 (point-min) (1- (point-max)))))
    (when (and (string-match ivan-erc-japanese-channel (buffer-name))
               (memq 'unicode (find-charset-region
                               (point-min) (point-max)))
               (ivan-japanese-kanji string))
      (goto-char (point-max))
      (forward-char -1)
      (insert (concat "\n" (ivan-japanese-kakasi string))))))

(add-hook 'erc-insert-modify-hook 'ivan-erc-furigana)

;; /lisp/emacs.d/ivan-japanese.el

(defvar ivan-japanese-kakasi-buffer "*kakasi*"
  "Define temporary buffer for kakasi conversion")

(defun ivan-japanese-kakasi (input)
  "Take a Japanese string and return INPUT in hiragana"
  (get-buffer-create ivan-japanese-kakasi-buffer)
  (with-temp-buffer
    (insert input)
    (let ((coding-system-for-read 'euc-jp)
          (coding-system-for-write 'euc-jp))
      (call-process-region
       (point-min) (point-max)
       "kakasi" nil ivan-japanese-kakasi-buffer nil "-JH" "-s")))
  (prog1
      (with-current-buffer ivan-japanese-kakasi-buffer
        (buffer-substring-no-properties (point-min) (point-max)))
    (kill-buffer ivan-japanese-kakasi-buffer)))

(defun ivan-japanese-kanji (string)
  "Return t if string contains Japanese kanji"
  (let ((length (length string))
        (count 0)
        (ret nil)
        (char ?a))
    (while (< count length)
      (setq char (aref string count))
      (if (and (< char ?\u9fa5)
               (> char ?\u4e00))
          (setq ret t))
      (setq count (1+ count)))
    ret))

20100826: nterm version 0.4

In this version of nterm I have added unit testing and reworked ED and EL.

20100725: nterm version 0.3

This version fixed several bugs that made the program crash. Optimisation makes nterm noticably faster.

20100530: etags and bookmarks

I did some contracting work on a C++ project that was a complete disaster. I used etags on hundreds of classes and I wish I had a tag history listing mode for emacs. With bookmark it's dead simple, the following code will stash all etags you jumped to in the bookmark file.

;; put etags information in bookmark
(defun ivan-etags-bookmark ()
  (bookmark-set tagname))

(add-hook 'find-tag-hook 'ivan-etags-bookmark)

20100417: new version of winpack

I have made a new version of winpack. I cut it to half the size. It includes emacs and many other goodies. Most Unix users will feel at home with a bash shell and several GNU tools.

20091217: appointment implement variable warning time

I use appointment with org. I find that a global time delay for each appointments is inconvenient. For example I need to be warned an hour before an appointment downtown and only 5 minutes for a meeting at work. I have hacked appt.el to keep track of a delay for each appointment. The function appt-add is compatible with the old appt.

Download the new appt, or apply the patch.

20091129: nterm version 0.2 is out

The big new feature is double width and height font. If you are interested it can be downloade here.

20090927: Picture for bbdb

Bbdb (Big Brother DataBase) is the rolodex of emacs. I have added picture support so that you can see your contacts face.

All you need is to download the following file bbdb-picture.el.

20090914: Why emacs is great

With emacs you can chat in japanese in irc and look up words you don't know.

20070608: Gradient Color Faces on Emacs

Another productive day hacking and what not. A picture is worth a thousand words. Download the code if you want to use it.

Snapshot of emacs with gradient color faces
Snapshot of emacs with gradient color faces

20070629: Miscelleneous projects

This month has been productive with Emacs. The mercurial back-end I wrote last year made it in CVS. I wrote a world clock that should be included as well.

I have made a Real Player interface. It needs X Windows to run. It interface with emacs-w3m so that you can listen to radio. Users can bind keys to pause, fast forward, rewind stream.

It can even embed the player in a frame if emacs is compiled with GTK, I am not using this functionality. I expect it could play video in a different frame.

I made good progress on a password manager called keyring. It was designed with a modular back-end.

Currently, there are two back-ends pwsafe and palm. Pwsafe uses the program of the same name. Palm is a back-end for the GNU Keyring program for the Palm OS. It uses a Perl script that called keyring.pl.

Support for editing, renaming and deleting entries still needs to be written.

20040624: Nxml Mode For Emacs

Another tips on emacs. Use James Clark's nxml mode, it is a fantastic XML mode that validates document on the fly. It is handy to edit Docbook document.

It can also be used to edit XHTML pages. No need to run the document through a validator as the errors will be highlighted on the fly. This software is just too good for words and helps me create valid HTML document quicker.

The screenshot belows show a document with intentional errors. All errors are underlined red. If you move the cursor on the error, it will display more information on the status bar.

Nxml mode in action
Nxml mode in action

There is package ready to install on Debian testing called nxml-mode.

back