From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: goncholden Newsgroups: gmane.emacs.help Subject: Re: Adding functionality to a minor mode Date: Sat, 05 Feb 2022 18:50:52 +0000 Message-ID: References: Reply-To: goncholden Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24876"; mail-complaints-to="usenet@ciao.gmane.io" Cc: goncholden via Users list for the GNU Emacs text editor To: goncholden Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 05 20:01:14 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nGQJ7-0006JQ-St for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 05 Feb 2022 20:01:13 +0100 Original-Received: from localhost ([::1]:34842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGQJ6-00056j-Ko for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 05 Feb 2022 14:01:12 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:60098) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGQ9C-0002mG-86 for help-gnu-emacs@gnu.org; Sat, 05 Feb 2022 13:51:02 -0500 Original-Received: from mail-4319.protonmail.ch ([185.70.43.19]:62345) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGQ9A-0007nq-2Z for help-gnu-emacs@gnu.org; Sat, 05 Feb 2022 13:50:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail2; t=1644087053; bh=DD6tFk2B1alycPI73sKHXtHSdqlFnVXAvsrnVZ5gao4=; h=Date:To:From:Cc:Reply-To:Subject:Message-ID:In-Reply-To: References:From:To:Cc; b=Tt3ehsZw5HfbI2B2aA5A57fDLGKU0ewuyWhEz+XUTdYejvminepcl+rPdltjQp0w/ Cj28EgYaNsChPlvPBBT8HR9atOfoJBGkwsD3FtaX+1ldeA7MdqVMhhMp41DiLWzYUC ZQhvTvQ5vh7aNO5a3C34ZRaBVe6agpzsCeRiJ9KhmfU2deoPmBgnnxEyJkrIQLnPtx UKYuQh7RYUwNkA+67lMHT/6IbVrOIfuzu7oYE/rpOVw0QcZBFxkdrP2jLsb8LOGPhZ PSiG2F/NCjADg4FxjMDZuSZWozyXK8L++c6hOpFHXIqa+J43GaVcC9Jps81LkWBL0k yHcYXgX68wfqw== In-Reply-To: Received-SPF: pass client-ip=185.70.43.19; envelope-from=goncholden@protonmail.com; helo=mail-4319.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, TO_EQ_FM_DIRECT_MX=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:135778 Archived-At: ------- Original Message ------- On Saturday, February 5th, 2022 at 10:00 AM, goncholden via Users list for = the GNU Emacs text editor wrote: > I have made a minor-mode with some defvar and defun. Have added some func= tionality > > for comments, and put everything in the following function definition. > > (defun rich-annotation-tools () > "Aggregates annotation tools for comments." > (rich-annotation-font-weight) > (rich-annotation-low-contrast) > (rich-annotation-keytrigger)) > > I would expect to add "(rich-annotation-tools)" in define-minor-mode. Wou= ld I introduce it > within the "(when rich-minor-mode" part? > > ;;;###autoload > (define-minor-mode rich-minor-mode > "This is the description." > :lighter "rich" ; indicator in mode-line > (font-lock-remove-keywords nil rich-font-lock) > > (when rich-minor-mode > (font-lock-add-keywords nil rich-font-lock 'append) > (set (make-local-variable 'jit-lock-contextually) t) ) > (rich-annotation-tools) > > (when font-lock-mode > (if (fboundp 'font-lock-flush) > (font-lock-flush) > (with-no-warnings (font-lock-fontify-buffer)) )) ) What are the standard techniques for defining a minor mode (e.g. should onl= y only use "(when rich-minor-mode"), and for enabling, disabling minor-mode functionality.