1 ;;; mew-fib.el --- Filling blanks for Mew
3 ;; Author: Yoshinari NOMURA <nom@csce.kyushu-u.ac.jp>
4 ;; Created: Nov 29, 1994
5 ;; Revised: Aug 30, 1999
9 (defconst mew-fib-version "mew-fib.el version 0.12")
13 (defvar mew-fib-item-file "~/.mew-fib")
14 (defvar mew-fib-item-alist nil)
16 (defun mew-fib-split (str)
18 (while (string-match "[\t \n]*\\([^,]+\\)" str)
19 (setq match (substring str (match-beginning 1) (match-end 1))
20 str (substring str (match-end 0))
21 match (if (string-match "[\t \n]+$" match)
22 (substring match 0 (match-beginning 0))
24 ret (cons match ret)))
27 (defun mew-fib-make-alist ()
29 (let ((fib-file (expand-file-name mew-fib-item-file))
31 (setq mew-fib-item-alist nil)
33 (if (file-exists-p fib-file)
34 (insert-file-contents fib-file))
35 (goto-char (point-min))
36 (delete-matching-lines "^[ \t]*[;#%]")
37 (while (re-search-forward "^\\([^:]+\\):[ \t]*\\(.*\\)$" nil t)
38 (setq item (buffer-substring (match-beginning 1) (match-end 1))
39 tmp-val (buffer-substring (match-beginning 2) (match-end 2))
40 val (if (string= tmp-val "") val tmp-val)
41 ret (append ret (mapcar (function (lambda (arg)
42 (cons (downcase arg) val)))
43 (mew-fib-split item)))))
46 (defun mew-fib-fill-default ()
47 "Fill |>item<| according to the information from .mew-fib"
51 (setq mew-fib-item-alist (mew-fib-make-alist))
52 (goto-char (point-min))
53 (while (re-search-forward "|>\\([^<]+\\)<|" nil t)
54 (setq begin (match-beginning 1)
56 str (buffer-substring begin end))
57 (delete-region begin end)
59 (insert (or (cdr (assoc (downcase str) mew-fib-item-alist)) str)))
62 (defun mew-fib-delete-frame ()
63 "Delete all quotations, '|>' and '<|'. This is the finishing stroke."
66 (goto-char (point-min))
67 (while (re-search-forward "|>\\|<|" nil t)
68 (replace-match "" nil t)
71 (defun mew-fib-flush-input ()
72 "Flush the fib item on the current point."
76 (if (and (search-backward "|>" nil t)
77 (looking-at "|>\\([^<]+\\)<|")
78 (>= ptr (match-beginning 1))
79 (<= ptr (match-end 1)))
80 (delete-region (match-beginning 1)
83 (defun mew-fib-next-item ()
84 "Jump to the next fib item."
86 (if (re-search-forward "|>\\([^<]+\\)<|" nil t)
88 (goto-char (point-min))
89 (re-search-forward "|>\\([^<]+\\)<|" nil t)))
91 (defun mew-fib-previous-item ()
92 "Jump to the previous fib item."
94 (if (re-search-backward "|>\\([^<]+\\)<|" nil t)
96 (goto-char (point-max))
97 (re-search-backward "|>\\([^<]+\\)<|" nil t)))
101 ;;; Copyright Notice:
103 ;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999 Mew developing team.
104 ;; All rights reserved.
106 ;; Redistribution and use in source and binary forms, with or without
107 ;; modification, are permitted provided that the following conditions
110 ;; 1. Redistributions of source code must retain the above copyright
111 ;; notice, this list of conditions and the following disclaimer.
112 ;; 2. Redistributions in binary form must reproduce the above copyright
113 ;; notice, this list of conditions and the following disclaimer in the
114 ;; documentation and/or other materials provided with the distribution.
115 ;; 3. Neither the name of the team nor the names of its contributors
116 ;; may be used to endorse or promote products derived from this software
117 ;; without specific prior written permission.
119 ;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS'' AND
120 ;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
121 ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
122 ;; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE TEAM OR CONTRIBUTORS BE
123 ;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
124 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
125 ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
126 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
127 ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
128 ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
129 ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
131 ;;; mew-fib.el ends here