select-xface-0.15/0040755000076400007640000000000007433741244014244 5ustar teranisiteranisiselect-xface-0.15/ChangeLog0100644000076400007640000001227207433741203016012 0ustar teranisiteranisi2002-02-17 Yuuichi Teranishi * v0.15 - "Live And Let Die" * README.jis: グレースケール X-Face に関する説明を追加。 * select-xface.el: グレースケール X-Face に対応。 1999-11-22 Yuuichi Teranishi * README.jis: Animated X-Face に関する説明を追加。 * 別ファイル名で同じ候補があるときに名前がずれるのを修正。 * (set-buffer-modified-p nil) するようにした。 1999-11-20 Hironori Fukuchi * XEmacs でアイコンが表示されない場合があったのを修正。 1999-10-01 Yuuichi Teranishi * v0.13 - "Junk" * 本文中にヘッダっぽい記述があったら書き換えてしまう不具合を修正。 (watanabe@sigmaitec.co.jp (渡辺 正 / Tadashi Watanabe) さんの御指摘) 1999-09-29 Yuuichi Teranishi * v0.12 - "I Got Stung" * select-xface-delete-all-xface-related-fields がヘッダの末尾を 検出していなかったのを修正。 (watanabe@sigmaitec.co.jp (渡辺 正 / Tadashi Watanabe) さんの御指摘) * v0.11 - "Helen Wheels" 1999-09-29 "Ken'ichi Tanaka" * 最新版の x-face-mule.el から、関数 x-face-mule:x-face-decode-message-header が削除されたのに対応。 1998-10-07 Yuuichi Teranishi * v0.10 - "Goodnight Tonight" * error になったファイルがあったときに、modeline に表示される名前と 絵が一致しないのを修正。 * default では、x-face-mule を使って mule上 で select-xface したとき、 x-face-mule-highlight-x-face-position を 'x-face にしていると select-xface の窓に "X-Face-Img:" が挿入されてしまって、表示が X-Face-Img: XXXXXX XXXXXXX XXXXXXX こんな感じになってしまうのを修正。 (津邑さんの御指摘) 1998-04-14 Yuuichi Teranishi * v0.09 - "Figure Of Eight". * select 用 window を popup する位置を固定にしたつもり。 * insert のとき、switch-buffer ではなく、set-buffer でないと まずかった。 1998-03-17 Yuuichi Teranishi * v0.08 - "Ebony And Ivory". * visible-region をなくす。 1997-12-18 Yuuichi Teranishi * window をたくさんひらいているときに、parent ではないバッファに 顔が挿入されるバグの fix と、select-xface-insert-hook の位置の 修正。 thanks to TSUMURA Tomoaki (津邑公暁) 1997-12-17 Teranishi Yuuichi * v0.07 - "Distractions". * x-face-mule.el の設定を追加。 ドキュメントにも x-face-mule.el の説明を追加する。 1997-11-10 Teranishi Yuuichi * default-tab-width が設定されていると顔がずれるバグを解消. thanks to KORIYAMA Naohiro . 1997-11-05 塩野@FSC * buffer-rename して候補名を表示. 1997-11-05 Teranishi Yuuichi * x-face-append-out-first で空行がつくバグを fix. * x-face-insert が失敗した場合、その候補は無視するようにする。 1997-11-04 Teranishi Yuuichi * v0.06 - "Coming Up". * mew-xface-mule.el v0.05 を利用できるようにする。 * Mule2.3, Emacs20.2 に対応させるために XEmacs 固有の関数を排除。 1997-10-13 Teranishi Yuuichi * v0.05 - "Band On The Run". * ポップアップメニューを追加。 * select-xface-append-out-last を最初にやると空行がつくバグを fix. * select-xface-next-face と select-xface-prev-face の内容を入れ換える。 * X-Face フィールド挿入後のフック select-xface-insert-hook を新設。 1997-10-12 Katsumi Yamaoka * select-xface-insert 時に inhibit-read-only を t に拘束。 1997-10-09 Teranishi Yuuichi * v0.03 - "Another Day" elips release. 1997-10-07 Teranishi Yuuichi * 顔候補のリストをキャッシュするようにした。ディレクトリを読み直して 候補のリストを作り直す関数、select-xface-rebuild-face-list も新設。"r" に bind。 * select-xface-candidate-regexp を新設。regexp にマッチする名前を 持つ file か directory のみが候補となるようにする。default は nil。 * README.jis の 「face ファイル」は Emacs の face と混同しそうなので 「xface ファイル」に変えた。 1997-10-06 Teranishi Yuuichi * サブディレクトリの処理を再帰的にやるようにする。同時に関連関数を 大幅に書き換える。 1997-10-04 Teranishi Yuuichi * Select-XFace バッファで X-Face-Type を出すのを止める。 * select-xface-append-{first|last} を新設。 それぞれ [a ←]、[a →] に bind。 select-xface-append-last は space key にも bind。 1997-10-03 Katsumi Yamaoka * select-xface-directory などのユーザ変数の値を M-x set-variable で 変えることができるよう、doc string の先頭に "*" を入れる。 * select-xface-gzip-program の新設。 * select-xface-orig-window-config を defvar。 * x-face-insert を使う部分で *.xbm だけでなく *.xbm.gz も対象になるよ うにする。 * x-face-insert を使う部分で x-face-add-x-face-version-header を nil に拘束し、X-Face-Version が付かないようにする。 1997-10-02 Teranishi Yuuichi * v0.02 - "Jet" elips release. * X-Face utility v1.2.8 b3 に対応させて、カラー/マルチを 扱えるようにする。 1997-8-22 Teranishi Yuuichi * v0.01 Initial version - "Three-hours Hack" mew-dist release. select-xface-0.15/README.jis0100644000076400007640000001606507433741036015714 0ustar teranisiteranisiSelect X-Face -- select x-face graphically v0.15 Feb. 2002 Yuuichi Teranishi X-Face $B%U%#!<%k%I$NA^F~$r4i$N2hA|$r8+$J$,$iA*BrE*$K9T$($^$9!#(B XEmacs, Mule2.3@19.28, Mule2.3@19.34, Emacs 20.2$B!A(B $B$GF0:n3NG':Q$_$G$9!#(B Emacs/Mule $B$G4i$r8+$i$l$k$h$&$K$9$k$K$O!"(Bx-face-mule.el $B$,I,MW$G$9!#(B x-face-mule.el $B$O!"(Bftp://ftp.jpl.org/pub/elisp/x-face-mule-**.tar.gz $B$+$iF~H$7$F$/$@$5$$!#(B $B;H$$J}(B: 1. select-xface.el $B$r(B load-path $B$N$I$3$+$KCV$-!"%P%$%H%3%s%Q%$%k$7$^$9!#(B 2. $B%[!<%`%G%#%l%/%H%j$K(B .xfaces $B$H$$$&%G%#%l%/%H%j$r$D$/$j$^$9!#(B .xfaces $B$H$$$&%G%#%l%/%H%jL>$O(B .emacs $B$K(B (setq select-xface-directory "/anywhere/you/want") $B$H$$$&$+$s$8$N@_Dj$r2C$($l$PJQ99$G$-$^$9!#(B 3. 2. $B$N(B .xfaces $B%G%#%l%/%H%j$K!"8uJd$K$7$?$$(B xface $B%U%!%$%k(B $B$rJ#?tCV$-$^$9!#%U%!%$%kL>$O2?$G$b$h$$$G$9!#(B $B$3$3$G$$$&(B xface $B%U%!%$%k$H$O!"(BX-Face $B$N%G!<%?$=$N$^$^$NFbMF$r$b$D%U%!%$%k(B $B$r;X$7$^$9!#(B $BNc$($P!"$3$s$J$N$G$9!#(B --$B$3$3$+$i(B-- 03C/yqeE_(Zt@-l.JKp\)0fxhT=lLIuKJta/Sj<*DS_Q,"j&y-h|uJ]TaIuL_x5@e|#+rx| `W2z%G`\W{p>(FmB61%|"qcI|?#CP05@0?|jU.\A9le6f|+mQ7ShQS.Gd~t9vT<5?Y9$F_GmF$#RRF 0xHeO."!N[wDl)B|0?/Qtn[LI&has6UQe_NYaStsZb;K"TE_}X9YjG[)YU*7K --$B$3$3$^$G(B-- $BJ#?t$N(B X-Face $B$r0l$D$N8uJd$H$7$F07$&$3$H$b$G$-$^$9!#(B $B$3$N>l9g$O!"(B.xfaces $B$N2<$K%G%#%l%/%H%j$r:n$C$F$=$3$K0l$D$N8uJd$H$7$?$$(B $BJ#?t$N(B xface $B%U%!%$%k$rCV$-$^$9!#(B x-face.el $B$r$*;H$$$N>l9g$O(B X bitmap $B%U%!%$%k(B(gzip $B05=L$b2D(B)$B$b8uJd$H$9$k$3(B $B$H$,$G$-$^$9!#(B x-face.el $B$O;32,9nH~(B $B$5$s$i$K$h$C$F3+H/$5$l$F$$$k(B X-Face $B$r07$&$?$a$N%f!<%F%#%j%F%#$G$9!#(Bx-face.el v1.2.8 b3 $B0J9_$r$*;H$$$/(B $B$@$5$$!#(BX bitmap $B%U%!%$%k$N3HD%;R$O(B ".xbm" ($B$b$7$/$O(B ".xbm.gz")$B$H$7$F$/$@(B $B$5$$(B($B3HD%;R$GH=JL$7$F$$$^$9(B)$B!#(B $B$^$?!"(Bx-face 1.3.6.4 $B0J9_$G$O(B Animated X-Face $B$,MxMQ$G$-$^$9!#(B Animated X-Face $B$rA*Br8uJd$N0l$D$H$7$?$$>l9g$O!"(B --- X-Face-Type: animate=0.5; geometry=1x1 X-Face: 'M-Iu07RLXEn2_dm90%S0>;I_?Igs6\iQ(Nyb[76,5,`T"9'no}`Kp"\V8!YI4jLwftM>M X-Face: '~FmF"`$eK,BU|2UX}4&KT^D+&.?&|/UlD|M7fi'OZETC1:U4"]YSylN^h?C]@JN2$*_H0y ]m]V'tHN24}Le@5\~`B8SnRrcB>cZ`a'j.Q0ix/by17L4.Il)yB.!RZblv%:Q]_17l&FJXvf@@FH#c AtK9{yKNHiw5gT$:ID!UFU`:!z-;2-6Fc82V0"{sz%Tv1r"gJ&Y=rMnH8=~(SMP1nN/IV X-Face: A!9c@vh-@qlDZfYw7),BzNmBWQ$}p>WJnDxdB>_\6KC&4{Ndrv%=A-Tq%101t"Jf({G|NGF VSKs295lGgqXXj/lp2't4^;S=E%kv?hxf)~Yd{w>sjKY,WmK9+sXvjd^o:`Y.mK7Z9P"]BAvx`Bm&g v_l$)Zp[RQIfCF?GIy0{;1G)pI,CpR.@~}]vF8be:3js1j!^Sy>p=#q_![sC7y$s78fW X-Face: '~FmF"`$eK,BU|2UX}4&KT^D+&.?&|/UlD|M7fi'OZETC1:U4"]YSylN^h?C]@JN2$*_H0y ]m]V'tHN24}Le@5\~`B8SnRrcB>cZ`a'j.Q0ix/by17L4.Il)yB.!RZblv%:Q]_17l&FJXvf@@FH#c AtK9{yKNHiw5gT$:ID!UFU`:!z-;2-6Fc82V0"{sz%Tv1r"gJ&Y=rMnH8=~(SMP1nN/IV --- $B$N$h$&$JCf?H$r$b$D%U%!%$%k$KE,Ev$JL>A0$r$D$1$F(B .xfaces $B$N2<$KCV$$$F(B $B$/$@$5$$!#(B($BA*Br;~$K(B`$BF0$/(B'$B$h$&$K$9$k$K$O!"8e=R$N(B `x-face-xmas-replace-highlight-headers' $B$N@_Dj$,I,MW$G$9(B) $B$5$i$K!"%0%l!<%9%1!<%k$N(B X-Face $B$K$D$$$F$bF1MM$K!"(B --- X-Face: #Ek=$}&%CM;v2`2Bf@DqrQ|tSZO3K} IJS64l$qDWzyj}>Oc&dJm>BUY1=uIZ X-Face-1: ',mm@o.~l_F_Zl_^ZTm|n{x/D}m4@)9!GEh*^>PDA3F,&,1#VCZl+{P"Myk'!_uWBI,LA rBs/lV7E58eccGLW~t/wm({t+(j@kE5>Kedl\cKTpW@/OQJ0?qxV|SN^r,G~KmmVr+~ZSSpCXATG(z Yedk]MS:$=lBkMh8X:U66LSkY;;X<"Rco+cx/)o- X-Face-2: 0>G#dFq/Lc;~~aU#g+S!nRwX%r,QcnQ^,gzHUl0_mP5+q2[n-RmD`PtX`4fF_\3HRYEm: cXe+Fm%T=y\yG9>2R({]h:ye0HPkSYs>v;:H(PJCr]0S+HMgDy5ow\=SZyZ9ai*MFsxEe35(lb~M";;%jFPh 4=G#9!$*IrKz>ui((HH^|\URD-htum\kb64"JXM --- $B$N$h$&$JCf?H$r$b$D%U%!%$%k$KE,Ev$JL>A0$r$D$1$F(B .xfaces $B$N2<$KCV$1$P(B $BA*Br$N8uJd$H$J$j$^$9!#(B ($BNc(B) $BNc$($P!"$\$/$N(B .xfaces $B$O0J2<$N$h$&$K$J$C$F$$$^$9!#(B % cd ~/.xfaces % ls a b c multi/ teranisi.xbm % ls multi 1 2 3 a, b, c $B$O(B xface $B%U%!%$%k(B, multi $B$O%G%#%l%/%H%j(B, teranisi.xbm $B$O%S%C%H%^%C%W(B $B%U%!%$%k$G$9!#%G%#%l%/%H%j(B multi $B$N2<$K$O(B 1, 2, 3 $B$H$$$&(B xface $B%U%!%$%k$,$"$j(B $B$^$9!#$3$NNc$G$O!"8uJd$O(B a, b, c, (1,2,3$B$N(B3$B$D(B), teranisi.xbm $B$N(B 5 $B$D$H$J$j$^(B $B$9!#(B 4. .emacs $B$K0J2<$N$h$&$J@_Dj$r$7$^$9!#(B (autoload 'select-xface "select-xface" "Select X-Face" t) ;; Mew $B$N>l9g(B (add-hook 'mew-draft-mode-hook (lambda () (define-key (current-local-map) "\C-c\C-x" 'select-xface))) ;;; Gnus $B$N>l9g(B (add-hook 'gnus-message-setup-hook (lambda () (define-key (current-local-map) "\C-x4x" 'select-xface))) ;;; mh-e $B$N>l9g(B (add-hook 'mh-letter-mode-hook (lambda () (define-key (current-local-map) "\C-x4x" 'select-xface))) ;;; MAIL, RMAIL, VM, cmail, Wanderlust $B$N>l9g(B (add-hook 'mail-mode-hook (lambda () (define-key (current-local-map) "\C-x4x" 'select-xface))) ;; x-face.el $B$H$H$b$K;H$&>l9g$O!"0J2<$N@_Dj$r$7$^$9!#(B (require 'x-face) ;; highlight-headers $B$NF~$l49$((B (XEmacs $B$N>l9g(B) (x-face-xmas-replace-highlight-headers) 5. $B%a!<%i$N%a%C%;!<%8JT=8%b!<%I$G!"(B * ($B>e5-@_Dj$N(B Mew $B$N>l9g(B) C-c C-x $B$r$*$9$H!"4i$N8uJd$N3($,%]%C%W%"%C%W$7$^$9!#(B * C-p, C-n $B$G$7$F4i$N8uJd$r%m!<%I$7$J$*$7$^$9!#(B $B4{$K(B X-Face: $B%U%#!<%k%I$,B8:_$9$k>l9g$O!"$=$N4i$,:G=i$K8=$l$^$9!#(B .xfaces $B$KF1$84i$N8uJd$,J#?t$"$k>l9g$O!"$=$l$i$O(B 1 $B$D$N8uJd$K$J$j$^$9!#(B $B1~MQJT(B: ;; $BL>A0$,@55,I=8=$K%^%C%A$9$k8uJd$7$+;H$o$J$$$h$&$K$9$k!#(B (setq select-xface-candidate-regexp "\\.xbm\\(\\.gz\\)?$") ;; $B%P!<%8%g%s>pJs$b%X%C%@$KA^F~(B (setq select-xface-add-x-face-version-header t) ;; x-face $B$r$*;H$$$G!"(Bx-face-add-x-face-version-header $B$,(B non nil $B$N>l9g$O(B ;; select-xface-add-x-face-version-header $B$r@_Dj$7$J$/$F$b(B ;; x-face.el $B$H(Bselect-xface.el $B$N%P!<%8%g%s>pJs$,<+F0E*$KIU$12C$o$j$^$9!#(B ;; X-Face utility $B$r;H$C$F4iA^F~;~$K%a%C%;!<%8JT=8%P%C%U%!$K%$%a!<%8$r=P$9(B ;; (XEmacs $B$N>l9g(B) (add-hook 'select-xface-insert-hook (lambda () (x-face-xmas-display-x-face 1))) $B$B$5$s$r$O$8$a$H$9$k(B elips ML $B$N%a%s%P$NJ}!9$K$O!"5.=E$J8f=u8@!"5Z$S%Q%C%A$r8fDs6!$$$?$@$$$F$$$^$9!#(B $B$3$3$K46 ; Time-stamp: <2002-02-17 23:46:09 teranisi> ;; Copyright (C) 1997-2002 Yuuichi Teranishi ;; Author: Yuuichi Teranishi ;; Maintainer: Yuuichi Teranishi ;; Version: 0.15 ;; Target: Emacs, Mule, XEmacs ;; Select X-Face 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 ;; any later version. ;; Select X-Face 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, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;; Setup: ;; ;; (autoload 'select-xface "select-xface" "Select X-Face" t) ;; ;; For Mew: ;; (add-hook 'mew-draft-mode-hook ;; (lambda () ;; (define-key (current-local-map) "\C-c\C-x" ;; 'select-xface))) ;; ;; For Gnus: ;; (add-hook 'gnus-message-setup-hook ;; (lambda () ;; (define-key (current-local-map) "\C-x4x" ;; 'select-xface))) ;; For mh-e: ;; (add-hook 'mh-letter-mode-hook ;; (lambda () ;; (define-key (current-local-map) "\C-x4x" ;; 'select-xface))) ;; For MAIL, RMAIL, VM, cmail, Wanderlust: ;; (add-hook 'mail-mode-hook ;; (lambda () ;; (define-key (current-local-map) "\C-x4x" ;; 'select-xface))) ;;; Commentary: ;; ;;; Code: (defconst select-xface-appname "Select X-Face") (defconst select-xface-version-number "v0.15") (defconst select-xface-codename "Live And Let Die") (defconst select-xface-version (concat select-xface-appname " " select-xface-version-number " - \"" select-xface-codename "\"")) ;; ;; Users may set these variables ;; (defvar select-xface-directory "~/.xfaces" "*files or subdirectories in this directory become the candidates.") (defvar select-xface-height 5 "*height of the popup buffer.") (defvar select-xface-field-insert-before "^X-Mailer:\\|^User-Agent:\\|^--" "*insert xface field before this regexp.") (defvar select-xface-mode-hook nil "*hooks to be called after select-xface-mode starts.") (defvar select-xface-insert-hook nil "*hooks to be called after xface is inserted.") (defvar select-xface-candidate-regexp "^[^.].*" "*only file/directory names containing that regexp are adopted.") (defvar select-xface-gzip-program "gzip" "*gzip executable.") (defvar select-xface-add-x-face-version-header nil "*insert X-Face-Version header.") (defvar select-xface-header-separator-regexp "\\(^--.*$\\)\\|\\(\n\n\\)" "*header separator. (regexp)") (defvar select-xface-display-func (function (lambda (beg end) (cond ((featurep 'xemacs) (require 'highlight-headers) (let ((highlight-headers-hack-x-face-p t) (x-face-xmas-like-highlight-headers nil)) (highlight-headers beg end nil))) ((fboundp 'x-face-decode-message-header) (x-face-decode-message-header beg end)) (t nil)))) "xface display function.") ;; ;; No setting is needed for these variables. ;; (defvar select-xface-candidate-list nil) (defvar select-xface-face-list nil) (defvar select-xface-current-list-pos 0) (defvar select-xface-mode-map nil) (defvar select-xface-parent-buffer nil) (defvar select-xface-orig-window-config nil) (defvar select-xface-popup-menu nil) (defconst select-xface-buffer select-xface-appname) (defmacro select-xface-header-end () (` (save-excursion (goto-char (point-min)) (if (re-search-forward select-xface-header-separator-regexp nil t) (point))))) (if select-xface-mode-map nil (setq select-xface-mode-map (make-sparse-keymap)) (define-key select-xface-mode-map "p" 'select-xface-prev-face) (define-key select-xface-mode-map "\C-p" 'select-xface-prev-face) (define-key select-xface-mode-map [up] 'select-xface-prev-face) (define-key select-xface-mode-map "n" 'select-xface-next-face) (define-key select-xface-mode-map "\C-n" 'select-xface-next-face) (define-key select-xface-mode-map [down] 'select-xface-next-face) (define-key select-xface-mode-map "\C-m" 'select-xface-out) (define-key select-xface-mode-map "o" 'select-xface-out) (define-key select-xface-mode-map "q" 'select-xface-exit) (define-key select-xface-mode-map "\C-g" 'select-xface-exit) ; (define-key select-xface-mode-map [?a up] 'select-xface-append-out-top) (define-key select-xface-mode-map [?a right] 'select-xface-append-out-last) ; (define-key select-xface-mode-map [?a down] 'select-xface-append-out-bottom) (define-key select-xface-mode-map [?a left] 'select-xface-append-out-first) (define-key select-xface-mode-map " " 'select-xface-append-out-last) (define-key select-xface-mode-map "r" 'select-xface-rebuild-face-list) ) (defun select-xface-make-popup-menu () "define popup menu." (if (not select-xface-popup-menu) (easy-menu-define select-xface-popup-menu select-xface-mode-map "Menu for Select X-Face" '("Select X-Face" ["Prev" select-xface-prev-face t] ["Next" select-xface-next-face t] ["Output" select-xface-out t] ["Append" select-xface-append-out-last t] "----" ["Quit" select-xface-exit t] ) ) ) (easy-menu-add select-xface-popup-menu)) (defun select-xface-mode () ;;a up select-xface-append-out-top append the current as the top face ;;a down select-xface-append-out-bottom append the current as the bottom face "Major mode for select and insert X-Face: field in the current draft buffer. RET select-xface-out output the current face o select-xface-out output the current face C-n select-xface-next-face display the next candidate n select-xface-next-face display the next candidate C-p select-xface-prev-face display the previous candidate p select-xface-prev-face display the previous candidate a right select-xface-append-out-last append the current as the last face a left select-xface-append-out-first append the current as the first face r select-xface-rebuild-face-list rebuild face list SPC select-xface-append-out-last append the current as the last face C-g select-xface-exit quit selecting face q select-xface-exit quit selecting face " (interactive) (setq major-mode 'select-xface-mode) (setq mode-name select-xface-appname) (use-local-map select-xface-mode-map) (make-local-variable 'tab-width) (setq tab-width 8) (select-xface-make-popup-menu) (if (featurep 'xemacs) (set-specifier text-cursor-visible-p (cons (current-buffer) nil))) (run-hooks 'select-xface-mode-hook)) (defun select-xface-delete-all-xface-related-fields () "delete all xface related fields in the current buffer." (save-excursion (goto-char (point-min)) (while (re-search-forward "^\\(X-Face.*:\\) *\\(.*\\(\n[ \t].*\\)*\\)\n" (select-xface-header-end) t) (delete-region (match-beginning 0) (match-end 0)) (goto-char (point-min))))) (defun select-xface-collect-xface-related-fields () "collect the xface related fields in the current buffer." (let ((end (select-xface-header-end)) ret) (save-excursion (goto-char (point-min)) (while (re-search-forward "\\(^\\(X-Face-Type:\\)[ \t]*\\(.*\\(\n[ \t].*\\)*\\)\n\\)\\|\\(^\\(X-Face[-0-9]*:\\)[ \t]*\\(.*\\(\n[ \t].*\\)*\\)\n\\)" end t) (setq ret (concat ret (buffer-substring (match-beginning 0) (match-end 0))))) (if ret (let ((ret-len (length ret))) (if (string= (substring ret (- ret-len 1) ret-len) "\n") (setq ret (substring ret 0 (- ret-len 1))))))) ret)) (defun select-xface-append-out-last () "append the current face as the last face." (interactive) (setq this-command 'select-xface-out) (select-xface-insert (select-xface-make-out-xface) 'last) ) (defun select-xface-append-out-first () "append the current face as the frst face." (interactive) (setq this-command 'select-xface-out) (select-xface-insert (select-xface-make-out-xface) 'first)) (defun select-xface-append-out-top () "append the current face as the top face." (interactive) (select-xface-insert (select-xface-make-out-xface) 'top)) (defun select-xface-append-out-bottom () "append the current face as the bottom face." (interactive) (select-xface-insert (select-xface-make-out-xface) 'bottom)) (defun select-xface-make-append-xface (current-xface out-xface direction) "append the current face in the specified direction." (interactive) (let (insert-str) (cond ((eq direction 'top) (setq insert-str (concat "X-Face-Type: geometry=1x2\n" out-xface current-xface "\n"))) ((eq direction 'first) (setq insert-str (concat ;; "X-Face-Type: geometry=2x1\n" out-xface "\n" current-xface))) ((eq direction 'bottom) (setq insert-str (concat "X-Face-Type: geometry=1x2\n" (if current-xface (concat current-xface "\n")) out-xface))) (t ;; last or other (setq insert-str (concat ;; "X-Face-Type: geometry=2x1\n" (if current-xface (concat current-xface "\n")) out-xface)))) insert-str )) (defun select-xface-make-out-xface () "make output xface string from select-xface buffer." (nth select-xface-current-list-pos select-xface-face-list)) (defun select-xface-out () "output the current face." (interactive) (select-xface-insert (select-xface-make-out-xface))) (defun select-xface-insert (out-xface &optional append-direction) "insert the xface into the draft buffer." (save-window-excursion (delete-window) (let ((inhibit-read-only t) current-xface beg end ) (save-excursion (set-buffer select-xface-parent-buffer) (if append-direction (setq current-xface (select-xface-collect-xface-related-fields))) (select-xface-delete-all-xface-related-fields) (goto-char (point-min)) (re-search-forward select-xface-field-insert-before end t) (beginning-of-line) (setq beg (point)) (if append-direction (insert (select-xface-make-append-xface current-xface out-xface append-direction)) (insert out-xface)) (insert "\n") (put-text-property beg (point) 'invisible nil) (if (and (fboundp 'x-face-insert-version-header) x-face-add-x-face-version-header) (progn (setq beg (point)) (x-face-insert-version-header) (if (not (eq beg (point))) (progn (put-text-property beg (point) 'invisible nil) (insert (concat " with " select-xface-version "\n"))))) (if select-xface-add-x-face-version-header (insert (concat "X-Face-Version: " select-xface-version "\n")))) (run-hooks 'select-xface-insert-hook) ) ) ) (select-xface-exit)) (defun select-xface-prev-face () "display previous candidate." (interactive) (if (= 0 select-xface-current-list-pos) (select-xface-set-list-pos (1- (length select-xface-face-list))) (select-xface-set-list-pos (1- select-xface-current-list-pos)))) (defun select-xface-next-face () "display next candidate." (interactive) (if (= select-xface-current-list-pos (1- (length select-xface-face-list))) (select-xface-set-list-pos 0) (select-xface-set-list-pos (1+ select-xface-current-list-pos)))) (defun select-xface-set-invisible (string) "set string invisible." (save-excursion (goto-char (point-min)) (while (re-search-forward (concat "\\(" string "\\)") nil t) (put-text-property (match-beginning 1) (match-end 1) 'invisible t)))) (defun select-xface-set-list-pos (pos) "display nth candidate in the popup buffer." (setq select-xface-current-list-pos pos) ; (message (format "%d th entry." pos)) (let ((buffer-read-only nil) (entry (nth pos select-xface-face-list)) (xface-name (nth pos select-xface-candidate-list)) ) (setq xface-name (if xface-name xface-name "No name")) (erase-buffer) (if (not entry) () (if (string-match "^X-Face-Type: .*\n" entry) (progn (insert "From: \n") (insert entry) (insert "\n") (funcall select-xface-display-func (point-min) (point-max)) (goto-char (point-min)) (while (re-search-forward "^X-Face-Type: .*\n" nil t) (delete-region (match-beginning 0) (match-end 0))) (re-search-backward "From:" nil t) (select-xface-set-invisible "X-Face:") (select-xface-set-invisible "From:") (select-xface-set-invisible " ") ) (insert "From: \n") (insert entry) (insert "\n") (funcall select-xface-display-func (point-min) (point-max)) (goto-char (point-min)) (select-xface-set-invisible "From:") (select-xface-set-invisible " ")) (goto-char (point-max)) (if (featurep 'xemacs) (goto-char (point-min)) (while (char-equal (char-before (point)) ?\n) (backward-char 1))) (set-buffer-modified-p nil) (rename-buffer (concat select-xface-appname "(" xface-name ")")) (setq select-xface-buffer (concat select-xface-appname "(" xface-name ")")) ))) (defun select-xface-check-rgb (list) "check if files in the path are rgb." (let ((tmplist list)) (setq tmplist (delete "red" tmplist)) (setq tmplist (delete "green" tmplist)) (setq tmplist (delete "blue" tmplist)) (not tmplist))) (defun select-xface-make-candidate-list (path) "make file list in the path." (let (ret files attr) (setq ret (directory-files path nil select-xface-candidate-regexp nil)) (setq ret (delete "." ret)) (setq ret (delete ".." ret)) (setq files ret) (while files (setq attr (car files)) (if (car (file-attributes (expand-file-name attr path))) (setq ret (delete attr ret))) (setq files (cdr files))) ret) ) (defun select-xface-reduce-needless-character-in-buffer () "reduce needless character for xface in the buffer." (if (= 0 (buffer-size)) () ;; reduce a space character in the beginning of the buffer. (while (char-equal (char-after (point-min)) ? ) (progn (goto-char (point-min)) (delete-char 1))) ;; reduce a newline character in the end of the buffer. (while (char-equal (char-before (point-max)) ?\n) (progn (goto-char (1- (point-max))) (delete-char 1))))) (defun select-xface-reduce-needless-character-in-string (string) "reduce needless character for xface in the string." (let ((strlen (length string)) (ret-string string)) (if (= 0 strlen) () ;; reduce a newline character in the end of the string. (while (and (not (= strlen 0)) (string= (substring ret-string (- strlen 1) strlen) "\n")) (setq ret-string (substring ret-string 0 (- strlen 1))) (setq strlen (- strlen 1))) ;; reduce a space character in the beginning of the string. (while (and (not (= strlen 0)) (string= (substring ret-string 0 1) " ")) (setq ret-string (substring ret-string 1 strlen)) (setq strlen (- strlen 1)))) ret-string )) (defun select-xface-make-xface-string (candidate-name directory) "make xface string from face file." (save-excursion (let ((tmp-buffer (get-buffer-create (concat "*Select-X-Face-" (expand-file-name candidate-name directory) "-tmp*" ))) (coding-system-for-read 'binary) (coding-system-for-write 'binary) format-alist jka-compr-compression-info-list child-clist ret-string) (set-buffer tmp-buffer) (if (not (file-directory-p (expand-file-name candidate-name directory))) (progn (if (string-match "\\.xbm\\(\\.gz\\)?$" candidate-name) ;; ;; use X-Face utility for xbm or gzipped xbm file. ;; (if (fboundp 'x-face-insert) (let (x-face-add-x-face-version-header) (condition-case () (x-face-insert (expand-file-name candidate-name select-xface-directory)) (error (setq select-xface-candidate-list (delete candidate-name select-xface-candidate-list)) (message (format "%s has illegal contents(ignored)." candidate-name)))) (select-xface-reduce-needless-character-in-buffer) ) (message "xbm file is not supported.")) ;; ;; xface file. ;; (insert-file-contents (expand-file-name candidate-name directory)) (if (looking-at "\x1f\x8b") ; gzipped? (call-process-region (point-min) (point-max) select-xface-gzip-program t t nil "-cd")) (select-xface-reduce-needless-character-in-buffer) (goto-char (point-min)) (if (not (re-search-forward "X-Face:" nil t)) (insert "X-Face: "))) (setq ret-string (select-xface-reduce-needless-character-in-string (concat (buffer-substring (point-min) (point-max)))))) ;; ;; recursive subdirectory processing. ;; (setq child-clist (select-xface-make-candidate-list (expand-file-name candidate-name directory))) (if (select-xface-check-rgb child-clist) (progn (insert ) (setq ret-string (concat "X-Face-Type: RGB; geometry=1x1\n" (select-xface-make-xface-string "red" (expand-file-name candidate-name directory)))) (setq ret-string (concat ret-string "\n" (select-xface-make-xface-string "green" (expand-file-name candidate-name directory)))) (setq ret-string (concat ret-string "\n" (select-xface-make-xface-string "blue" (expand-file-name candidate-name directory))))) ;; (insert (format "X-Face-Type: geometry=%dx1\n" ;; (length child-flist))) ;; insert subdirectory candidates recursively. (let (cur-cname) (while child-clist (setq cur-cname (car child-clist)) (setq ret-string (concat ret-string (select-xface-make-xface-string cur-cname (expand-file-name candidate-name directory)) "\n" )) (setq child-clist (cdr child-clist))) ) )) (setq ret-string (select-xface-reduce-needless-character-in-string ret-string)) (if (string= ret-string "") (setq ret-string nil)) (kill-buffer tmp-buffer) ret-string ))) (defun select-xface-add-face-to-face-list (face &optional name) "add face to select-xface-face-list. returns pos." (let ((flist select-xface-face-list) (found nil) (pos 0) ) (catch 'loop (while flist (if (string= face (car flist)) (progn (setq found t) (throw 'loop nil)) (setq flist (cdr flist)) (setq pos (1+ pos)) ))) (if (and face (not found)) (setq select-xface-face-list (append select-xface-face-list (list face))) (if name (progn (setq select-xface-candidate-list (delete name select-xface-candidate-list)) (message "Same candidate already exists!")))) (if (not face) (setq pos 0)) pos)) (defun select-xface-rebuild-face-list () "rebuild face list from directory." (interactive) (setq select-xface-candidate-list nil) (setq select-xface-face-list nil) (select-xface-make-face-list) (if select-xface-face-list (select-xface-set-list-pos 0) (message "No X-Face candidates.") (select-xface-exit) ) ) (defun select-xface-make-face-list () "make face list from directory." ;; if select-xface-candidate-list is nil, all files or directories ;; that contain select-xface-candidate-regexp ;; in the select-xface-directory became the candidates. (if (not select-xface-candidate-list) (setq select-xface-candidate-list (select-xface-make-candidate-list select-xface-directory))) ;; make face list from candidate list. (if (not select-xface-face-list) (select-xface-make-face-list-from-candidate-list select-xface-candidate-list))) (defun select-xface-make-face-list-from-candidate-list (candidate-list) "make list of faces." (save-excursion (let ((ret-list nil) (clist candidate-list)) (while clist (select-xface-add-face-to-face-list (select-xface-make-xface-string (car clist) select-xface-directory) (car clist)) (setq clist (cdr clist))) ret-list ;; return value ))) (defun select-xface-pop-to-buffer (buf) "split current window." (split-window-vertically) (other-window 1) (switch-to-buffer buf)) (defun select-xface () "select xfaces graphically." (interactive) (if (not select-xface-display-func) (message "cannot display X-Face in your environment.") (setq select-xface-parent-buffer (buffer-name)) (select-xface-make-face-list) ;; add current face to candidate list. (let (pos) (setq pos (select-xface-add-face-to-face-list (select-xface-collect-xface-related-fields))) (if select-xface-face-list (progn (setq select-xface-orig-window-config (current-window-configuration)) (if (get-buffer select-xface-buffer) (select-xface-pop-to-buffer select-xface-buffer) (let* () (select-xface-pop-to-buffer select-xface-buffer) (enlarge-window (- select-xface-height (window-height))) (select-xface-set-list-pos pos) (toggle-read-only))) (select-xface-mode)) (message "No X-Face candidates.")) )) ) (defun select-xface-exit () "quit selecting xface." (interactive) (pop-to-buffer select-xface-parent-buffer) (set-window-configuration select-xface-orig-window-config) (kill-buffer select-xface-buffer) ) (provide 'select-xface) ;;; select-xface.el ends here