1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-26 07:33:47 +00:00
emacs/lisp/international/kkc.el

661 lines
24 KiB
EmacsLisp
Raw Normal View History

;;; kkc.el --- Kana Kanji converter
1997-02-20 07:02:49 +00:00
;; Copyright (C) 1997-1998, 2001-2021 Free Software Foundation, Inc.
2006-12-13 01:13:58 +00:00
;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
2011-01-02 23:50:46 +00:00
;; 2005, 2006, 2007, 2008, 2009, 2010, 2011
2005-05-13 06:03:46 +00:00
;; National Institute of Advanced Industrial Science and Technology (AIST)
;; Registration Number H14PRO021
1997-02-20 07:02:49 +00:00
;; Keywords: i18n, mule, multilingual, Japanese
1997-02-20 07:02:49 +00:00
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
1997-02-20 07:02:49 +00:00
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
1997-02-20 07:02:49 +00:00
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
1997-02-20 07:02:49 +00:00
;;; Commentary:
;; These routines provide a simple and easy-to-use converter from
;; Kana-string to Kana-Kanji-mixed-string. This converter (here after
;; KKC) uses a SKK dictionary to get information how to convert
;; Kana-string. Since KKC can't be fully automated, we need an
;; interaction with a user to decide the correct conversion. For
;; that, we provide KKC major mode.
;;; Code:
(require 'ja-dic-utl)
1997-02-20 07:02:49 +00:00
(defvar kkc-input-method-title ""
1997-02-20 07:02:49 +00:00
"String denoting KKC input method.
This string is shown at mode line when users are in KKC mode.")
(defvar kkc-init-file-name (locate-user-emacs-file "kkcrc" ".kkcrc")
1997-02-20 07:02:49 +00:00
"Name of a file which contains user's initial setup code for KKC.")
;; A flag to control a file specified by `kkc-init-file-name'.
;; The value nil means the file is not yet consulted.
;; The value t means the file has already been consulted but there's
;; no need of updating it yet.
;; Any other value means that we must update the file before exiting Emacs.
(defvar kkc-init-file-flag nil)
;; Cash data for `kkc-lookup-key'. This may be initialized by loading
;; a file specified by `kkc-init-file-name'. If any elements are
;; modified, the data is written out to the file when exiting Emacs.
(defvar kkc-lookup-cache nil)
;; Tag symbol of `kkc-lookup-cache'.
(defconst kkc-lookup-cache-tag 'kkc-lookup-cache-2)
1997-02-20 07:02:49 +00:00
(defun kkc-save-init-file ()
lisp/*.el: Fix typos and other trivial doc fixes * lisp/allout-widgets.el (allout-widgets-auto-activation) (allout-current-decorated-p): * lisp/auth-source.el (auth-source-protocols): * lisp/autorevert.el (auto-revert-set-timer): * lisp/battery.el (battery-mode-line-limit): * lisp/calc/calcalg3.el (math-map-binop): * lisp/calendar/cal-dst.el (calendar-dst-find-startend): * lisp/calendar/cal-mayan.el (calendar-mayan-long-count-to-absolute): * lisp/calendar/calendar.el (calendar-date-echo-text) (calendar-generate-month, calendar-string-spread) (calendar-cursor-to-date, calendar-read, calendar-read-date) (calendar-mark-visible-date, calendar-dayname-on-or-before): * lisp/calendar/diary-lib.el (diary-ordinal-suffix): * lisp/cedet/ede/autoconf-edit.el (autoconf-new-program) (autoconf-find-last-macro, autoconf-parameter-strip): * lisp/cedet/ede/config.el (ede-target-with-config-build): * lisp/cedet/ede/linux.el (ede-linux--detect-architecture) (ede-linux--get-architecture): * lisp/cedet/semantic/complete.el (semantic-collector-calculate-cache) (semantic-displayer-abstract, semantic-displayer-point-position): * lisp/cedet/semantic/format.el (semantic-format-face-alist) (semantic-format-tag-short-doc): * lisp/cedet/semantic/fw.el (semantic-find-file-noselect): * lisp/cedet/semantic/idle.el (semantic-idle-scheduler-work-idle-time) (semantic-idle-breadcrumbs-display-function) (semantic-idle-breadcrumbs-format-tag-list-function): * lisp/cedet/semantic/lex.el (semantic-lex-map-types) (define-lex, define-lex-block-type-analyzer): * lisp/cedet/semantic/senator.el (senator-search-default-tag-filter): * lisp/cedet/semantic/symref.el (semantic-symref-result) (semantic-symref-hit-to-tag-via-db): * lisp/cedet/semantic/symref.el (semantic-symref-tool-baseclass): * lisp/cedet/semantic/tag.el (semantic-tag-new-variable) (semantic-tag-new-include, semantic-tag-new-package) (semantic-tag-set-faux, semantic-create-tag-proxy) (semantic-tag-function-parent) (semantic-tag-components-with-overlays): * lisp/cedet/srecode/cpp.el (srecode-cpp-namespaces) (srecode-semantic-handle-:c, srecode-semantic-apply-tag-to-dict): * lisp/cedet/srecode/dictionary.el (srecode-create-dictionary) (srecode-dictionary-add-entries, srecode-dictionary-lookup-name) (srecode-create-dictionaries-from-tags): * lisp/cmuscheme.el (scheme-compile-region): * lisp/color.el (color-lab-to-lch): * lisp/doc-view.el (doc-view-image-width) (doc-view-set-up-single-converter): * lisp/dynamic-setting.el (font-setting-change-default-font) (dynamic-setting-handle-config-changed-event): * lisp/elec-pair.el (electric-pair-text-pairs) (electric-pair-skip-whitespace-function) (electric-pair-string-bound-function): * lisp/emacs-lisp/avl-tree.el (avl-tree--del-balance) (avl-tree-member, avl-tree-mapcar, avl-tree-iter): * lisp/emacs-lisp/bytecomp.el (byte-compile-generate-call-tree): * lisp/emacs-lisp/checkdoc.el (checkdoc-autofix-flag) (checkdoc-spellcheck-documentation-flag, checkdoc-ispell) (checkdoc-ispell-current-buffer, checkdoc-ispell-interactive) (checkdoc-ispell-message-interactive) (checkdoc-ispell-message-text, checkdoc-ispell-start) (checkdoc-ispell-continue, checkdoc-ispell-comments) (checkdoc-ispell-defun): * lisp/emacs-lisp/cl-generic.el (cl--generic-search-method): * lisp/emacs-lisp/eieio-custom.el (eieio-read-customization-group): * lisp/emacs-lisp/lisp.el (forward-sexp, up-list): * lisp/emacs-lisp/package-x.el (package--archive-contents-from-file): * lisp/emacs-lisp/package.el (package-desc) (package--make-autoloads-and-stuff, package-hidden-regexps): * lisp/emacs-lisp/tcover-ses.el (ses-exercise-startup): * lisp/emacs-lisp/testcover.el (testcover-nohits) (testcover-1value): * lisp/epg.el (epg-receive-keys, epg-start-edit-key): * lisp/erc/erc-backend.el (erc-server-processing-p) (erc-split-line-length, erc-server-coding-system) (erc-server-send, erc-message): * lisp/erc/erc-button.el (erc-button-face, erc-button-alist) (erc-browse-emacswiki): * lisp/erc/erc-ezbounce.el (erc-ezbounce, erc-ezb-get-login): * lisp/erc/erc-fill.el (erc-fill-variable-maximum-indentation): * lisp/erc/erc-log.el (erc-current-logfile): * lisp/erc/erc-match.el (erc-log-match-format) (erc-text-matched-hook): * lisp/erc/erc-netsplit.el (erc-netsplit, erc-netsplit-debug): * lisp/erc/erc-networks.el (erc-server-alist) (erc-networks-alist, erc-current-network): * lisp/erc/erc-ring.el (erc-input-ring-index): * lisp/erc/erc-speedbar.el (erc-speedbar) (erc-speedbar-update-channel): * lisp/erc/erc-stamp.el (erc-timestamp-only-if-changed-flag): * lisp/erc/erc-track.el (erc-track-position-in-mode-line) (erc-track-remove-from-mode-line, erc-modified-channels-update) (erc-track-last-non-erc-buffer, erc-track-sort-by-importance) (erc-track-get-active-buffer): * lisp/erc/erc.el (erc-get-channel-user-list) (erc-echo-notice-hook, erc-echo-notice-always-hook) (erc-wash-quit-reason, erc-format-@nick): * lisp/ffap.el (ffap-latex-mode): * lisp/files.el (abort-if-file-too-large) (dir-locals--get-sort-score, buffer-stale--default-function): * lisp/filesets.el (filesets-tree-max-level, filesets-data) (filesets-update-pre010505): * lisp/gnus/gnus-agent.el (gnus-agent-flush-cache): * lisp/gnus/gnus-art.el (gnus-article-encrypt-protocol) (gnus-button-prefer-mid-or-mail): * lisp/gnus/gnus-cus.el (gnus-group-parameters): * lisp/gnus/gnus-demon.el (gnus-demon-handlers) (gnus-demon-run-callback): * lisp/gnus/gnus-dired.el (gnus-dired-print): * lisp/gnus/gnus-icalendar.el (gnus-icalendar-event-from-buffer): * lisp/gnus/gnus-range.el (gnus-range-normalize): * lisp/gnus/gnus-spec.el (gnus-pad-form): * lisp/gnus/gnus-srvr.el (gnus-server-agent, gnus-server-cloud) (gnus-server-opened, gnus-server-closed, gnus-server-denied) (gnus-server-offline): * lisp/gnus/gnus-sum.el (gnus-refer-thread-use-nnir) (gnus-refer-thread-limit-to-thread) (gnus-summary-limit-include-thread, gnus-summary-refer-thread) (gnus-summary-find-matching): * lisp/gnus/gnus-util.el (gnus-rescale-image): * lisp/gnus/gnus.el (gnus-summary-line-format, gnus-no-server): * lisp/gnus/mail-source.el (mail-source-incoming-file-prefix): * lisp/gnus/message.el (message-cite-reply-position) (message-cite-style-outlook, message-cite-style-thunderbird) (message-cite-style-gmail, message--send-mail-maybe-partially): * lisp/gnus/mm-extern.el (mm-inline-external-body): * lisp/gnus/mm-partial.el (mm-inline-partial): * lisp/gnus/mml-sec.el (mml-secure-message-sign) (mml-secure-message-sign-encrypt, mml-secure-message-encrypt): * lisp/gnus/mml2015.el (mml2015-epg-key-image) (mml2015-epg-key-image-to-string): * lisp/gnus/nndiary.el (nndiary-reminders, nndiary-get-new-mail): * lisp/gnus/nnheader.el (nnheader-directory-files-is-safe): * lisp/gnus/nnir.el (nnir-search-history) (nnir-imap-search-other, nnir-artlist-length) (nnir-artlist-article, nnir-artitem-group, nnir-artitem-number) (nnir-artitem-rsv, nnir-article-group, nnir-article-number) (nnir-article-rsv, nnir-article-ids, nnir-categorize) (nnir-retrieve-headers-override-function) (nnir-imap-default-search-key, nnir-hyrex-additional-switches) (gnus-group-make-nnir-group, nnir-run-namazu, nnir-read-parms) (nnir-read-parm, nnir-read-server-parm, nnir-search-thread): * lisp/gnus/nnmairix.el (nnmairix-default-group) (nnmairix-propagate-marks): * lisp/gnus/smime.el (smime-keys, smime-crl-check) (smime-verify-buffer, smime-noverify-buffer): * lisp/gnus/spam-report.el (spam-report-url-ping-mm-url): * lisp/gnus/spam.el (spam-spamassassin-positive-spam-flag-header) (spam-spamassassin-spam-status-header, spam-sa-learn-rebuild) (spam-classifications, spam-check-stat, spam-spamassassin-score): * lisp/help.el (describe-minor-mode-from-symbol): * lisp/hippie-exp.el (hippie-expand-ignore-buffers): * lisp/htmlfontify.el (hfy-optimizations, hfy-face-resolve-face) (hfy-begin-span): * lisp/ibuf-ext.el (ibuffer-update-saved-filters-format) (ibuffer-saved-filters, ibuffer-old-saved-filters-warning) (ibuffer-filtering-qualifiers, ibuffer-repair-saved-filters) (eval, ibuffer-unary-operand, file-extension, directory): * lisp/image-dired.el (image-dired-cmd-pngcrush-options): * lisp/image-mode.el (image-toggle-display): * lisp/international/ccl.el (ccl-compile-read-multibyte-character) (ccl-compile-write-multibyte-character): * lisp/international/kkc.el (kkc-save-init-file): * lisp/international/latin1-disp.el (latin1-display): * lisp/international/ogonek.el (ogonek-name-encoding-alist) (ogonek-information, ogonek-lookup-encoding) (ogonek-deprefixify-region): * lisp/isearch.el (isearch-filter-predicate) (isearch--momentary-message): * lisp/jsonrpc.el (jsonrpc-connection-send) (jsonrpc-process-connection, jsonrpc-shutdown) (jsonrpc--async-request-1): * lisp/language/tibet-util.el (tibetan-char-p): * lisp/mail/feedmail.el (feedmail-queue-use-send-time-for-date) (feedmail-last-chance-hook, feedmail-before-fcc-hook) (feedmail-send-it-immediately-wrapper, feedmail-find-eoh): * lisp/mail/hashcash.el (hashcash-generate-payment) (hashcash-generate-payment-async, hashcash-insert-payment) (hashcash-verify-payment): * lisp/mail/rmail.el (rmail-movemail-variant-in-use) (rmail-get-attr-value): * lisp/mail/rmailmm.el (rmail-mime-prefer-html, rmail-mime): * lisp/mail/rmailsum.el (rmail-summary-show-message): * lisp/mail/supercite.el (sc-raw-mode-toggle): * lisp/man.el (Man-start-calling): * lisp/mh-e/mh-acros.el (mh-do-at-event-location) (mh-iterate-on-messages-in-region, mh-iterate-on-range): * lisp/mh-e/mh-alias.el (mh-alias-system-aliases) (mh-alias-reload, mh-alias-ali) (mh-alias-canonicalize-suggestion, mh-alias-add-alias-to-file) (mh-alias-add-alias): * lisp/mouse.el (mouse-save-then-kill): * lisp/net/browse-url.el (browse-url-default-macosx-browser): * lisp/net/eudc.el (eudc-set, eudc-variable-protocol-value) (eudc-variable-server-value, eudc-update-variable) (eudc-expand-inline): * lisp/net/eudcb-bbdb.el (eudc-bbdb-format-record-as-result): * lisp/net/eudcb-ldap.el (eudc-ldap-get-field-list): * lisp/net/pop3.el (pop3-list): * lisp/net/soap-client.el (soap-namespace-put) (soap-xs-parse-sequence, soap-parse-envelope): * lisp/net/soap-inspect.el (soap-inspect-xs-complex-type): * lisp/nxml/rng-xsd.el (rng-xsd-date-to-days): * lisp/org/ob-C.el (org-babel-prep-session:C) (org-babel-load-session:C): * lisp/org/ob-J.el (org-babel-execute:J): * lisp/org/ob-asymptote.el (org-babel-prep-session:asymptote): * lisp/org/ob-awk.el (org-babel-execute:awk): * lisp/org/ob-core.el (org-babel-process-file-name): * lisp/org/ob-ebnf.el (org-babel-execute:ebnf): * lisp/org/ob-forth.el (org-babel-execute:forth): * lisp/org/ob-fortran.el (org-babel-execute:fortran) (org-babel-prep-session:fortran, org-babel-load-session:fortran): * lisp/org/ob-groovy.el (org-babel-execute:groovy): * lisp/org/ob-io.el (org-babel-execute:io): * lisp/org/ob-js.el (org-babel-execute:js): * lisp/org/ob-lilypond.el (org-babel-default-header-args:lilypond) (org-babel-lilypond-compile-post-tangle) (org-babel-lilypond-display-pdf-post-tangle) (org-babel-lilypond-tangle) (org-babel-lilypond-execute-tangled-ly) (org-babel-lilypond-compile-lilyfile) (org-babel-lilypond-check-for-compile-error) (org-babel-lilypond-process-compile-error) (org-babel-lilypond-mark-error-line) (org-babel-lilypond-parse-error-line) (org-babel-lilypond-attempt-to-open-pdf) (org-babel-lilypond-attempt-to-play-midi) (org-babel-lilypond-switch-extension) (org-babel-lilypond-set-header-args): * lisp/org/ob-lua.el (org-babel-prep-session:lua): * lisp/org/ob-picolisp.el (org-babel-execute:picolisp): * lisp/org/ob-processing.el (org-babel-prep-session:processing): * lisp/org/ob-python.el (org-babel-prep-session:python): * lisp/org/ob-scheme.el (org-babel-scheme-capture-current-message) (org-babel-scheme-execute-with-geiser, org-babel-execute:scheme): * lisp/org/ob-shen.el (org-babel-execute:shen): * lisp/org/org-agenda.el (org-agenda-entry-types) (org-agenda-move-date-from-past-immediately-to-today) (org-agenda-time-grid, org-agenda-sorting-strategy) (org-agenda-filter-by-category, org-agenda-forward-block): * lisp/org/org-colview.el (org-columns--overlay-text): * lisp/org/org-faces.el (org-verbatim, org-cycle-level-faces): * lisp/org/org-indent.el (org-indent-set-line-properties): * lisp/org/org-macs.el (org-get-limited-outline-regexp): * lisp/org/org-mobile.el (org-mobile-files): * lisp/org/org.el (org-use-fast-todo-selection) (org-extend-today-until, org-use-property-inheritance) (org-refresh-effort-properties, org-open-at-point-global) (org-track-ordered-property-with-tag, org-shiftright): * lisp/org/ox-html.el (org-html-checkbox-type): * lisp/org/ox-man.el (org-man-source-highlight) (org-man-verse-block): * lisp/org/ox-publish.el (org-publish-sitemap-default): * lisp/outline.el (outline-head-from-level): * lisp/progmodes/dcl-mode.el (dcl-back-to-indentation-1) (dcl-calc-command-indent, dcl-indent-to): * lisp/progmodes/flymake.el (flymake-make-diagnostic) (flymake--overlays, flymake-diagnostic-functions) (flymake-diagnostic-types-alist, flymake--backend-state) (flymake-is-running, flymake--collect, flymake-mode): * lisp/progmodes/gdb-mi.el (gdb-threads-list, gdb, gdb-non-stop) (gdb-buffers, gdb-gud-context-call, gdb-jsonify-buffer): * lisp/progmodes/grep.el (grep-error-screen-columns): * lisp/progmodes/gud.el (gud-prev-expr): * lisp/progmodes/ps-mode.el (ps-mode, ps-mode-target-column) (ps-run-goto-error): * lisp/progmodes/python.el (python-eldoc-get-doc) (python-eldoc-function-timeout-permanent, python-eldoc-function): * lisp/shadowfile.el (shadow-make-group): * lisp/speedbar.el (speedbar-obj-do-check): * lisp/textmodes/flyspell.el (flyspell-auto-correct-previous-hook): * lisp/textmodes/reftex-cite.el (reftex-bib-or-thebib): * lisp/textmodes/reftex-index.el (reftex-index-goto-entry) (reftex-index-kill, reftex-index-undo): * lisp/textmodes/reftex-parse.el (reftex-context-substring): * lisp/textmodes/reftex.el (reftex-TeX-master-file): * lisp/textmodes/rst.el (rst-next-hdr, rst-toc) (rst-uncomment-region, rst-font-lock-extend-region-internal): * lisp/thumbs.el (thumbs-mode): * lisp/vc/ediff-util.el (ediff-restore-diff): * lisp/vc/pcvs-defs.el (cvs-cvsroot, cvs-force-dir-tag): * lisp/vc/vc-hg.el (vc-hg--ignore-patterns-valid-p): * lisp/wid-edit.el (widget-field-value-set, string): * lisp/x-dnd.el (x-dnd-version-from-flags) (x-dnd-more-than-3-from-flags): Assorted docfixes.
2019-09-20 22:27:53 +00:00
"Save initial setup code for KKC to a file specified by `kkc-init-file-name'."
1997-02-20 07:02:49 +00:00
(if (and kkc-init-file-flag
(not (eq kkc-init-file-flag t)))
(let ((coding-system-for-write 'iso-2022-7bit)
(print-length nil))
1997-02-20 07:02:49 +00:00
(write-region (format "(setq kkc-lookup-cache '%S)\n" kkc-lookup-cache)
nil
kkc-init-file-name))))
;; Sequence of characters to be used for indexes for shown list. The
;; Nth character is for the Nth conversion in the list currently shown.
(defvar kkc-show-conversion-list-index-chars
"1234567890")
1997-02-20 07:02:49 +00:00
(defun kkc-help ()
"Show key bindings available while converting by KKC."
(interactive)
(with-output-to-temp-buffer "*Help*"
(princ (substitute-command-keys "\\{kkc-keymap}"))))
(defvar kkc-keymap
(let ((map (make-sparse-keymap))
(len (length kkc-show-conversion-list-index-chars))
1997-02-20 07:02:49 +00:00
(i 0))
(while (< i len)
(define-key map
(char-to-string (aref kkc-show-conversion-list-index-chars i))
'kkc-select-from-list)
1997-02-20 07:02:49 +00:00
(setq i (1+ i)))
(define-key map " " 'kkc-next)
(define-key map "\r" 'kkc-terminate)
(define-key map "\C-@" 'kkc-first-char-only)
(define-key map "\C-n" 'kkc-next)
(define-key map "\C-p" 'kkc-prev)
(define-key map "\C-i" 'kkc-shorter)
(define-key map "\C-o" 'kkc-longer)
(define-key map "I" 'kkc-shorter-conversion)
(define-key map "O" 'kkc-longer-phrase)
1997-02-20 07:02:49 +00:00
(define-key map "\C-c" 'kkc-cancel)
(define-key map "\C-?" 'kkc-cancel)
(define-key map "\C-f" 'kkc-next-phrase)
(define-key map "K" 'kkc-katakana)
(define-key map "H" 'kkc-hiragana)
(define-key map "l" 'kkc-show-conversion-list-or-next-group)
(define-key map "L" 'kkc-show-conversion-list-or-prev-group)
(define-key map [?\C- ] 'kkc-first-char-only)
1997-02-20 07:02:49 +00:00
(define-key map [delete] 'kkc-cancel)
(define-key map [return] 'kkc-terminate)
(define-key map "\C-h" 'kkc-help)
map)
"Keymap for KKC (Kana Kanji Converter).")
1997-02-20 07:02:49 +00:00
;;; Internal variables used in KKC.
;; The current Kana string to be converted.
(defvar kkc-original-kana nil)
;; The current key sequence (vector of Kana characters) generated from
;; `kkc-original-kana'.
(defvar kkc-current-key nil)
;; List of the current conversions for `kkc-current-key'.
(defvar kkc-current-conversions nil)
;; Vector of the same length as `kkc-current-conversion'. The first
;; element is a vector of:
;; o index number of the first conversion shown previously,
;; o index number of a conversion next of the last one shown previously,
;; o the shown string itself.
;; The remaining elements are widths (including columns for index
;; numbers) of conversions stored in the same order as in
;; `kkc-current-conversion'.
(defvar kkc-current-conversions-width nil)
(defcustom kkc-show-conversion-list-count 4
"Count of successive `kkc-next' or `kkc-prev' to show conversion list.
When you type SPC or C-p successively this count while using the input
method `japanese', the conversion candidates are shown in the echo
area while indicating the current selection by `<N>'."
:group 'mule
:type 'integer)
;; Count of successive invocations of `kkc-next'.
(defvar kkc-next-count nil)
;; Count of successive invocations of `kkc-prev'.
(defvar kkc-prev-count nil)
1997-02-20 07:02:49 +00:00
;; Provided that `kkc-current-key' is [A B C D E F G H I], the current
;; conversion target is [A B C D E F], and the sequence of which
1997-02-20 07:02:49 +00:00
;; conversion is found is [A B C D]:
;;
;; A B C D E F G H I
;; kkc-overlay-head (black): |<--------->|
;; kkc-overlay-tail (underline): |<------->|
;; kkc-length-head: |<--------->|
;; kkc-length-converted: |<----->|
;;
(defvar kkc-overlay-head nil)
(defvar kkc-overlay-tail nil)
(defvar kkc-length-head nil)
(defvar kkc-length-converted nil)
;; Cursor type (`box' or `bar') of the current frame.
(defvar kkc-cursor-type nil)
;; Lookup Japanese dictionary to set list of conversions in
1997-02-20 07:02:49 +00:00
;; 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.
2003-02-04 13:24:35 +00:00
;; Postfixes are handled only if POSTFIX is non-nil.
(defun kkc-lookup-key (len &optional postfix prefer-noun)
1997-02-20 07:02:49 +00:00
;; 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))
1997-02-20 07:02:49 +00:00
(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))
1997-02-20 07:02:49 +00:00
(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)))))))
* lisp/subr.el (define-error): New function. * doc/lispref/control.texi (Signaling Errors): Refer to define-error. (Error Symbols): Add `define-error'. * doc/lispref/errors.texi (Standard Errors): Don't refer to `error-conditions'. * lisp/progmodes/ada-xref.el (ada-error-file-not-found): Rename from error-file-not-found and define with define-error. * lisp/emacs-lisp/cl-lib.el (cl-assertion-failed): Move here from subr.el and define with define-error. * lisp/userlock.el (file-locked, file-supersession): * lisp/simple.el (mark-inactive): * lisp/progmodes/js.el (js-moz-bad-rpc, js-js-error): * lisp/progmodes/ada-mode.el (ada-mode-errors): * lisp/play/life.el (life-extinct): * lisp/nxml/xsd-regexp.el (xsdre-invalid-regexp, xsdre-parse-error): * lisp/nxml/xmltok.el (xmltok-markup-declaration-parse-error): * lisp/nxml/rng-util.el (rng-error): * lisp/nxml/rng-uri.el (rng-uri-error): * lisp/nxml/rng-match.el (rng-compile-error): * lisp/nxml/rng-cmpct.el (rng-c-incorrect-schema): * lisp/nxml/nxml-util.el (nxml-error, nxml-file-parse-error): * lisp/nxml/nxml-rap.el (nxml-scan-error): * lisp/nxml/nxml-outln.el (nxml-outline-error): * lisp/net/soap-client.el (soap-error): * lisp/net/gnutls.el (gnutls-error): * lisp/net/ange-ftp.el (ftp-error): * lisp/mpc.el (mpc-proc-error): * lisp/json.el (json-error, json-readtable-error, json-unknown-keyword) (json-number-format, json-string-escape, json-string-format) (json-key-format, json-object-format): * lisp/jka-compr.el (compression-error): * lisp/international/quail.el (quail-error): * lisp/international/kkc.el (kkc-error): * lisp/emacs-lisp/ert.el (ert-test-failed): * lisp/calc/calc.el (calc-error, inexact-result, math-overflow) (math-underflow): * lisp/bookmark.el (bookmark-error-no-filename): * lisp/epg.el (epg-error): Define with define-error.
2013-08-09 21:22:44 +00:00
(define-error 'kkc-error nil)
(defun kkc-error (&rest args)
More-conservative ‘format’ quote restyling Instead of restyling curved quotes for every call to ‘format’, create a new function ‘format-message’ that does the restyling, and using the new function instead of ‘format’ only in contexts where this seems appropriate. Problem reported by Dmitry Gutov and Andreas Schwab in: http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00826.html http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00827.html * doc/lispref/commands.texi (Using Interactive): * doc/lispref/control.texi (Signaling Errors, Signaling Errors): * doc/lispref/display.texi (Displaying Messages, Progress): * doc/lispref/elisp.texi: * doc/lispref/help.texi (Keys in Documentation): * doc/lispref/minibuf.texi (Minibuffer Misc): * doc/lispref/strings.texi (Formatting Strings): * etc/NEWS: Document the changes. * lisp/abbrev.el (expand-region-abbrevs): * lisp/apropos.el (apropos-library): * lisp/calc/calc-ext.el (calc-record-message) (calc-user-function-list): * lisp/calc/calc-help.el (calc-describe-key, calc-full-help): * lisp/calc/calc-lang.el (math-read-big-balance): * lisp/calc/calc-store.el (calc-edit-variable): * lisp/calc/calc-units.el (math-build-units-table-buffer): * lisp/calc/calc-yank.el (calc-edit-mode): * lisp/calendar/icalendar.el (icalendar-export-region) (icalendar--add-diary-entry): * lisp/cedet/mode-local.el (mode-local-print-binding) (mode-local-describe-bindings-2): * lisp/cedet/semantic/complete.el (semantic-completion-message): * lisp/cedet/semantic/edit.el (semantic-parse-changes-failed): * lisp/cedet/semantic/wisent/comp.el (wisent-log): * lisp/cedet/srecode/insert.el (srecode-insert-show-error-report): * lisp/descr-text.el (describe-text-properties-1, describe-char): * lisp/dframe.el (dframe-message): * lisp/dired-aux.el (dired-query): * lisp/emacs-lisp/byte-opt.el (byte-compile-log-lap-1): * lisp/emacs-lisp/bytecomp.el (byte-compile-log) (byte-compile-log-file, byte-compile-warn, byte-compile-form): * lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use) (cconv-analyze-form): * lisp/emacs-lisp/check-declare.el (check-declare-warn): * lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine): * lisp/emacs-lisp/cl-macs.el (cl-symbol-macrolet): * lisp/emacs-lisp/edebug.el (edebug-format): * lisp/emacs-lisp/eieio-core.el (eieio-oref): * lisp/emacs-lisp/eldoc.el (eldoc-minibuffer-message) (eldoc-message): * lisp/emacs-lisp/elint.el (elint-file, elint-log): * lisp/emacs-lisp/find-func.el (find-function-library): * lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning): * lisp/emacs-lisp/map-ynp.el (map-y-or-n-p): * lisp/emacs-lisp/nadvice.el (advice--make-docstring): * lisp/emacs-lisp/package.el (package-compute-transaction) (package-install-button-action, package-delete-button-action) (package-menu--list-to-prompt): * lisp/emacs-lisp/timer.el (timer-event-handler): * lisp/emacs-lisp/warnings.el (lwarn, warn): * lisp/emulation/viper-cmd.el: (viper-toggle-parse-sexp-ignore-comments) (viper-kill-buffer, viper-brac-function): * lisp/emulation/viper-macs.el (viper-record-kbd-macro): * lisp/facemenu.el (facemenu-add-new-face): * lisp/faces.el (face-documentation, read-face-name) (face-read-string, read-face-font, describe-face): * lisp/files.el (find-alternate-file, hack-local-variables) (hack-one-local-variable--obsolete, write-file) (basic-save-buffer, delete-directory): * lisp/format.el (format-write-file, format-find-file) (format-insert-file): * lisp/help-fns.el (help-fns--key-bindings) (help-fns--compiler-macro, help-fns--obsolete) (help-fns--interactive-only, describe-function-1) (describe-variable): * lisp/help.el (describe-mode): * lisp/info-xref.el (info-xref-output): * lisp/info.el (Info-virtual-index-find-node) (Info-virtual-index, info-apropos): * lisp/international/kkc.el (kkc-error): * lisp/international/mule-cmds.el: (select-safe-coding-system-interactively) (select-safe-coding-system, describe-input-method): * lisp/international/mule-conf.el (code-offset): * lisp/international/mule-diag.el (describe-character-set) (list-input-methods-1): * lisp/international/quail.el (quail-error): * lisp/minibuffer.el (minibuffer-message): * lisp/mpc.el (mpc--debug): * lisp/msb.el (msb--choose-menu): * lisp/net/ange-ftp.el (ange-ftp-message): * lisp/net/gnutls.el (gnutls-message-maybe): * lisp/net/newst-backend.el (newsticker--sentinel-work): * lisp/net/newst-treeview.el (newsticker--treeview-load): * lisp/net/nsm.el (nsm-query-user): * lisp/net/rlogin.el (rlogin): * lisp/net/soap-client.el (soap-warning): * lisp/net/tramp.el (tramp-debug-message): * lisp/nxml/nxml-outln.el (nxml-report-outline-error): * lisp/nxml/nxml-parse.el (nxml-parse-error): * lisp/nxml/rng-cmpct.el (rng-c-error): * lisp/nxml/rng-match.el (rng-compile-error): * lisp/nxml/rng-uri.el (rng-uri-error): * lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer): * lisp/org/org-ctags.el: (org-ctags-ask-rebuild-tags-file-then-find-tag): * lisp/proced.el (proced-log): * lisp/progmodes/ebnf2ps.el (ebnf-log): * lisp/progmodes/flymake.el (flymake-log): * lisp/progmodes/vhdl-mode.el (vhdl-warning-when-idle): * lisp/replace.el (occur-1): * lisp/simple.el (execute-extended-command) (undo-outer-limit-truncate, define-alternatives): * lisp/startup.el (command-line): * lisp/subr.el (error, user-error, add-to-list): * lisp/tutorial.el (tutorial--describe-nonstandard-key) (tutorial--find-changed-keys): * src/callint.c (Fcall_interactively): * src/editfns.c (Fmessage, Fmessage_box): Restyle the quotes of format strings intended for use as a diagnostic, when restyling seems appropriate. * lisp/subr.el (format-message): New function. * src/doc.c (Finternal__text_restyle): New function. (syms_of_doc): Define it.
2015-08-24 05:38:02 +00:00
(signal 'kkc-error (apply #'format-message args)))
(defvar kkc-converting nil)
;;;###autoload
(defvar kkc-after-update-conversion-functions nil
"Functions to run after a conversion is selected in `japanese' input method.
With this input method, a user can select a proper conversion from
candidate list. Each time he changes the selection, functions in this
list are called with two arguments; starting and ending buffer
positions that contains the current selection.")
1997-02-20 07:02:49 +00:00
;;;###autoload
(defun kkc-region (from to)
1997-02-20 07:02:49 +00:00
"Convert Kana string in the current region to Kanji-Kana mixed string.
Users can select a desirable conversion interactively.
When called from a program, expects two arguments,
positions FROM and TO (integers or markers) specifying the target region.
When it returns, the point is at the tail of the selected conversion,
and the return value is the length of the conversion."
1997-02-20 07:02:49 +00:00
(interactive "r")
(setq kkc-original-kana (buffer-substring from to))
(goto-char from)
;; Setup overlays.
(if (overlayp kkc-overlay-head)
(move-overlay kkc-overlay-head from to)
(setq kkc-overlay-head (make-overlay from to nil nil t))
(overlay-put kkc-overlay-head 'face 'highlight))
(if (overlayp kkc-overlay-tail)
(move-overlay kkc-overlay-tail to to)
(setq kkc-overlay-tail (make-overlay to to nil nil t))
(overlay-put kkc-overlay-tail 'face 'underline))
(setq kkc-current-key (string-to-vector kkc-original-kana))
(setq kkc-length-head (length kkc-current-key))
(setq kkc-length-converted 0)
(unwind-protect
;; At first convert the region to the first candidate.
(let ((current-input-method-title kkc-input-method-title)
(input-method-function nil)
(modified-p (buffer-modified-p))
(first t))
(while (not (kkc-lookup-key kkc-length-head nil first))
(setq kkc-length-head (1- kkc-length-head)
first nil))
(goto-char to)
(kkc-update-conversion 'all)
(setq kkc-next-count 1 kkc-prev-count 0)
(if (and (>= kkc-next-count kkc-show-conversion-list-count)
(>= (length kkc-current-conversions) 3))
(kkc-show-conversion-list-or-next-group))
1998-09-06 14:31:49 +00:00
;; Then, ask users to select a desirable conversion.
(force-mode-line-update)
(setq kkc-converting t)
;; Hide "... loaded" message.
(message nil)
(while kkc-converting
(set-buffer-modified-p modified-p)
(let* ((overriding-terminal-local-map kkc-keymap)
(help-char nil)
(keyseq (read-key-sequence nil))
(cmd (lookup-key kkc-keymap keyseq)))
(if (commandp cmd)
(condition-case err
(progn
(cond ((eq cmd 'kkc-next)
(setq kkc-next-count (1+ kkc-next-count)
kkc-prev-count 0))
((eq cmd 'kkc-prev)
(setq kkc-prev-count (1+ kkc-prev-count)
kkc-next-count 0))
(t
(setq kkc-next-count 0 kkc-prev-count 0)))
(call-interactively cmd))
(kkc-error (message "%s" (cdr err)) (beep)))
;; KEYSEQ is not defined in KKC keymap.
;; Let's put the event back.
(setq unread-input-method-events
(append (string-to-list (this-single-command-raw-keys))
unread-input-method-events))
(kkc-terminate))))
(force-mode-line-update)
(goto-char (overlay-end kkc-overlay-tail))
(- (overlay-start kkc-overlay-head) from))
(delete-overlay kkc-overlay-head)
(delete-overlay kkc-overlay-tail)))
1997-02-20 07:02:49 +00:00
(defun kkc-terminate ()
"Exit from KKC mode by fixing the current conversion."
(interactive)
(goto-char (overlay-end kkc-overlay-tail))
(move-overlay kkc-overlay-head (point) (point))
(setq kkc-converting nil))
1997-02-20 07:02:49 +00:00
(defun kkc-cancel ()
"Exit from KKC mode by canceling any conversions."
(interactive)
(goto-char (overlay-start kkc-overlay-head))
1997-02-20 07:02:49 +00:00
(delete-region (overlay-start kkc-overlay-head)
(overlay-end kkc-overlay-tail))
(insert kkc-original-kana)
(setq kkc-converting nil))
1997-02-20 07:02:49 +00:00
(defun kkc-first-char-only ()
"Select only the first character currently converted."
(interactive)
(goto-char (overlay-start kkc-overlay-head))
(forward-char 1)
(delete-region (point) (overlay-end kkc-overlay-tail))
(kkc-terminate))
(defun kkc-next ()
"Select the next candidate of conversion."
(interactive)
(let ((idx (1+ (car kkc-current-conversions))))
(if (< idx 0)
(setq idx 1))
(if (>= idx (length kkc-current-conversions))
(setq idx 0))
(setcar kkc-current-conversions idx)
(if (> idx 1)
(progn
(set-nested-alist kkc-current-key kkc-current-conversions
kkc-lookup-cache kkc-length-converted)
(setq kkc-init-file-flag 'kkc-lookup-cache)))
(if (or kkc-current-conversions-width
(>= kkc-next-count kkc-show-conversion-list-count))
(kkc-show-conversion-list-update))
(kkc-update-conversion)))
(defun kkc-prev ()
"Select the previous candidate of conversion."
(interactive)
(let ((idx (1- (car kkc-current-conversions))))
(if (< idx 0)
(setq idx (1- (length kkc-current-conversions))))
(setcar kkc-current-conversions idx)
(if (> idx 1)
(progn
(set-nested-alist kkc-current-key kkc-current-conversions
kkc-lookup-cache kkc-length-converted)
(setq kkc-init-file-flag 'kkc-lookup-cache)))
(if (or kkc-current-conversions-width
(>= kkc-prev-count kkc-show-conversion-list-count))
(kkc-show-conversion-list-update))
(kkc-update-conversion)))
(defun kkc-select-from-list ()
"Select one candidate from the list currently shown in echo area."
(interactive)
(let (idx)
(if kkc-current-conversions-width
(let ((len (length kkc-show-conversion-list-index-chars))
(maxlen (- (aref (aref kkc-current-conversions-width 0) 1)
(aref (aref kkc-current-conversions-width 0) 0)))
(i 0))
(if (> len maxlen)
(setq len maxlen))
(while (< i len)
(if (= (aref kkc-show-conversion-list-index-chars i)
last-input-event)
1997-02-20 07:02:49 +00:00
(setq idx i i len)
(setq i (1+ i))))))
(if idx
(progn
(setcar kkc-current-conversions
(+ (aref (aref kkc-current-conversions-width 0) 0) idx))
(kkc-show-conversion-list-update)
(kkc-update-conversion))
(setq unread-input-method-events
(cons last-input-event unread-input-method-events))
1997-02-20 07:02:49 +00:00
(kkc-terminate))))
(defun kkc-katakana ()
"Convert to Katakana."
(interactive)
(setcar kkc-current-conversions -1)
(kkc-update-conversion 'all))
(defun kkc-hiragana ()
"Convert to hiragana."
(interactive)
(setcar kkc-current-conversions 0)
(kkc-update-conversion))
(defun kkc-shorter ()
"Make the Kana string to be converted shorter."
(interactive)
(if (<= kkc-length-head 1)
(kkc-error "Can't be shorter"))
(setq kkc-length-head (1- kkc-length-head))
(if (> kkc-length-converted kkc-length-head)
(let ((len kkc-length-head))
(setq kkc-length-converted 0)
(while (not (kkc-lookup-key len))
(setq len (1- len)))))
(kkc-update-conversion 'all))
1997-02-20 07:02:49 +00:00
(defun kkc-longer ()
"Make the Kana string to be converted longer."
(interactive)
(if (>= kkc-length-head (length kkc-current-key))
(kkc-error "Can't be longer"))
(setq kkc-length-head (1+ kkc-length-head))
;; This time, try also entries with postfixes.
(kkc-lookup-key kkc-length-head 'postfix)
(kkc-update-conversion 'all))
(defun kkc-shorter-conversion ()
"Make the Kana string to be converted shorter."
(interactive)
(if (<= kkc-length-converted 1)
(kkc-error "Can't be shorter"))
(let ((len (1- kkc-length-converted)))
(setq kkc-length-converted 0)
(while (not (kkc-lookup-key len))
(setq len (1- len))))
(kkc-update-conversion 'all))
(defun kkc-longer-phrase ()
"Make the current phrase (BUNSETSU) longer without looking up dictionary."
(interactive)
(if (>= kkc-length-head (length kkc-current-key))
(kkc-error "Can't be longer"))
(setq kkc-length-head (1+ kkc-length-head))
(kkc-update-conversion 'all))
1997-02-20 07:02:49 +00:00
(defun kkc-next-phrase ()
"Fix the currently converted string and try to convert the remaining string."
(interactive)
(if (>= kkc-length-head (length kkc-current-key))
(kkc-terminate)
(setq kkc-length-head (- (length kkc-current-key) kkc-length-head))
(goto-char (overlay-end kkc-overlay-head))
(while (and (< (point) (overlay-end kkc-overlay-tail))
(looking-at "\\CH"))
(goto-char (match-end 0))
(setq kkc-length-head (1- kkc-length-head)))
(if (= kkc-length-head 0)
(kkc-terminate)
(let ((newkey (make-vector kkc-length-head 0))
(idx (- (length kkc-current-key) kkc-length-head))
(len kkc-length-head)
1997-02-20 07:02:49 +00:00
(i 0))
;; For the moment, (setq kkc-original-kana (concat newkey))
;; doesn't work.
(setq kkc-original-kana "")
(while (< i kkc-length-head)
(aset newkey i (aref kkc-current-key (+ idx i)))
(setq kkc-original-kana
(concat kkc-original-kana (char-to-string (aref newkey i))))
(setq i (1+ i)))
(setq kkc-current-key newkey)
(setq kkc-length-converted 0)
(while (and (not (kkc-lookup-key kkc-length-head nil
(< kkc-length-head len)))
1997-02-20 07:02:49 +00:00
(> kkc-length-head 1))
(setq kkc-length-head (1- kkc-length-head)))
(let ((pos (point))
(tail (overlay-end kkc-overlay-tail)))
(move-overlay kkc-overlay-head pos tail)
(move-overlay kkc-overlay-tail tail tail))
(kkc-update-conversion 'all)))))
;; We'll show users a list of available conversions in echo area with
;; index numbers so that users can select one conversion with the
;; number.
;; Set `kkc-current-conversions-width'.
(defun kkc-setup-current-conversions-width ()
(let ((convs (cdr kkc-current-conversions))
(len (length kkc-current-conversions))
(idx 1))
(setq kkc-current-conversions-width (make-vector len nil))
;; To tell `kkc-show-conversion-list-update' to generate
;; message from scratch.
(aset kkc-current-conversions-width 0 (vector len -2 nil))
;; Fill the remaining slots.
(while convs
(aset kkc-current-conversions-width idx
(+ (string-width (car convs)) 4))
(setq convs (cdr convs)
idx (1+ idx)))))
(defun kkc-show-conversion-list-or-next-group ()
"Show list of available conversions in echo area with index numbers.
If the list is already shown, show the next group of conversions,
and change the current conversion to the first one in the group."
(interactive)
(if (< (length kkc-current-conversions) 3)
(kkc-error "No alternative"))
1997-02-20 07:02:49 +00:00
(if kkc-current-conversions-width
(let ((next-idx (aref (aref kkc-current-conversions-width 0) 1)))
(if (< next-idx (length kkc-current-conversions-width))
(setcar kkc-current-conversions next-idx)
(setcar kkc-current-conversions 1))
(kkc-show-conversion-list-update)
(kkc-update-conversion))
(kkc-setup-current-conversions-width)
(kkc-show-conversion-list-update)))
(defun kkc-show-conversion-list-or-prev-group ()
"Show list of available conversions in echo area with index numbers.
If the list is already shown, show the previous group of conversions,
and change the current conversion to the last one in the group."
(interactive)
(if (< (length kkc-current-conversions) 3)
(kkc-error "No alternative"))
1997-02-20 07:02:49 +00:00
(if kkc-current-conversions-width
(let ((this-idx (aref (aref kkc-current-conversions-width 0) 0)))
(if (> this-idx 1)
(setcar kkc-current-conversions (1- this-idx))
(setcar kkc-current-conversions
(1- (length kkc-current-conversions-width))))
(kkc-show-conversion-list-update)
(kkc-update-conversion))
(kkc-setup-current-conversions-width)
(kkc-show-conversion-list-update)))
;; Update the conversion list shown in echo area.
(defun kkc-show-conversion-list-update ()
(or kkc-current-conversions-width
(kkc-setup-current-conversions-width))
(let* ((current-idx (car kkc-current-conversions))
(first-slot (aref kkc-current-conversions-width 0))
(this-idx (aref first-slot 0))
(next-idx (aref first-slot 1))
(msg (aref first-slot 2)))
(if (< current-idx this-idx)
;; The currently selected conversion is before the list shown
;; previously. We must start calculation of message width
;; from the start again.
(setq this-idx 1 msg nil)
(if (>= current-idx next-idx)
;; The currently selected conversion is after the list shown
;; previously. We start calculation of message width from
;; the conversion next of TO.
(setq this-idx next-idx msg nil)))
1997-02-20 07:02:49 +00:00
(if (not msg)
(let ((len (length kkc-current-conversions))
(max-width (window-width (minibuffer-window)))
(width-table kkc-current-conversions-width)
(width 0)
(idx this-idx)
(max-items (length kkc-show-conversion-list-index-chars))
1997-02-20 07:02:49 +00:00
l)
;; Set THIS-IDX to the first index of conversion to be shown
;; in MSG, and reflect it in kkc-current-conversions-width.
(while (<= idx current-idx)
(if (and (<= (+ width (aref width-table idx)) max-width)
(< (- idx this-idx) max-items))
1997-02-20 07:02:49 +00:00
(setq width (+ width (aref width-table idx)))
(setq this-idx idx width (aref width-table idx)))
(setq idx (1+ idx)
l (cdr l)))
(aset first-slot 0 this-idx)
;; Set NEXT-IDX to the next index of the last conversion
;; shown in MSG, and reflect it in
;; kkc-current-conversions-width.
1997-02-20 07:02:49 +00:00
(while (and (< idx len)
(<= (+ width (aref width-table idx)) max-width)
(< (- idx this-idx) max-items))
1997-02-20 07:02:49 +00:00
(setq width (+ width (aref width-table idx))
idx (1+ idx)
l (cdr l)))
(aset first-slot 1 (setq next-idx idx))
(setq l (nthcdr this-idx kkc-current-conversions))
(setq msg (format " %c %s"
(aref kkc-show-conversion-list-index-chars 0)
(propertize (car l)
'kkc-conversion-index this-idx))
idx (1+ this-idx)
l (cdr l))
1997-02-20 07:02:49 +00:00
(while (< idx next-idx)
(setq msg (format "%s %c %s"
1997-02-20 07:02:49 +00:00
msg
(aref kkc-show-conversion-list-index-chars
(- idx this-idx))
(propertize (car l)
'kkc-conversion-index idx))
idx (1+ idx)
1997-02-20 07:02:49 +00:00
l (cdr l)))
(aset first-slot 2 msg)))
;; Highlight the current conversion.
1997-02-20 07:02:49 +00:00
(if (> current-idx 0)
(let ((pos 3)
(limit (length msg)))
(remove-text-properties 0 (length msg) '(face nil) msg)
(while (not (eq (get-text-property pos 'kkc-conversion-index msg)
current-idx))
(setq pos (next-single-property-change pos 'kkc-conversion-index
msg limit)))
(put-text-property pos (next-single-property-change
pos 'kkc-conversion-index msg limit)
'face 'highlight msg)))
(let ((message-log-max nil))
(message "%s" msg))))
1997-02-20 07:02:49 +00:00
;; Update the conversion area with the latest conversion selected.
lisp/*.el, src/*.c: Fix typos in docstrings * lisp/apropos.el (apropos-do-all): * lisp/auth-source-pass.el (auth-source-pass--select-from-entries): * lisp/auth-source.el (auth-source-user-or-password): * lisp/calc/calc-forms.el (math-tzone-names): * lisp/calendar/diary-lib.el (diary-face-attrs) (diary-mark-entries-1): * lisp/cedet/cedet-files.el (cedet-files-list-recursively): * lisp/cedet/ede.el (ede-constructing, ede-deep-rescan): * lisp/cedet/ede/cpp-root.el (ede-cpp-root-header-file-p): * lisp/cedet/ede/proj.el (ede-proj-target-makefile): * lisp/cedet/inversion.el (inversion-check-version) (inversion-test): * lisp/cedet/mode-local.el (mode-local-map-file-buffers): * lisp/cedet/semantic/complete.el (semantic-displayer-ghost): * lisp/cedet/semantic/db-find.el (semanticdb-find-translate-path-default): * lisp/cedet/semantic/db.el (semanticdb-table) (semanticdb-search-system-databases): * lisp/cedet/semantic/imenu.el (semantic-imenu-index-directory): * lisp/cedet/semantic/java.el (semantic-java-doc-keywords-map): * lisp/cedet/semantic/lex-spp.el (semantic-lex-spp-use-headers-flag): * lisp/cedet/semantic/lex.el (semantic-lex-make-keyword-table) (semantic-lex-make-type-table, semantic-lex-debug-analyzers): * lisp/cedet/semantic/tag-ls.el (semantic-tag-abstract-p) (semantic-tag-leaf-p, semantic-tag-static-p) (semantic-tag-prototype-p): * lisp/dnd.el (dnd-open-remote-file-function, dnd-open-local-file): * lisp/emacs-lisp/eieio-opt.el (eieio-build-class-alist) (eieio-read-class, eieio-read-subclass): * lisp/emacs-lisp/generator.el (cps--replace-variable-references) (cps--handle-loop-for): * lisp/erc/erc-dcc.el (erc-dcc-list, erc-dcc-member, erc-dcc-server) (erc-dcc-auto-mask-p, erc-dcc-get-file, erc-dcc-chat-accept): * lisp/eshell/em-pred.el (eshell-pred-file-type): * lisp/faces.el (defined-colors-with-face-attributes): * lisp/font-core.el (font-lock-mode): * lisp/frame.el (frame-restack): * lisp/net/shr.el (shr-image-animate): * lisp/org/org-agenda.el (org-agenda-change-all-lines) (org-agenda-today-p): * lisp/org/org-id.el (org-id-get): * lisp/org/org.el (org-highlight-latex-and-related) (org--valid-property-p): * lisp/org/ox-beamer.el (org-beamer--get-label): * lisp/org/ox-latex.el (org-latex--caption-above-p): * lisp/org/ox-odt.el (org-odt--copy-image-file) (org-odt--copy-formula-file): * lisp/org/ox.el (org-export-with-timestamps): * lisp/progmodes/verilog-mode.el (verilog-indent-declaration-macros): * lisp/ses.el (ses-file-format-extend-parameter-list): * lisp/term.el (ansi-term): * lisp/textmodes/bibtex.el (bibtex-no-opt-remove-re) (bibtex-beginning-of-first-entry, bibtex-autokey-get-title) (bibtex-read-key, bibtex-initialize): * lisp/textmodes/flyspell.el (flyspell-word): * lisp/view.el (view-mode-exit): * src/composite.c: * src/floatfns.c (Fisnan): Fix typos in docstrings.
2019-09-19 02:32:25 +00:00
;; ALL if non-nil means to update the whole area, else update only
1997-02-20 07:02:49 +00:00
;; inside quail-overlay-head.
(defun kkc-update-conversion (&optional all)
(goto-char (overlay-start kkc-overlay-head))
(cond ((= (car kkc-current-conversions) 0) ; Hiragana
(let ((i 0))
(while (< i kkc-length-converted)
(insert (aref kkc-current-key i))
(setq i (1+ i)))))
((= (car kkc-current-conversions) -1) ; Katakana
(let ((i 0))
(while (< i kkc-length-converted)
(insert (japanese-katakana (aref kkc-current-key i)))
(setq i (1+ i)))))
(t
(insert (nth (car kkc-current-conversions) kkc-current-conversions))))
(delete-region (point) (overlay-start kkc-overlay-tail))
(if all
(let ((len (length kkc-current-key))
(i kkc-length-converted))
(delete-region (overlay-start kkc-overlay-tail)
(overlay-end kkc-overlay-head))
(while (< i kkc-length-head)
(if (= (car kkc-current-conversions) -1)
(insert (japanese-katakana (aref kkc-current-key i)))
(insert (aref kkc-current-key i)))
(setq i (1+ i)))
(let ((pos (point)))
(while (< i len)
(insert (aref kkc-current-key i))
(setq i (1+ i)))
(move-overlay kkc-overlay-head
(overlay-start kkc-overlay-head) pos)
(delete-region (point) (overlay-end kkc-overlay-tail)))))
(unwind-protect
(run-hook-with-args 'kkc-after-update-conversion-functions
(overlay-start kkc-overlay-head)
(overlay-end kkc-overlay-head))
(goto-char (overlay-end kkc-overlay-tail))))
1997-02-20 07:02:49 +00:00
;;
(provide 'kkc)
;;; kkc.el ends here