diff --git a/.config/emacs/config.el b/.config/emacs/config.el index e49372e..9dd7506 100644 --- a/.config/emacs/config.el +++ b/.config/emacs/config.el @@ -1,64 +1,74 @@ -(defvar elpaca-installer-version 0.4) -(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory)) -(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory)) -(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory)) -(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git" - :ref nil - :files (:defaults (:exclude "extensions")) - :build (:not elpaca--activate-package))) -(let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory)) - (build (expand-file-name "elpaca/" elpaca-builds-directory)) - (order (cdr elpaca-order)) - (default-directory repo)) - (add-to-list 'load-path (if (file-exists-p build) build repo)) - (unless (file-exists-p repo) - (make-directory repo t) - (when (< emacs-major-version 28) (require 'subr-x)) - (condition-case-unless-debug err - (if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*")) - ((zerop (call-process "git" nil buffer t "clone" - (plist-get order :repo) repo))) - ((zerop (call-process "git" nil buffer t "checkout" - (or (plist-get order :ref) "--")))) - (emacs (concat invocation-directory invocation-name)) - ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch" - "--eval" "(byte-recompile-directory \".\" 0 'force)"))) - ((require 'elpaca)) - ((elpaca-generate-autoloads "elpaca" repo))) - (kill-buffer buffer) - (error "%s" (with-current-buffer buffer (buffer-string)))) -((error) (warn "%s" err) (delete-directory repo 'recursive)))) - (unless (require 'elpaca-autoloads nil t) - (require 'elpaca) - (elpaca-generate-autoloads "elpaca" repo) - (load "./elpaca-autoloads"))) -(add-hook 'after-init-hook #'elpaca-process-queues) -(elpaca `(,@elpaca-order)) +(add-to-list 'load-path "~/.config/emacs/scripts/") -;; Install use-package support -(elpaca elpaca-use-package - ;; Enable :elpaca use-package keyword. - (elpaca-use-package-mode) - ;; Assume :elpaca t unless otherwise specified. - (setq elpaca-use-package-by-default t)) +(require 'elpaca-setup) ;; The Elpaca Package Manager +(require 'buffer-move) ;; Buffer-move for better window management +(require 'app-launchers) ;; Use emacs as a run launcher like dmenu (experimental) -;; Block until current queue processed. -(elpaca-wait) +(use-package all-the-icons + :ensure t + :if (display-graphic-p)) -;;When installing a package which modifies a form used at the top-level -;;(e.g. a package which adds a use-package key word), -;;use `elpaca-wait' to block until that package has been installed/configured. -;;For example: -;;(use-package general :demand t) -;;(elpaca-wait) +(use-package all-the-icons-dired + :hook (dired-mode . (lambda () (all-the-icons-dired-mode t)))) -;;Turns off elpaca-use-package-mode current declartion -;;Note this will cause the declaration to be interpreted immediately (not deferred). -;;Useful for configuring built-in emacs features. -;;(use-package emacs :elpaca nil :config (setq ring-bell-function #'ignore)) +(setq backup-directory-alist '((".*" . "~/.Trash"))) -;; Don't install anything. Defer execution of BODY -;;(elpaca nil (message "deferred")) +(use-package company + :defer 2 + :diminish + :custom + (company-begin-commands '(self-insert-command)) + (company-idle-delay .1) + (company-minimum-prefix-length 2) + (company-show-numbers t) + (company-tooltip-align-annotations 't) + (global-company-mode t)) + +(use-package company-box + :after company + :diminish + :hook (company-mode . company-box-mode)) + +(use-package dashboard + :ensure t + :init + (setq initial-buffer-choice 'dashboard-open) + (setq dashboard-set-heading-icons t) + (setq dashboard-set-file-icons t) + (setq dashboard-banner-logo-title "Emacs Is More Than A Text Editor!") + ;;(setq dashboard-startup-banner 'logo) ;; use standard emacs logo as banner + (setq dashboard-startup-banner "/home/dt/.config/emacs/images/dtmacs-logo.png") ;; use custom image as banner + (setq dashboard-center-content nil) ;; set to 't' for centered content + (setq dashboard-items '((recents . 5) + (agenda . 5 ) + (bookmarks . 3) + (projects . 3) + (registers . 3))) + :custom + (dashboard-modify-heading-icons '((recents . "file-text") + (bookmarks . "book"))) + :config + (dashboard-setup-startup-hook)) + +(use-package diminish) + +(use-package dired-open + :config + (setq dired-open-extensions '(("gif" . "sxiv") + ("jpg" . "sxiv") + ("png" . "sxiv") + ("mkv" . "mpv") + ("mp4" . "mpv")))) + +(use-package peep-dired + :after dired + :hook (evil-normalize-keymaps . peep-dired-hook) + :config + (evil-define-key 'normal dired-mode-map (kbd "h") 'dired-up-directory) + (evil-define-key 'normal dired-mode-map (kbd "l") 'dired-open-file) ; use dired-find-file instead if not using dired-open package + (evil-define-key 'normal peep-dired-mode-map (kbd "j") 'peep-dired-next-file) + (evil-define-key 'normal peep-dired-mode-map (kbd "k") 'peep-dired-prev-file) +) ;; Expands to: (elpaca evil (use-package evil :demand t)) (use-package evil @@ -75,6 +85,45 @@ (evil-collection-init)) (use-package evil-tutor) +(use-package flycheck + :ensure t + :defer t + :diminish + :init (global-flycheck-mode)) + +(set-face-attribute 'default nil + :font "JetBrains Mono" + :height 110 + :weight 'medium) +(set-face-attribute 'variable-pitch nil + :font "Ubuntu" + :height 120 + :weight 'medium) +(set-face-attribute 'fixed-pitch nil + :font "JetBrains Mono" + :height 110 + :weight 'medium) +;; Makes commented text and keywords italics. +;; This is working in emacsclient but not emacs. +;; Your font must have an italic face available. +(set-face-attribute 'font-lock-comment-face nil + :slant 'italic) +(set-face-attribute 'font-lock-keyword-face nil + :slant 'italic) + +;; This sets the default font on all graphical frames created after restarting Emacs. +;; Does the same thing as 'set-face-attribute default' above, but emacsclient fonts +;; are not right unless I also add this method of setting the default font. +(add-to-list 'default-frame-alist '(font . "JetBrains Mono-11")) + +;; Uncomment the following line if line spacing needs adjusting. +(setq-default line-spacing 0.12) + +(global-set-key (kbd "C-=") 'text-scale-increase) +(global-set-key (kbd "C--") 'text-scale-decrease) +(global-set-key (kbd "") 'text-scale-increase) +(global-set-key (kbd "") 'text-scale-decrease) + (use-package general :config (general-evil-setup) @@ -178,219 +227,6 @@ "w L" '(buf-move-right :wk "Buffer move right")) ) -(defun emacs-counsel-launcher () - "Create and select a frame called emacs-counsel-launcher which consists only of a minibuffer and has specific dimensions. Runs counsel-linux-app on that frame, which is an emacs command that prompts you to select an app and open it in a dmenu like behaviour. Delete the frame after that command has exited" - (interactive) - (with-selected-frame - (make-frame '((name . "emacs-run-launcher") - (minibuffer . only) - (fullscreen . 0) ; no fullscreen - (undecorated . t) ; remove title bar - ;;(auto-raise . t) ; focus on this frame - ;;(tool-bar-lines . 0) - ;;(menu-bar-lines . 0) - (internal-border-width . 10) - (width . 80) - (height . 11))) - (unwind-protect - (counsel-linux-app) - (delete-frame)))) - -(use-package app-launcher - :elpaca '(app-launcher :host github :repo "SebastienWae/app-launcher")) -;; create a global keyboard shortcut with the following code -;; emacsclient -cF "((visibility . nil))" -e "(emacs-run-launcher)" - -(defun emacs-run-launcher () - "Create and select a frame called emacs-run-launcher which consists only of a minibuffer and has specific dimensions. Runs app-launcher-run-app on that frame, which is an emacs command that prompts you to select an app and open it in a dmenu like behaviour. Delete the frame after that command has exited" - (interactive) - (with-selected-frame - (make-frame '((name . "emacs-run-launcher") - (minibuffer . only) - (fullscreen . 0) ; no fullscreen - (undecorated . t) ; remove title bar - ;;(auto-raise . t) ; focus on this frame - ;;(tool-bar-lines . 0) - ;;(menu-bar-lines . 0) - (internal-border-width . 10) - (width . 80) - (height . 11))) - (unwind-protect - (app-launcher-run-app) - (delete-frame)))) - -(use-package all-the-icons - :ensure t - :if (display-graphic-p)) - -(use-package all-the-icons-dired - :hook (dired-mode . (lambda () (all-the-icons-dired-mode t)))) - -(require 'windmove) - -;;;###autoload -(defun buf-move-up () - "Swap the current buffer and the buffer above the split. -If there is no split, ie now window above the current one, an -error is signaled." -;; "Switches between the current buffer, and the buffer above the -;; split, if possible." - (interactive) - (let* ((other-win (windmove-find-other-window 'up)) - (buf-this-buf (window-buffer (selected-window)))) - (if (null other-win) - (error "No window above this one") - ;; swap top with this one - (set-window-buffer (selected-window) (window-buffer other-win)) - ;; move this one to top - (set-window-buffer other-win buf-this-buf) - (select-window other-win)))) - -;;;###autoload -(defun buf-move-down () -"Swap the current buffer and the buffer under the split. -If there is no split, ie now window under the current one, an -error is signaled." - (interactive) - (let* ((other-win (windmove-find-other-window 'down)) - (buf-this-buf (window-buffer (selected-window)))) - (if (or (null other-win) - (string-match "^ \\*Minibuf" (buffer-name (window-buffer other-win)))) - (error "No window under this one") - ;; swap top with this one - (set-window-buffer (selected-window) (window-buffer other-win)) - ;; move this one to top - (set-window-buffer other-win buf-this-buf) - (select-window other-win)))) - -;;;###autoload -(defun buf-move-left () -"Swap the current buffer and the buffer on the left of the split. -If there is no split, ie now window on the left of the current -one, an error is signaled." - (interactive) - (let* ((other-win (windmove-find-other-window 'left)) - (buf-this-buf (window-buffer (selected-window)))) - (if (null other-win) - (error "No left split") - ;; swap top with this one - (set-window-buffer (selected-window) (window-buffer other-win)) - ;; move this one to top - (set-window-buffer other-win buf-this-buf) - (select-window other-win)))) - -;;;###autoload -(defun buf-move-right () -"Swap the current buffer and the buffer on the right of the split. -If there is no split, ie now window on the right of the current -one, an error is signaled." - (interactive) - (let* ((other-win (windmove-find-other-window 'right)) - (buf-this-buf (window-buffer (selected-window)))) - (if (null other-win) - (error "No right split") - ;; swap top with this one - (set-window-buffer (selected-window) (window-buffer other-win)) - ;; move this one to top - (set-window-buffer other-win buf-this-buf) - (select-window other-win)))) - -(use-package company - :defer 2 - :diminish - :custom - (company-begin-commands '(self-insert-command)) - (company-idle-delay .1) - (company-minimum-prefix-length 2) - (company-show-numbers t) - (company-tooltip-align-annotations 't) - (global-company-mode t)) - -(use-package company-box - :after company - :diminish - :hook (company-mode . company-box-mode)) - -(use-package dashboard - :ensure t - :init - (setq initial-buffer-choice 'dashboard-open) - (setq dashboard-set-heading-icons t) - (setq dashboard-set-file-icons t) - (setq dashboard-banner-logo-title "Emacs Is More Than A Text Editor!") - ;;(setq dashboard-startup-banner 'logo) ;; use standard emacs logo as banner - (setq dashboard-startup-banner "/home/dt/.config/emacs/images/dtmacs-logo.png") ;; use custom image as banner - (setq dashboard-center-content nil) ;; set to 't' for centered content - (setq dashboard-items '((recents . 5) - (agenda . 5 ) - (bookmarks . 3) - (projects . 3) - (registers . 3))) - :custom - (dashboard-modify-heading-icons '((recents . "file-text") - (bookmarks . "book"))) - :config - (dashboard-setup-startup-hook)) - -(use-package diminish) - -(use-package dired-open - :config - (setq dired-open-extensions '(("gif" . "sxiv") - ("jpg" . "sxiv") - ("png" . "sxiv") - ("mkv" . "mpv") - ("mp4" . "mpv")))) - -(use-package peep-dired - :after dired - :hook (evil-normalize-keymaps . peep-dired-hook) - :config - (evil-define-key 'normal dired-mode-map (kbd "h") 'dired-up-directory) - (evil-define-key 'normal dired-mode-map (kbd "l") 'dired-open-file) ; use dired-find-file instead if not using dired-open package - (evil-define-key 'normal peep-dired-mode-map (kbd "j") 'peep-dired-next-file) - (evil-define-key 'normal peep-dired-mode-map (kbd "k") 'peep-dired-prev-file) -) - -(use-package flycheck - :ensure t - :defer t - :diminish - :init (global-flycheck-mode)) - -(set-face-attribute 'default nil - :font "JetBrains Mono" - :height 110 - :weight 'medium) -(set-face-attribute 'variable-pitch nil - :font "Ubuntu" - :height 120 - :weight 'medium) -(set-face-attribute 'fixed-pitch nil - :font "JetBrains Mono" - :height 110 - :weight 'medium) -;; Makes commented text and keywords italics. -;; This is working in emacsclient but not emacs. -;; Your font must have an italic face available. -(set-face-attribute 'font-lock-comment-face nil - :slant 'italic) -(set-face-attribute 'font-lock-keyword-face nil - :slant 'italic) - -;; This sets the default font on all graphical frames created after restarting Emacs. -;; Does the same thing as 'set-face-attribute default' above, but emacsclient fonts -;; are not right unless I also add this method of setting the default font. -(add-to-list 'default-frame-alist '(font . "JetBrains Mono-11")) - -;; Uncomment the following line if line spacing needs adjusting. -(setq-default line-spacing 0.12) - -(global-set-key (kbd "C-=") 'text-scale-increase) -(global-set-key (kbd "C--") 'text-scale-decrease) -(global-set-key (kbd "") 'text-scale-increase) -(global-set-key (kbd "") 'text-scale-decrease) - (menu-bar-mode -1) (tool-bar-mode -1) (scroll-bar-mode -1) diff --git a/.config/emacs/config.org b/.config/emacs/config.org index 715cfb7..ffbe551 100644 --- a/.config/emacs/config.org +++ b/.config/emacs/config.org @@ -6,22 +6,20 @@ * TABLE OF CONTENTS :toc: - [[#important-programs-to-load-first][IMPORTANT PROGRAMS TO LOAD FIRST]] - - [[#elpaca-package-manager][Elpaca Package Manager]] - - [[#load-evil-mode][Load Evil Mode]] - - [[#general-keybindings][General Keybindings]] -- [[#app-launchers][APP LAUNCHERS]] - - [[#counsel-linux-app][Counsel-Linux-App]] - - [[#app-launcher][App-Launcher]] + - [[#adding-the-scripts-directory-to-path][Adding the scripts directory to path]] + - [[#sourcing-the-scripts][Sourcing the scripts]] - [[#all-the-icons][ALL THE ICONS]] -- [[#buffer-move][BUFFER-MOVE]] +- [[#backup-files][BACKUP FILES]] - [[#company][COMPANY]] - [[#dashboard][DASHBOARD]] - [[#diminish][DIMINISH]] - [[#dired][DIRED]] +- [[#evil][EVIL]] - [[#flycheck][FLYCHECK]] - [[#fonts][FONTS]] - [[#setting-the-font-face][Setting the Font Face]] - [[#zooming-inout][Zooming In/Out]] +- [[#general-keybindings][GENERAL KEYBINDINGS]] - [[#graphical-user-interface-tweaks][GRAPHICAL USER INTERFACE TWEAKS]] - [[#disable-menubar-toolbars-and-scrollbars][Disable Menubar, Toolbars and Scrollbars]] - [[#display-line-numbers-and-truncated-lines][Display Line Numbers and Truncated Lines]] @@ -48,72 +46,120 @@ - [[#which-key][WHICH-KEY]] * IMPORTANT PROGRAMS TO LOAD FIRST -** Elpaca Package Manager +To keep this =config.org= a reasonable length, I have moved a lot of code to individual scripts that will be sourced by this config. These scripts are found in "~/.config/emacs/scripts" and do not contain any code that most people are likely to need to edit. + +** Adding the scripts directory to path #+begin_src emacs-lisp -(defvar elpaca-installer-version 0.4) -(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory)) -(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory)) -(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory)) -(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git" - :ref nil - :files (:defaults (:exclude "extensions")) - :build (:not elpaca--activate-package))) -(let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory)) - (build (expand-file-name "elpaca/" elpaca-builds-directory)) - (order (cdr elpaca-order)) - (default-directory repo)) - (add-to-list 'load-path (if (file-exists-p build) build repo)) - (unless (file-exists-p repo) - (make-directory repo t) - (when (< emacs-major-version 28) (require 'subr-x)) - (condition-case-unless-debug err - (if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*")) - ((zerop (call-process "git" nil buffer t "clone" - (plist-get order :repo) repo))) - ((zerop (call-process "git" nil buffer t "checkout" - (or (plist-get order :ref) "--")))) - (emacs (concat invocation-directory invocation-name)) - ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch" - "--eval" "(byte-recompile-directory \".\" 0 'force)"))) - ((require 'elpaca)) - ((elpaca-generate-autoloads "elpaca" repo))) - (kill-buffer buffer) - (error "%s" (with-current-buffer buffer (buffer-string)))) -((error) (warn "%s" err) (delete-directory repo 'recursive)))) - (unless (require 'elpaca-autoloads nil t) - (require 'elpaca) - (elpaca-generate-autoloads "elpaca" repo) - (load "./elpaca-autoloads"))) -(add-hook 'after-init-hook #'elpaca-process-queues) -(elpaca `(,@elpaca-order)) - -;; Install use-package support -(elpaca elpaca-use-package - ;; Enable :elpaca use-package keyword. - (elpaca-use-package-mode) - ;; Assume :elpaca t unless otherwise specified. - (setq elpaca-use-package-by-default t)) - -;; Block until current queue processed. -(elpaca-wait) - -;;When installing a package which modifies a form used at the top-level -;;(e.g. a package which adds a use-package key word), -;;use `elpaca-wait' to block until that package has been installed/configured. -;;For example: -;;(use-package general :demand t) -;;(elpaca-wait) - -;;Turns off elpaca-use-package-mode current declartion -;;Note this will cause the declaration to be interpreted immediately (not deferred). -;;Useful for configuring built-in emacs features. -;;(use-package emacs :elpaca nil :config (setq ring-bell-function #'ignore)) - -;; Don't install anything. Defer execution of BODY -;;(elpaca nil (message "deferred")) +(add-to-list 'load-path "~/.config/emacs/scripts/") #+end_src -** Load Evil Mode +** Sourcing the scripts +#+begin_src emacs-lisp +(require 'elpaca-setup) ;; The Elpaca Package Manager +(require 'buffer-move) ;; Buffer-move for better window management +(require 'app-launchers) ;; Use emacs as a run launcher like dmenu (experimental) +#+end_src + +* ALL THE ICONS +This is an icon set that can be used with dashboard, dired, ibuffer and other Emacs programs. + +#+begin_src emacs-lisp +(use-package all-the-icons + :ensure t + :if (display-graphic-p)) + +(use-package all-the-icons-dired + :hook (dired-mode . (lambda () (all-the-icons-dired-mode t)))) +#+end_src + +* BACKUP FILES +By default, Emacs creates automatic backups of files in their original directories, such "file.el" and the backup "file.el~". This leads to a lot of clutter, so let's tell Emacs to put all backups that it creates in the =TRASH= directory. + +#+begin_src emacs-lisp +(setq backup-directory-alist '((".*" . "~/.Trash"))) + +#+end_src + +* COMPANY +[[https://company-mode.github.io/][Company]] is a text completion framework for Emacs. The name stands for "complete anything". Completion will start automatically after you type a few letters. Use M-n and M-p to select, to complete or to complete the common part. + +#+begin_src emacs-lisp +(use-package company + :defer 2 + :diminish + :custom + (company-begin-commands '(self-insert-command)) + (company-idle-delay .1) + (company-minimum-prefix-length 2) + (company-show-numbers t) + (company-tooltip-align-annotations 't) + (global-company-mode t)) + +(use-package company-box + :after company + :diminish + :hook (company-mode . company-box-mode)) +#+end_src + +* DASHBOARD +Emacs Dashboard is an extensible startup screen showing you recent files, bookmarks, agenda items and an Emacs banner. + +#+begin_src emacs-lisp +(use-package dashboard + :ensure t + :init + (setq initial-buffer-choice 'dashboard-open) + (setq dashboard-set-heading-icons t) + (setq dashboard-set-file-icons t) + (setq dashboard-banner-logo-title "Emacs Is More Than A Text Editor!") + ;;(setq dashboard-startup-banner 'logo) ;; use standard emacs logo as banner + (setq dashboard-startup-banner "/home/dt/.config/emacs/images/dtmacs-logo.png") ;; use custom image as banner + (setq dashboard-center-content nil) ;; set to 't' for centered content + (setq dashboard-items '((recents . 5) + (agenda . 5 ) + (bookmarks . 3) + (projects . 3) + (registers . 3))) + :custom + (dashboard-modify-heading-icons '((recents . "file-text") + (bookmarks . "book"))) + :config + (dashboard-setup-startup-hook)) + +#+end_src + +* DIMINISH +This package implements hiding or abbreviation of the modeline displays (lighters) of minor-modes. With this package installed, you can add ':diminish' to any use-package block to hide that particular mode in the modeline. + +#+begin_src emacs-lisp +(use-package diminish) + +#+end_src + +* DIRED +#+begin_src emacs-lisp +(use-package dired-open + :config + (setq dired-open-extensions '(("gif" . "sxiv") + ("jpg" . "sxiv") + ("png" . "sxiv") + ("mkv" . "mpv") + ("mp4" . "mpv")))) + +(use-package peep-dired + :after dired + :hook (evil-normalize-keymaps . peep-dired-hook) + :config + (evil-define-key 'normal dired-mode-map (kbd "h") 'dired-up-directory) + (evil-define-key 'normal dired-mode-map (kbd "l") 'dired-open-file) ; use dired-find-file instead if not using dired-open package + (evil-define-key 'normal peep-dired-mode-map (kbd "j") 'peep-dired-next-file) + (evil-define-key 'normal peep-dired-mode-map (kbd "k") 'peep-dired-prev-file) +) + +#+end_src + +* EVIL +[[https://github.com/emacs-evil/evil][Evil]] is an extensible vi/vim layer for Emacs. Because...let's face it. The Vim keybindings are just plain better. #+begin_src emacs-lisp ;; Expands to: (elpaca evil (use-package evil :demand t)) @@ -132,7 +178,64 @@ (use-package evil-tutor) #+end_src -** General Keybindings +* FLYCHECK +Install =luacheck= from your Linux distro's repositories for flycheck to work correctly with lua files. Install =python-pylint= for flycheck to work with python files. Haskell works with flycheck as long as =haskell-ghc= or =haskell-stack-ghc= is installed. For more information on language support for flycheck, [[https://www.flycheck.org/en/latest/languages.html][read this]]. + +#+begin_src emacs-lisp +(use-package flycheck + :ensure t + :defer t + :diminish + :init (global-flycheck-mode)) + +#+end_src + +* FONTS +Defining the various fonts that Emacs will use. + +** Setting the Font Face +#+begin_src emacs-lisp +(set-face-attribute 'default nil + :font "JetBrains Mono" + :height 110 + :weight 'medium) +(set-face-attribute 'variable-pitch nil + :font "Ubuntu" + :height 120 + :weight 'medium) +(set-face-attribute 'fixed-pitch nil + :font "JetBrains Mono" + :height 110 + :weight 'medium) +;; Makes commented text and keywords italics. +;; This is working in emacsclient but not emacs. +;; Your font must have an italic face available. +(set-face-attribute 'font-lock-comment-face nil + :slant 'italic) +(set-face-attribute 'font-lock-keyword-face nil + :slant 'italic) + +;; This sets the default font on all graphical frames created after restarting Emacs. +;; Does the same thing as 'set-face-attribute default' above, but emacsclient fonts +;; are not right unless I also add this method of setting the default font. +(add-to-list 'default-frame-alist '(font . "JetBrains Mono-11")) + +;; Uncomment the following line if line spacing needs adjusting. +(setq-default line-spacing 0.12) + +#+end_src + +** Zooming In/Out +You can use the bindings CTRL plus =/- for zooming in/out. You can also use CTRL plus the mouse wheel for zooming in/out. + +#+begin_src emacs-lisp +(global-set-key (kbd "C-=") 'text-scale-increase) +(global-set-key (kbd "C--") 'text-scale-decrease) +(global-set-key (kbd "") 'text-scale-increase) +(global-set-key (kbd "") 'text-scale-decrease) +#+end_src + +* GENERAL KEYBINDINGS #+begin_src emacs-lisp (use-package general :config @@ -239,284 +342,6 @@ #+end_src -* APP LAUNCHERS - -** Counsel-Linux-App -Since we have counsel installed, we can use =counsel-linux-app= to launch our Linux apps. It list the apps by their executable command, so it's kind of tricky to use. - -#+begin_src emacs-lisp -(defun emacs-counsel-launcher () - "Create and select a frame called emacs-counsel-launcher which consists only of a minibuffer and has specific dimensions. Runs counsel-linux-app on that frame, which is an emacs command that prompts you to select an app and open it in a dmenu like behaviour. Delete the frame after that command has exited" - (interactive) - (with-selected-frame - (make-frame '((name . "emacs-run-launcher") - (minibuffer . only) - (fullscreen . 0) ; no fullscreen - (undecorated . t) ; remove title bar - ;;(auto-raise . t) ; focus on this frame - ;;(tool-bar-lines . 0) - ;;(menu-bar-lines . 0) - (internal-border-width . 10) - (width . 80) - (height . 11))) - (unwind-protect - (counsel-linux-app) - (delete-frame)))) - -#+end_src - -** App-Launcher -The =app-launcher= is a better run launcher since it reads the desktop applications on your system and you can search them by their names as defined in their desktop file. This means that sometimes you have to search for a generic term rather than the actual binary command of the program. - -#+begin_src emacs-lisp -(use-package app-launcher - :elpaca '(app-launcher :host github :repo "SebastienWae/app-launcher")) -;; create a global keyboard shortcut with the following code -;; emacsclient -cF "((visibility . nil))" -e "(emacs-run-launcher)" - -(defun emacs-run-launcher () - "Create and select a frame called emacs-run-launcher which consists only of a minibuffer and has specific dimensions. Runs app-launcher-run-app on that frame, which is an emacs command that prompts you to select an app and open it in a dmenu like behaviour. Delete the frame after that command has exited" - (interactive) - (with-selected-frame - (make-frame '((name . "emacs-run-launcher") - (minibuffer . only) - (fullscreen . 0) ; no fullscreen - (undecorated . t) ; remove title bar - ;;(auto-raise . t) ; focus on this frame - ;;(tool-bar-lines . 0) - ;;(menu-bar-lines . 0) - (internal-border-width . 10) - (width . 80) - (height . 11))) - (unwind-protect - (app-launcher-run-app) - (delete-frame)))) - -#+end_src - -* ALL THE ICONS -This is an icon set that can be used with dashboard, dired, ibuffer and other Emacs programs. - -#+begin_src emacs-lisp -(use-package all-the-icons - :ensure t - :if (display-graphic-p)) - -(use-package all-the-icons-dired - :hook (dired-mode . (lambda () (all-the-icons-dired-mode t)))) -#+end_src - -* BUFFER-MOVE -Creating some functions to allow us to easily move windows (splits) around. The following block of code was taken from buffer-move.el found on the EmacsWiki: -https://www.emacswiki.org/emacs/buffer-move.el - -#+begin_src emacs-lisp -(require 'windmove) - -;;;###autoload -(defun buf-move-up () - "Swap the current buffer and the buffer above the split. -If there is no split, ie now window above the current one, an -error is signaled." -;; "Switches between the current buffer, and the buffer above the -;; split, if possible." - (interactive) - (let* ((other-win (windmove-find-other-window 'up)) - (buf-this-buf (window-buffer (selected-window)))) - (if (null other-win) - (error "No window above this one") - ;; swap top with this one - (set-window-buffer (selected-window) (window-buffer other-win)) - ;; move this one to top - (set-window-buffer other-win buf-this-buf) - (select-window other-win)))) - -;;;###autoload -(defun buf-move-down () -"Swap the current buffer and the buffer under the split. -If there is no split, ie now window under the current one, an -error is signaled." - (interactive) - (let* ((other-win (windmove-find-other-window 'down)) - (buf-this-buf (window-buffer (selected-window)))) - (if (or (null other-win) - (string-match "^ \\*Minibuf" (buffer-name (window-buffer other-win)))) - (error "No window under this one") - ;; swap top with this one - (set-window-buffer (selected-window) (window-buffer other-win)) - ;; move this one to top - (set-window-buffer other-win buf-this-buf) - (select-window other-win)))) - -;;;###autoload -(defun buf-move-left () -"Swap the current buffer and the buffer on the left of the split. -If there is no split, ie now window on the left of the current -one, an error is signaled." - (interactive) - (let* ((other-win (windmove-find-other-window 'left)) - (buf-this-buf (window-buffer (selected-window)))) - (if (null other-win) - (error "No left split") - ;; swap top with this one - (set-window-buffer (selected-window) (window-buffer other-win)) - ;; move this one to top - (set-window-buffer other-win buf-this-buf) - (select-window other-win)))) - -;;;###autoload -(defun buf-move-right () -"Swap the current buffer and the buffer on the right of the split. -If there is no split, ie now window on the right of the current -one, an error is signaled." - (interactive) - (let* ((other-win (windmove-find-other-window 'right)) - (buf-this-buf (window-buffer (selected-window)))) - (if (null other-win) - (error "No right split") - ;; swap top with this one - (set-window-buffer (selected-window) (window-buffer other-win)) - ;; move this one to top - (set-window-buffer other-win buf-this-buf) - (select-window other-win)))) -#+end_src - -* COMPANY -[[https://company-mode.github.io/][Company]] is a text completion framework for Emacs. The name stands for "complete anything". Completion will start automatically after you type a few letters. Use M-n and M-p to select, to complete or to complete the common part. - -#+begin_src emacs-lisp -(use-package company - :defer 2 - :diminish - :custom - (company-begin-commands '(self-insert-command)) - (company-idle-delay .1) - (company-minimum-prefix-length 2) - (company-show-numbers t) - (company-tooltip-align-annotations 't) - (global-company-mode t)) - -(use-package company-box - :after company - :diminish - :hook (company-mode . company-box-mode)) -#+end_src - -* DASHBOARD -Emacs Dashboard is an extensible startup screen showing you recent files, bookmarks, agenda items and an Emacs banner. - -#+begin_src emacs-lisp -(use-package dashboard - :ensure t - :init - (setq initial-buffer-choice 'dashboard-open) - (setq dashboard-set-heading-icons t) - (setq dashboard-set-file-icons t) - (setq dashboard-banner-logo-title "Emacs Is More Than A Text Editor!") - ;;(setq dashboard-startup-banner 'logo) ;; use standard emacs logo as banner - (setq dashboard-startup-banner "/home/dt/.config/emacs/images/dtmacs-logo.png") ;; use custom image as banner - (setq dashboard-center-content nil) ;; set to 't' for centered content - (setq dashboard-items '((recents . 5) - (agenda . 5 ) - (bookmarks . 3) - (projects . 3) - (registers . 3))) - :custom - (dashboard-modify-heading-icons '((recents . "file-text") - (bookmarks . "book"))) - :config - (dashboard-setup-startup-hook)) - -#+end_src - -* DIMINISH -This package implements hiding or abbreviation of the modeline displays (lighters) of minor-modes. With this package installed, you can add ':diminish' to any use-package block to hide that particular mode in the modeline. - -#+begin_src emacs-lisp -(use-package diminish) - -#+end_src - -* DIRED -#+begin_src emacs-lisp -(use-package dired-open - :config - (setq dired-open-extensions '(("gif" . "sxiv") - ("jpg" . "sxiv") - ("png" . "sxiv") - ("mkv" . "mpv") - ("mp4" . "mpv")))) - -(use-package peep-dired - :after dired - :hook (evil-normalize-keymaps . peep-dired-hook) - :config - (evil-define-key 'normal dired-mode-map (kbd "h") 'dired-up-directory) - (evil-define-key 'normal dired-mode-map (kbd "l") 'dired-open-file) ; use dired-find-file instead if not using dired-open package - (evil-define-key 'normal peep-dired-mode-map (kbd "j") 'peep-dired-next-file) - (evil-define-key 'normal peep-dired-mode-map (kbd "k") 'peep-dired-prev-file) -) - -#+end_src - -* FLYCHECK -Install =luacheck= from your Linux distro's repositories for flycheck to work correctly with lua files. Install =python-pylint= for flycheck to work with python files. Haskell works with flycheck as long as =haskell-ghc= or =haskell-stack-ghc= is installed. For more information on language support for flycheck, [[https://www.flycheck.org/en/latest/languages.html][read this]]. - -#+begin_src emacs-lisp -(use-package flycheck - :ensure t - :defer t - :diminish - :init (global-flycheck-mode)) - -#+end_src - -* FONTS -Defining the various fonts that Emacs will use. - -** Setting the Font Face -#+begin_src emacs-lisp -(set-face-attribute 'default nil - :font "JetBrains Mono" - :height 110 - :weight 'medium) -(set-face-attribute 'variable-pitch nil - :font "Ubuntu" - :height 120 - :weight 'medium) -(set-face-attribute 'fixed-pitch nil - :font "JetBrains Mono" - :height 110 - :weight 'medium) -;; Makes commented text and keywords italics. -;; This is working in emacsclient but not emacs. -;; Your font must have an italic face available. -(set-face-attribute 'font-lock-comment-face nil - :slant 'italic) -(set-face-attribute 'font-lock-keyword-face nil - :slant 'italic) - -;; This sets the default font on all graphical frames created after restarting Emacs. -;; Does the same thing as 'set-face-attribute default' above, but emacsclient fonts -;; are not right unless I also add this method of setting the default font. -(add-to-list 'default-frame-alist '(font . "JetBrains Mono-11")) - -;; Uncomment the following line if line spacing needs adjusting. -(setq-default line-spacing 0.12) - -#+end_src - -** Zooming In/Out -You can use the bindings CTRL plus =/- for zooming in/out. You can also use CTRL plus the mouse wheel for zooming in/out. - -#+begin_src emacs-lisp -(global-set-key (kbd "C-=") 'text-scale-increase) -(global-set-key (kbd "C--") 'text-scale-decrease) -(global-set-key (kbd "") 'text-scale-increase) -(global-set-key (kbd "") 'text-scale-decrease) -#+end_src - - * GRAPHICAL USER INTERFACE TWEAKS Let's make GNU Emacs look a little better. diff --git a/.config/emacs/scripts/app-launchers.el b/.config/emacs/scripts/app-launchers.el new file mode 100644 index 0000000..327079c --- /dev/null +++ b/.config/emacs/scripts/app-launchers.el @@ -0,0 +1,55 @@ +;;; app-launchers.el --- Possible alternatives to dmenu/rofi + +;;; Code: + +;; Counsel-Linux-App +;; Since we have counsel installed, we can use 'counsel-linux-app' to launch our Linux apps. It list the apps by their executable command, so it's kind of tricky to use. + +(defun emacs-counsel-launcher () + "Create and select a frame called emacs-counsel-launcher which consists only of a minibuffer and has specific dimensions. Runs counsel-linux-app on that frame, which is an emacs command that prompts you to select an app and open it in a dmenu like behaviour. Delete the frame after that command has exited" + (interactive) + (with-selected-frame + (make-frame '((name . "emacs-run-launcher") + (minibuffer . only) + (fullscreen . 0) ; no fullscreen + (undecorated . t) ; remove title bar + ;;(auto-raise . t) ; focus on this frame + ;;(tool-bar-lines . 0) + ;;(menu-bar-lines . 0) + (internal-border-width . 10) + (width . 80) + (height . 11))) + (unwind-protect + (counsel-linux-app) + (delete-frame)))) + + +;; App-Launcher +;; The 'app-launcher' is a better run launcher since it reads the desktop applications on your system and you can search them by their names as defined in their desktop file. This means that sometimes you have to search for a generic term rather than the actual binary command of the program. + +(use-package app-launcher + :elpaca '(app-launcher :host github :repo "SebastienWae/app-launcher")) +;; create a global keyboard shortcut with the following code +;; emacsclient -cF "((visibility . nil))" -e "(emacs-run-launcher)" + +(defun emacs-run-launcher () + "Create and select a frame called emacs-run-launcher which consists only of a minibuffer and has specific dimensions. Runs app-launcher-run-app on that frame, which is an emacs command that prompts you to select an app and open it in a dmenu like behaviour. Delete the frame after that command has exited" + (interactive) + (with-selected-frame + (make-frame '((name . "emacs-run-launcher") + (minibuffer . only) + (fullscreen . 0) ; no fullscreen + (undecorated . t) ; remove title bar + ;;(auto-raise . t) ; focus on this frame + ;;(tool-bar-lines . 0) + ;;(menu-bar-lines . 0) + (internal-border-width . 10) + (width . 80) + (height . 11))) + (unwind-protect + (app-launcher-run-app) + (delete-frame)))) + + +(provide 'app-launchers) +;;; app-launchers.el ends here diff --git a/.config/emacs/scripts/buffer-move.el b/.config/emacs/scripts/buffer-move.el new file mode 100644 index 0000000..5dcde11 --- /dev/null +++ b/.config/emacs/scripts/buffer-move.el @@ -0,0 +1,101 @@ +;;; buffer-move.el --- Buffer move allows for better window controls. + +;; Copyright (C) 2004-2014 Lucas Bonnet + +;; Author: Lucas Bonnet +;; Keywords: lisp,convenience +;; Version: 0.5 +;; URL : https://github.com/lukhas/buffer-move + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 2 +;; of the License, or (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program; if not, write to the Free Software +;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +;; 02111-1307, USA. + +;;; Commentary: + +;; This file is for lazy people wanting to swap buffers without +;; typing C-x b on each window. + +;;; Code: +(require 'windmove) + +;;;###autoload +(defun buf-move-up () + "Swap the current buffer and the buffer above the split. +If there is no split, ie now window above the current one, an +error is signaled." +;; "Switches between the current buffer, and the buffer above the +;; split, if possible." + (interactive) + (let* ((other-win (windmove-find-other-window 'up)) + (buf-this-buf (window-buffer (selected-window)))) + (if (null other-win) + (error "No window above this one") + ;; swap top with this one + (set-window-buffer (selected-window) (window-buffer other-win)) + ;; move this one to top + (set-window-buffer other-win buf-this-buf) + (select-window other-win)))) + +;;;###autoload +(defun buf-move-down () +"Swap the current buffer and the buffer under the split. +If there is no split, ie now window under the current one, an +error is signaled." + (interactive) + (let* ((other-win (windmove-find-other-window 'down)) + (buf-this-buf (window-buffer (selected-window)))) + (if (or (null other-win) + (string-match "^ \\*Minibuf" (buffer-name (window-buffer other-win)))) + (error "No window under this one") + ;; swap top with this one + (set-window-buffer (selected-window) (window-buffer other-win)) + ;; move this one to top + (set-window-buffer other-win buf-this-buf) + (select-window other-win)))) + +;;;###autoload +(defun buf-move-left () +"Swap the current buffer and the buffer on the left of the split. +If there is no split, ie now window on the left of the current +one, an error is signaled." + (interactive) + (let* ((other-win (windmove-find-other-window 'left)) + (buf-this-buf (window-buffer (selected-window)))) + (if (null other-win) + (error "No left split") + ;; swap top with this one + (set-window-buffer (selected-window) (window-buffer other-win)) + ;; move this one to top + (set-window-buffer other-win buf-this-buf) + (select-window other-win)))) + +;;;###autoload +(defun buf-move-right () +"Swap the current buffer and the buffer on the right of the split. +If there is no split, ie now window on the right of the current +one, an error is signaled." + (interactive) + (let* ((other-win (windmove-find-other-window 'right)) + (buf-this-buf (window-buffer (selected-window)))) + (if (null other-win) + (error "No right split") + ;; swap top with this one + (set-window-buffer (selected-window) (window-buffer other-win)) + ;; move this one to top + (set-window-buffer other-win buf-this-buf) + (select-window other-win)))) + +(provide 'buffer-move) +;;; buffer-move.el ends here diff --git a/.config/emacs/scripts/elpaca-setup.el b/.config/emacs/scripts/elpaca-setup.el new file mode 100644 index 0000000..3655d20 --- /dev/null +++ b/.config/emacs/scripts/elpaca-setup.el @@ -0,0 +1,68 @@ + +;;; Code: + +(defvar elpaca-installer-version 0.4) +(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory)) +(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory)) +(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory)) +(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git" + :ref nil + :files (:defaults (:exclude "extensions")) + :build (:not elpaca--activate-package))) +(let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory)) + (build (expand-file-name "elpaca/" elpaca-builds-directory)) + (order (cdr elpaca-order)) + (default-directory repo)) + (add-to-list 'load-path (if (file-exists-p build) build repo)) + (unless (file-exists-p repo) + (make-directory repo t) + (when (< emacs-major-version 28) (require 'subr-x)) + (condition-case-unless-debug err + (if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*")) + ((zerop (call-process "git" nil buffer t "clone" + (plist-get order :repo) repo))) + ((zerop (call-process "git" nil buffer t "checkout" + (or (plist-get order :ref) "--")))) + (emacs (concat invocation-directory invocation-name)) + ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch" + "--eval" "(byte-recompile-directory \".\" 0 'force)"))) + ((require 'elpaca)) + ((elpaca-generate-autoloads "elpaca" repo))) + (kill-buffer buffer) + (error "%s" (with-current-buffer buffer (buffer-string)))) +((error) (warn "%s" err) (delete-directory repo 'recursive)))) + (unless (require 'elpaca-autoloads nil t) + (require 'elpaca) + (elpaca-generate-autoloads "elpaca" repo) + (load "./elpaca-autoloads"))) +(add-hook 'after-init-hook #'elpaca-process-queues) +(elpaca `(,@elpaca-order)) + +;; Install use-package support +(elpaca elpaca-use-package + ;; Enable :elpaca use-package keyword. + (elpaca-use-package-mode) + ;; Assume :elpaca t unless otherwise specified. + (setq elpaca-use-package-by-default t)) + +;; Block until current queue processed. +(elpaca-wait) + +;;When installing a package which modifies a form used at the top-level +;;(e.g. a package which adds a use-package key word), +;;use `elpaca-wait' to block until that package has been installed/configured. +;;For example: +;;(use-package general :demand t) +;;(elpaca-wait) + +;;Turns off elpaca-use-package-mode current declartion +;;Note this will cause the declaration to be interpreted immediately (not deferred). +;;Useful for configuring built-in emacs features. +;;(use-package emacs :elpaca nil :config (setq ring-bell-function #'ignore)) + +;; Don't install anything. Defer execution of BODY +;;(elpaca nil (message "deferred")) + +(provide 'elpaca-setup) + +;;; elpaca-setup.el ends here