unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Using keymap argument of define-minor-mode
@ 2016-04-15 11:57 Philipp Stephani
  2016-04-15 12:36 ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Philipp Stephani @ 2016-04-15 11:57 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

The docstring of `define-minor-mode' says that KEYMAP can be a list of
arguments to `easy-mmode-define-keymap'. However, this doesn't seem to work:

(define-minor-mode test-mode nil
  :keymap '((([?a] . ignore)) :inherit grep-mode-map))

This attempts to call `easy-mmode-define-keymap' with the single
argument ((([97]
. ignore)) :inherit grep-mode-map), so it doesn't interpret the list as
list of arguments. Is the syntax somehow different, or is this a bug?

Thanks,
Philipp


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

* Re: Using keymap argument of define-minor-mode
  2016-04-15 11:57 Using keymap argument of define-minor-mode Philipp Stephani
@ 2016-04-15 12:36 ` Stefan Monnier
  2016-04-15 20:02   ` Philipp Stephani
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2016-04-15 12:36 UTC (permalink / raw)
  To: help-gnu-emacs

> The docstring of `define-minor-mode' says that KEYMAP can be a list of
> arguments to `easy-mmode-define-keymap'. However, this doesn't seem to work:

I recommend you stay away from it.

Just use

    (defvar foo-mode-map
      (let ((map (make-sparse-keymap)))
        <bindings>
        map))

    (define-minor-mode foo-mode
      "blabla"
      <body>)


-- Stefan




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

* Re: Using keymap argument of define-minor-mode
  2016-04-15 12:36 ` Stefan Monnier
@ 2016-04-15 20:02   ` Philipp Stephani
  2016-04-15 21:18     ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Philipp Stephani @ 2016-04-15 20:02 UTC (permalink / raw)
  To: Stefan Monnier, help-gnu-emacs

Stefan Monnier <monnier@iro.umontreal.ca> schrieb am Fr., 15. Apr. 2016 um
14:40 Uhr:

> > The docstring of `define-minor-mode' says that KEYMAP can be a list of
> > arguments to `easy-mmode-define-keymap'. However, this doesn't seem to
> work:
>
> I recommend you stay away from it.
>

Fair enough, but that doesn't really answer the question. Is the docstring
wrong, or the implementation of define-minor-mode, or my example?


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

* Re: Using keymap argument of define-minor-mode
  2016-04-15 20:02   ` Philipp Stephani
@ 2016-04-15 21:18     ` Stefan Monnier
  2016-04-16 13:16       ` Philipp Stephani
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2016-04-15 21:18 UTC (permalink / raw)
  To: Philipp Stephani; +Cc: help-gnu-emacs

> Fair enough, but that doesn't really answer the question. Is the docstring
> wrong, or the implementation of define-minor-mode, or my example?

Good question.  The code passes the list as first (and sole) arg to
easy-mmode-define-keymap, and given the lack of interest to support this
in the future, I guess the code should take precedence over
the docstring.


        Stefan



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

* Re: Using keymap argument of define-minor-mode
  2016-04-15 21:18     ` Stefan Monnier
@ 2016-04-16 13:16       ` Philipp Stephani
  2016-04-18 16:32         ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Philipp Stephani @ 2016-04-16 13:16 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 518 bytes --]

Stefan Monnier <monnier@iro.umontreal.ca> schrieb am Fr., 15. Apr. 2016 um
23:18 Uhr:

> > Fair enough, but that doesn't really answer the question. Is the
> docstring
> > wrong, or the implementation of define-minor-mode, or my example?
>
> Good question.  The code passes the list as first (and sole) arg to
> easy-mmode-define-keymap, and given the lack of interest to support this
> in the future, I guess the code should take precedence over
> the docstring.
>
>
>
OK, I've attached a patch to fix the docstring.

