configurations: emacs

This commit is contained in:
Mateusz Słodkowicz 2024-11-11 01:22:14 +01:00
parent d3d3397c23
commit 3d1cc80150
Signed by: materus
GPG Key ID: 28D140BCA60B4FD1
5 changed files with 74 additions and 66 deletions

View File

@ -89,7 +89,7 @@ in {
name = "Emacs"; name = "Emacs";
genericName = "Edytor tekstu"; genericName = "Edytor tekstu";
comment = "Edytuj tekst"; comment = "Edytuj tekst";
exec = ''env COLORTERM=truecolor emacsclient -a "" -c %F''; exec = ''env COLORTERM=truecolor emacsclient -a "" -r -n %F'';
icon = "emacs"; icon = "emacs";
terminal = false; terminal = false;
type = "Application"; type = "Application";
@ -113,7 +113,7 @@ in {
"x-scheme-handler/org-protocol" "x-scheme-handler/org-protocol"
]; ];
actions.new-window = { actions.new-window = {
exec = ''env COLORTERM=truecolor emacsclient -a "" -c %F''; exec = ''env COLORTERM=truecolor emacsclient -a "" -c -n %F'';
name = "Nowe okno"; name = "Nowe okno";
}; };
actions.no-daemon = { actions.no-daemon = {

View File

@ -164,7 +164,7 @@ in
${lib.getExe pkgs.curl} -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | ${lib.getExe pkgs.python3} ${lib.getExe pkgs.curl} -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | ${lib.getExe pkgs.python3}
} }
${lib.optionalString config.materus.profile.editor.emacs.enable ''alias "e"="emacsclient -nw -c --alternate-editor= "''} ${lib.optionalString config.materus.profile.editor.emacs.enable ''alias "e"="emacsclient -nw -c --alternate-editor= "''}
${lib.optionalString config.materus.profile.editor.emacs.enable ''alias "ee"="emacsclient -n -r --alternate-editor= "''}
'' + '' +

View File

