|
From: | Rodrigo Canellas |
Subject: | Re: insert space after specific chars |
Date: | Tue, 15 Jul 2008 17:00:39 -0300 |
User-agent: | Thunderbird 2.0.0.14 (X11/20080505) |
Thanks Pascal, it works fine! Pascal J. Bourguignon escreveu: 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 -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. |
[Prev in Thread] | Current Thread | [Next in Thread] |