From 4b7fd0bfd894dd76c1d2c4e6dc3096423a23f3a1 Mon Sep 17 00:00:00 2001 From: not manx Date: Mon, 4 May 2020 17:22:29 +0000 Subject: [PATCH] use tabs properly --- config.el | 32 ++-- config.org | 448 +++++++++++++++++++++++++++-------------------------- custom.el | 6 +- init.el | 33 ++-- 4 files changed, 259 insertions(+), 260 deletions(-) diff --git a/config.el b/config.el index 471535d..f6d9bea 100644 --- a/config.el +++ b/config.el @@ -60,7 +60,7 @@ (add-hook 'org-mode-hook (local-keybind "C-c C-l" manx/org-insert-link)) -1(tool-bar-mode -1) +(tool-bar-mode -1) (menu-bar-mode -1) (scroll-bar-mode -1) (line-number-mode 1) @@ -278,34 +278,32 @@ (add-hook 'doc-view-mode-hook 'auto-revert-mode) -(setq tab-width 2 - indent-tabs-mode t) - -(defvaralias 'js-indent-level 'tab-width) +(setq-default tab-width 2 + indent-tabs-mode t) (defvaralias 'css-indent-offset 'tab-width) (defvar auto-minor-mode-alist () - "Alist of filename patterns vs correpsonding minor mode functions, see `auto-mode-alist' + "Alist of filename patterns vs correpsonding minor mode functions, see `auto-mode-alist' All elements of this alist are checked, meaning you can enable multiple minor modes for the same regexp.") (defun enable-minor-mode-based-on-extension () - "Check file name against `auto-minor-mode-alist' to enable minor modes + "Check file name against `auto-minor-mode-alist' to enable minor modes the checking happens for all pairs in auto-minor-mode-alist" - (when buffer-file-name - (let ((name (file-name-sans-versions buffer-file-name)) - (remote-id (file-remote-p buffer-file-name)) - (case-fold-search auto-mode-case-fold) - (alist auto-minor-mode-alist)) - ;; Remove remote file name identification. - (when (and (stringp remote-id) + (when buffer-file-name + (let ((name (file-name-sans-versions buffer-file-name)) + (remote-id (file-remote-p buffer-file-name)) + (case-fold-search auto-mode-case-fold) + (alist auto-minor-mode-alist)) + ;; Remove remote file name identification. + (when (and (stringp remote-id) (string-match-p (regexp-quote remote-id) name)) (setq name (substring name (match-end 0)))) - (while (and alist (caar alist) (cdar alist)) + (while (and alist (caar alist) (cdar alist)) (if (string-match-p (caar alist) name) - (funcall (cdar alist) 1)) + (funcall (cdar alist) 1)) (setq alist (cdr alist)))))) -(add-hook 'find-file-hook#'enable-minor-mode-based-on-extension) +(add-hook 'find-file-hook #'enable-minor-mode-based-on-extension) (define-minor-mode sensitive-minor-mode "For sensitive files like password lists. diff --git a/config.org b/config.org index 5df3938..826829b 100644 --- a/config.org +++ b/config.org @@ -10,208 +10,212 @@ Wrappers around functions and lambdas so I don't have to type (interactive) all the damn time #+BEGIN_SRC emacs-lisp - (defmacro definteractive (name &rest body) - `(defun ,name ,(car body) - (interactive) - ,@(cdr body))) + (defmacro definteractive (name &rest body) + `(defun ,name ,(car body) + (interactive) + ,@(cdr body))) - (defmacro lambdainteractive (&rest body) - `(lambda ,(car body) (interactive) ,@(cdr body))) + (defmacro lambdainteractive (&rest body) + `(lambda ,(car body) (interactive) ,@(cdr body))) #+END_SRC ** local-keybind Hide unecessary lambda when calling (local-set-key) for org-modefunctions #+BEGIN_SRC emacs-lisp - (defmacro local-keybind (key value) - `(lambda () (local-set-key (kbd ,key) (quote ,value)))) + (defmacro local-keybind (key value) + `(lambda () (local-set-key (kbd ,key) (quote ,value)))) #+END_SRC * org ** edit/reload config.org Saves config.org if it's open then reloads the file. #+BEGIN_SRC emacs-lisp - (definteractive manx/config-reload () - (when (get-buffer "config.org") + (definteractive manx/config-reload () + (when (get-buffer "config.org") (with-current-buffer "config.org" (save-buffer))) - (org-babel-load-file (expand-file-name "~/.emacs.d/config.org"))) + (org-babel-load-file (expand-file-name "~/.emacs.d/config.org"))) - (global-set-key (kbd "C-c x r") 'manx/config-reload) - (global-set-key (kbd "C-c x e") (lambdainteractive ()(find-file "~/.emacs.d/config.org"))) + (global-set-key (kbd "C-c x r") 'manx/config-reload) + (global-set-key (kbd "C-c x e") (lambdainteractive ()(find-file "~/.emacs.d/config.org"))) #+END_SRC ** misc #+BEGIN_SRC emacs-lisp - (setq org-src-window-setup 'current-window) + (setq org-src-window-setup 'current-window) - ;; I read somewhere that Company breaks things? - (add-hook 'org-mode-hook 'company-mode) + ;; I read somewhere that Company breaks things? + (add-hook 'org-mode-hook 'company-mode) - ;; Don't indent whole file with org-mode - (eval-after-load "org-mode" (local-set-key (kbd "s-i") nil)) + ;; Don't indent whole file with org-mode + (eval-after-load "org-mode" (local-set-key (kbd "s-i") nil)) #+END_SRC ** Snippets #+BEGIN_SRC emacs-lisp - (setq org-structure-template-alist + (setq org-structure-template-alist (append '(("el" "#+BEGIN_SRC emacs-lisp\n?\n#+END_SRC") - ("js" "#+BEGIN_SRC javascript\n?\n#+END_SRC")) + ("js" "#+BEGIN_SRC javascript\n?\n#+END_SRC")) org-structure-template-alist)) #+END_SRC ** html export #+BEGIN_SRC emacs-lisp - (setq org-html-doctype "html5") + (setq org-html-doctype "html5") - (definteractive manx/save-org-to-html() - (when (equal major-mode 'org-mode) - (save-buffer) - (org-html-export-to-html))) + (definteractive manx/save-org-to-html() + (when (equal major-mode 'org-mode) + (save-buffer) + (org-html-export-to-html))) - (add-hook 'org-mode-hook - (local-keybind "C-c s h" manx/save-org-to-html)) + (add-hook 'org-mode-hook + (local-keybind "C-c s h" manx/save-org-to-html)) #+END_SRC ** Links #+BEGIN_SRC emacs-lisp - (definteractive manx/delete-org-link () - (if (org-in-regexp org-bracket-link-regexp 1) + (definteractive manx/delete-org-link () + (if (org-in-regexp org-bracket-link-regexp 1) (apply 'delete-region (list (match-beginning 0) (match-end 0))))) - (add-hook 'org-mode-hook (local-keybind "C-c o l" manx/delete-org-link)) + (add-hook 'org-mode-hook (local-keybind "C-c o l" manx/delete-org-link)) #+END_SRC *** Inline Images #+BEGIN_SRC emacs-lisp - (setq org-image-actual-width 150) + (setq org-image-actual-width 150) - (definteractive manx/org-insert-link () - (org-insert-link) - (org-redisplay-inline-images)) + (definteractive manx/org-insert-link () + (org-insert-link) + (org-redisplay-inline-images)) - (add-hook 'org-mode-hook (local-keybind "C-c C-l" manx/org-insert-link)) + (add-hook 'org-mode-hook (local-keybind "C-c C-l" manx/org-insert-link)) #+END_SRC * emacs gui #+BEGIN_SRC emacs-lisp - 1(tool-bar-mode -1) - (menu-bar-mode -1) - (scroll-bar-mode -1) - (line-number-mode 1) - (column-number-mode 1) - (display-battery-mode 1) + (tool-bar-mode -1) + (menu-bar-mode -1) + (scroll-bar-mode -1) + (line-number-mode 1) + (column-number-mode 1) + (display-battery-mode 1) - (global-unset-key (kbd "C-z")) + (global-unset-key (kbd "C-z")) #+END_SRC * functions ** text +*** forward whitespace +#+BEGIN_SRC emacs-lisp + (global-set-k'ey (kbd "") 'forward-whitespace) +#+END_SRC *** kill whole word #+BEGIN_SRC emacs-lisp - (definteractive manx/kill-whole-word () - (backward-word) - (kill-word 1)) + (definteractive manx/kill-whole-word () + (backward-word) + (kill-word 1)) - (global-set-key (kbd "C-c k w") 'manx/kill-whole-word) + (global-set-key (kbd "C-c k w") 'manx/kill-whole-word) #+END_SRC *** kill whole line #+BEGIN_SRC emacs-lisp - (definteractive manx/kill-whole-line() - (move-beginning-of-line nil) - (kill-whole-line)) + (definteractive manx/kill-whole-line() + (move-beginning-of-line nil) + (kill-whole-line)) - (global-set-key (kbd "C-c k l") 'manx/kill-whole-line) + (global-set-key (kbd "C-c k l") 'manx/kill-whole-line) #+END_SRC *** revert buffer #+BEGIN_SRC emacs-lisp - (global-set-key (kbd "C-c r b") 'revert-buffer) + (global-set-key (kbd "C-c r b") 'revert-buffer) #+END_SRC *** Format whole file #+BEGIN_SRC emacs-lisp - (definteractive manx/format-whole-buffer() - (save-excursion - (indent-region (point-min) (point-max) nil))) + (definteractive manx/format-whole-buffer() + (save-excursion + (indent-region (point-min) (point-max) nil))) - (global-set-key (kbd "s-i") 'manx/format-whole-buffer) + (global-set-key (kbd "s-i") 'manx/format-whole-buffer) #+END_SRC *** colour under cursor #+BEGIN_SRC emacs-lisp - (defun what-face (pos) - (interactive "d") - (let ((face (or (get-char-property (pos) 'read-face-name) - (get-char-property (pos) 'face)))) - (if face (message "Face: %s" face) (message "No face at %d" pos)))) + (defun what-face (pos) + (interactive "d") + (let ((face (or (get-char-property (pos) 'read-face-name) + (get-char-property (pos) 'face)))) + (if face (message "Face: %s" face) (message "No face at %d" pos)))) #+END_SRC ** buffers #+BEGIN_SRC emacs-lisp - (global-set-key (kbd "C-x k") (lambdainteractive () (kill-buffer (current-buffer)))) - (global-set-key (kbd "C-M-s-k") (lambdainteractive () (mapc 'kill-buffer (buffer-list)))) + (global-set-key (kbd "C-x k") (lambdainteractive () (kill-buffer (current-buffer)))) + (global-set-key (kbd "C-M-s-k") (lambdainteractive () (mapc 'kill-buffer (buffer-list)))) #+END_SRC ** frames *** transpose-frame #+BEGIN_SRC emacs-lisp - ;; This is only used here for now but we should still more it some - ;; time - (add-to-list 'load-path "~/.emacs.d/scripts/") + ;; This is only used here for now but we should still more it some + ;; time + (add-to-list 'load-path "~/.emacs.d/scripts/") - (require 'transpose-frame) - (global-set-key (kbd "C-c f t") 'transpose-frame) - (global-set-key (kbd "C-c f i") 'flip-frame) - (global-set-key (kbd "C-c f o") 'flop-frame) + (require 'transpose-frame) + (global-set-key (kbd "C-c f t") 'transpose-frame) + (global-set-key (kbd "C-c f i") 'flip-frame) + (global-set-key (kbd "C-c f o") 'flop-frame) #+END_SRC *** split and follow #+BEGIN_SRC emacs-lisp - (defmacro manx/split-and-follow (direction) - `(progn - ,direction - (balance-windows) - (other-window 1))) + (defmacro manx/split-and-follow (direction) + `(progn + ,direction + (balance-windows) + (other-window 1))) - (global-set-key (kbd "C-x 3") (lambdainteractive () (manx/split-and-follow (split-window-below)))) - (global-set-key (kbd "C-x 2") (lambdainteractive () (manx/split-and-follow (split-window-horizontally)))) + (global-set-key (kbd "C-x 3") (lambdainteractive () (manx/split-and-follow (split-window-below)))) + (global-set-key (kbd "C-x 2") (lambdainteractive () (manx/split-and-follow (split-window-horizontally)))) #+END_SRC * use-package #+BEGIN_SRC emacs-lisp - (setq use-package-always-ensure t - use-package-verbose t) + (setq use-package-always-ensure t + use-package-verbose t) #+END_SRC ** diminish #+BEGIN_SRC emacs-lisp - (use-package diminish) + (use-package diminish) #+END_SRC ** keychain-environment #+BEGIN_SRC emacs-lisp - (use-package keychain-environment - :bind ("C-c r e" . 'keychain-refresh-environment) - :init (keychain-refresh-environment)) + (use-package keychain-environment + :bind ("C-c r e" . 'keychain-refresh-environment) + :init (keychain-refresh-environment)) #+END_SRC ** exwm #+BEGIN_SRC emacs-lisp - (unless (display-graphic-p) - (use-package exwm - :bind ("s-k" . 'exwm-workspace-delete) - :config - (require 'exwm-config) - (require 'exwm-systemtray) - (exwm-systemtray-enable))) + (unless (display-graphic-p) + (use-package exwm + :bind ("s-k" . 'exwm-workspace-delete) + :config + (require 'exwm-config) + (require 'exwm-systemtray) + (exwm-systemtray-enable))) #+END_SRC ** nginx #+BEGIN_SRC emacs-lisp - (use-package nginx-mode - :custom - (nginx-indent-tabs-mode t) - (nginx-indent-level 2) - :config (add-to-list 'auto-mode-alist '("/nginx/sites-\\(?:available\\|enabled\\)/" . nginx-mode))) + (use-package nginx-mode + :custom + (nginx-indent-tabs-mode t) + (nginx-indent-level 2) + :config (add-to-list 'auto-mode-alist '("/nginx/sites-\\(?:available\\|enabled\\)/" . nginx-mode))) #+END_SRC ** company #+BEGIN_SRC emacs-lisp - (use-package company - :diminish 'company-mode - :bind (:map company-mode-map + (use-package company + :diminish 'company-mode + :bind (:map company-mode-map ("C-c /" . 'yas-expand)) - :custom - (company-idle-delay 0) - (company-minimum-prefix-length 3) - :init (add-hook 'after-init-hook 'global-company-mode)) + :custom + (company-idle-delay 0) + (company-minimum-prefix-length 3) + :init (add-hook 'after-init-hook 'global-company-mode)) #+END_SRC ** c# #+BEGIN_SRC emacs-lisp - (use-package csharp-mode - :defer t - :config - (use-package omnisharp + (use-package csharp-mode + :defer t + :config + (use-package omnisharp :defer t :config (add-hook 'csharp-mode-hook 'omnisharp-mode) @@ -220,169 +224,167 @@ Saves config.org if it's open then reloads the file. #+END_SRC ** spaceline #+BEGIN_SRC emacs-lisp - (use-package spaceline - :init - (require 'spaceline-config) - (setq powerline-default-seperator (quote arrow)) - (spaceline-spacemacs-theme) - :config (spaceline-toggle-buffer-size-off)) + (use-package spaceline + :init + (require 'spaceline-config) + (setq powerline-default-seperator (quote arrow)) + (spaceline-spacemacs-theme) + :config (spaceline-toggle-buffer-size-off)) #+END_SRC ** dashboard #+BEGIN_SRC emacs-lisp - (use-package dashboard - :diminish (dashboard-mode page-break-lines-mode) - :custom - (dashboard-center-content t) - (dashboard-banner-logo-title "Komacs") - (dashboard-set-init-info t) - (dashboard-startup-banner "~/.emacs.d/Komacs.png") - (dashboard-show-shortcuts nil) - (dashboard-items '((recents . 5))) - :config (dashboard-setup-startup-hook)) + (use-package dashboard + :diminish (dashboard-mode page-break-lines-mode) + :custom + (dashboard-center-content t) + (dashboard-banner-logo-title "Komacs") + (dashboard-set-init-info t) + (dashboard-startup-banner "~/.emacs.d/Komacs.png") + (dashboard-show-shortcuts nil) + (dashboard-items '((recents . 5))) + :config (dashboard-setup-startup-hook)) - (setq initial-buffer-choice (lambda () (get-buffer "*dashboard*"))) + (setq initial-buffer-choice (lambda () (get-buffer "*dashboard*"))) #+END_SRC ** slime #+BEGIN_SRC emacs-lisp - (use-package slime - :defer t - :custom - (slime-lisp-implementations - '((sbcl ("sbcl" "--core" "/usr/lib64/sbcl/sbcl.core") - :env ("SBCL_HOME=/usr/lib64/sbcl/")))) - :diminish 'slime-mode - :init - (use-package slime-company) - (add-hook 'lisp-mode-hook 'slime-mode) - (slime-setup '(slime-fancy slime-company))) + (use-package slime + :defer t + :custom + (slime-lisp-implementations + '((sbcl ("sbcl" "--core" "/usr/lib64/sbcl/sbcl.core") + :env ("SBCL_HOME=/usr/lib64/sbcl/")))) + :diminish 'slime-mode + :init + (use-package slime-company) + (add-hook 'lisp-mode-hook 'slime-mode) + (slime-setup '(slime-fancy slime-company))) #+END_SRC ** switch window #+BEGIN_SRC emacs-lisp - (use-package switch-window - :custom - (switch-window-input-style 'minibuffer) - (switch-window-increase 4) - (switch-window-threshold 2) - :bind ([remap other-window] . switch-window)) + (use-package switch-window + :custom + (switch-window-input-style 'minibuffer) + (switch-window-increase 4) + (switch-window-threshold 2) + :bind ([remap other-window] . switch-window)) #+END_SRC ** elixir #+BEGIN_SRC emacs-lisp - (use-package elixir-mode - :defer t - :config (use-package alchemist)) + (use-package elixir-mode + :defer t + :config (use-package alchemist)) #+END_SRC ** yasnippet #+BEGIN_SRC emacs-lisp - (use-package yasnippet - :diminish 'yas-minor-mode - :hook ((html-mode - LaTeX-mode - emacs-lisp-mode - lisp-mode) - . yas-minor-mode) - :init - (use-package yasnippet-snippets) - (yas-reload-all)) + (use-package yasnippet + :diminish 'yas-minor-mode + :hook ((html-mode + LaTeX-mode + emacs-lisp-mode + lisp-mode) + . yas-minor-mode) + :init + (use-package yasnippet-snippets) + (yas-reload-all)) #+END_SRC ** minor modes *** hungry delete #+BEGIN_SRC emacs-lisp - (use-package hungry-delete - :diminish 'hungry-delete-mode - :config (global-hungry-delete-mode 1)) + (use-package hungry-delete + :diminish 'hungry-delete-mode + :config (global-hungry-delete-mode 1)) #+END_SRC *** which key #+BEGIN_SRC emacs-lisp - (use-package which-key - :diminish 'which-key-mode - :config (which-key-mode)) + (use-package which-key + :diminish 'which-key-mode + :config (which-key-mode)) #+END_SRC *** avy #+BEGIN_SRC emacs-lisp - (use-package avy - :bind ("M-s" . avy-goto-char)) + (use-package avy + :bind ("M-s" . avy-goto-char)) #+END_SRC *** beacon #+BEGIN_SRC emacs-lisp - (use-package beacon - :diminish 'beacon-mode - :config (beacon-mode 1)) + (use-package beacon + :diminish 'beacon-mode + :config (beacon-mode 1)) #+END_SRC *** popup kill ring #+BEGIN_SRC emacs-lisp - (use-package popup-kill-ring - :bind ("M-y" . popup-kill-ring)) + (use-package popup-kill-ring + :bind ("M-y" . popup-kill-ring)) #+END_SRC * ido #+BEGIN_SRC emacs-lisp - (setq ido-enable-flex-matching t + (setq ido-enable-flex-matching t ido-create-new-buffer 'always ido-everywhere 1) - (use-package ido-vertical-mode - :bind ("C-l" . 'ido-reread-directory) - :custom - (ido-vertical-define-keys 'C-n-and-C-p-only) - :config - (ido-vertical-mode 1) - (ido-mode 1)) + (use-package ido-vertical-mode + :bind ("C-l" . 'ido-reread-directory) + :custom + (ido-vertical-define-keys 'C-n-and-C-p-only) + :config + (ido-vertical-mode 1) + (ido-mode 1)) #+END_SRC * misc ** unix line endings #+BEGIN_SRC emacs-lisp - (defun unix-line-ends () - (let ((coding-str (symbol-name buffer-file-coding-system))) - (when (string-match "-\\(?:dos\\|mac\\)$" coding-str) - (set-buffer-file-coding-system 'unix)))) + (defun unix-line-ends () + (let ((coding-str (symbol-name buffer-file-coding-system))) + (when (string-match "-\\(?:dos\\|mac\\)$" coding-str) + (set-buffer-file-coding-system 'unix)))) - (add-hook 'find-file-hooks 'unix-line-ends) + (add-hook 'find-file-hooks 'unix-line-ends) #+END_SRC ** UTF8 #+BEGIN_SRC emacs-lisp - (setq locale-coding-system 'utf-8) - (set-terminal-coding-system 'utf-8) - (set-keyboard-coding-system 'utf-8) - (set-selection-coding-system 'utf-8) - (prefer-coding-system 'utf-8) - (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)) + (setq locale-coding-system 'utf-8) + (set-terminal-coding-system 'utf-8) + (set-keyboard-coding-system 'utf-8) + (set-selection-coding-system 'utf-8) + (prefer-coding-system 'utf-8) + (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)) #+END_SRC ** terminal *** Make bash implicit terminal #+BEGIN_SRC emacs-lisp - (defvar my-term-shell "/bin/bash") - (defadvice ansi-term (before force-bash) - (interactive (list my-term-shell))) - (ad-activate 'ansi-term) + (defvar my-term-shell "/bin/bash") + (defadvice ansi-term (before force-bash) + (interactive (list my-term-shell))) + (ad-activate 'ansi-term) - (global-set-key (kbd "") 'ansi-term) + (global-set-key (kbd "") 'ansi-term) #+END_SRC ** minor things #+BEGIN_SRC emacs-lisp - (show-paren-mode 1) - (electric-pair-mode t) - (global-hl-line-mode t) - (global-prettify-symbols-mode t) + (show-paren-mode 1) + (electric-pair-mode t) + (global-hl-line-mode t) + (global-prettify-symbols-mode t) - (defalias 'yes-or-no-p 'y-or-n-p) + (defalias 'yes-or-no-p 'y-or-n-p) - (setq scroll-conservatively 100 + (setq scroll-conservatively 100 x-select-enable-clipboard t vc-follow-symlinks t) - (setq backup-directory-alist + (setq backup-directory-alist `(("." . ,(concat user-emacs-directory "autosaves")))) #+END_SRC ** docView auto reload #+BEGIN_SRC emacs-lisp - (add-hook 'doc-view-mode-hook 'auto-revert-mode) + (add-hook 'doc-view-mode-hook 'auto-revert-mode) #+END_SRC -** Indentation +** indentation #+BEGIN_SRC emacs-lisp - (setq tab-width 2 - indent-tabs-mode t) - - (defvaralias 'js-indent-level 'tab-width) - (defvaralias 'css-indent-offset 'tab-width) + (setq-default tab-width 2 + indent-tabs-mode t) + (defvaralias 'css-indent-offset 'tab-width) #+END_SRC * auto-minor-mode auto-mode-alist for minor modes. @@ -390,28 +392,28 @@ auto-mode-alist for minor modes. For example, used with sensitive-mode to not create backups (path/to/file~) when creating yasnippets #+BEGIN_SRC emacs-lisp - (defvar auto-minor-mode-alist () - "Alist of filename patterns vs correpsonding minor mode functions, see `auto-mode-alist' - All elements of this alist are checked, meaning you can enable multiple minor modes for the same regexp.") + (defvar auto-minor-mode-alist () + "Alist of filename patterns vs correpsonding minor mode functions, see `auto-mode-alist' + All elements of this alist are checked, meaning you can enable multiple minor modes for the same regexp.") - (defun enable-minor-mode-based-on-extension () - "Check file name against `auto-minor-mode-alist' to enable minor modes - the checking happens for all pairs in auto-minor-mode-alist" - (when buffer-file-name - (let ((name (file-name-sans-versions buffer-file-name)) - (remote-id (file-remote-p buffer-file-name)) - (case-fold-search auto-mode-case-fold) - (alist auto-minor-mode-alist)) - ;; Remove remote file name identification. - (when (and (stringp remote-id) - (string-match-p (regexp-quote remote-id) name)) - (setq name (substring name (match-end 0)))) - (while (and alist (caar alist) (cdar alist)) - (if (string-match-p (caar alist) name) - (funcall (cdar alist) 1)) - (setq alist (cdr alist)))))) + (defun enable-minor-mode-based-on-extension () + "Check file name against `auto-minor-mode-alist' to enable minor modes + the checking happens for all pairs in auto-minor-mode-alist" + (when buffer-file-name + (let ((name (file-name-sans-versions buffer-file-name)) + (remote-id (file-remote-p buffer-file-name)) + (case-fold-search auto-mode-case-fold) + (alist auto-minor-mode-alist)) + ;; Remove remote file name identification. + (when (and (stringp remote-id) + (string-match-p (regexp-quote remote-id) name)) + (setq name (substring name (match-end 0)))) + (while (and alist (caar alist) (cdar alist)) + (if (string-match-p (caar alist) name) + (funcall (cdar alist) 1)) + (setq alist (cdr alist)))))) - (add-hook 'find-file-hook#'enable-minor-mode-based-on-extension) + (add-hook 'find-file-hook #'enable-minor-mode-based-on-extension) #+END_SRC * sensitive-minor-mode #+BEGIN_SRC emacs-lisp diff --git a/custom.el b/custom.el index 70312ce..e2c4156 100644 --- a/custom.el +++ b/custom.el @@ -22,7 +22,7 @@ '(nginx-indent-tabs-mode t) '(package-selected-packages (quote - (benchmark-init alchemist elixir-mode nginx-mode ac-js2 pdf-tools yasnippet-snippets which-key use-package symon switch-window spacemacs-theme spaceline slime-company popup-kill-ring omnisharp keychain-environment js2-mode ido-vertical-mode hungry-delete exwm diminish dashboard company-auctex beacon avy))) + (benchmark-init alchemist elixir-mode nginx-mode yasnippet-snippets which-key use-package switch-window spacemacs-theme spaceline slime-company popup-kill-ring omnisharp keychain-environment ido-vertical-mode hungry-delete exwm diminish dashboard company-auctex beacon avy))) '(slime-lisp-implementations (quote ((sbcl @@ -30,8 +30,8 @@ :env ("SBCL_HOME=/usr/lib64/sbcl/")))) t) '(switch-window-increase 4 t) - '(switch-window-input-style (quote minibuffer) t) - '(switch-window-threshold 2 t)) + '(switch-window-input-style (quote minibuffer)) + '(switch-window-threshold 2)) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. diff --git a/init.el b/init.el index 06cc54b..1a8804a 100644 --- a/init.el +++ b/init.el @@ -2,24 +2,24 @@ (require 'package) (setq package-enable-at-startup nil) (add-to-list 'package-archives - '("melpa" . "http://melpa.milkbox.net/packages/") t) + '("melpa" . "http://melpa.milkbox.net/packages/") t) (package-initialize) (unless (package-installed-p 'use-package) - (package-refresh-contents) - (package-install 'use-package)) + (package-refresh-contents) + (package-install 'use-package)) (unless (package-installed-p 'spacemacs-theme) - (package-refresh-contents) - (package-install 'spacemacs-theme)) + (package-refresh-contents) + (package-install 'spacemacs-theme)) (defun in-emacs-home (file) - "Checks if a file exists in your emacs home" - (when (stringp file) - (let ((file (concat user-emacs-directory file))) - (when (file-exists-p file) - file)))) + "Checks if a file exists in your emacs home" + (when (stringp file) + (let ((file (concat user-emacs-directory file))) + (when (file-exists-p file) + file)))) ;; Files we care about loading (setq custom-file (in-emacs-home "custom.el")) @@ -28,10 +28,9 @@ (defconst emacs-email (in-emacs-home "email.el")) ;; If everything exists then execute files -(when (mapcar (lambda (x) (not (null x))) - (list custom-file emacs-config emacs-org emacs-email)) - (if (file-newer-than-file-p emacs-org emacs-config) - (org-babel-load-file emacs-org) - (load emacs-config)) - (load custom-file 'noerrror) - (load emacs-email 'noerror)) +(unless (member nil '(custom-file emacs-config emacs-org emacs-email)) + (if (file-newer-than-file-p emacs-org emacs-config) + (org-babel-load-file emacs-org) + (load emacs-config)) + (load custom-file 'noerrror) + (load emacs-email 'noerror))