From 59ba7cf99902ec2749226a9eae4049ce260d1435 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Mon, 3 Aug 2020 15:13:24 +0300 Subject: [PATCH] Add FreeBSD handling --- 01mac.el => 01base.el | 69 ++++++++----------------------------------- 01sys-specific.el | 66 +++++++++++++++++++++++++++++++++++++++++ init.el | 3 +- 3 files changed, 81 insertions(+), 57 deletions(-) rename 01mac.el => 01base.el (74%) create mode 100644 01sys-specific.el diff --git a/01mac.el b/01base.el similarity index 74% rename from 01mac.el rename to 01base.el index 7b6b390..9766bee 100644 --- a/01mac.el +++ b/01base.el @@ -1,13 +1,20 @@ -;;; 01mac -- summary +;;; 01base.el --- summary + +;; Author: Maciej Szlosarczyk +;; Maintainer: Maciej Szlosarczyk +;; Version: 0.1-snapshot + ;;; Commentary: -;;; Make Emacs play nicer with MacOS. + +;; 01base defines basic packages and environment. + ;;; Code: ;;;;;;;;; GC configuration ;;;;;;;;;;;;;;;;;;; (setq gc-cons-threshold 50000000) ;;;;;;;; Other optimizations ;;;;;;;;;;;;;;;;; -;; Stolen from Doom Emacs. +;;;;;;;; Stolen from Doom Emacs. ;;;;;;;;;;;;; ;; Update emacs less often (setq idle-update-delay 1.0) @@ -34,48 +41,12 @@ ;;;;;;;;; Emacs bindings ;;;;;;;;;;;;;;;;;;;;; (global-set-key (kbd "RET") 'newline) - -(setq mac-option-modifier 'meta) -(setq mac-command-modifier 'hyper) - -(defun mac-switch-meta nil - "Switch meta between Option and Command." - (interactive) - (if (eq mac-option-modifier nil) - (progn - (setq mac-option-modifier 'meta) - (setq mac-command-modifier 'hyper) - ) - (progn - (setq mac-option-modifier nil) - (setq mac-command-modifier 'meta) - ) - ) - ) - -;;;;;;;;; Mac binding (fix) ;;;;;;;;;;;;;;;;;; (define-key global-map [home] 'beginning-of-line) (define-key global-map [end] 'end-of-line) -(global-set-key (kbd "H-") 'end-of-line) -(global-set-key (kbd "H-") 'beginning-of-line) -(global-set-key (kbd "H-") 'scroll-down) ; WTF is this reverse, I dunno -(global-set-key (kbd "H-") 'scroll-up) - -(global-set-key [(hyper a)] 'mark-whole-buffer) -(global-set-key [(hyper v)] 'yank) -(global-set-key [(hyper x)] 'kill-region) -(global-set-key [(hyper c)] 'kill-ring-save) -(global-set-key [(hyper s)] 'save-buffer) -(global-set-key [(hyper l)] 'goto-line) -(global-set-key [(hyper w)] - (lambda () (interactive) (delete-window))) -(global-set-key [(hyper z)] 'undo) -(global-set-key [(hyper q)] 'kill-emacs) ;;; Helpful key bindings (global-set-key (kbd " b") 'describe-bindings) ;; List all key bindings ;; there are. - (global-set-key (kbd "C-c \\") 'split-window-right) ;; Split window to the right (global-set-key (kbd "C-c /") 'split-window-below) ;; Split window to the bottom @@ -170,21 +141,7 @@ :if (memq window-system '(mac ns)) :ensure t :config (add-to-list 'exec-path "/opt/local/bin") - (exec-path-from-shell-initialize)) - -;;;;;;;;;;;;;;;;;;;;;; Window configuration ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Always start in fullscreen -(defun toggle-fullscreen () - "Toggle full screen." - (interactive) - (set-frame-parameter - nil 'fullscreen - (when (not (frame-parameter nil 'fullscreen)) 'fullboth))) - -(global-set-key (kbd "C-H-f") 'toggle-fullscreen) - -;; Disable meta on right alt (useful for Polish characters) -(setq mac-right-option-modifier nil) + (exec-path-from-shell-initialize)) ;; Draw underline lower (setq x-underline-at-descent-line t) @@ -210,5 +167,5 @@ (which-key-mode t) -(provide '01mac) -;;; 01mac.el ends here +(provide '01base) +;;; 01base.el ends here diff --git a/01sys-specific.el b/01sys-specific.el new file mode 100644 index 0000000..d8941c2 --- /dev/null +++ b/01sys-specific.el @@ -0,0 +1,66 @@ +;;; 01sys-specific -- summary +;;; Commentary: +;;; Make Emacs play nicer with specific operating systems +;;; Code: + +(defconst IS-MAC (eq system-type 'darwin)) +(defconst IS-BSD (eq system-type 'berkeley-unix)) + +;;;;;;;;; Mac-specific config ;;;;;;;;;;;;;;;;;;;;; +(if IS-MAC + (progn + (setq mac-option-modifier 'meta) + (setq mac-command-modifier 'hyper) + + (defun mac-switch-meta nil + "Switch meta between Option and Command." + (interactive) + (if (eq mac-option-modifier nil) + (progn + (setq mac-option-modifier 'meta) + (setq mac-command-modifier 'hyper)) + (progn + (setq mac-option-modifier nil) + (setq mac-command-modifier 'meta)))) + + ;;;;;;;;; Mac binding (fix) ;;;;;;;;;;;;;;;;;; + (global-set-key (kbd "H-") 'end-of-line) + (global-set-key (kbd "H-") 'beginning-of-line) + (global-set-key (kbd "H-") 'scroll-down) ; WTF is this reverse, I dunno + (global-set-key (kbd "H-") 'scroll-up) + + (global-set-key [(hyper a)] 'mark-whole-buffer) + (global-set-key [(hyper v)] 'yank) + (global-set-key [(hyper x)] 'kill-region) + (global-set-key [(hyper c)] 'kill-ring-save) + (global-set-key [(hyper s)] 'save-buffer) + (global-set-key [(hyper l)] 'goto-line) + (global-set-key [(hyper w)] + (lambda () (interactive) (delete-window))) + (global-set-key [(hyper z)] 'undo) + (global-set-key [(hyper q)] 'kill-emacs) + + ;; Disable meta on right alt (useful for Polish characters) + (setq mac-right-option-modifier nil))) + +;;;;;;;;; BSD-specific config ;;;;;;;;;;;;;;;;;;;;; +(if IS-BSD + (progn + (global-set-key (kbd "A-") 'end-of-line) + (global-set-key (kbd "A-") 'beginning-of-line) + (global-set-key (kbd "A-") 'scroll-down) ; WTF is this reverse, I dunno + (global-set-key (kbd "A-") 'scroll-up) + + (global-set-key (kbd "A-a") 'mark-whole-buffer) + (global-set-key (kbd "A-v") 'yank) + (global-set-key (kbd "A-x") 'kill-region) + (global-set-key (kbd "A-c") 'kill-ring-save) + (global-set-key (kbd "A-s") 'save-buffer) + (global-set-key (kbd "A-l") 'goto-line) + (global-set-key (kbd "A-w") + (lambda () (interactive) (delete-window))) + (global-set-key (kbd "A-z") 'undo) + (global-set-key (kbd "A-q") 'kill-emacs))) + +(provide '01sys-specific) +;;; 01sys-specific.el ends here diff --git a/init.el b/init.el index f257362..381d640 100644 --- a/init.el +++ b/init.el @@ -18,7 +18,8 @@ (require 'use-package) ;; General configuration files. -(require '01mac "$HOME/.emacs.d/01mac.el") +(require '01base "$HOME/.emacs.d/01base.el") +(require '01sys-specific "$HOME/.emacs.d/01sys-specific.el") (require '05macros "$HOME/.emacs.d/05macros.el") (require '05ivy "$HOME/.emacs.d/05ivy.el") (require '05hydra "$HOME/.emacs.d/05hydra.el")