From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Heime Newsgroups: gmane.emacs.help Subject: Re: Functions which are mode dependent Date: Sat, 24 Aug 2024 21:08:22 +0000 Message-ID: References: <3RfPnnmfz0Qgr0JGJbNKnydaMu1QfnGGBk7xX7qxkXSkzXBNt8snc9Ye1n6AvZtOln0VoPDXmjnYc_X5lGkPVxnvPPlBbjvnuKMQs4cki18=@protonmail.com> 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="33874"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Yuri Khan , Heime via Users list for the GNU Emacs text editor To: Heime Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 24 23:09:09 2024 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 1shy0S-0008gi-L9 for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 24 Aug 2024 23:09:08 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1shxzy-0000bC-BQ; Sat, 24 Aug 2024 17:08:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1shxzv-0000am-Iz for help-gnu-emacs@gnu.org; Sat, 24 Aug 2024 17:08:35 -0400 Original-Received: from mail-43167.protonmail.ch ([185.70.43.167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1shxzt-00035M-Hf for help-gnu-emacs@gnu.org; Sat, 24 Aug 2024 17:08:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1724533704; x=1724792904; bh=8eIkcdnonExB//METRxDIxWjwkCGUi8pQwLOf245l0w=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=gDJVhomdqSVh6eRcIdNfSi+0ke43fj1OY2wK5q0dcQJ07MN/QKL21aBDW94Ekg5aS hy0tTBoz3WnDUnkjMu4SAC4X7MlJwVxOw6f92P9L01GjFKWCF6i+Do3Iob+1YrcG4x ku3lKmY24F5XwtQIg4vtD4Co1etyt4eOCrjqS7W94770mHHkq0JIwW56/B9hOAjJSG q/GAKg7DwkAmTN7T/JWMA4hc47pNyFF5yaGf1HX2LtVX2tAQdvNmkoLh2Vz7Qkwb71 wKFbhYOZG3f7BtIHoqviYhl8UKVnV6fq74RdhywKR/ffUgBthLVeqhiFhORuWrMDfm PNmQ6CIYS9Q3A== In-Reply-To: Feedback-ID: 57735886:user:proton X-Pm-Message-ID: db4b06dd275e7d24f28418678a8928cccd273546 Received-SPF: pass client-ip=185.70.43.167; envelope-from=heimeborgia@protonmail.com; helo=mail-43167.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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:147806 Archived-At: On Saturday, August 24th, 2024 at 11:33 PM, Heime wrote: > On Saturday, August 24th, 2024 at 10:20 PM, Yuri Khan yuri.v.khan@gmail.c= om wrote: >=20 > > On Sat, 24 Aug 2024 at 16:46, Heime heimeborgia@protonmail.com wrote: > >=20 > > > Is this be the correct way for a minor mode to use the variable > > > tema-expr-elisp for imenu-generic-expression that will be applied > > > when enabling tema-minor-mode on a buffer in emacs-lisp-mode ? > >=20 > > No. Consider: > >=20 > > 1. You open an Elisp file (C-x C-f /home/me/some.el RET). > > 2. A buffer is created. > > 3. The file=E2=80=99s contents are loaded into the buffer. > > 4. The buffer switches to emacs-lisp-mode. > > 5. emacs-lisp-mode runs emacs-lisp-mode-hook. At this point, the hook > > is empty so nothing special happens. > > 6. You enable your minor mode (M-x tema-minor-mode RET). > > 7. It adds tema-imenu-expr-elisp to emacs-lisp-mode-hook, but at this > > point it is too late for your current buffer. > >=20 > > Observed result: your minor mode is enabled in the buffer of some.el, > > but its configuration is not applied. When enabling the minor mode in an already opened buffer, I can check the= =20 current major-mode and directly call the appropriate configuration function= =20 (tema-imenu-expr-sh or tema-imenu-expr-elisp) for the current buffer. But how would I disable the settings when the minor-mode is turned off ? ;;;###autoload (define-minor-mode tema-minor-mode "DESC." :init-value nil :lighter " Tema" (if tema-minor-mode (progn ;; Apply the configuration for the current buffer if the major mode= matches (cond ((eq major-mode 'sh-mode) (tema-imenu-expr-sh)) ((eq major-mode 'emacs-lisp-mode) (tema-imenu-expr-elisp))))=20 (tema-disable-imenu) ))