pkgsrc-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: pkg/60647: New package: inputmethod/anthy-unicode and inputmethod/anthy-unicode-elisp
The following reply was made to PR pkg/60647; it has been noted by GNATS.
From: Showta Ishizaki <zakinko%snowrabbit.org@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: zakinko%snowrabbit.org@localhost
Subject: Re: pkg/60647: New package: inputmethod/anthy-unicode and inputmethod/anthy-unicode-elisp
Date: Fri, 28 Aug 2026 08:42:23 +0900 (JST)
Please replace patch-src-util_anthy-unicode.el from the shar with the one
below. Working on the upstream pull request (fujiwarat/anthy-unicode#21)
turned up two problems with the version I sent.
The first is that it adds byte-compile warnings on Emacs 24 and later. It
wrote the old names directly in an else branch, so an Emacs that does not
have them reports "not known to be defined"; on Emacs 30 the count went from
nine to fourteen. Picking the name once at load time and calling through a
variable adds none.
The second is the coding system on the pipe: it should be 'utf-8-unix, not
'utf-8. Plain utf-8 leaves the end-of-line undecided and the decoding side
settles on utf-8-dos.
While there, two problems that have nothing to do with Emacs 20 and 21 also
turned up, and the new patch fixes them. The coding system on the pipe is
left to the locale, so a ja_JP.eucJP or ja_JP.SJIS user gets mojibake out of
the conversion; and the undo list anthy puts aside while a preedit is open is
shared by every buffer, so opening a preedit in a second buffer overwrites
what the first one saved and the first buffer gets the wrong undo history
back. Both happen on Emacs 22.3 through 31.1.
The patch was applied to the 1.0.0.20260213 tarball and the six .el files
byte-compiled the way the package does it -- with Mule-UCS preloaded on
Emacs 20 and 21 -- then exercised from the .elc alone: 6 of 6 files compiled
with no warnings on Emacs 20.7, 21.4 and 30.2, and japanese-anthy-unicode
converted nihongo and switched off again under both ja_JP.UTF-8 and
ja_JP.eucJP on all three.
The elisp itself was measured more widely on NetBSD 11.0/amd64, with Emacs
20.7, 21.4, 22.3, 23.4, 24.5, 25.3, 26.3, 27.2, 28.2, 29.4, 30.2, 31.1 and
XEmacs 21.4.25.
Once upstream takes it the patch can be dropped. PKGREVISION is not touched,
the package not being in the tree yet.
$NetBSD$
Fix the coding system on the pipe to the agent, keep each buffer's saved undo
list to itself, and let the file work on the older Emacs versions pkgsrc
still carries.
The first two are not about old Emacs at all. anthy-agent-unicode speaks
UTF-8 and nothing else, but nothing sets the coding system on the pipe, so
Emacs uses default-process-coding-system, which follows the user's locale.
Under a ja_JP.eucJP or ja_JP.SJIS locale the conversion comes back as
mojibake on Emacs 22.3 through 31.1 alike. utf-8-unix is set explicitly;
the -unix matters, because plain utf-8 leaves the end-of-line undecided and
the decoding side settles on utf-8-dos.
anthy stops undo while a preedit is open and puts the buffer's undo list
aside until the text is committed. The flag saying it did so is
anthy-deflocalvar, that is per buffer, but the list itself was an undeclared
global shared by every buffer, so opening a preedit in a second buffer
overwrote what the first one had put aside, and the first buffer got the
second one's undo history when it committed.
anthy-restore-undo-list is dead: the two places that set the variable it
reads and its one call site are all commented out, as they already were in
anthy 9100h. It is commented out too rather than deleted, the same way its
callers are, so that taking the semicolons off brings it back.
The rest is the older Emacs versions. Each name is picked once at load time
and called through a variable:
set-face-underline Emacs 20 has only set-face-underline-p, and
until 24.3 that is the current spelling.
The call is at top level, so on Emacs 20 the
file does not load and only 4 of the 6 .elc
files get built.
set-process-query-on-exit-flag new in 22.1. It is called from
anthy-check-agent, so Emacs 21 and XEmacs
build and load and then die at the first
conversion.
deactivate-input-method,
deactivate-current-input-method-function
renamed from inactivate-* in 24.3. Emacs 22
and 23 convert and then cannot leave the
input method: void-function nil, because the
variable they read stays nil.
mapc new in Emacs 21; 9100h used mapcar here.
Writing the old name in an else branch would work, but a current Emacs then
reports it as not known to be defined, so this goes through a variable. The
XEmacs-only names in anthy-last-command-char get the same treatment, and a
lexical-binding cookie is added, which together take Emacs 24 and later from
nine byte-compile warnings to none.
Emacs 20, 21 and XEmacs 21.4 have no utf-8 coding system that covers CJK, so
Mule-UCS is required there, inside condition-case so that nothing happens
where it is not installed and nothing at all happens from Emacs 22 on.
XEmacs takes a coding system object rather than a symbol, so the value goes
through find-coding-system there.
Measured on NetBSD 11.0/amd64 with Emacs 20.7, 21.4, 22.3, 23.4, 24.5, 25.3,
26.3, 27.2, 28.2, 29.4, 30.2, 31.1 and XEmacs 21.4.25, typing nihongo,
converting, committing and switching the input method off again.
Sent upstream as fujiwarat/anthy-unicode#21; this can be dropped once a
release includes it.
--- src-util/anthy-unicode.el.orig
+++ src-util/anthy-unicode.el
@@ -1,4 +1,4 @@
-;;; anthy-unicode.el -- Anthy
+;;; anthy-unicode.el -- Anthy -*- lexical-binding: nil -*-
;; Copyright (C) 2001 - 2007 KMC(Kyoto University Micro Computer Club)
;; Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1%gmail.com@localhost>
@@ -70,12 +70,73 @@
(defvar anthy-agent-unicode-command-list '("anthy-agent-unicode")
"anthy-agent-unicodeã?®PATH å??")
+;; XEmacs ã?«ã??ã??ç?¡ã??å??å??ã??anthy-xemacs ã??ç??ã?®ã?¨ã??ã??ã??å?¼ã?°ã?ªã??ã??ã??ç?´æ?¥æ?¸ã??ã?¨
+;; GNU Emacs ã?® byte compiler ã?? "not known to be defined" ã?¨è¨?ã??ã??
+(defvar anthy-event-matches-key-specifier-p-function
+ 'event-matches-key-specifier-p)
+(defvar anthy-event-to-character-function 'event-to-character)
+(defvar anthy-char-to-int-function 'char-to-int)
+
+;; Emacs 22.1 ã??ã??ã??Emacs 20/21 ã?¨ XEmacs ã?¯ process-kill-without-queryã??
+;; ã?©ã?¡ã??ã??第äº?å¼?æ?° nil ã?§ã??çµ?äº?æ??ã?«å??ã??å??ã??ã??ã?ªã??ã??ã?®æ??å?³ã?«ã?ªã??ã??
+(defvar anthy-set-process-no-query-function
+ (if (fboundp 'set-process-query-on-exit-flag)
+ 'set-process-query-on-exit-flag
+ 'process-kill-without-query))
+
+;; Emacs 24.3 ã?§ inactivate-* ã??ã??æ?¹å??ã??ã??ã??ã??Emacs 20 ã??ã?? 23 ã?¨ XEmacs ã?¯
+;; æ?§å??ã??ã??æ??ã??ã?ªã??ã??
+(defvar anthy-deactivate-input-method-function
+ (if (fboundp 'deactivate-input-method)
+ 'deactivate-input-method
+ 'inactivate-input-method))
+(defvar anthy-deactivate-current-input-method-variable
+ (if (boundp 'deactivate-current-input-method-function)
+ 'deactivate-current-input-method-function
+ 'inactivate-current-input-method-function))
+
+;; Emacs 21 ã??ã??ã??Emacs 20 ã?¨ XEmacs ã?¯ set-face-underline-p ã?®ã?¿ã??24.3 ã?¾ã?§ã?¯
+;; -p ã?®æ?¹ã??æ£ã?§ã??ã??ã?¡ã??ã?? obsoleteã??ã??ã??ã?¯ top level ã?ªã?®ã?§ã??ç?¡ã??ç??ã?§ã?¯ load
+;; ã??ã?®ã??ã?®ã??失æ??ã??ã??ã??
+(defvar anthy-set-face-underline-function
+ (if (fboundp 'set-face-underline)
+ 'set-face-underline
+ 'set-face-underline-p))
+
+;; Emacs 21 ã??ã??ã??Emacs 20 ã?«ã?¯ç?¡ã??ã??anthy 9100h ã?¯ã??ã?®è¡?ã?§ mapcar ã? ã?£ã??ã??
+;; è¿?ã??å?¤ã?¯æ?¨ã?¦ã??ã?®ã?§ã??ã?©ã?¡ã??ã?§ã??å??ã??ã??
+(defvar anthy-mapc-function
+ (if (fboundp 'mapc)
+ 'mapc
+ 'mapcar))
+
+;; Emacs 20 ã?¨ 21 ã?® utf-8 ã?¯ CJK ã??å?«ã?¾ã?ªã?? (20 ã?«ã?¯ utf-8 ã??ã?®ã??ã?®ã??ç?¡ã??)ã??
+;; XEmacs 21.4 ã?«ã?? utf-8 ã??ç?¡ã??ã??agent ã?¯ UTF-8 ã?§ã??ã??話ã??ã?ªã??ã?®ã?§ã??
+;; Mule-UCS ã??ã??ã??ã?°è¼?ã??ã??ã??
+(if (and (or (featurep 'xemacs)
+ (< emacs-major-version 22))
+ (not (featurep 'un-define)))
+ (condition-case nil
+ (require 'un-define)
+ (error nil)))
+
+;; XEmacs ã?® coding-system-p ã?¯ symbol ã?§ã?¯ã?ªã?? coding system ã?ªã??ã?¸ã?§ã?¯ã??ã??
+;; å??ã??ã?®ã?§ã??find-coding-system ã??é??ã??ã??
+(defvar anthy-agent-coding-system
+ (if (featurep 'xemacs)
+ (and (fboundp 'find-coding-system)
+ (find-coding-system 'utf-8-unix))
+ (and (coding-system-p 'utf-8-unix)
+ 'utf-8-unix)))
+
;; face
(defvar anthy-highlight-face nil)
(defvar anthy-underline-face nil)
(copy-face 'highlight 'anthy-highlight-face)
+;(if (not (featurep 'xemacs))
+; (set-face-underline 'anthy-highlight-face t))
(if (not (featurep 'xemacs))
- (set-face-underline 'anthy-highlight-face t))
+ (funcall anthy-set-face-underline-function 'anthy-highlight-face t))
(copy-face 'underline 'anthy-underline-face)
;;
@@ -202,6 +263,9 @@
(anthy-deflocalvar anthy-current-rkmap "hiragana")
; undo
(anthy-deflocalvar anthy-buffer-undo-list-saved nil)
+;; å¾?é?¿ã??ã?? undo list ã??ã?®ã??ã?®ã??æ??ã? ã?? buffer local ã?§ä¸èº«ã?? global ã? ã?£ã??ã?®ã?§ã??
+;; buffer ã??äº?ã?¤ä½¿ã??ã?¨ç??æ?¹ã?®å±¥æ´ã??ã??ã??ç??æ?¹ã?®ã??ã?®ã?§ä¸?æ?¸ã??ã??ã??ã?¦ã??ã??ã??
+(anthy-deflocalvar anthy-buffer-undo-list nil)
;;
(defvar anthy-wide-space "ã??" "ã?¹ã??ã?¼ã?¹ã??æ?¼ã??ã??æ??ã?«å?ºã?¦æ?¥ã??æ??å?")
@@ -250,7 +314,8 @@
(delete-region start (+ start len))
(goto-char start)))
(setq anthy-preedit "")
- (mapc 'delete-overlay anthy-preedit-overlays)
+; (mapc 'delete-overlay anthy-preedit-overlays)
+ (funcall anthy-mapc-function 'delete-overlay anthy-preedit-overlays)
(setq anthy-preedit-overlays nil))
(defun anthy-select-face-by-attr (attr)
@@ -546,14 +611,17 @@
(char-to-string ch)
nil))))
-(defun anthy-restore-undo-list (commit-str)
- (let* ((len (length commit-str))
- (beginning (point))
- (end (+ beginning len)))
- (setq buffer-undo-list
- (cons (cons beginning end)
- (cons nil anthy-saved-buffer-undo-list)))
- ))
+;; å?¼ã?³å?ºã??å?´ã??ã??anthy-saved-buffer-undo-list ã??è¨å®?ã??ã??äº?ç®?æ??ã??ã??å??ã??ã??
+;; ã?³ã?¡ã?³ã??ã?¢ã?¦ã??ã??ã??ã?¦ã??ã??ã??ã??ã?®é?¢æ?°ã? ã??ã??ç??ã??ã?¦ã??ã?¦ã??å?¼ã?¹ã?° void-variable ã?«
+;; ã?ªã??ã??å??ã??ã??ã??ã?«é??ã??ã?¦ã??ã??ã??
+;(defun anthy-restore-undo-list (commit-str)
+; (let* ((len (length commit-str))
+; (beginning (point))
+; (end (+ beginning len)))
+; (setq buffer-undo-list
+; (cons (cons beginning end)
+; (cons nil anthy-saved-buffer-undo-list)))
+; ))
(defun anthy-proc-agent-reply (repl)
(let*
@@ -752,7 +820,13 @@
(if anthy-agent-unicode-process
(kill-process anthy-agent-unicode-process))
(setq anthy-agent-unicode-process proc)
- (set-process-query-on-exit-flag proc nil)
+; (set-process-query-on-exit-flag proc nil)
+ (funcall anthy-set-process-no-query-function proc nil)
+; (if (coding-system-p 'utf-8-unix)
+; (set-process-coding-system proc 'utf-8-unix 'utf-8-unix))
+ (if anthy-agent-coding-system
+ (set-process-coding-system proc anthy-agent-coding-system
+ anthy-agent-coding-system))
;; (if anthy-xemacs
;; (if (coding-system-p (find-coding-system 'euc-japan))
;; (set-process-coding-system proc 'euc-japan 'euc-japan))
@@ -871,7 +945,9 @@
;; leim ã?® activate
;;
(defun anthy-unicode-leim-activate (&optional name)
- (setq deactivate-current-input-method-function 'anthy-unicode-leim-inactivate)
+; (setq deactivate-current-input-method-function 'anthy-unicode-leim-inactivate)
+ (set anthy-deactivate-current-input-method-variable
+ 'anthy-unicode-leim-inactivate)
(setq anthy-leim-active-p t)
(anthy-update-mode)
(when (eq (selected-window) (minibuffer-window))
@@ -881,7 +957,8 @@
;; emacsã?®ã??ã?°é?¿ã??ã??ã??ã??ã?§ã??
;;
(defun anthy-unicode-leim-exit-from-minibuffer ()
- (deactivate-input-method)
+; (deactivate-input-method)
+ (funcall anthy-deactivate-input-method-function)
(when (<= (minibuffer-depth) 1)
(remove-hook 'minibuffer-exit-hook 'anthy-unicode-leim-exit-from-minibuffer)))
@@ -891,14 +968,24 @@
;;
(defun anthy-last-command-char ()
"æ??å¾?ã?®å?¥å??ã?¤ã??ã?³ã??ã??è¿?ã??ã??XEmacs ã?§ã?¯ int ã?«å¤?æ??ã??ã??"
+; (if anthy-xemacs
+; (let ((event last-command-event))
+; (cond
+; ((event-matches-key-specifier-p event 'left) 2)
+; ((event-matches-key-specifier-p event 'right) 6)
+; ((event-matches-key-specifier-p event 'backspace) 8)
+; (t
+; (char-to-int (event-to-character event)))))
+; last-command-event))
(if anthy-xemacs
(let ((event last-command-event))
(cond
- ((event-matches-key-specifier-p event 'left) 2)
- ((event-matches-key-specifier-p event 'right) 6)
- ((event-matches-key-specifier-p event 'backspace) 8)
+ ((funcall anthy-event-matches-key-specifier-p-function event 'left) 2)
+ ((funcall anthy-event-matches-key-specifier-p-function event 'right) 6)
+ ((funcall anthy-event-matches-key-specifier-p-function event 'backspace) 8)
(t
- (char-to-int (event-to-character event)))))
+ (funcall anthy-char-to-int-function
+ (funcall anthy-event-to-character-function event)))))
last-command-event))
;;
Home |
Main Index |
Thread Index |
Old Index