unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* "Command Discovery In Emacs "
@ 2021-08-16  5:31 Jean-Christophe Helary
  2021-08-16 11:38 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 16+ messages in thread
From: Jean-Christophe Helary @ 2021-08-16  5:31 UTC (permalink / raw)
  To: Emacs Devel

I just read Sacha's news and found that "Command Discovery In Emacs" article by Lars.

(And I also found the "Welcome, New Emacs Developers", and the debbugs thing is really cool, but that will be for another time  :-)

That command discovery is really nice and I was wondering how to find the proper way to annotate the various functions. How do we know what modes are the functions are to be used in ? Is there an easy way to find out ?

-- 
Jean-Christophe Helary @brandelune
https://mac4translators.blogspot.com
https://sr.ht/~brandelune/omegat-as-a-book/




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

* Re: "Command Discovery In Emacs "
  2021-08-16  5:31 "Command Discovery In Emacs " Jean-Christophe Helary
@ 2021-08-16 11:38 ` Lars Ingebrigtsen
  2021-08-16 12:29   ` Jean-Christophe Helary
  2021-08-16 14:58   ` Stephen Berman
  0 siblings, 2 replies; 16+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-16 11:38 UTC (permalink / raw)
  To: Jean-Christophe Helary; +Cc: Emacs Devel

Jean-Christophe Helary <lists@traduction-libre.org> writes:

> That command discovery is really nice and I was wondering how to find
> the proper way to annotate the various functions. How do we know what
> modes are the functions are to be used in ? Is there an easy way to
> find out ?

See the "Command Modes" section in the Emacs Lisp manual.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



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

* Re: "Command Discovery In Emacs "
  2021-08-16 11:38 ` Lars Ingebrigtsen
@ 2021-08-16 12:29   ` Jean-Christophe Helary
  2021-08-16 12:56     ` Lars Ingebrigtsen
  2021-08-16 14:58   ` Stephen Berman
  1 sibling, 1 reply; 16+ messages in thread
From: Jean-Christophe Helary @ 2021-08-16 12:29 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Emacs Devel



> On Aug 16, 2021, at 20:38, Lars Ingebrigtsen <larsi@gnus.org> wrote:
> 
> Jean-Christophe Helary <lists@traduction-libre.org> writes:
> 
>> That command discovery is really nice and I was wondering how to find
>> the proper way to annotate the various functions. How do we know what
>> modes are the functions are to be used in ? Is there an easy way to
>> find out ?
> 
> See the "Command Modes" section in the Emacs Lisp manual.

It doesn't say whether there is an easy way to find which mode is a given function associated to... :)


-- 
Jean-Christophe Helary @brandelune
https://mac4translators.blogspot.com
https://sr.ht/~brandelune/omegat-as-a-book/




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

* Re: "Command Discovery In Emacs "
  2021-08-16 12:29   ` Jean-Christophe Helary
@ 2021-08-16 12:56     ` Lars Ingebrigtsen
  2021-08-16 13:15       ` Jean-Christophe Helary
  0 siblings, 1 reply; 16+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-16 12:56 UTC (permalink / raw)
  To: Jean-Christophe Helary; +Cc: Emacs Devel

Jean-Christophe Helary <lists@traduction-libre.org> writes:

>> See the "Command Modes" section in the Emacs Lisp manual.
>
> It doesn't say whether there is an easy way to find which mode is a
> given function associated to... :)

There is and there isn't.  :-)  This stuff is about creating a way to
reliably find commands that are meant for a specific mode -- there isn't
one today.

