unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Define-key doc string - binding changes always if it exists
@ 2005-08-10 21:37 Lennart Borgman
  2005-08-11 15:05 ` Kevin Rodgers
  2005-08-12  7:19 ` Stefan Monnier
  0 siblings, 2 replies; 4+ messages in thread
From: Lennart Borgman @ 2005-08-10 21:37 UTC (permalink / raw)


I found the doc string for define-key a bit strange. It kind of suggests 
that if the keymap is not sparse then it is not changed. I suggest the 
following patch:

Index: keymap.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/keymap.c,v
retrieving revision 1.306
diff -u -r1.306 keymap.c
--- keymap.c    7 Aug 2005 12:33:17 -0000    1.306
+++ keymap.c    10 Aug 2005 19:42:37 -0000
@@ -1105,9 +1105,8 @@
     (DEFN should be a valid definition in its own right),
  or a cons (MAP . CHAR), meaning use definition of CHAR in keymap MAP.
 
-If KEYMAP is a sparse keymap with a binding for KEY, the existing
-binding is altered.  If there is no binding for KEY, the new pair
-binding KEY to DEF is added at the front of KEYMAP.  */)
+If KEYMAP is a sparse keymap and there is no binding for KEY, the new
+pair binding KEY to DEF is added at the front of KEYMAP.  */)
      (keymap, key, def)
      Lisp_Object keymap;
      Lisp_Object key;

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

* Re: Define-key doc string - binding changes always if it exists
  2005-08-10 21:37 Define-key doc string - binding changes always if it exists Lennart Borgman
@ 2005-08-11 15:05 ` Kevin Rodgers
  2005-08-11 15:45   ` Lennart Borgman
  2005-08-12  7:19 ` Stefan Monnier
  1 sibling, 1 reply; 4+ messages in thread
From: Kevin Rodgers @ 2005-08-11 15:05 UTC (permalink / raw)


Lennart Borgman wrote:
 > I found the doc string for define-key a bit strange. It kind of suggests
 > that if the keymap is not sparse then it is not changed. I suggest the
 > following patch:

I don't agree.  You've changed:

 > -If KEYMAP is a sparse keymap with a binding for KEY, the existing
 > -binding is altered.  If there is no binding for KEY, the new pair
 > -binding KEY to DEF is added at the front of KEYMAP.  */)

to:

 > +If KEYMAP is a sparse keymap and there is no binding for KEY, the new
 > +pair binding KEY to DEF is added at the front of KEYMAP.  */)

The original does not say anything about full keymaps (because there is
nothing to add), whereas your version doesn't say anything about a KEY
that's already bound in a sparse KEYMAP.

Your version is close to what's in Emacs 21, which was corrected to
distinguish between a new binding and an altered binding:

| If KEYMAP is a sparse keymap, the pair binding KEY to DEF is added at
| the front of KEYMAP.

-- 
Kevin Rodgers

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

* Re: Define-key doc string - binding changes always if it exists
  2005-08-11 15:05 ` Kevin Rodgers
@ 2005-08-11 15:45   ` Lennart Borgman
  0 siblings, 0 replies; 4+ messages in thread
From: Lennart Borgman @ 2005-08-11 15:45 UTC (permalink / raw)
  Cc: emacs-devel

Kevin Rodgers wrote:

> I don't agree.  You've changed:
>
> > -If KEYMAP is a sparse keymap with a binding for KEY, the existing
> > -binding is altered.  If there is no binding for KEY, the new pair
> > -binding KEY to DEF is added at the front of KEYMAP.  */)
>
> to:
>
> > +If KEYMAP is a sparse keymap and there is no binding for KEY, the new
> > +pair binding KEY to DEF is added at the front of KEYMAP.  */)
>
> The original does not say anything about full keymaps (because there is
> nothing to add), whereas your version doesn't say anything about a KEY
> that's already bound in a sparse KEYMAP.

I thought that in the same way there is nothing to add about full 
keymaps there is nothing to add in the case when there is a binding. It 
behaves the same for both full and sparse keymaps.

>
> Your version is close to what's in Emacs 21, which was corrected to
> distinguish between a new binding and an altered binding:
>
> | If KEYMAP is a sparse keymap, the pair binding KEY to DEF is added at
> | the front of KEYMAP.

Yes, but with the important distinction that it is more specific, it 
tries to say clearly that it is just for the case when there is no 
binding. However if people do not find this clear then of course we 
should not change it. Though I personally think it is more clear... ;-)

This is no big issue of course.

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

* Re: Define-key doc string - binding changes always if it exists
  2005-08-10 21:37 Define-key doc string - binding changes always if it exists Lennart Borgman
  2005-08-11 15:05 ` Kevin Rodgers
@ 2005-08-12  7:19 ` Stefan Monnier
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2005-08-12  7:19 UTC (permalink / raw)
  Cc: Emacs Devel

>      (DEFN should be a valid definition in its own right),
>   or a cons (MAP . CHAR), meaning use definition of CHAR in keymap MAP.
>  -If KEYMAP is a sparse keymap with a binding for KEY, the existing
> -binding is altered.  If there is no binding for KEY, the new pair
> -binding KEY to DEF is added at the front of KEYMAP.  */)
> +If KEYMAP is a sparse keymap and there is no binding for KEY, the new
> +pair binding KEY to DEF is added at the front of KEYMAP.  */)

The behavior should be the same with sparse maps as for dense maps,
at least from the function's user point of view, so the docstring shouldn't
need to distinguish.
Instead of the above patch, I'd remove the word "sparse".
Dense maps also use pairs (KEY . DEF) for non-char keys.


        Stefan

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

end of thread, other threads:[~2005-08-12  7:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-10 21:37 Define-key doc string - binding changes always if it exists Lennart Borgman
2005-08-11 15:05 ` Kevin Rodgers
2005-08-11 15:45   ` Lennart Borgman
2005-08-12  7:19 ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

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

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).