all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* weirdness with no-break space, fset and defun
@ 2015-08-02 10:10 Toomas Rosin
  2015-08-02 11:13 ` Yuri Khan
  0 siblings, 1 reply; 2+ messages in thread
From: Toomas Rosin @ 2015-08-02 10:10 UTC (permalink / raw)
  To: help-gnu-emacs

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.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-08-02 11:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-02 10:10 weirdness with no-break space, fset and defun Toomas Rosin
2015-08-02 11:13 ` Yuri Khan

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.