(setq user-full-name "Yann Herklotz") (setq user-mail-address "yann@yannherklotz.com") (setq gc-cons-threshold (* 1024 1024 1024)) ;; Set some global key rebindings, mainly trying to use `*-dwim' functions ;; whenever possible and making other common functions more convenient. The ;; main keybinding that conflicts with other modes is `C-.' or `C-,'. (global-set-key (kbd "M-u") #'upcase-dwim) (global-set-key (kbd "M-l") #'downcase-dwim) (global-set-key (kbd "M-c") #'capitalize-dwim) (global-set-key (kbd "C-c z") #'quick-calc) (global-set-key (kbd "") #'revert-buffer) (global-set-key (kbd "C-.") #'other-window) (global-set-key (kbd "C-,") #'ymh/prev-window) (global-set-key (kbd "C-\\") #'undo-only) (global-set-key (kbd "M-SPC") (lambda () (interactive) (insert " "))) (global-set-key (kbd "C-") #'tab-bar-switch-to-recent-tab) (global-set-key (kbd "C-c l") #'org-store-link) (global-set-key (kbd "C-c c") #'org-capture) (define-key global-map (kbd "M-Q") #'ymh/unfill-paragraph) ;; Create my own keymap for other, less important but still useful commands ;; which I want to have quick access to. This can be quite flexible, and it ;; might change depending on what I need or how the configuration changes. (define-prefix-command 'ymh-map) (global-set-key (kbd "C-c y") 'ymh-map) (define-key ymh-map (kbd "o") #'ymh/reset-coq-windows) (define-key ymh-map (kbd "c") #'calendar) (define-key ymh-map (kbd "C-l") #'org-agenda-open-link) (define-key ymh-map (kbd "C-p") #'org-previous-link) (define-key ymh-map (kbd "C-n") #'org-next-link) ;; Create variables which hold default locations for various things like my Org ;; directory or the directory containing the bibliography. This makes it much ;; easier to migrate the configuration. (defvar ymh/org-base-dir "~/Dropbox/org" "Contains the base directory for Org files.") (defvar ymh/keyboard :default "Define which keyboard is being used. Should be one of `:white-split', `:modified' or `:default'") (defvar ymh/bib-base-dir "~/Dropbox/bibliography" "Contains the base directory for the bibliography related files.") ;; Define functions using the previous variables and `expand-file-name' to ;; calculate the full path for any file correctly. (defun ymh/expand-org-file (file) "Expand FILE name relative to `ymh/org-base-dir'." (expand-file-name file ymh/org-base-dir)) (defun ymh/expand-bib-file (file) "Expand FILE name relative to `ymh/bib-base-dir'." (expand-file-name file ymh/bib-base-dir)) ;; Set registers for commonly accessed files, especially org-mode files that ;; will be edited a lot. In general, I use `org-capture' to edit the Org files ;; in particular though. (set-register ?l (cons 'file (expand-file-name "init.el" user-emacs-directory))) (set-register ?m (cons 'file (ymh/expand-org-file "meetings.org"))) (set-register ?i (cons 'file (ymh/expand-org-file "inbox.org"))) (set-register ?p (cons 'file (ymh/expand-org-file "projects.org"))) (set-register ?c (cons 'file (ymh/expand-org-file (format-time-string "%Y-%m.org")))) ;; Emacs 29 contains some packages that otherwise need to be downloaded from ;; Melpa, and in addition to that it also allows for the installation of ;; packages using git. (defvar ymh/emacs-29-p (version<= "29" emacs-version) "Checks if the current Emacs version is 29 or not.") ;; There are also some changes that are means for MacOS only, so it's useful to ;; have a flag for that as well. (defvar ymh/macos-p (eq system-type 'darwin) "Checks if the current operating system is MacOS.") ;; Add linker arguments when compiling for macos. (when ymh/macos-p (customize-set-variable 'native-comp-driver-options '("-Wl,-w"))) ;; I currently use 80 as the default fill column width as it works on low-res ;; displays as well. (setq-default fill-column 80) (setq completion-cycle-threshold 3) (setq tab-always-indent 'complete) ;; Some simple configurations which make using the interface a bit nicer. (setq use-short-answers t) (setq inhibit-startup-message t) (setq confirm-nonexistent-file-or-buffer nil) (setq ring-bell-function 'ignore) ;; I always end sentences in two spaces so that emacs can detect them easier. (setq sentence-end-double-space t) ;; Follow symlinks when opening a file. (setq find-file-visit-truename t) (setq vc-follow-symlinks t) ;; When you have two dired buffers open, it will copy them from one to the ;; other automatically. (setq dired-dwim-target t) (setq wdired-allow-to-change-permissions t) ;; Some performance improvements because I do not use right-to-left text. (setq truncate-partial-width-windows nil) (setq-default bidi-paragraph-direction 'left-to-right) (if (version<= "27.1" emacs-version) (setq bidi-inhibit-bpa t)) (setq read-extended-command-predicate #'command-completion-default-include-p) (setq enable-recursive-minibuffers t) ;; Clean up backup directories. (defvar --backup-directory) (setq --backup-directory (expand-file-name "backups" user-emacs-directory)) (if (not (file-exists-p --backup-directory)) (make-directory --backup-directory t)) (setq backup-directory-alist `(("^/dev/shm/" . nil) ("^/tmp/" . nil) ("." . ,--backup-directory))) (setq make-backup-files t) (setq backup-by-copying t) (setq version-control t) (setq delete-old-versions t) (setq delete-by-moving-to-trash t) (setq kept-old-versions 6) (setq kept-new-versions 9) (setq auto-save-default t) (setq auto-save-timeout 20) (setq auto-save-interval 200) ;; Setup some options to be able to use changelog mode. (setq add-log-full-name user-full-name) (setq add-log-mailing-address "git@yannherklotz.com") (setq change-log-default-name "CHANGELOG") (add-hook 'change-log-mode-hook (lambda () (make-local-variable 'tab-width) (make-local-variable 'left-margin) (setq tab-width 2 left-margin 2))) ;; Set indentation settings for various languages. (setq-default indent-tabs-mode nil) (setq-default tab-width 4) (setq-default python-indent-offset 4) (setq-default c-basic-offset 4) (setq line-number-display-limit 2000000) ;; Remove the emacs border when on Linux. (unless ymh/macos-p (setq default-frame-alist '((undecorated . t) (drag-internal-border . 1) (internal-border-width . 5)))) (setq auth-sources '("~/.authinfo" "~/.authinfo.gpg" "~/.netrc")) ;; Set visual new line indicators when using `visual-line-mode'. (setq visual-line-fringe-indicators '(left-curly-arrow nil)) (unless ymh/macos-p (menu-bar-mode -1)) (tool-bar-mode -1) (scroll-bar-mode -1) (column-number-mode 1) (global-display-fill-column-indicator-mode) (add-hook 'text-mode-hook #'visual-line-mode) (add-hook 'text-mode-hook #'auto-fill-mode) ;; Enable those (dolist (c '(overwrite-mode narrow-to-region narrow-to-page upcase-region downcase-region)) (put c 'disabled nil)) (set-frame-font "Iosevka YMHG Semibold-10" nil t) (add-to-list 'mode-line-misc-info '(t ("[t:" (:eval (alist-get 'name (tab-bar--current-tab))) "] "))) ;; Mac configuration (when ymh/macos-p (cl-case ymh/keyboard (:white-split (setq mac-right-option-modifier 'hyper mac-command-modifier 'meta mac-option-modifier 'super)) (:modified (setq mac-right-option-modifier 'meta mac-command-modifier 'super mac-option-modifier 'hyper)) (:default (setq mac-right-option-modifier 'hyper mac-command-modifier 'meta mac-option-modifier 'super))) (add-hook 'ns-system-appearance-change-functions #'ymh/apply-theme)) (provide 'vanilla)