From: Toomas Rosin <toomas@rosin.ee>
To: help-gnu-emacs@gnu.org
Subject: weirdness with no-break space, fset and defun
Date: Sun, 02 Aug 2015 13:10:39 +0300 [thread overview]
Message-ID: <20800.1438510239@toomas.lan> (raw)
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.
next reply other threads:[~2015-08-02 10:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-02 10:10 Toomas Rosin [this message]
2015-08-02 11:13 ` weirdness with no-break space, fset and defun Yuri Khan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20800.1438510239@toomas.lan \
--to=toomas@rosin.ee \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.