[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: insert text after a char depending on next char
From: |
weber |
Subject: |
Re: insert text after a char depending on next char |
Date: |
20 Apr 2007 15:11:03 -0700 |
User-agent: |
G2/1.0 |
On Apr 20, 6:45 pm, james <james.kings...@gmail.com> wrote:
> 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)))))))
Cool! I had never seen that!