all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lars Magne Ingebrigtsen <larsi@gnus.org>
To: Tom <adatgyujto@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Ordering of command completions
Date: Sun, 07 Dec 2014 17:28:12 +0100	[thread overview]
Message-ID: <m3sigrh1b7.fsf@stories.gnus.org> (raw)
In-Reply-To: <loom.20141207T171040-414@post.gmane.org> (Tom's message of "Sun,  7 Dec 2014 16:14:37 +0000 (UTC)")

Tom <adatgyujto@gmail.com> writes:

> Just a quick thought: various modes have lots of keybindings and
> often I use M-x to invoke commands of unfamiliar or rarely used
> modes, because I don't always know the relevant keybindings. Of
> course, I can use the prefix of the mode when completing, but I
> may not know it and it may not be obvious depending on the
> mode. It occured to me that M-x, when showing completions, could
> list command matches from the current major mode first, then from
> the minor modes and then the rest of the commands.

By looking at the commands bound in the active keymaps?  Yes, that would
help.

We discussed the opposite problem a while ago -- excluding commands that
only make sense in a specific mode from turning up when doing command
completion.  For instance, if you're in the *scratch* buffer, you never
want the `message-send-and-exit' command.

During the last discussion, we touched on introducing a new form that
would explicitly say what mode a commands belongs to.  (Some commands
are applicable generally; most are related to a specific mode.)  So
something like

(defun message-send-and-exit ()
  "Doc string."
  (command message-mode "P")
  ...)

where `command' is just like `interactive', only that it takes a mode
name (or a list of mode names) that says "where it belongs".

The main problem with that approach is that it wouldn't really work for
out-of-tree packages, since introducing something like that requires
Emacs Lisp engine level changes, I think.

But if we had this mechanism, then `M-x m<TAB>' would only complete to
things that are potentially useful in the current buffer (or globally),
which would be very nice.

Other, less intrusive approaches (that is, that could be used out of
tree by including legacy macros) would be

(defcommand message-send-and-exit ()
  "Doc string."
  (command message-mode "P")
  ...)

where out-of-tree `defcommand' would be a macro that just transforms
`command' into `interactive'.

Or even more ugly, but even less intrusive for out-of-tree use, by using
a special comment cookie that would just the appropriate modes:

;;;##!message-mode
(defun message-send-and-exit ()
  "Doc string."
  (interactive "P")
  ...)

And probably other approaches...

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



  reply	other threads:[~2014-12-07 16:28 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-07 16:14 Ordering of command completions Tom
2014-12-07 16:28 ` Lars Magne Ingebrigtsen [this message]
2014-12-07 17:36   ` Andreas Schwab
2014-12-07 17:42     ` Lars Magne Ingebrigtsen
2014-12-07 21:20       ` Lars Magne Ingebrigtsen
2014-12-07 21:33         ` Lars Magne Ingebrigtsen
2014-12-07 21:47           ` Lars Magne Ingebrigtsen
2014-12-07 22:00             ` Autoload cookies (was: Ordering of command completions) Lars Magne Ingebrigtsen
2014-12-07 22:03               ` Autoload cookies Daniel Colascione
2014-12-07 22:08                 ` Lars Magne Ingebrigtsen
2014-12-07 22:06               ` Andreas Schwab
2014-12-08  0:14               ` Autoload cookies (was: Ordering of command completions) Artur Malabarba
2014-12-07 22:05             ` Ordering of command completions Óscar Fuentes
2014-12-07 22:13               ` Lars Magne Ingebrigtsen
2014-12-08  0:53                 ` Artur Malabarba
2014-12-08  0:56                   ` Artur Malabarba
2014-12-07 18:33   ` Óscar Fuentes
2014-12-07 18:42     ` Drew Adams
2014-12-07 19:37       ` Óscar Fuentes
2014-12-07 20:10         ` Drew Adams
2014-12-07 20:24           ` Óscar Fuentes
2014-12-07 20:42             ` Drew Adams
2014-12-07 21:06               ` Óscar Fuentes
2014-12-07 21:26                 ` Drew Adams
2014-12-07 18:45     ` Lars Magne Ingebrigtsen
2014-12-07 18:59       ` Óscar Fuentes
2014-12-07 20:34         ` Lars Magne Ingebrigtsen
2014-12-07 20:47           ` Drew Adams
2014-12-07 21:20   ` Stefan Monnier
2014-12-07 21:25     ` Lars Magne Ingebrigtsen
2014-12-08  9:51   ` define "out-of-tree"? Stephen Leake
2014-12-08 18:04     ` Lars Magne Ingebrigtsen
2014-12-09 11:00       ` Richard Stallman
2014-12-09 20:00     ` Karl Fogel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3sigrh1b7.fsf@stories.gnus.org \
    --to=larsi@gnus.org \
    --cc=adatgyujto@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.