From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.org!not-for-mail
From: Thien-Thi Nguyen <ttn@gnu.org>
Newsgroups: gmane.emacs.devel
Subject: Re: A patch for enforcing double-width CJK character display
Date: Tue, 29 Apr 2014 10:16:31 +0200
Message-ID: <87fvkwy2hs.fsf@zigzag.favinet>
References: <CA+Gegu_J9EFD6WhiXvA8C+5EA2BwvpRD0Y_HLe_Lgb35kBkM0g@mail.gmail.com>
	<jwvwqe8r9w2.fsf-monnier+emacs@gnu.org>
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/signed; boundary="==-=-=";
	micalg=pgp-sha1; protocol="application/pgp-signature"
X-Trace: ger.gmane.org 1398759155 28219 80.91.229.3 (29 Apr 2014 08:12:35 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 29 Apr 2014 08:12:35 +0000 (UTC)
To: emacs-devel@gnu.org
Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Apr 29 10:12:28 2014
Return-path: <emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org>
Envelope-to: ged-emacs-devel@m.gmane.org
Original-Received: from lists.gnu.org ([208.118.235.17])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org>)
	id 1Wf39P-0007am-CB
	for ged-emacs-devel@m.gmane.org; Tue, 29 Apr 2014 10:12:27 +0200
Original-Received: from localhost ([::1]:47732 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org>)
	id 1Wf39O-0007SF-S3
	for ged-emacs-devel@m.gmane.org; Tue, 29 Apr 2014 04:12:26 -0400
Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38830)
	by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <ttn@gnu.org>)
	id 1Wf39G-0007EX-3r
	for emacs-devel@gnu.org; Tue, 29 Apr 2014 04:12:23 -0400
Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <ttn@gnu.org>) id 1Wf39A-0007B8-83
	for emacs-devel@gnu.org; Tue, 29 Apr 2014 04:12:18 -0400
Original-Received: from smtp206.alice.it ([82.57.200.102]:53522)
	by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ttn@gnu.org>)
	id 1Wf399-0007Az-Ko
	for emacs-devel@gnu.org; Tue, 29 Apr 2014 04:12:11 -0400
Original-Received: from zigzag.favinet (95.236.26.188) by smtp206.alice.it (8.6.060.28)
	id 529A678F1D336803 for emacs-devel@gnu.org;
	Tue, 29 Apr 2014 10:12:10 +0200
Original-Received: from ttn by zigzag.favinet with local (Exim 4.80)
	(envelope-from <ttn@gnu.org>) id 1Wf3DY-0006YR-HP
	for emacs-devel@gnu.org; Tue, 29 Apr 2014 10:16:44 +0200
Mail-Followup-To: emacs-devel@gnu.org
In-Reply-To: <jwvwqe8r9w2.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message
	of "Tue, 29 Apr 2014 01:39:39 -0400")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 82.57.200.102
X-BeenThere: emacs-devel@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "Emacs development discussions." <emacs-devel.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-devel>,
	<mailto:emacs-devel-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/emacs-devel>
List-Post: <mailto:emacs-devel@gnu.org>
List-Help: <mailto:emacs-devel-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-devel>,
	<mailto:emacs-devel-request@gnu.org?subject=subscribe>
Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org
Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org
Xref: news.gmane.org gmane.emacs.devel:171651
Archived-At: <http://permalink.gmane.org/gmane.emacs.devel/171651>

--==-=-=
Content-Type: multipart/mixed; boundary="=-=-="

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

() Stefan Monnier <monnier@iro.umontreal.ca>
() Tue, 29 Apr 2014 01:39:39 -0400

   > +    return 1;
   > +  return 0;=20

   Please make the return type "bool", then.  And use "true" and "false"
   rather than 1 and 0.  Also, you can apply eta-reduction to the above
   code and just write

  return (XftCharExists (xftfont_info->display, xftfont_info->xftfont, 0x4E=
00)
          || XftCharExists (xftfont_info->display, xftfont_info->xftfont, 0=
xAC00));

   [ Tho that would step over the 80 columns limit, so you may then want to
     introduce a local var to hold xftfont_info->display, maybe.  ]

Another wrinkle is func =E2=80=98XftCharExists=E2=80=99 returns =E2=80=98Fc=
Bool=E2=80=99, so to be
excruciatingly correct, we would want to compare each call's rv against
=E2=80=98FcTrue=E2=80=99, something like:


--=-=-=
Content-Type: text/x-c++src
Content-Disposition: inline

#define EXISTS(c) \
  (FcTrue == XftCharExists (i->display, i->xftfont, c))

  return EXISTS (0x4E00) || EXISTS (0xAC00);

#undef EXISTS

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable


(I'm a fan of local macros (#define/#undef inside a function), but
that's inappropriate for Emacs, it seems.  Hmm, i see one other call to
=E2=80=98XftCharExists=E2=80=99 in that file, so maybe a top-level macro is=
 warranted.)
Also, although we could use =E2=80=98(FcChar32) c=E2=80=99 as third arg, th=
at's probably
not a good idea; better to let callers cast if need be.

=2D-=20
Thien-Thi Nguyen
   GPG key: 4C807502
   (if you're human and you know it)
      read my lisp: (responsep (questions 'technical)
                               (not (via 'mailing-list)))
                     =3D> nil

--=-=-=--

--==-=-=
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlNfX+MACgkQZwMiJEyAdQJ8UQCfbt/w4TX5ho+1z/jr7r/riLam
kdsAoKYdSMmefKS64zgEXb/vXQB/XcjK
=d8IK
-----END PGP SIGNATURE-----
--==-=-=--