help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: insert text after a char depending on next char


From: Sebastian Meisel
Subject: Re: insert text after a char depending on next char
Date: Sat, 21 Apr 2007 11:43:19 +0200
User-agent: Thunderbird 1.5.0.10 (Macintosh/20070221)

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?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]