From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Dan Hitt Newsgroups: gmane.emacs.help Subject: Re: extending a mode Date: Sat, 28 Oct 2017 20:35:23 -0700 Message-ID: References: <1509241395.11482.8.camel@qlfiles.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1509248162 15737 195.159.176.226 (29 Oct 2017 03:36:02 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 29 Oct 2017 03:36:02 +0000 (UTC) Cc: "help-gnu-emacs@gnu.org" To: Christopher Howard Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Oct 29 04:35:56 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 1e8eO6-0002cX-FJ for geh-help-gnu-emacs@m.gmane.org; Sun, 29 Oct 2017 04:35:50 +0100 Original-Received: from localhost ([::1]:34680 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8eOB-0008UW-90 for geh-help-gnu-emacs@m.gmane.org; Sat, 28 Oct 2017 23:35:55 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36254) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8eNi-0008UQ-MK for help-gnu-emacs@gnu.org; Sat, 28 Oct 2017 23:35:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e8eNh-0004Ds-23 for help-gnu-emacs@gnu.org; Sat, 28 Oct 2017 23:35:26 -0400 Original-Received: from mail-oi0-x22e.google.com ([2607:f8b0:4003:c06::22e]:47668) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e8eNg-0004DW-St for help-gnu-emacs@gnu.org; Sat, 28 Oct 2017 23:35:24 -0400 Original-Received: by mail-oi0-x22e.google.com with SMTP id h200so16456625oib.4 for ; Sat, 28 Oct 2017 20:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=MMzc9BYu0Ep3VQxW+kItXolaAjb7j/7aEbX3O276jpQ=; b=co4n8VOiDJm9vqWgq4i7fHzgVpwog0xDLr8u7Ib3VARh+L+NAnfOnmcO0DjMll57qi ky+lr/US2tIat2hFLig7tgy+L/EwvH02hcE/aMoQlo9ZpA2tjDw+KeFnILQio85mxo32 UlwP6/SSnst/ur25+hqHMMS6Vq9R0rHSeIJS2tIn3PDj6fgiiBHlUXgQDDJJNL6jIlEt gv8+WKsVvm83hb7th53+xgtJZydXsIE55OPlorJ9VLiRs67yz7JSItebrx82WeEzk09I NbPFEyzva7ipVo+yZKYfXRl0zzuY5tij1P+XT/IblTPW9EaWx8YTFwOplaq6l512dAYA F1Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=MMzc9BYu0Ep3VQxW+kItXolaAjb7j/7aEbX3O276jpQ=; b=f7P+JZE1zlBaaeQ+RcgVUucmGNpkW6hsyRAGlqSg+g63rSN8RM2Mfbgyg1tuJGsIn9 L4L7kPF7y6QhROPXJ5U68uJZ5gtpgeOAD4DLSy2TeDmio6hjvLzDBDsj5arqOyf4Adwr veSkgGSk1Cv6mjaLEN8Gfj0KXB2emgTFdDbMVVk7ekVhLpKadpx8cGhQgKJkcKgPYbKX wsw0V6HjlL0IMn8QeA3fUoCh8+3HwlNPrSujopPvmE3lyJtiA7X3QNIUTLJBWyKlzc70 c+26Ztm9YsnSRuRSmT0Idt99YDXpUtdWOxNhXRWFnkGBbMkJqRuYOAzi8BGkxTDFNia5 RIWg== X-Gm-Message-State: AMCzsaWaY42cYxuV11ZRVTCEPQAPfY3M4gESvRgqd8/Pru7IjSl3u+Sr 49+fA2W2GXXq65UHr5YoYnG4DARvXc6P5+NvD7o= X-Google-Smtp-Source: ABhQp+QI1WDAuM0fVGN5YfvPTxjkcoujwHdrW6A6iXI6DytY8nW6laah7NgmZpHmcpFndeug6hl742oOKz/fres47no= X-Received: by 10.202.7.69 with SMTP id 66mr2882745oih.404.1509248123597; Sat, 28 Oct 2017 20:35:23 -0700 (PDT) Original-Received: by 10.74.162.36 with HTTP; Sat, 28 Oct 2017 20:35:23 -0700 (PDT) In-Reply-To: <1509241395.11482.8.camel@qlfiles.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22e 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:114689 Archived-At: On Sat, Oct 28, 2017 at 6:43 PM, Christopher Howard wrote: > Hi, I wrote a simple command that I use when in Org mode, and probably > will write a few more in the course of time. I'm not sure if anybody > else besides me would ever use them. However, I want emacs to load > those commands when it enters Org mode. What is the simplest and/or > best way to do this? One trick I learned was that I could (add-hook) > and 'org-mode-hook with a defun in it; however, this causes the command > to be available under other modes as well. > > -- > https://answersingenesis.org/ Hi Christopher, As soon as the defun is executed, i think that will make the function available everywhere (dynamic scope vs. lexical scope). So i think that much is expected. 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. But maybe i'm missing your point? If you post the add-hook think you've done, i think somebody around here will figure it out though. dan