1 ;;; lsdb.el --- the Lovely Sister Database
3 ;; Copyright (C) 2002 Daiki Ueno
5 ;; Author: Daiki Ueno <ueno@unixuser.org>
6 ;; Keywords: adress book
8 ;; This file is part of the Lovely Sister Database.
10 ;; This program is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or (at
13 ;; your option) any later version.
15 ;; This program is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with this program; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
28 ;;; (autoload 'lsdb-gnus-insinuate "lsdb")
29 ;;; (autoload 'lsdb-gnus-insinuate-message "lsdb")
30 ;;; (add-hook 'gnus-startup-hook 'lsdb-gnus-insinuate)
31 ;;; (add-hook 'message-setup-hook
33 ;;; (define-key message-mode-map "\M-\t" 'lsdb-complete-name)))
35 ;;; For Wanderlust, put the following lines into your ~/.wl:
37 ;;; (lsdb-wl-insinuate)
38 ;;; (add-hook 'wl-draft-mode-hook
40 ;;; (define-key wl-draft-mode-map "\M-\t" 'lsdb-complete-name)))
47 ;;;_* USER CUSTOMIZATION VARIABLES:
49 "The Lovely Sister Database."
53 (defcustom lsdb-file (expand-file-name "~/.lsdb")
54 "The name of the Lovely Sister Database file."
58 (defcustom lsdb-file-coding-system 'iso-2022-jp
59 "Coding system for `lsdb-file'."
63 (defcustom lsdb-sender-headers
65 "List of headers to search for senders."
69 (defcustom lsdb-recipients-headers
70 "Resent-To\\|Resent-Cc\\|Reply-To\\|To\\|Cc\\|Bcc"
71 "List of headers to search for recipients."
75 (defcustom lsdb-interesting-header-alist
76 '(("Organization" nil organization)
77 ("\\(X-\\)?User-Agent\\|X-Mailer" nil user-agent)
78 ("\\(X-\\)?ML-Name" nil mailing-list)
79 ("\\(X-URL\\|X-URI\\)" nil www)
80 ("X-Attribution\\|X-cite-me" nil attribution)
81 ("X-Face" nil x-face))
82 "Alist of headers we are interested in.
83 The format of elements of this list should be
84 (FIELD-NAME REGEXP ENTRY STRING)
85 where the last three elements are optional."
89 (defcustom lsdb-entry-type-alist
99 "Alist of entries to display.
100 The format of elements of this list should be
102 where the last element is optional."
106 (defcustom lsdb-decode-field-body-function #'lsdb-decode-field-body
107 "Field body decoder."
111 (defcustom lsdb-canonicalize-full-name-function
112 #'lsdb-canonicalize-spaces-and-dots
113 "Way to canonicalize full name."
117 (defcustom lsdb-print-record-function
119 "Function to print LSDB record."
123 (defcustom lsdb-window-max-height 7
124 "Maximum number of lines used to display LSDB record."
128 (defcustom lsdb-insert-x-face-function
129 (if (and (>= emacs-major-version 21)
130 (locate-library "x-face-e21"))
131 #'lsdb-insert-x-face-with-x-face-e21)
132 "Function to display X-Face."
136 (defcustom lsdb-display-record-hook
137 (if lsdb-insert-x-face-function
138 #'lsdb-expose-x-face)
139 "A hook called after a record is displayed."
143 (defgroup lsdb-edit-form nil
144 "A mode for editing forms."
147 (defcustom lsdb-edit-form-mode-hook nil
148 "Hook run in `lsdb-edit-form-mode' buffers."
149 :group 'lsdb-edit-form
153 (defface lsdb-header-face
154 '((t (:underline t)))
155 "Face for the file header line in `lsdb-mode'."
157 (defvar lsdb-header-face 'lsdb-header-face)
159 (defface lsdb-field-name-face
160 '((((class color) (background dark))
161 (:foreground "PaleTurquoise" :bold t))
163 "Face for the message header line in `lsdb-mode'."
165 (defvar lsdb-field-name-face 'lsdb-field-name-face)
167 (defface lsdb-field-body-face
168 '((((class color) (background dark))
169 (:foreground "turquoise" :italic t))
171 "Face for the message header line in `lsdb-mode'."
173 (defvar lsdb-field-body-face 'lsdb-field-body-face)
175 (defconst lsdb-font-lock-keywords
177 (0 lsdb-header-face))
179 (0 lsdb-field-body-face))
180 ("^\t\\([^\t:]+:\\)[ \t]*\\(.*\\)$"
181 (1 lsdb-field-name-face)
182 (2 lsdb-field-body-face))))
184 (put 'lsdb-mode 'font-lock-defaults '(lsdb-font-lock-keywords t))
186 ;;;_* CODE - no user customizations below
187 (defvar lsdb-hash-table nil
188 "Internal hash table to hold LSDB records.")
190 (defvar lsdb-buffer-name "*LSDB*"
191 "Buffer name to display LSDB record.")
193 (defvar lsdb-hash-table-is-dirty nil
194 "Flag to indicate whether the hash table needs to be saved.")
196 ;;;_. Hash Table Emulation
197 (if (fboundp 'make-hash-table)
199 (defalias 'lsdb-puthash 'puthash)
200 (defalias 'lsdb-gethash 'gethash)
201 (defalias 'lsdb-remhash 'remhash)
202 (defalias 'lsdb-maphash 'maphash)
203 (defalias 'lsdb-hash-table-size 'hash-table-size)
204 (defalias 'lsdb-hash-table-count 'hash-table-count)
205 (defalias 'lsdb-make-hash-table 'make-hash-table))
206 (defun lsdb-puthash (key value hash-table)
207 "Hash KEY to VALUE in HASH-TABLE."
208 ;; Obarray is regarded as an open hash table, as a matter of
209 ;; fact, rehashing doesn't make sense.
211 (when (> (car hash-table)
212 (* (length (nth 1 hash-table)) 0.7))
213 (setq new-obarray (make-vector (* (length (nth 1 hash-table)) 2) 0))
216 (set (intern (symbol-name symbol) new-obarray)
217 (symbol-value symbol)))
219 (setcdr hash-table (list new-obarray)))
220 (set (intern key (nth 1 hash-table)) value)
221 (setcar hash-table (1+ (car hash-table)))))
222 (defun lsdb-gethash (key hash-table &optional default)
223 "Find hash value for KEY in HASH-TABLE.
224 If there is no corresponding value, return DEFAULT (which defaults to nil)."
225 (let ((symbol (intern-soft key (nth 1 hash-table))))
227 (symbol-value symbol)
229 (defun lsdb-remhash (key hash-table)
230 "Remove the entry for KEY from HASH-TABLE.
231 Do nothing if there is no entry for KEY in HASH-TABLE."
232 (unintern key (nth 1 hash-table))
233 (setcar hash-table (1- (car hash-table))))
234 (defun lsdb-maphash (function hash-table)
235 "Map FUNCTION over entries in HASH-TABLE, calling it with two args,
236 each key and value in HASH-TABLE.
238 FUNCTION may not modify HASH-TABLE, with the one exception that FUNCTION
239 may remhash or puthash the entry currently being processed by FUNCTION."
242 (funcall function (symbol-name symbol) (symbol-value symbol)))
244 (defun lsdb-hash-table-size (hash-table)
245 "Return the size of HASH-TABLE.
246 This is the current number of slots in HASH-TABLE, whether occupied or not."
247 (length (nth 1 hash-table)))
248 (defalias 'lsdb-hash-table-count 'car)
249 (defun lsdb-make-hash-table (&rest args)
250 "Return a new empty hash table object."
251 (list 0 (make-vector (or (plist-get args :size) 29) 0))))
253 ;;;_. Hash Table Reader/Writer
257 ;; In XEmacs, hash tables can also be created by the lisp reader
258 ;; using structure syntax.
259 (read-from-string "#s(hash-table)")
260 (defun lsdb-load-file (file)
261 "Read the contents of FILE into a hash table."
263 (set-buffer (find-file-noselect file))
264 (re-search-forward "^#s")
266 (read (point-min-marker)))))
268 (defun lsdb-load-file (file)
269 "Read the contents of FILE into a hash table."
272 (insert-file-contents file)
274 (re-search-forward "^#s")
277 (cdr (read (point-marker))))))
278 (size (plist-get plist 'size))
279 (data (plist-get plist 'data))
280 (hash-table (lsdb-make-hash-table :size size :test 'equal)))
282 (lsdb-puthash (pop data) (pop data) hash-table))
285 (defun lsdb-save-file (file hash-table)
286 "Write the entries within HASH-TABLE into FILE."
287 (let ((coding-system-for-write lsdb-file-coding-system))
289 (if (and (or (featurep 'mule)
290 (featurep 'file-coding))
291 lsdb-file-coding-system)
292 (insert ";;; -*- coding: "
293 (if (symbolp lsdb-file-coding-system)
294 (symbol-name lsdb-file-coding-system)
296 (coding-system-name lsdb-file-coding-system))
298 (insert "#s(hash-table size "
299 (number-to-string (lsdb-hash-table-size hash-table))
300 " test equal data (")
303 (insert (prin1-to-string key) " " (prin1-to-string value) " "))
307 ;;;_. Mail Header Extraction
308 (defun lsdb-fetch-field-bodies (regexp)
310 (goto-char (point-min))
311 (let ((case-fold-search t)
313 (while (re-search-forward (concat "^\\(" regexp "\\):[ \t]*")
315 (push (funcall lsdb-decode-field-body-function
316 (buffer-substring (point) (std11-field-end))
319 (nreverse field-bodies))))
321 (defun lsdb-canonicalize-spaces-and-dots (string)
322 (while (string-match " +\\|[\f\t\n\r\v]+\\|\\." string)
323 (setq string (replace-match " " nil t string)))
326 (defun lsdb-extract-address-components (string)
327 (let ((components (std11-extract-address-components string)))
328 (if (nth 1 components)
330 (list (nth 1 components)
331 (funcall lsdb-canonicalize-full-name-function
333 (list (nth 1 components) (nth 1 components))))))
335 ;; stolen (and renamed) from nnheader.el
336 (defun lsdb-decode-field-body (field-body field-name
337 &optional mode max-column)
338 (let ((multibyte enable-multibyte-characters))
341 (set-buffer-multibyte t)
342 (mime-decode-field-body field-body
343 (if (stringp field-name)
344 (intern (capitalize field-name))
347 (set-buffer-multibyte multibyte))))
349 ;;;_. Record Management
350 (defun lsdb-maybe-load-file ()
351 (unless lsdb-hash-table
352 (if (file-exists-p lsdb-file)
353 (setq lsdb-hash-table (lsdb-load-file lsdb-file))
354 (setq lsdb-hash-table (lsdb-make-hash-table :test 'equal)))))
356 (defun lsdb-update-record (sender &optional interesting)
357 (let ((old (lsdb-gethash (nth 1 sender) lsdb-hash-table))
358 (new (cons (cons 'net (list (car sender)))
363 (setq new (cons (cons 'creation-date (format-time-string "%Y-%m-%d"))
365 (setq merged (lsdb-merge-record-entries old new)
366 record (cons (nth 1 sender) merged))
367 (unless (equal merged old)
368 (let ((entry (assq 'last-modified (cdr record)))
369 (last-modified (format-time-string "%Y-%m-%d")))
371 (setcdr entry last-modified)
372 (setcdr record (cons (cons 'last-modified last-modified)
374 (lsdb-puthash (car record) (cdr record)
376 (setq lsdb-hash-table-is-dirty t))
379 (defun lsdb-update-records ()
380 (lsdb-maybe-load-file)
381 (let (senders recipients interesting alist records bodies entry)
383 (std11-narrow-to-header)
385 (delq nil (mapcar #'lsdb-extract-address-components
386 (lsdb-fetch-field-bodies
387 lsdb-sender-headers)))
389 (delq nil (mapcar #'lsdb-extract-address-components
390 (lsdb-fetch-field-bodies
391 lsdb-recipients-headers))))
392 (setq alist lsdb-interesting-header-alist)
397 (if (and (nth 1 (car alist))
398 (string-match (nth 1 (car alist)) field-body))
399 (replace-match (nth 3 (car alist)) nil nil field-body)
401 (lsdb-fetch-field-bodies (car (car alist)))))
403 (setq entry (or (nth 2 (car alist))
406 (if (eq ?. (nth 2 (assq entry lsdb-entry-type-alist)))
410 (setq alist (cdr alist))))
412 (setq records (list (lsdb-update-record (pop senders) interesting))))
413 (setq alist (nconc senders recipients))
415 (setq records (cons (lsdb-update-record (pop alist)) records)))
418 (defun lsdb-merge-record-entries (old new)
419 (setq old (copy-sequence old))
421 (let ((entry (assq (car (car new)) old))
424 (setq old (nconc old (list (car new))))
425 (if (listp (cdr entry))
427 (setq list (cdr (car new)) pointer list)
429 (if (member (car pointer) (cdr entry))
430 (setq list (delq (car pointer) list)))
431 (setq pointer (cdr pointer)))
432 (setcdr entry (nconc (cdr entry) list)))
433 (setcdr entry (cdr (car new))))))
434 (setq new (cdr new)))
437 ;;;_. Display Management
438 (defun lsdb-temp-buffer-show-function (buffer)
439 (save-selected-window
440 (let ((window (or (get-buffer-window lsdb-buffer-name)
442 (select-window (get-largest-window))
443 (split-window-vertically))))
445 (set-window-buffer window buffer)
446 (select-window window)
447 (unless (pos-visible-in-window-p (point-max))
448 (enlarge-window (- lsdb-window-max-height (window-height))))
449 (shrink-window-if-larger-than-buffer)
450 (if (> (setq height (window-height))
451 lsdb-window-max-height)
452 (shrink-window (- height lsdb-window-max-height))
453 (shrink-window-if-larger-than-buffer)))))
455 (defun lsdb-display-record (record)
456 "Display only one RECORD, then shrink the window as possible."
457 (let ((temp-buffer-show-function
458 (function lsdb-temp-buffer-show-function)))
459 (lsdb-display-records (list record))))
461 (defun lsdb-display-records (records)
462 (with-output-to-temp-buffer lsdb-buffer-name
463 (set-buffer standard-output)
466 (narrow-to-region (point) (point))
467 (funcall lsdb-print-record-function (car records))
468 (add-text-properties (point-min) (point-max)
469 (list 'lsdb-record (car records)))
470 (run-hooks 'lsdb-display-record-hook))
471 (setq records (cdr records)))
474 (defsubst lsdb-entry-score (entry)
475 (or (nth 1 (assq (car entry) lsdb-entry-type-alist)) 0))
477 (defun lsdb-insert-entry (entry)
478 (insert "\t" (capitalize (symbol-name (car entry))) ": "
479 (if (listp (cdr entry))
481 #'identity (cdr entry)
482 (if (eq ?, (nth 2 (assq (car entry) lsdb-entry-type-alist)))
488 (defun lsdb-print-record (record)
489 (insert (car record) "\n")
491 (sort (copy-sequence (cdr record))
492 (lambda (entry1 entry2)
493 (> (lsdb-entry-score entry1) (lsdb-entry-score entry2))))))
495 (if (>= (lsdb-entry-score (car entries)) 0)
496 (lsdb-insert-entry (car entries)))
497 (setq entries (cdr entries)))))
500 (defvar lsdb-last-completion nil)
501 (defvar lsdb-last-candidates nil)
502 (defvar lsdb-last-candidates-pointer nil)
504 (defun lsdb-complete-name ()
505 "Complete the user full-name or net-address before point"
507 (lsdb-maybe-load-file)
510 (re-search-backward "\\(\\`\\|[\n:,]\\)[ \t]*")
511 (goto-char (match-end 0))
515 (completion-ignore-case t))
516 (unless (eq last-command this-command)
517 (setq lsdb-last-candidates nil
518 lsdb-last-candidates-pointer nil
519 lsdb-last-completion (buffer-substring start (point))
520 pattern (concat "\\<" lsdb-last-completion))
523 (let ((net (cdr (assq 'net value))))
524 (if (string-match pattern key)
525 (setq lsdb-last-candidates
526 (nconc lsdb-last-candidates
527 (mapcar (lambda (address)
528 (if (equal key address)
530 (concat key " <" address ">")))
533 (if (string-match pattern (car net))
534 (push (car net) lsdb-last-candidates))
535 (setq net (cdr net))))))
537 (unless lsdb-last-candidates-pointer
538 (setq lsdb-last-candidates-pointer lsdb-last-candidates))
539 (when lsdb-last-candidates-pointer
540 (delete-region start (point))
541 (insert (pop lsdb-last-candidates-pointer)))))
543 ;;;_. Major Mode (`lsdb-mode') Implementation
544 (defvar lsdb-mode-map
545 (let ((keymap (make-sparse-keymap)))
546 (define-key keymap "a" 'lsdb-mode-add-entry)
547 (define-key keymap "d" 'lsdb-mode-delete-entry)
548 (define-key keymap "e" 'lsdb-mode-edit-entry)
549 (define-key keymap "s" 'lsdb-mode-save)
550 (define-key keymap "q" 'lsdb-mode-quit-window)
554 (if (commandp 'quit-window)
555 (defalias 'lsdb-mode-quit-window 'quit-window)
556 (defun lsdb-mode-quit-window ()
562 (define-derived-mode lsdb-mode fundamental-mode "LSDB"
563 "Major mode for browsing LSDB records."
564 (setq buffer-read-only t)
565 (if (featurep 'xemacs)
566 ;; In XEmacs, setting `font-lock-defaults' only affects on
567 ;; `find-file-hooks'.
568 (font-lock-set-defaults)
569 (set (make-local-variable 'font-lock-defaults)
570 '(lsdb-font-lock-keywords t))))
572 (defun lsdb-narrow-to-record ()
574 (or (previous-single-property-change (point) 'lsdb-record)
576 (or (next-single-property-change (point) 'lsdb-record)
579 (defun lsdb-current-entry ()
582 (if (looking-at "^[^\t]")
583 (let ((record (get-text-property (point) 'lsdb-record))
584 (completion-ignore-case t))
586 "Which entry to edit: "
587 (mapcar (lambda (entry)
588 (list (capitalize (symbol-name (car entry)))))
591 (re-search-backward "^\t\\([^\t][^:]+\\):")
594 (defun lsdb-mode-add-entry (entry-name)
595 "Add an entry on the current line."
596 (interactive "sEntry name: ")
598 (unless (symbolp entry-name)
599 (setq entry-name (intern (downcase entry-name))))
600 (when (assq entry-name (cdr (get-text-property (point) 'lsdb-record)))
601 (error "The entry already exists"))
602 (let ((marker (point-marker)))
604 nil "Editing the entry."
608 (set-buffer lsdb-buffer-name)
611 (let* ((record (get-text-property (point) 'lsdb-record))
612 (inhibit-read-only t)
614 (setcdr record (cons (cons ',entry-name form) (cdr record)))
615 (lsdb-puthash (car record) (cdr record)
617 (setq lsdb-hash-table-is-dirty t)
622 (lsdb-insert-entry (cons ',entry-name form))
624 (list 'lsdb-record record)))))))))
626 (defun lsdb-mode-delete-entry (&optional entry-name dont-update)
627 "Delete the entry on the current line."
629 (let ((record (get-text-property (point) 'lsdb-record))
632 (setq entry-name (lsdb-current-entry)))
633 (setq entry (assq (intern (downcase entry-name)) (cdr record)))
636 (setcdr record (delq entry (cdr record)))
637 (lsdb-puthash (car record) (cdr record)
639 (setq lsdb-hash-table-is-dirty t))
641 (lsdb-narrow-to-record)
642 (let ((case-fold-search t)
643 (inhibit-read-only t)
645 (goto-char (point-min))
646 (if (re-search-forward
647 (concat "^\t" (or entry-name
648 (lsdb-current-entry))
651 (delete-region (match-beginning 0)
652 (if (re-search-forward
653 "^\t[^\t][^:]+:" nil t)
657 (defun lsdb-mode-edit-entry ()
658 "Edit the entry on the current line."
660 (let* ((record (get-text-property (point) 'lsdb-record))
661 (entry-name (intern (downcase (lsdb-current-entry))))
662 (entry (assq entry-name (cdr record)))
663 (marker (point-marker)))
665 (cdr entry) "Editing the entry."
667 (unless (equal form ',entry-name)
669 (set-buffer lsdb-buffer-name)
671 (let* ((record (get-text-property (point) 'lsdb-record))
672 (entry (assq ',entry-name (cdr record)))
673 (inhibit-read-only t)
676 (setq lsdb-hash-table-is-dirty t)
677 (lsdb-mode-delete-entry (symbol-name ',entry-name) t)
682 (lsdb-insert-entry (cons ',entry-name form))
684 (list 'lsdb-record record)))))))))
686 (defun lsdb-mode-save ()
688 (if (and lsdb-hash-table-is-dirty
690 (y-or-n-p "Save the LSDB now?")))
691 (lsdb-save-file lsdb-file lsdb-hash-table)))
693 ;;;_ : Edit Forms -- stolen (and renamed) from gnus-eform.el
694 (defvar lsdb-edit-form-buffer "*LSDB edit form*")
695 (defvar lsdb-edit-form-done-function nil)
696 (defvar lsdb-previous-window-configuration nil)
698 (defvar lsdb-edit-form-mode-map
699 (let ((keymap (make-sparse-keymap)))
700 (set-keymap-parent keymap emacs-lisp-mode-map)
701 (define-key keymap "\C-c\C-c" 'lsdb-edit-form-done)
702 (define-key keymap "\C-c\C-k" 'lsdb-edit-form-exit)
704 "Edit form's keymap.")
706 (defun lsdb-edit-form-mode ()
707 "Major mode for editing forms.
708 It is a slightly enhanced emacs-lisp-mode.
710 \\{lsdb-edit-form-mode-map}"
712 (kill-all-local-variables)
713 (setq major-mode 'lsdb-edit-form-mode
714 mode-name "LSDB Edit Form")
715 (use-local-map lsdb-edit-form-mode-map)
716 (make-local-variable 'lsdb-edit-form-done-function)
717 (make-local-variable 'lsdb-previous-window-configuration)
718 (run-hooks 'lsdb-edit-form-mode-hook))
720 (defun lsdb-edit-form (form documentation exit-func)
721 "Edit FORM in a new buffer.
722 Call EXIT-FUNC on exit. Display DOCUMENTATION in the beginning
724 (let ((window-configuration
725 (current-window-configuration)))
726 (switch-to-buffer (get-buffer-create lsdb-edit-form-buffer))
727 (lsdb-edit-form-mode)
728 (setq lsdb-previous-window-configuration window-configuration
729 lsdb-edit-form-done-function exit-func)
731 (insert documentation)
734 (goto-char (point-min))
738 (insert ";; Type `C-c C-c' after you've finished editing.\n")
741 (pp form (current-buffer))
745 (defun lsdb-edit-form-done ()
746 "Update changes and kill the current buffer."
748 (goto-char (point-min))
749 (let ((form (condition-case nil
750 (read (current-buffer))
752 (func lsdb-edit-form-done-function))
753 (lsdb-edit-form-exit)
754 (funcall func form)))
756 (defun lsdb-edit-form-exit ()
757 "Kill the current buffer."
759 (let ((window-configuration lsdb-previous-window-configuration))
760 (kill-buffer (current-buffer))
761 (set-window-configuration window-configuration)))
763 ;;;_. Interface to Semi-gnus
765 (defun lsdb-gnus-insinuate ()
766 "Call this function to hook LSDB into Semi-gnus."
767 (add-hook 'gnus-article-prepare-hook 'lsdb-gnus-update-record)
768 (add-hook 'gnus-save-newsrc-hook 'lsdb-mode-save))
770 (defvar gnus-current-headers)
771 (defun lsdb-gnus-update-record ()
772 (let ((entity gnus-current-headers)
775 (set-buffer-multibyte nil)
776 (buffer-disable-undo)
777 (mime-insert-entity entity)
778 (setq records (lsdb-update-records))
780 (lsdb-display-record (car records))))))
782 ;;;_. Interface to Wanderlust
783 (defun lsdb-wl-insinuate ()
784 "Call this function to hook LSDB into Wanderlust."
785 (add-hook 'wl-message-redisplay-hook 'lsdb-wl-update-record)
786 (add-hook 'wl-summary-exit-hook 'lsdb-wl-hide-buffer)
787 (add-hook 'wl-exit-hook 'lsdb-mode-save))
789 (defun lsdb-wl-update-record ()
791 (set-buffer (wl-message-get-original-buffer))
792 (let ((records (lsdb-update-records)))
794 (lsdb-display-record (car records))))))
796 (defun lsdb-wl-hide-buffer ()
797 (let ((window (get-buffer-window lsdb-buffer-name)))
799 (delete-window window))))
801 ;;;_. X-Face Rendering
802 (defun lsdb-expose-x-face ()
803 (let* ((record (get-text-property (point-min) 'lsdb-record))
804 (x-face (cdr (assq 'x-face (cdr record)))))
805 (when (and lsdb-insert-x-face-function
807 (goto-char (point-min))
809 (insert (propertize "\r" 'invisible t) " ")
811 (funcall lsdb-insert-x-face-function (pop x-face))))))
813 ;; stolen (and renamed) from gnus-summary-x-face.el written by Akihiro Arisawa.
814 (defvar lsdb-x-face-scale-factor 0.5
815 "A number of scale factor used to scale down X-face image.
816 See also `x-face-scale-factor'.")
818 (defun lsdb-insert-x-face-with-x-face-e21 (x-face)
819 (require 'x-face-e21)
820 (insert-image (x-face-create-image
821 x-face :scale-factor lsdb-x-face-scale-factor)))
825 ;;;_* Local emacs vars.
826 ;;; The following `outline-layout' local variable setting:
827 ;;; - closes all topics from the first topic to just before the third-to-last,
828 ;;; - shows the children of the third to last (config vars)
829 ;;; - and the second to last (code section),
830 ;;; - and closes the last topic (this local-variables section).
832 ;;;outline-layout: (0 : -1 -1 0)
835 ;;; lsdb.el ends here