Move basic settings from configuration.org to init.el

This commit is contained in:
Gergely Polonkai 2025-05-30 11:06:38 +02:00
parent 69549ce861
commit 9e5528e519
No known key found for this signature in database
GPG Key ID: 2D2885533B869ED4
2 changed files with 171 additions and 198 deletions

View File

@ -1,201 +1,3 @@
* Set up the very basics
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
#+end_src
** 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 "org-mode" 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
:ensure nil
:custom-face
(default ((t (:family "Fira Code Retina" :foundry "simp" :slant normal :weight normal :height 100 :width normal))))
(trailing-whitespace ((t (:inherit nil :background "red3")))))
#+end_src
*** Fira Code comes with nice ligatures, lets use them!
#+begin_src emacs-lisp
(use-package ligature
:config
;; Enable the "www" ligature in every possible major mode
(ligature-set-ligatures 't '("www"))
;; Enable traditional ligature support in eww-mode, if the
;; `variable-pitch' face supports it
(ligature-set-ligatures 'eww-mode '("ff" "fi" "ffi"))
;; Enable all Cascadia and Fira Code ligatures in programming modes
(ligature-set-ligatures 'prog-mode
'(;; == === ==== => =| =>>=>=|=>==>> ==< =/=//=// =~
;; =:= =!=
("=" (rx (+ (or ">" "<" "|" "/" "~" ":" "!" "="))))
;; ;; ;;;
(";" (rx (+ ";")))
;; && &&&
("&" (rx (+ "&")))
;; !! !!! !. !: !!. != !== !~
("!" (rx (+ (or "=" "!" "\." ":" "~"))))
;; ?? ??? ?: ?= ?.
("?" (rx (or ":" "=" "\." (+ "?"))))
;; %% %%%
("%" (rx (+ "%")))
;; |> ||> |||> ||||> |] |} || ||| |-> ||-||
;; |->>-||-<<-| |- |== ||=||
;; |==>>==<<==<=>==//==/=!==:===>
("|" (rx (+ (or ">" "<" "|" "/" ":" "!" "}" "\]"
"-" "=" ))))
;; \\ \\\ \/
("\\" (rx (or "/" (+ "\\"))))
;; ++ +++ ++++ +>
("+" (rx (or ">" (+ "+"))))
;; :: ::: :::: :> :< := :// ::=
(":" (rx (or ">" "<" "=" "//" ":=" (+ ":"))))
;; // /// //// /\ /* /> /===:===!=//===>>==>==/
("/" (rx (+ (or ">" "<" "|" "/" "\\" "\*" ":" "!"
"="))))
;; .. ... .... .= .- .? ..= ..<
("\." (rx (or "=" "-" "\?" "\.=" "\.<" (+ "\."))))
;; -- --- ---- -~ -> ->> -| -|->-->>->--<<-|
("-" (rx (+ (or ">" "<" "|" "~" "-"))))
;; *> */ *) ** *** ****
("*" (rx (or ">" "/" ")" (+ "*"))))
;; www wwww
("w" (rx (+ "w")))
;; <> <!-- <|> <: <~ <~> <~~ <+ <* <$ </ <+> <*>
;; <$> </> <| <|| <||| <|||| <- <-| <-<<-|-> <->>
;; <<-> <= <=> <<==<<==>=|=>==/==//=!==:=>
;; << <<< <<<<
("<" (rx (+ (or "\+" "\*" "\$" "<" ">" ":" "~" "!"
"-" "/" "|" "="))))
;; >: >- >>- >--|-> >>-|-> >= >== >>== >=|=:=>>
;; >> >>> >>>>
(">" (rx (+ (or ">" "<" "|" "/" ":" "=" "-"))))
;; #: #= #! #( #? #[ #{ #_ #_( ## ### #####
("#" (rx (or ":" "=" "!" "(" "\?" "\[" "{" "_(" "_"
(+ "#"))))
;; ~~ ~~~ ~= ~- ~@ ~> ~~>
("~" (rx (or ">" "=" "-" "@" "~>" (+ "~"))))
;; __ ___ ____ _|_ __|____|_
("_" (rx (+ (or "_" "|"))))
;; Fira code: 0xFF 0x12
("0" (rx (and "x" (+ (in "A-F" "a-f" "0-9")))))
;; Fira code:
"Fl" "Tl" "fi" "fj" "fl" "ft"
;; The few not covered by the regexps.
"{|" "[|" "]#" "(*" "}#" "$>" "^="))
;; Enables ligature checks globally in all buffers. You can also do it
;; per mode with `ligature-mode'.
(global-ligature-mode t))
#+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-10")
(set-frame-font "Fira Code Retina-10" 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 UTF-8 as the default encoding
Just to make sure, although most Linux DEs do this for me.
#+begin_src emacs-lisp
(set-language-environment "UTF-8")
(set-default-coding-systems 'utf-8)
#+end_src
** Default frame settings
#+begin_src emacs-lisp
(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
* Global built-in packages
** ~simple~, to always show the current column, and using visual lines in text modes

171
init.el
View File

@ -105,6 +105,177 @@ order."
:hook
(minibuffer-setup . cursor-intangible-mode))
;; Basic settings
;;
;; Now that we have package management configured we can set up defaults more
;; easily. This includes every builtin packages, font faces, and the like.
;; 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.
(setq org-directory (expand-file-name "~/Nextcloud/orgmode"))
;; Set up my personal keymap
(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)
;; Set up some faces
(use-package faces
:ensure nil
:custom-face
(default ((t (:family "Fira Code Retina" :foundry "simp" :slant normal :weight normal :height 100 :width normal))))
(trailing-whitespace ((t (:inherit nil :background "red3")))))
;; Fira Code comes with nice ligatures, lets use them!
(use-package ligature
:config
;; Enable the "www" ligature in every possible major mode
(ligature-set-ligatures 't '("www"))
;; Enable traditional ligature support in eww-mode, if the
;; `variable-pitch' face supports it
(ligature-set-ligatures 'eww-mode '("ff" "fi" "ffi"))
;; Enable all Cascadia and Fira Code ligatures in programming modes
(ligature-set-ligatures 'prog-mode
'(;; == === ==== => =| =>>=>=|=>==>> ==< =/=//=// =~
;; =:= =!=
("=" (rx (+ (or ">" "<" "|" "/" "~" ":" "!" "="))))
;; ;; ;;;
(";" (rx (+ ";")))
;; && &&&
("&" (rx (+ "&")))
;; !! !!! !. !: !!. != !== !~
("!" (rx (+ (or "=" "!" "\." ":" "~"))))
;; ?? ??? ?: ?= ?.
("?" (rx (or ":" "=" "\." (+ "?"))))
;; %% %%%
("%" (rx (+ "%")))
;; |> ||> |||> ||||> |] |} || ||| |-> ||-||
;; |->>-||-<<-| |- |== ||=||
;; |==>>==<<==<=>==//==/=!==:===>
("|" (rx (+ (or ">" "<" "|" "/" ":" "!" "}" "\]"
"-" "=" ))))
;; \\ \\\ \/
("\\" (rx (or "/" (+ "\\"))))
;; ++ +++ ++++ +>
("+" (rx (or ">" (+ "+"))))
;; :: ::: :::: :> :< := :// ::=
(":" (rx (or ">" "<" "=" "//" ":=" (+ ":"))))
;; // /// //// /\ /* /> /===:===!=//===>>==>==/
("/" (rx (+ (or ">" "<" "|" "/" "\\" "\*" ":" "!"
"="))))
;; .. ... .... .= .- .? ..= ..<
("\." (rx (or "=" "-" "\?" "\.=" "\.<" (+ "\."))))
;; -- --- ---- -~ -> ->> -| -|->-->>->--<<-|
("-" (rx (+ (or ">" "<" "|" "~" "-"))))
;; *> */ *) ** *** ****
("*" (rx (or ">" "/" ")" (+ "*"))))
;; www wwww
("w" (rx (+ "w")))
;; <> <!-- <|> <: <~ <~> <~~ <+ <* <$ </ <+> <*>
;; <$> </> <| <|| <||| <|||| <- <-| <-<<-|-> <->>
;; <<-> <= <=> <<==<<==>=|=>==/==//=!==:=>
;; << <<< <<<<
("<" (rx (+ (or "\+" "\*" "\$" "<" ">" ":" "~" "!"
"-" "/" "|" "="))))
;; >: >- >>- >--|-> >>-|-> >= >== >>== >=|=:=>>
;; >> >>> >>>>
(">" (rx (+ (or ">" "<" "|" "/" ":" "=" "-"))))
;; #: #= #! #( #? #[ #{ #_ #_( ## ### #####
("#" (rx (or ":" "=" "!" "(" "\?" "\[" "{" "_(" "_"
(+ "#"))))
;; ~~ ~~~ ~= ~- ~@ ~> ~~>
("~" (rx (or ">" "=" "-" "@" "~>" (+ "~"))))
;; __ ___ ____ _|_ __|____|_
("_" (rx (+ (or "_" "|"))))
;; Fira code: 0xFF 0x12
("0" (rx (and "x" (+ (in "A-F" "a-f" "0-9")))))
;; Fira code:
"Fl" "Tl" "fi" "fj" "fl" "ft"
;; The few not covered by the regexps.
"{|" "[|" "]#" "(*" "}#" "$>" "^="))
;; Enables ligature checks globally in all buffers. You can also do it
;; per mode with `ligature-mode'.
(global-ligature-mode t))
;; Set the default font and configure font resizing
;; Before this can be used, make sure the Symbola font
;; (https://zhm.github.io/symbola/) font is installed.
(defun gpolonkai/set-font-size (frame)
"Set default fonts and font sizes in FRAME."
(when (display-graphic-p frame)
(set-face-attribute 'default frame :font "Fira Code Retina-10")
(set-frame-font "Fira Code Retina-10" 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)
;; Set UTF-8 as the default encoding
(set-language-environment "UTF-8")
(set-default-coding-systems 'utf-8)
(use-package frame
:ensure nil
:custom
(blink-cursor-mode t))
;; I really dont want to type more than i really must…
(defalias 'yes-or-no-p 'y-or-n-p)
;; Tweak window chrome, AKA lets set up the UI!
;; Turn off the toolbar
(tool-bar-mode 0)
;; Turn off the menu bar
(menu-bar-mode 0)
;; If we are running in a graphical environment, turn off the scroll bar
;;
;; TODO: This is not done for every new frame!
(when window-system
(scroll-bar-mode -1))
;; Maximise newly created frames (AKA DE windows)
(set-frame-parameter nil 'fullscreen 'maximized)
;; Enable all the commands! These are disabled for a reason, but im a rockstar,
;; so who cares‽
;;
;; TODO: There must be a way to do it programatically
(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)
;; I started moving my configuration to this Org file. Its easier to document this way.
(org-babel-load-file (expand-file-name "configuration.org" user-emacs-directory))