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: Tue, 08 Feb 2022 17:05:53 +0000 Message-ID: References: <8735kvtdvh.fsf@ericabrahamsen.net> 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="32898"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Feb 08 20:10:49 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 1nHVt3-0008S7-5i for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 08 Feb 2022 20:10:49 +0100 Original-Received: from localhost ([::1]:40114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHVsz-0007TT-AD for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 08 Feb 2022 14:10:45 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:45898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHTwG-0007PR-4i for help-gnu-emacs@gnu.org; Tue, 08 Feb 2022 12:06:01 -0500 Original-Received: from mail-40132.protonmail.ch ([185.70.40.132]:20266) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHTwD-0000gd-2o for help-gnu-emacs@gnu.org; Tue, 08 Feb 2022 12:05:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1644339954; bh=69s3i12lkw+0VxIADDoXdEasZPKRwiBJqgJiB5qyR30=; h=Date:To:From:Cc:Reply-To:Subject:Message-ID:In-Reply-To: References:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID; b=mCXrpsipchPeEK9vrQ6/OqoYG0TFmFEDPzvjF4z/3/FoVGH245k/ZZNooRzfZnmLO Zuc5Nm8lI5GP81CAbKKeajVTlBS2T1tYkRnqXGRjFp8fO5sVl6T6ozMS326duAyOK3 V+QQex1h2YkHFBZASGwvc8G/9qdEJXi0ZLjAxB5nE0Q32/vUXzo7XG6uYTQ/fiRqH3 bQhrHq7pCnYPVTdTENRLvECoQQQXxkwi0dhvuc5rnLT8EvoogKf0oGlf2/HEqKPHr7 GOtuzqL1vRCXaRaXaHCL1e7YaXV6ahEU72aQWqiUWxVAkvoNASus1CrIbU0vtigeef 88Gb2HsJQX+NQ== In-Reply-To: Received-SPF: pass client-ip=185.70.40.132; envelope-from=goncholden@protonmail.com; helo=mail-40132.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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-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:135843 Archived-At: Sent with ProtonMail Secure Email. ------- Original Message ------- On Tuesday, February 8th, 2022 at 1:27 PM, Stefan Monnier via Users list fo= r the GNU Emacs text editor wrote: > Is there a way that I can remember the :weight used initially, > > "(set-face-attribute 'default nil :height 160 :weight 'ultra-bold)" > > so I can set comments to ultra-bold again when the minor-mode is disabled= . Rather than `set-face-attribute` you want to go through Customize's face settings. E.g. you can get the above behavior using a "Custom theme", which you can then enable&disable at will. Custom themes are conceptually very similar to (global) minor modes. Stefan I already use modus-themes. How does custom theme work? Have done this way by calling (set-face-attribute 'font-lock-comment-face nil :weight (face-attribute 'default :weight)) Here is the code ;;;###autoload (define-minor-mode rich-minor-mode "Colour Comments." :lighter "rich" ; indicator in mode-line (font-lock-remove-keywords nil rich-font-lock) (set-face-attribute 'font-lock-comment-face nil :weight (face-attribute 'default :weight)) (when rich-minor-mode ; evaluates true when mode enabled (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)) )) )