[-- Attachment #2: 0001-Fix-docstring-of-define-minor-mode.patch --]
[-- Type: application/octet-stream, Size: 1632 bytes --]

From e84c7f70b4b9394b06944bea3f8e7eed6a1ce6ba Mon Sep 17 00:00:00 2001
From: Philipp Stephani <phst@google.com>
Date: Sat, 16 Apr 2016 15:13:44 +0200
Subject: [PATCH] =?UTF-8?q?Fix=20docstring=20of=20=E2=80=98define-minor-mo?=
 =?UTF-8?q?de=E2=80=99.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Discussed in
https://lists.gnu.org/archive/html/help-gnu-emacs/2016-04/msg00071.html.

* emacs-lisp/easy-mmode.el (define-minor-mode): Fix docstring so that it
matches the actual implementation.
---
 lisp/emacs-lisp/easy-mmode.el | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index 6a4d835..46d5d0d 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -108,9 +108,10 @@ define-minor-mode
 Optional KEYMAP is the default keymap bound to the mode keymap.
   If non-nil, it should be a variable name (whose value is a keymap),
   or an expression that returns either a keymap or a list of
-  arguments for `easy-mmode-define-keymap'.  If you supply a KEYMAP
-  argument that is not a symbol, this macro defines the variable
-  MODE-map and gives it the value that KEYMAP specifies.
+  (KEY . BINDING) pairs where KEY and BINDING are suitable for
+  `define-key'.  If you supply a KEYMAP argument that is not a
+  symbol, this macro defines the variable MODE-map and gives it
+  the value that KEYMAP specifies.
 
 BODY contains code to execute each time the mode is enabled or disabled.
   It is executed after toggling the mode, and before running MODE-hook.
-- 
2.7.4


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

* Re: Using keymap argument of define-minor-mode
  2016-04-16 13:16       ` Philipp Stephani
@ 2016-04-18 16:32         ` Stefan Monnier
  2016-04-18 16:42           ` Kaushal Modi
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2016-04-18 16:32 UTC (permalink / raw)
  To: Philipp Stephani; +Cc: help-gnu-emacs

Thanks, installed in trunk.


        Stefan


>>>>> "Philipp" == Philipp Stephani <p.stephani2@gmail.com> writes:

> Stefan Monnier <monnier@iro.umontreal.ca> schrieb am Fr., 15. Apr. 2016 um
> 23:18 Uhr:

>> > Fair enough, but that doesn't really answer the question. Is the
>> docstring
>> > wrong, or the implementation of define-minor-mode, or my example?
>> 
>> Good question.  The code passes the list as first (and sole) arg to
>> easy-mmode-define-keymap, and given the lack of interest to support this
>> in the future, I guess the code should take precedence over
>> the docstring.
>> 
>> 
>> 
> OK, I've attached a patch to fix the docstring.
> From e84c7f70b4b9394b06944bea3f8e7eed6a1ce6ba Mon Sep 17 00:00:00 2001
> From: Philipp Stephani <phst@google.com>
> Date: Sat, 16 Apr 2016 15:13:44 +0200
> Subject: [PATCH] =?UTF-8?q?Fix=20docstring=20of=20=E2=80=98define-minor-mo?=
>  =?UTF-8?q?de=E2=80=99.?=
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit

> Discussed in
> https://lists.gnu.org/archive/html/help-gnu-emacs/2016-04/msg00071.html.

> * emacs-lisp/easy-mmode.el (define-minor-mode): Fix docstring so that it
> matches the actual implementation.
> ---
>  lisp/emacs-lisp/easy-mmode.el | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

> diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
> index 6a4d835..46d5d0d 100644
> --- a/lisp/emacs-lisp/easy-mmode.el
> +++ b/lisp/emacs-lisp/easy-mmode.el
> @@ -108,9 +108,10 @@ define-minor-mode
>  Optional KEYMAP is the default keymap bound to the mode keymap.
>    If non-nil, it should be a variable name (whose value is a keymap),
>    or an expression that returns either a keymap or a list of
> -  arguments for `easy-mmode-define-keymap'.  If you supply a KEYMAP
> -  argument that is not a symbol, this macro defines the variable
> -  MODE-map and gives it the value that KEYMAP specifies.
> +  (KEY . BINDING) pairs where KEY and BINDING are suitable for
> +  `define-key'.  If you supply a KEYMAP argument that is not a
> +  symbol, this macro defines the variable MODE-map and gives it
> +  the value that KEYMAP specifies.
 
>  BODY contains code to execute each time the mode is enabled or disabled.
>    It is executed after toggling the mode, and before running MODE-hook.
> -- 
> 2.7.4





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

* Re: Using keymap argument of define-minor-mode
  2016-04-18 16:32         ` Stefan Monnier
@ 2016-04-18 16:42           ` Kaushal Modi
  2016-04-18 18:42             ` John Wiegley
  0 siblings, 1 reply; 9+ messages in thread
From: Kaushal Modi @ 2016-04-18 16:42 UTC (permalink / raw)
  To: Stefan Monnier, Philipp Stephani, John Wiegley; +Cc: help-gnu-emacs

If this is just a docstring change, can it go to emacs-25 branch too?


On Mon, Apr 18, 2016 at 12:34 PM Stefan Monnier <monnier@iro.umontreal.ca>
wrote:

> Thanks, installed in trunk.
>
>
>         Stefan
>
> --

-- 
Kaushal Modi


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

* Re: Using keymap argument of define-minor-mode
  2016-04-18 16:42           ` Kaushal Modi
@ 2016-04-18 18:42             ` John Wiegley
  2016-12-07 12:59               ` Philipp Stephani
  0 siblings, 1 reply; 9+ messages in thread
From: John Wiegley @ 2016-04-18 18:42 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: help-gnu-emacs, Philipp Stephani, Stefan Monnier

>>>>> Kaushal Modi <kaushal.modi@gmail.com> writes:

> If this is just a docstring change, can it go to emacs-25 branch too?

docstring fixes should be able to go into emacs-25.

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2



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

* Re: Using keymap argument of define-minor-mode
  2016-04-18 18:42             ` John Wiegley
@ 2016-12-07 12:59               ` Philipp Stephani
  0 siblings, 0 replies; 9+ messages in thread
From: Philipp Stephani @ 2016-12-07 12:59 UTC (permalink / raw)
  To: Kaushal Modi, Stefan Monnier, help-gnu-emacs

John Wiegley <jwiegley@gmail.com> schrieb am Mo., 18. Apr. 2016 um
20:42 Uhr:

> >>>>> Kaushal Modi <kaushal.modi@gmail.com> writes:
>
> > If this is just a docstring change, can it go to emacs-25 branch too?
>
> docstring fixes should be able to go into emacs-25.
>
>
Thanks, I've cherry-picked the commit to emacs-25.


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

end of thread, other threads:[~2016-12-07 12:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-15 11:57 Using keymap argument of define-minor-mode Philipp Stephani
2016-04-15 12:36 ` Stefan Monnier
2016-04-15 20:02   ` Philipp Stephani
2016-04-15 21:18     ` Stefan Monnier
2016-04-16 13:16       ` Philipp Stephani
2016-04-18 16:32         ` Stefan Monnier
2016-04-18 16:42           ` Kaushal Modi
2016-04-18 18:42             ` John Wiegley
2016-12-07 12:59               ` Philipp Stephani

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