Function: quail-update-leim-list-file
quail-update-leim-list-file is an autoloaded, interactive and
byte-compiled function defined in quail.el.gz.
Signature
(quail-update-leim-list-file DIRNAME &rest DIRNAMES)
Documentation
Update entries for Quail packages in LEIM list file in directory DIRNAME.
DIRNAME is a directory containing Emacs input methods;
normally, it should specify the leim subdirectory
of the Emacs source tree.
It searches for Quail packages under quail subdirectory of DIRNAME,
and update the file "leim-list.el" in DIRNAME.
When called from a program, the remaining arguments are additional
directory names to search for Quail packages under quail subdirectory
of each directory.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/international/quail.el.gz
;;;###autoload
(defun quail-update-leim-list-file (dirname &rest dirnames)
"Update entries for Quail packages in `LEIM' list file in directory DIRNAME.
DIRNAME is a directory containing Emacs input methods;
normally, it should specify the `leim' subdirectory
of the Emacs source tree.
It searches for Quail packages under `quail' subdirectory of DIRNAME,
and update the file \"leim-list.el\" in DIRNAME.
When called from a program, the remaining arguments are additional
directory names to search for Quail packages under `quail' subdirectory
of each directory."
(interactive "FDirectory of LEIM: ")
(setq dirname (expand-file-name dirname))
(let ((leim-list (expand-file-name leim-list-file-name dirname))
quail-dirs list-buf pkg-list pos)
(if (not (file-writable-p leim-list))
(error "Can't write to file \"%s\"" leim-list))
(or noninteractive (message "Updating %s ..." leim-list))
(setq list-buf (find-file-noselect leim-list))
;; At first, clean up the file.
(with-current-buffer list-buf
(goto-char (point-min))
;; Insert the correct header.
(if (looking-at (regexp-quote leim-list-header))
(goto-char (match-end 0))
(insert leim-list-header))
(setq pos (point))
(if (not (re-search-forward leim-list-entry-regexp nil t))
nil
;; Remove garbage after the header.
(goto-char (match-beginning 0))
(if (< pos (point))
(delete-region pos (point)))
;; Remove all entries for Quail.
(while (re-search-forward leim-list-entry-regexp nil 'move)
(goto-char (match-beginning 0))
(setq pos (point))
(condition-case nil
(let ((form (read list-buf)))
(when (equal (nth 3 form) ''quail-use-package)
(if (eolp) (forward-line 1))
(delete-region pos (point))))
(error
;; Delete the remaining contents because it seems that
;; this file is broken.
(message "Garbage in %s deleted" leim-list)
(delete-region pos (point-max)))))))
;; Search for `quail' subdirectory under each DIRNAMES.
(setq dirnames (cons dirname dirnames))
(let ((l dirnames))
(while l
(setcar l (expand-file-name (car l)))
(setq dirname (expand-file-name quail-directory-name (car l)))
(if (file-readable-p dirname)
(setq quail-dirs (cons dirname quail-dirs))
(message "%s doesn't have `%s' subdirectory, just ignored"
(car l) quail-directory-name)
(setq quail-dirs (cons nil quail-dirs)))
(setq l (cdr l)))
(setq quail-dirs (nreverse quail-dirs)))
;; Insert input method registering forms.
(while quail-dirs
(setq dirname (car quail-dirs))
(when dirname
(setq pkg-list (directory-files dirname 'full "\\.el\\'"))
(while pkg-list
(with-temp-buffer
(insert-file-contents (car pkg-list))
(goto-char (point-min))
;; Don't get fooled by commented-out code.
(while (re-search-forward "^[ \t]*(quail-define-package" nil t)
(goto-char (match-beginning 0))
(let (form)
(condition-case err
(progn
(setq form (read (current-buffer)))
(with-current-buffer list-buf
(insert
(format "(register-input-method
%S %S '%s
%S %S
%S)\n"
(nth 1 form) ; PACKAGE-NAME
(nth 2 form) ; LANGUAGE
'quail-use-package ; ACTIVATE-FUNC
(nth 3 form) ; PACKAGE-TITLE
(progn ; PACKAGE-DESCRIPTION (one line)
(string-match ".*" (nth 5 form))
(match-string 0 (nth 5 form)))
(file-relative-name ; PACKAGE-FILENAME
(file-name-sans-extension (car pkg-list))
(car dirnames))))))
(error
;; Ignore the remaining contents of this file.
(goto-char (point-max))
(message "Some part of \"%s\" is broken: %s in %s"
(car pkg-list) err form))))))
(setq pkg-list (cdr pkg-list)))
(setq quail-dirs (cdr quail-dirs) dirnames (cdr dirnames))))
;; At last, write out LEIM list file.
(with-current-buffer list-buf
(let ((coding-system-for-write 'utf-8))
(save-buffer 0)))
(kill-buffer list-buf)
(or noninteractive (message "Updating %s ... done" leim-list))))