From: xah@xahlee.org
To: help-gnu-emacs@gnu.org
Subject: Re: Meta-Characters, Special Characters
Date: 29 May 2007 16:29:33 -0700 [thread overview]
Message-ID: <1180481373.651591.253210@i38g2000prf.googlegroups.com> (raw)
In-Reply-To: <5c2mbdF2ung8hU1@mid.individual.net>
Will (aka weber) wrote:
«
[about the various ways to input or represent keystrokes and or non-
printable characters in Emacs]
As far as I can see in all those situations entering meta-characters
is
addressed in a different way which I find confusing, e.g.:
a) <key> _or_ C-q <key>
b) C-q C-[, C-q C-m, C-q C-j, C-q C-i
c) \e, \r, \n, \t
d) (define-key [(meta c) (control c) (tab c)] "This is confusing!")
»
None of this complexity is istrinsic.
Will wrote:
«a) <key> _or_ C-q <key>»
The C-q (or, pressing the Control key down then type q) is the
keyboard shortcut to invoke the command quoted-insert. It is a
general a way to allow you to input any non-printable characters. This
facility usually don't exist in other text editors. In popular text
editor such as Microsoft Word or Mac's Application, you usally bring
up a window showing all the special characters, then press a button to
insert the char you want.
« b) C-q C-[, C-q C-m, C-q C-j, C-q C-i»
In this, the C-q is the keyboard shortcut to invoke the command quoted-
insert, which will insert a literal character of whatever character
you can type on your keyboard. So, for example, C-q followed by the
tab key will insert a the non-printable character tab.
When speaking of non-printable characters, the context is a character
set standard. Implicitly, we are talking about ASCII, and this applies
to emacs. Now, in ASCII, there are about 30 non-printable characters.
Each of these is given a standard abbreviation, and several
representations for different purposes. For example, ASCII 13 is the
“Carriage return” character, with abbr code CR, and ^M as its control-
key-input representation. (M being the 13th of the English alphabet)
For the full detail, look at the table here:
http://en.wikipedia.org/wiki/Ascii
(Note: Emacs also have a general way to input non-printable characters
of the unicode standard. See
Emacs and Unicode Tips
http://xahlee.org/emacs/emacs_n_unicode.html
)
« c) \e, \r, \n, \t »
This is a ad-hoc set of input and display representation for a few non-
printable characters. This set is started by the motherfucking unix
tech geeking morons, and by its free and speedy nature as cigarette
given to children, today has spread to many languages (Perl, Java, C+
+, C#, Python, JavaScript ...) and is a de facto standard. The damage
is to such a degree that the general concept of unprintable
characters, their representation, and their method of input, all
treated in one systematic, simple way, are not in the consciousness of
average industrial programers.
I do not know the history of these display representations. (hopefully
someone will) It is my guess, that part of the reason for these, is
that the unix text editor vi, doesn't have a general way to input non-
printable chars.
« d) (define-key [(meta c) (control c) (tab c)] "This is confusing!")
»
This is the only part of complexity in our context that we can blame
emacs's design. Emacs has several ways to represent keystrokes for
defining shortcuts. The varieties mostly came from historical reasons,
combined the the influence of unix mentality “Why Change when it ain't
broken”.
Note here, that keystroke combination and sequence, is not the same
and cannot be mapped to character's input/representation in a
character set such as ASCII. For example, the F1 key in vast majority
of keyboards, isn't a character. So, this means, when you have a
editor with a language such as emacs, that allows users to define
arbitrary key stroke sequences, you necessarily have to come up with a
system to represent keystrokes. So, this complexity is a intrinsic
complexity.
(Side note: A easy way to understand what's intrinsic vs extraneous
complexity is to think: “My god, why is math so complex? God must have
fucked up in its design.”. The gist is that, certain things, are
inherently complex by nature, while others, are extraneous complexity
that are artificially created by lousy design or evolution. As a
concrete example in computing, languages like Lisp, is in general very
well designed. Due to its simplity and almost no artificial
complexity, programers are immediately exposed to many of the
intrinsic complexity of computing. While languages like C and its
litters such as C++, Java, C#, Perl etc created by the unix
motherfuckers, are filled to the brim with artificial complexity due
to tremendous laziness, ignorance, and lies. )
For various ways to represent keyboard shortcuts, see
http://xahlee.org/emacs/keyboard_shortcuts.html
For the unix mentality “Why Change when it ain't broken”, see
http://xahlee.org/UnixResource_dir/writ/aint_broken.html
We, as software creators, must not have unix's “why change when it
ain't broken” attitude. Emacs itself, although far more well thought
out than majority of software, nevertheless aquired many baggages in
its 30 or so years of old age. I would recommend that we start a
effort to eliminate some of these outdated baggages. Please see:
“The Modernization of Emacs”
http://xahlee.org/emacs/modernization.html
Xah
xah@xahlee.org
∑ http://xahlee.org/
On May 29, 5:58 am, Will <schimpan...@gmx.de> wrote:
> Hi,
>
> how can I find the an overview on how to enter meta-characters
> (e.g. esc, return, linefeed, tab, ...)
> a) in a regular buffer
> b) in the minibuffer when using standard search/replace-functions
> c) in the minibuffer when using search/replace-functions using regular
> expressions
> d) in the .emacs file when defining keybindings
>
> As far as I can see in all those situations entering meta-characters is
> addressed in a different way which I find confusing, e.g.:
> a) <key> _or_ C-q <key>
> b) C-q C-[, C-q C-m, C-q C-j, C-q C-i
> c) \e, \r, \n, \t
> d) (define-key [(meta c) (control c) (tab c)] "This is confusing!")
>
> Furthermore, they are displayed in a different way,e.g.
> - actual, visible layout
> - ^E, ^M, ^L, ^I
> - Octals
>
> I would be happy about pages summarizing such information.
> Any references available?
>
> Thanks in advance,
>
> Will
next prev parent reply other threads:[~2007-05-29 23:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-29 12:58 Meta-Characters, Special Characters Will
2007-05-29 14:12 ` weber
2007-05-29 23:29 ` xah [this message]
2007-05-30 1:44 ` Joshua Cranmer
2007-05-30 4:42 ` Gernot Hassenpflug
2007-06-02 3:18 ` Miles Bader
2007-06-02 6:18 ` Gernot Hassenpflug
2007-06-02 7:45 ` David Kastrup
2007-06-02 15:39 ` Gernot Hassenpflug
2007-06-02 7:23 ` Eli Zaretskii
[not found] ` <mailman.1490.1180769072.32220.help-gnu-emacs@gnu.org>
2007-06-02 15:41 ` Gernot Hassenpflug
2007-05-31 1:20 ` xah
2007-05-31 9:25 ` Ingo Menger
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1180481373.651591.253210@i38g2000prf.googlegroups.com \
--to=xah@xahlee.org \
--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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).