c-sig-3.8.orig/ 40755 1750 1750 0 6731210011 13142 5ustar kawamurakawamurac-sig-3.8.orig/c-sig-eng.faq100644 1750 1750 12201 6731116130 15524 0ustar kawamurakawamura c-sig FAQL release 3.8 date 1999/06/10 This is FAQ list for c-sig. ---------------------------------------------------------------------- If you are reading this FAQ using emacs, type "M-2 C-x $" to see only questions. Type "C-x $" to see answer. If you want to search question using number line "X-XX", type "M-C-s ^X-XX". (If you can not find it, type "C-r".) When you find questin, type ESC to exit from search mode. ---------------------------------------------------------------------- General A-1:Documant for c-sig is really heard to understand, why? At first, I have a question. Can you understand English? If yes, sorry about that. I loundly cry "I did my best!", but I know my English is reaaaaly far from easy to understand. I suggest 3 thing. No 1 Learn Japanese Since I am Japanese, Japanese documents are much better. No 2 Make friend who can understand Japanese. Same reason with above. No 3 Send me a question in English. I promize I will try to explain with my best effort, but you may need patience like teachers in elementary school. Oh, I have one more idea. No 4 Introduce me a free and good translator. This will make everyone happy. A-2:Why FAQL for c-sig have only a few questions? Because c-sig is perfect. There are only a few questions. No, I am liar. Of course, c-sig is not perfect. I also want to know why I got only a few questions. Ha? you say there must be only a few users? I don't like you. A-3:I thought abbreviation of "signature" is "sign", why are you using "sig" instead of "sign". I don't matter it. In fact, it is none of my bussiness because "sig" of "c-sig" is not abbreviation of "signature". It is "Chaanto Signature wo Irenaito Guaiga waruizeyo". ("Too bad if you don't insert a signature properly" in Japanese.) A-4:c-sig is great. I want to make a donation to you. Please let me know your bank account. You are in bad confusion. The great thing is not c-sig, it must be GNU emacs or GNU itself. If you want to make a donation, do it to FSF! If it is hard for you to send money to US, buy any GNU products. (books, CDs or T shirts) If you can not find any of them, don't worry. You can donate source code like me. A-5:I heard c-sig is made by "shibata@sgi.co.jp" Oh, no! I have released previous version of c-sig using the address, but it is not valid now. Even it is valid, it is not my address. Please use kshibata@tky.3web.ne.jp instead. If you have question about jisx0201.el or han-kata.el, please use above address as well. (I guess no one uses these lisps though) Setting. B-1:I am using "insert-signature-automatically", but signatures appears in fixed order every time. put (random t) to ~/.emacs. B-2:I want to change strings in my signatures, but I can't. Maybe you forgot to do (setq sig-replace-string t). Put it in ~/.emacs B-3:I want to use signatures in .signature or .signature-alt. Sorry, c-sig can not use it. All signatures for c-sig need to be in database. You can import your old signatures by C-x C-i while making new signatures for c-sig using "add-signature". B-4:A signature is inserted just before current line. This is by design. If you want to insert a signature at the end of mail, set t to sig-insert-end. Advanced c-sig C-1:I want to use a random signature for specific person. At first, add "sig-get-random-signature" at the end of "sig-search-funcions" list. Add following statement to ~/.emacs. (setq sig-search-functions (list 'sig-search-name-alist 'sig-search-regexp 'sig-get-random-signature)) If you want, set list of signature names to "sig-random-sig-list". c-sig select a signature from the list, when it need to select a signature randomly. Next, modify "sig-name-alist" and "sig-regexp-alist" For example, If you want to use a random signature for kshibata@tky.3web.ne.jp, add this line to both "sig-name-alist" and "sig-regexp-alist". ("kshibata@tky.3web.ne.jp" . nil) By this, retrieval return for both learning database and reguler expression dabase will be nil, and nil means "not found". So c-sig calls final function in sig-search-functions. This modify affects to person who can not find in your database, you will see a random signature for them. (Sorry about that.) C-2:I don't want to add a signature for specific people. I know you don't want to add a signature for all mails, you should have some mail addresses which you don't send your funny (sory artistic) signature. When you are binding c-sig function to key to insert a signature. Just not type the key not to insert a signature. But if you are using hook to insert a signature... Pray God to be selected a proper signature. Or do following steps. At first make an empty signature. When you write nothing on "add-signature", you can get an empty signature. (You need to name it, even it is empty.) When an empty signature is selected, c-sig doesn't do anything. (don't add sig-separator as well.) Only exception is "sig-purge-void-lines", if you set it, blank lines at the end of mails are removed. It is what you want, right? c-sig-3.8.orig/c-sig-eng.man100644 1750 1750 43413 6731116125 15545 0ustar kawamurakawamura c-sig users guide (release 3.8 date 1999/06/10) INDEX 1. What is c-sig? 2. How to install. 3. How to use. 3.1 How to use insert-signature-eref 3.2 Learning signatures 3.3 Searching signature using regular expression 3.4 How c-sig select default signature? 3.5 Convert string in signature 4. Functions users can . 5. Variables users can change. 6. Functions users can write. 7. About distribution. 8. Afterword 1. What is c-sig? What is c-sig. In the beginning, it was just a tool for inputing a signature to mails or news. After adding many features requested my friends, now I guess c-sig is "ultra super deluxe sigature insertion tool". OK, let me explain how c-sig is ultra super deluxe. -- Easy to create signatures. c-sig has function for generating a new signature called "add-signature" and function for deleting them called "delete-signature". Users can create signatures interactively using these two functions. Also, "add-signature" can inport existing signatures while writing a new signature. -- Three insertion functions. Now c-sig has 3 insertion function. "insert-signature-eref" has dialog interface for selecting a signature. "insert-signature-automatically" selects and insert a signature using database. "insert-signature-randomly" insert a signature randomly. -- Powerful retrieval and learning function. c-sig has the function which selects a signature refering specific field using "reguler expression" Also, c-sig has the function which learns selected a signature, so users can use "wise selection function" without writting "reguler expression". -- c-sig can convert text automatically when insertion. c-sig can convert texts in your signatures when it selected. This function support random selection from list. This should be useful when users want to write "my favorit word" in their signatures. -- signatures can be modified by emacs lisp. If users want to modify a signature in more complex way than random selection. They can do it by writing filter function with emacs lisp. Using this function, users can call outer program also. So they can do almost every thing the computer can do, when they insert a signature. Now, do you agree c-sig is ultra super deluxe? No? c-sig doesn't have something you want to use? OK, please let me know what kind of feature you want (using simple and easy English.) 2. How to install At first, add following statements to set up "autoload". You don't need all of last 3, if you don't use them. You may add two more function "write-sig-file" and "read-sig-file", if you want to use them. (autoload 'add-signature "c-sig" "c-sig" t) (autoload 'delete-signature "c-sig" "c-sig" t) (autoload 'insert-signature-eref "c-sig" "c-sig" t) (autoload 'insert-signature-automatically "c-sig" "c-sig" t) (autoload 'insert-signature-randomly "c-sig" "c-sig" t) If you don't mind to type M-x insert-signature-XXXX everytime you want to insert a signature. These are enough. But you must want to bind c-sig function to keys, right? You can use global-set-key to do this, but it's not beautiful. It should be better way to use local-set-key in proper "hook". (mh-letter-mode-hook for mh-e, mail-mode-hook for rmail and news-setup-hook for gnus) If you can not understand what "local-set-key" or "hook" means, don't mind. Please ask anyone who is using same emacs tools with you. As always, this must be best way for those who don't know emacs lisp. To gnus users, gnus automatically insert a signature using . signature or .signature-*. If you want stop this, set nil to gnus-signature-file. But you should remove all existing .signature or .signature-*, I think. Now you have c-sig and c-sig can do anything without them. If you want to use function which use randomness, you may need to add (random t) to ~/.emacs or you may get everytime a same signature even you are using random function. (Newer emacs may not use this, I am not sure.) 3. How to use. 3.1 How to use insert-signature-eref "insert-signature-eref" is a function to insert a signature interactively. When you call this funcction, buffer "*sig-buffer*" appears and a default signature is displayed there. (I will explain how to decide a default signature later.) Key assign in "*sig-buffer*" p Display a previous signature P Display a previous signature n Display a next signature N Display a next signature q Quit inserting a signature Q Quit inserting a signature RET Insert a signature currently displayed x Insert a signature currently displayed X Insert a signature currently displayed When you call "insert-signature-eref" with argument (for example, C-u M-x insert-signature-eref, or C-u ), the signature you selected will be moved to a top of signature list. Doing this sometimes, you can change order of singatures in signature list. 3.2 Learning signatures When you select non default signature using "insert-signature-eref" and the valule of "sig-save-to-sig-name-alist" is non-nil, c-sig learns the relation of the signature and the mail address (or newsgroup name) to chose the signature as default from next time. When you chose a new signature, the message "Regster this signature for XXXXXX ? (y or n) " in mini buffer. If you type "y", this relation is saved to learning database. (or modifies entry already existing.) 3.3 Searching signature using regular expression Setting data to the variable "sig-regexp-alist", you can find signature using regular expression. Format of "sig-regexp-alist" is like this. (Even the name of the variable contains "alist", it is not alist) (( ( . ) … ( . )) … ( ( . ) … ( . ))) Usually, you will set "To" or "Newsgroups" to . (Off cause, you can use other fields, but I am not sure it is useful.) c-sig recognize string in the field as address or newsgroup name, and try to separate it using "," as separator. c-sig does matching as the order of the list, so you need to set the variable carefully. In general, it should be detail address first, and vague address last. Ex) If you want to set "jp$" and "foo.bar.jp$", you need to "foo.bar.jp$" first or "jp$" matches faster than "foo.bar.jp$". "sig-regexp-alist" is saved in "~/.signature.alist", but running emacs may also have it in memory. So, when you want to modify it, you should run "write-sig-file" to refresh the file. And don't forget to run "read-sig-file" after modifying it. 3.4 How c-sig select a default signature? c-sig calls functions in list "sig-search-functions" when it select a default signature. As default, is is "search using learning database" -> "search using reguler expression" -> "the signature defined in "sig-default-name". Searching from learning dabase is like this. c-sig have a list of signatures name and mail address (or news group name) (usually, it is added by "insert-signature-eref" when you selected non default signature. ) c-sig cuts mail address or newsgroup name from "To" or "Newsgroup" fileld, and search it from this database. If you find it, return the signature name to finish searching. When c-sig can not find mail address or newsgroup name in learning database, c-sig will check reguler expression database secondly. This dababase have information which header should be checked, so c-sig check the header only. As a sample example function for "sig-search-functions", I put "sig-get-random-signature" into c-sig package. If you add it to the end of "sig-search-functions", searching order is "search using learning database" -> "search using reguler expression" -> "get a randome signature". So, when c-sig find no information for a default signature in both learning database or reguler expression database, c-sig will use a random signature. When you want to use a random signature for specific persons, See section C-1 in "c-sig-eng.faq". 3.5 Convert string in signatures For example, anyone who changes company offten need to change their signatures so offen and this must be really tough job. (I am not talking about me.) c-sig have a feature for these kind of ..... special ..... people. You can write any string like "%%my-address%%" or "<>" in stead of your address and c-sig changes it to your really address. This converion is disabled as default. To enable this, add following statement tot ~/.emacs. (setq sig-replace-string t) Conversion table is "sig-replace-list" in "~/.signature.replace" (You can change the name of the file using "sig-replace-string-file".) "sig-replace-list" is like this. ( ( ( ... )) ( ( ... )) ... ) If you specify some strings as targets, one of them is randomly selected. This is example of "sig-replace-list". (setq sig-replace-list '( ("%%my-address%%" ("kshibata@tky.3web.ne.jp")) ("<>" ("Cast not pearls before swine" "Cast not golds before cat (japanese proverb)" "Cast not c-sig before vi users")) )) Attention: "insert-signature-eref" convert strings when it insert a signature. (not when a default signature is displayed.) By the way, don't you wan to use specific rules instead of randomness? I know, I know, I got a lot of requests like that. Yes, I have already add the feature already. Just write function name instead of a name of list. (setq sig-replace-list '( ("%%my-address%%" ("kshibata@tky.3web.ne.jp")) ("<>" ("Cast not pearls before swine" "Cast not golds before cat (japanese proverb)" "Cast not c-sig before vi users")) ("**shiteru-koto**" shiteru-koto )) By this setting, "**shiteru-koto**" in your signature will converted to return value of function "shiteru-koto". (This means return value of "shiteru-koto" must be in string.) Example of "shiteru-koto" is like this. (defun shiteru-koto () (let ((wtime (string-to-number (substring (current-time-string) 11 13)))) (cond ((< wtime 9) "I am Sleeping.") ((< wtime 12) "I am reading mails.") ((< wtime 13) "I am eating lanch.") ((< wtime 17) "I am reading news.") (t "I am playing games.")))) Using same manner, you can make a signature depending day of the week or month. 4. Functions users can use. insert-signature-eref Using this function, but users can select a signature by themselves. When a default signature is displayed, use "n" or "p" to select an other signature, "ret" to decide and "q" to cancel. c-sig can learn retationship of a signature and an address (or news group name), if you want. insert-signature-randomly Select and insert signauture randomly. insert-signature-automatically Select a signature automatically and insert it. A default signature for "insert-signature-eref" is inserted. add-signature Create a new signature. When you call this function, editor screen comes up. After writing a signature, typing C-c C-c will ask you the name of the signature. If you specify it, signature will be registed. If you want to cancel, type C-c C-q. You can also type C-c C-i to import existing signatures. delete-signature Delete unnecessary signatures. When use call delete-signature, selection screen appears. "n" or "p" to selecte a signature. "ret" to decide and "q" to quit. Confirmation message will appear when you type "ret" and "y" to remove it. sig-purge-void-lines Remove blank lines at the end of the mail and new line code ("\n") at the end of the mail if it doesn't exist. If sig-purge has non-nil value, insert-signature-* call this function automatically, so c-sig users doesn't need to use this function directly. I made this function public for users who don't like these blank line but don't want to use c-sig and don't know emacs lisp well. read-sig-file Read signature database from files. When use modified signature database in files using editor, please call this function. write-sig-file Write signature database if necessary. When you want to modify singature database using editor, please call this function. 5. Variables users can change. sig-replace-string If non-nil (t for example), replace using sig-replace-list is activated. Default value is nil. sig-insert-end If non-nil, c-sig insert a signature at the end of mail (like rmail.) If nil, c-sig insert a signature just before current line. (not current position.) Default value is nil sig-purge if non-nil, blank lines at the end of mail are removed before inserting a signature, and if there is no New line code ("\n") at the end of mail, it is inserted. If value of this variable is string, it will be inserted at the end of mail. Default value is t. sig-separator sig-separator will be inserted just before the signature you chose. If you want to add one null line and "--" before the signature, please set "\n--\n". (need "\n" at the end, if you want new line.) Default value is nil. sig-save-to-sig-name-alist If non-nil, c-sig saves selected a signature to database relating mail address or newsgroup name. When you select non default signature, you will asked "save this relation to database?" and if you answer "Yes", it will be saved. Default value is t. sig-default-name Name of a default signature. When c-sig can not find a signature from database, c-sig select this signature. If nil, c-sig select the top signature in list. Default value is nil. sig-save-file-every-change If non-nil, c-sig saves all information everytime database is changed. (If nil, save only on exiting emacs) Default is t. (I suggest not to change this.) sig-make-backup-files If non nil, c-sig make backup file when it saves database. (c-sig doesn't refer make-backup-files.) Default value is t. sig-end-of-headers Regular expression to look for the end of headers. If you are using special mailer, you may need to change this. Default value is "^$\\|^--". sig-search-functions List of functions to retrieve a signature. Default value is (list 'sig-search-name-alist 'sig-search-regexp). This means "search address name from database first and search reguler expression database second. If you add 'sig-get-random-signature to the end of the list, c-sig select arandom signature when it can not find signature using above two function. sig-random-sig-list List of signatures which can be selected randomly. "insert-signature-randomly" and "sig-get-random-signature" select a signature randomly from all signature you have, but if you set list of signatures to "sig-random-sig-list", these function choses a signature from the list. Default value is nil. sig-alist-file File name for alist database. Default value is "~/.signature.alist". sig-replace-string-file File name for replace strings. Default value is "~/.signature.replace". sig-regexp-alist Database for reguler expression, which is saved to ~/.signature.alist. Example of setting. (setq sig-regexp-alist '(("To" ("jp$" . "Japanese") ("com$" . "English")) ("Newsgroups" ("^fj" . "japanese") ("^comp" . "English")))) 6. Functions users can write. sig-filter-function When this function is defined, c-sig calls this function with setting the signature as argument, and insert return value as the signature. This function is not defined as default. I implemented this function in order to change some part of a signature randomly, but I add new function for this perpose. So I guess only a few people will use this function. If you are a kind a guru and want to use a special signature which contains output of extra outer command (or a more complexed signature), this function may be useful. Example of sig-filter-function Using this function, %name% in the signature will be changed to "MY NAME" and %title% will be changed to "MY TITLE". (defun sig-filter-function (sig) (let ((work) (buffer (get-buffer-create "*temp buffer*"))) (save-excursion (set-buffer buffer) (erase-buffer) (insert-string sig) (goto-char (point-min)) (replace-string "%name%" "MY NAME") (goto-char (point-min)) (replace-string "%title%" "MY TITLE") (setq work (buffer-substring (point-min) (point-max))) (kill-buffer buffer) work))) Since c-sig already has this function, this function is not worth to use. (sorry for this bad example) 7. About distribution. You must know about GNU General Public License very well, right? If no or only a little, pelase read it. It's very very exciting document. I guarantee. 8. Afterword Long time ago, far far away, yes, actually it's in far east. there lived a young guy who joined many mailing list and read many internet news. He thought he wanted to use specific signatures to specific ML or news group and started writing a little emacas function only for his own use. But he made a big big mistake. Accidentally, he talked about his tool at the offline meeting of a ML he joined. He didn't realize, but every other ML member also awaited this kind of tool. He forced to release his tool in the ML and to add new features requested form the members. Yes, this is a really begining of c-sig. Was this story interesting? Actually, I don't. Anyway you have c-sig now and I hope you like it. But be aware, don't spend to much time for creating a new signatures. That's a really really bad manner. I know it very well. Oh, I have one more thing. There is "c-sig official home page". http://www.threeweb.ad.jp/~kshibata/c-sig/english But this page is rarelly updated. Oh, I meant I would update offen this page from now on. -- (defvar after-five-hook ; Ken Shibata '((lambda () ; (while (<= (current-time) mid-night) ; kshibata@tky.3web.ne.jp (drink beer))))) ; c-sig-3.8.orig/c-sig-jp.faq100644 1750 1750 11206 6731116141 15372 0ustar kawamurakawamura c-sig FAQL release 3.8 date 1999/06/10 これは c-sig に関する FAQ list です。 ---------------------------------------------------------------------- この FAQ を emacs で見ている場合は、"M-2 C-x $" と入力することにより質 問だけを抜き出すことができます。答も見たい場合には "C-x $" とタイプす ればもとに戻ります。 質問番号 X-XX で検索しいたいときは、"M-C-s ^X-XX:" と入力してください。 もし見つからなかったら、続けて "C-r" とタイプしてみてください。質問が 見つかったら ESC をタイプすると検索モードから抜けられます。 ---------------------------------------------------------------------- c-sig 全般 A-1:c-sig のマニュアルってさっぱり分からないんですけど。 すまんこってす。一言もありません。 いや、それなりに努力はしているんですがなにしろ丁寧に書くのは面倒で……。 あ、そうじゃなくって、そっ、その……。 ごめんなさい。次のリリースではしっかり書きます。 A-2:c-sig の FAQ list ってなんでこんなに項目が少ないの? 作者が一人でこっそり作ったからです。これ以上何を書いて良いのか思い付 かなかったのです。こんな情報が必要だと教えて頂けば喜んで追加します。 A-3:signature を sig と略すのは良くないんじゃありませんか? 分りません。しかし c-sig には関係ありません。c-sig は「ちゃーんとシ グネチャをいれないと具合悪いぜよ」の略ですから…。 A-4:c-sig は最高です。是非ドネーションしたいので送り先を教えてください。 誤解があるようですね。最高なのは c-sig ではなくて、emacs です。 ですから、寄付をするなら迷わず FSF にしましょう。アメリカまでお金を 送るのが面倒だという人は寄付の含まれている GNU 関連の書籍やCDやT シャツを買いましょう。 え?そういうのが見当たらない?じゃあ、私のようにソースを寄付しましょ う。 A-5:c-sig の作者は shibata@sgi.co.jp だって聞いたんだけど……。 すんません。以前のバージョンはそのアドレスで公開したんですが、今はそ のアドレスはも う無効です。 有効だったとしても別人に届きます。kshibata@tky.3web.ne.jp を使ってく ださい。 jisx0201.el と han-kata.el に関する質問も(億が一あれば)上のアドレ スに送ってください。 c-sig の設定 B-1:insert-signature-automatically でいつも固定の順番で signature がつ いてしまうんですけど…。 (random t) を .emacs に入れましょう。 B-2:シグネチャ内の文字列の自動変換機能が効かないんですけど… おそらく (setq sig-replace-string t) するのを忘れているのだと思いま す。.emacs に上記の設定をいれてください。 B-3:.signature や .signature-fj にある signature を挿入したいんですけ ど… c-sig にはできません。c-sig は signature データベースに名前と signature を保管しておいて、その名前で signature を管理します。 すでに signature をいろいろなファイルに作成してしまっている人は add-signature で新しい signature を登録するときにそれを読込んでくだ さい。 B-4:signature がカーソルのある行の前に挿入されるんですが…。 仕様です。メールの最後に signature を挿入したい人は sig-insert-end に t を設定してください。 より高度な c-sig の使い方 C-1:特定の人にランダムな signature を付けたいんでけど…。 まず sig-search-functions の最後に sig-get-random-signature を追加し ます。 具体的には .emacs に次の設定を書き加えます。 (setq sig-search-functions (list 'sig-search-name-alist 'sig-search-regexp 'sig-get-random-signature)) 必要であれば sig-random-sig-list に signature 名のリストを設定して下 さい。sig-get-random-signature はこの中からランダムに signature を選 択します。 次に、sig-name-alist と sig-regexp-alist に細工をします。例えば kshibata@tky.3web.ne.jp にランダムな signature を送りたいのであれば 以下の一行を sig-name-alist と sig-regexp-alist の双方に加えて下さい。 ("kshibata@tky.3web.ne.jp" . nil) この結果、学習データベースでも正規表現検索でも結果として nil が返る ことになります。nil は「発見できず」という意味ですので次の検索フェイ ズに移り、最終的にランダムな signature が付くことになります。 ただし副作用として、学習データベースから見つからなかった人にもランダ ムに signature がついてしまいます。まあ、それは愛敬ということで勘弁 してください。 C-2:特定の人には signature を付けたくないんですけど…。 さて、メールだからと言って常に signature をつけるとは限りません。付 けたくない時もあるでしょう。insert-signature-* をキーにバインドして 手動で signature をつけている間は良いのですが、hook などを利用して自 動的に signature を付加するようにした場合、「この人にはつけない」と いう設定が必要になります。 そのためにはまず「空の signature」を作成します。add-signature で何も 入力せずに登録すると「空の signature」を登録できます。(名前は適宜付 けて下さい。) c-sig では空の signature が選択された場合は signature の挿入処理は行 なわれません。(sig-separator も付加されません。) ただし、sig-purge-void-lines が設定されている場合は mail 末の余分な 改行は削除されます。 でもそれがいいっしょ? c-sig-3.8.orig/c-sig-jp.man100644 1750 1750 43364 6731116133 15411 0ustar kawamurakawamura c-sig ユーザーズガイド (release 3.8 date 1999/06/10) 目次 1. c-sig って何? 2. インストールの手引 3. 使用方法 3.1 insert-signature-eref の操作 3.2 signature の学習 3.3 正規表現によるデフォルトの signature の検索 3.4 デフォルトの signature の決定方法 3.5 signature 内の文字列の自動変換 4. 使用できる関数の一覧 5. 設定できる変数の一覧 6. 設定できる関数の一覧 7. 配布についてのお願い 8. 後書き 1. c-sig って何? c-sig とはなんでしょう?c-sig も最初はただの「signature の選択挿入す る lisp」でした。しかし「あんなこともしたい」、「こんなこともしたい」 といろいろな人の意見を採り入れているうちに「ウルトラ・スーパー・デラッ クスな signature の挿入プログラム」になってしまいました。 どこがウルトラ・スーパー・デラックスなのかを、セールスポイントをあげ ることで説明しましょう。 ・signature の登録を対話型でできる。 c-sig には signature の登録関数 add-signature と削除関数 delete-signature が附属しています。ユーザはこの関数を使用することで対話的に signature を作成することができます。 また add-signature で新しい signature を作成中に既存の signature を 引用することができます。 ・いろいろな挿入関数がある。 c-sig には現在のところ3種類の挿入関数が用意されています。signature を対話型に選択する insert-signature-eref、データベースからの検索結果に 従い自動的に挿入する insert-signature-automatically、ランダムに挿入す る insert-signature-randomly です。 ・強力な検索機能、学習機能を持っている。 c-sig には特定の field を正規表現で検索し一致した signature を選択す る機能および実際に選択した signature を学習し、次からそれが選択される 機能を持っています。 また、正規表現が分からないひとでも学習機能さえ生かせばかなり賢い選択 が可能です。 ・挿入する signature 内の文字列を挿入時に変換できる。 c-sig では挿入しようとする signature の中の特定の文字列を挿入時に、 別の文字列や、特定のリストの中からランダムに選択した文字列に変換するこ とができます。アドレスや所属を自動的に変換したり、好きな言葉を引用する ときに便利です。 ・挿入する signature を elisp で処理することができる。 c-sig では挿入しようとする signature を emacs lisp の filter により 処理することができます。この機能により signature の中でプログラムを起 動して「今日のできごと」を挿入したり、より高度な置換処理を入れることが 可能です。 どうです。c-sig が「ウルトラ・スーパー・デラックス」であるということ がお分かりいただけたでしょうか? 何?まだ機能が不足している?もしそういう方がいらっしゃいましたら作者 まで是非御一報ください。 2. インストールの手引 まず ~/.emacs で以下の関数の autoload を設定してください。最後の3行 は使用するものだけでも構いません。 さらに、必要に応じて write-sig-file や read-sig-file なども autoload してもよいでしょう。 (autoload 'add-signature "c-sig" "c-sig" t) (autoload 'delete-signature "c-sig" "c-sig" t) (autoload 'insert-signature-eref "c-sig" "c-sig" t) (autoload 'insert-signature-automatically "c-sig" "c-sig" t) (autoload 'insert-signature-randomly "c-sig" "c-sig" t) この設定だけでも一応 c-sig を使用することは可能ですが、いちいち M-x insert-signature-eref と入力するのは面倒ですので、キーにバインドしよう という話になります。 global-set-key でどかんと設定しても大丈夫は大丈夫ですが、分かるので あれば使用するメーラやニュースリーダのしかるべき hook で local に設定 するのが良いでしょう。 たとえば mh-e では mh-letter-mode-hook を rmail は mail-mode-hook を gnus では news-setup-hook が妥当だと思います。  hook ってなに?キーにバインドって何?という人はあまり無理しないほう が良いです。ベストなのは「同じ環境の人から .emacs をもらう」です。これ は emacs lisp がわからない人には多くの場合もっとも有効な手段です。 gnus では .signature と .signature-* というファイルから signature を 自動的に付加しようとします。これは gnus-signature-file に nil を設定す ることで防ぐことができますが、.signature* というファイルがホームディレ クトリにたくさんあるのもなんなので、ここはすっぱりその手のファイルを削 除してしまいましょう。.signature-* でできる設定は c-sig ですべて行なう ことが可能です。 insert-signature-randomly などの乱数を使う機能を使う人は ~/.emacs に (random t) も入れておきましょう。そうしないとランダムなはずなのにいつ も同じ signature が挿入されてしまいます。(新しい emacs だといらないか も。^_^;) 3.使用方法 3.1 insert-signature-eref の操作 insert-signature-eref は対話型に signature を挿入する関数です。この 関数を実行すると *sig-buffer* というバッファが表示され、そこにデフォル トの signature が表示されます。(デフォルトの signature の検索ロジック に関しては後で説明します。) *sig-buffer* でのキー割り当て p 一つ前の signature の表示 P 一つ前の signature の表示 n 次の signature の表示 N 次の signature の表示 q signature の挿入の中止 Q signature の挿入の中止 RET 表示中の signature の挿入 x 表示中の signature の挿入 X 表示中の signature の挿入 insert-signature-eref を引数付きで起動した場合(例えば、C-u M-x insert-signature-eref、あるいは C-u <割り当てたキー>)、挿入した signature は signature list の先頭に移動されます。これを繰り返すことに より signature list の順番を変更することができます。 3.2 signature の学習 insert-signature-eref で最初に表示されたデフォルトの signature 以外 を挿入し、かつ変数 sig-save-to-sig-name-alist が non-nil の場合、次か らこの signature がデフォルトになるように address と signature 名の対 応をデータベースに格納することが可能です。 新しい signature を挿入すると mini buffer に "Regster this signature for XXXXXX ? (y or n) " と表示されます。ここで y を入力すればデータベー スへ格納されます。既にデータベースに入っているアドレスに別の signature を選択した場合もこのメッセージを聞いてきますのでデータベースの更新が可 能です。 3.3 正規表現によるデフォルトの signature の検索 sig-regexp-alist という変数にデータを設定することにより正規表現によ りデフォルトの signature を設定することが可能です。 sig-regexp-alist は以下のような形式です。(alist といいながら alist ではありません。_o_) (( (<正規表現> . ) … (<正規表現> . )) … ( (<正規表現> . ) … (<正規表現> . ))) 普通 Field 名には "To" とか "Newsgroups" を設定することになります。 (もちろん他の field 名も指定できますが、意味があるかどうか…。) Field 内の文字列はアドレスであると仮定しているので "," をセパレータ として分割した後、正規表現とマッチングをとります。検索順もこのリストの 順に行ないますから、より細かい正規表現を前に、おおざっぱなものを後に記 述してください。 例) "jp$" と "foo.bar.jp$" と記述したい場合は "foo.bar.jp$" を先に記述 しないと "jp$" に先にマッチしてしまいます。 sig-regexp-alist は ~/.signature.alist に格納されています。変数を設 定する時に注意して欲しいのは sig-regexp-alist はメモリにも常駐していて (設定により)終了時に上書きされる可能性があることです。そこでファイル を書き換える前に現在のデータを write-sig-file で保管してください。 write-sig-file はデータが更新されていず、不要なときは保存を行いません から気軽に行ってください。そして、ファイルに対する修正が終ったら read-sig-file を実行して変更内容を読み込んでください。 3.4 デフォルトの signature の決定方法 前の節でも少し触れましたが、デフォルトの signature の決定方法に関し てもう少し詳細を説明します。 デフォルトの signature は変数 sig-search-functions に格納されている 関数を順番に呼びだすことで行なわれます。 標準の設定では「学習データベースの検索」→「正規表現データベースの検 索」→「sig-default-name に設定されている signature 名」→「signature のリストの先頭のもの」という順番になっています。 学習データベースは "To" と "Newsgroup" の field から "," をセパレー タとしてアドレスないしは news group 名を切り出してきてそれらがデータベー ス内の文字列と一致するかどうかを調べます。一致した場合は対応する signature 名を戻し検索を終了します。 学習データベース内に見つからなかった場合は正規表現データベースを検索 にいきます。こちらはデータベース内に検索する field 名がありますからそ の field 内でのみ検索を行ないます。 sig-search-functions の拡張例として sig-get-random-signature という 関数が用意されています。これを sig-search-functions の最後に追加した場 合、検索順が「学習データベースの検索」→「正規表現データベースの検 索」→「ランダムな signature」という順番になります。 つまり、検索で一致しない場合ランダムなシグネチャが与えられると言うこ とになるわけです。しかし、実際には「特定のアドレスにランダムな signature を使いたい」という場合が多いはずです。そういう人は c-sig.faq の「C-1:特定の人にランダムな signature を付けたい」を見てください。 3.5 signature 内の文字列の自動変換 例えば、自分のアドレスがしょっちゅう変わるとか自分の所属がしょっちゅ う変わるという人は c-sig で作った膨大な signature を全て書き換えるのは 大変面倒です。(私のことじゃないっすよ。) c-sig ではそういう激しい人のために、あらかじめ signature には %%my-address%% とか <> というような文字列を入れておいてそ れを挿入時に変換するという機能を持っています。 この文字列の自動変換機能はデフォルトでは無効になっています。有効にす るには .emacs などに下記の一行を追加してください。 (setq sig-replace-string t) 変換文字列は ~/.signature.replace (sig-replace-string-file で変更可 能)の中で sig-replace-list を設定することで行います。 sig-replace-list は以下のような形式です。 ( ( <変換元の文字列> ( <変更する文字列> <変更する文字列> … <変更する文字列> )) ( <変換元の文字列> ( <変更する文字列> <変更する文字列> … <変更する文字列> )) … ) 変更する文字列が複数指定されている場合はその中の一つをランダムに選択 します。 以下に sig-replace-list の設定例をのせます。参考にしてください。 (setq sig-replace-list '( ("%%my-address%%" ("kshibata@tky.3web.ne.jp")) ("<>" ("猫に小判" "豚に真珠" "vi ユーザに c-sig")) )) (注意)insert-signature-eref では表示時でなく、挿入時に変換されます。 ところでこの置換ですが、ランダムではなく特定の規則で置き換えたいとい う人いませんか?もちろんいますね。そういう要望はたくさん来ていますから…。 そこでこの replace-list に関数を設定することによりその関数の戻り値を 挿入するという機能を付け加えてみました。リストの代りに関数名をそのまま 書いてください。 (setq sig-replace-list '( ("%%my-address%%" ("kshibata@tky.3web.ne.jp")) ("<>" ("猫に小判" "豚に真珠" "vi ユーザに c-sig")) ("**shiteru-koto**" shiteru-koto )) この設定により、signature 中の **shiteru-koto** という文字列は shiteru-koto という関数の戻り値に置き換わります。(つまり関数の戻り値 は文字列である必要があります。) 具体的には以下のような関数になります。 (defun shiteru-koto () (let ((wtime (string-to-number (substring (current-time-string) 11 13)))) (cond ((< wtime 9) "睡眠中") ((< wtime 12) "メール購読中") ((< wtime 13) "食事中") ((< wtime 17) "ニュース購読中") (t "ゲーム中")))) 同じようなやり方で曜日や月で変わる signature も書けます。 4. 使用できる関数の一覧 insert-signature-eref signature を選択挿入します。データベースに従ってデフォルトに signature が表示されますが、n および p キーで選択が可能です。ret で 確定して q でキャンセルです。 またここで選択した signature が次のデフォルトになるようにデータベー スに登録することも可能です。 insert-signature-randomly signauture をランダムに挿入します。 insert-signature-automatically signature を自動挿入します。 挿入される signature は insert-signature-eref でデフォルトになるもの です。 add-signature 新しい signature を作成します。 実行するとエディタ画面になります。作成後、C-c C-c を押すと signature 名を問い合わせてきます。signature 名を入力するとその signature は登 録されます。登録をキャンセルする場合は C-c C-q を押してください。 また、作成中に C-c C-i を押して既存の signature を呼び出すことができ ます。 delete-signature 不要になった signature を削除します。 delete-signature を実行すると signature の選択画面になります。n と p で不要の signature を選択し、ret で確定、q でキャンセルします。ret を押すと確認メッセージが表示されますので y を押して削除してください。 sig-purge-void-lines mail 末の余分な空白行が全て削除し、mail 末に改行コードがない場合は改 行コードを一つ挿入します。変数 sig-purge に文字列が設定されていると その文字列を mail 末に挿入します。 sig-purge に non-nil が設定されている場合、insert-signature-* はこの 関数を自動的に呼び出しますので、通常は使用する必要はありません。  この関数はメール発送時に余分な改行を削除したいが別に c-sig を使う気 はない、しかも emacs lisp は書きたくないというユーザのために解放され ています。 read-sig-file signature database を読み込みます。signature database をエディタで変 更した後はこのコマンドを実行してください。 write-sig-file signature database を必要があれば保管します。singature database をエ ディタで変更する前にこのコマンドを実行してください。 5. ユーザが設定可能な変数 sig-replace-string non-nil (たとえば t)が設定されていると, sig-replace-list で指定され る置換が有効になります。 デフォルトは nil sig-insert-end non-nil が設定されていると rmail の様に mail 末に signature が挿入さ れます。 nil の場合は現在行の前に signature が挿入されます。デフォルトは nil。 ^^^^^^^^^^^^ sig-purge non-nil が設定されていると mail 末の余分な空白行が全て削除され、mail 末に改行コードがない場合は挿入されます。 また、変数の内容が文字列だとその内容が mail 末に挿入されます。 デフォルトは t sig-separator signature に先行して挿入される文字列を指定します。signature の前に一 行の空白と "--" を入れたいのであれば "\n--\n" としてください。(行末 の \n は自動的には付加されません。)デフォルトは nil sig-save-to-sig-name-alist non-nil を設定すると、対話型で選択した signature をデータベースに保 管することができます。 検索された signature と異なる signature を挿入した場合、登録確認メッ セージが表示されますので y と応えるとアドレス名と signature 名の組を データベースに保管します。次の検索からこのデータは有効になります。 デフォルトは t sig-default-name signature の検索に失敗した場合にこの変数に収納されている signature をデフォルトとして使用します。nil の場合、signature alist の先頭がデ フォルトになります。 デフォルトは nil sig-save-file-every-change non-nil が設定されていると、c-sig は signature database の内容が変更 になるたびに情報を save します。nil の場合は kill-emacs 関数を書き換 えて終了時に save します。emacs を滅多に終了しない人は t にしておい た方が安全です。 デフォルトは t sig-make-backup-files c-sig は変数 make-backup-files の値ではなくこの変数の値に従って sig-alist-file のバックアップファイルを作成するかどうかを決定します。 t なら作成し、nil ならしません。 デフォルトは t sig-end-of-headers c-sig が header の終了を認識するための正規表現です。特殊な mailer を 使用している人は変更してください。 デフォルトは "^$\\|^--" sig-search-functions デフォルトの signature を検索する関数の list。 デフォルトは (list 'sig-search-name-alist 'sig-search-regexp) で、ま ずデータベースからアドレス名をを検索し、見つからない場合は正規表現デー タベースを検索します。それでも見つからない場合はデフォルトの signature 名を使用します。 'sig-get-random-signature を最後につけると正規表現データベースでもマッ チングしなかった場合、ランダムに signature を選択します。 sig-random-sig-list insert-signature-randomly または sig-get-random-signature は signature の list の中からランダムに signature を選択します。 しかし、sig-random-sig-list に signature 名の list が設定されていた 場合、その中からランダムに signature を選択します。 デフォルトは nil sig-alist-file データベースなどを格納するファイル名。 デフォルトは "~/.signature.alist" sig-replace-string-file 置換文字列を格納するファイル名。 デフォルトは "~/.signature.replace" sig-regexp-alist 正規表現データベース。~/.signature.alist に格納されます。 設定例 (setq sig-regexp-alist '(("To" ("jp$" . "Japanese") ("com$" . "English")) ("Newsgroups" ("^fj" . "japanese") ("^comp" . "English")))) 6. ユーザが設定可能な関数 sig-filter-function この関数が宣言されていると signature の挿入時に signature 自身を引数 としてこの関数が呼ばれ、戻りを signature として挿入します。デフォルト では宣言されていません。 filter function はもともとは「ランダムに signature の内容を書き換え る」という機能のために作成しましたが、その後その機能をデフォルトで実装 してしまったため、現在はどのような価値があるのか良く分りません。でも、 この機能があれば外部コマンドを実行し、その出力を signature に取り込む こともできるので、そういうことをしようという強者がいればそれなりに便利 だと思います。 sig-filter-function の記述例 以下のような関数を宣言しておくと signature 中の %name% という文字列 を名前に、%title% という文字列を肩書に変換することができます。 (defun sig-filter-function (sig) (let ((work) (buffer (get-buffer-create "*temp buffer*"))) (save-excursion (set-buffer buffer) (erase-buffer) (insert-string sig) (goto-char (point-min)) (replace-string "%name%" "自分の名前") (goto-char (point-min)) (replace-string "%title%" "自分の肩書") (setq work (buffer-substring (point-min) (point-max))) (kill-buffer buffer) work))) c-sig には既に上記の機能があるので実用性はありません。(悪い例で申し 訳ない) 7.配布について c-sig は GNU General Public License で配布していますので煮て食おうが 焼いて食おうが自由と言えば自由です。GNU General Public License って何? という人はこれを機会にちょっと読んでみてください。 8. 後書き 思えば c-sig を作りはじめたのは……いつだったかなぁ。最初は自分のた めだけにこっそり書いていたのですが、うっかりあるMLのオフミで「こんな lisp を書いているんだ」と口を滑らせたのがきっかけで、マイナーに公開す るはめになり、その後、徐々に機能を増やしていきました。 何度か net news に流そうと思ったのですが、もう少し機能を追加したい とか、ドキュメントを丁寧に書きたいとか、似たような lisp が出回っている とかで思いためらっていました。 結局、3.7 beta を fj.sources に流したんですが、その後、ずっとメンテ をしないでいました。どうもすみません。 なお、c-sig の公式ホームページが一応あります。 http://www.threeweb.ad.jp/~kshibata/c-sig ですが、滅多に更新されませ ん。 あ、いや。今後はまめにアップデートします。 -- (defvar after-five-hook ; 柴田 健 '((lambda () ; (while (<= (current-time) mid-night) ; kshibata@tky.3web.ne.jp (drink beer))))) ; c-sig-3.8.orig/c-sig.el100644 1750 1750 45154 6731116136 14631 0ustar kawamurakawamura;; c-sig.el signature tool for news and mail ;; Copyright (C) 1995-1999 Free Software Foundation, Inc. ;; Author: Ken Shibata ;; Maintainer: Ken Shibata ;; Created: Sep 1995 - first release to internet ;; Modified: Jun 1999 - wrote English documents ;; Version: $Id: c-sig.el,v 3.8 1999/06/10 00:00:00 kshibata Exp kshibata $ ;; Keywords: mail news signature ;; This file is part of GNU Emacs. ;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. (provide 'c-sig) (require 'mail-utils) (defconst c-sig-version-number "3.8") (defun c-sig-version () (interactive) (message "Using c-sig version %s" c-sig-version-number)) (defvar sig-replace-string nil "non-nil, replace strings in signature.") (defvar sig-insert-end nil "non-nil, insert signature at the of the mail.\n\ nil, insert signature before current line.") (defvar sig-purge t "if non-nil, purge void line at the end of mail,\n\ and if the value is string, insert it there.") (defvar sig-separator nil "if string is set, insert it before signature.") (defvar sig-save-to-sig-name-alist t "if non-nil, activate sig-name-alist") (defvar sig-default-name nil "default signature name") (defvar sig-save-file-every-change t "if non-nil, save sig-alist-file every time you made changes. if nil, save sig-alist-file in kill-emacs.") (defvar sig-make-backup-files t "if t, make backup file for sig-alist-file") (defvar sig-end-of-headers "^$\\|^--" "Regular expression to look for the end of headers") (defvar sig-search-functions (list 'sig-search-name-alist 'sig-search-regexp) "") (defvar sig-random-sig-list nil "list of random signature") (defvar sig-replace-string-file (expand-file-name "~/.signature.replace") "File name for replace strings") (defvar sig-alist-file (expand-file-name "~/.signature.alist") "File name for alists") (defvar c-sig-load-hook nil "User definable hook. Runs after c-sig is loaded.") (defvar sig-buffer-name "*sig-buffer*") (defvar sig-editor-name "*sig-editor*") (defvar sig-electric-mode-map nil "*Keymap for sig-electric-mode.") (defvar sig-alist nil) (defvar sig-name-alist nil) (defvar sig-regexp-alist nil) (setq sig-need-to-save nil) (setq sig-delete-mode nil) (setq sig-normal-mode t) (if (file-exists-p sig-alist-file) (load sig-alist-file)) (if (not sig-save-file-every-change) (progn (if (not (fboundp 'c-sig-orig:kill-emacs)) (fset 'c-sig-orig:kill-emacs (symbol-function 'kill-emacs))) (defun c-sig:kill-emacs (&optional query) (interactive "P") (write-sig-file) (c-sig-orig:kill-emacs query)) (fset 'kill-emacs (symbol-function 'c-sig:kill-emacs)))) (if sig-electric-mode-map nil (setq sig-electric-mode-map (make-sparse-keymap)) (define-key sig-electric-mode-map "p" 'sig-eref-prev) (define-key sig-electric-mode-map "P" 'sig-eref-prev) (define-key sig-electric-mode-map "n" 'sig-eref-next) (define-key sig-electric-mode-map "N" 'sig-eref-next) (define-key sig-electric-mode-map "q" 'sig-eref-abort) (define-key sig-electric-mode-map "Q" 'sig-eref-abort) (define-key sig-electric-mode-map "\r" 'sig-eref-exit) (define-key sig-electric-mode-map "\n" 'sig-eref-exit) (define-key sig-electric-mode-map "x" 'sig-eref-exit) (define-key sig-electric-mode-map "X" 'sig-eref-exit) ) (defvar sig-msg1 "Name of Signature: ") (defvar sig-msg2 "Need to specify a name of the signature") (defvar sig-msg3 "The signature name is already exists. Do you want to override it?") (defvar sig-msg4 "Saving...") (defvar sig-msg5 "Done") (defvar sig-msg6 "No signature is registered.") (defvar sig-msg7 "Are you sure ? ") (defvar sig-msg8 "Regiser this signature for %s? ") (defun insert-signature-eref (&optional arg) "Insert signature from signature alist. If optinal argument ARG is non-nil, move selected signature to the head of sig-alist." (interactive "P") (if sig-alist (let* ((sig-def-name "") (sig-key nil) (sig nil)) (if (setq sig (sig-electric-mode (setq sig-def-name (sig-search-default-signature)))) (progn (sig-insert-sig-internal (cdr sig)) (if arg (progn (asort 'sig-alist (car sig)) (setq sig-need-to-save t))) (if (and sig-save-to-sig-name-alist sig-key (not (string= sig-def-name (car sig))) (y-or-n-p (format sig-msg8 sig-key))) (progn (setq sig-need-to-save t) (aput 'sig-name-alist sig-key (car sig)))) (if sig-save-file-every-change (write-sig-file))))))) (defun insert-signature-randomly () "Insert signature from signature alist randomly." (interactive) (if sig-alist (sig-insert-sig-internal (cdr (assoc (sig-get-random-signature) sig-alist ))) (message sig-msg6))) (defun insert-signature-automatically () "Insert signature automatically." (interactive) (let ((sig-key nil)) (if sig-alist (let ((sig-name (sig-search-default-signature))) (sig-insert-sig-internal (if sig-name (cdr (assoc sig-name sig-alist)) ""))) (message sig-msg6)))) (defun sig-insert-sig-internal (sig) (if sig (save-excursion (if sig-purge (sig-purge-void-lines)) (if (string= sig "") nil (if sig-normal-mode (progn (if sig-replace-string (setq sig (sig-replace-string-function sig))) (if (fboundp 'sig-filter-function) (setq sig (sig-filter-function sig))))) (if sig-insert-end (goto-char (point-max)) (beginning-of-line)) (if sig-separator (insert sig-separator)) (insert sig)) (set-buffer-modified-p (buffer-modified-p))))) (defun add-signature () "add new signature into a signature alist." (interactive) (save-excursion (save-window-excursion (delete-other-windows) (pop-to-buffer sig-editor-name) (kill-all-local-variables) (local-set-key "\C-c\C-c" 'save-and-exit-signature) (local-set-key "\C-c\C-s" 'save-signature) (local-set-key "\C-c\C-i" (function (lambda () (interactive) (let ((sig-separator nil) (sig-save-to-sig-name-alist nil) (sig-normal-mode nil) (sig-purge nil)) (insert-signature-eref))))) (local-set-key "\C-c\C-q" 'quit-signature) (local-set-key "\C-x\C-s" 'save-signature) (local-set-key "\C-xk" 'quit-signature) (recursive-edit) (kill-buffer sig-editor-name)))) (defun delete-signature () "delete signature from signature alist." (interactive) (if sig-alist (let* ((sig (car (sig-electric-mode nil t)))) (if sig (progn (save-excursion (adelete 'sig-alist sig) (setq sig-need-to-save t) (if sig-save-file-every-change (write-sig-file)) (message sig-msg5))))) (message sig-msg6))) (defun sig-purge-void-lines () "purge void line at the end of mail." (interactive) (save-excursion (save-restriction (let ((cur-pos (point))) (if (and (bolp) (eolp) (progn (while (eq (following-char) ?\n) (forward-char)) (eobp))) (delete-region cur-pos (point-max))) (goto-char (point-max)) (if (bolp) (progn (backward-char) (while (eq (preceding-char) ?\n) (delete-backward-char 1))) (insert "\n")) (if (stringp sig-purge) (progn (goto-char (point-max)) (insert sig-purge))))))) (defun read-sig-file () "read signature database" (interactive) (load sig-alist-file) (setq sig-need-to-save nil)) (defun write-sig-file () "write signature database" (interactive) (if sig-need-to-save (let ((make-backup-files sig-make-backup-files) (version-control nil)) (message sig-msg4) (set-buffer (get-buffer-create " *sig-alist*")) (erase-buffer) ;;; ;;; sig-alist ;;; (if sig-alist (progn (insert "(setq sig-alist '(\n") (mapcar '(lambda (element) (insert "( " (prin1-to-string (car element)) " .\n" (prin1-to-string (cdr element)) ")\n")) sig-alist) (insert "))\n\n")) (insert "(setq sig-alist nil)\n\n")) ;;; ;;; sig-name-alist ;;; (if sig-name-alist (progn (insert "(setq sig-name-alist '(\n") (mapcar '(lambda (element) (insert (prin1-to-string element) "\n")) sig-name-alist) (insert "))\n")) (insert "(setq sig-name-alist nil)\n")) ;;; ;;; sig-regexp-alist ;;; (if sig-regexp-alist (progn (insert "(setq sig-regexp-alist '(\n") (mapcar '(lambda (element) (insert "(" (prin1-to-string (car element)) "\n") (mapcar '(lambda (element2) (insert "\t" (prin1-to-string element2) "\n")) (cdr element)) (insert ")\n")) sig-regexp-alist) (insert "))\n")) (insert "(setq sig-regexp-alist nil)\n")) ;;; ;;; file close ;;; (write-file sig-alist-file) (kill-buffer (current-buffer)) (setq sig-need-to-save nil) (message sig-msg5)))) (defun sig-electric-mode (begin &optional arg) (let* ((signature nil) (sig-cur-num 0) (sig-max-num (length sig-alist)) (work sig-alist)) (if (and begin (cdr (assoc begin sig-alist))) (while (not (string= (car (car work)) begin)) (setq sig-cur-num (1+ sig-cur-num)) (setq work (cdr work)))) (save-excursion (save-window-excursion (get-buffer-create sig-buffer-name) (pop-to-buffer sig-buffer-name) (kill-all-local-variables) (setq mode-name "Sig" major-mode 'sig-electric-mode) (use-local-map sig-electric-mode-map) (setq sig-delete-mode arg) (set-buffer sig-buffer-name) (setq buffer-read-only t) (sig-eref-show) (recursive-edit) (kill-buffer sig-buffer-name))) signature)) (defun sig-eref-show (&optional arg) "Show reference INDEX in sc-rewrite-header-list." (save-excursion (set-buffer sig-buffer-name) (let ((buffer-read-only nil)) (erase-buffer) (goto-char (point-min)) (insert (cdr (setq signature (nth sig-cur-num sig-alist)))) (setq mode-line-process (concat " : " (car signature)))))) (defun sig-eref-next () "Display next reference in other buffer." (interactive) (if (eq sig-max-num (setq sig-cur-num (1+ sig-cur-num))) (setq sig-cur-num 0)) (sig-eref-show)) (defun sig-eref-prev () "Display previous reference in other buffer." (interactive) (setq sig-cur-num (if (eq sig-cur-num 0) (1- sig-max-num) (1- sig-cur-num))) (sig-eref-show)) (defun sig-eref-abort () "Exit from electric reference mode without inserting reference." (interactive) (setq signature nil) (exit-recursive-edit)) (defun sig-eref-exit () "Exit from electric reference mode and insert selected reference." (interactive) (if (and sig-delete-mode (not (y-or-n-p sig-msg7))) (message "") (exit-recursive-edit))) (defun save-and-exit-signature () "" (interactive) (save-signature) (exit-recursive-edit)) (defun quit-signature () "" (interactive) (exit-recursive-edit)) (defun save-signature () "" (interactive) (let* ((sig-name (read-input sig-msg1 ""))) (if (string= sig-name "") (error sig-msg2) (if (and (cdr (assoc sig-name sig-alist)) (not (y-or-n-p sig-msg3))) nil (aput 'sig-alist sig-name (buffer-substring (point-min) (point-max))) (setq sig-need-to-save t) (if sig-save-file-every-change (write-sig-file)))))) ;;; ;;; functions for looking for default signature. ;;; (defun sig-search-default-signature () (let ((ret nil) (functions sig-search-functions)) (while functions (if (setq ret (funcall (car functions))) (setq functions nil) (setq functions (cdr functions)))) (or ret sig-default-name))) (defun sig-search-name-alist () "" (let (key keys name pos work) (save-excursion (save-restriction (goto-char (point-min)) (if (not (re-search-forward sig-end-of-headers nil t)) (goto-char (point-max))) (beginning-of-line) (narrow-to-region (point-min) (point)) (setq keys (mail-strip-quoted-names (or (mail-fetch-field "to") (mail-fetch-field "newsgroups") ""))))) (while (not (string= keys "")) (setq pos (string-match "[ \t\n]*,[ \t\n]*" keys)) (setq key (substring keys 0 pos)) (setq keys (if pos (substring keys (match-end 0)) "")) (if (setq name (cdr (assoc key sig-name-alist))) (setq sig-key key keys "") (or sig-key (setq sig-key key)))) name)) (defun sig-search-regexp () (if sig-regexp-alist (let ((w-alist sig-regexp-alist) keys key pos (ret nil)) (while w-alist (setq keys (mail-strip-quoted-names (mail-fetch-field (car (car w-alist))))) (while keys (setq pos (string-match "[ \t\n]*,[ \t\n]*" keys)) (setq key (substring keys 0 pos)) (setq keys (if pos (substring keys (match-end 0)) nil)) (let ((reg-alist (cdr (car w-alist)))) (while reg-alist (if (string-match (car (car reg-alist)) key) (setq ret (cdr (car reg-alist)) sig-key (mail-strip-quoted-names key) reg-alist nil w-alist nil keys nil) (setq reg-alist (cdr reg-alist)))))) (setq w-alist (cdr w-alist))) ret) nil)) (defun sig-get-random-signature () "" (let ((max) (num (random))) (if sig-random-sig-list (progn (setq max (length sig-random-sig-list)) (setq num (% (if (< num 0) (- num) num) max)) (nth num sig-random-sig-list)) (setq max (length sig-alist)) (setq num (% (if (< num 0) (- num) num) max)) (car (nth num sig-alist))))) (defun sig-replace-string-function (sig) "" (save-excursion (let ((sig-replace-list) (work)) (if (file-exists-p sig-replace-string-file) (progn (load sig-replace-string-file) (set-buffer (get-buffer-create " *sig-temp*")) (erase-buffer) (insert sig) (while sig-replace-list (goto-char (point-min)) (setq work (car (cdr (car sig-replace-list)))) (replace-string (car (car sig-replace-list)) ;;;;;; (cond ((listp work) (nth (random (length work)) work)) ((fboundp work) (funcall work)) (t ""))) ;;;;;; (setq sig-replace-list (cdr sig-replace-list))) (setq sig (buffer-substring (point-min) (point-max))) (kill-buffer (current-buffer))))) sig)) ;;; Following functions are taken from sc-alist.el Version 1.0. ;;; sc-alist.el is not included in SuperCite versions 3.X any more. (defun asort (alist-symbol key) "Move a specified key-value pair to the head of an alist. The alist is referenced by ALIST-SYMBOL. Key-value pair to move to head is one matching KEY. Returns the sorted list and doesn't affect the order of any other key-value pair. Side effect sets alist to new sorted list." (set alist-symbol (sort (copy-alist (eval alist-symbol)) (function (lambda (a b) (equal (car a) key)))))) (defun aelement (key value) "Makes a list of a cons cell containing car of KEY and cdr of VALUE. The returned list is suitable as an element of an alist." (list (cons key value))) (defun aheadsym (alist) "Return the key symbol at the head of ALIST." (car (car alist))) (defun anot-head-p (alist key) "Find out if a specified key-value pair is not at the head of an alist. The alist to check is specified by ALIST and the key-value pair is the one matching the supplied KEY. Returns nil if ALIST is nil, or if key-value pair is at the head of the alist. Returns t if key-value pair is not at the head of alist. ALIST is not altered." (not (equal (aheadsym alist) key))) (defun aput (alist-symbol key &optional value) "Inserts a key-value pair into an alist. The alist is referenced by ALIST-SYMBOL. The key-value pair is made from KEY and optionally, VALUE. Returns the altered alist or nil if ALIST is nil. If the key-value pair referenced by KEY can be found in the alist, and VALUE is supplied non-nil, then the value of KEY will be set to VALUE. If VALUE is not supplied, or is nil, the key-value pair will not be modified, but will be moved to the head of the alist. If the key-value pair cannot be found in the alist, it will be inserted into the head of the alist (with value nil if VALUE is nil or not supplied)." (let ((elem (aelement key value)) alist) (asort alist-symbol key) (setq alist (eval alist-symbol)) (cond ((null alist) (set alist-symbol elem)) ((anot-head-p alist key) (set alist-symbol (nconc elem alist))) (value (setcar alist (car elem))) (t alist)))) (defun adelete (alist-symbol key) "Delete a key-value pair from the alist. Alist is referenced by ALIST-SYMBOL and the key-value pair to remove is pair matching KEY. Returns the altered alist." (asort alist-symbol key) (let ((alist (eval alist-symbol))) (cond ((null alist) nil) ((anot-head-p alist key) alist) (t (set alist-symbol (cdr alist)))))) (defun aget (alist key &optional keynil-p) "Returns the value in ALIST that is associated with KEY. Optional KEYNIL-P describes what to do if the value associated with KEY is nil. If KEYNIL-P is not supplied or is nil, and the value is nil, then KEY is returned. If KEYNIL-P is non-nil, then nil would be returned. If no key-value pair matching KEY could be found in ALIST, or ALIST is nil then nil is returned. ALIST is not altered." (let ((copy (copy-alist alist))) (cond ((null alist) nil) ((progn (asort 'copy key) (anot-head-p copy key)) nil) ((cdr (car copy))) (keynil-p nil) ((car (car copy))) (t nil)))) (defun amake (alist-symbol keylist &optional valuelist) "Make an association list. The association list is attached to the alist referenced by ALIST-SYMBOL. Each element in the KEYLIST becomes a key and is associated with the value in VALUELIST with the same index. If VALUELIST is not supplied or is nil, then each key in KEYLIST is associated with nil. KEYLIST and VALUELIST should have the same number of elements, but this isn't enforced. If VALUELIST is smaller than KEYLIST, remaining keys are associated with nil. If VALUELIST is larger than KEYLIST, extra values are ignored. Returns the created alist." (let ((keycar (car keylist)) (keycdr (cdr keylist)) (valcar (car valuelist)) (valcdr (cdr valuelist))) (cond ((null keycdr) (aput alist-symbol keycar valcar)) (t (amake alist-symbol keycdr valcdr) (aput alist-symbol keycar valcar)))) (eval alist-symbol)) (run-hooks 'c-sig-load-hook) c-sig-3.8.orig/whats.new100644 1750 1750 204 6731116143 15067 0ustar kawamurakawamura What's new 3.8 (1999/06/10) . Just wrote English documents. If you are using 3.7 beta, you don't need to update to this release.