Function: kkc-lookup-key

kkc-lookup-key is a byte-compiled function defined in kkc.el.gz.

Signature

(kkc-lookup-key LEN &optional POSTFIX PREFER-NOUN)

Source Code

;; Defined in /usr/src/emacs/lisp/international/kkc.el.gz
;; Lookup Japanese dictionary to set list of conversions in
;; kkc-current-conversions for key sequence kkc-current-key of length
;; LEN.  If no conversion is found in the dictionary, don't change
;; kkc-current-conversions and return nil.
;; Postfixes are handled only if POSTFIX is non-nil.
(defun kkc-lookup-key (len &optional postfix prefer-noun)
  ;; At first, prepare cache data if any.
  (unless kkc-init-file-flag
    (setq kkc-init-file-flag t
	  kkc-lookup-cache nil)
    (add-hook 'kill-emacs-hook 'kkc-save-init-file)
    (if (file-readable-p kkc-init-file-name)
	(condition-case nil
	    (load-file kkc-init-file-name)
	  (kkc-error "Invalid data in %s" kkc-init-file-name))))
  (or (and (nested-alist-p kkc-lookup-cache)
	   (eq (car kkc-lookup-cache) kkc-lookup-cache-tag))
      (setq kkc-lookup-cache (list kkc-lookup-cache-tag)
	    kkc-init-file-flag 'kkc-lookup-cache))
  (let ((entry (lookup-nested-alist kkc-current-key kkc-lookup-cache len 0 t)))
    (if (consp (car entry))
	(setq kkc-length-converted len
	      kkc-current-conversions-width nil
	      kkc-current-conversions (car entry))
      (setq entry (skkdic-lookup-key kkc-current-key len postfix prefer-noun))
      (if entry
	  (progn
	    (setq kkc-length-converted len
		  kkc-current-conversions-width nil
		  kkc-current-conversions (cons 1 entry))
	    (if postfix
		;; Store this conversions in the cache.
		(progn
		  (set-nested-alist kkc-current-key kkc-current-conversions
				    kkc-lookup-cache kkc-length-converted)
		  (setq kkc-init-file-flag 'kkc-lookup-cache)))
	    t)
	(if (= len 1)
	    (setq kkc-length-converted 1
		  kkc-current-conversions-width nil
		  kkc-current-conversions (cons 0 nil)))))))