emacs.d

bloated emacs configuration
git clone git://git.ckyln.com/~cem/emacs.d.git
Log | Files | Refs | README

commit 1b8c7bbc17d3d7569624770db621b02c95f8bd15
parent 145ebee00833ba5df947cc3aec84a928f9283058
Author: Cem Keylan <cem@ckyln.com>
Date:   Wed, 22 Apr 2020 01:53:36 +0300

minor tweaks and documentation updates

Diffstat:
Minit.org | 138+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 111 insertions(+), 27 deletions(-)

diff --git a/init.org b/init.org @@ -15,7 +15,7 @@ init file. - [[#intro][Intro]] - [[#installation-instructions][Installation Instructions]] - [[#ignoring-initel-changes-on-git][Ignoring init.el changes on Git]] - - [[#meta][Meta]] + - [[#start-of-the-initel][Start of the init.el]] - [[#attribution][Attribution]] - [[#startup-settings][Startup Settings]] - [[#declutter][Declutter]] @@ -23,6 +23,7 @@ init file. - [[#custom-file][Custom-file]] - [[#private-file][Private file]] - [[#starting-the-server][Starting the server]] + - [[#cheatsheet][cheatsheet]] - [[#packages][Packages]] - [[#evil-mode][Evil-mode]] - [[#org-mode][Org-mode]] @@ -39,6 +40,7 @@ init file. - [[#functions][Functions]] - [[#paste-services][Paste Services]] - [[#notmuch][Notmuch]] + - [[#tangle-init][Tangle Init]] - [[#other-settings][Other Settings]] - [[#dired----ls-dired][Dired -- ls dired]] - [[#coding-system-for-terminal][Coding System for Terminal]] @@ -77,24 +79,20 @@ this by doing git update-index --assume-unchanged init.el #+END_SRC -** Meta - -To load init.el properly we run a function such as this. - +** Start of the init.el +We want lexical binding on init.el and some little commentary. +It would be useful if user decides to read the init.el file instead +of this init.org file. #+BEGIN_SRC emacs-lisp - (defun tangle-init () - "If the current buffer is 'init.org' the code-blocks are - tangled, and the tangled file is compiled." - (when (equal (buffer-file-name) - (expand-file-name (concat user-emacs-directory "init.org"))) - ;; Avoid running hooks when tangling. - (let ((prog-mode-hook nil)) - (org-babel-tangle) - (byte-compile-file (concat user-emacs-directory "init.el"))))) + ;;; init.el -- Cem Keylan -*- lexical-binding: t; -*- - (add-hook 'after-save-hook 'tangle-init) -#+END_SRC + ;;; Commentary: + ;;; This file is automatically generated by the init.org + ;;; document, which includes more information about installed + ;;; packages and usage information. + ;;; Code: +#+END_SRC ** Attribution I am still relatively new to the emacs environment myself. These are the people that I have stolen from. @@ -181,7 +179,7 @@ my cache folder. (setq custom-file "~/.cache/emacs-custom.el") #+END_SRC -Let's load the custom-file if it is there +If the custom variables are not inside ~init.el~, they are not loaded. #+BEGIN_SRC emacs-lisp (when (file-exists-p custom-file) @@ -220,7 +218,7 @@ use a tiny script for it. You can install the generated emc script by doing #+BEGIN_SRC sh :tangle no - install -Dm755 -t /usr/local/bin emc + install -Dm755 -t ~/.local/bin emc #+END_SRC #+BEGIN_SRC emacs-lisp @@ -229,6 +227,23 @@ You can install the generated emc script by doing (server-start)) #+END_SRC +** cheatsheet +This is the program I am using to track individual keybindings. We want +this to be loaded as one of the first packages + +#+BEGIN_SRC emacs-lisp + (use-package cheatsheet + :straight t + :bind ("C-c s" . cheatsheet-show) + :config + (cheatsheet-add-group 'Common + '(:key "C-x C-c" :description "leave Emacs") + '(:key "C-x C-f" :description "find file") + '(:key "C-x d" :description "dired")) + (cheatsheet-add-group 'Cheatsheet + '(:key "C-c s" :description "Open the cheatsheet buffer") + '(:key "C-q" :description "exit the cheatsheet buffer"))) +#+END_SRC * Packages Now we can continue by loading our packages, those are listed according @@ -288,8 +303,8 @@ the [[Attribution]] section. :straight org-plus-contrib :functions org-babel-tangle :after evil - :bind (("C-c l" . org-store-link) - ("C-c a" . org-agenda) + :bind (("C-c l" . org-store-link) ;; See the cheatsheet configuration + ("C-c a" . org-agenda) ;; if you change the bindings ("C-c c" . org-capture)) :custom (org-directory "~/Org/") @@ -332,7 +347,17 @@ the [[Attribution]] section. ("PHONE" :foreground "spring green" :weight bold)))) (org-export-backends (quote - (ascii beamer html latex man md groff)))) + (ascii beamer html latex man md groff))) + :config + (cheatsheet-add-group '"Org-mode Global" + '(:key "C-c a" :description "open org-agenda") + '(:key "C-c c" :description "open the org-capture buffer") + '(:key "C-c c" :description "org store link") + '(:key "C-c C-w" :description "refile the current header")) + (cheatsheet-add-group 'Org-mode + '(:key "C-c C-e" :description "org-export") + '(:key "C-c C-o" :description "follow link")) + ) #+END_SRC @@ -363,7 +388,18 @@ along with it. #+BEGIN_SRC emacs-lisp (use-package magit :straight t - :bind ("C-x g" . magit-status)) + :bind ("C-x g" . magit-status) + :config + (cheatsheet-add-group 'Magit + '(:key "C-x g" :description "open Magit status buffer") + '(:key "s" :description "stage object on point (can be file or hunk)") + '(:key "u" :description "unstage object on point (can be file or hunk)") + '(:key "c c" :description "commit") + '(:key "P u" :description "push to upstream") + '(:key "F u" :description "pull from upstream") + '(:key "w" :description "Apply patches") + '(:key "W" :description "Create patches")) + ) #+END_SRC *** evil-magit @@ -394,7 +430,13 @@ hacky and buggy on Vim. #+BEGIN_SRC emacs-lisp (use-package flycheck :straight t - :config (global-flycheck-mode)) + :config + (global-flycheck-mode) + (cheatsheet-add-group '"Syntax Checking" + '(:key "C-c ! n" :description "navigate to the next error") + '(:key "C-c ! p" :description "navigate to the previous error") + '(:key "C-c ! l" :description "list flycheck errors")) + ) #+END_SRC ** Company Mode @@ -428,7 +470,7 @@ far as I can wrap my head-around. Mingus is an [[https://musicpd.org][MPD]] client for the Emacs operating system. It has a rather simple, straightforward interface. #+BEGIN_SRC emacs-lisp - (use-package mingus + (use-package mingus :straight t :bind ("C-c m" . mingus)) #+END_SRC @@ -437,14 +479,28 @@ simple, straightforward interface. (use-package projectile :straight t :bind-keymap ("C-c p" . projectile-command-map) - :config (projectile-mode +1)) + :config (projectile-mode +1) + (cheatsheet-add-group 'Projectile + '(:key "C-c p" :description "projectile prefix") + '(:key "C-c p f" :description "find file in project") + '(:key "C-c p p" :description "switch to project") + '(:key "C-c p c" :description "compile project") + '(:key "C-c p d" :description "dired in project") + '(:key "C-c p s g" :description "grep in project")) + ) #+END_SRC ** Treemacs #+BEGIN_SRC emacs-lisp (use-package treemacs :straight t :bind ("C-c t" . treemacs) - :custom (treemacs-no-png-images t)) + :custom (treemacs-no-png-images t) + :config + (cheatsheet-add-group 'Treemacs + '(:key "C-c t" :description "open treemacs") + '(:key "C-c C-p a" :description "select a new project to add to the treemacs workspace") + '(:key "C-c C-p d" :description "remove project at point from the workspace")) + ) (use-package treemacs-evil :straight t @@ -497,7 +553,8 @@ the other lines. :custom (linum-relative-current-symbol "") (display-line-numbers-type 'visual) - :hook (prog-mode . display-line-numbers-mode)) + :hook (prog-mode . display-line-numbers-mode) + :config (cheatsheet-add :group "Common" :key "C-c r" :description "toggle line numbers")) #+END_SRC *** markdown-mode @@ -673,6 +730,13 @@ Here are two paste-thingies that I use. I got the first code from (interactive) (message "pushing buffer to server...") (shell-command-on-region (point-min) (point-max) (concat "pastesrv " (read-string "Enter file name (optional): ")))) + + (global-set-key (kbd "C-x p r") 'region-to-srv) + (global-set-key (kbd "C-x p b") 'buffer-to-srv) + + (cheatsheet-add-group 'Common + '(:key "C-x p r" :description "Push the current region to server") + '(:key "C-x p b" :description "Push the buffer to server")) #+END_SRC *** Pastesrv This is the simple shell script I use to paste to my server. It @@ -693,6 +757,26 @@ a shell function so that I can use it with Emacs. #+BEGIN_SRC emacs-lisp (autoload 'notmuch "notmuch" "notmuch mail" t) #+END_SRC +** Tangle Init + +To load init.el properly we run a function such as this. This +function generates init.el from the source blocks inside this +file using ~org-babel-tangle~ and byte compiles it into ~init.elc~. +After defining the function, we add an ~after-save-hook~ so +that the file is generated everytime we save init.org. + +#+BEGIN_SRC emacs-lisp + (defun tangle-init () + "Tangles the init.org file, and byte compiles it." + (when (equal (buffer-file-name) + (expand-file-name (concat user-emacs-directory "init.org"))) + (let ((prog-mode-hook nil)) + (org-babel-tangle) + (byte-compile-file (concat user-emacs-directory "init.el"))))) + + (add-hook 'after-save-hook 'tangle-init) +#+END_SRC + * Other Settings Those are small settings for emacs that I cannot categorize but have importance