<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>sacha chua :: enterprise 2.0 consultant, storyteller, geek &#187; elisp</title>
	<atom:link href="http://sachachua.com/wp/category/elisp/feed/" rel="self" type="application/rss+xml" />
	<link>http://sachachua.com/wp</link>
	<description>I help people connect through blogs, wikis, other Web 2.0 tools. I'm also writing a book about Emacs.</description>
	<pubDate>Thu, 21 Aug 2008 04:07:41 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
	<language>en</language>
			<item>
		<title>Crazy Emacs: Personalized signatures with random taglines</title>
		<link>http://sachachua.com/wp/2006/10/02/crazy-emacs-personalized-signatures-with-random-taglines/</link>
		<comments>http://sachachua.com/wp/2006/10/02/crazy-emacs-personalized-signatures-with-random-taglines/#comments</comments>
		<pubDate>Mon, 02 Oct 2006 19:05:00 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[bbdb]]></category>

		<category><![CDATA[elisp]]></category>

		<category><![CDATA[emacs]]></category>

		<category><![CDATA[hack]]></category>

		<guid isPermaLink="false">http://sachachua.com/notebook/wiki/2006.10.02.php#anchor-11</guid>
		<description><![CDATA[<p>Of course, that naturally leads to the crazy idea: "What if I can
personalize my signatures?" Knowing that Paul Lussier is an Emacs geek, I can reward him for reading all the way
to the bottom of my message... ;)</p>

<pre class="example">
(defun sacha/gnus-personalize-signature ()
  "Personalizes signature based on BBDB signature field.
BBDB signature field should be a lambda expression.
First person with a custom signature field gets used."
  (let* ((bbdb-get-addresses-headers
          (list (assoc 'recipients bbdb-get-addresses-headers)))
         (records (bbdb-update-records
                   (bbdb-get-addresses
                    nil
                    gnus-ignored-from-addresses 'gnus-fetch-field)
                   nil
                   nil))
         signature)
    (while (and records (not signature))
      (when (bbdb-record-getprop (car records) 'signature)
        (setq signature
              (eval (read (bbdb-record-getprop (car records)
                                               'signature)))))
      (setq records (cdr records)))
    (or signature t)))
(setq-default message-signature 'sacha/gnus-personalize-signature)
</pre>

<p>So then all I have to do is add the following field to his record:</p>

<pre class="example">
      signature: (concat "Sacha Chua - Emacs geek
                 What crazy idea can I help you hack next?
                 Random Emacs symbol: "
                 (sacha/random-tagline
                  "~/.taglines.random-emacs-symbols"))
</pre>

<p>Emacs. One crazy idea at a time. Now I can use this to select random
information, like my favorite networking books or a list of my
upcoming events...</p>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/bbdb" rel="tag">bbdb</a>, <a href="http://www.technorati.com/tag/elisp" rel="tag">elisp</a>, <a href="http://www.technorati.com/tag/hack" rel="tag">hack</a></p>

<p>Random Emacs symbol: sort-coding-systems-predicate - Variable: If non-nil, a predicate function to sort coding systems.</p>
]]></description>
			<content:encoded><![CDATA[<p>Of course, that naturally leads to the crazy idea: "What if I can
personalize my signatures?" Knowing that Paul Lussier is an Emacs geek, I can reward him for reading all the way
to the bottom of my message... ;)</p>

<pre class="example">
(defun sacha/gnus-personalize-signature ()
  "Personalizes signature based on BBDB signature field.
BBDB signature field should be a lambda expression.
First person with a custom signature field gets used."
  (let* ((bbdb-get-addresses-headers
          (list (assoc 'recipients bbdb-get-addresses-headers)))
         (records (bbdb-update-records
                   (bbdb-get-addresses
                    nil
                    gnus-ignored-from-addresses 'gnus-fetch-field)
                   nil
                   nil))
         signature)
    (while (and records (not signature))
      (when (bbdb-record-getprop (car records) 'signature)
        (setq signature
              (eval (read (bbdb-record-getprop (car records)
                                               'signature)))))
      (setq records (cdr records)))
    (or signature t)))
(setq-default message-signature 'sacha/gnus-personalize-signature)
</pre>

<p>So then all I have to do is add the following field to his record:</p>

<pre class="example">
      signature: (concat "Sacha Chua - Emacs geek
                 What crazy idea can I help you hack next?
                 Random Emacs symbol: "
                 (sacha/random-tagline
                  "~/.taglines.random-emacs-symbols"))
</pre>

<p>Emacs. One crazy idea at a time. Now I can use this to select random
information, like my favorite networking books or a list of my
upcoming events...</p>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/bbdb" rel="tag">bbdb</a>, <a href="http://www.technorati.com/tag/elisp" rel="tag">elisp</a>, <a href="http://www.technorati.com/tag/hack" rel="tag">hack</a></p>

<p>Random Emacs symbol: sort-coding-systems-predicate - Variable: If non-nil, a predicate function to sort coding systems.</p>
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2006/10/02/crazy-emacs-personalized-signatures-with-random-taglines/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Crazy idea for Emacs: Random Emacs taglines</title>
		<link>http://sachachua.com/wp/2006/10/02/crazy-idea-for-emacs-random-emacs-taglines/</link>
		<comments>http://sachachua.com/wp/2006/10/02/crazy-idea-for-emacs-random-emacs-taglines/#comments</comments>
		<pubDate>Mon, 02 Oct 2006 18:34:00 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[elisp]]></category>

		<category><![CDATA[emacs]]></category>

		<category><![CDATA[pimpmyemacs]]></category>

		<guid isPermaLink="false">http://sachachua.com/notebook/wiki/2006.10.02.php#anchor-10</guid>
		<description><![CDATA[<p>Would anyone happen to know of a way to select a random symbol with a
description?</p>

<p>Actually. Hmm.</p>

<pre class="example">
(progn
  (apropos ".")
  (write-file "~/.taglines.random-emacs-symbols")
  (delete-matching-lines "Plist")
  (delete-matching-lines "not documented")
  (replace-regexp "\n  " " - " nil)
  (delete-non-matching-lines " - "))
</pre>

<p>Et voila! Random Emacs taglines together with the code:</p>

<pre class="example">
(defun sacha/random-tagline (&#038;optional file)
  "Return a random tagline and put it in the kill ring."
  (interactive)
  (with-current-buffer (find-file-noselect (or file "~/.taglines"))
    (goto-char (random (point-max)))
    (let ((string
           (buffer-substring (line-beginning-position)
                             (line-end-position))))
      (kill-new string)
      string)))

(defadvice remember (after sacha-tagline activate)
  "Add random tagline."
  (save-excursion
  (goto-char (point-max))
  (insert "\n\nRandom Emacs symbol: "
          (sacha/random-tagline "~/.taglines.random-emacs-symbols")
          "\n\n")))))
</pre>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/pimpmyemacs" rel="tag">pimpmyemacs</a>, <a href="http://www.technorati.com/tag/elisp" rel="tag">elisp</a></p>

<p>Random Emacs symbol: eshell-remove-entries - Function: From PATH, remove all of the given FILES, perhaps interactively.</p>
]]></description>
			<content:encoded><![CDATA[<p>Would anyone happen to know of a way to select a random symbol with a
description?</p>

<p>Actually. Hmm.</p>

<pre class="example">
(progn
  (apropos ".")
  (write-file "~/.taglines.random-emacs-symbols")
  (delete-matching-lines "Plist")
  (delete-matching-lines "not documented")
  (replace-regexp "\n  " " - " nil)
  (delete-non-matching-lines " - "))
</pre>

<p>Et voila! Random Emacs taglines together with the code:</p>

<pre class="example">
(defun sacha/random-tagline (&optional file)
  "Return a random tagline and put it in the kill ring."
  (interactive)
  (with-current-buffer (find-file-noselect (or file "~/.taglines"))
    (goto-char (random (point-max)))
    (let ((string
           (buffer-substring (line-beginning-position)
                             (line-end-position))))
      (kill-new string)
      string)))

(defadvice remember (after sacha-tagline activate)
  "Add random tagline."
  (save-excursion
  (goto-char (point-max))
  (insert "\n\nRandom Emacs symbol: "
          (sacha/random-tagline "~/.taglines.random-emacs-symbols")
          "\n\n")))))
</pre>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/pimpmyemacs" rel="tag">pimpmyemacs</a>, <a href="http://www.technorati.com/tag/elisp" rel="tag">elisp</a></p>

<p>Random Emacs symbol: eshell-remove-entries - Function: From PATH, remove all of the given FILES, perhaps interactively.</p>
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2006/10/02/crazy-idea-for-emacs-random-emacs-taglines/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Emacs BBDB: Prioritize exact matches</title>
		<link>http://sachachua.com/wp/2006/09/29/emacs-bbdb-prioritize-exact-matches/</link>
		<comments>http://sachachua.com/wp/2006/09/29/emacs-bbdb-prioritize-exact-matches/#comments</comments>
		<pubDate>Fri, 29 Sep 2006 19:54:00 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[bbdb]]></category>

		<category><![CDATA[crm]]></category>

		<category><![CDATA[elisp]]></category>

		<category><![CDATA[emacs]]></category>

		<category><![CDATA[pimpmyemacs]]></category>

		<guid isPermaLink="false">http://sachachua.com/notebook/wiki/2006.09.29.php#anchor-8</guid>
		<description><![CDATA[<p>I often include people's names in my notes on other people, such as
when I'm tracking who introduced me to whom. The following code
modifies BBDB's behavior to put exact matches for name, company, or
network address above matches for notes.</p>

<pre class="example">
(defun sacha/bbdb (string elidep)
  "Display all entries in the BBDB matching the regexp STRING
in either the name(s), company, network address, or notes.
Prioritize non-note matches."
  (interactive
   (list (bbdb-search-prompt "Search records %m regexp: ")
         current-prefix-arg))
  (let* ((bbdb-display-layout (bbdb-grovel-elide-arg elidep))
         (notes (cons '* string))
         (records-top
          (bbdb-search (bbdb-records) string string string nil
                       nil))
         (records
          (bbdb-search (bbdb-records) string string string notes
                       nil))
         temp)
    (setq temp records-top)
    (while temp
      (setq records (delete (car temp) records))
      (setq temp (cdr temp)))
    (if (or records-top records)
        (bbdb-display-records (append
                               records-top
                               records))
      ;; we could use error here, but it's not really an error.
      (message "No records matching '%s'" string))))

(defalias 'bbdb 'sacha/bbdb)
</pre>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/bbdb" rel="tag">bbdb</a>, <a href="http://www.technorati.com/tag/crm" rel="tag">crm</a>, <a href="http://www.technorati.com/tag/elisp" rel="tag">elisp</a>, <a href="http://www.technorati.com/tag/pimpmyemacs" rel="tag">pimpmyemacs</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I often include people's names in my notes on other people, such as
when I'm tracking who introduced me to whom. The following code
modifies BBDB's behavior to put exact matches for name, company, or
network address above matches for notes.</p>

<pre class="example">
(defun sacha/bbdb (string elidep)
  "Display all entries in the BBDB matching the regexp STRING
in either the name(s), company, network address, or notes.
Prioritize non-note matches."
  (interactive
   (list (bbdb-search-prompt "Search records %m regexp: ")
         current-prefix-arg))
  (let* ((bbdb-display-layout (bbdb-grovel-elide-arg elidep))
         (notes (cons '* string))
         (records-top
          (bbdb-search (bbdb-records) string string string nil
                       nil))
         (records
          (bbdb-search (bbdb-records) string string string notes
                       nil))
         temp)
    (setq temp records-top)
    (while temp
      (setq records (delete (car temp) records))
      (setq temp (cdr temp)))
    (if (or records-top records)
        (bbdb-display-records (append
                               records-top
                               records))
      ;; we could use error here, but it's not really an error.
      (message "No records matching '%s'" string))))

(defalias 'bbdb 'sacha/bbdb)
</pre>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/bbdb" rel="tag">bbdb</a>, <a href="http://www.technorati.com/tag/crm" rel="tag">crm</a>, <a href="http://www.technorati.com/tag/elisp" rel="tag">elisp</a>, <a href="http://www.technorati.com/tag/pimpmyemacs" rel="tag">pimpmyemacs</a></p>
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2006/09/29/emacs-bbdb-prioritize-exact-matches/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Emacs: BBDB rapid serial visualization</title>
		<link>http://sachachua.com/wp/2006/09/28/emacs-bbdb-rapid-serial-visualization/</link>
		<comments>http://sachachua.com/wp/2006/09/28/emacs-bbdb-rapid-serial-visualization/#comments</comments>
		<pubDate>Thu, 28 Sep 2006 15:35:00 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[bbdb]]></category>

		<category><![CDATA[crm]]></category>

		<category><![CDATA[elisp]]></category>

		<category><![CDATA[emacs]]></category>

		<category><![CDATA[pimpmyemacs]]></category>

		<guid isPermaLink="false">http://sachachua.com/notebook/wiki/2006.09.28.php#anchor-4</guid>
		<description><![CDATA[<p>And because it's good to quickly flash through records once in a while
to refresh my memory...</p>

<pre class="example">
(defvar sacha/bbdb-rapid-serial-visualization-delay
 1
 "*Number of seconds to wait between records.
Set to 0 to wait for input.")

(defun sacha/bbdb-rapid-serial-visualization ()
  "Breeze through everyone's name and notes."
  (interactive)
  (window-configuration-to-register ?a)
  ;; Copy the currently visible records
  (let ((records bbdb-records)
        (default-size (face-attribute 'default :height))
        (new-size 400)
        (continue t))
    (set-face-attribute 'default nil :height new-size)
    (pop-to-buffer (get-buffer-create "BBDB-Serial"))
    (delete-other-windows)
    (while (and records continue)
      (insert (bbdb-record-name (caar records))
              "\n\n"
              (or (car (bbdb-record-net (caar records))) "No e-mail")
              "\n\n"
              (or (bbdb-record-notes (caar records)) "")
              (make-string 50 ?\n))
      (goto-char (point-min))
      (sit-for sacha/bbdb-rapid-serial-visualization-delay)
      (setq records (cdr records)))
    (set-face-attribute 'default nil :height default-size)
    (when continue
      (jump-to-register ?a))))
</pre>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/bbdb" rel="tag">bbdb</a>, <a href="http://www.technorati.com/tag/crm" rel="tag">crm</a>, <a href="http://www.technorati.com/tag/elisp" rel="tag">elisp</a>, <a href="http://www.technorati.com/tag/pimpmyemacs" rel="tag">pimpmyemacs</a></p>
]]></description>
			<content:encoded><![CDATA[<p>And because it's good to quickly flash through records once in a while
to refresh my memory...</p>

<pre class="example">
(defvar sacha/bbdb-rapid-serial-visualization-delay
 1
 "*Number of seconds to wait between records.
Set to 0 to wait for input.")

(defun sacha/bbdb-rapid-serial-visualization ()
  "Breeze through everyone's name and notes."
  (interactive)
  (window-configuration-to-register ?a)
  ;; Copy the currently visible records
  (let ((records bbdb-records)
        (default-size (face-attribute 'default :height))
        (new-size 400)
        (continue t))
    (set-face-attribute 'default nil :height new-size)
    (pop-to-buffer (get-buffer-create "BBDB-Serial"))
    (delete-other-windows)
    (while (and records continue)
      (insert (bbdb-record-name (caar records))
              "\n\n"
              (or (car (bbdb-record-net (caar records))) "No e-mail")
              "\n\n"
              (or (bbdb-record-notes (caar records)) "")
              (make-string 50 ?\n))
      (goto-char (point-min))
      (sit-for sacha/bbdb-rapid-serial-visualization-delay)
      (setq records (cdr records)))
    (set-face-attribute 'default nil :height default-size)
    (when continue
      (jump-to-register ?a))))
</pre>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/bbdb" rel="tag">bbdb</a>, <a href="http://www.technorati.com/tag/crm" rel="tag">crm</a>, <a href="http://www.technorati.com/tag/elisp" rel="tag">elisp</a>, <a href="http://www.technorati.com/tag/pimpmyemacs" rel="tag">pimpmyemacs</a></p>
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2006/09/28/emacs-bbdb-rapid-serial-visualization/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Emacs: Show only people whom I haven&#039;t pinged since&#8230;</title>
		<link>http://sachachua.com/wp/2006/09/28/emacs-show-only-people-whom-i-havent-pinged-since/</link>
		<comments>http://sachachua.com/wp/2006/09/28/emacs-show-only-people-whom-i-havent-pinged-since/#comments</comments>
		<pubDate>Thu, 28 Sep 2006 15:23:00 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[bbdb]]></category>

		<category><![CDATA[elisp]]></category>

		<category><![CDATA[emacs]]></category>

		<category><![CDATA[hack]]></category>

		<category><![CDATA[networking]]></category>

		<category><![CDATA[pimpmyemacs]]></category>

		<category><![CDATA[planner]]></category>

		<guid isPermaLink="false">http://sachachua.com/notebook/wiki/2006.09.28.php#anchor-3</guid>
		<description><![CDATA[<p>One of the things I want in a contact management system is a quick way
to find out who I haven't pinged in a while. The following code
filters currently-displayed contacts to show who I might want to get
back in touch with. Call it from a *BBDB* window and specify the date
(could be 2006.01.01 for annual, -7 for the last seven days, etc.).
This works incredibly well with the following hacks:</p>

<ul>
<li><a href="http://sachachua.com/notebook/wiki/2006.09.01.php#anchor-2">Emacs: Keep track of messages sent</a></li>
<li><a href="http://sachachua.com/notebook/wiki/2006.06.03.php#anchor-5">BBDB pinging code</a></li>
</ul>

<p>I should write a small book about how to build a contact management
system with Emacs. ;) It's insanely powerful, you know.</p>

<pre class="example">
(require 'planner)
(require 'bbdb)
(defun sacha/bbdb-show-only-no-contact-since (date)
  "Show only people who haven't been pinged since DATE or at all."
  (interactive (list (planner-read-date)))
  (let ((records bbdb-records)
        new-records
        last-match
        omit
        notes)
    (while records
      ;; Find the latest date mentioned in the entry
      (setq notes (or (bbdb-record-notes (caar records)) ""))
      (setq last-match nil omit nil)
      (while (string-match
              "[0-9][0-9][0-9][0-9]\\.[0-9][0-9]\\.[0-9][0-9]"
              notes
              (or last-match 0))
        (unless (string> date (match-string 0 notes))
          (setq omit t)
          (setq last-match (length notes)))
        (setq last-match (match-end 0)))
      (unless (and last-match omit)
        (add-to-list 'new-records (caar records) t))
      (setq records (cdr records)))
    (bbdb-display-records new-records)))
</pre>

<p>One of the other things I'd like to smooth over is keeping track of
who owes whom e-mail... &#60;laugh&#62;</p>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/bbdb" rel="tag">bbdb</a>, <a href="http://www.technorati.com/tag/pimpmyemacs" rel="tag">pimpmyemacs</a>, <a href="http://www.technorati.com/tag/planner" rel="tag">planner</a>, <a href="http://www.technorati.com/tag/networking" rel="tag">networking</a>, <a href="http://www.technorati.com/tag/hack" rel="tag">hack</a>, <a href="http://www.technorati.com/tag/elisp" rel="tag">elisp</a></p>
]]></description>
			<content:encoded><![CDATA[<p>One of the things I want in a contact management system is a quick way
to find out who I haven't pinged in a while. The following code
filters currently-displayed contacts to show who I might want to get
back in touch with. Call it from a *BBDB* window and specify the date
(could be 2006.01.01 for annual, -7 for the last seven days, etc.).
This works incredibly well with the following hacks:</p>

<ul>
<li><a href="http://sachachua.com/notebook/wiki/2006.09.01.php#anchor-2">Emacs: Keep track of messages sent</a></li>
<li><a href="http://sachachua.com/notebook/wiki/2006.06.03.php#anchor-5">BBDB pinging code</a></li>
</ul>

<p>I should write a small book about how to build a contact management
system with Emacs. ;) It's insanely powerful, you know.</p>

<pre class="example">
(require 'planner)
(require 'bbdb)
(defun sacha/bbdb-show-only-no-contact-since (date)
  "Show only people who haven't been pinged since DATE or at all."
  (interactive (list (planner-read-date)))
  (let ((records bbdb-records)
        new-records
        last-match
        omit
        notes)
    (while records
      ;; Find the latest date mentioned in the entry
      (setq notes (or (bbdb-record-notes (caar records)) ""))
      (setq last-match nil omit nil)
      (while (string-match
              "[0-9][0-9][0-9][0-9]\\.[0-9][0-9]\\.[0-9][0-9]"
              notes
              (or last-match 0))
        (unless (string> date (match-string 0 notes))
          (setq omit t)
          (setq last-match (length notes)))
        (setq last-match (match-end 0)))
      (unless (and last-match omit)
        (add-to-list 'new-records (caar records) t))
      (setq records (cdr records)))
    (bbdb-display-records new-records)))
</pre>

<p>One of the other things I'd like to smooth over is keeping track of
who owes whom e-mail... &lt;laugh&gt;</p>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/bbdb" rel="tag">bbdb</a>, <a href="http://www.technorati.com/tag/pimpmyemacs" rel="tag">pimpmyemacs</a>, <a href="http://www.technorati.com/tag/planner" rel="tag">planner</a>, <a href="http://www.technorati.com/tag/networking" rel="tag">networking</a>, <a href="http://www.technorati.com/tag/hack" rel="tag">hack</a>, <a href="http://www.technorati.com/tag/elisp" rel="tag">elisp</a></p>
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2006/09/28/emacs-show-only-people-whom-i-havent-pinged-since/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Emacs BBDB magic: Greeting people with nicknames</title>
		<link>http://sachachua.com/wp/2006/07/20/emacs-bbdb-magic-greeting-people-with-nicknames/</link>
		<comments>http://sachachua.com/wp/2006/07/20/emacs-bbdb-magic-greeting-people-with-nicknames/#comments</comments>
		<pubDate>Thu, 20 Jul 2006 17:06:00 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[code]]></category>

		<category><![CDATA[elisp]]></category>

		<category><![CDATA[emacs]]></category>

		<category><![CDATA[gnus]]></category>

		<guid isPermaLink="false">http://sachachua.com/notebook/wiki/2006.07.20.php#anchor-1</guid>
		<description><![CDATA[<p>I use Gnus to read my mail within the Emacs text editor. One of the
advantages of using a mail client that's infinitely programmable is
that you can add all sorts of little tweaks to it. Gnus can be
integrated with Emacs' Big Brother Database (BBDB), a semi-structured
text database in which I store all sorts of weird notes. This little
hack takes the nick field of the database and automatically inserts a
greeting. If someone signs himself as Mikong, I should call him that
instead of Joseph Michael. Similarly, I sign my messages as Sacha, not
Sandra Jean. This little tidbit makes it easier to remember to call
people by their nicknames.</p>

<pre class="example">
(defun sacha/gnus-add-nick-to-message ()
  "Inserts \"Hello, NICK!\" in messages based on the recipient's nick field."
  (interactive)
  (save-excursion
    (let ((bbdb-get-addresses-headers (list (assoc 'recipients bbdb-get-addresses-headers)))
          nicks)
      (setq nicks
            (delq nil
                  (mapcar (lambda (rec) (bbdb-record-getprop rec 'nick))
                          (bbdb-update-records
                           (bbdb-get-addresses nil gnus-ignored-from-addresses 'gnus-fetch-field)
                           nil
                           nil))))
      (goto-char (point-min))
      (when (and nicks
                 (re-search-forward "--text follows this line--" nil t))
        (forward-line 1)
        (insert "Hello, "
                (mapconcat 'identity nicks ", ")
                "!\n\n")))))

(defadvice gnus-post-news (after sacha activate)
  (sacha/gnus-add-nick-to-message))
</pre>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/gnus" rel="tag">gnus</a>, <a href="http://www.technorati.com/tag/code" rel="tag">code</a>, <a href="http://www.technorati.com/tag/elisp" rel="tag">elisp</a></p>

<p>Random Japanese sentence: ÃƒÂ¨Ã‚Â™Ã‚ÂŽÃƒÂ£Ã‚Â‚Ã‚Â’ÃƒÂ¥Ã‚Â¤Ã‚Â§ÃƒÂ£Ã‚ÂÃ‚ÂÃƒÂ£Ã‚ÂÃ‚ÂªÃƒÂ§Ã‚ÂŒÃ‚Â«ÃƒÂ£Ã‚ÂÃ‚Â¨ÃƒÂ£Ã‚ÂÃ‚Â„ÃƒÂ£Ã‚ÂÃ‚Â†ÃƒÂ£Ã‚ÂÃ‚ÂªÃƒÂ£Ã‚Â‚Ã‚Â‰ÃƒÂ£Ã‚Â€Ã‚ÂÃƒÂ¥Ã‚ÂÃ‚ÂŒÃƒÂ£Ã‚ÂÃ‚Â˜ÃƒÂ£Ã‚Â‚Ã‚ÂˆÃƒÂ£Ã‚ÂÃ‚Â†ÃƒÂ£Ã‚ÂÃ‚Â«ÃƒÂ§Ã‚ÂŒÃ‚Â«ÃƒÂ£Ã‚Â‚Ã‚Â’ÃƒÂ¥Ã‚Â°Ã‚ÂÃƒÂ£Ã‚ÂÃ‚Â•ÃƒÂ£Ã‚ÂÃ‚ÂªÃƒÂ¨Ã‚Â™Ã‚ÂŽÃƒÂ£Ã‚ÂÃ‚Â¨ÃƒÂ£Ã‚ÂÃ‚Â„ÃƒÂ£Ã‚ÂÃ‚Â£ÃƒÂ£Ã‚ÂÃ‚Â¦ÃƒÂ£Ã‚Â‚Ã‚Â‚ÃƒÂ£Ã‚Â‚Ã‚ÂˆÃƒÂ£Ã‚ÂÃ‚Â„ÃƒÂ£Ã‚Â€Ã‚Â‚	You may as well call a cat a small tiger as call a tiger a big cat.</p>
]]></description>
			<content:encoded><![CDATA[<p>I use Gnus to read my mail within the Emacs text editor. One of the
advantages of using a mail client that's infinitely programmable is
that you can add all sorts of little tweaks to it. Gnus can be
integrated with Emacs' Big Brother Database (BBDB), a semi-structured
text database in which I store all sorts of weird notes. This little
hack takes the nick field of the database and automatically inserts a
greeting. If someone signs himself as Mikong, I should call him that
instead of Joseph Michael. Similarly, I sign my messages as Sacha, not
Sandra Jean. This little tidbit makes it easier to remember to call
people by their nicknames.</p>

<pre class="example">
(defun sacha/gnus-add-nick-to-message ()
  "Inserts \"Hello, NICK!\" in messages based on the recipient's nick field."
  (interactive)
  (save-excursion
    (let ((bbdb-get-addresses-headers (list (assoc 'recipients bbdb-get-addresses-headers)))
          nicks)
      (setq nicks
            (delq nil
                  (mapcar (lambda (rec) (bbdb-record-getprop rec 'nick))
                          (bbdb-update-records
                           (bbdb-get-addresses nil gnus-ignored-from-addresses 'gnus-fetch-field)
                           nil
                           nil))))
      (goto-char (point-min))
      (when (and nicks
                 (re-search-forward "--text follows this line--" nil t))
        (forward-line 1)
        (insert "Hello, "
                (mapconcat 'identity nicks ", ")
                "!\n\n")))))

(defadvice gnus-post-news (after sacha activate)
  (sacha/gnus-add-nick-to-message))
</pre>

<p>On Technorati: <a href="http://www.technorati.com/tag/emacs" rel="tag">emacs</a>, <a href="http://www.technorati.com/tag/gnus" rel="tag">gnus</a>, <a href="http://www.technorati.com/tag/code" rel="tag">code</a>, <a href="http://www.technorati.com/tag/elisp" rel="tag">elisp</a></p>

<p>Random Japanese sentence: ÃƒÂ¨Ã‚Â™Ã‚ÂŽÃƒÂ£Ã‚Â‚Ã‚Â’ÃƒÂ¥Ã‚Â¤Ã‚Â§ÃƒÂ£Ã‚ÂÃ‚ÂÃƒÂ£Ã‚ÂÃ‚ÂªÃƒÂ§Ã‚ÂŒÃ‚Â«ÃƒÂ£Ã‚ÂÃ‚Â¨ÃƒÂ£Ã‚ÂÃ‚Â„ÃƒÂ£Ã‚ÂÃ‚Â†ÃƒÂ£Ã‚ÂÃ‚ÂªÃƒÂ£Ã‚Â‚Ã‚Â‰ÃƒÂ£Ã‚Â€Ã‚ÂÃƒÂ¥Ã‚ÂÃ‚ÂŒÃƒÂ£Ã‚ÂÃ‚Â˜ÃƒÂ£Ã‚Â‚Ã‚ÂˆÃƒÂ£Ã‚ÂÃ‚Â†ÃƒÂ£Ã‚ÂÃ‚Â«ÃƒÂ§Ã‚ÂŒÃ‚Â«ÃƒÂ£Ã‚Â‚Ã‚Â’ÃƒÂ¥Ã‚Â°Ã‚ÂÃƒÂ£Ã‚ÂÃ‚Â•ÃƒÂ£Ã‚ÂÃ‚ÂªÃƒÂ¨Ã‚Â™Ã‚ÂŽÃƒÂ£Ã‚ÂÃ‚Â¨ÃƒÂ£Ã‚ÂÃ‚Â„ÃƒÂ£Ã‚ÂÃ‚Â£ÃƒÂ£Ã‚ÂÃ‚Â¦ÃƒÂ£Ã‚Â‚Ã‚Â‚ÃƒÂ£Ã‚Â‚Ã‚ÂˆÃƒÂ£Ã‚ÂÃ‚Â„ÃƒÂ£Ã‚Â€Ã‚Â‚	You may as well call a cat a small tiger as call a tiger a big cat.</p>
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2006/07/20/emacs-bbdb-magic-greeting-people-with-nicknames/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
