unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* About the activation of minor modes
@ 2022-03-05  2:47 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-06  3:06 ` Eduardo Ochs
  0 siblings, 2 replies; 15+ messages in thread
From: angelomolina--- via Users list for the GNU Emacs text editor @ 2022-03-05  2:47 UTC (permalink / raw)
  To: help-gnu-emacs


Can a minor mode activate another minor-mode or functionalities residing in other files ?  I ask because I would like my tools to be organised according to some categorisation criteria' rather than all being huddled together.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: About the activation of minor modes
  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-06  3:06 ` Eduardo Ochs
  1 sibling, 1 reply; 15+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-03-05  6:20 UTC (permalink / raw)
  To: help-gnu-emacs

angelomolina--- via Users list for the GNU Emacs text editor wrote:

> Can a minor mode activate another minor-mode or
> functionalities residing in other files ?

Indeed, you can do whatever you want with and in a minor mode
since it's just a bunch of code like everything else.

Here's an example,

  https://dataswamp.org/~incal/emacs-init/caps-back.el

> I ask because I would like my tools to be organised
> according to some categorisation criteria' rather than all
> being huddled together.

Yeah, but what has the minor-mode question to do with that?

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: About the activation of minor modes
  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
  0 siblings, 2 replies; 15+ messages in thread
From: angelomolina--- via Users list for the GNU Emacs text editor @ 2022-03-05 15:37 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: Help Gnu Emacs


Mar 5, 2022, 06:20 by help-gnu-emacs@gnu.org:

> angelomolina--- via Users list for the GNU Emacs text editor wrote:
>
>> Can a minor mode activate another minor-mode or
>> functionalities residing in other files ?
>>
>
> Indeed, you can do whatever you want with and in a minor mode
> since it's just a bunch of code like everything else.
>
> Here's an example,
>
>  https://dataswamp.org/~incal/emacs-init/caps-back.el
>
>> I ask because I would like my tools to be organised
>> according to some categorisation criteria' rather than all
>> being huddled together.
>>
>
> Yeah, but what has the minor-mode question to do with that?
>

How does one do things?  Can one extend a minor-mode by calling 
 another minor-mode?  I need some simple examples as your code only
defined a minor mode in a single file.

Many thanks

> -- 
> underground experts united
> https://dataswamp.org/~incal
>



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: About the activation of minor modes
  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
  1 sibling, 0 replies; 15+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-03-05 21:49 UTC (permalink / raw)
  To: help-gnu-emacs

angelomolina--- via Users list for the GNU Emacs text editor wrote:

> I need some simple examples as your code only defined
> a minor mode in a single file.

Yeah, but that's a fine way to do it.

BTW even major modes need not involve more than a "only"
a single file, e.g.

  https://dataswamp.org/~incal/fps/fpscalc.el

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: About the activation of minor modes
  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
  1 sibling, 1 reply; 15+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-03-05 22:20 UTC (permalink / raw)
  To: help-gnu-emacs

angelomolina--- via Users list for the GNU Emacs text editor wrote:

> Can one extend a minor-mode by calling another minor-mode?

Well, what do you want to do?

Let's take it from there, rather ...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: About the activation of minor modes
  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-06  3:06 ` Eduardo Ochs
  2022-03-06  5:01   ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 15+ messages in thread
From: Eduardo Ochs @ 2022-03-06  3:06 UTC (permalink / raw)
  To: angelomolina; +Cc: help-gnu-emacs

On Fri, 4 Mar 2022 at 23:48, angelomolina--- via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Can a minor mode activate another minor-mode or functionalities residing in other files ?  I ask because I would like my tools to be organised according to some categorisation criteria' rather than all being huddled together.


Hi Angelo,

I don't know if this idea will help or not, but this is how I would
try to find the answer...

The function `find-epp' of eev pretty-prints its argument and shows
the result in a temporary buffer, and this

  (find-epp (macroexpand '

    (define-minor-mode A-mode
      "Help for A-mode"
      :init-value nil
      :global nil
      :lighter " A")

  ))

