#+TITLE: Likhon’s GNU Emacs Configuration
#+AUTHOR: Likhon Barai
#+EMAIL: [email protected]
#+DATE: 2022 Nov 19
#+LANGUAGE: en
#+STARTUP: overview
#+TAGS: emacs
#+DESCRIPTION: My Emacs config diaries!
#+html:

[[
https://www.gnu.org/licenses/gpl-3.0.txt][
https://img.shields.io/badge/license-GPL_3-green.svg?style=flat&logo=appveyor]]
[[
https://github.com/ellerbrock/open-source-badges/][
https://badges.frapsoft.com/os/v1/open-source.png?v=103]]
[[
https://img.shields.io/github/forks/Likhon-baRoy/.emacs.d.svg?style=flat]]
[[
https://img.shields.io/github/stars/Likhon-baRoy/.emacs.d.svg?style=flat]]
[[
https://img.shields.io/github/commit-activity/m/Likhon-baRoy/.emacs.d.svg?style=flat]]
[[
https://img.shields.io/tokei/lines/github/Likhon-baRoy/.emacs.d.svg?style=flat]]
[[https://img.shields.io/badge/arch-yes-success.svg?logo=archlinux&style=flat-square]]
[[https://img.shields.io/badge/macos-yes-success.svg?logo=apple&style=flat-square]]
[[https://img.shields.io/badge/windows-untested-important.svg?logo=windows&style=flat-square]]
#+begin_quote
An infinite number of monkeys typing into GNU Emacs would never make a good program.\
——— Linus Torvalds
#+end_quote
- [[#about][About]]
- [[#about-readme][About README]]
- [[#screenshots][Screenshots]]
- [[#how-to-use-this-configuration][How to Use This Configuration]]
- [[#installation][Installation]]
- [[#why-this-config][Why this Config?]]
- [[#troubleshooting][Troubleshooting]]
- [[#further-updates][Further Updates]]
- [[#contribution][Contribution]]
- [[#special-thanks][Special Thanks]]
- [[#prerequisites][Prerequisites]]
- [[#user-information][User Information]]
- [[#install-packages][Install Packages]]
- [[#user-guidance][User Guidance]]
- [[#custom-configurations][Custom Configurations]]
- [[#custom-key-bindings][Custom key bindings]]
- [[#custom-functions][Custom functions]]
- [[#optional][Optional]]
- [[#setup-bangla-language-environment][Setup the Bangla Language Environment]]
- [[#recommendations][Recommendations]]
- [[#replace-capslock-with-ctrl][Replace CapsLock with CTRL]]
- [[#ask-me-anything][Ask Me Anything!]]
- [[#scroll-license][:scroll: License]]
- About
Emacs changes how you think about programming.
Emacs is totally introspectable. You can always find out /what code runs when I press this button?/.
Emacs is an incremental programming environment. There’s no edit-compile-run cycle. There isn’t even an edit-run cycle. You can execute snippets of code and gradually turn them into a finished project. There’s no distinction between your editor and your interpreter.
Emacs is a mutable environment. You can set variables, tweak functions with advice, or redefine entire functions. Nothing is off-limits.
Emacs provides functionality without applications. Rather than separate applications, functionality is all integrated into your Emacs instance. Amazingly, this works. Ever wanted to use the same snippet tool for writing C++ classes as well as emails?
Emacs is full of incredible software concepts that haven’t hit mainstream yet. For example:
- Many platforms have a single item clipboard. Emacs has an infinite clipboard.
- If you undo a change, and then continue editing, you can’t redo the original change. Emacs allows undoing to any historical state, even allowing tree-based exploration of history.
- Emacs supports a reverse variable search: you can find variables with a given value.
- You can perform structural editing of code, allowing you to make changes without breaking syntax. This works for lisps (paredit) and non-lisps (smartparens).
- Many applications use a modal GUI: for example, you can’t do other edits during a find-and-replace operation. Emacs provides recursive editing that allow you to suspend what you’re currently doing, perform other edits, then continue the original task.
Emacs has a documentation culture. Emacs includes a usage manual, a lisp programming manual, pervasive docstrings and even an interactive tutorial.
Emacs has a broad ecosystem. If you want to edit code in a niche language, there’s probably an Emacs package for it.
Emacs doesn’t have a monopoly on good ideas, and there are other great tools out there. Nonetheless, we believe the [[https://i.stack.imgur.com/7Cu9Z.jpg][Emacs learning curve]] pays off.
This beautifully written About EMACS section credits to [[https://github.com/remacs/remacs][Remacs]].
** About README
Welcome to the /Emacs Of Your Dreams/. Wait no, I meant the Emacs Operating System. \
This repository contains my personal configuration for GNU Emacs that I use on the daily and port around from system to system with me. This is an example of a fully customizable Emacs configuration that you can use as an inspiration when building your own!
Customization began with a single-file =~/.emacs= with a few settings and some random snippets. It didn’t take long to become a monster. I loved to cherry-pick 🍒 packages literally from anywhere, I was like why don’t you apt-get.
The configuration depends on [[file:init.el][init.el]], [https://github.com/Likhon-baRoy/.emacs.d/tree/main/my-lisp][my-lisp] and [[file:early-init.el][early-init.el]] (sets up a few initial GUI settings), bootstraps [[https://github.com/jwiegley/use-package][use-package]]. and loads [[file:init.el][init.el]], which is where the majority of the configuration magic happens.
This is an Emacs distribution that aims to enhance the default Emacs experience. It alters a lot of the default settings, bundles of additional packages and adds its own core library to the mix. The final product offers an easy to use Emacs configuration for Emacs newcomers and lots of additional power for Emacs power users.
It’s able to run on GNU/Linux, macOS and Windows. It is compatible ONLY with GNU Emacs 27.1 and Above. In general you’re advised to always run the latest stable release - currently 28.2.
- Screenshots
Here are some demos… \
/A dashboard on startup to clean my mind/.😌
#+BEGIN_CENTER
[[…/screenshots/ss-1.png]]
#+END_CENTER
/Centered text in the frame, looks nice ;) and =flycheck= with BitMap-Arrow on the right-fringe/ 😎
#+BEGIN_CENTER
[[…/screenshots/ss-2.png]]
#+END_CENTER
/default Transparent mode/ 👍🏻
#+BEGIN_CENTER
[[…/screenshots/ss-3.png]]
#+END_CENTER
/File navigation with Speed-bar./
#+BEGIN_CENTER
[[…/screenshots/ss-4.png]]
#+END_CENTER
/feel the Org-mode/ :D
#+BEGIN_CENTER
[[…/screenshots/ss-5.png]]
#+END_CENTER
/Company-mode with yasnippet/ 🔥
#+BEGIN_CENTER
[[…/screenshots/ss-6.png]]
#+END_CENTER
#+html:

- How to Use This Configuration
This repo is meant to be a companion to the Emacs From Scratch video series, serving as an example of a custom configuration build on top of vanilla Emacs. I give instructions below on how to set it up to try it out, but it isn’t meant to be used as your main configuration! My goal here is to provide a working configuration that you can take inspiration from (and copy from directly).
Just keep in mind that this repo isn’t set up to be used directly as your own configuration! Copy the code to your own dotfiles repository and have fun :)
🧨 DISCLAIMER: 🐒 MAKE SURE YOU HAVE THE BACKUP ⚠ THE AUTHOR will
not be responsible for the 🔥 harm 🔥 caused by using this
configuration.
Oh! you wanna use my config! its super duper +easy+ ! It may be in the
future but I’m still +trying+ to avoid making the installer (literally
don’t know how) and just trying to get by my work.
- Install [[https://www.gnu.org/software/emacs/][GNU Emacs]].
- Move =~/.emacs= or =~/.emacs.d=, if you already have it.
- Clone this repo to =HOME= or =~/= path using git and update all the submodules.\
/Run these snippets in your terminal:/
#+begin_src sh
cd ~
git clone https://github.com/Likhon-baRoy/.emacs.d.git
cd .emacs.d
#+end_src
- Ensure a stable connection to Melpa Packages, then open Emacs.
- Enter =y= when prompted with =Auto-update packages now?=, wait for all packages to install. /(Ignore the warnings on the first launch.)/
- In your favorite browser, =Ctrl-f Prerequisite= through this README and follow the Prerequisite instructions.
- Restart Emacs and Start using your Dream Emacs! :tada:
** Why this Config?
There is absolutely no reason for you to use this config, it would
be like the first time 🏊 swimmer, who would mostly likely drown with
an unnecessary amount of effort. Although I’m great underwater so
to say somewhat athletic underachievers.
Time 🕥 and time 🕝 again I learned elisp just to forget it with
endless pondering and compromises, without ✍ jotting things down,
it would have been impossible to configure. May be this started for
maintenance, now its more of rants taking over the configuration! 😎
If you ask me, would I have started with other’s config? I would
definitely say YES. But you should understand an all-in-one
package 📦 or distribution is like bringing a gun 🔫 to a fist 👊
fight. You might end up using less than 5 % of the bloat. And if
you want to change or fix something it is a big 😫 pain to peel
layer after layer to find the actual root cause. Yet you might
want to try these first
And these configurations too.
** Troubleshooting
While troubleshooting I go though these procedures (may not be in the
same order)
-
hate myself when it happens
-
REMOVE the damn plugin and GET BACK TO WORK
-
throw ERROR MSG at google and try catching relevant pages
-
maybe waste few hrs with random trials
-
set debug variable
#+BEGIN_SRC emacs-lisp :tangle no
(setq debug-on-error 1)
(setq debug-on-quit t) ;; C-g
#+END_SRC
** Further Updates
I will be updating My-EMACS from time to time, it is best to =git pull= once a while to stay up to date.
Please also execute ~git submodule update --recursive --remote~ to sync with all the submodules.
** Contribution
If you spotted a bug or you have any suggestions, please fill in an issue. If you have something to fix, feel free to create a pull request.
** Special Thanks
Everyone starts somewhere, and I started here.
My heart whelming Thanks 🙏🏽 to you guy’s 💜, whose effort always makes Emacs go one-step further.
And many other people from the Internet World.
[[https://github.com/emacs-tw/awesome-emacs][Awesome Emacs]] has a good list of packages and themes to check out.
- Prerequisites
** User Information
Please update this file with your personal info.
#+BEGIN_SRC emacs-lisp
(setq user-full-name “Your Name”
user-login-name “Login_Name”
user-real-login-name “Real_Login_Name”
user-mail-address “[email protected]”)
#+END_SRC
** Install Packages
Also this project relies on the following list of applications:
📝 Note: (/for beginners/) I’ll be using =Ctrl= as =C=, =Alt= as =M=, =Shift= as =S=, =Space= as =SPC= and =BackSpace= as =BS=. \
After installation process is done. Whenever you open a file within Emacs, the whole file will be opened in folding mode. Which you obviously won’t see until you find the shortcut key-binding. There is a default feature for this which called hs-minor-mode I just changed some default key-bindings for more useful. \
check this out:
#+begin_example
C-c h (hide-all)
C-c s (show-all)
S-BS (hide-block)
C-BS (show-block)
C-TAB (toggle-hiding) - fold the current section.
S-TAB (hide-level) - fold the sub sections of the current section.
#+end_example
- Custom Configurations
Here are some of my personal changes for Emacs which comes default with this configuration.
** Custom key bindings
#+BEGIN_SRC emacs-lisp
;;; this is confusion
(global-unset-key (kbd “C-z”)) ; unbind (suspend-frame)
;; normal undo and redo
(global-set-key (kbd “C-z”) 'undo-only)
(global-set-key (kbd “C-S-z”) 'undo-tree-redo)
;; ;;; Shell
(global-set-key (kbd “C-!”) ‘eshell-here) ; see this function in `shell.el’
(global-set-key “\C-w” 'backward-kill-word)
;; I use C-h' for backspace in Emacs and move help-command’ elsewhere:
(global-set-key “^h” 'backward-delete-char)
(define-key isearch-mode-map “\C-h” 'isearch-delete-char)
(global-set-key (kbd “C-S-H”) 'kill-whole-line)
;; long lines go-off the side of the screen instead of hosing up the ascii art
(global-set-key “\C-x\C-l” 'toggle-truncate-lines)
;; Rename File
(global-set-key (kbd “C-S-R”) 'rename-file)
;; Delete current file
(global-set-key “\C-cD” 'Delete-current-file)
;; kill selected region
(global-set-key “\C-x\C-k” 'kill-region)
(global-set-key “\C-c\C-k” 'kill-region)
;; Duplicate a whole line
(global-set-key “\C-c\C-d” “\C-a\C- \C-n\M-w\C-y”)
;; Buffer
(global-set-key “\M-n” 'next-buffer)
(global-set-key “\M-p” 'previous-buffer)
;; Window
(global-set-key “\M-o” ‘other-window) ; use with `ace-window’
(global-set-key (kbd “C-.”) #'other-window)
(global-set-key (kbd “C-,”) #'prev-window)
;; auto-complete
(global-set-key “\M-TAB” 'company-complete-common-or-cycle)
#+END_SRC
** Custom functions
#+BEGIN_SRC emacs-lisp
;; Unfill paragraph
;; Might be good. For instance for canceling all of the paragraph quickly or for commenting it away.
(defun unfill-paragraph ()
“Convert a multi-line paragraph into a single line of text.”
(interactive)
(let ((fill-column (point-max)))
(fill-paragraph nil)))
;; Handy key definition
(define-key global-map “\M-Q” 'unfill-paragraph)
#+END_SRC
- Now now, how much do you like transparency? With this config, this method comes default. \
you can toggle =on= / =off= transparency /using/ =C-c t= keystrokes.
#+BEGIN_SRC emacs-lisp
;;________________________________________________________________
;; Transparent Emacs
;;________________________________________________________________
(set-frame-parameter (selected-frame) 'alpha '(85 . 50))
(add-to-list 'default-frame-alist '(alpha . (85 . 50)))
;; (set-frame-parameter (selected-frame) 'alpha '( . ))
;; (set-frame-parameter (selected-frame) 'alpha )
;; Use the following snippet after you’ve set the alpha as above to assign a toggle to “C-c t”:
(defun toggle-transparency ()
“Crave for transparency!”
(interactive)
(let ((alpha (frame-parameter nil 'alpha)))
(set-frame-parameter
nil 'alpha
(if (eql (cond ((numberp alpha) alpha)
((numberp (cdr alpha)) (cdr alpha))
;; Also handle undocumented ( ) form.
((numberp (cadr alpha)) (cadr alpha)))
100)
'(85 . 50) '(100 . 100)))))
(global-set-key (kbd “C-c t”) 'toggle-transparency)
#+END_SRC
- Optional
** Setup Bangla Language Environment
Writing in Bangla using company-wordfreq.
*** Requirements
*** Settings
You can put this configuration code to your =init.el= file or make an extra separate file and put it in =~/.emacs.d/my-lisp/= directory then Emacs will autoload this file from there.
set your keyboard default layout to =Probhat= key-layout.
#+BEGIN_SRC emacs-lisp
(setq default-input-method “bengali-probhat”)
(set-fontset-font “fontset-default” 'bengali (font-spec :family “Kalpurush” :size 16))
#+END_SRC
Install the following package for auto suggestions of Bangla words.
#+BEGIN_SRC emacs-lisp
(use-package company-wordfreq
:delight " 𝛄")
#+END_SRC
We need to the set up the following in the local buffer. This can be done by invoking an interactive function as below.
#+BEGIN_SRC emacs-lisp
(defun remove-quail-show-guidance ()
nil)
(defun remove-quail-completion ()
(quail-select-current))
(defun bn-company-wordfreq ()
(interactive)
(advice-add 'quail-show-guidance :override #'remove-quail-show-guidance)
(advice-add 'quail-completion :override #'remove-quail-completion)
(setq ispell-local-dictionary “bengali_439”)
(setq-local company-backends '(company-wordfreq))
(setq-local company-transformers nil))
#+END_SRC
And let’s hook them up into Text buffer-mode.
#+BEGIN_SRC emacs-lisp
(add-hook 'text-mode-hook (lambda ()
(setq-local company-backends '(company-wordfreq))
(setq-local company-transformers nil)))
#+END_SRC
/for more information visit this link here:/ [[https://mdarifshaikh.com/2021/05/27/typing-bangla-in-emacs.html][Typing Bangla in emacs]]
*** Workflow
- Change the input-method using =C-=
- Enable =company-wordfreq= and other changes for a nice experience using =M-x bn-company-wordfreq=
Now you can enjoy your Bangla/Bengali lang workflow :D
- Recommendations
Here are some general recommendations on Emacs usage that you might find helpful:
** Replace CapsLock with CTRL
Most people don’t use the CapsLock key (unless you like YELLING ON THE INTERNET) so you can use this simple fix to replace it with the CTRL to make your Emacs life easier. Doing this will prevent you from having to bend your pinky down all day long to hit all those fabled Emacs keybindings, allowing you to keep your hands on the home row of the keyboard.
Here’s how to do it across all 3 major operating systems:
Linux X11
There are [[https://askubuntu.com/questions/33774/how-do-i-remap-the-caps-lock-and-ctrl-keys][many ways]] to accomplish this in Linux, but the easiest (and most repeatable) I’ve found is to use [[https://wiki.archlinux.org/index.php/Xmodmap][xmodmap]]. First, create a file named =.Xmodmap= in your home folder and populate it like so:
#+begin_src
clear lock
clear control
keycode 66 = Control_L
add control = Control_L
add Lock = Control_R
#+end_src
This replaces CapsLock with control and also replaces the Ctrl key on the right side with CapsLock just in case you ever need to use it. Most login systems (GDM, KDM, etc) will load this file when you log in so you may not need to do anything extra for it to take effect, just log out and log back in again. If that doesn’t seem to work, you can add this line to one of your startup files (=.xinitrc=, =.profile=, window manager configuration, etc):
#+begin_src sh
xmodmap ~/.Xmodmap
#+end_src
This beautifully written Replace CapsLock with CTRL section credits to [[https://github.com/daviwil/emacs-from-scratch/blob/master/README.org][Emacs From Scratch]]
[[https://GitHub.com/Likhon-baRoy/.emacs.d][https://img.shields.io/badge/Ask me-anything-1abc9c.svg]]
Anything means anything, Personal questions, Money, Work, Life, Code,
Cooking, Traveling, Sports, Teaching, Pokémon, Whatever. :joy:
This project is open source software which is licensed under the [[https://github.com/sergeyklay/bnf-mode/blob/master/LICENSE][GNU General Public Licence version 3]].
#+html:
#+begin_quote
Copyright © 2022-present, Likhon Baroy [email protected].
#+end_quote
评论