├── LICENSE ├── README.md └── colored-clients.sh /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Blaine Mooers and the University of Oklahoma Board of Regents 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Version](https://img.shields.io/static/v1?label=emacsclient-custom-frames&message=0.2&color=brightcolor) 2 | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) 3 | 4 | # Customize emacsclient frames to make them distinguishable 5 | 6 | 7 | ## Problem addressed 8 | 9 | Emacsclient opens a new frame (aka what non-Emacs users or non-Emacsens call a window). 10 | It can be preferable to have multiple frames open rather than multiple panes (Emacsens call these windows) open in a frame, especially when working on multiple projects, each with an independent context. 11 | The server can run for days or months, so the frames remain up for days or months. 12 | 13 | It took me too long to grasp the joys of **emacslient**. 14 | I wish that I had started using them earlier. 15 | 16 | This above bash script `colored-clients.sh` provides 21 functions for calling **emacslient**, each with a unique foreground--background color combination. 17 | They enable the opening of 21 uniquely colored frames. 18 | 19 | These functions also take the project's name or index number as a command line argument. 20 | The project name appears in the upper lefthand corner of the frame. 21 | In the example below, the project index number is `6112`. 22 | Its full name is `6112MooersLabGitHubLabRepos`, which I could have passed as a command line argument. 23 | This label negates memorizing which color scheme is mapped to which project. 24 | 25 | Screenshot 2024-12-03 at 6 21 32 AM 26 | 27 | The snapshot below shows the upper lefthand corner of four frames, each with a different label. 28 | 29 | Screenshot 2024-12-03 at 6 35 37 AM 30 | 31 | ## Further explanation of the problem 32 | 33 | Emacs will take progressively longer to start when your initialization file becomes longer. 34 | A file with a thousand lines may take five seconds to start. 35 | This delay will be annoying, especially when the time approaches a minute or a few minutes. 36 | Some of the delays can sometimes be associated with an over-configured shell. 37 | 38 | One way around this problem is to start an Emacs server (M-x server-start) inside Emacs and then use the binary **emacsclient** to attach it to the server. 39 | This binary resides in the same folder as your Emacs binary. 40 | A new instance of the Emacs frame will open instantly with the configuration of the Emacs profile used to start the profile. 41 | 42 | You can launch one server per profile if you have multiple profiles for distinct workflows. 43 | You can name each server to attach it to your desired profile. 44 | 45 | You may wind up with many Emacs frames that look identical. 46 | You may have different buffers opened in the other frames, but they all share the same set of buffers. 47 | The above script ,`colored-clients.sh`, of bash functions opens emacslient client instances with the project's name taken from the command line as an argument. 48 | The bash functions are mapped to 21 foreground and background color combinations. 49 | 11 are dark on light, and 10 are light on dark. 50 | 51 | ## Easy recovery of the names of the customization functions 52 | 53 | A table of the function names and the pairs of colored can be printed to the terminal by entering `efclients`. 54 | The function named `efclients` aids in selecting a function that will generate a frame with the desired label and color scheme. 55 | `ef` is my abbreviation for my Emacs profile, which named `e29fewpackages`. 56 | `29` is the version number of the Emacs binary. 57 | 58 | ```bash 59 | FunctionName bg color fg color 60 | ------------ + ----------------- + -------------- 61 | eflgc Light Green Black 62 | eflyc Light Yellow Black 63 | efwc White Black 64 | eflgyc Light Gray Black 65 | efic Ivory Black 66 | efbec Biege Black 67 | eflac Lavender Black 68 | efmcc Mint Cream Black 69 | efabc Alice Blue Black 70 | efhdc Honey Drew Black 71 | efptc Pale Turquoise Black 72 | efsbtc Dark Slate Blue Thistle 73 | efdglcc Dark Slate Gray Light Cyan 74 | efmbcc Midnight Blue Lavender 75 | efdgpgc Dark Olive Green Pale Green 76 | efsbppc Saddle Brown Peach Puff 77 | efdgpgc Dark Red Light Coral 78 | efdmpc Dark Magenta Plum 79 | efdcac Dark Cyan Aquamarin 80 | efimpc Indigo Medium Purple 81 | efdgmc Dark Goldenrod Moccasin 82 | ``` 83 | 84 | ## Usage example 85 | 86 | Enter the following command in the terminal after customizing and sourcing the above bash script. 87 | 88 | ```bash 89 | efimpc 6112MooersLabGitHubLabRepos 90 | ``` 91 | 92 | 93 | ## Naming an Emacs server after its profile 94 | 95 | Give the server a unique name in the `init.el` file by adding the following line. 96 | This server name will be used in the above bash functions to attach to the correct profile. 97 | 98 | ```elisp 99 | (setq server-name "e29f") 100 | ``` 101 | 102 | You could make another set of functions to attach to a different profile, or these could be generalized by passing the profile name as a command line argument. 103 | 104 | ## Making text visible on highlighted lines 105 | 106 | I would like to highlight the line that the cursor is currently on. 107 | The color I selected for this highlighting blended too well with light-colored font when using dark backgrounds. 108 | I had to pick a neutral color that would work against dark and light backgrounds. 109 | 110 | hliine 111 | 112 | I added the following code to my initialization file. 113 | 114 | ```elisp 115 | ;; Load hl-line mode 116 | (require 'hl-line) 117 | 118 | ;; Set the hl-line face to a neutral color 119 | (set-face-attribute 'hl-line nil :background "Gray70" :foreground nil) 120 | 121 | ;; Enable global hl-line mode 122 | (global-hl-line-mode 1) 123 | ``` 124 | 125 | Likewise, I had a similar problem with selected text that was part of a region. 126 | The following code will change the color of the selected text in a region to black. 127 | 128 | region 129 | 130 | ```elisp 131 | ;; Set the region face to an intermediate color 132 | (set-face-attribute 'region nil :background "SlateGray" :foreground "black") 133 | 134 | ;; Set the cursor color 135 | (set-cursor-color "yellow") 136 | ``` 137 | 138 | 139 | ## Update history 140 | 141 | |Version | Changes | Date | 142 | |:-----------|:------------------------------------------------------------------------------------------------------------------------------------------|:---------------------| 143 | | Version 0.1 | Added badges, funding, and update table. Initial commit. | 2024 December 2 | 144 | | Version 0.2 | Very extensive updates to the README.md file. Rewrote the text, added images, and added more code blocks. | 2024 December 3 | 145 | 146 | ## Sources of funding 147 | 148 | - NIH: R01 CA242845 149 | - NIH: R01 AI088011 150 | - NIH: P30 CA225520 (PI: R. Mannel) 151 | - NIH: P20 GM103640 and P30 GM145423 (PI: A. West) 152 | 153 | -------------------------------------------------------------------------------- /colored-clients.sh: -------------------------------------------------------------------------------- 1 | function efc { 2 | /Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient -s e29f -c --eval "(modify-frame-parameters nil '((name . \"$1\")))" 3 | echo "Provide project ID as name of frame." 4 | echo "C-x 5 0 when finished with the frame." 5 | } 6 | 7 | function eflgc { 8 | /Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient -s e29f -c --eval "(modify-frame-parameters nil '((name . \"$1\") (foreground-color . \"black\") (background-color . \"lightgreen\")))" 9 | echo "light green background,black foreground" 10 | echo "C-x 5 0 when finished with the frame." 11 | } 12 | 13 | function eflyc { 14 | /Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient -s e29f -c --eval "(modify-frame-parameters nil '((name . \"$1\") (foreground-color . \"black\") (background-color . \"#FFFFE0\")))" 15 | echo "light yellow background,black foreground" 16 | echo "C-x 5 0 when finished with the frame." 17 | } 18 | 19 | function efwc { 20 | /Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient -s e29f -c --eval "(modify-frame-parameters nil '((name . \"$1\") (foreground-color . \"black\") (background-color . \"#FFFFFF\")))" 21 | echo "white background,black foreground" 22 | echo "C-x 5 0 when finished with the frame." 23 | } 24 | 25 | function eflgyc { 26 | /Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient -s e29f -c --eval "(modify-frame-parameters nil '((name . \"$1\") (foreground-color . \"black\") (background-color . \"#D3D3D3\")))" 27 | echo "light gray background,black foreground" 28 | echo "C-x 5 0 when finished with the frame." 29 | } 30 | 31 | function efic { 32 | /Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient -s e29f -c --eval "(modify-frame-parameters nil '((name . \"$1\") (foreground-color . \"black\") (background-color . \"#FFFFF0\")))" 33 | echo "Ivory background,black foreground" 34 | echo "C-x 5 0 when finished with the frame." 35 | } 36 | 37 | function efbec { 38 | /Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient -s e29f -c --eval "(modify-frame-parameters nil '((name . \"$1\") (foreground-color . \"black\") (background-color . \"#F5F5DC\")))" 39 | echo "biege background,black foreground" 40 | echo "C-x 5 0 when finished with the frame." 41 | } 42 | 43 | function eflac { 44 | /Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient -s e29f -c --eval "(modify-frame-parameters nil '((name . \"$1\") (foreground-color . \"black\") (background-color . \"#E6E6FA\")))" 45 | echo "lavender background,black foreground" 46 | echo "C-x 5 0 when finished with the frame." 47 | } 48 | 49 | function efmcc { 50 | /Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient -s e29f -c --eval "(modify-frame-parameters nil '((name . \"$1\") (foreground-color . \"black\") (background-color . \"#F5FFFA\")))" 51 | echo "mint cream background,black foreground" 52 | echo "C-x 5 0 when finished with the frame." 53 | } 54 | 55 | function efabc { 56 | /Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient -s e29f -c --eval "(modify-frame-parameters nil '((name . \"$1\") (foreground-color . \"black\") (background-color . \"#F0F8FF\")))" 57 | echo "Alice Blue background,black foreground" 58 | echo "C-x 5 0 when finished with the frame." 59 | } 60 | 61 | function efhdc { 62 | /Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient -s e29f -c --eval "(modify-frame-parameters nil '((name . \"$1\") (foreground-color . \"black\") (background-color . \"#F0FFF0\")))" 63 | echo "Honey Drew background,black foreground" 64 | echo "C-x 5 0 when finished with the frame." 65 | } 66 | 67 | function efptc { 68 | /Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient -s e29f -c --eval "(modify-frame-parameters nil '((name . \"$1\") (foreground-color . \"black\") (background-color . \"#AFEEEE\")))" 69 | echo "Pale Turquoise background,black foreground" 70 | echo "C-x 5 0 when finished with the frame." 71 | } 72 | 73 | 74 | function efdglcc { 75 | /Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient -s e29f -c --eval "(modify-frame-parameters nil '((name . \"$1\") (foreground-color . \"#E0FFFF\") (background-color . \"#2F4F4F\")))" 76 | echo "Dark Slate Gray background, Light Cyan foreground" 77 | echo "C-x 5 0 when finished with the frame." 78 | } 79 | 80 | function efsbtc { 81 | /Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient -s e29f -c --eval "(modify-frame-parameters nil '((name . \"$1\") (foreground-color . \"#D8BFD8\") (background-color . \"#483D8B\")))" 82 | echo "Dark Slate Blue background, Thistle foreground" 83 | echo "C-x 5 0 when finished with the frame." 84 | } 85 | 86 | function efmbcc { 87 | /Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient -s e29f -c --eval "(modify-frame-parameters nil '((name . \"$1\") (foreground-color . \"#E6E6FA\") (background-color . \"#191970\")))" 88 | echo "Midnight Blue background, Lavender foreground" 89 | echo "C-x 5 0 when finished with the frame." 90 | } 91 | 92 | function efdgpgc { 93 | /Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient -s e29f -c --eval "(modify-frame-parameters nil '((name . \"$1\") (foreground-color . \"#98FB98\") (background-color . \"#556B2F\")))" 94 | echo "Dark Olive Green background, Pale Green foreground" 95 | echo "C-x 5 0 when finished with the frame." 96 | } 97 | 98 | function efsbppc { 99 | /Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient -s e29f -c --eval "(modify-frame-parameters nil '((name . \"$1\") (foreground-color . \"#FFDAB9\") (background-color . \"#8B4513\")))" 100 | echo "Saddle Brown background, Peach Puff foreground" 101 | echo "C-x 5 0 when finished with the frame." 102 | } 103 | 104 | 105 | function efdgpgc { 106 | /Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient -s e29f -c --eval "(modify-frame-parameters nil '((name . \"$1\") (foreground-color . \"#F08080\") (background-color . \"#8B0000\")))" 107 | echo "Dark Red background, Light Coral foreground" 108 | echo "C-x 5 0 when finished with the frame." 109 | } 110 | 111 | function efdmpc { 112 | /Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient -s e29f -c --eval "(modify-frame-parameters nil '((name . \"$1\") (foreground-color . \"#DDA0DD\") (background-color . \"#8B008B\")))" 113 | echo "Dark Magenta background, Plum foreground" 114 | echo "C-x 5 0 when finished with the frame." 115 | } 116 | 117 | function efdcac { 118 | /Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient -s e29f -c --eval "(modify-frame-parameters nil '((name . \"$1\") (foreground-color . \"#7FFFD4\") (background-color . \"#008B8B\")))" 119 | echo "Dark Cyan background, Aquamarine foreground" 120 | echo "C-x 5 0 when finished with the frame." 121 | } 122 | 123 | function efimpc { 124 | /Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient -s e29f -c --eval "(modify-frame-parameters nil '((name . \"$1\") (foreground-color . \"#9370DB\") (background-color . \"#4B0082\")))" 125 | echo "Indigo background, Medium Purple foreground" 126 | echo "C-x 5 0 when finished with the frame." 127 | } 128 | 129 | function efdgmc { 130 | /Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient -s e29f -c --eval "(modify-frame-parameters nil '((name . \"$1\") (foreground-color . \"#FFE4B5\") (background-color . \"#B8860B\")))" 131 | echo "Dark Goldenrod background, Moccasin foreground" 132 | echo "C-x 5 0 when finished with the frame." 133 | } 134 | 135 | 136 | function efclients { 137 | # Define the table content 138 | table_content="FunctionName,bg color,fg color 139 | ------------ +,----------------- +,-------------- 140 | eflgc,Light Green,Black 141 | eflyc,Light Yellow,Black 142 | efwc,White,Black 143 | eflgyc,Light Gray,Black 144 | efic,Ivory,Black 145 | efbec,Biege,Black 146 | eflac,Lavender,Black 147 | efmcc,Mint Cream,Black 148 | efabc,Alice Blue,Black 149 | efhdc,Honey Drew,Black 150 | efptc,Pale Turquoise,Black 151 | efsbtc,Dark Slate Blue,Thistle 152 | efdglcc,Dark Slate Gray,Light Cyan 153 | efmbcc,Midnight Blue,Lavender 154 | efdgpgc,Dark Olive Green,Pale Green 155 | efsbppc,Saddle Brown,Peach Puff 156 | efdgpgc,Dark Red,Light Coral 157 | efdmpc,Dark Magenta,Plum 158 | efdcac,Dark Cyan,Aquamarin 159 | efimpc,Indigo,Medium Purple 160 | efdgmc,Dark Goldenrod,Moccasin" 161 | 162 | # Print the table using column command 163 | echo "$table_content" | column -t -s "," 164 | } 165 | 166 | --------------------------------------------------------------------------------