emacs-devel
[Top][All Lists]
Advanced

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

Re: Proposal: Bind backspace and delete like DEL in view-mode


From: Kim F. Storm
Subject: Re: Proposal: Bind backspace and delete like DEL in view-mode
Date: 27 Dec 2001 21:57:34 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

Eli Zaretskii <address@hidden> writes:

> On 26 Dec 2001, Kim F. Storm wrote:
> 
> > If I enter C-h k <backspace>, emacs tells me:
> > 
> >         DEL runs the command delete-backward-char
> 
> Would it be better if instead it would tell this:
> 
>   <backspace> is mapped to DEL which runs the command delete-backward-char
>

On first sight, it looks like an improvement, but thinking more about
it, it might actually be more confusing to the novice user!

For the expert user, it is nice to get the extra information, but for
the novice, it now offers two names for the same key...  but it still
doesn't explain how to rebind that key in a safe manner.

 
> > Sure, but how does the novice user that TAB is "\t".
> 
> Key rebinding in .emacs is not novice stuff, IMHO.

Maybe not, but even novices will often need to do it anyway - so if it
can be simplified I don't see why we should neglect to do so.

And binding keys in .emacs is typically one of the first
experiences novice users have with emacs lisp.

>                                                    In interactive
> rebinding, they don't need to know about \t.  For more advanced users,
> the manual explains the \t issue in the node "Init Rebinding".
> 

I think M-x global-set-key is pretty useless in most cases - since it
doesn't store the bindings in .emacs.

> Perhaps we could have a command which will write to .emacs a Lisp
> expression for binding a given key; then users could rebind a key
> interactively and selectively save their bindings without dealing with
> the complications.

I guess global-set-key could be enhanced to do that when run
interactively.

However, I don't think local-set-key will be able to
do that (as there is no easy way to get the *name* of
the variable holding the current mode map - it might
not even exist yet when reading .emacs...

> 
> We could also modify what "C-h c" prints like this:
> 
>   TAB (or "\t") runs the command indent-relative
> 
> or maybe like this:
> 
>   TAB runs the command indent-relative (use "\t" to rebind)
>

Or using the patch I just posted, it doesn't have to mention \t
since [TAB] will be a valid key definition.


 
> > This would allow users to write things like
> > 
> >         (define-key map 'DEL ...)
> >         (define-key map ?\C-a ...)
> 
> I don't see how using 'DEL would solve the problem.

It doesn't.  The suggestion was unrelated to the other issue.  I just
noticed that it would be easy to enhance define-key to accept a single
symbol or integer as argument in addition to a vector or string.
I.e. it would interpret ?A as [?A] and 'DEL as [DEL].

The necessary changes to define-key (and lookup-key) are trivial:

Index: keymap.c
===================================================================
RCS file: /cvs/emacs/src/keymap.c,v
retrieving revision 1.250
diff -u -r1.250 keymap.c
--- keymap.c    20 Dec 2001 18:26:10 -0000      1.250
+++ keymap.c    27 Dec 2001 20:50:03 -0000
@@ -983,7 +983,9 @@
 
   keymap = get_keymap (keymap, 1, 1);
 
-  if (!VECTORP (key) && !STRINGP (key))
+  if (INTEGERP (key) || SYMBOLP (key))
+    key = Fmake_vector (make_number (1), key);
+  else if (!VECTORP (key) && !STRINGP (key))
     key = wrong_type_argument (Qarrayp, key);
 
   length = XFASTINT (Flength (key));
@@ -1077,7 +1081,9 @@
 
   keymap = get_keymap (keymap, 1, 1);
 
-  if (!VECTORP (key) && !STRINGP (key))
+  if (INTEGERP (key) || SYMBOLP (key))
+    key = Fmake_vector (make_number (1), key);
+  else if (!VECTORP (key) && !STRINGP (key))
     key = wrong_type_argument (Qarrayp, key);
 
   length = XFASTINT (Flength (key));




reply via email to

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