From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: angelomolina--- via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: Re: About the activation of minor modes Date: Wed, 9 Mar 2022 11:24:32 +0100 (CET) Message-ID: References: <87lexoly3m.fsf@zoho.eu> <87y21ohwir.fsf@zoho.eu> <87lexkpbee.fsf@zoho.eu> <87bkygng27.fsf@zoho.eu> Reply-To: angelomolina@tutanota.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_85003_468090228.1646821472402" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29461"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Help Gnu Emacs To: Emanuel Berg Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Mar 09 11:26:21 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 1nRtWP-0007UQ-5B for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 09 Mar 2022 11:26:21 +0100 Original-Received: from localhost ([::1]:55190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRtWM-0007OF-G0 for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 09 Mar 2022 05:26:18 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:59204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRtUw-0007NG-OQ for help-gnu-emacs@gnu.org; Wed, 09 Mar 2022 05:24:50 -0500 Original-Received: from w1.tutanota.de ([81.3.6.162]:45070) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRtUt-0006YC-37 for help-gnu-emacs@gnu.org; Wed, 09 Mar 2022 05:24:50 -0500 Original-Received: from w3.tutanota.de (unknown [192.168.1.164]) by w1.tutanota.de (Postfix) with ESMTP id 6609FFA0325; Wed, 9 Mar 2022 10:24:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1646821472; s=s1; d=tutanota.com; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=YwnEHNdudKEyejhDAVkcAMFZ9xYnv9gI5j+mXdK/WD8=; b=2GxYoBgvbYaOhH/nih76SucjGViesVLzyi9zaHYqKZw+qwo9JKjF6qdiEEh7ov5t IN0194PHxOEsFrNF02esxcLfJwRQjGFq8IYsrtiuHcsnKhxR9h0fo7Oduet3XTFaYTe fms6rA0D/qaGyPBAhYz3kwaH9dv/EnV9F/yoKWkuhtq+Uzn9XbMT7IF+IimbI+eO4js svk/sn5YQhAebh2+eLHGqiSBVcF6gZ/fQqV3mhuJBsvgkZK5VfOB2KQS6IK5dLsl3Sg cbMiJMy7nstpmBKQGgjmGdqWLB3EjQ5s0rpbPdeq7EeJ8wBJd72VRuCblVWWS6fwR// BXzv7Hr6rw== In-Reply-To: <87bkygng27.fsf@zoho.eu> Received-SPF: pass client-ip=81.3.6.162; envelope-from=angelomolina@tutanota.com; helo=w1.tutanota.de 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, HTML_MESSAGE=0.001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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-Content-Filtered-By: Mailman/MimeDel 2.1.29 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:136417 Archived-At: ------=_Part_85003_468090228.1646821472402 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I attach one of the minor-mode file.=C2=A0 Would you be so kind to examine = it for improvements.=C2=A0 I do not think I can use (toromona-minor-mode) to activate the mode.=C2=A0 =C2=A0=20 Mar 9, 2022, 00:08 by help-gnu-emacs@gnu.org: > angelomolina--- via Users list for the GNU Emacs text editor wrote: > >>> But you decrease modularity that way. >>> >>> If you want both minor modes for a major mode, just stack >>> them on top of each other when you enable them. >>> >> >> I understand your point. I can keep the various minor-modes >> as they are. But then have a parent minor-mode that >> activates all of them. I am putting the respective files in >> the same directory. >> > > I would stack them in the hook for the major mode where they > are intended to be used. > > E.g., if I want `auto-fill-mode' and `abbrev-mode' (minor > modes) in `latex-mode' (major mode) I'd put it like this. > > (defun latex-mode-hook-f () > (auto-fill-mode) > (abbrev-mode) ) > (add-hook 'latex-mode-hook #'latex-mode-hook-f) > > --=20 > underground experts united > https://dataswamp.org/~incal > ------=_Part_85003_468090228.1646821472402 Content-Type: text/x-emacs-lisp; charset=us-ascii; name=toromona-voyager.el Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=toromona-voyager.el ;;; toromona-voyager.el -*- lexical-binding: t; -*- ;; ;; Version 1.0 ;; Copyright 2021 ;; This file forms part of. ;; Mode: rec ;; File: toromona-voyager.el ;; Version: File Version 1.0 ;; Brief: Organises ;; FileVers: 1.0 ;; Copyright: 2021 ;; License: Gnu Affero General Public License (Gnu AGPL) ;; + Version 3 or Any Later Version ;; Author: Strategist Christopher Dimech ;; Keywords: ;; # end of rec ;;; Copying Conditions ;; _ _ ;; __ ___ _ __ _ _ __ ___ _ _ __| (_) ;; / _/ _ \ '_ \ || | / _/ _ \ ' \/ _` | | ;; \__\___/ .__/\_, | \__\___/_||_\__,_|_| ;; |_| |__/ ;; This file is part of Behistun, a Gnu Package. ;; Gnu Behistun is free software. You can re-distribute Behistun or ;; modify it under the terms of the Gnu Affero General Public License ;; as published by the Free Software Foundation, either Version 3 of ;; the License, or (at your option) any later version. ;; A copy of the license is included in the file entitled ;; "gnu-agpl.texi". If not, see https://www.gnu.org/licenses/. ;;; Commentary: ;; _ ;; __ ___ _ __ _ __ ___ _ _| |_ __ _ _ _ _ _ ;; / _/ _ \ ' \| ' \/ -_) ' \ _/ _` | '_| || | ;; \__\___/_|_|_|_|_|_\___|_||_\__\__,_|_| \_, | ;; |__/ ;;; Code: ;; _ ;; __ ___ __| |___ ;; / _/ _ \/ _` / -_) ;; \__\___/\__,_\___| ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defgroup toromona nil "A minor mode that sets typeface for comments." :prefix "toromona-" :group 'applications) ;; +++++++++++++++++++++++++++++++++++++++++++++++++++++ ;; _ _ _ ;; __ _ _ _ _ _ ___| |_ __ _| |_(_)___ _ _ ;; / _` | ' \| ' \/ _ \ _/ _` | _| / _ \ ' \ ;; \__,_|_||_|_||_\___/\__\__,_|\__|_\___/_||_| ;; Copy and Inherit Face Attributes ;; ******************************** ;; ;; :inherit ;; The name of a face from which to inherit attributes, or a list ;; of face names. Attributes from inherited faces are merged into ;; the face. ;; ;; ;; comment-delimiter-face inherits from font-lock-comment-face ;; (set-face-attribute 'font-lock-comment-delimiter-face ;; :inherit 'font-lock-comment-face) ;; ;; copy-face copies typeface to font-lock-comment-delimiter-face ;; ;; (copy-face 'font-lock-comment-face 'font-lock-comment-delimiter-face) (defun toromona-annotation-style () "Set colour for the comment delimiter. Use normal weight typeface for comments." (set-face-attribute 'font-lock-comment-face nil :weight 'normal :slant 'italic)) ;; ----------------------------------------------------- (defvar toromona-annotation-contrast 2 "Sets the colour contrast (against background) for comments.") ;; ----------------------------------------------------- (defvar toromona-annotation-chroma ;; Uses two Association Lists, comprising a Chroma Intensity Key ;; (low, mid, high) associated with an RGB Hex-Code. To list ;; colour-names and hex-codes, call the Emacs Minibuffer Command ;; `M-x list-colors-display'. '( (dark . ((low . "#8600E6") ; indigo (Blu:63% Red:37% Grn:0%) (mid . "#AA33FF") ; indigo (Blu:54% Red:36% Grn:11%) (high . "#C370FF"))) ; indigo (Blu:45% Red:35% Grn:20%) (light . ((low . "#C16BFF") ; indigo (Blu:46% Red:35% Grn:19%) (mid . "#AA33FF") ; indigo (Blu:54% Red:36% Grn:11%) (high . "#8000DB"))) ) ; indigo (Blu:63% Red:37% Grn:0%) "Colour contrast for comments, indigo on dark and light background.") ;; ----------------------------------------------------- (defun toromona-annotation-body (chroma) "Set the foreground colour for comments following delimiter. CHROMA Intensity Key used for setting colour of comments ." (let* ( (colors toromona-annotation-chroma) (levels (alist-get (frame-parameter nil 'background-mode) colors)) ) (face-remap-add-relative 'font-lock-comment-face `(:foreground ,(alist-get chroma levels)))) ) ;; +++++++++++++++++++++++++++++++++++++++++++++++++++++ (defun toromona-annotation-delimiter () "Set foreground colour for the comment delimiter." ;; comment-delimiter-face inherits from font-lock-comment-face (if (eq 'dark (frame-parameter nil 'background-mode)) ;; for dark theme (set-face-attribute 'font-lock-comment-delimiter-face nil :foreground "#00FF00") ;; for light theme (set-face-attribute 'font-lock-comment-delimiter-face nil :foreground "#00FFFF") )) ;; +++++++++++++++++++++++++++++++++++++++++++++++++++++ (defun toromona-annotation-sweep () "Cycles through the colour chroma for comment body. Colours are determined by `toromona-annotation'." (interactive) (pcase toromona-annotation-contrast (1 (toromona-annotation-body 'low) (message "Arktika | Toromona Annotation | %s" "Low Contrast") (setq toromona-annotation-contrast 2)) (2 (toromona-annotation-body 'mid) (message "Arktika | Toromona Annotation | %s" "Mid Contrast") (setq toromona-annotation-contrast 3)) (_ (toromona-annotation-body 'high) (message "Arktika | Toromona Annotation | %s" "High Contrast") (setq toromona-annotation-contrast 1)) )) ;; +++++++++++++++++++++++++++++++++++++++++++++++++++++ (defun toromona-annotation-low-contrast () (when toromona-minor-mode (toromona-annotation-body 'low))) ;; +++++++++++++++++++++++++++++++++++++++++++++++++++++ (defun toromona-annotation-keytrigger () "Key trigger for rapid execution of richkov commands" (interactive) (global-set-key (kbd "H-;") #'toromona-annotation-sweep)) ;; +++++++++++++++++++++++++++++++++++++++++++++++++++++ (defun toromona-annotation-tools () "Aggregates annotation tools for comments." (toromona-annotation-style) (toromona-annotation-delimiter) (toromona-annotation-low-contrast) (toromona-annotation-keytrigger)) ;; ----------------------------------------------------- (defun toromona-annotation-typeface (chroma) "Set the foreground colour for comments. CHROMA Intensity Key used for setting colour of comments ." (message "toromona-annotation-typeface") (let* ( (colors toromona-annotation-chroma) (levels (alist-get (frame-parameter nil 'background-mode) colors)) ) (face-remap-add-relative 'font-lock-comment-face `(:foreground ,(alist-get chroma levels))) ;; delimiter-face inherits from font-lock-comment-face (if (eq 'dark (frame-parameter nil 'background-mode)) (set-face-attribute 'font-lock-comment-delimiter-face nil :foreground "#00FF00") ; for dark theme (set-face-attribute 'font-lock-comment-delimiter-face nil :foreground "#00FFFF") ) ; for light theme (message "toromona: %s Annotation: " chroma)) ) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun toromona-margins (&optional width) "Sets size of window margins. \n WIDTH Number of character cells for two margin areas. WIDTH dafaults to 3, but can be set using the Universal Prefix Argument. \nC-u Width M-x toromona-margins" (interactive) (let ( (width (or width 3)) ) (dolist (window (window-list)) (set-window-margins window width width))) ) ;; ----------------------------------------------------- (defvar emacsbars-enable 1 "Sets the action for enabling or disabling bar modes.") (defun toromona-switch (&optional action) "Enables or disables Emacs Bars M-x toromona-emacsbars RET Activates (enables) emacs bars. C-u M-x toromona-emacsbars RET Deactivates (disables) emacs bars. C-u action M-x toromona-margins Uses value in action to enable or disable." (interactive "P") ;; If action in nil, set action to enable the bar modes (unless action (setq action 1)) (if action (progn ; enables emacs bar modes (menu-bar-mode 1) (tool-bar-mode 1) (scroll-bar-mode 1)) (progn ; disables emacs bar modes (menu-bar-mode -1) (tool-bar-mode -1) (scroll-bar-mode -1)) )) ;; ----------------------------------------------------- (defun toromona-enable () "Use Margined Fullscreen without Emacs Tool Bars" (interactive) (tool-bar-mode -1) ; disable emacs bar modes (scroll-bar-mode -1) (menu-bar-mode -1) (if (one-window-p) (toromona-margins) ; single window (toromona-margins 2)) ; multiple windows (set-frame-parameter (selected-frame) 'fullscreen 'fullboth)) ;; ----------------------------------------------------- (defun toromona-disable () "Disables toromona, enables emacs Tool Bars" (interactive) (menu-bar-mode 1) ; enables emacs bar modes (tool-bar-mode 1) (scroll-bar-mode 1) (toromona-margins 0) (set-frame-parameter (selected-frame) 'fullscreen 'maximised)) ;; ----------------------------------------------------- (defvar toromona-kondor-level 1) (defun toromona-sweep () "Cycles frame-size among default, big, and small." (interactive) (pcase toromona-kondor-level (1 (message "+ Toromona") (toromona-enable) (setq toromona-kondor-level 2)) (2 (message "+ Fullscreen") (toromona-disable) (setq toromona-kondor-level 3)) (3 (message "+ Reduced Size") ;; Turn off fullscreen, then perform a frame resize. (let ( (w (frame-width)) (h (frame-height)) ) (set-frame-parameter (selected-frame) 'fullscreen nil) (set-frame-size nil 75 (1- h))) (setq toromona-kondor-level 1))) ) ;; +++++++++++++++++++++++++++++++++++++++++++++++++++++ (defun toromona-keytrigger () "Set keybinding for changing toromona-recluder mode" (global-unset-key [f11]) (global-set-key (kbd "") 'toromona-sweep) ) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun toromona-launch () "Set keybinding for changing toromona mode" (toromona-keytrigger)) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; _ _ ;; _ __ (_)_ _ ___ _ _ _ __ ___ __| |___ ;; | ' \| | ' \/ _ \ '_| | ' \/ _ \/ _` / -_) ;; |_|_|_|_|_||_\___/_| |_|_|_\___/\__,_\___| ;;;###autoload (define-minor-mode toromona-minor-mode "Colour Brace Marks according to their depth." :lighter " toromona" ; indicator in mode-line (set-face-attribute 'font-lock-comment-face nil :weight (face-attribute 'default :weight)) (when toromona-minor-mode ; evaluates true when mode enabled (set-face-attribute 'default nil :weight 'bold) (toromona-annotation-tools)) ) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;###autoload (defun toromona-minor-mode-enable () "Enable `toromona-minor-mode'." (toromona-minor-mode 1)) ;;;###autoload (defun toromona-minor-mode-disable () "Disable `toromona-minor-mode'." (toromona-minor-mode 0)) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (provide 'toromona) ;; file ends here [toromona.el] ------=_Part_85003_468090228.1646821472402--