From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rupert Swarbrick Newsgroups: gmane.emacs.help Subject: Re: How to simulate keyboard input in self-defined function? Date: Sat, 23 Aug 2008 10:48:33 +0100 Organization: albasani.net Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1219488048 30654 80.91.229.12 (23 Aug 2008 10:40:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 23 Aug 2008 10:40:48 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Aug 23 12:41:42 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KWqYv-0003iT-5j for geh-help-gnu-emacs@m.gmane.org; Sat, 23 Aug 2008 12:41:41 +0200 Original-Received: from localhost ([127.0.0.1]:41507 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KWqXx-0004Et-94 for geh-help-gnu-emacs@m.gmane.org; Sat, 23 Aug 2008 06:40:41 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!newsfeed.straub-nv.de!news.albasani.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 94 Original-X-Trace: news.albasani.net I/V+XMa1lXDKbtnhqOrEmCe7KsjX5xrStwt3MgRqdf+VZ1sAIvPhJFeEf8lK/rd3KdZ9QE73nk58yScXp/FuWNXOP2PiVfnZ4f/991rTout3W6jiCITGh22DJbkioVoP Original-X-Complaints-To: abuse@albasani.net Original-NNTP-Posting-Date: Sat, 23 Aug 2008 09:48:37 +0000 (UTC) X-User-ID: +7vPq1ix+M6dcrJhJAQ5d5vcgjvdo9puJGTNfCK5eKs= Cancel-Lock: sha1:KQIMdhrO4mQDJtHBGsuYL4wnT5s= User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/22.2 (gnu/linux) X-NNTP-Posting-Host: 57EymhDGL6h7VmPOMVLzRpcLFXq8C/dZnTE2xAmmmvs= Original-Xref: news.stanford.edu gnu.emacs.help:161555 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:56899 Archived-At: --=-=-= Content-Transfer-Encoding: quoted-printable "xiaopeng hu" writes: So, grumpy stuff first. There's a real reply below. =2D Please reply to posts in newsgroups to the groups themselves: there's no particular reason this had to go as a private email. =2D Please don't top-post. "xiaopeng hu" writes: > I want emacs more intelligent in latex file. > Every strike input real charater. > Don't space many keystrike to toggle input method > Thanks > I'm sorry, but I don't actually understand what you mean here - could you be more specific? > 2008/8/23 xiaopeng hu > > Thanks for your warm heart! I want to simulate keystrike "t" + > (not simultaneously). If what I get is not "t ", I know > my input method is not english. Then I will simulate "Ctrl" once > to toggle input method between english and chinese. >=20=20=20=20 > Why I do this is that I want to define a function, which > automatically switch my input method to english when I in math > mode such as $...$, \[ ...\](in latex file), switch to chinese > when I out of math mode. >=20=20=20=20 > In my computer , I do use another efficient input method ,whic use > only "Ctrol" to switch between chinese and english. >=20=20=20=20 > Input method builded in emacs is poor.=20 >=20=20=20=20 > I just don't know how to implement the function, using defined > function or hook? >=20=20=20=20 > Thanks >=20=20=20=20 I now see what you mean about simulating key strokes. I think this is very dependent on what other software you're using. Is this windows? And what is the software that's catching single CTRL keypresses and switching modes? You see, although I don't know this for sure, I suspect that when you're in "English Mode", if you hit "t" then " " on the keyboard, "t" then " " are sent to Emacs. Fine. But if this external software is in another mode (where it presumably does some clever stuff like composing characters), the Emacs process won't ever see the "t" and the " " and instead will see what it gets translated to. Moreover, I suspect you won't actually have a way to change this input method from emacs either - how do you propose to send a message to the external program? Now, I see two obvious ways forward from here, but bear in mind I don't use multiple input methods except occaisionally switching to German, so this might not be that useful: 1) Live with it. No, really, it doesn't seem like an easy problem to solve, the way you've got things set up. 2) Try out the inbuilt emacs input methods. I understand you believe them to be "poor", but can you explain exactly what's wrong? After all, if there is something really wrong and you haven't got them mis-configured I'm sure someone will want to fix them. If you do use inbuilt emacs modes, then you'll have access to elisp like (toggle-input-method) to switch between modes etc. and what you want with the $$ characters seems quite achievable. Hope this is of some help, Rupert --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iJwEAQECAAYFAkiv3PEACgkQRtd/pJbYVobs1wP/TjC9B3DM3N+/DDYvnSIsYn3C uQMO+pplxMDRQLK2TIl//0W1TOYrtvrbrlbZ4IOsRobDoyY+KwtMK4yTkMsXxCQT j4ZB9IC5y/HIMjaGoAiPhuQtvtaCSfl6COa42ePkwpFNX6wYlpkuOmQbKaWz7ANt nL9QEytz2koaltBH1pQ= =Hogh -----END PGP SIGNATURE----- --=-=-=--