From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.help Subject: RE: extending a mode Date: Sun, 29 Oct 2017 00:00:54 -0700 (PDT) Message-ID: <8dc75cf2-e788-4ed3-99b4-321a7342a546@default> References: <1509241395.11482.8.camel@qlfiles.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1509260526 11912 195.159.176.226 (29 Oct 2017 07:02:06 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 29 Oct 2017 07:02:06 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Dan Hitt , Christopher Howard Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Oct 29 08:01:59 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e8hbV-0001bH-Mj for geh-help-gnu-emacs@m.gmane.org; Sun, 29 Oct 2017 08:01:53 +0100 Original-Received: from localhost ([::1]:35036 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8hbb-0004VL-EB for geh-help-gnu-emacs@m.gmane.org; Sun, 29 Oct 2017 03:01:59 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54234) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8hb9-0004V9-T2 for help-gnu-emacs@gnu.org; Sun, 29 Oct 2017 03:01:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e8hb6-00082W-PZ for help-gnu-emacs@gnu.org; Sun, 29 Oct 2017 03:01:31 -0400 Original-Received: from userp1040.oracle.com ([156.151.31.81]:35295) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e8hb6-00081I-HG for help-gnu-emacs@gnu.org; Sun, 29 Oct 2017 03:01:28 -0400 Original-Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v9T71NuN027146 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Oct 2017 07:01:25 GMT Original-Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v9T71Mfj009548 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Oct 2017 07:01:23 GMT Original-Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v9T71KPI015777; Sun, 29 Oct 2017 07:01:22 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4600.0 (x86)] X-Source-IP: aserv0021.oracle.com [141.146.126.233] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 156.151.31.81 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:114690 Archived-At: > > I wrote a simple command that I use when in Org mode... > > however, this causes the command to be available under > > other modes as well. >=20 > But you should be able to run a piece of code with your add-hook that > will bind the command to some keys, and this binding will only be > available in a particular mode. As Dan said, you can bind the command to a key in the mode's keymap. If the command is appropriate only for the mode then you can also change its code so that if it is ever invoked outside the mode (usually tested using `derived-mode-p') then it does nothing, or it shows a message saying it is only for the mode, or it raises an error saying the same thing.