better font configuration, added csv mode, and other minor improvements

This commit is contained in:
Ian Griffin 2024-10-15 18:37:45 +08:00
parent a7768782fe
commit 0e91b480dc
8 changed files with 154 additions and 84 deletions

View File

@ -12,7 +12,7 @@ Functions needed at the start of the configuration
* User Emacs Directories
set the directory for emacs and it's apps to put stuff.
#+begin_src emacs-lisp
(if (version< emacs-version "28")
(if (version< "28" emacs-version)
(setq user-emacs-directory
(expand-file-name "emacs" (safe-getenv "XDG_DATA_HOME" "~/.local/share"))))
#+end_src

View File

@ -20,7 +20,7 @@ this speeds up emacs startup
** Set Package Directory
#+begin_src emacs-lisp
(setq package-user-dir (expand-file-name "emacs/packages" (safe-getenv "XDG_DATA_HOME" "~/.local/share")))
(setq package-user-dir (expand-file-name "packages" user-emacs-directory))
#+end_src
** Add package sources

View File

@ -1,25 +1,81 @@
#+TITLE: Font Configuration
* Configuration
** default fonts
* set default fonts
#+begin_src emacs-lisp
(let ((default-family "Roboto Mono")
(variable-family "Inter"))
(custom-set-faces
;; set default font
'(default ((t (:inherit nil :extend nil :stipple nil
:inverse-video nil :box nil
:strike-through nil :overline nil :underline nil
:slant normal :weight normal
:height 100 :width normal
:foundry "CTDB" :family "Roboto Mono"))))
'(fixed-pitch ((t (:family "Roboto Mono"))))
'(fixed-pitch-serif ((t (:family "Roboto Mono"))))
'(variable-pitch ((t (:inherit default :weight regular :family "Inter")))))
;; set default font
`(default ((t (:inherit nil :extend nil :stipple nil
:inverse-video nil :box nil
:strike-through nil :overline nil :underline nil
:slant normal :weight normal
:height 100 :width normal
:family ,default-family))))
`(fixed-pitch ((t (:family ,default-family))))
`(fixed-pitch-serif ((t (:family ,default-family))))
`(variable-pitch ((t (:inherit default :weight regular :family ,variable-family))))))
#+end_src
** Chinese Font
* Font setter function
#+begin_src emacs-lisp
(defun set-face-attr-family (face font-families &optional attributes)
"Set FACE's font family to the first available font family from FONT-FAMILIES list,
and apply other ATTRIBUTES specified in the plist."
(when attributes
(while attributes
(let ((attr (pop attributes))
(value (pop attributes)))
(set-face-attribute face nil attr value))))
(let ((available-font (seq-find (lambda (font)
(find-font (font-spec :family font)))
font-families)))
(when available-font
;; Set the font family
(set-face-attribute face nil :family available-font)
;; Apply other attributes from the plist
(message "Set %s face to use font family: %s with attributes: %s"
face available-font attributes))))
#+end_src
* Set face family and attributes
#+begin_src emacs-lisp
(set-face-attr-family 'default
'("Roboto Mono" "Source Code Pro" "Fira Code" "Noto Sans Mono" "Cascadia Code" "SF Pro Mono" "fixed")
'(:inherit nil :extend nil :stipple nil
:inverse-video nil :box nil
:strike-through nil :overline nil :underline nil
:slant normal :weight normal
:height 100 :width normal))
(set-face-attr-family 'variable-pitch
'("Inter" "Cantarell" "Fira Sans" "Noto Sans" "Segoe UI" "SF Pro Display")
'(:inherit default :weight regular))
(set-face-attribute 'fixed-pitch nil :family (face-attribute 'default :family))
(set-face-attribute 'fixed-pitch-serif nil :family (face-attribute 'default :family))
(set-face-attribute 'fringe nil :background (face-background 'default))
(set-face-attribute 'line-number nil :background (face-background 'default))
(set-face-attribute 'line-number nil :foreground (face-foreground 'shadow))
#+end_src
* Chinese Font
#+begin_src emacs-lisp
;; (dolist (charset '(kana han symbol cjk-misc bopomofo))
;; (set-fontset-font (frame-parameter nil 'font)
;; charset (font-spec :family "Noto Sans Mono CJK TC Regular"
;; :size 10)))
#+end_src
* Font finder function
#+begin_src emacs-lisp
;; (defun find-available-font-family (font-families)
;; "Return the first available font family from FONT-FAMILIES list, or nil if none is found."
;; (seq-find (lambda (font)
;; (find-font (font-spec :family font)))
;; font-families))
#+end_src

View File

@ -36,13 +36,6 @@ run the function at startup of a frame
(add-hook 'before-make-frame-hook 'set-window-size)
#+end_src
* Fringes
Fringes are the small gap at the side of emacs.
#+BEGIN_SRC emacs-lisp
(fringe-mode '(12 . 6))
#+END_SRC
* 80 Column Line with fill-column-indicator
#+begin_src emacs-lisp
(when (> emacs-major-version 27)
@ -67,46 +60,36 @@ sets the tab size 5 spaces
c-basic-offset custom-tab-size))
#+end_src
* Line numbers
Turn on line numbers in text mode/code modes.
~this part is not fully working~
#+BEGIN_SRC emacs-lisp
(add-hook 'term-mode-hook (lambda () (display-line-numbers-mode -1)))
(add-hook 'text-mode-hook 'display-line-numbers-mode)
(add-hook 'emacs-lisp-mode-hook 'display-line-numbers-mode)
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
#+END_SRC
* Line Highlight
Highlights the current line
#+begin_src emacs-lisp
(global-hl-line-mode 1)
#+end_src
* Indentation guides
#+begin_src emacs-lisp
(use-package highlight-indent-guides
:hook (prog-mode . highlight-indent-guides-mode))
;; :custom
;; (highlight-indent-guides-method 'character "set the guide style to a bitmap picture")
;; (highlight-indent-guides-character "│" "set the guide character to a horizontal line")
;; (highlight-indent-guides-auto-enabled nil)
;; :config
;; (set-face-foreground 'highlight-indent-guides-character-face (face-foreground 'fill-column-indicator)))
#+end_src
* Matching Pairs
** Highlight
highlight matching pairs of parenthesis, and other characters
#+BEGIN_SRC emacs-lisp
(show-paren-mode 1)
#+END_SRC
highlight matching pairs of parenthesis, and other characters
#+begin_src emacs-lisp
(show-paren-mode 1)
#+end_src
** Electric-pair-mode
Automatically pair parentheses, and other characters, built in on emacs
#+BEGIN_SRC emacs-lisp
(electric-pair-mode 1)
#+END_SRC
#+begin_src emacs-lisp
(electric-pair-mode 1)
#+end_src
* Clock/Time in Modeline
currently unused
@ -159,8 +142,23 @@ Load theme (that is built-in)
#+end_src
* Fringes
Fringes are the small gap at the side of emacs.
#+begin_src emacs-lisp
(fringe-mode '(12 . 6))
#+end_src
* Line numbers
Turn on line numbers in text mode/code modes.
#+begin_src emacs-lisp
(add-hook 'term-mode-hook (lambda () (display-line-numbers-mode -1)))
(add-hook 'text-mode-hook 'display-line-numbers-mode)
(add-hook 'emacs-lisp-mode-hook 'display-line-numbers-mode)
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
#+end_src
* Welcome Screen
Having a blank screen at the start is much more simpler and better
Having a blank screen at the start is much more simpler and better
#+begin_src emacs-lisp
(setq inhibit-startup-screen t)
#+end_src

View File

@ -29,7 +29,7 @@ Tell gnus to read ~gnus.el~ from the config dir.
other configuration on gnus is on the ~gnus.el~ file.
* RMail Config
Even though Gnus is used as the main E-Mail reader, Rmail is also setup as a backup mail reader incase gnus became unusable
Even though Gnus is used as the main E-Mail reader, Rmail is also setup as a redundant mail reader.
** Dependencies
Since RMail is only a Mail Reader, E-Mails needs to be fetched using external programs.

View File

@ -1,16 +0,0 @@
#+TITLE: PDF-Tools Configuration
* Intro
*PDF-Tools* is a emacs package that provides better PDF support to emacs.
It is faster, and less resource intensive compared to Emacs' PDFView mode
#+begin_src emacs-lisp
(use-package pdf-tools
;; :hook "\\.pdf\\'"
:config
(pdf-loader-install)
:hook
(pdf-major-mode . (lambda () (fringe-mode 0)))
(pdf-outline-buffer-mode . (lambda ()
(display-line-numbers-mode -1))))
#+end_src

View File

@ -16,7 +16,7 @@
* Built-in Modes
** hook default settings to configured language modes
#+begin_src emacs-lisp
(let ((langs '("sh" "c++" "go-ts" "java" "js" "json" "LaTeX" "mhtml" "python" "typescript-ts" "tsx-ts")))
(let ((langs '("sh" "c++" "go-ts" "java" "js" "json" "LaTeX" "mhtml" "python" "typescript-ts" "tsx-ts" "python-ts")))
(dolist (lang langs)
(add-hook (intern (concat lang "-mode-hook")) 'lang-default-settings)))
#+end_src
@ -72,8 +72,7 @@ No longer using typescript-mode, as there's a builtin typescript-ts mode in Emac
#+begin_src emacs-lisp
(use-package markdown-mode
:commands (markdown-mode gfm-mode)
:mode (("\\.md\\'". markdown-mode)
("\\.markdown\\'" . markdown-mode))
:mode ("\\.md\\'" "\\.markdown\\'")
:custom ((markdown-command "multimarkdown" "set the markdown command")))
#+end_src
@ -113,14 +112,10 @@ python venv manager
*** Jupyter
#+begin_src emacs-lisp
(use-package ein
:commands (ein:run ein:notebook-open ein:login)
:bind ("C-c C-o" . ein:notebook-open)
:config
(add-to-list 'org-babel-load-languages '(ein . t))
:bind
("C-c C-o" . ein:notebook-open)
:commands
ein:run
ein:notebook-open
ein:login)
(add-to-list 'org-babel-load-languages '(ein . t)))
;; :custom
;; (ein:jupyter-server-use-subcommand "server" "use jupyterlab instead of jupyter notebook")
#+end_src
@ -137,3 +132,12 @@ Python code is recomendded to set the tab size to 4
c-basic-offset custom-tab-size))))
#+end_src
* CSV-mode
#+begin_src emacs-lisp
(use-package csv-mode
:pin "gnu"
:commands (csv-mode csv-align-mode csv-field-index-mode)
:mode (("\\.csv\\'" . csv-align-mode) ("\\.tsv\\'" . csv-align-mode))
:custom (csv-invisibility-default nil "show separators when records are aligned"))
#+end_src

View File

@ -7,11 +7,12 @@
Ido is a autocomplete package for emacs' commands
#+begin_src emacs-lisp
(use-package ido
:config
(setq ido-everywhere t
ido-virtual-buffers t
ido-use-faces t)
(ido-mode 1))
:custom
(ido-virtual-buffers t)
(ido-use-faces t)
:config
(ido-everywhere t)
(ido-mode 1))
#+end_src
* EWW
@ -25,6 +26,21 @@ This config just sets the download directory
(eww-search-prefix "https://lite.duckduckgo.com/lite/?q=" "prefix url to do search"))
#+end_src
* PDF-Tools
*PDF-Tools* is a emacs package that provides better PDF support to emacs.
It is faster, and less resource intensive compared to Emacs' PDFView mode
#+begin_src emacs-lisp
(use-package pdf-tools
;; :hook "\\.pdf\\'"
:config
(pdf-loader-install)
:hook
(pdf-major-mode . (lambda () (fringe-mode 0)))
(pdf-outline-buffer-mode . (lambda ()
(display-line-numbers-mode -1))))
#+end_src
* Fancy Battery
This shows the battery level on the emacs modeline
@ -149,6 +165,18 @@ Abbrev is helpful for typing long commands, but I don't need to know it in the m
(org-crypt-use-before-save-magic))
#+end_src
* Telega
Telegram chat client for Emacs
#+begin_src emacs-lisp
(use-package telega
:commands telega
:pin "melpa-stable"
:custom
(telega-directory (expand-file-name "telega" user-emacs-directory) "set telega runtime files to be inside user-emacs-directory")
(telega-use-images t)
(telega-emoji-font-family "Noto Color Emoji")
(telega-emoji-use-images nil))
#+end_src
* Elfeed Web
Elfeed is a emacs package for reading RSS Web News.