Function: quail-build-decode-map

quail-build-decode-map is a byte-compiled function defined in quail.el.gz.

Signature

(quail-build-decode-map MAP-LIST KEY DECODE-MAP NUM &optional MAXNUM IGNORES)

Documentation

Build a decoding map.

Accumulate in the cdr part of DECODE-MAP all pairs of key sequences vs the corresponding translations defined in the Quail map specified by the first element MAP-LIST. Each pair has the form
(KEYSEQ . TRANSLATION). DECODE-MAP should have the form
(decode-map . ALIST), where ALIST is an alist of length NUM. KEY
is a key sequence to reach MAP. Optional 5th arg MAXNUM limits the number of accumulated pairs. Optional 6th arg IGNORES is a list of translations to ignore.

Source Code

;; Defined in /usr/src/emacs/lisp/international/quail.el.gz
(defun quail-build-decode-map (map-list key decode-map num
					&optional maxnum ignores)
  "Build a decoding map.
Accumulate in the cdr part of DECODE-MAP all pairs of key sequences
vs the corresponding translations defined in the Quail map
specified by the first element MAP-LIST.  Each pair has the form
\(KEYSEQ . TRANSLATION).  DECODE-MAP should have the form
\(decode-map . ALIST), where ALIST is an alist of length NUM.  KEY
is a key sequence to reach MAP.
Optional 5th arg MAXNUM limits the number of accumulated pairs.
Optional 6th arg IGNORES is a list of translations to ignore."
  (let* ((map (car map-list))
	 (translation (quail-get-translation (car map) key (length key)))
	 elt)
    (cond ((integerp translation)
	   ;; Accept only non-ASCII chars not listed in IGNORES.
	   (when (and (> translation 127) (not (memq translation ignores)))
	     (setcdr decode-map
		     (cons (cons key translation) (cdr decode-map)))
	     (setq num (1+ num))))
	  ((consp translation)
	   (setq translation (cdr translation))
	   (let ((multibyte nil))
             (mapc (lambda (x)
                     ;; Accept only non-ASCII chars not
                     ;; listed in IGNORES.
                     (if (and (if (integerp x) (> x 127)
                                (string-match-p "[^[:ascii:]]" x))
                              (not (member x ignores)))
                         (setq multibyte t)))
		   translation)
	     (when multibyte
	       (setcdr decode-map
		       (cons (cons key translation) (cdr decode-map)))
	       (setq num (+ num (length translation)))))))
    (if (and maxnum (> num maxnum))
	(- num)
      (setq map (cdr map))
      ;; Recursively check the deeper map.
      (while (and map (>= num 0))
	(setq elt (car map) map (cdr map))
	(when (and (integerp (car elt)) (consp (cdr elt))
		   (not (memq (cdr elt) map-list)))
	  (setq num (quail-build-decode-map (cons (cdr elt) map-list)
					    (format "%s%c" key (car elt))
					    decode-map num maxnum ignores))))
      num)))