From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Toomas Rosin Newsgroups: gmane.emacs.help Subject: weirdness with no-break space, fset and defun Date: Sun, 02 Aug 2015 13:10:39 +0300 Message-ID: <20800.1438510239@toomas.lan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1438510267 18088 80.91.229.3 (2 Aug 2015 10:11:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 2 Aug 2015 10:11:07 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Aug 02 12:11:01 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZLqEO-0000Vf-OT for geh-help-gnu-emacs@m.gmane.org; Sun, 02 Aug 2015 12:11:00 +0200 Original-Received: from localhost ([::1]:55609 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZLqEN-0006rA-Qc for geh-help-gnu-emacs@m.gmane.org; Sun, 02 Aug 2015 06:10:59 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZLqEF-0006r5-GO for help-gnu-emacs@gnu.org; Sun, 02 Aug 2015 06:10:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZLqEC-0000a4-99 for help-gnu-emacs@gnu.org; Sun, 02 Aug 2015 06:10:51 -0400 Original-Received: from rosin.ee ([88.196.134.13]:42071) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZLqEB-0000ZT-Pp for help-gnu-emacs@gnu.org; Sun, 02 Aug 2015 06:10:48 -0400 Original-Received: from localhost.lan ([127.0.0.1] helo=toomas.lan) by rosin.ee with esmtp (Exim 4.84) (envelope-from ) id 1ZLqE3-0005PV-BB for help-gnu-emacs@gnu.org; Sun, 02 Aug 2015 13:10:39 +0300 X-Mailer: MH-E 8.6; nmh 1.6; GNU Emacs 24.4.1 Content-ID: <20799.1438510239.1@toomas.lan> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 88.196.134.13 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:106205 Archived-At: Good ! I have a text file in which I want to occasionally overwrite regular spaces (, #x20) with UTF-8 no-break spaces (). Trying to define a shortcut key for this (C-c SPC, which is a lot easier to type frequently than C-x 8 SPC), I ran into a bit of trouble. I got it right finally, but am still puzzled about why my first attempts failed. When I do M-: (fset SPC 'insert-no-break-space SPC " C-x 8 SPC ") RET = M-x insert-no-break-space RET , the result depends on where the point is located. After a regular space (#0x20), this command has absolutely no effect; elsewhere it inserts a *regular* (instead of no-break) space, *without overwriting the next character* in overwrite mode! When I do, instead, M-: (defun SPC insert-no-break-space SPC () SPC (interactive) SPC (ins= ert SPC " C-x 8 SPC ")) RET M-x insert-no-break-space RET , the command inserts a no-break space all right, but still does not overwrite the next character in overwrite mode. (I did these experiments first in a regular Emacs session, but the same happened with "LANG=3DC emacs --no-init". I have Emacs 24.4.1, a fairly regular build: "--prefix=3D/usr --with-gif=3Dno --localstatedir=3D/var", w= ith X libraries.) The method I arrived at at last is the following: M-: (fset SPC 'insert-no-break-space SPC " C-q C-x 8 SPC ") RET (i.e. with C-q before C-x). This does exactly what I need. I am confused. What's going on? Am I missing something I should know? With best wishes, T.