Changeset 71 for lang/elisp
- Timestamp:
- 01/30/09 23:52:02 (16 years ago)
- Location:
- lang/elisp/pdicv-mode/trunk
- Files:
-
- 1 removed
- 13 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/elisp/pdicv-mode/trunk/README.utf8
r67 r71 5 5 アルク刊「英辞郎」赤本・黒本CD-ROMに収録されているPDIC形式の辞書データや、 6 6 インターネット上で入手可能なPDIC形式の様々な辞書データリソースが利用できます。 7 [NEW]アルク刊「英辞郎 第四版」に収録されているUnicodeタイプの英辞郎データにも対応しました!(2009/1) 7 8 8 9 Unicode(BOCU)辞書にも対応しています。(要(?)Mule-UCS) … … 28 29 ◎ 作者連絡先 29 30 30 Naochan (Naoya TOZUKA) <pdicviewer@gmail.com>31 http:// www.naochan.com/32 http://d.hatena.ne.jp/naoya_t/ 31 naoya_t <naoya.t@aqua.plala.or.jp> 32 http://blog.livedoor.jp/naoya_t/ 33 33 34 34 35 ◎ 一次配布元 35 36 http://pdicviewer.naochan.com/el/ 37 36 svn://lambdarepos.svnrepository.com/svn/share/lang/elisp/pdicv-mode/trunk -
lang/elisp/pdicv-mode/trunk/nt-bocu.el
r67 r71 1 1 ;;; nt-bocu.el --- decode/encode BOCU-1 string (via utf-8, so requires Mule-UCS) 2 2 ;; 3 ;; Copyright (C) 2005 Naoya TOZUKA. All Rights Reserved.3 ;; Copyright (C) 2005-2009 naoya_t. All Rights Reserved. 4 4 ;; 5 ;; Author: Naoya TOZUKA <pdicviewer@gmail.com> 6 ;; Maintainer: Naoya TOZUKA <pdicviewer@gmail.com> 7 ;; Primary distribution site: http://pdicviewer.naochan.com/el/ 5 ;; Author: naoya_t <naoya.t@aqua.plala.or.jp> 6 ;; Maintainer: naoya_t <naoya.t@aqua.plala.or.jp> 7 ;; Primary distribution site: 8 ;; http://lambdarepos.svnrepository.com/svn/share/lang/elisp/pdicv-mode/trunk 8 9 ;; 9 10 ;; Created: 12 Feb 2005 … … 38 39 ((>= tr #x10) (- tr 10)) ;10 ... 19 >> 06 ... 0F 39 40 (t (1- tr)) ;01 ... 06 >> 00 ... 05 40 ) ; cond41 ) 41 )) 42 42 43 (defsubst nt:bocu-encode-trail-char (c) 43 44 "[BOCU] encode trail char" … … 47 48 ((>= c #x06) (+ c 10)) ;06 ... 0F >> 10 ... 19 48 49 (t (1+ c)) ;00 ... 05 >> 01 ... 06 49 ); cond 50 ) 50 )) 51 51 52 52 (defun nt:bocustr-to-rawcode-list (s) … … 67 67 ; trail 1 68 68 (setq tr (nt:bocu-decode-trail-char (aref s i)) i (1+ i)) 69 (setq diff (+ diff tr)) 70 ) 69 (setq diff (+ diff tr)) ) 71 70 ((< lead #x25) ;22-24 (L T T) 72 71 (setq diff (+ -10513 (* (- lead #x25) 243 243))) … … 76 75 ; trail 1 77 76 (setq tr (nt:bocu-decode-trail-char (aref s i)) i (1+ i)) 78 (setq diff (+ diff tr)) 79 ) 77 (setq diff (+ diff tr)) ) 80 78 ((< lead #x50) ;25-4f (L T) 81 79 (setq diff (+ -64 (* (- lead #x50) 243))) 82 80 ; trail 1 83 81 (setq tr (nt:bocu-decode-trail-char (aref s i)) i (1+ i)) 84 (setq diff (+ diff tr)) 85 ) 82 (setq diff (+ diff tr)) ) 86 83 ((< lead #xd0) ;50-cf (L) 87 (setq diff (- lead #x90)) 88 ) 84 (setq diff (- lead #x90)) ) 89 85 ((< lead #xfb) ;d0-fa (L T) 90 86 (setq diff (+ 64 (* (- lead #xd0) 243))) 91 87 ; trail 1 92 88 (setq tr (nt:bocu-decode-trail-char (aref s i)) i (1+ i)) 93 (setq diff (+ diff tr)) 94 ) 89 (setq diff (+ diff tr)) ) 95 90 ((< lead #xfe) ;fb-fd (L T T) 96 91 (setq diff (+ 10513 (* (- lead #xfb) 243 243))) … … 100 95 ; trail 1 101 96 (setq tr (nt:bocu-decode-trail-char (aref s i)) i (1+ i)) 102 (setq diff (+ diff tr)) 103 ) 97 (setq diff (+ diff tr)) ) 104 98 ((= lead #xfe) ;fe (L T T T) 105 99 (setq diff 187660) … … 112 106 ; trail 1 113 107 (setq tr (nt:bocu-decode-trail-char (aref s i)) i (1+ i)) 114 (setq diff (+ diff tr)) 115 ) 116 ((= lead #xff) ; reset 117 ) 118 ); end of cond. 108 (setq diff (+ diff tr)) ) 109 ((= lead #xff) )) ; reset 119 110 120 111 (cond … … 122 113 (push lead l) 123 114 ; (setq r (concat r (string lead))) 124 (if (< lead #x20) (setq pc #x40)) ;#x20�ʤ餽�Τޤ� ) 125 ((< lead #xff) 115 (if (< lead #x20) (setq pc #x40)) ) ;#x20�ʤ餽�Τޤ� ((< lead #xff) 126 116 (progn 127 117 (setq code (+ pc diff)) 128 118 (if (< code 0) (setq code 0));; error recovery 129 130 119 (push code l) 131 120 ; (setq r (concat r (if (> code 0) (code-to-utf8 code) "?"))) … … 140 129 )); pc 141 130 )) 142 (t (setq pc #x40)); #xFF: reset 143 ) 144 ); wend 145 (nreverse l) 146 ); let 147 ) 131 (t (setq pc #x40)) )); #xFF: reset 132 (nreverse l) )) 148 133 149 134 (defun nt:diff-to-bocustr (diff) … … 160 145 (setq t1 (% diff 243)) (setq diff (/ diff 243)) 161 146 ;(setq t0 diff) 162 (string #x21 (nt:bocu-encode-trail-char t1) (nt:bocu-encode-trail-char t2) (nt:bocu-encode-trail-char t3)) 163 ) 164 ) 147 (string #x21 (nt:bocu-encode-trail-char t1) (nt:bocu-encode-trail-char t2) (nt:bocu-encode-trail-char t3)) )) 165 148 ((< diff -10513) ; [-187660,-10513) : 22-24 166 149 (progn … … 169 152 (setq t1 (% diff 243)) (setq diff (/ diff 243)) 170 153 (setq t0 diff) 171 (string (+ #x22 t0) (nt:bocu-encode-trail-char t1) (nt:bocu-encode-trail-char t2)) 172 ) 173 ) 154 (string (+ #x22 t0) (nt:bocu-encode-trail-char t1) (nt:bocu-encode-trail-char t2)) )) 174 155 ((< diff -64) ; [-10513,-64) : 25-4F 175 156 (progn … … 177 158 (setq t1 (% diff 243)) (setq diff (/ diff 243)) 178 159 (setq t0 diff) 179 (string (+ #x25 t0) (nt:bocu-encode-trail-char t1)) 180 ) 181 ) 160 (string (+ #x25 t0) (nt:bocu-encode-trail-char t1)) )) 182 161 ((< diff 64) ; [-64,63) : 50-CF 183 162 (progn 184 163 (setq diff (- diff -64)) 185 164 (setq t0 diff) 186 (string (+ #x50 t0)) 187 ) 188 ) 165 (string (+ #x50 t0)) )) 189 166 ((< diff 10513) ; [64,10513) : D0-FA 190 167 (progn … … 192 169 (setq t1 (% diff 243)) (setq diff (/ diff 243)) 193 170 (setq t0 diff) 194 (string (+ #xD0 t0) (nt:bocu-encode-trail-char t1)) 195 ) 196 ) 171 (string (+ #xD0 t0) (nt:bocu-encode-trail-char t1)) )) 197 172 ((< diff 187660) ; [10513,187660) : FB-FD 198 173 (progn … … 201 176 (setq t1 (% diff 243)) (setq diff (/ diff 243)) 202 177 (setq t0 diff) 203 (string (+ #xFB t0) (nt:bocu-encode-trail-char t1) (nt:bocu-encode-trail-char t2)) 204 ) 205 ) 178 (string (+ #xFB t0) (nt:bocu-encode-trail-char t1) (nt:bocu-encode-trail-char t2)) )) 206 179 ((< diff 14536567) ; [187660,14536567) : FE 207 180 (progn … … 211 184 (setq t1 (% diff 243)) (setq diff (/ diff 243)) 212 185 ;(setq t0 diff) 213 (string #xFE (nt:bocu-encode-trail-char t1) (nt:bocu-encode-trail-char t2) (nt:bocu-encode-trail-char t3)) 214 ) 215 ) 216 (t (throw 'bocu-encode-diff 'overflow-exception)) 217 ); cond 218 ); let 219 ); caught 220 ) 186 (string #xFE (nt:bocu-encode-trail-char t1) (nt:bocu-encode-trail-char t2) (nt:bocu-encode-trail-char t3)) )) 187 (t (throw 'bocu-encode-diff 'overflow-exception)) )))) 221 188 222 189 (defun nt:rawcode-list-to-bocustr (l) ; not tested much … … 234 201 ((and (<= #x4E00 code) (<= code #x9FA5)) #x7711) 235 202 ((and (<= #xAC00 code) (<= code #xD7A3)) #xC1D1) 236 (t (+ (logand code #xffff80) #x40)))) 237 ); let* 238 ); wend 239 s 240 ); let* 241 ) 203 (t (+ (logand code #xffff80) #x40)))) )) 204 s)) 242 205 243 206 (defsubst nt:bocu-decode (s) … … 245 208 (let* ((rawcode-list (nt:bocustr-to-rawcode-list s)) 246 209 (utf8str (nt:rawcode-list-to-utf8str rawcode-list))) 247 (decode-coding-string utf8str 'utf-8) 248 ) 249 ) 210 (decode-coding-string utf8str 'utf-8) )) 250 211 251 212 (defsubst nt:bocu-encode (s) … … 253 214 (let* ((utf8str (encode-coding-string s 'utf-8)) 254 215 (rawcode-list (nt:utf8str-to-rawcode-list utf8str)) 255 (bocustr (nt:rawcode-list-to-bocustr rawcode-list)) 256 ) 257 bocustr 258 ) 259 ) 216 (bocustr (nt:rawcode-list-to-bocustr rawcode-list))) 217 bocustr)) 260 218 261 219 ;;; nt-bocu.el ends here -
lang/elisp/pdicv-mode/trunk/nt-english.el
r67 r71 1 1 ;;; nt-english.el --- English 2 2 ;; 3 ;; Copyright (C) 2005 Naoya TOZUKA. All Rights Reserved.3 ;; Copyright (C) 2005-2009 naoya_t. All Rights Reserved. 4 4 ;; 5 ;; Author: Naoya TOZUKA <pdicviewer@gmail.com> 6 ;; Maintainer: Naoya TOZUKA <pdicviewer@gmail.com> 7 ;; Primary distribution site: http://pdicviewer.naochan.com/el/ 5 ;; Author: naoya_t <naoya.t@aqua.plala.or.jp> 6 ;; Maintainer: naoya_t <naoya.t@aqua.plala.or.jp> 7 ;; Primary distribution site: 8 ;; http://lambdarepos.svnrepository.com/svn/share/lang/elisp/pdicv-mode/trunk 8 9 ;; 9 10 ;; Created: 23 Dec 2005 … … 261 262 ((null word) (throw 'block nil)) 262 263 ((string= word "") (throw 'block nil)) 263 (t nil) 264 ) 264 (t nil)) 265 265 266 266 (let* ((word-len (length word)) … … 273 273 (setq suffix-1 (substring word -1 nil)) 274 274 275 (if (>= word-len 2) 276 (progn 277 (setq body-2 (substring word 0 -2)) 278 (setq suffix-2 (substring word -2 nil)) 279 280 (if (>= word-len 3) 281 (progn 282 (setq body-3 (substring word 0 -3)) 283 (setq suffix-3 (substring word -3 nil)) 284 285 (if (>= word-len 4) 286 (progn 287 (setq body-4 (substring word 0 -4)) 288 (setq suffix-4 (substring word -4 nil)) 289 )) 290 )) 291 )) 275 (when (>= word-len 2) 276 (setq body-2 (substring word 0 -2)) 277 (setq suffix-2 (substring word -2 nil)) 278 (when (>= word-len 3) 279 (setq body-3 (substring word 0 -3)) 280 (setq suffix-3 (substring word -3 nil)) 281 (when (>= word-len 4) 282 (setq body-4 (substring word 0 -4)) 283 (setq suffix-4 (substring word -4 nil))))) 292 284 293 285 ;; irregular verbs/nouns first. 294 286 (setq tmp (cdr (assoc word nt-english-irreg-verbs-list))) 295 ( iftmp (throw 'block (list tmp)))287 (when tmp (throw 'block (list tmp))) 296 288 (setq tmp (cdr (assoc word nt-english-irreg-nouns-list))) 297 ( iftmp (throw 'block (list tmp)))289 (when tmp (throw 'block (list tmp))) 298 290 299 291 (cond … … 328 320 ((string= suffix-2 "'s") (list body-2)) 329 321 330 (t nil) ;; ������ʤ��������������� 331 ) ;cond 332 ) ;let 333 );caught 334 ) 322 (t nil))))) ;; ������ʤ��������������� 335 323 336 324 (defmacro nt:skipit-p (word) -
lang/elisp/pdicv-mode/trunk/nt-file.el
r67 r71 1 1 ;;; nt-file.el --- file-related functions 2 2 ;; 3 ;; Copyright (C) 2005 Naoya TOZUKA. All Rights Reserved.3 ;; Copyright (C) 2005-2009 naoya_t. All Rights Reserved. 4 4 ;; 5 ;; Author: Naoya TOZUKA <pdicviewer@gmail.com> 6 ;; Maintainer: Naoya TOZUKA <pdicviewer@gmail.com> 7 ;; Primary distribution site: http://pdicviewer.naochan.com/el/ 5 ;; Author: naoya_t <naoya.t@aqua.plala.or.jp> 6 ;; Maintainer: naoya_t <naoya.t@aqua.plala.or.jp> 7 ;; Primary distribution site: 8 ;; http://lambdarepos.svnrepository.com/svn/share/lang/elisp/pdicv-mode/trunk 8 9 ;; 9 10 ;; Created: 16 Feb 2005 (formerly nt-utils) … … 36 37 (setq my-buffer (buffer-substring 1 (+ 1 read-length))) 37 38 (kill-buffer buffer-name) 38 my-buffer 39 ) ; let 40 ) ; save-current-buffer 41 ) 39 my-buffer))) 42 40 43 41 (defun nt:scan-latest-version (filename-format min max) … … 47 45 (let ((file (format filename-format version))) 48 46 (if (file-readable-p file) (throw 'scan-latest-version (list file version)) 49 (setq version (1- version)) 50 );fi 51 );let 52 );wend 53 nil 54 );let 55 );caught 56 ) 47 (setq version (1- version))))) 48 nil))) 57 49 58 50 ;;; nt-file.el ends here -
lang/elisp/pdicv-mode/trunk/nt-macros.el
r67 r71 1 1 ;;; nt-macros.el --- useful (at least for NT) macros 2 2 ;; 3 ;; Copyright (C) 2005 Naoya TOZUKA. All Rights Reserved.3 ;; Copyright (C) 2005-2009 naoya_t. All Rights Reserved. 4 4 ;; 5 ;; Author: Naoya TOZUKA <pdicviewer@gmail.com> 6 ;; Maintainer: Naoya TOZUKA <pdicviewer@gmail.com> 7 ;; Primary distribution site: http://pdicviewer.naochan.com/el/ 5 ;; Author: naoya_t <naoya.t@aqua.plala.or.jp> 6 ;; Maintainer: naoya_t <naoya.t@aqua.plala.or.jp> 7 ;; Primary distribution site: 8 ;; http://lambdarepos.svnrepository.com/svn/share/lang/elisp/pdicv-mode/trunk 8 9 ;; 9 10 ;; Created: 16 Feb 2005 (formerly nt-utils.el) -
lang/elisp/pdicv-mode/trunk/nt-readval.el
r67 r71 1 1 ;;; nt-readval.el --- read value or a string from buffer 2 2 ;; 3 ;; Copyright (C) 2005 Naoya TOZUKA. All Rights Reserved.3 ;; Copyright (C) 2005-2009 naoya_t. All Rights Reserved. 4 4 ;; 5 ;; Author: Naoya TOZUKA <pdicviewer@gmail.com> 6 ;; Maintainer: Naoya TOZUKA <pdicviewer@gmail.com> 7 ;; Primary distribution site: http://pdicviewer.naochan.com/el/ 5 ;; Author: naoya_t <naoya.t@aqua.plala.or.jp> 6 ;; Maintainer: naoya_t <naoya.t@aqua.plala.or.jp> 7 ;; Primary distribution site: 8 ;; http://lambdarepos.svnrepository.com/svn/share/lang/elisp/pdicv-mode/trunk 8 9 ;; 9 10 ;; Created: 06 Feb 2005 … … 29 30 (if (not index) (setq index 0)) 30 31 (if (or (< index 0) (<= (length s) index)) (throw 'uchar 'out-of-bounds-exception)) 31 (aref s index) 32 ) 33 ) 32 (aref s index))) 34 33 35 34 ;;=========================================================== … … 48 47 (if (or (< index 0) (<= (length s) index)) (throw 'char 'out-of-bounds-exception)) 49 48 (setq c (aref s index)) 50 (if (< c 128) c (- c 256)) ; =result 51 ); let 52 ); caught 53 ) 49 (if (< c 128) c (- c 256))))) ; =result 54 50 55 51 ;;============================================================== … … 63 59 (if (or (< index 0) (< (- (length s) 2) index)) (throw 'ushort 'out-of-bounds-exception)) 64 60 (+ (lsh (aref s (1+ index)) 8) 65 (aref s index)) 66 ) 67 ) 61 (aref s index)))) 68 62 69 63 (defsubst nt:read-ushort-bigendian (s &optional index) … … 73 67 (if (or (< index 0) (< (- (length s) 2) index)) (throw 'ushort 'out-of-bounds-exception)) 74 68 (+ (lsh (aref s index) 8) 75 (aref s (1+ index))) 76 ) 77 ) 69 (aref s (1+ index))))) 78 70 79 71 (defmacro nt:read-ushort-littleendian (s &optional index) … … 90 82 (let ((us (nt:read-ushort s index))) 91 83 (if (eq us 'out-of-bounds-exception) (throw 'short us)) 92 (if (< us 32768) us (- us 65536)) 93 ) ; let 94 );caught 95 ) 84 (if (< us 32768) us (- us 65536))))) 96 85 97 86 (defsubst nt:read-short-bigendian (s &optional index) … … 100 89 (let ((us (nt:read-ushort-bigendian s index))) 101 90 (if (eq us 'out-of-bounds-exception) (throw 'short us)) 102 (if (< us 32768) us (- us 65536)) 103 ) ; let 104 ) 105 ) 91 (if (< us 32768) us (- us 65536))))) 106 92 107 93 (defmacro nt:read-short-littleendian (s &optional index) … … 123 109 (if (or (< index 0) (< (- (length s) 4) index)) (throw 'long 'out-of-bounds-exception)) 124 110 125 (let* ( 126 (hh (aref s (+ index 3))) 127 (h0 (lsh hh -4)) 128 ) 129 111 (let* ((hh (aref s (+ index 3))) 112 (h0 (lsh hh -4))) 130 113 (cond ((zerop h0) nil) ; plus 131 114 ((= h0 15) nil) ; minus 132 115 ; (t (setq hh (logand 15 hh))) 133 116 ((< h0 8) (throw 'long 'overflow-exception)) 134 ((>= h0 8) (throw 'long 'underflow-exception)) 135 ) 117 ((>= h0 8) (throw 'long 'underflow-exception))) 136 118 ; (logior (lsh (aref s (+ index 3)) 24) 137 119 (logior (lsh hh 24) 138 120 (lsh (aref s (+ index 2)) 16) 139 121 (lsh (aref s (1+ index)) 8) 140 (aref s index)) 141 ) 142 ) 143 ) 122 (aref s index))))) 144 123 145 124 (defsubst nt:read-long-bigendian (s &optional index) … … 150 129 (if (or (< index 0) (< (- (length s) 4) index)) (throw 'long 'out-of-bounds-exception)) 151 130 152 (let* ( 153 (hh (aref s index)) 154 (h0 (lsh hh -4)) 155 ) 156 131 (let* ((hh (aref s index)) 132 (h0 (lsh hh -4))) 157 133 (cond ((zerop h0) nil) ; plus 158 134 ((= h0 15) nil) ; minus 159 135 ; (t (setq hh (logand 15 hh))) 160 136 ((< h0 8) (throw 'long 'overflow-exception)) 161 ((>= h0 8) (throw 'long 'underflow-exception)) 162 ) 137 ((>= h0 8) (throw 'long 'underflow-exception))) 163 138 ; (logior (lsh (aref s (+ index 3)) 24) 164 139 (logior (lsh hh 24) 165 140 (lsh (aref s (1+ index)) 16) 166 141 (lsh (aref s (+ index 2)) 8) 167 (aref s (+ index 3))) 168 ) 169 ) 170 ) 142 (aref s (+ index 3)))))) 171 143 172 144 (defmacro nt:read-long-littleendian (s &optional index) … … 188 160 (if (or (< index 0) (< (- (length s) 4) index)) (throw 'ulong 'out-of-bounds-exception)) 189 161 190 (let* ( 191 (hh (aref s (+ index 3))) 192 (h0 (lsh hh -4)) 193 ) 194 162 (let* ((hh (aref s (+ index 3))) 163 (h0 (lsh hh -4))) 195 164 (cond ((zerop h0) nil) ; plus 196 165 ; (t (setq hh (logand 15 hh))) … … 200 169 (lsh (aref s (+ index 2)) 16) 201 170 (lsh (aref s (1+ index)) 8) 202 (aref s index)) 203 ) 204 ) 205 206 ; (let ((sl (long s index))) 207 ; (if (>= sl 0) sl 0) 208 ; ) 209 ) 171 (aref s index))))) 210 172 211 173 (defsubst nt:read-ulong-bigendian (s &optional index) … … 216 178 (if (or (< index 0) (< (- (length s) 4) index)) (throw 'ulong 'out-of-bounds-exception)) 217 179 218 (let* ( 219 (hh (aref s index)) 220 (h0 (lsh hh -4)) 221 ) 222 180 (let* ((hh (aref s index)) 181 (h0 (lsh hh -4))) 223 182 (cond ((zerop h0) nil) ; plus 224 183 ; (t (setq hh (logand 15 hh))) … … 228 187 (lsh (aref s (1+ index)) 16) 229 188 (lsh (aref s (+ index 2)) 8) 230 (aref s (+ index 3))) 231 ) 232 ) 233 234 ; (let ((sl (long s index))) 235 ; (if (>= sl 0) sl 0) 236 ; ) 237 ) 189 (aref s (+ index 3)))))) 238 190 239 191 (defmacro nt:read-ulong-littleendian (s &optional index) … … 255 207 ; (if (> ofs-max 248) (setq ofs-max 248)) 256 208 (while (< ofs ofs-max) 257 (if (zerop (aref s (+ index ofs))) 258 (throw 'cstring (cons (substring s index (+ index ofs)) ofs) ) 259 ) 260 (setq ofs (1+ ofs)) 261 ) 262 (cons (substring s index nil) ofs-max) 263 ) 264 ) 265 ) 209 (if (zerop (aref s (+ index ofs))) 210 (throw 'cstring (cons (substring s index (+ index ofs)) ofs) )) 211 (setq ofs (1+ ofs))) 212 (cons (substring s index nil) ofs-max)))) 266 213 267 214 ;;============================================== … … 278 225 (size (nt:read-uchar s index)) ) 279 226 (if (> (1+ size) ofs-max) (throw 'pstring 'out-of-bounds-exception)) 280 (throw 'pstring (cons (substring s (1+ index) (+ index 1 size)) size) ) 281 ); let 282 ); caught 283 ) 227 (throw 'pstring (cons (substring s (1+ index) (+ index 1 size)) size) )))) 284 228 285 229 (defsubst nt:read-bcd (s ofs bytes) … … 289 233 (setq c (aref s (+ ofs i))) 290 234 (setq n (+ (* n 100) (* (lsh c -4) 10) (logand c #x0f))) 291 (setq i (1+ i)) ;; (++ i) 292 );wend 293 n 294 );let 295 ) 235 (setq i (1+ i))) ;; (++ i) 236 n)) 296 237 297 238 ;;; nt-readval.el ends here -
lang/elisp/pdicv-mode/trunk/nt-string.el
r67 r71 1 1 ;;; nt-string.el --- NT's string utilities 2 3 2 ;; 4 ;; Copyright (C) 2005 Naoya TOZUKA. All Rights Reserved.3 ;; Copyright (C) 2005-2009 naoya_t. All Rights Reserved. 5 4 ;; 6 ;; Author: Naoya TOZUKA <pdicviewer@gmail.com> 7 ;; Maintainer: Naoya TOZUKA <pdicviewer@gmail.com> 8 ;; Primary distribution site: http://pdicviewer.naochan.com/el/ 5 ;; Author: naoya_t <naoya.t@aqua.plala.or.jp> 6 ;; Maintainer: naoya_t <naoya.t@aqua.plala.or.jp> 7 ;; Primary distribution site: 8 ;; http://lambdarepos.svnrepository.com/svn/share/lang/elisp/pdicv-mode/trunk 9 9 ;; 10 10 ;; Created: 16 Feb 2005 … … 44 44 (i 0)) 45 45 46 ( ifn47 (if(or (> n s1-length) (> n s2-length))48 49 ( if(null n)50 46 (when n 47 (when (or (> n s1-length) (> n s2-length)) 48 (setq n nil strncmp-p nil))) 49 (when (null n) 50 (setq n (min s1-length s2-length))) 51 51 52 (if (zerop n) (throw 'strcmp 0)) 53 52 (when (zerop n) (throw 'strcmp 0)) 54 53 55 54 (while (< i n) 56 55 (let ((s1-i (aref s1 i)) 57 56 (s2-i (aref s2 i))) 58 (if (/= s1-i s2-i) (throw 'strcmp (- s1-i s2-i))) 59 );let 60 (setq i (1+ i)) 61 );wend 57 (when (/= s1-i s2-i) (throw 'strcmp (- s1-i s2-i)))) 58 (setq i (1+ i))) 62 59 63 60 ;nʸ����1=s2 … … 82 79 (while (<= i till) 83 80 (setq at (string-match r str i)) 84 ( if(null at) (throw 'replace-in-string (concat result (substring str i))))81 (when (null at) (throw 'replace-in-string (concat result (substring str i)))) 85 82 86 83 (setq result (concat result (substring str i at) n)) 87 (setq i (+ at r-len)) 88 ); wend 89 result 90 ); let 91 ); caught 92 ) 84 (setq i (+ at r-len))) 85 result))) 93 86 94 87 (defun nt:replace-all (str regex subst) … … 103 96 (progn 104 97 (setq result (concat result (substring str ofs found-at) subst)) 105 (setq ofs (match-end 0)) 106 ) 98 (setq ofs (match-end 0))) 107 99 (progn 108 100 (setq result (concat result (substring str ofs last))) 109 (throw 'while nil) 110 )) 111 );let 112 );wend 113 );caught 114 result 115 );let 116 ) 101 (throw 'while nil)))))) 102 result)) 117 103 118 104 (defun nt:rtrim (str) … … 121 107 (let ((i (1- (length str)))) 122 108 (while (> i 0) 123 (if (> (aref str i) #x20) (throw 'rtrim (substring str 0 (1+ i)))) 124 (-- i) 125 );wend 126 );let 127 );caught 128 ) 109 (when (> (aref str i) #x20) (throw 'rtrim (substring str 0 (1+ i)))) 110 (-- i))))) 129 111 130 112 (defun nt:ltrim (str) … … 133 115 (let ((len (length str)) (i 0)) 134 116 (while (< i len) 135 (if (> (aref str i) #x20) (throw 'ltrim (substring str i len))) 136 (++ i) 137 );wend 138 );let 139 );caught 140 ) 117 (when (> (aref str i) #x20) (throw 'ltrim (substring str i len))) 118 (++ i))))) 141 119 142 120 ;(defun nt:trim (str) 143 121 ; "trim" 144 ; (nt:ltrim (nt:rtrim str)) 145 ; ) 122 ; (nt:ltrim (nt:rtrim str))) 146 123 (defmacro nt:trim (str) 147 124 "trim" 148 `(nt:ltrim (nt:rtrim ,str)) 149 ) 125 `(nt:ltrim (nt:rtrim ,str))) 150 126 151 127 ;;; nt-string.el ends here -
lang/elisp/pdicv-mode/trunk/nt-utf8.el
r67 r71 2 2 ;;; some functions require Mule-UCS 3 3 ;; 4 ;; Copyright (C) 2005 Naoya TOZUKA. All Rights Reserved.4 ;; Copyright (C) 2005-2009 naoya_t. All Rights Reserved. 5 5 ;; 6 ;; Author: Naoya TOZUKA <pdicviewer@gmail.com> 7 ;; Maintainer: Naoya TOZUKA <pdicviewer@gmail.com> 8 ;; Primary distribution site: http://pdicviewer.naochan.com/el/ 6 ;; Author: naoya_t <naoya.t@aqua.plala.or.jp> 7 ;; Maintainer: naoya_t <naoya.t@aqua.plala.or.jp> 8 ;; Primary distribution site: 9 ;; http://lambdarepos.svnrepository.com/svn/share/lang/elisp/pdicv-mode/trunk 9 10 ;; 10 11 ;; Created: 14 Feb 2005 -
lang/elisp/pdicv-mode/trunk/pdicv-core.el
r67 r71 1 1 ;;; pdicv-core.el --- core functions for PDIC-formatted dictionaries 2 2 ;; 3 ;; Copyright (C) 2005 Naoya TOZUKA. All Rights Reserved.3 ;; Copyright (C) 2005-2009 naoya_t. All Rights Reserved. 4 4 ;; 5 ;; Author: Naoya TOZUKA <pdicviewer@gmail.com> 6 ;; Maintainer: Naoya TOZUKA <pdicviewer@gmail.com> 7 ;; Primary distribution site: http://pdicviewer.naochan.com/el/ 5 ;; Author: naoya_t <naoya.t@aqua.plala.or.jp> 6 ;; Maintainer: naoya_t <naoya.t@aqua.plala.or.jp> 7 ;; Primary distribution site: 8 ;; http://lambdarepos.svnrepository.com/svn/share/lang/elisp/pdicv-mode/trunk 8 9 ;; 9 10 ;; Created: 14 Feb 2005 10 ;; Last modified: 23 Dec 200511 ;; Version: 0.9. 112 ;; Keywords: PDIC dictionary search 11 ;; Last modified: 30 Jan 2009 12 ;; Version: 0.9.2 13 ;; Keywords: PDIC dictionary search eijiro 13 14 14 15 (provide 'pdicv-core) 15 ;(put 'pdicv-core 'version "0.9. 1")16 ;(put 'pdicv-core 'version "0.9.2") 16 17 17 18 ;;; Commentary: 18 19 19 20 ; (pdicv-get-header-info FILENAME) 20 ; - �إå���� 21 ; - ��ؒ�Ò���������ߒ�蒤� 22 ; (pdicv-get-index-list FILENAME [WORD-ENCODING]) 23 ; - PDIC��������������뒤���钡���������Ò�������꒥���Ȓ���� 21 24 ; 22 ; (pdicv-get-index-list FILENAME [WORD-ENCODING])23 ; - PDIC��������뤫�顢����å����ꥹ�Ȥ��;24 25 ; (pdicv-scan-datablock FILENAME PHYS CRITERIA-FUNC) 25 ; - �ǡ����֥������� 26 ; - ��ǒ�������֒�풥Ò���������㒥�; (pdicv-core-search DICINFO CRITERIA [SIMPLE-MODE-P DONT-CLEAR-P]) 27 ; - PDIC��������������뒡������ 26 28 ; 27 ; (pdicv-core-search DICINFO CRITERIA [SIMPLE-MODE-P DONT-CLEAR-P])28 ; - PDIC��������롼���;29 29 30 30 ;;; Code: … … 49 49 (defvar pdicv-result-height 8) 50 50 ; 51 ; �إå���� 52 ; 51 ; ��ؒ�Ò���������ߒ�蒤� 53 52 (defun pdicv-get-header-info (filename) 54 53 "[PDIC] Get Header Info" … … 56 55 (let* ((header-buf (nt:read-from-file filename 0 256)) 57 56 ; 58 (headername nil); (substring header-buf 1 100))59 (dictitle nil); (substring header-buf 101 140))57 (headername nil); (substring header-buf 1 100)) 58 (dictitle nil); (substring header-buf 101 140)) 60 59 (version (nt:read-short header-buf 140)) 61 60 (lword (nt:read-short header-buf 142)) … … 85 84 86 85 (setq version 87 (nth major-version '(not-supported not-supported newdic1 newdic2 newdic3 newdic4 )))86 (nth major-version '(not-supported not-supported newdic1 newdic2 newdic3 newdic4 unicode-bocu-6))) 88 87 89 88 (setq dicorder 90 89 (nth (nt:read-uchar header-buf 164) '(code-order ignore-case dictionary-order order-descendant))) 91 90 92 (if (> (logand dictype 128) 0) (setq dictype* (cons 'tree-view-mode dictype*))) 93 (if (> (logand dictype 64) 0) (setq dictype* (cons 'crypted dictype*))) 94 ; (if (> (logand dictype 32) 0) (setq dictype* (cons 'multilingual dictype*))) 95 (if (> (logand dictype 16) 0) (setq dictype* (cons 'unicode dictype*))) 96 (if (> (logand dictype 8) 0) (setq dictype* (cons 'bocu dictype*))) 97 (if (> (logand dictype 1) 0) (setq dictype* (cons 'ar-compressed dictype*))) 98 99 (if (= major-version 5) 100 (progn "HyperDIC, Ver 5.00" 101 (setq os (nt:read-char header-buf 167)) 102 (setq os (cond ((= os 0) 'sjis-crlf) 103 ((= os 1) 'sjis-cr) 104 ((= os 2) 'sjis-lf) 105 ((= os 3) 'euc-lf) 106 ((= os 4) 'jis-lf) 107 ((= os 32) 'bocu) 108 )) 109 (if (eq os 'bocu) (setq bocu t)) 110 (setq olenumber (nt:read-long header-buf 168)) 111 ;(setq lid-word (short header-buf 172)) 112 ;(setq lid-japa (short header-buf 174)) 113 ;(setq lid-exp (short header-buf 176)) 114 ;(setq lid-pron (short header-buf 178)) 115 ;(setq lid-other (short header-buf 180)) 116 (setq index-blkbit (if (= (nt:read-uchar header-buf 182) 1) 32 16)) 117 ; dummy0 @185 118 (setq extheader (nt:read-ulong header-buf 184)) 119 (setq empty-block (nt:read-long header-buf 188)) ;overwrite 120 (setq nindex (nt:read-long header-buf 192)) ;overwrite 121 (setq nblock (nt:read-long header-buf 196)) ;overwrite 122 (setq datablock-size (* nblock block-size)) 123 (setq cypt (substring header-buf 200 208)) ;- reserved[8] 124 (setq update-count (nt:read-ulong header-buf 208)) 91 (when (> (logand dictype 128) 0) (setq dictype* (cons 'tree-view-mode dictype*))) 92 (when (> (logand dictype 64) 0) (setq dictype* (cons 'crypted dictype*))) 93 ; (when (> (logand dictype 32) 0) (setq dictype* (cons 'multilingual dictype*))) 94 (when (> (logand dictype 16) 0) (setq dictype* (cons 'unicode dictype*))) 95 (when (> (logand dictype 8) 0) (setq dictype* (cons 'bocu dictype*))) 96 (when (> (logand dictype 1) 0) (setq dictype* (cons 'ar-compressed dictype*))) 97 98 (case major-version 99 (6 "Ver 6.xx" 100 (setq os (nt:read-char header-buf 167)) 101 (setq os (cond ((= os 0) 'sjis-crlf) 102 ((= os 1) 'sjis-cr) 103 ((= os 2) 'sjis-lf) 104 ((= os 3) 'euc-lf) 105 ((= os 4) 'jis-lf) 106 ((= os 32) 'bocu) 107 )) 108 (when (eq os 'bocu) (setq bocu t)) 109 (setq olenumber (nt:read-long header-buf 168)) 110 ;; dummy_lid, 10 bytes 111 (setq index-blkbit (if (= (nt:read-uchar header-buf 182) 1) 32 16)) 112 ;; dummy0 @185 113 (setq extheader (nt:read-ulong header-buf 184)) 114 (setq empty-block (nt:read-long header-buf 188)) ;overwrite 115 (setq nindex (nt:read-long header-buf 192)) ;overwrite 116 (setq nblock (nt:read-long header-buf 196)) ;overwrite 117 (setq datablock-size (* nblock block-size)) 118 (setq cypt (substring header-buf 200 208)) ;- reserved[8] 119 (setq update-count (nt:read-ulong header-buf 208)) 125 120 ; dummy00 @212[4] 126 121 (setq dicident (substring header-buf 216 224)) 127 122 ;(setq dummy (substring header-buf 224 256)) 128 (setq index-size (* index-block block-size)) ;overwrite 129 130 );progn 131 (progn "< 5.0" 132 (if (>= major-version 3) 133 (progn "NEWDIC2-" 134 (setq olenumber (nt:read-long header-buf 167)) 123 (setq index-size (* index-block block-size)) ;overwrite 124 );6 125 (5 "HyperDIC, Ver 5.00" 126 (setq os (nt:read-char header-buf 167)) 127 (setq os (cond ((= os 0) 'sjis-crlf) 128 ((= os 1) 'sjis-cr) 129 ((= os 2) 'sjis-lf) 130 ((= os 3) 'euc-lf) 131 ((= os 4) 'jis-lf) 132 ((= os 32) 'bocu) 133 )) 134 (when (eq os 'bocu) (setq bocu t)) 135 (setq olenumber (nt:read-long header-buf 168)) 136 (setq index-blkbit (if (= (nt:read-uchar header-buf 182) 1) 32 16)) 137 ;; dummy0 @185 138 (setq extheader (nt:read-ulong header-buf 184)) 139 (setq empty-block (nt:read-long header-buf 188)) ;overwrite 140 (setq nindex (nt:read-long header-buf 192)) ;overwrite 141 (setq nblock (nt:read-long header-buf 196)) ;overwrite 142 (setq datablock-size (* nblock block-size)) 143 (setq cypt (substring header-buf 200 208)) ;- reserved[8] 144 (setq update-count (nt:read-ulong header-buf 208)) 145 ; dummy00 @212[4] 146 (setq dicident (substring header-buf 216 224)) 147 ;(setq dummy (substring header-buf 224 256)) 148 (setq index-size (* index-block block-size)) ;overwrite 149 );5 150 (t "< 5.0" 151 (when (>= major-version 3) 152 "NEWDIC2-" 153 (setq olenumber (nt:read-long header-buf 167)) 135 154 ;(setq os (byte (substring header-buf 172 173))) 136 155 (setq os (nth (nt:read-char header-buf 171) '(sjis-crlf))) 137 156 ;(setq lid-word (short header-buf 172)) 138 157 ;(setq lid-japa (short header-buf 174)) … … 140 159 ;(setq lid-pron (short header-buf 178)) 141 160 ;(setq lid-other (short header-buf 180)) 142 ))143 (if(>= major-version 4)144 (progn"NEWDIC3-"145 146 147 148 149 150 151 152 161 ) 162 (when (>= major-version 4) 163 "NEWDIC3-" 164 (setq extheader (nt:read-ulong header-buf 182)) 165 (setq empty-block (nt:read-long header-buf 186)) ;overwrite 166 (setq nindex (nt:read-long header-buf 190)) ;overwrite 167 (setq nblock (nt:read-long header-buf 194)) ;overwrite 168 (setq datablock-size (* nblock block-size)) 169 (setq index-blkbit (if (= (nt:read-uchar header-buf 198) 1) 32 16)) 170 (setq cypt (substring header-buf 200 208)) 171 (setq update-count (nt:read-ulong header-buf 207)) 153 172 ;(setq dummy (substring header-buf 212 256)) 154 (setq index-size (* index-block block-size)) ;overwrite 155 )) 156 ); < 5.0 157 );fi 158 173 (setq index-size (* index-block block-size)) ;overwrite 174 ) 175 )); esac 159 176 (list 160 177 ; (cons 'headername headername) ; … … 189 206 (cons 'datablock-ends-at (+ header-size extheader index-size datablock-size)) 190 207 (cons 'datablock-size datablock-size) 191 (cons 'bocu bocu) 192 ); list 193 ); let* 194 ); caught 195 ) 208 (cons 'bocu bocu))))) 196 209 197 210 (defun pdicv-get-index-list (filename &optional word-encoding) 198 211 "[PDICV] Get the index list from PDIC file" 199 (let* ( 200 (header (pdicv-get-header-info filename)) 212 (let* ((header (pdicv-get-header-info filename)) 201 213 (index-buf (nt:read-from-file filename 202 214 (-> header 'index-begins-at) (-> header 'index-size))) 203 215 204 216 (32bit-address-mode (if (= (-> header 'index-blkbit) 32) t nil)) 217 (tab-sep-p (if (eq 'unicode-bocu-6 (-> header 'version)) t nil)) 205 218 206 219 (ix 0) (ix-max (-> header 'nindex)) 207 220 (ofs 0) 208 (index-list ()) 209 ) 210 221 (index-list ())) 211 222 (while (< ix ix-max) 212 223 (let ((phys -1) (word "") (word* nil)) 213 224 (if 32bit-address-mode 214 (progn (setq phys (nt:read-ulong index-buf ofs)) (setq ofs (+ ofs 4))) 215 (progn (setq phys (nt:read-ushort index-buf ofs)) (setq ofs (+ ofs 2))) 216 ) 225 (progn (setq phys (nt:read-ulong index-buf ofs)) 226 (setq ofs (+ ofs 4))) 227 (progn (setq phys (nt:read-ushort index-buf ofs)) 228 (setq ofs (+ ofs 2)))) 217 229 (setq word* (nt:read-cstring index-buf ofs)) (setq ofs (+ ofs (cdr word*) 1)) 218 230 (setq word (car word*)) 231 232 (when tab-sep-p 233 (let ((tsv (split-string word "\t"))) 234 (when (consp tsv) 235 (setq word (car tsv))))) 219 236 ; (cond 220 237 ; ((eq word-encoding 'bocu) … … 229 246 (push (cons phys word) index-list) 230 247 (setq ix (1+ ix)) 231 );let 232 ) 233 (nreverse index-list) 234 ) 235 ) 248 )) 249 (nreverse index-list) )) 236 250 237 251 (defface pdicv-face-dummy … … 255 269 256 270 (defvar pdicv-default-inserter 257 258 259 271 (lambda (eword pron jword example) 272 (progn 273 (set-text-properties 0 (length eword) '(face bold) eword) 260 274 ; (set-text-properties 0 (length eword) '(face pdicv-face-caption-green) eword) 261 275 ; (set-text-properties 0 (length jword) '(face pdicv-face-caption-gray) jword) 262 276 263 (setq jword (nt:replace-all jword "����/ "))264 265 266 267 268 (if(string< "" pron) (setq buf (concat buf " [" pron "]")))277 (setq jword (nt:replace-all jword "������/ ")) 278 (setq jword (nt:replace-all jword "\n" "\n ")) 279 280 (let ((buf "")) 281 (setq buf eword) 282 (when (string< "" pron) (setq buf (concat buf " [" pron "]"))) 269 283 ; (setq result (concat result " : " jword)) 270 271 (if (string< "" example) (setq buf (concat buf "\n - " example))284 (setq buf (concat buf "\n " jword)) 285 (when (string< "" example) (setq buf (concat buf "\n - " example))) 272 286 ; (setq buf (concat buf "\n")) 273 )274 287 ; (setq buf (concat buf "\n\n")) 275 (setq buf (concat buf "\n")) 276 277 (insert buf) 278 ); let 279 ); progn 280 );lambda 281 ) 288 (setq buf (concat buf "\n")) 289 290 (insert buf))))) 282 291 ;; 283 292 ;; … … 285 294 (defun pdicv-scan-datablock (filename phys criteria-func) 286 295 "[PDICV] scan a datablock" 287 ; (insert (format "pdicv-scan-datablock (%s %d ...)\n" filename phys))288 296 (catch 'pdicv-scan-datablock 289 297 (let* ((result ()) ;(match-count 0) 290 298 (header (pdicv-get-header-info filename)) 291 (offset (+ (-> header 'datablock-begins-at) (lsh phys 8))) 292 (aligned (if (eq (-> header 'version) 'newdic4) t nil)) 293 ; (bocu (-> header 'bocu)) 299 (block-size (-> header 'block-size)) 300 (offset (+ (-> header 'datablock-begins-at) (* phys block-size))) 301 (aligned (and (member (-> header 'version) '(newdic4 unicode-bocu-6)) t)) 302 ;; (bocu (-> header 'bocu)) 294 303 (head-word (nt:read-ushort (nt:read-from-file filename offset 2))) 295 304 (blocks (logand 32767 head-word)) 296 (block-length (- ( lsh blocks 8) 2))305 (block-length (- (* blocks block-size) 2)) 297 306 (field-size (if (zerop (logand 32768 head-word)) 2 4)) 298 307 (datablock (nt:read-from-file filename (+ offset 2) block-length)) 299 308 ; (list blocks field-size datablock) 300 309 (p 0) 301 310 (field-length 0) 302 311 (compress-length 0) 303 312 (rest nil) … … 308 317 (setq field-length 309 318 (if (= field-size 2) (nt:read-ushort datablock p) (nt:read-ulong datablock p)) ) 310 ( if(zerop field-length) (throw 'pdicv-scan-datablock (nreverse result))); sfield-list))311 (setq p (+ p field-size)) ;2� ʤ���4�Х��� (setq compress-length (nt:read-uchar datablock p)) ; �����319 (when (zerop field-length) (throw 'pdicv-scan-datablock (nreverse result))); sfield-list)) 320 (setq p (+ p field-size)) ;2��ʒ�����4��В����� (setq compress-length (nt:read-uchar datablock p)) ; �����̒Ĺ 312 321 (setq p (1+ p)) 313 322 314 (if aligned (progn 315 (setq eword-attrib (nt:read-uchar datablock p)) ; ���Ф���� 316 (setq p (1+ p)) 317 )) 318 ; ���Ф����ߤ�ꤢ���� rest ����� 319 (setq rest (substring datablock p (+ p field-length))) 323 (when aligned 324 (setq eword-attrib (nt:read-uchar datablock p)) ; �����В�������� 325 (setq p (1+ p))) 326 ; �����В����쒰ʒ�ߒ����꒤������� rest ��˒���쒤� (setq rest (substring datablock p (+ p field-length))) 320 327 (setq p (+ p field-length)) 321 ; ��� Ф���NULL��ü)328 ; �����В�����NULL����ü) 322 329 (let* ((eword-cstr (nt:read-cstring rest)) 323 330 (eword-compressed (car eword-cstr)) (eword-len (cdr eword-cstr)) … … 327 334 (jword-cstr nil) (jword "") (jword-len 0) 328 335 (ext-list nil) 329 (example "") (pron "") (link "") 330 ) 336 (example "") (pron "") (link "")) 331 337 332 338 (setq eword (if (zerop compress-length) 333 339 eword-compressed 334 (concat (substring eword 0 compress-length) eword-compressed) 335 )) 340 (concat (substring eword 0 compress-length) eword-compressed) )) 336 341 (setq q (1+ eword-len)) 337 ; ��� Ф����338 ( if (not aligned) (progn339 340 (setq q (1+ q))341 )) 342 ; �����В�������� 343 (when (not aligned) 344 (setq eword-attrib (nt:read-uchar rest q)) 345 (setq q (1+ q))) 346 342 347 (setq level (logand eword-attrib 15)) 343 348 ; (insert (format ": %s %d %d\n" eword eword-len eword-attrib)) … … 348 353 (setq extended (if (zerop (logand eword-attrib 16)) nil t)) 349 354 (if extended 350 (progn ;�� �355 (progn ;��Ȓĥ 351 356 (setq jword-cstr (nt:read-cstring rest q)) 352 357 (setq jword (car jword-cstr)) (setq jword-len (cdr jword-cstr)) … … 359 364 (exdata-cstr nil) 360 365 (exdata "") (exdata-len 0) ) 361 ( if(= (logand ex-attrib 128) 128) (throw 'while t))366 (when (= (logand ex-attrib 128) 128) (throw 'while t)) 362 367 (setq q (1+ q)) 363 368 (setq exdata-cstr (nt:read-cstring rest q)) … … 374 379 ) ; catch while2 375 380 ) ; progn 376 (progn ; ɸ�� (setq jword (substring rest q))381 (progn ;�ɸ��� (setq jword (substring rest q)) 377 382 (setq pron "") 378 (setq example "") 379 ) ; progn 383 (setq example "")) 380 384 ) ; if extended 381 385 382 386 ; (insert (format "- %s\n" eword)) 383 ( if(funcall criteria-func eword pron jword example)384 387 (when (funcall criteria-func eword pron jword example) 388 (push (list eword pron jword example) result)) 385 389 );let 386 390 ); wend 387 (nreverse result) 388 ); let* 389 ) ;catch(0) 390 ) 391 (nreverse result)))) 391 392 392 393 (defun pdicv-core-search (dicinfo criteria &optional simple-mode-p dont-clear-p) … … 396 397 (encoding-list (nth 2 dicinfo)) 397 398 (decoder-list ()) 398 (index-table (-> pdicv-index-table-list dicname)) 399 ) 399 (index-table (-> pdicv-index-table-list dicname))) 400 400 ; (if (null index-table) (setq index-table (pdicv-get-index-list dicfile))) 401 401 402 ( if(atom encoding-list) ;; expand encoding-list403 402 (when (atom encoding-list) ;; expand encoding-list 403 (setq encoding-list (list encoding-list encoding-list encoding-list encoding-list))) 404 404 405 405 (while encoding-list ;; build the decoder-list … … 410 410 ((eq encoding 'latin1) (push pdicv-latin1-decoder decoder-list)) 411 411 (encoding (push (pdicv-create-decoder encoding) decoder-list)) 412 (t (push pdicv-null-decoder decoder-list)) 413 );cond 414 );let 415 (setq encoding-list (cdr encoding-list)) 416 );wend 412 (t (push pdicv-null-decoder decoder-list)))) 413 (setq encoding-list (cdr encoding-list))) 417 414 (setq decoder-list (nreverse decoder-list)) 418 415 … … 434 431 (ix index-table) (index-size (length ix)) (curr-size index-size) 435 432 (ix+ (cadr ix)); next one 436 (match-count 0) 437 ) 433 (match-count 0)) 438 434 439 435 ; (switch-to-buffer pdicv-buffer-name) 440 436 (save-current-buffer 441 437 (set-buffer pdicv-buffer) 442 (if (null dont-clear-p) (erase-buffer)) 443 444 (if (not simple-mode-p) 445 (progn 438 (when (null dont-clear-p) (erase-buffer)) 439 440 (when (not simple-mode-p) 446 441 ;(pop-to-buffer pdicv-buffer-name) 447 442 ; (set-buffer pdicv-buffer-name) 448 (insert (format "�����%s\n" word-to-search))449 (insert (format "�����: ????\n"))450 443 (insert (format "��������� %s\n" word-to-search)) 444 (insert (format "��������???\n")) 445 (newline)) 451 446 ;(insert "\n")) 452 ) 453 (if index-needles 454 (setq ix 455 (let ((p ix) (last-p nil)) 456 (catch 'pdicv-search-in-index 457 (while p 458 (let* ((elem (car p)) 459 ;(phys (car elem)) 460 (word (cdr elem)) ) 461 462 (if (string< needle1 word) (throw 'pdicv-search-in-index last-p)) 463 ; (if (string< needle2 word) (throw 'pdicv-search-in-index last-p)) 464 447 (when index-needles 448 (setq ix 449 (let ((p ix) (last-p nil)) 450 (catch 'pdicv-search-in-index 451 (while p 452 (let* ((elem (car p)) ;(phys (car elem)) 453 (word (cdr elem))) 454 (if (string< needle1 word) (throw 'pdicv-search-in-index last-p)) 455 ;; (if (string< needle2 word) (throw 'pdicv-search-in-index last-p)) 465 456 (setq last-p p) 466 (setq p (cdr p)) 467 ); let 468 ); wend 469 last-p 470 ); caught 471 472 ); let 473 )) 474 457 (setq p (cdr p)) )) 458 last-p)))) 475 459 (catch 'while 476 460 (while ix 477 461 (let* ((curr (car ix)) 478 462 (phys (car curr)) (word (cdr curr)) 479 463 ;; (x (insert (format "* current ix: (%d %s)\n" phys word))) 480 464 (result (pdicv-scan-datablock dicfile phys datablock-criteria-func)); decoder-list nil)) 481 465 (result-count (length result)) 482 (inserter pdicv-default-inserter) 483 ) 484 485 (if index-needles 486 (if (string>= word needle2) (throw 'while t))) 487 ; (if (not (string< word (cdr index-needles))) (throw 'while t))) 466 (inserter pdicv-default-inserter)) 467 (when index-needles 468 (when (string>= word needle2) (throw 'while t))) 469 ;; (if (not (string< word (cdr index-needles))) (throw 'while t))) 488 470 489 471 ; (insert (format "(%s with index %s ... %s)\n" … … 501 483 ) 502 484 (setq match-count (1+ match-count)) 503 ) 504 );wend 485 )) 505 486 (message "%5d/%5d:%7d" curr-size index-size match-count) 506 (sit-for 0) 507 ) 508 (progn ;else 509 (if (zerop (% curr-size 128)) ;;128�����ʿ� (message "%5d/%5d:%7d" curr-size index-size match-count)) 510 ));fi 511 );let* 487 (sit-for 0)) 488 ;;else 489 (when (zerop (% curr-size 128)) ;;128��ϒŬ����ʒ�� (message "%5d/%5d:%7d" curr-size index-size match-count)))) 512 490 (setq ix (cdr ix)) 513 491 (setq curr-size (1- curr-size)) … … 515 493 );caught 516 494 517 495 ;;(insert (pdicv-scan-datablock dicfile (car (car ix)) decoder-list nil needle1 needle2)) 518 496 (goto-char 1) 519 497 520 (if (not simple-mode-p) 521 (if (re-search-forward ": [?][?][?][?]" nil t nil) 522 (replace-match (format ": %d" match-count) t t nil 0)) 523 );fi 524 498 (when (not simple-mode-p) 499 (when (re-search-forward ": [?][?][?][?]" nil t nil) 500 (replace-match (format ": %d" match-count) t t nil 0))) 525 501 ); save-current-buffer 526 502 527 503 ; (pop-to-buffer (current-buffer)) 528 504 ; (setq split-height-threshold 6) 529 (if (one-window-p) 530 (set-window-buffer (split-window-vertically (- pdicv-result-height)) pdicv-buffer) 531 ) 532 ); let* 533 ); caught 534 );let* 535 ) 505 (when (one-window-p) 506 (set-window-buffer (split-window-vertically (- pdicv-result-height)) pdicv-buffer)) 507 )))) 536 508 537 509 ;;; pdicv-core.el ends here -
lang/elisp/pdicv-mode/trunk/pdicv-eijiro.el
r67 r71 1 1 ;;; pdicv-eijiro.el --- around eijiro 2 2 ;; 3 ;; Copyright (C) 2005 Naoya TOZUKA. All Rights Reserved.3 ;; Copyright (C) 2005-2009 naoya_t. All Rights Reserved. 4 4 ;; 5 ;; Author: Naoya TOZUKA <pdicviewer@gmail.com> 6 ;; Maintainer: Naoya TOZUKA <pdicviewer@gmail.com> 7 ;; Primary distribution site: http://pdicviewer.naochan.com/el/ 5 ;; Author: naoya_t <naoya.t@aqua.plala.or.jp> 6 ;; Maintainer: naoya_t <naoya.t@aqua.plala.or.jp> 7 ;; Primary distribution site: 8 ;; http://lambdarepos.svnrepository.com/svn/share/lang/elisp/pdicv-mode/trunk 8 9 ;; 9 10 ;; Created: 06 Feb 2005 10 11 ;; Last modified: 23 Dec 2005 11 ;; Version: 0.9. 112 ;; Version: 0.9.2 12 13 ;; Keywords: eijiro waeijiro 13 14 -
lang/elisp/pdicv-mode/trunk/pdicv-mode.el
r67 r71 1 1 ;; pdicviewer.el - PDIC Viewer for Emacs 2 2 ;; 3 ;; Copyright (C) 2005 Naoya TOZUKA. All Rights Reserved.3 ;; Copyright (C) 2005-2009 naoya_t. All Rights Reserved. 4 4 ;; 5 ;; Author: Naoya TOZUKA <pdicviewer@gmail.com> 6 ;; Maintainer: Naoya TOZUKA <pdicviewer@gmail.com> 7 ;; Primary distribution site: http://pdicviewer.naochan.com/el/ 5 ;; Author: naoya_t <naoya.t@aqua.plala.or.jp> 6 ;; Maintainer: naoya_t <naoya.t@aqua.plala.or.jp> 7 ;; Primary distribution site: 8 ;; http://lambdarepos.svnrepository.com/svn/share/lang/elisp/pdicv-mode/trunk 8 9 ;; 9 10 ;; Created: 14 Feb 2005 10 11 ;; Last modified: 23 Dec 2005 11 ;; Version: 0.9. 112 ;; Version: 0.9.2 12 13 ;; Keywords: PDIC dictionary search eijiro 13 14 ;; -
lang/elisp/pdicv-mode/trunk/pdicv-search.el
r67 r71 1 1 ;;; pdicv-search.el --- upper layer 2 2 ;; 3 ;; Copyright (C) 2005 Naoya TOZUKA. All Rights Reserved. 4 ;; 5 ;; Author: Naoya TOZUKA <pdicviewer@gmail.com> 6 ;; Maintainer: Naoya TOZUKA <pdicviewer@gmail.com> 7 ;; Primary distribution site: http://pdicviewer.naochan.com/el/ 3 ;; Copyright (C) 2005-2009 naoya_t. All Rights Reserved. 4 ;; 5 ;; Author: naoya_t <naoya.t@aqua.plala.or.jp> 6 ;; Maintainer: naoya_t <naoya.t@aqua.plala.or.jp> 7 ;; Primary distribution site: 8 ;; http://lambdarepos.svnrepository.com/svn/share/lang/elisp/pdicv-mode/trunk 8 9 ;; 9 10 ;; Created: 06 Feb 2005 10 11 ;; Last modified: 23 Dec 2005 11 ;; Version: 0.9. 112 ;; Version: 0.9.2 12 13 ;; Keywords: read-from-file 13 14 … … 73 74 "" 74 75 ; (pdicv-search dicname nil regexp-to-search t field-to-search) 75 (pdicv-search dicname regexp-to-search nil t field-to-search) 76 ) 76 (pdicv-search dicname regexp-to-search nil t field-to-search)) 77 77 78 78 (defun pdicv-search-just (dicname word-to-search &optional field-to-search) 79 79 "" 80 (pdicv-search dicname word-to-search t nil field-to-search) 81 ) 80 (pdicv-search dicname word-to-search t nil field-to-search)) 82 81 83 82 (defun pdicv-search (dicname word-to-search &optional just-p regexp-p field-to-search) … … 89 88 (catch 'pdicv-search 90 89 (let ((candidates 91 (if just-p (cons (downcase word-to-search) (nt:english-guess-original-form word-to-search)))) 90 (if just-p (cons (downcase word-to-search) (nt:english-guess-original-form word-to-search)) 91 (list word-to-search) 92 )) 92 93 (candidate word-to-search) 93 94 (first-round-p t) 94 95 (dicinfo (assoc dicname pdicv-dictionary-list))) 95 96 ;;(debug candidates);(nt:english-guess-original-form word-to-search)) 96 97 (if (null dicinfo) (throw 'pdicv-search 'dictionary-not-found)) 97 98 … … 106 107 (while dicname-list 107 108 (pdicv-search (car dicname-list) candidate just-p regexp-p field-to-search) 108 (setq dicname-list (cdr dicname-list)) 109 ) 110 ) 111 ;else... 109 (setq dicname-list (cdr dicname-list)))) 110 ;;else... 112 111 (let* ((encoding-list (nth 2 dicinfo)) 113 112 (word-encoding (if (listp encoding-list) (car encoding-list) encoding-list)) … … 154 153 );let* 155 154 ; (insert (format "%s" criteria)) 156 157 155 (pdicv-core-search dicinfo criteria simple-mode-p (not first-round-p)) ; clear only at the first time 158 156 );let* … … 163 161 );caught 164 162 ) 163 ;;debug 165 164 166 165 (defun pdicv-search-interactive () -
lang/elisp/pdicv-mode/trunk/pdicviewer.el
r67 r71 1 1 ;; pdicviewer.el - PDIC Viewer for Emacs 2 2 ;; 3 ;; Copyright (C) 2005 Naoya TOZUKA. All Rights Reserved.3 ;; Copyright (C) 2005-2009 naoya_t. All Rights Reserved. 4 4 ;; 5 ;; Author: Naoya TOZUKA <pdicviewer@gmail.com> 6 ;; Maintainer: Naoya TOZUKA <pdicviewer@gmail.com> 7 ;; Primary distribution site: http://pdicviewer.naochan.com/el/ 5 ;; Author: naoya_t <naoya.t@aqua.plala.or.jp> 6 ;; Maintainer: naoya_t <naoya.t@aqua.plala.or.jp> 7 ;; Primary distribution site: 8 ;; http://lambdarepos.svnrepository.com/svn/share/lang/elisp/pdicv-mode/trunk 8 9 ;; 9 10 ;; Created: 14 Feb 2005 10 11 ;; Last modified: 23 Dec 2005 11 ;; Version: 0.9. 112 ;; Version: 0.9.2 12 13 ;; Keywords: PDIC dictionary search eijiro 13 14 ;; … … 33 34 ; (sample "~/pdic/SAMPLE.DIC" ; 34 35 ; (nil nil sjis sjis) t) 35 (cj2 "~/pdic/cj2.dic" ; 36 bocu nil) 37 (eijiro "~/pdic/eijiro81/EIJIRO81.DIC" 38 (nil nil sjis sjis)) 39 (waeijiro "~/pdic/eijiro81/WAEIJI81.DIC" 40 (sjis nil sjis sjis) t) 41 (fr "~/pdic/fr.dic" 42 (latin1 nil sjis latin1) nil) 36 ; (cj2 "~/pdic/cj2.dic" ; 37 ; bocu nil) 38 (eijiro "~/Library/EIJIRO 4th Edition/Eijiro112.dic" bocu nil) 39 (waeijiro "~/Library/EIJIRO 4th Edition/Waeiji112.dic" bocu nil) 40 ; (eijiro "~/pdic/eijiro81/EIJIRO81.DIC" 41 ; (nil nil sjis sjis)) 42 ; (waeijiro "~/pdic/eijiro81/WAEIJI81.DIC" 43 ; (sjis nil sjis sjis) t) 44 ; (fr "~/pdic/fr.dic" 45 ; (latin1 nil sjis latin1) nil) 43 46 ; (ej 44 47 ; (eijiro waeijiro))