unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Sebastian Meisel <sebastianmeisel@web.de>
To: Emacs Mailing List <help-gnu-emacs@gnu.org>
Subject: Re: insert text after a char depending on next char
Date: Sat, 21 Apr 2007 11:43:19 +0200	[thread overview]
Message-ID: <4629DCB7.2040105@web.de> (raw)
In-Reply-To: <1177105532.679291.45760@o5g2000hsb.googlegroups.com>

james schrieb:
> On Apr 20, 1:55 pm, weber <hug...@gmail.com> wrote:
>   
>> On 20 abr, 15:05, james <james.kings...@gmail.com> wrote:
>>
>>
>>
>>     
>>> On Apr 20, 9:17 am, Sebastian Meisel <sebastianmei...@web.de> wrote:
>>>       
>>>> Hallo,
>>>>         
>>>> is the following possible in emacs, and if it is how can it be done:
>>>>         
>>>> I want emacs  to insert  "\," after a dot ("."), when no space is following:
>>>>         
>>>> I type: "Hallo World. Hallo World." -> emacs shall not insert anything,
>>>> because a space is following.
>>>> I type: "Hallo World.Hallo World." -> emacs shall insert "\," after the
>>>> dot resulting in: "Hallo World.\,Hallo World.".
>>>>         
>>>> Thanks for any hints.
>>>>         
>>>> Sebastian Meisel
>>>>         
>>> Something like this:
>>>       
>>> (defun qwerty()
>>>   (interactive)
>>>   (cond ((looking-at " ") (insert "."))
>>>         (t (insert ".\\,"))))
>>>       
>>> (local-set-key (kbd ".") 'qwerty)
>>>       
>>> Seems like the sort of thing you'd want to add more conditions to
>>>       
>> At first I thought about something like that too, but you got to
>> realize that when he types the '.' he still has not completed the rest
>> of the sentence...
>> So it seems that the correct would be: after any keypress, look back:
>> if there is ". " then nothing, is there is ".H" then insert \, after
>> the dot...
>>
>> Cheers,
>> weber
>>     
>
> (defun qwerty()
>   (interactive)
>   (insert ".")
>   (let ((c (read-event)))
>     (cond
>      ((eq 32 c) (insert " "))
>      (t (insert (concat "\\," (make-string 1 c)))))))
>
>   
There is one last thing I'm missing to make it perfect (which that 
solution is close to): Is there a way to handle M- and C- events so they 
are evaluated not by the function, but with there standard binding?

  parent reply	other threads:[~2007-04-21  9:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.2312.1177079016.7795.help-gnu-emacs@gnu.org>
2007-04-20 18:05 ` insert text after a char depending on next char james
2007-04-20 18:55   ` weber
2007-04-20 21:45     ` james
2007-04-20 22:11       ` weber
2007-04-21  9:43       ` Sebastian Meisel [this message]
2007-04-20 14:17 Sebastian Meisel
2007-04-20 19:01 ` Peter Dyballa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4629DCB7.2040105@web.de \
    --to=sebastianmeisel@web.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).