But in practice it's pretty easy.  If you look at a random (special)
mode like tetris.el, it's pretty obvious which commands are for that
mode only (and which ones aren't), which makes tagging up the commands
easy enough.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



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

* Re: "Command Discovery In Emacs "
  2021-08-16 12:56     ` Lars Ingebrigtsen
@ 2021-08-16 13:15       ` Jean-Christophe Helary
  2021-08-16 13:23         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 16+ messages in thread
From: Jean-Christophe Helary @ 2021-08-16 13:15 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Emacs Devel



> On Aug 16, 2021, at 21:56, Lars Ingebrigtsen <larsi@gnus.org> wrote:
> 
> Jean-Christophe Helary <lists@traduction-libre.org> writes:
> 
>>> See the "Command Modes" section in the Emacs Lisp manual.
>> 
>> It doesn't say whether there is an easy way to find which mode is a
>> given function associated to... :)
> 
> There is and there isn't.  :-)  This stuff is about creating a way to
> reliably find commands that are meant for a specific mode -- there isn't
> one today.
> 
> But in practice it's pretty easy.  If you look at a random (special)
> mode like tetris.el, it's pretty obvious which commands are for that
> mode only (and which ones aren't), which makes tagging up the commands
> easy enough.

Ok, that's what I eventually guessed. So, the idea is to check whether a function is interactive and try to guess whether it is limited to a given mode (most probably the mode it is defined in), and if yes tag it ?

 I'll give that a try for a few modes I use. Thank you for this feature! After helpful, which-keys, it really is a nice addition. I'm always looking for such modes/features that help with the discovery process.


-- 
Jean-Christophe Helary @brandelune
https://mac4translators.blogspot.com
https://sr.ht/~brandelune/omegat-as-a-book/




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

* Re: "Command Discovery In Emacs "
  2021-08-16 13:15       ` Jean-Christophe Helary
@ 2021-08-16 13:23         ` Lars Ingebrigtsen
  2021-08-16 13:33           ` Condy Chen
  0 siblings, 1 reply; 16+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-16 13:23 UTC (permalink / raw)
  To: Jean-Christophe Helary; +Cc: Emacs Devel

Jean-Christophe Helary <lists@traduction-libre.org> writes:

> Ok, that's what I eventually guessed. So, the idea is to check whether
> a function is interactive and try to guess whether it is limited to a
> given mode (most probably the mode it is defined in), and if yes tag
> it ?

Yup.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



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

* Re: "Command Discovery In Emacs "
  2021-08-16 13:23         ` Lars Ingebrigtsen
@ 2021-08-16 13:33           ` Condy Chen
  2021-08-16 13:43             ` Lars Ingebrigtsen
  0 siblings, 1 reply; 16+ messages in thread
From: Condy Chen @ 2021-08-16 13:33 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Jean-Christophe Helary, Emacs Devel

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

By defining `foo' with

(defun foo (arg)
  (interactive "p" org-mode)
  (message "foo"))

M-x foo is still available in elisp-mode.

I'm using GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.30, cairo version 1.17.4) of 2021-08-16

On Mon, Aug 16, 2021 at 9:24 PM Lars Ingebrigtsen <larsi@gnus.org> wrote:

> Jean-Christophe Helary <lists@traduction-libre.org> writes:
>
> > Ok, that's what I eventually guessed. So, the idea is to check whether
> > a function is interactive and try to guess whether it is limited to a
> > given mode (most probably the mode it is defined in), and if yes tag
> > it ?
>
> Yup.
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no
>
>

[-- Attachment #2: Type: text/html, Size: 1346 bytes --]

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

* Re: "Command Discovery In Emacs "
  2021-08-16 13:33           ` Condy Chen
@ 2021-08-16 13:43             ` Lars Ingebrigtsen
  2021-08-16 13:46               ` Condy Chen
  0 siblings, 1 reply; 16+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-16 13:43 UTC (permalink / raw)
  To: Condy Chen; +Cc: Jean-Christophe Helary, Emacs Devel

Condy Chen <condy0919@gmail.com> writes:

> By defining `foo' with
>
> (defun foo (arg)
>   (interactive "p" org-mode)
>   (message "foo"))
>
> M-x foo is still available in elisp-mode.

Try

(setq read-extended-command-predicate 'command-completion-default-include-p)


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



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

* Re: "Command Discovery In Emacs "
  2021-08-16 13:43             ` Lars Ingebrigtsen
@ 2021-08-16 13:46               ` Condy Chen
  0 siblings, 0 replies; 16+ messages in thread
From: Condy Chen @ 2021-08-16 13:46 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Jean-Christophe Helary, Emacs Devel

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

It works, thanks.

On Mon, Aug 16, 2021 at 9:44 PM Lars Ingebrigtsen <larsi@gnus.org> wrote:

> Condy Chen <condy0919@gmail.com> writes:
>
> > By defining `foo' with
> >
> > (defun foo (arg)
> >   (interactive "p" org-mode)
> >   (message "foo"))
> >
> > M-x foo is still available in elisp-mode.
>
> Try
>
> (setq read-extended-command-predicate
> 'command-completion-default-include-p)
>
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no
>

[-- Attachment #2: Type: text/html, Size: 1029 bytes --]

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

* Re: "Command Discovery In Emacs "
  2021-08-16 11:38 ` Lars Ingebrigtsen
  2021-08-16 12:29   ` Jean-Christophe Helary
@ 2021-08-16 14:58   ` Stephen Berman
  2021-08-16 15:49     ` Eli Zaretskii
  1 sibling, 1 reply; 16+ messages in thread
From: Stephen Berman @ 2021-08-16 14:58 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Emacs Devel

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

On Mon, 16 Aug 2021 13:38:47 +0200 Lars Ingebrigtsen <larsi@gnus.org> wrote:

> Jean-Christophe Helary <lists@traduction-libre.org> writes:
>
>> That command discovery is really nice and I was wondering how to find
>> the proper way to annotate the various functions. How do we know what
>> modes are the functions are to be used in ? Is there an easy way to
>> find out ?
>
> See the "Command Modes" section in the Emacs Lisp manual.

This section is not listed in the Detailed Node Listing in the top node
of the manual, and it's also not indexed.  I'm not well-versed in
texinfo; is the following patch sufficient?

Steve Berman


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: List and index Command Modes node in Elisp manual --]
[-- Type: text/x-patch, Size: 1075 bytes --]

diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi
index b4a8b733a0..6d45099867 100644
--- a/doc/lispref/commands.texi
+++ b/doc/lispref/commands.texi
@@ -601,6 +601,9 @@ Interactive Examples

 @node Command Modes
 @subsection Specifying Modes For Commands
+@cindex commands, mode-specific
+@cindex commands, specify as mode-specific
+@cindex mode-specific commands

 Many commands in Emacs are general, and not tied to any specific mode.
 For instance, @kbd{M-x kill-region} can be used in pretty much any
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi
index 8b440c7977..337c71c295 100644
--- a/doc/lispref/elisp.texi
+++ b/doc/lispref/elisp.texi
@@ -788,6 +788,7 @@ Top
 * Interactive Codes::       The standard letter-codes for reading arguments
                               in various ways.
 * Interactive Examples::    Examples of how to read interactive arguments.
+* Command Modes::            Specifying that commands are for a specific mode.
 * Generic Commands::        Select among command alternatives.



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

* Re: "Command Discovery In Emacs "
  2021-08-16 14:58   ` Stephen Berman
@ 2021-08-16 15:49     ` Eli Zaretskii
  2021-08-16 16:13       ` Stephen Berman
  0 siblings, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2021-08-16 15:49 UTC (permalink / raw)
  To: Stephen Berman; +Cc: larsi, emacs-devel

> From: Stephen Berman <stephen.berman@gmx.net>
> Date: Mon, 16 Aug 2021 16:58:57 +0200
> Cc: Emacs Devel <emacs-devel@gnu.org>
> 
> > See the "Command Modes" section in the Emacs Lisp manual.
> 
> This section is not listed in the Detailed Node Listing in the top node
> of the manual, and it's also not indexed.  I'm not well-versed in
> texinfo; is the following patch sufficient?

Yes, thanks for catching this omission.  But please align the
description part of the menu item you are adding, so it is in-line
with the others around it.



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

* Re: "Command Discovery In Emacs "
  2021-08-16 15:49     ` Eli Zaretskii
@ 2021-08-16 16:13       ` Stephen Berman
  2021-08-16 16:32         ` Eli Zaretskii
  2021-08-16 20:59         ` Matthias Meulien
  0 siblings, 2 replies; 16+ messages in thread
From: Stephen Berman @ 2021-08-16 16:13 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: larsi, emacs-devel

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

On Mon, 16 Aug 2021 18:49:39 +0300 Eli Zaretskii <eliz@gnu.org> wrote:

>> From: Stephen Berman <stephen.berman@gmx.net>
>> Date: Mon, 16 Aug 2021 16:58:57 +0200
>> Cc: Emacs Devel <emacs-devel@gnu.org>
>>
>> > See the "Command Modes" section in the Emacs Lisp manual.
>>
>> This section is not listed in the Detailed Node Listing in the top node
>> of the manual, and it's also not indexed.  I'm not well-versed in
>> texinfo; is the following patch sufficient?
>
> Yes, thanks for catching this omission.  But please align the
> description part of the menu item you are adding, so it is in-line
> with the others around it.

Hm, in the file elisp.texi it appears to be aligned:


[-- Attachment #2: node-listing.png --]
[-- Type: image/png, Size: 12622 bytes --]

[-- Attachment #3: Type: text/plain, Size: 40 bytes --]


But in the diff it appears not to be:


[-- Attachment #4: node-listing-diff.png --]
[-- Type: image/png, Size: 17609 bytes --]

[-- Attachment #5: Type: text/plain, Size: 70 bytes --]


Is that a bug in Diff mode or just a display artefact?

Steve Berman

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

* Re: "Command Discovery In Emacs "
  2021-08-16 16:13       ` Stephen Berman
@ 2021-08-16 16:32         ` Eli Zaretskii
  2021-08-16 17:17           ` Stephen Berman
  2021-08-16 20:59         ` Matthias Meulien
  1 sibling, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2021-08-16 16:32 UTC (permalink / raw)
  To: Stephen Berman; +Cc: larsi, emacs-devel

> From: Stephen Berman <stephen.berman@gmx.net>
> Cc: larsi@gnus.org,  emacs-devel@gnu.org
> Date: Mon, 16 Aug 2021 18:13:46 +0200
> 
> Is that a bug in Diff mode or just a display artefact?

Never mind, if they are aligned in the file, all's good.

Thanks.



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

* Re: "Command Discovery In Emacs "
  2021-08-16 16:32         ` Eli Zaretskii
@ 2021-08-16 17:17           ` Stephen Berman
  2021-08-16 20:58             ` Stephen Berman
  0 siblings, 1 reply; 16+ messages in thread
From: Stephen Berman @ 2021-08-16 17:17 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: larsi, emacs-devel

On Mon, 16 Aug 2021 19:32:11 +0300 Eli Zaretskii <eliz@gnu.org> wrote:

>> From: Stephen Berman <stephen.berman@gmx.net>
>> Cc: larsi@gnus.org,  emacs-devel@gnu.org
>> Date: Mon, 16 Aug 2021 18:13:46 +0200
>>
>> Is that a bug in Diff mode or just a display artefact?
>
> Never mind, if they are aligned in the file, all's good.

Ok, thanks.  I pushed the changes to master.

Steve Berman



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

* Re: "Command Discovery In Emacs "
  2021-08-16 17:17           ` Stephen Berman
@ 2021-08-16 20:58             ` Stephen Berman
  0 siblings, 0 replies; 16+ messages in thread
From: Stephen Berman @ 2021-08-16 20:58 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: larsi, emacs-devel

On Mon, 16 Aug 2021 19:17:15 +0200 Stephen Berman <stephen.berman@gmx.net> wrote:

> On Mon, 16 Aug 2021 19:32:11 +0300 Eli Zaretskii <eliz@gnu.org> wrote:
>
>>> From: Stephen Berman <stephen.berman@gmx.net>
>>> Cc: larsi@gnus.org,  emacs-devel@gnu.org
>>> Date: Mon, 16 Aug 2021 18:13:46 +0200
>>>
>>> Is that a bug in Diff mode or just a display artefact?
>>
>> Never mind, if they are aligned in the file, all's good.
>
> Ok, thanks.  I pushed the changes to master.

And now I see that menu entry out of alignment :-(.  I don't know how it
could have been aligned right after I changed the file, as documented in
the screenshot I posted, but now, after revisiting that file, it appears
with the same indentation as the diff displayed -- and that's also what
it looks like at
https://git.savannah.gnu.org/cgit/emacs.git/tree/doc/lispref/elisp.texi?id=b21c9b0816e9bb923e00d6e69eed7c4341850dd0,
line 791.  Perhaps I inadvertantly changed the aligment between making
the two screenshots.  Anyway, I realigned again, rebuilt and checked
with -Q, and it looks right, so I pushed the change again.  If I screwed
up again, someone else should fix it.

Steve Berman



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

* Re: "Command Discovery In Emacs "
  2021-08-16 16:13       ` Stephen Berman
  2021-08-16 16:32         ` Eli Zaretskii
@ 2021-08-16 20:59         ` Matthias Meulien
  1 sibling, 0 replies; 16+ messages in thread
From: Matthias Meulien @ 2021-08-16 20:59 UTC (permalink / raw)
  To: emacs-devel

Stephen Berman <stephen.berman@gmx.net> writes:

> On Mon, 16 Aug 2021 18:49:39 +0300 Eli Zaretskii <eliz@gnu.org> wrote:
>
>> Yes, thanks for catching this omission.  But please align the
>> description part of the menu item you are adding, so it is in-line
>> with the others around it.
>
> Hm, in the file elisp.texi it appears to be aligned:
>
>
>
> But in the diff it appears not to be:
>
>
>
> Is that a bug in Diff mode or just a display artefact?

If I remember correctly, it's a bug related to `diff-font-lock-prettify'
being true...
-- 
Matthias



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

end of thread, other threads:[~2021-08-16 20:59 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-16  5:31 "Command Discovery In Emacs " Jean-Christophe Helary
2021-08-16 11:38 ` Lars Ingebrigtsen
2021-08-16 12:29   ` Jean-Christophe Helary
2021-08-16 12:56     ` Lars Ingebrigtsen
2021-08-16 13:15       ` Jean-Christophe Helary
2021-08-16 13:23         ` Lars Ingebrigtsen
2021-08-16 13:33           ` Condy Chen
2021-08-16 13:43             ` Lars Ingebrigtsen
2021-08-16 13:46               ` Condy Chen
2021-08-16 14:58   ` Stephen Berman
2021-08-16 15:49     ` Eli Zaretskii
2021-08-16 16:13       ` Stephen Berman
2021-08-16 16:32         ` Eli Zaretskii
2021-08-16 17:17           ` Stephen Berman
2021-08-16 20:58             ` Stephen Berman
2021-08-16 20:59         ` Matthias Meulien

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