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

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

weirdness with no-break space, fset and defun


From: Toomas Rosin
Subject: weirdness with no-break space, fset and defun
Date: Sun, 02 Aug 2015 13:10:39 +0300

Good <insert your local time of day here>!

I have a text file in which I want to occasionally overwrite regular
spaces (<U0020>, #x20) with UTF-8 no-break spaces (<U00A0>).  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 (insert 
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=C emacs --no-init".  I have Emacs 24.4.1, a fairly
regular build: "--prefix=/usr --with-gif=no --localstatedir=/var", with
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.



reply via email to

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