[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: insert space after specific chars
From: |
Pascal J. Bourguignon |
Subject: |
Re: insert space after specific chars |
Date: |
Tue, 15 Jul 2008 20:23:13 +0200 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/22.2 (gnu/linux) |
Rodrigo Canellas <rodrigo.canellas@tqtvd.com> writes:
> I would like to insert a single space after certain characters, such
> as '+', '-', '&', '=', etc.
>
> I think I can do this with a hook lisp function, but I do not know how.
I assume you don't what this to occur everywhere, only in a certain mode.
That means that you will have to locate that mode hook variable (M-x
apropos RET <the-mode> hook RET), and add to it some "meat", that is a
function that will customize the behavior of these keys, by modifying
the local bindings of the buffer.
(defun self-insert-and-space-command ()
(interactive)
(insert last-command-char " "))
M-x local-set-key RET + RET self-insert-and-space-command RET
If it's ok, then define your meat:
(defun <the-mode>-meat ()
(dolist (key (list (kbd "+")
(kbd "-")
(kbd "&")
(kbd "=")))
(local-set-key key 'self-insert-and-space-command)))
Then hook the meat:
(add-hook '<the-mode>-hook '<the-mode>-meat)
When you test the hook, be sure to kill and reopen the buffer, or
directly execute the meat with M-: (<the-mode>-meat) RET
--
__Pascal Bourguignon__ http://www.informatimago.com/
HANDLE WITH EXTREME CARE: This product contains minute electrically
charged particles moving at velocities in excess of five hundred
million miles per hour.