@ -1,5 +1,5 @@
(defvar materus/init-early t) ; Var to ensure early-init loaded (defvar materus/init-early t) ; Var to ensure early-init loaded
(setq materus/init-early t) ; Probably useless (setq materus/init-early t) ; Probably useless
(setq initial-major-mode 'fundamental-mode) (setq initial-major-mode 'fundamental-mode)
(setq native-comp-async-report-warnings-errors nil) (setq native-comp-async-report-warnings-errors nil)
@ -13,8 +13,6 @@
(unless (daemonp) (unless (daemonp)
(setq gc-cons-threshold most-positive-fixnum ; 2^61 bytes (setq gc-cons-threshold most-positive-fixnum ; 2^61 bytes
gc-cons-percentage 0.6) gc-cons-percentage 0.6)
(advice-add #'tty-run-terminal-initialization :override #'ignore) (advice-add #'tty-run-terminal-initialization :override #'ignore)
(add-hook 'window-setup-hook (add-hook 'window-setup-hook
(lambda () (lambda ()
@ -34,10 +32,10 @@
(convert-standard-filename (convert-standard-filename
(expand-file-name "var/eln-cache/" user-emacs-directory)))) (expand-file-name "var/eln-cache/" user-emacs-directory))))
(setq auto-save-default nil) (setq auto-save-default nil)
(setq backup-directory-alist (setq backup-directory-alist
`((".*" . ,(concat user-emacs-directory "var/backups/")))) ; Change backup and auto save dir to var dir `((".*" . ,(concat user-emacs-directory "var/backups/")))) ; Change backup and auto save dir to var dir
(setq auto-save-file-name-transforms (setq auto-save-file-name-transforms
`((".*" ,(concat user-emacs-directory "var/recovery/") t))) `((".*" ,(concat user-emacs-directory "var/recovery/") t)))
(setq auto-save-list-file-prefix (concat user-emacs-directory "var/auto-save/sessions/")) (setq auto-save-list-file-prefix (concat user-emacs-directory "var/auto-save/sessions/"))
(setq custom-file (concat user-emacs-directory "etc/custom.el")) (setq custom-file (concat user-emacs-directory "etc/custom.el"))

View File

@ -1,11 +1,11 @@
#+TITLE: Materus Emacs Cfg #+TITLE: Materus Emacs Cfg
#+AUTHOR: materus #+AUTHOR: materus
#+DESCRIPTION: materus emacs configuration #+DESCRIPTION: materus emacs configuration
#+STARTUP: showeverything #+STARTUP: overview
#+PROPERTY: header-args :tangle etc/materus/emacs-config.el #+PROPERTY: header-args :tangle etc/materus/emacs-config.el
#+auto_tangle: t #+auto_tangle: t
My emacs config, tangled file is [[file:etc/materus/emacs-config.el][there]] My emacs config, tangled file is [[file:etc/materus/emacs-config.el][there]]
* Table of Contents :TOC_3: * Table of Contents :noexport:TOC_3:
- [[#init-files][Init Files]] - [[#init-files][Init Files]]
- [[#early-init][Early Init]] - [[#early-init][Early Init]]
- [[#init][Init]] - [[#init][Init]]
@ -44,10 +44,10 @@ My emacs config, tangled file is [[file:etc/materus/emacs-config.el][there]]
:PROPERTIES: :PROPERTIES:
:header-args: :tangle early-init.el :header-args: :tangle early-init.el
:END: :END:
Early init file, setting for GC and some paths. Early init file, setting for GC and some paths.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defvar materus/init-early t) ; Var to ensure early-init loaded (defvar materus/init-early t) ; Var to ensure early-init loaded
(setq materus/init-early t) ; Probably useless (setq materus/init-early t) ; Probably useless
(setq initial-major-mode 'fundamental-mode) (setq initial-major-mode 'fundamental-mode)
(setq native-comp-async-report-warnings-errors nil) (setq native-comp-async-report-warnings-errors nil)
@ -61,8 +61,6 @@ Early init file, setting for GC and some paths.
(unless (daemonp) (unless (daemonp)
(setq gc-cons-threshold most-positive-fixnum ; 2^61 bytes (setq gc-cons-threshold most-positive-fixnum ; 2^61 bytes
gc-cons-percentage 0.6) gc-cons-percentage 0.6)
(advice-add #'tty-run-terminal-initialization :override #'ignore) (advice-add #'tty-run-terminal-initialization :override #'ignore)
(add-hook 'window-setup-hook (add-hook 'window-setup-hook
(lambda () (lambda ()
@ -82,11 +80,11 @@ Early init file, setting for GC and some paths.
(convert-standard-filename (convert-standard-filename
(expand-file-name "var/eln-cache/" user-emacs-directory)))) (expand-file-name "var/eln-cache/" user-emacs-directory))))
(setq auto-save-default nil) (setq auto-save-default nil)
(setq backup-directory-alist (setq backup-directory-alist
`((".*" . ,(concat user-emacs-directory "var/backups/")))) ; Change backup and auto save dir to var dir `((".*" . ,(concat user-emacs-directory "var/backups/")))) ; Change backup and auto save dir to var dir
(setq auto-save-file-name-transforms (setq auto-save-file-name-transforms
`((".*" ,(concat user-emacs-directory "var/recovery/") t))) `((".*" ,(concat user-emacs-directory "var/recovery/") t)))
(setq auto-save-list-file-prefix (concat user-emacs-directory "var/auto-save/sessions/")) (setq auto-save-list-file-prefix (concat user-emacs-directory "var/auto-save/sessions/"))
(setq custom-file (concat user-emacs-directory "etc/custom.el")) (setq custom-file (concat user-emacs-directory "etc/custom.el"))
#+end_src #+end_src
@ -125,11 +123,12 @@ After some testing default package manager works best for me.
(require 'cl-lib) (require 'cl-lib)
(require 'package) (require 'package)
(setq package-user-dir (concat user-emacs-directory "var/elpa/" emacs-version "/" )) (setq package-user-dir (concat user-emacs-directory "var/elpa/" emacs-version "/" ))
(setq package-gnupghome-dir (concat user-emacs-directory "var/elpa/gnupg/" ))
(add-to-list 'package-archives '("nongnu-devel" . "https://elpa.nongnu.org/nongnu-devel/")) (add-to-list 'package-archives '("nongnu-devel" . "https://elpa.nongnu.org/nongnu-devel/"))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize) (package-initialize)
#+end_src #+end_src
** Packages ** Packages
Packages to install Packages to install
#+begin_src emacs-lisp #+begin_src emacs-lisp
@ -200,7 +199,7 @@ Packages to install
right-click-context right-click-context
dracula-theme dracula-theme
doom-themes doom-themes
doom-modeline doom-modeline
orderless orderless
popper popper
undo-tree undo-tree
@ -224,8 +223,11 @@ Packages to install
toc-org toc-org
eshell-vterm eshell-vterm
empv empv
volatile-highlights volatile-highlights
highlight highlight
elfeed
elfeed-goodies
drag-stuff
) )
"A list of packages to ensure are installed at launch.") "A list of packages to ensure are installed at launch.")
@ -236,10 +238,10 @@ Packages to install
(defun materus/install-packages () (defun materus/install-packages ()
(unless (materus/packages-installed-p) (unless (materus/packages-installed-p)
(package-refresh-contents) (package-refresh-contents)
(dolist (p materus/packages) (dolist (p materus/packages)
(when (not (package-installed-p p)) (when (not (package-installed-p p))
(package-install p))))) (package-install p)))))
(materus/install-packages) (materus/install-packages)
#+end_src #+end_src
@ -270,7 +272,6 @@ Graphical related settings.
#+end_src #+end_src
*** Misc *** Misc
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq frame-inhibit-implied-resize t) (setq frame-inhibit-implied-resize t)
(setq frame-resize-pixelwise t) (setq frame-resize-pixelwise t)
(setq window-resize-pixelwise t) (setq window-resize-pixelwise t)
@ -288,7 +289,11 @@ Graphical related settings.
(setq read-process-output-max (* 1024 1024 3)) (setq read-process-output-max (* 1024 1024 3))
(setq ring-bell-function 'ignore) (setq ring-bell-function 'ignore)
(setq-default cursor-type '(bar . 1)) (setq-default cursor-type '(bar . 1))
;; Rainbow mode
(use-package rainbow-mode
:hook
((org-mode . rainbow-mode)
(prog-mode . rainbow-mode)))
;; Delimiters ;; Delimiters
(use-package rainbow-delimiters :hook (use-package rainbow-delimiters :hook
@ -305,17 +310,16 @@ Graphical related settings.
;; Theme ;; Theme
(use-package dracula-theme :config (use-package dracula-theme :config
(if (daemonp) (if (daemonp)
(add-hook 'after-make-frame-functions (add-hook 'after-make-frame-functions
(lambda (frame) (lambda (frame)
(with-selected-frame frame (load-theme 'dracula t)))) (with-selected-frame frame (load-theme 'dracula t))))
(load-theme 'dracula t))) (load-theme 'dracula t)))
(defun startup-screen-advice (orig-fun &rest args) (defun startup-screen-advice (orig-fun &rest args)
(when (= (seq-count #'buffer-file-name (buffer-list)) 0) (when (= (seq-count #'buffer-file-name (buffer-list)) 0)
(apply orig-fun args))) (apply orig-fun args)))
(advice-add 'display-startup-screen :around #'startup-screen-advice) ; Hide startup screen if started with file (advice-add 'display-startup-screen :around #'startup-screen-advice) ; Hide startup screen if started with file
#+end_src #+end_src
*** Dashboard *** Dashboard
#+begin_src emacs-lisp #+begin_src emacs-lisp
@ -328,7 +332,7 @@ Graphical related settings.
(dashboard-setup-startup-hook) (dashboard-setup-startup-hook)
(when (daemonp) (when (daemonp)
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*"))) ; Show dashboard when emacs is running as daemon (setq initial-buffer-choice (lambda () (get-buffer "*dashboard*"))) ; Show dashboard when emacs is running as daemon
) )
) )
#+end_src #+end_src
*** Modeline *** Modeline
@ -338,12 +342,11 @@ Graphical related settings.
:hook (after-init . doom-modeline-mode) :hook (after-init . doom-modeline-mode)
:config :config
(setq doom-modeline-icon t) (setq doom-modeline-icon t)
(setq display-time-24hr-format t) (setq display-time-24hr-format t)'
(display-time-mode 1)) (display-time-mode 1))
(use-package minions (use-package minions
:hook (after-init . minions-mode)) :hook (after-init . minions-mode))
#+end_src #+end_src
** Org-mode ** Org-mode
Org mode settings Org mode settings
@ -390,11 +393,11 @@ Org mode settings
:after (consult marginalia) :after (consult marginalia)
:config :config
(setq completion-in-region-function (setq completion-in-region-function
(lambda (&rest args) (lambda (&rest args)
(apply (if vertico-mode (apply (if vertico-mode
#'consult-completion-in-region #'consult-completion-in-region
#'completion--in-region) #'completion--in-region)
args))) args)))
(vertico-mode 1) (vertico-mode 1)
(marginalia-mode 1)) (marginalia-mode 1))
@ -412,6 +415,7 @@ Other configs
#+begin_src emacs-lisp #+begin_src emacs-lisp
(electric-pair-mode 1) (electric-pair-mode 1)
(electric-indent-mode -1) (electric-indent-mode -1)
(setq-default indent-tabs-mode nil)
(setq-default buffer-file-coding-system 'utf-8-dos) (setq-default buffer-file-coding-system 'utf-8-dos)
#+end_src #+end_src
*** Elcord *** Elcord
@ -541,7 +545,6 @@ Other configs
(keymap-set cua--cua-keys-keymap "C-z" 'undo-tree-undo) (keymap-set cua--cua-keys-keymap "C-z" 'undo-tree-undo)
(keymap-set cua--cua-keys-keymap "C-y" 'undo-tree-redo) (keymap-set cua--cua-keys-keymap "C-y" 'undo-tree-redo)
(keymap-set global-map "C-<iso-lefttab>" #'indent-rigidly-left-to-tab-stop) (keymap-set global-map "C-<iso-lefttab>" #'indent-rigidly-left-to-tab-stop)
(keymap-set global-map "C-<tab>" #'indent-rigidly-right-to-tab-stop) (keymap-set global-map "C-<tab>" #'indent-rigidly-right-to-tab-stop)
@ -563,12 +566,11 @@ Just for testing some code
;;; (setq completion-styles '(orderless basic) ;;; (setq completion-styles '(orderless basic)
;;; completion-category-defaults nil ;;; completion-category-defaults nil
;;; completion-category-overrides '((file (styles partial-completion)))) ;;; completion-category-overrides '((file (styles partial-completion))))
#+end_src #+end_src

View File

@ -10,6 +10,7 @@
(require 'cl-lib) (require 'cl-lib)
(require 'package) (require 'package)
(setq package-user-dir (concat user-emacs-directory "var/elpa/" emacs-version "/" )) (setq package-user-dir (concat user-emacs-directory "var/elpa/" emacs-version "/" ))
(setq package-gnupghome-dir (concat user-emacs-directory "var/elpa/gnupg/" ))
(add-to-list 'package-archives '("nongnu-devel" . "https://elpa.nongnu.org/nongnu-devel/")) (add-to-list 'package-archives '("nongnu-devel" . "https://elpa.nongnu.org/nongnu-devel/"))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize) (package-initialize)
@ -81,7 +82,7 @@
right-click-context right-click-context
dracula-theme dracula-theme
doom-themes doom-themes
doom-modeline doom-modeline
orderless orderless
popper popper
undo-tree undo-tree
@ -105,8 +106,11 @@
toc-org toc-org
eshell-vterm eshell-vterm
empv empv
volatile-highlights volatile-highlights
highlight highlight
elfeed
elfeed-goodies
drag-stuff
) )
"A list of packages to ensure are installed at launch.") "A list of packages to ensure are installed at launch.")
@ -117,10 +121,10 @@
(defun materus/install-packages () (defun materus/install-packages ()
(unless (materus/packages-installed-p) (unless (materus/packages-installed-p)
(package-refresh-contents) (package-refresh-contents)
(dolist (p materus/packages) (dolist (p materus/packages)
(when (not (package-installed-p p)) (when (not (package-installed-p p))
(package-install p))))) (package-install p)))))
(materus/install-packages) (materus/install-packages)
(require 'recentf) (require 'recentf)
@ -156,7 +160,11 @@
(setq read-process-output-max (* 1024 1024 3)) (setq read-process-output-max (* 1024 1024 3))
(setq ring-bell-function 'ignore) (setq ring-bell-function 'ignore)
(setq-default cursor-type '(bar . 1)) (setq-default cursor-type '(bar . 1))
;; Rainbow mode
(use-package rainbow-mode
:hook
((org-mode . rainbow-mode)
(prog-mode . rainbow-mode)))
;; Delimiters ;; Delimiters
(use-package rainbow-delimiters :hook (use-package rainbow-delimiters :hook
@ -173,11 +181,11 @@
;; Theme ;; Theme
(use-package dracula-theme :config (use-package dracula-theme :config
(if (daemonp) (if (daemonp)
(add-hook 'after-make-frame-functions (add-hook 'after-make-frame-functions
(lambda (frame) (lambda (frame)
(with-selected-frame frame (load-theme 'dracula t)))) (with-selected-frame frame (load-theme 'dracula t))))
(load-theme 'dracula t))) (load-theme 'dracula t)))
(defun startup-screen-advice (orig-fun &rest args) (defun startup-screen-advice (orig-fun &rest args)
(when (= (seq-count #'buffer-file-name (buffer-list)) 0) (when (= (seq-count #'buffer-file-name (buffer-list)) 0)
@ -193,7 +201,7 @@
(dashboard-setup-startup-hook) (dashboard-setup-startup-hook)
(when (daemonp) (when (daemonp)
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*"))) ; Show dashboard when emacs is running as daemon (setq initial-buffer-choice (lambda () (get-buffer "*dashboard*"))) ; Show dashboard when emacs is running as daemon
) )
) )
(use-package doom-modeline (use-package doom-modeline
@ -201,7 +209,7 @@
:hook (after-init . doom-modeline-mode) :hook (after-init . doom-modeline-mode)
:config :config
(setq doom-modeline-icon t) (setq doom-modeline-icon t)
(setq display-time-24hr-format t) (setq display-time-24hr-format t)'
(display-time-mode 1)) (display-time-mode 1))
(use-package minions (use-package minions
@ -245,11 +253,11 @@
:after (consult marginalia) :after (consult marginalia)
:config :config
(setq completion-in-region-function (setq completion-in-region-function
(lambda (&rest args) (lambda (&rest args)
(apply (if vertico-mode (apply (if vertico-mode
#'consult-completion-in-region #'consult-completion-in-region
#'completion--in-region) #'completion--in-region)
args))) args)))
(vertico-mode 1) (vertico-mode 1)
(marginalia-mode 1)) (marginalia-mode 1))
@ -258,6 +266,7 @@
(electric-pair-mode 1) (electric-pair-mode 1)
(electric-indent-mode -1) (electric-indent-mode -1)
(setq-default indent-tabs-mode nil)
(setq-default buffer-file-coding-system 'utf-8-dos) (setq-default buffer-file-coding-system 'utf-8-dos)
(defun materus/elcord-toggle (&optional _frame) (defun materus/elcord-toggle (&optional _frame)
@ -354,7 +363,6 @@
(keymap-set cua--cua-keys-keymap "C-z" 'undo-tree-undo) (keymap-set cua--cua-keys-keymap "C-z" 'undo-tree-undo)
(keymap-set cua--cua-keys-keymap "C-y" 'undo-tree-redo) (keymap-set cua--cua-keys-keymap "C-y" 'undo-tree-redo)
(keymap-set global-map "C-<iso-lefttab>" #'indent-rigidly-left-to-tab-stop) (keymap-set global-map "C-<iso-lefttab>" #'indent-rigidly-left-to-tab-stop)
(keymap-set global-map "C-<tab>" #'indent-rigidly-right-to-tab-stop) (keymap-set global-map "C-<tab>" #'indent-rigidly-right-to-tab-stop)
@ -371,5 +379,5 @@
;;; (setq completion-styles '(orderless basic) ;;; (setq completion-styles '(orderless basic)
;;; completion-category-defaults nil ;;; completion-category-defaults nil
;;; completion-category-overrides '((file (styles partial-completion)))) ;;; completion-category-overrides '((file (styles partial-completion))))