Function: skkdic-lookup-key
skkdic-lookup-key is a byte-compiled function defined in
ja-dic-utl.el.gz.
Signature
(skkdic-lookup-key SEQ LEN &optional POSTFIX PREFER-NOUN)
Documentation
Return a list of conversion string for sequence SEQ of length LEN.
SEQ is a vector of Kana characters to be converted by SKK dictionary. If LEN is shorter than the length of KEYSEQ, the first LEN keys in SEQ are took into account.
Optional 3rd arg POSTFIX non-nil means SETSUBIJI (postfix) are also considered to find conversion strings.
Optional 4th arg PREFER-NOUN non-nil means that the conversions without okurigana are placed at the head of the returned list.
Source Code
;; Defined in /usr/src/emacs/lisp/international/ja-dic-utl.el.gz
(defun skkdic-lookup-key (seq len &optional postfix prefer-noun)
"Return a list of conversion string for sequence SEQ of length LEN.
SEQ is a vector of Kana characters to be converted by SKK dictionary.
If LEN is shorter than the length of KEYSEQ, the first LEN keys in SEQ
are took into account.
Optional 3rd arg POSTFIX non-nil means SETSUBIJI (postfix) are also
considered to find conversion strings.
Optional 4th arg PREFER-NOUN non-nil means that the conversions
without okurigana are placed at the head of the returned list."
(or skkdic-okuri-nasi
(condition-case err
(load-library "ja-dic/ja-dic")
(error (ding)
(with-output-to-temp-buffer "*Help*"
(princ (substitute-command-keys "\
The library `ja-dic' can't be loaded.
This might indicate a problem with your Emacs installation, as
LEIM (Libraries of Emacs Input Method) should normally always be
installed together with Emacs.")))
(signal (car err) (cdr err)))))
(let ((vec (make-vector len 0))
(i 0)
entry)
;; At first, generate vector VEC from SEQ for looking up SKK
;; alists. Nth element in VEC corresponds to Nth element in SEQ.
;; The values are decided as follows.
;; If SEQ[N] is `ー', VEC[N] is 0,
;; else if SEQ[N] is a Hiragana character, VEC[N] is:
;; ((The 2nd position code of SEQ[N]) - 32),
;; else VEC[N] is 128.
(while (< i len)
(let ((ch (aref seq i))
code)
(cond ((= ch ?ー)
(aset vec i 0))
((and (>= ch (car skkdic-jisx0208-hiragana-block))
(<= ch (cdr skkdic-jisx0208-hiragana-block)))
(setq code (encode-char ch 'japanese-jisx0208))
(if code
(aset vec i (- (logand code #xFF) 32))
(aset vec i 128)))
(t
(aset vec i 128))))
(setq i (1+ i)))
;; Search OKURI-NASI entries.
(setq entry (lookup-nested-alist vec skkdic-okuri-nasi len 0 t))
(if (consp (car entry))
(setq entry (copy-sequence (car entry)))
(setq entry nil))
(if postfix
;; Search OKURI-NASI entries with postfixes.
(let ((break (max (- len (car skkdic-postfix)) 1))
entry-head entry-postfix entry2)
(while (< break len)
(if (and (setq entry-head
(lookup-nested-alist vec skkdic-okuri-nasi
break 0 t))
(consp (car entry-head))
(setq entry-postfix
(lookup-nested-alist vec skkdic-postfix
len break t))
(consp (car entry-postfix))
(setq entry2 (skkdic-merge-head-and-tail
(car entry-head) (car entry-postfix) t)))
(if entry
(nconc entry entry2)
(setq entry entry2)))
(setq break (1+ break)))))
;; Search OKURI-NASI entries with prefixes.
(let ((break (min (car skkdic-prefix) (- len 2)))
entry-prefix entry-tail entry2)
(while (> break 0)
(if (and (setq entry-prefix
(lookup-nested-alist vec skkdic-prefix break 0 t))
(consp (car entry-prefix))
(setq entry-tail
(lookup-nested-alist vec skkdic-okuri-nasi len break t))
(consp (car entry-tail))
(setq entry2 (skkdic-merge-head-and-tail
(car entry-prefix) (car entry-tail) nil)))
(progn
(if entry
(nconc entry entry2)
(setq entry entry2))))
(setq break (1- break))))
;; Search OKURI-ARI entries.
(let ((okurigana (assq (aref seq (1- len)) skkdic-okurigana-table))
orig-element entry2)
(if okurigana
(progn
(setq orig-element (aref vec (1- len)))
(aset vec (1- len) (- (cdr okurigana)))
(if (and (setq entry2 (lookup-nested-alist vec skkdic-okuri-ari
len 0 t))
(consp (car entry2)))
(progn
(setq entry2 (copy-sequence (car entry2)))
(let ((l entry2)
(okuri (char-to-string (aref seq (1- len)))))
(while l
(setcar l (concat (car l) okuri))
(setq l (cdr l)))
(if entry
(if prefer-noun
(nconc entry entry2)
(setq entry2 (nreverse entry2))
(nconc entry2 entry)
(setq entry entry2))
(setq entry (nreverse entry2))))))
(aset vec (1- len) orig-element))))
entry))