From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: How do I initialize globalized minor mode only once? Date: Tue, 10 Jul 2012 23:20:12 -0400 Organization: A noiseless patient Spider Message-ID: References: NNTP-Posting-Host: plane.gmane.org X-Trace: dough.gmane.org 1341977115 13184 80.91.229.3 (11 Jul 2012 03:25:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 11 Jul 2012 03:25:15 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jul 11 05:25:15 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SonY9-0003Rq-Ve for geh-help-gnu-emacs@m.gmane.org; Wed, 11 Jul 2012 05:25:14 +0200 Original-Received: from localhost ([::1]:52048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SonY8-0005rE-R1 for geh-help-gnu-emacs@m.gmane.org; Tue, 10 Jul 2012 23:25:12 -0400 Original-Path: usenet.stanford.edu!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 32 Injection-Info: barmar.motzarella.org; posting-host="78fb7125a45724f15e21604c94a7d968"; logging-data="8872"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/nDnDF4n9zFmh7rWu2kFt3" User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Cancel-Lock: sha1:tV2p1uGMyyrW7zFNQMbdRFe3UOs= Original-Xref: usenet.stanford.edu gnu.emacs.help:193389 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:85775 Archived-At: In article , Dmitry Gutov wrote: > Hi all, > > I have written a globalized minor mode which has a relatively costly > initialization (external process call), which I need to do when the mode > is enabled. > > But the turn-on function is getting called twice for each new opened > buffer, once in default major mode, and once in the final major mode. > > What's the best way to turn on the minor mode only once? > Currently I'm comparing major-mode value to the default value, but > that's probably not the best solution, since the minor mode in question > can apply to some fundamental-mode (or other default mode) buffers, too. Why not just set a variable saying whether you've done the initialization: (defvar *my-mode-initialized* nil) ... (if (not *my-mode-initialized*) (progn ... (setq *my-mode-initialized* t))) -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me ***