shows exactly what this `define-minor-mode' does. I _guess_ that it
should be easy to modify the (define-minor-mode A-mode ...) sexp bit
by bit until you get something that turns on and off B-mode when
A-mode is turned on and off - and if you use

  :lighter " B"

in your definition of B-mode then you'll be able to check if B mode
was turned on and off by just looking at the mode line.

Some people like to learn things using this approach and some hate it.
For more info on that, see:

  http://angg.twu.net/find-elisp-intro.html

and for more (basic) info on eev, see:

  http://angg.twu.net/2020-list-packages-eev-nav.html

Cheers and happy hacking =),
  Eduardo Ochs
  http://angg.twu.net/#eev



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: About the activation of minor modes
  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
  0 siblings, 1 reply; 15+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-03-06  5:01 UTC (permalink / raw)
  To: help-gnu-emacs

Eduardo Ochs wrote:

> The function `find-epp' of eev pretty-prints its argument
> and shows the result in a temporary buffer, and this
>
>   (find-epp (macroexpand '
>
>     (define-minor-mode A-mode
>       "Help for A-mode"
>       :init-value nil
>       :global nil
>       :lighter " A")
>
>   ))
>
> shows exactly what this `define-minor-mode' does. I _guess_
> that it should be easy to modify the (define-minor-mode
> A-mode ...)

Yeah ... _guess_es are that should be pretty easy: obscure
3rd-party software, `macroexpand', a quoted piece of Lisp (a
note to the OP, a `quote' turns Lisp software into data,
however now the macro ... err, whatever).

Study this example instead.

What do you see happening in the below code?

(abbrev-mode           -1)
(auto-encryption-mode  -1)
(file-name-shadow-mode -1)
(gpm-mouse-mode        -1)
(menu-bar-mode         -1)
(tooltip-mode          -1)

(font-lock-mode)
(transient-mark-mode)

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: About the activation of minor modes
  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
  0 siblings, 1 reply; 15+ messages in thread
From: Eduardo Ochs @ 2022-03-06  5:26 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Sun, 6 Mar 2022 at 02:04, Emanuel Berg via Users list for the GNU
Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Eduardo Ochs wrote:
>
> > The function `find-epp' of eev pretty-prints its argument
> > and shows the result in a temporary buffer, and this
> >
> >   (find-epp (macroexpand '
> >
> >     (define-minor-mode A-mode
> >       "Help for A-mode"
> >       :init-value nil
> >       :global nil
> >       :lighter " A")
> >
> >   ))
> >
> > shows exactly what this `define-minor-mode' does. I _guess_
> > that it should be easy to modify the (define-minor-mode
> > A-mode ...)
>
> Yeah ... _guess_es are that should be pretty easy: obscure
> 3rd-party software, `macroexpand', a quoted piece of Lisp (a
> note to the OP, a `quote' turns Lisp software into data,
> however now the macro ... err, whatever).
>
> Study this example instead.
>
> What do you see happening in the below code?
>
> (abbrev-mode           -1)
> (auto-encryption-mode  -1)
> (file-name-shadow-mode -1)
> (gpm-mouse-mode        -1)
> (menu-bar-mode         -1)
> (tooltip-mode          -1)
>
> (font-lock-mode)
> (transient-mark-mode)


Hi Emanuel,

In the page about the elisp tutorial that comes with eev -

  http://angg.twu.net/find-elisp-intro.html

there's this line here:

  When I announced this on an Emacs mailing list the feedback was
  quite bad. See the thread.

The thread only has messages by you and me.
You are _THE_ example of a person who hates eev... =/

  Cheers,
    Eduardo Ochs
    http://angg.twu.net/#eev



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: About the activation of minor modes
  2022-03-06  5:26     ` Eduardo Ochs
@ 2022-03-06  6:08       ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 15+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-03-06  6:08 UTC (permalink / raw)
  To: help-gnu-emacs

