From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Engster Newsgroups: gmane.emacs.devel Subject: Re: Per-mode obarray for M-x Date: Sun, 06 Mar 2011 14:39:28 +0100 Message-ID: <878vwsbc6n.fsf@engster.org> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1299418839 4108 80.91.229.12 (6 Mar 2011 13:40:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 6 Mar 2011 13:40:39 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 06 14:40:35 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PwECJ-0006JE-Fk for ged-emacs-devel@m.gmane.org; Sun, 06 Mar 2011 14:40:35 +0100 Original-Received: from localhost ([127.0.0.1]:47956 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PwECJ-0008FI-2L for ged-emacs-devel@m.gmane.org; Sun, 06 Mar 2011 08:40:35 -0500 Original-Received: from [140.186.70.92] (port=55797 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PwECD-0008F0-1G for emacs-devel@gnu.org; Sun, 06 Mar 2011 08:40:31 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PwECB-0003BV-Ph for emacs-devel@gnu.org; Sun, 06 Mar 2011 08:40:28 -0500 Original-Received: from v3-1008.vxen.de ([79.140.41.8]:53349) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PwECB-00036O-JD for emacs-devel@gnu.org; Sun, 06 Mar 2011 08:40:27 -0500 Original-Received: from dslc-082-082-173-246.pools.arcor-ip.net ([82.82.173.246] helo=spaten) by v3-1008.vxen.de with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1PwEC4-0002cw-2m for emacs-devel@gnu.org; Sun, 06 Mar 2011 14:40:20 +0100 In-Reply-To: (Scott Frazer's message of "Sun, 6 Mar 2011 08:04:42 -0500") User-Agent: Gnus/5.110014 (No Gnus v0.14) Emacs/23.2 (gnu/linux) Mail-Followup-To: emacs-devel@gnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-Received-From: 79.140.41.8 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:136812 Archived-At: Scott Frazer writes: > How hard would it be to make a per-mode obarray for M-x? Sort of like > the per-mode keymap and abbrev tables, I'd like to do "M-x command" > and have it act differently depending on the mode; e.g. "M-x html" in > a org-mode buffer would run org-export-as-html, but the 'default' > action in other buffers would be to run, say, htmlize-buffer. This is not exactly what you're looking for, but take a look at the mode-local package which now ships with Emacs. It's in the lisp/cedet directory and lets you define variables and functions dependent on the major-mode. In a nutshell: (define-overloadable-function somefunc (params) "doc-string") (defun somefunc-default (params) "doc-string" ... default behavior ...) (define-mode-local-override somefunc org-mode (params) "doc-string" ... behavior for org-mode ...) -David