From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rodrigo Canellas Newsgroups: gmane.emacs.help Subject: Re: insert space after specific chars Date: Tue, 15 Jul 2008 17:00:39 -0300 Message-ID: <487D01E7.50207@tqtvd.com> References: <487B5CF9.9030300@tqtvd.com> <87abgjypke.fsf@hubble.informatimago.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1216152213 19672 80.91.229.12 (15 Jul 2008 20:03:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 15 Jul 2008 20:03:33 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: "Pascal J. Bourguignon" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jul 15 22:04:19 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KIqkx-0003m7-Tl for geh-help-gnu-emacs@m.gmane.org; Tue, 15 Jul 2008 22:04:16 +0200 Original-Received: from localhost ([127.0.0.1]:43435 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KIqk4-0007Sd-3A for geh-help-gnu-emacs@m.gmane.org; Tue, 15 Jul 2008 16:03:20 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KIqjj-0007Rr-Pb for help-gnu-emacs@gnu.org; Tue, 15 Jul 2008 16:02:59 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KIqjh-0007QD-IC for help-gnu-emacs@gnu.org; Tue, 15 Jul 2008 16:02:59 -0400 Original-Received: from [199.232.76.173] (port=60530 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KIqjh-0007Q5-DT for help-gnu-emacs@gnu.org; Tue, 15 Jul 2008 16:02:57 -0400 Original-Received: from mail.quality.com.br ([200.179.60.40]:45402) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KIqjg-0000TM-2t for help-gnu-emacs@gnu.org; Tue, 15 Jul 2008 16:02:57 -0400 Received-SPF: none (tqtvd.com: No applicable sender policy available) receiver=mail.quality.com.br; identity=mfrom; envelope-from="rodrigo.canellas@tqtvd.com"; helo="[10.0.8.207]"; client-ip=10.0.8.207 Original-Received: from [10.0.8.207] (unknown [10.0.8.207]) by mail.quality.com.br (Postfix) with ESMTP id BBE7815815A; Tue, 15 Jul 2008 16:41:06 -0300 (BRT) User-Agent: Thunderbird 2.0.0.14 (X11/20080505) In-Reply-To: <87abgjypke.fsf@hubble.informatimago.com> X-Quality-MailScanner-Information: Please contact the ISP for more information X-MailScanner-ID: BBE7815815A.43BA1 X-Quality-MailScanner: Found to be clean X-Quality-MailScanner-From: rodrigo.canellas@tqtvd.com X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:55605 Archived-At: 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.