Eduardo Ochs wrote:

> The thread only has messages by you and me. You are _THE_
> example of a person who hates eev... =/

Haha, I certainly don't hate eev and besides the opposite of
love isn't hate but indifference ...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: About the activation of minor modes
  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
  0 siblings, 1 reply; 15+ messages in thread
From: angelomolina--- via Users list for the GNU Emacs text editor @ 2022-03-07 23:01 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: Help Gnu Emacs


Mar 5, 2022, 22:20 by help-gnu-emacs@gnu.org:

> angelomolina--- via Users list for the GNU Emacs text editor wrote:
>
>> Can one extend a minor-mode by calling another minor-mode?
>>
>
> Well, what do you want to do?
>
> Let's take it from there, rather ...
>
I have been making a number of minor modes.  But as the number of modes
are increasing, I would like to start integrating them into a single minor-mode,
but keeping the same names.  

Keeping the same names would keep the various  functionalities separate, 
and the corresponding code easier to maintain (for instance,  one could simply
 turn a few of the functionalities off).  Would one use one minor-mode calling other 
minor-modes, or just have separate files calling the required functions but removing
the minor-mode definition in each file, and having just a parent minor-mode?

Does it make sense (or even possible) to extend a minor-mode?  I do not see much
information to achieve the plan, because the descriptions in the manual seem to focus
on a defining just a single minor-mode in one file.  Perhaps some information on this
could be inserted in the elisp tutorial?

Many thanks



> -- 
> underground experts united
> https://dataswamp.org/~incal
>



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: About the activation of minor modes
  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
  0 siblings, 1 reply; 15+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-03-08 18:06 UTC (permalink / raw)
  To: help-gnu-emacs

angelomolina--- via Users list for the GNU Emacs text editor wrote:

> I have been making a number of minor modes. But as the
> number of modes are increasing, I would like to start
> integrating them into a single minor-mode

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.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: About the activation of minor modes
  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
  0 siblings, 1 reply; 15+ messages in thread
From: angelomolina--- via Users list for the GNU Emacs text editor @ 2022-03-08 23:09 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: Help Gnu Emacs


Mar 8, 2022, 18:06 by help-gnu-emacs@gnu.org:

> angelomolina--- via Users list for the GNU Emacs text editor wrote:
>
>> I have been making a number of minor modes. But as the
>> number of modes are increasing, I would like to start
>> integrating them into a single minor-mode
>>
>
> 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.

parent minor-mode (arktika)
minor-mode (toromona)

Would be very grateful if you could show me a sample code.

I have done

----- .emacs -----

(add-to-list 'load-path "~/Opstk/typex/arktika")
(require 'arktika)


----- arktika.el -----

(defun arktika-launch ()
  "desc"
  (require 'toromona)
  (toromona-launch) )

(provide 'arktika)



> -- 
> underground experts united
> https://dataswamp.org/~incal
>



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: About the activation of minor modes
  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
  0 siblings, 2 replies; 15+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-03-09  0:08 UTC (permalink / raw)
  To: help-gnu-emacs

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




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: About the activation of minor modes
  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
  1 sibling, 0 replies; 15+ messages in thread
From: angelomolina--- via Users list for the GNU Emacs text editor @ 2022-03-09  9:46 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: Help Gnu Emacs

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)
>

Whilst I have written some minor modes which I enable using 
add-hook,  I am not confident how I can call the minor-mode
using something similar to (abbrev-mode), e.g.  (toromona-mode).

Currently I have

  (add-hook 'prog-mode-hook    'toromona-minor-mode) 
  (add-hook 'texinfo-mode-hook 'toromona-minor-mode)








^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: About the activation of minor modes
  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
  1 sibling, 0 replies; 15+ messages in thread
From: angelomolina--- via Users list for the GNU Emacs text editor @ 2022-03-09 10:24 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: Help Gnu Emacs

[-- 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]

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2022-03-09 10:24 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).