all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: angelomolina--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: Emanuel Berg <moasenwood@zoho.eu>
Cc: Help Gnu Emacs <help-gnu-emacs@gnu.org>
Subject: Re: About the activation of minor modes
Date: Wed, 9 Mar 2022 11:24:32 +0100 (CET)	[thread overview]
Message-ID: <MxiCMPu--3-2@tutanota.com> (raw)
In-Reply-To: <87bkygng27.fsf@zoho.eu>

[-- Attachment #1: Type: text/plain, Size: 1107 bytes --]


I attach one of the minor-mode file.  Would you be so kind to examine it
for improvements.  I do not think I can use (toromona-minor-mode) to
activate the mode.    

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)
>
> -- 
> underground experts united
> https://dataswamp.org/~incal
>


[-- Attachment #2: toromona-voyager.el --]
[-- Type: text/x-emacs-lisp, Size: 11224 bytes --]

;;; 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 "<f11>") '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]

  parent reply	other threads:[~2022-03-09 10:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-05  2:47 About the activation of minor modes angelomolina--- via Users list for the GNU Emacs text editor
2022-03-05  6:20 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-05 15:37   ` angelomolina--- via Users list for the GNU Emacs text editor
2022-03-05 21:49     ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-05 22:20     ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-07 23:01       ` angelomolina--- via Users list for the GNU Emacs text editor
2022-03-08 18:06         ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-08 23:09           ` angelomolina--- via Users list for the GNU Emacs text editor
2022-03-09  0:08             ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-09  9:46               ` angelomolina--- via Users list for the GNU Emacs text editor
2022-03-09 10:24               ` angelomolina--- via Users list for the GNU Emacs text editor [this message]
2022-03-06  3:06 ` Eduardo Ochs
2022-03-06  5:01   ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-06  5:26     ` Eduardo Ochs
2022-03-06  6:08       ` Emanuel Berg via Users list for the GNU Emacs text editor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MxiCMPu--3-2@tutanota.com \
    --to=help-gnu-emacs@gnu.org \
    --cc=angelomolina@tutanota.com \
    --cc=moasenwood@zoho.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.