~long lines -> auto-fill-mode

In my config.org, and from now on in all text documents, auto fill
mode will be employed. I've added a text-mode-hook for auto-fill-mode.

I've found difficulty in handling long lines through truncate lines,
which doesn't have full control over movement in lines that run over
the terminal width. I've had to use '$' or move-end-of-line to move to
a point which visually should just require next-line to move to.

This inconsistency between visuals and movement is very frustrating
and abrupt when it occurs. Though auto fill mode has its own issues
(sets all text to 80 characters, which can be annoying in terms of
version control) it is far better than any other solution that I can
find.
This commit is contained in:
2020-08-09 14:10:17 +01:00
parent 1f4e7245c9
commit 229647da08

View File

@@ -20,13 +20,15 @@ Bootstrap of straight (from github)
(load bootstrap-file nil 'nomessage)) (load bootstrap-file nil 'nomessage))
#+END_SRC #+END_SRC
** Setup use package ** Setup use package
Straight clone use-package and state that all use-package statements implicity use straight. Straight clone use-package and state that all use-package statements
implicity use straight.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(straight-use-package 'use-package) (straight-use-package 'use-package)
(setq straight-use-package-by-default t) (setq straight-use-package-by-default t)
#+END_SRC #+END_SRC
** Setup alpha and yes-or-no-p ** Setup alpha and yes-or-no-p
This just sets the alpha to 85% and all yes or no questions to single letter responses. This just sets the alpha to 85% and all yes or no questions to single
letter responses.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(add-to-list 'default-frame-alist '(alpha . 85)) (add-to-list 'default-frame-alist '(alpha . 85))
(fset 'yes-or-no-p 'y-or-n-p) (fset 'yes-or-no-p 'y-or-n-p)
@@ -37,7 +39,8 @@ Turn on hs minor mode for all prog-mode.
(add-hook 'prog-mode-hook #'hs-minor-mode) (add-hook 'prog-mode-hook #'hs-minor-mode)
#+END_SRC #+END_SRC
** Set backup directory ** Set backup directory
Set the backup directory to =user-emacs-directory=/saves so I don't get those annoying '~' files. Set the backup directory to =user-emacs-directory=/saves so I don't
get those annoying '~' files.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(setq backup-directory-alist `(("." . "~/.config/emacs/saves"))) (setq backup-directory-alist `(("." . "~/.config/emacs/saves")))
#+END_SRC #+END_SRC
@@ -57,19 +60,29 @@ Load my custom "Grayscale" theme (look at [[file:Grayscale-theme.el][this file]]
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(setq inhibit-startup-screen t) (setq inhibit-startup-screen t)
#+END_SRC #+END_SRC
** Set auto-fill-mode for all text-modes
Auto fill mode is nice for most text modes, 80 char limit is great.
#+BEGIN_SRC emacs-lisp
(add-hook 'text-mode-hook #'auto-fill-mode)
#+END_SRC
* Emacs Mode-line * Emacs Mode-line
Firstly, declare a variable for the number of spaces between each module in the modeline. Firstly, declare a variable for the number of spaces between each
module in the modeline.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defconst +modeline/sep-spaces 4 "Number of spaces separating modules.") (defconst +modeline/sep-spaces 4 "Number of spaces separating modules.")
#+END_SRC #+END_SRC
Then, declare a list of reserved characters for which the previously declared seperator won't be applied when placed at the end of a module string. Then, declare a list of reserved characters for which the previously
declared seperator won't be applied when placed at the end of a module
string.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defconst +modeline/reserved-chars (list "[" "(") (defconst +modeline/reserved-chars (list "[" "(")
"Characters that, when at the end of a module string, won't have the separator applied to them.") "Characters that, when at the end of a module string, won't have the separator applied to them.")
#+END_SRC #+END_SRC
Now declare a function that applies the separator with respect to the reserved characters to any one string. Now declare a function that applies the separator with respect to the
reserved characters to any one string.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defun +modeline/handle-string (STR) (defun +modeline/handle-string (STR)
(condition-case nil (condition-case nil
@@ -102,13 +115,20 @@ Finally, set the mode-line-format.
* Custom Functions * Custom Functions
These are custom functions I have defined These are custom functions I have defined
** New line function ** New line function
Vim bindings don't have a nice way of adding new lines before or after the current line while staying in normal mode. Vim bindings don't have a nice way of adding new lines before or after
You can use =o/O= to enter insert mode at a new line, but this isn't the same as being able to stay in normal mode, and only adds extra keypresses if your only purpose was to open up some lines. the current line while staying in normal mode. You can use =o/O= to
As this is Emacs I can extend it as I wish, so I decided to define a new line function that won't remove me from normal state. enter insert mode at a new line, but this isn't the same as being able
to stay in normal mode while opening newlines and only adds extra
keypresses if your only purpose was to open up some lines.
As this is Emacs I can extend it as I wish, so I decided to define a
new line function that won't remove me from normal state.
The logic is pretty simple: The logic is pretty simple:
- Use the predefined vim functions for opening new lines above and below with insert mode - Use the predefined vim functions for opening new lines above and
- Given the argument =BACKWARD= to assess whether to open lines above or below below with insert mode
- Given the argument =BACKWARD= to assess whether to open lines
above or below
- Return to previous location - Return to previous location
- Enter normal state - Enter normal state
@@ -137,7 +157,9 @@ Steps are as follows:
(start-process-shell-command "" nil (format "cd %s; ctags -Re ." root)))) (start-process-shell-command "" nil (format "cd %s; ctags -Re ." root))))
#+END_SRC #+END_SRC
* General * General
Setup general, a good package for defining keys. Setup general, a good package for defining keys. In this case, I
generate a new definer for the "LEADER" keys. Leader is bound to SPC
and it's functionally equivalent the doom/spacemacs leader.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package general (use-package general
:config :config
@@ -176,8 +198,8 @@ Setup general, a good package for defining keys.
#+END_SRC #+END_SRC
* Evil * Evil
** Evil default ** Evil default
Setup the evil package, with some basic keybinds. Setup the evil package, with some basic keybinds. Also declare a
Also declare a leader-map at "SPC". leader-map at "SPC".
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package evil (use-package evil
:init :init
@@ -209,10 +231,13 @@ Also declare a leader-map at "SPC".
(evil-commentary-mode)) (evil-commentary-mode))
#+END_SRC #+END_SRC
** Evil mc ** Evil mc
Setup for multicursors in Evil mode. Setup for multicursors in Evil mode. Don't let evil-mc setup it's own
Don't let evil-mc setup it's own keymap because it uses 'gr' as its prefix, which I don't like. keymap because it uses 'gr' as its prefix, which I don't like.
Instead, bind some useful functions to my personal =dx:evil-mc-map= which is bound to 'gz'.
Furthermore, define a function =dx:evil-mc-cursor-here= which pauses cursors upon placing a cursor at the current position. Instead, bind some useful functions to my personal =dx:evil-mc-map=
which is bound to 'gz'. Furthermore, define a function
=dx:evil-mc-cursor-here= which pauses cursors upon placing a cursor at
the current position.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package evil-mc (use-package evil-mc
:after evil :after evil
@@ -239,20 +264,22 @@ Furthermore, define a function =dx:evil-mc-cursor-here= which pauses cursors upo
(evil-mc-pause-cursors))) (evil-mc-pause-cursors)))
#+END_SRC #+END_SRC
** Evil collection ** Evil collection
Setup evil collection, but don't turn on the mode. Setup evil collection, but don't turn on the mode. Instead, I'll turn
Instead, I'll turn on setups for specific modes I think benefit from it. on setups for specific modes I think benefit from it.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package evil-collection (use-package evil-collection
:after evil) :after evil)
#+END_SRC #+END_SRC
* Ivy * Ivy
Ivy is a completion framework for Emacs, and my preferred (sometimes second favourite) one. Ivy is a completion framework for Emacs, and my preferred (sometimes
It has a great set of features with little to no pain with setting up. second favourite) one. It has a great set of features with little to
no pain with setting up.
** Ivy ** Ivy
Setup for ivy, in preparation for counsel. Setup for ivy, in preparation for counsel. Turn on ivy-mode just
Turn on ivy-mode just after init. after init.
Setup vim-like bindings for the minibuffer ("C-(j|k)" for down|up the selection list)
Also setup evil-collection for ivy. Setup vim-like bindings for the minibuffer ("C-(j|k)" for down|up the
selection list). Also setup evil-collection for ivy.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package ivy (use-package ivy
:hook (after-init . ivy-mode) :hook (after-init . ivy-mode)
@@ -279,15 +306,15 @@ Also setup evil-collection for ivy.
(evil-collection-ivy-setup)) (evil-collection-ivy-setup))
#+END_SRC #+END_SRC
** Counsel ** Counsel
Setup for counsel. Setup for counsel. Load after ivy and helpful.
Load after ivy and helpful.
Bind: Bind:
- Swiper to "C-s" - Swiper to "C-s"
- Switch buffer to "C-x b" - Switch buffer to "C-x b"
- Counsel ripgrep to "M-s r" (search namespace) - Counsel ripgrep to "M-s r" (search namespace)
Along with that, set the help function and variable functions to their helpful counterparts. Along with that, set the help function and variable functions to their
helpful counterparts.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package counsel (use-package counsel
:defer t :defer t
@@ -310,8 +337,10 @@ Along with that, set the help function and variable functions to their helpful c
counsel-describe-variable-function #'helpful-variable)) counsel-describe-variable-function #'helpful-variable))
#+END_SRC #+END_SRC
** Counsel etags ** Counsel etags
Counsel etags allows me to search generated tag files for tags. Counsel etags allows me to search generated tag files for tags. I
I already have a function defined [[*Generate tags][here]] to generate the tags, so it's just searching them which I find to be a bit of a hassle, and where this package comes in. already have a function defined to generate the tags, so it's just
searching them which I find to be a bit of a hassle, and where this
package comes in.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package counsel-etags (use-package counsel-etags
:after counsel :after counsel
@@ -330,8 +359,8 @@ Setup avy with leader.
"g" #'avy-goto-char-2)) "g" #'avy-goto-char-2))
#+END_SRC #+END_SRC
* Projectile * Projectile
Setup projectile, along with the tags command. Setup projectile, along with the tags command. Also bind "C-c C-p" to
Also bind "C-c C-p" to the projectile command map for quick access. the projectile command map for quick access.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package projectile (use-package projectile
:after evil :after evil
@@ -387,11 +416,13 @@ Counsel projectile provides the ivy interface to projectile commands, which is r
#+END_SRC #+END_SRC
* Dired * Dired
Setup for dired. Setup for dired. Firstly, as it's an inbuilt package don't let
Firstly, as it's an inbuilt package don't let straight try and download it. straight try and download it. Make dired-hide-details-mode the
Make dired-hide-details-mode the default mode when dired-mode, as it removes the clutter. default mode when dired-mode, as it removes the clutter. Create a
Create a keymap =dx:dired-map= which is bound to the prefix "C-c d", binding useful dired functions. keymap =dx:dired-map= which is bound to the prefix "C-c d", binding
Setup evil collection for dired (even though dired doesn't really conflict with evil, there are some black corners I'd like to adjust) useful dired functions. Setup evil collection for dired (even though
dired doesn't really conflict with evil, there are some black corners
I'd like to adjust)
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package dired (use-package dired
:straight nil :straight nil
@@ -408,6 +439,7 @@ Setup evil collection for dired (even though dired doesn't really conflict with
#+END_SRC #+END_SRC
* Hydra * Hydra
Use hydras for stuff that I use often, currently buffer manipulation Use hydras for stuff that I use often, currently buffer manipulation
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package hydra (use-package hydra
:after evil :after evil
@@ -462,8 +494,9 @@ Pretty simple, just activate after init.
:hook (after-init . which-key-mode)) :hook (after-init . which-key-mode))
#+END_SRC #+END_SRC
* Yasnippet * Yasnippet
Yasnippet is a great package for snippets, which I use heavily in programming and org-mode. Yasnippet is a great package for snippets, which I use heavily in
I setup here the global mode for yasnippet and a collection of snippets for ease of use. programming and org-mode. I setup here the global mode for yasnippet
and a collection of snippets for ease of use.
** Yasnippet default ** Yasnippet default
Setup global mode after evil mode has been loaded Setup global mode after evil mode has been loaded
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@@ -489,8 +522,8 @@ Collection of snippets, activate after yasnippet has been loaded.
(yatemplate-fill-alist)) (yatemplate-fill-alist))
#+END_SRC #+END_SRC
* Keychord * Keychord
Keychord is only really here for this one chord I wish to define: "jk" for exiting insert state. Keychord is only really here for this one chord I wish to define: "jk"
Otherwise, I don't really need it. for exiting insert state. Otherwise, I don't really need it.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package key-chord (use-package key-chord
:after evil :after evil
@@ -499,8 +532,10 @@ Otherwise, I don't really need it.
(key-chord-mode +1)) (key-chord-mode +1))
#+END_SRC #+END_SRC
* Ripgrep * Ripgrep
The ripgrep package provides utilities to grep projects and files for strings via the rg tool. The ripgrep package provides utilities to grep projects and files for
Though [[*Ivy][ivy]] comes with =counsel-rg= using it makes me dependent on the ivy framework, and this configuration is intentionally built to be modular and switchable. strings via the rg tool. Though [[*Ivy][ivy]] comes with =counsel-rg= using it
makes me dependent on the ivy framework, and this configuration is
intentionally built to be modular and switchable.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package rg (use-package rg
:after evil :after evil
@@ -519,9 +554,11 @@ Though [[*Ivy][ivy]] comes with =counsel-rg= using it makes me dependent on the
rg-default-alias-fallback "all")) rg-default-alias-fallback "all"))
#+END_SRC #+END_SRC
* Magit * Magit
Magit is *the* git porcelain for Emacs, which perfectly encapsulates the git cli. Magit is *the* git porcelain for Emacs, which perfectly encapsulates
In this case, I just need to setup the bindings for it. the git cli. In this case, I just need to setup the bindings for it.
As magit will definitely load after evil (as it must be run by a binding, and evil will load after init), I can use evil-collection freely. As magit will definitely load after evil (as it must be run by a
binding, and evil will load after init), I can use evil-collection
freely.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package magit (use-package magit
:general :general
@@ -531,9 +568,9 @@ As magit will definitely load after evil (as it must be run by a binding, and ev
:after magit) :after magit)
#+END_SRC #+END_SRC
* Company * Company
Company is the auto complete system I use. Company is the auto complete system I use. I don't like having heavy
I don't like having heavy setups for company, as it only makes it worse to use. setups for company, as it only makes it worse to use. In this case,
In this case, just setup some evil binds for company just setup some evil binds for company
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package company (use-package company
:hook (prog-mode . company-mode) :hook (prog-mode . company-mode)
@@ -543,9 +580,10 @@ In this case, just setup some evil binds for company
("M-k" . company-select-previous))) ("M-k" . company-select-previous)))
#+END_SRC #+END_SRC
* Elfeed * Elfeed
Elfeed is the perfect RSS feed reader, integrated into Emacs perfectly. Elfeed is the perfect RSS feed reader, integrated into Emacs
I've got a set of feeds that I use for a large variety of stuff, mostly media and entertainment. perfectly. I've got a set of feeds that I use for a large variety of
I've also bound "C-c r" to elfeed for loading the system. stuff, mostly media and entertainment. I've also bound "C-c r" to
elfeed for loading the system.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package elfeed (use-package elfeed
:general :general
@@ -578,8 +616,10 @@ I've also bound "C-c r" to elfeed for loading the system.
#+END_SRC #+END_SRC
* Org mode * Org mode
** Org default with evil ** Org default with evil
Setup for org mode, currently basically nothing. Setup for org mode, currently basically nothing. Has evil-org for
Has evil-org for evil bindings. evil bindings.
Also setup a lot of variables, particularly for latex exports.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package org (use-package org
:hook (org-mode . yas-minor-mode) :hook (org-mode . yas-minor-mode)
@@ -637,9 +677,10 @@ Has evil-org for evil bindings.
("C-c C-a" . flyspell-correct-at-point))) ("C-c C-a" . flyspell-correct-at-point)))
#+END_SRC #+END_SRC
* Window management * Window management
Window management is really important. Window management is really important. I find the default window
I find the default window handling of Emacs incredibly annoying: sometimes consuming my windows, sometimes creating new ones. handling of Emacs incredibly annoying: sometimes consuming my windows,
So, as Emacs is the ultimate editor, I want to configure and fine tune the window management of Emacs. sometimes creating new ones. So, as Emacs is the ultimate editor, I
want to configure and fine tune the window management of Emacs.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(setq display-buffer-alist (setq display-buffer-alist
'(("\\*e?shell\\*" '(("\\*e?shell\\*"
@@ -692,10 +733,11 @@ So, as Emacs is the ultimate editor, I want to configure and fine tune the windo
)) ))
#+END_SRC #+END_SRC
* Major modes and Programming * Major modes and Programming
Setups for common major modes and languages Setups for common major modes and languages. Here are some basic
Here are some basic packages for programming first packages for programming first
** Smartparens ** Smartparens
Smartparens is a smarter electric-parens, it's much more aware of stuff and easier to use. Smartparens is a smarter electric-parens, it's much more aware of
stuff and easier to use.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package smartparens (use-package smartparens
:hook (prog-mode . smartparens-mode) :hook (prog-mode . smartparens-mode)
@@ -726,10 +768,10 @@ Show parenthesis for Emacs
(use-package eldoc-box (use-package eldoc-box
:hook (eldoc-mode . eldoc-box-hover-mode)) :hook (eldoc-mode . eldoc-box-hover-mode))
#+END_SRC #+END_SRC
** Eglot ** Eglot
Eglot is a library of packages to communicate with LSP servers for better programming capabilities. Eglot is a library of packages to communicate with LSP servers for
Interactions with a server provide results to the client, done through JSON. better programming capabilities. Interactions with a server provide
results to the client, done through JSON.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package eglot (use-package eglot
:hook (c++-mode . eglot-ensure) :hook (c++-mode . eglot-ensure)
@@ -747,8 +789,10 @@ Interactions with a server provide results to the client, done through JSON.
(add-to-list 'eglot-server-programs '((c-mode c++-mode) "clangd"))) (add-to-list 'eglot-server-programs '((c-mode c++-mode) "clangd")))
#+END_SRC #+END_SRC
** Flycheck ** Flycheck
Flycheck is the checking system for Emacs. Flycheck is the checking system for Emacs. I don't necessarily like
I don't necessarily like having all my code checked all the time, so I haven't added a hook to prog-mode as it would be better for me to decide when I want checking and when I don't. having all my code checked all the time, so I haven't added a hook to
prog-mode as it would be better for me to decide when I want checking
and when I don't.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package flycheck (use-package flycheck
:commands flycheck-mode :commands flycheck-mode
@@ -774,10 +818,22 @@ Add a function to activate tabs mode.
(setq indent-tabs-mode t)) (setq indent-tabs-mode t))
#+END_SRC #+END_SRC
** C/C++ ** C/C++
Setup for C and C++ modes via the cc-mode package. Setup for C and C++ modes via the cc-mode package. Firstly hook the C
Firstly hook the C and C++ modes to activate tabs. and C++ modes to activate tabs. Then set the offset to 2, and the
Then set the offset to 2, and the general style to user. general style to user. Finally, add a user style that mimics the
Finally, add a user style that mimics the Microsoft guidelines for C# (open braces everywhere). Microsoft guidelines for C# (open braces everywhere) because I've got
a lot of screen real estate and I like the newline brace folds more
than same line brace folds:
#+begin_example
if (cond) {...}
#+end_example
vs
#+begin_example
if (cond)
{....}
#+end_example
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package cc-mode (use-package cc-mode
:hook (c-mode . dx:activate-tabs) :hook (c-mode . dx:activate-tabs)
@@ -890,4 +946,3 @@ Lisp function does not specify a special indentation."
(funcall method indent-point state)))))))) (funcall method indent-point state))))))))
(add-hook 'emacs-lisp-mode-hook #'(lambda () (interactive) (setq-local lisp-indent-function #'+modded/lisp-indent-function)))) (add-hook 'emacs-lisp-mode-hook #'(lambda () (interactive) (setq-local lisp-indent-function #'+modded/lisp-indent-function))))
#+END_SRC #+END_SRC