* Docstring for define-key
@ 2003-02-19 16:31 Kai Großjohann
2003-02-19 22:18 ` Kevin Rodgers
2003-02-20 18:21 ` Richard Stallman
0 siblings, 2 replies; 12+ messages in thread
From: Kai Großjohann @ 2003-02-19 16:31 UTC (permalink / raw)
The docstring for define-key says:
If KEYMAP is a sparse keymap, the pair binding KEY to DEF is added at
the front of KEYMAP.
When reading this, one could think that executing the same define-key
statement multiple times makes the KEYMAP grow. However, this is not
the case. Glancing at the code, I see that it seems to alter the old
binding, if one is already present. So one possibility to change it
is like this:
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.
The wording is not very good, I think.
Suggestions? Opinions?
Kudos to David Kastrup for bringing this up.
--
A turnip curses Elvis
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Docstring for define-key
2003-02-19 16:31 Docstring for define-key Kai Großjohann
@ 2003-02-19 22:18 ` Kevin Rodgers
2003-02-20 18:21 ` Richard Stallman
1 sibling, 0 replies; 12+ messages in thread
From: Kevin Rodgers @ 2003-02-19 22:18 UTC (permalink / raw)
Kai Großjohann wrote:
> When reading this, one could think that executing the same define-key
> statement multiple times makes the KEYMAP grow. However, this is not
> the case. Glancing at the code, I see that it seems to alter the old
> binding, if one is already present. So one possibility to change it
> is like this:
>
> 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.
>
> The wording is not very good, I think.
I think it's fine. My only suggestion is to replace "altered" with "modified"
or "destructively modified".
--
<a href="mailto:<kevin.rodgers@ihs.com>">Kevin Rodgers</a>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Docstring for define-key
2003-02-19 16:31 Docstring for define-key Kai Großjohann
2003-02-19 22:18 ` Kevin Rodgers
@ 2003-02-20 18:21 ` Richard Stallman
2003-02-20 19:58 ` Kai Großjohann
1 sibling, 1 reply; 12+ messages in thread
From: Richard Stallman @ 2003-02-20 18:21 UTC (permalink / raw)
Cc: emacs-devel
So one possibility to change it
is like this:
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.
The wording is not very good, I think.
It looks good.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Docstring for define-key
2003-02-20 18:21 ` Richard Stallman
@ 2003-02-20 19:58 ` Kai Großjohann
2003-02-21 7:39 ` Juanma Barranquero
0 siblings, 1 reply; 12+ messages in thread
From: Kai Großjohann @ 2003-02-20 19:58 UTC (permalink / raw)
Richard Stallman <rms@gnu.org> writes:
> It looks good.
I changed it accordingly.
--
A preposition is not a good thing to end a sentence with.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Docstring for define-key
2003-02-20 19:58 ` Kai Großjohann
@ 2003-02-21 7:39 ` Juanma Barranquero
2003-02-21 10:53 ` Kim F. Storm
0 siblings, 1 reply; 12+ messages in thread
From: Juanma Barranquero @ 2003-02-21 7:39 UTC (permalink / raw)
Cc: emacs-devel
On Thu, 20 Feb 2003 20:58:19 +0100, kai.grossjohann@uni-duisburg.de (Kai Großjohann) wrote:
> I changed it accordingly.
On the matter of define-key's docstring, the beginning:
"Args KEYMAP, KEY, DEF. Define key sequence KEY, in KEYMAP, as DEF.
KEYMAP is a keymap.
[...]"
is a bit redundant, isn't? What's wrong with:
"Define key sequence KEY, in keymap KEYMAP, as DEF.
[...]"
/L/e/k/t/u
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Docstring for define-key
2003-02-21 10:53 ` Kim F. Storm
@ 2003-02-21 10:34 ` Juanma Barranquero
2003-02-22 17:53 ` Richard Stallman
2003-02-21 14:36 ` Stefan Monnier
2003-02-21 16:38 ` Kai Großjohann
2 siblings, 1 reply; 12+ messages in thread
From: Juanma Barranquero @ 2003-02-21 10:34 UTC (permalink / raw)
Cc: emacs-devel
On 21 Feb 2003 11:53:41 +0100, storm@cua.dk (Kim F. Storm) wrote:
> The convention is that the first line of the doc string should mention
> the (non-optional) arguments in the actual sequence.
I didn't know that (although now that I know it, it's very logical :)
Thanks.
> But another wording could be used to fulfill the convention:
>
> Define, in KEYMAP, key sequence KEY as DEF.
And it would look less ugly.
/L/e/k/t/u
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Docstring for define-key
2003-02-21 7:39 ` Juanma Barranquero
@ 2003-02-21 10:53 ` Kim F. Storm
2003-02-21 10:34 ` Juanma Barranquero
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Kim F. Storm @ 2003-02-21 10:53 UTC (permalink / raw)
Cc: emacs-devel
Juanma Barranquero <lektu@terra.es> writes:
> On Thu, 20 Feb 2003 20:58:19 +0100, kai.grossjohann@uni-duisburg.de (Kai Großjohann) wrote:
>
> > I changed it accordingly.
>
> On the matter of define-key's docstring, the beginning:
>
> "Args KEYMAP, KEY, DEF. Define key sequence KEY, in KEYMAP, as DEF.
> KEYMAP is a keymap.
>
> [...]"
>
> is a bit redundant, isn't? What's wrong with:
>
> "Define key sequence KEY, in keymap KEYMAP, as DEF.
The convention is that the first line of the doc string should mention
the (non-optional) arguments in the actual sequence.
Since define-key args are KEYMAP KEY DEF, it's written like that.
However, if I enter C-h f define-key RET, the output looks like this:
'--------------------
|define-key is a built-in function.
|(define-key KEYMAP KEY DEF)
|
|Args KEYMAP, KEY, DEF. Define key sequence KEY, in KEYMAP, as DEF.
|KEYMAP is a keymap.
|
|KEY is a string or a vector of symbols and characters meaning a
|...
`-------------------
i.e. in that context, the arglist is printed right above the first line,
so it is indeed superfluous -- even if the arguments are mentioned in
the wrong order.
But another wording could be used to fulfill the convention:
Define, in KEYMAP, key sequence KEY as DEF.
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Docstring for define-key
2003-02-21 10:53 ` Kim F. Storm
2003-02-21 10:34 ` Juanma Barranquero
@ 2003-02-21 14:36 ` Stefan Monnier
2003-02-21 16:38 ` Kai Großjohann
2 siblings, 0 replies; 12+ messages in thread
From: Stefan Monnier @ 2003-02-21 14:36 UTC (permalink / raw)
Cc: emacs-devel
> Juanma Barranquero <lektu@terra.es> writes:
>
> > On Thu, 20 Feb 2003 20:58:19 +0100, kai.grossjohann@uni-duisburg.de (Kai Großjohann) wrote:
> >
> > > I changed it accordingly.
> >
> > On the matter of define-key's docstring, the beginning:
> >
> > "Args KEYMAP, KEY, DEF. Define key sequence KEY, in KEYMAP, as DEF.
> > KEYMAP is a keymap.
> >
> > [...]"
> >
> > is a bit redundant, isn't? What's wrong with:
> >
> > "Define key sequence KEY, in keymap KEYMAP, as DEF.
>
> The convention is that the first line of the doc string should mention
> the (non-optional) arguments in the actual sequence.
I doubt that was the reason. More likely the redundant text was
put there before `C-h f' started to automatically add the
(define-key KEYMAP KEY DEF) usage.
I don't think it's important at all whether arguments are listed in the
"proper" order or not. It's much more important that the text be
clear, concise, precise, simple.
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Docstring for define-key
2003-02-21 10:53 ` Kim F. Storm
2003-02-21 10:34 ` Juanma Barranquero
2003-02-21 14:36 ` Stefan Monnier
@ 2003-02-21 16:38 ` Kai Großjohann
2 siblings, 0 replies; 12+ messages in thread
From: Kai Großjohann @ 2003-02-21 16:38 UTC (permalink / raw)
storm@cua.dk (Kim F. Storm) writes:
> But another wording could be used to fulfill the convention:
>
> Define, in KEYMAP, key sequence KEY as DEF.
Right. Done.
Now the second line looks really strange: KEYMAP is a keymap. I
would never have guessed...
--
A preposition is not a good thing to end a sentence with.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Docstring for define-key
2003-02-21 10:34 ` Juanma Barranquero
@ 2003-02-22 17:53 ` Richard Stallman
2003-02-22 20:40 ` Stefan Monnier
0 siblings, 1 reply; 12+ messages in thread
From: Richard Stallman @ 2003-02-22 17:53 UTC (permalink / raw)
Cc: storm
But another wording could be used to fulfill the convention:
Define, in KEYMAP, key sequence KEY as DEF.
I think these words would be clearer:
But another wording could be used to fulfill the convention:
Define, in keymap KEYMAP, key sequence KEY with definition DEF.
It is a good practice to say explicitly what kind of value each arg
has even if its name states the type, because the name does
not always state the type.
> The convention is that the first line of the doc string should mention
> the (non-optional) arguments in the actual sequence.
I doubt that was the reason. More likely the redundant text was
put there before `C-h f' started to automatically add the
(define-key KEYMAP KEY DEF) usage.
I would expect it was a combination of both reasons.
I will add this to the Documentation Tips node in the Lisp ref manual.
@item
The first line should mention all the important arguments of the
function, and should mention them in the order that they are written
in a function call. If the function has many arguments, then it is
not feasible to mention them all in the first line; then the first
line should mention the first few arguments, including the most
important arguments.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Docstring for define-key
2003-02-22 17:53 ` Richard Stallman
@ 2003-02-22 20:40 ` Stefan Monnier
2003-02-24 16:37 ` Richard Stallman
0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2003-02-22 20:40 UTC (permalink / raw)
Cc: monnier+gnu/emacs
> The first line should mention all the important arguments of the
> function, and should mention them in the order that they are written
> in a function call.
Why "in the order" ?
What's the advantage ?
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Docstring for define-key
2003-02-22 20:40 ` Stefan Monnier
@ 2003-02-24 16:37 ` Richard Stallman
0 siblings, 0 replies; 12+ messages in thread
From: Richard Stallman @ 2003-02-24 16:37 UTC (permalink / raw)
Cc: monnier+gnu/emacs
> The first line should mention all the important arguments of the
> function, and should mention them in the order that they are written
> in a function call.
Why "in the order" ?
To ease the work of the programmer reading it.
To have to reorder the args for the code is extra work
and a source of mistakes.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2003-02-24 16:37 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-19 16:31 Docstring for define-key Kai Großjohann
2003-02-19 22:18 ` Kevin Rodgers
2003-02-20 18:21 ` Richard Stallman
2003-02-20 19:58 ` Kai Großjohann
2003-02-21 7:39 ` Juanma Barranquero
2003-02-21 10:53 ` Kim F. Storm
2003-02-21 10:34 ` Juanma Barranquero
2003-02-22 17:53 ` Richard Stallman
2003-02-22 20:40 ` Stefan Monnier
2003-02-24 16:37 ` Richard Stallman
2003-02-21 14:36 ` Stefan Monnier
2003-02-21 16:38 ` Kai Großjohann
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.