New minor mode "lux/focus-mode" for better reading
This commit is contained in:
75
README.org
75
README.org
@@ -1,3 +1,4 @@
|
|||||||
|
it
|
||||||
#+TITLE: luxicks Emacs Configuration
|
#+TITLE: luxicks Emacs Configuration
|
||||||
This is my configuration for the emacs editor.
|
This is my configuration for the emacs editor.
|
||||||
|
|
||||||
@@ -8,24 +9,21 @@ Points of intrest:
|
|||||||
- When Exporting HTML from ~org-mode~ the style from the ~org-theme.css~ file is inlined automatically.
|
- When Exporting HTML from ~org-mode~ the style from the ~org-theme.css~ file is inlined automatically.
|
||||||
|
|
||||||
* Set Up use-package
|
* Set Up use-package
|
||||||
State that we will need package support and define a macro for adding package repos to the archives
|
Throughout this configuration I will use =use-package= to configure packages from melpa and other sources.
|
||||||
|
[[https://github.com/jwiegley/use-package][Link to GitHub page]]
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(require 'package)
|
;; Add melpa to the package repos
|
||||||
(defmacro append-to-list (target suffix)
|
(add-to-list 'package-archives
|
||||||
"Append SUFFIX to TARGET in place."
|
'("melpa" . "http://melpa.org/packages/"))
|
||||||
`(setq ,target (append ,target ,suffix)))
|
|
||||||
|
|
||||||
;; add to the package repos
|
|
||||||
(append-to-list package-archives
|
|
||||||
'(("melpa" . "http://melpa.org/packages/")))
|
|
||||||
(package-initialize)
|
(package-initialize)
|
||||||
|
|
||||||
|
;; Install use-package
|
||||||
(unless (package-installed-p 'use-package)
|
(unless (package-installed-p 'use-package)
|
||||||
(package-refresh-contents)
|
(package-refresh-contents)
|
||||||
(package-install 'use-package))
|
(package-install 'use-package))
|
||||||
|
|
||||||
(require 'use-package)
|
|
||||||
(setq use-package-always-ensure t)
|
(setq use-package-always-ensure t)
|
||||||
(use-package gnu-elpa-keyring-update)
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
Packages that are manually installed should be saved under =.emacs.d/packages=
|
Packages that are manually installed should be saved under =.emacs.d/packages=
|
||||||
@@ -77,6 +75,7 @@ Emacs sure loves to clutter directories with backup files.
|
|||||||
cursor-type 'bar
|
cursor-type 'bar
|
||||||
indent-tabs-mode nil
|
indent-tabs-mode nil
|
||||||
cursor-in-non-selected-windows nil)
|
cursor-in-non-selected-windows nil)
|
||||||
|
(blink-cursor-mode 0)
|
||||||
|
|
||||||
;; Default column with
|
;; Default column with
|
||||||
(set-fill-column 95)
|
(set-fill-column 95)
|
||||||
@@ -187,6 +186,49 @@ This custom version of =variable-pitch-mode= allows to mix variable and fixed fo
|
|||||||
(variable-pitch-mode -1))))
|
(variable-pitch-mode -1))))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
** Focused Mode
|
||||||
|
This is a special minor mode that allows focus reading of longer texts. It is a combination of other useful modes to create a distraction free reading environment.
|
||||||
|
|
||||||
|
This is a minor mode for keeping the cursor at the center of the screen while scrolling
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(setq-default scroll-preserve-screen-position t)
|
||||||
|
(setq-default scroll-conservatively 1)
|
||||||
|
(setq-default scroll-margin 0)
|
||||||
|
|
||||||
|
(define-minor-mode lux/center-scroll-mode
|
||||||
|
"Toggle centred cursor scrolling behaviour."
|
||||||
|
:init-value nil
|
||||||
|
:lighter " S="
|
||||||
|
:global nil
|
||||||
|
(if lux/center-scroll-mode
|
||||||
|
(setq-local scroll-margin (* (frame-height) 2)
|
||||||
|
scroll-conservatively 0
|
||||||
|
maximum-scroll-margin 0.5)
|
||||||
|
(dolist (local '(scroll-preserve-screen-position
|
||||||
|
scroll-conservatively
|
||||||
|
maximum-scroll-margin
|
||||||
|
scroll-margin))
|
||||||
|
(kill-local-variable `,local))))
|
||||||
|
|
||||||
|
(bind-key "C-c l" 'lux/center-scroll-mode)
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(define-minor-mode lux/focus-mode
|
||||||
|
"Creates a distraction free reading environment in the current buffer"
|
||||||
|
:init-value nil
|
||||||
|
:global nil
|
||||||
|
(if lux/focus-mode
|
||||||
|
(progn
|
||||||
|
(olivetti-mode 1)
|
||||||
|
(lux/center-scroll-mode 1))
|
||||||
|
(progn
|
||||||
|
(olivetti-mode -1)
|
||||||
|
(lux/center-scroll-mode -1))))
|
||||||
|
|
||||||
|
(bind-key "C-c o" 'lux/focus-mode)
|
||||||
|
#+end_src
|
||||||
|
|
||||||
* Fonts
|
* Fonts
|
||||||
Set up the fonts to use
|
Set up the fonts to use
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
@@ -701,18 +743,13 @@ A simple Emacs minor mode for a nice writing environment.
|
|||||||
[[https://github.com/rnkn/olivetti][Gihub Link]]
|
[[https://github.com/rnkn/olivetti][Gihub Link]]
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package olivetti
|
(use-package olivetti
|
||||||
|
:diminish
|
||||||
:config
|
:config
|
||||||
(setq-default
|
(setq olivetti-minimum-body-width 72)
|
||||||
olivetti-hide-mode-line t
|
(setq olivetti-body-width 0.65)
|
||||||
olivetti-body-width 90))
|
(setq olivetti-recall-visual-line-mode-entry-state t))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
Auto enable it in text modes
|
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
;; Do not use for now
|
|
||||||
;;(add-hook 'text-mode-hook 'olivetti-mode)
|
|
||||||
#+END_SRC
|
|
||||||
** Ag
|
** Ag
|
||||||
Ag.el allows you to search using ~ag~ from inside Emacs. You can filter by file type, edit results inline, or find files.
|
Ag.el allows you to search using ~ag~ from inside Emacs. You can filter by file type, edit results inline, or find files.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user