Move Emacs default settings to (almost) the top

This commit is contained in:
Gergely Polonkai 2023-10-15 06:51:45 +02:00
parent 224c12a060
commit cde06cd98d
No known key found for this signature in database
GPG Key ID: 2D2885533B869ED4
1 changed files with 106 additions and 108 deletions

View File

@ -669,14 +669,15 @@ From [[http://whattheemacsd.com/file-defuns.el-02.html][whattheemacsd.org]].
(message "File '%s' successfully removed" filename)))))
#+end_src
* Emacs configuration
* Set up the very basics
** Set up the really basic things
Now that we have package management configured we can set up defaults more easily. This includes every builtin packages, font faces, and the like.
#+begin_src emacs-lisp
(use-package emacs
:ensure nil
:init
;; Required for Consult/Vertico
(defun crm-indicator (args)
(cons (format "[CRM%s] %s"
(replace-regexp-in-string
@ -685,6 +686,11 @@ From [[http://whattheemacsd.com/file-defuns.el-02.html][whattheemacsd.org]].
(car args))
(cdr args)))
(advice-add #'completing-read-multiple :filter-args #'crm-indicator)
(setq frame-title-format '((:eval (concat system-name
": "
(if (buffer-file-name)
(abbreviate-file-name (buffer-file-name))
"%b")))))
:custom
(user-full-name "Gergely Polonkai")
(user-mail-address "gergely@polonkai.eu")
@ -700,7 +706,29 @@ From [[http://whattheemacsd.com/file-defuns.el-02.html][whattheemacsd.org]].
(minibuffer-setup . cursor-intangible-mode))
#+end_src
** Set up some default faces
** Set Orgs main directory
Since a lot of packages (org-projectile, org-caldav, etc.) rely on it, it needs to be set as early as possible.
#+begin_src emacs-lisp
(setq org-directory (expand-file-name "NextCloud/orgmode" user-documents-directory))
#+end_src
** Set up my personal keymap
I set it up at the beginning so i can use it with ~use-package~ invocations from early on
This might (should?) become a [[*general][general]] map later.
#+begin_src emacs-lisp
(defvar gpolonkai/pers-map (make-sparse-keymap)
"My own, personal, keymap!")
(define-prefix-command 'gpolonkai/pers-map)
(define-key ctl-x-map "t" 'gpolonkai/pers-map)
(define-key global-map (kbd "C-t") 'gpolonkai/pers-map)
#+end_src
** Set up some faces
#+begin_src emacs-lisp
(use-package faces
@ -710,7 +738,7 @@ From [[http://whattheemacsd.com/file-defuns.el-02.html][whattheemacsd.org]].
(trailing-whitespace ((t (:inherit nil :background "red3")))))
#+end_src
** Use ligatures
*** Fira Code comes with nice ligatures, lets use them!
#+begin_src emacs-lisp
(use-package ligature
@ -784,49 +812,40 @@ From [[http://whattheemacsd.com/file-defuns.el-02.html][whattheemacsd.org]].
(global-ligature-mode t))
#+end_src
** Set up my personal keymap
** Set the default font and configure font resizing
I set it up early so i can use it in ~use-package~ calls immediately.
Before this can be used, make sure the [[https://zhm.github.io/symbola/][Symbola]] font is installed.
#+BEGIN_SRC emacs-lisp
(defvar gpolonkai/pers-map (make-sparse-keymap)
"My own, personal, keymap!")
(define-prefix-command 'gpolonkai/pers-map)
(define-key ctl-x-map "t" 'gpolonkai/pers-map)
(define-key global-map (kbd "C-t") 'gpolonkai/pers-map)
#+END_SRC
#+begin_src emacs-lisp
(defun gpolonkai/set-font-size (frame)
(when (display-graphic-p frame)
(set-face-attribute 'default frame :font "Fira Code Retina-14")
(set-frame-font "Fira Code Retina-14" t (list frame))))
** I really dont want to type more than i really must…
(defun --set-emoji-font (frame)
"Adjust the font setting of FRAME so Emacs can display Emoji properly."
(when (display-graphic-p frame)
(set-fontset-font t 'symbol
(font-spec :family "Symbola")
frame 'prepend)
(set-fontset-font t 'unicode
"Noto Emoji"
nil 'append)))
#+BEGIN_SRC emacs-lisp
(defalias 'yes-or-no-p 'y-or-n-p)
#+END_SRC
(add-hook 'after-make-frame-functions 'gpolonkai/set-font-size)
(add-hook 'after-make-frame-functions '--set-emoji-font)
(gpolonkai/set-font-size nil)
(--set-emoji-font nil)
#+end_src
** Set UTF-8 as the default encoding
Just to make sure, although most Linux DEs do this for me.
#+BEGIN_SRC emacs-lisp
#+begin_src emacs-lisp
(set-language-environment "UTF-8")
(set-default-coding-systems 'utf-8)
#+END_SRC
** Set Orgs main directory
Since a lot of packages use it as their base (org-projectile, org-caldav, etc.), i need
it as early as possible.
#+BEGIN_SRC emacs-lisp
(setq org-directory (expand-file-name "NextCloud/orgmode" user-documents-directory))
#+END_SRC
** ~simple.el~ settings
#+begin_src emacs-lisp
(use-package simple
:ensure nil
:custom
(column-number-mode t))
#+end_src
** Default frame settings
@ -835,9 +854,60 @@ it as early as possible.
(use-package frame
:ensure nil
:custom
;; Make that cursor blink!
(blink-cursor-mode t))
#+end_src
** I really dont want to type more than i really must…
#+begin_src emacs-lisp
(defalias 'yes-or-no-p 'y-or-n-p)
#+end_src
** Tweak window chrome, AKA lets set up the UI
Turn off the scroll bar (thats why Nyan-cat is here), the toolbar (I dont really use it), and
the menu bar (I rarely use it, and in those rare occasions I can simply turn it on.)
Also, maximise the frame.
#+begin_src emacs-lisp
(tool-bar-mode 0)
(menu-bar-mode 0)
(when window-system
(scroll-bar-mode -1))
(set-frame-parameter nil 'fullscreen 'maximized)
#+end_src
** Enable all the commands!
These are disabled for a reason, but im a rockstar, so who cares‽
#+begin_src emacs-lisp
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'erase-buffer 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'narrow-to-page 'disabled nil)
(put 'set-goal-column 'disabled nil)
(put 'scroll-left 'disabled nil)
(put 'dired-find-alternate-file 'disabled nil)
(put 'Info-edit 'disabled nil)
(put 'list-timers 'disabled nil)
#+end_src
* Emacs configuration
** ~simple.el~ settings
#+begin_src emacs-lisp
(use-package simple
:ensure nil
:custom
(column-number-mode t))
#+end_src
* Custom commands and functions
** Frame manipulation
@ -961,51 +1031,6 @@ Lets see if i can get my brain more organised this way…
(org-roam-ui-open-on-start nil))
#+end_src
* UI preferences
** Tweak window chrome
Turn off the scroll bar (thats why Nyan-cat is here), the toolbar (I dont really use it), and
the menu bar (I rarely use it, and in those rare occasions I can simply turn it on.)
Also, maximise the frame.
#+BEGIN_SRC emacs-lisp
(tool-bar-mode 0)
(menu-bar-mode 0)
(when window-system
(scroll-bar-mode -1))
(set-frame-parameter nil 'fullscreen 'maximized)
#+END_SRC
** Set the default font and configure font resizing
Before this can be used, make sure the [[https://zhm.github.io/symbola/][Symbola]] font is installed.
#+BEGIN_SRC emacs-lisp
(defun gpolonkai/set-font-size (frame)
(when (display-graphic-p frame)
(set-face-attribute 'default frame :font "Fira Code Retina-14")
(set-frame-font "Fira Code Retina-14" t (list frame))))
(defun --set-emoji-font (frame)
"Adjust the font setting of FRAME so Emacs can display Emoji properly."
(when (display-graphic-p frame)
(set-fontset-font t 'symbol
(font-spec :family "Symbola")
frame 'prepend)
(set-fontset-font t 'unicode
"Noto Emoji"
nil 'append)))
(add-hook 'after-make-frame-functions 'gpolonkai/set-font-size)
(add-hook 'after-make-frame-functions '--set-emoji-font)
(gpolonkai/set-font-size nil)
(--set-emoji-font nil)
#+END_SRC
* Set up global minor modes provided by Emacs
** Pretty lambdas
@ -1028,39 +1053,12 @@ And set up all the pretty symbols.
("or" . ?)))
#+END_SRC
Finally, set the frame title to the current file name
#+BEGIN_SRC emacs-lisp
(setq frame-title-format '((:eval (concat system-name
": "
(if (buffer-file-name)
(abbreviate-file-name (buffer-file-name))
"%b")))))
#+END_SRC
** Treat soft line breaks as hard ones in textual modes
#+BEGIN_SRC emacs-lisp
(add-hook 'text-mode-hook (lambda () (visual-line-mode t)))
#+END_SRC
* Enable disabled commands
Because im a rock star like that.
#+BEGIN_SRC emacs-lisp
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'erase-buffer 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'narrow-to-page 'disabled nil)
(put 'set-goal-column 'disabled nil)
(put 'scroll-left 'disabled nil)
(put 'dired-find-alternate-file 'disabled nil)
(put 'Info-edit 'disabled nil)
(put 'list-timers 'disabled nil)
#+END_SRC
* Load some built-in libraries
** ~thingatpt~