diff --git a/core/core-editor.el b/core/core-editor.el index 0b5f72ebb..b89a68f3d 100644 --- a/core/core-editor.el +++ b/core/core-editor.el @@ -75,43 +75,6 @@ fundamental-mode) for performance sake." (fundamental-mode)))) (add-hook 'find-file-hook #'doom|check-large-file) -;; Automatic minor modes -(defvar doom-auto-minor-mode-alist '() - "Alist mapping filename patterns to corresponding minor mode functions, like -`auto-mode-alist'. All elements of this alist are checked, meaning you can -enable multiple minor modes for the same regexp.") - -(defun doom|enable-minor-mode-maybe () - "Check file name against `doom-auto-minor-mode-alist'." - (when buffer-file-name - (let ((name buffer-file-name) - (remote-id (file-remote-p buffer-file-name)) - (alist doom-auto-minor-mode-alist)) - ;; Remove backup-suffixes from file name. - (setq name (file-name-sans-versions name)) - ;; 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 #'doom|enable-minor-mode-maybe) - -(defun doom*set-indirect-buffer-filename (orig-fn base-buffer name &optional clone) - "In indirect buffers, `buffer-file-name' is nil, which can cause problems -with functions that require it (like modeline segments)." - (let ((file-name (buffer-file-name base-buffer)) - (buffer (funcall orig-fn base-buffer name clone))) - (when (and file-name buffer) - (with-current-buffer buffer - (unless buffer-file-name - (setq buffer-file-name file-name - buffer-file-truename (file-truename file-name))))) - buffer)) -(advice-add #'make-indirect-buffer :around #'doom*set-indirect-buffer-filename) - (push '("/LICENSE$" . text-mode) auto-mode-alist) diff --git a/core/core.el b/core/core.el index 476363332..a72914a07 100644 --- a/core/core.el +++ b/core/core.el @@ -105,17 +105,6 @@ melodramatic ex-vimmer disappointed with the text-editor status quo." url-cache-directory (concat doom-cache-dir "url/") url-configuration-directory (concat doom-etc-dir "url/")) -(after! epa - (setq epa-file-encrypt-to (or epa-file-encrypt-to user-mail-address) - ;; With GPG 2.1, this lets Emacs prompt for gpg key passphrases - epa-pinentry-mode 'loopback)) - -(defun doom*no-authinfo-for-tramp (orig-fn &rest args) - "Don't look into .authinfo for local sudo TRAMP buffers." - (let ((auth-sources (if (equal tramp-current-method "sudo") nil auth-sources))) - (apply orig-fn args))) -(advice-add #'tramp-read-passwd :around #'doom*no-authinfo-for-tramp) - ;; move custom defs out of init.el (setq custom-file (concat doom-etc-dir "custom.el")) (load custom-file t t) @@ -201,5 +190,53 @@ ability to invoke the debugger in debug mode." (add-hook! '(emacs-startup-hook doom-reload-hook) #'doom|finalize)) + +;; +;; Emacs fixes/hacks +;; + +;; Automatic minor modes +(defvar doom-auto-minor-mode-alist '() + "Alist mapping filename patterns to corresponding minor mode functions, like +`auto-mode-alist'. All elements of this alist are checked, meaning you can +enable multiple minor modes for the same regexp.") + +(defun doom|enable-minor-mode-maybe () + "Check file name against `doom-auto-minor-mode-alist'." + (when buffer-file-name + (let ((name buffer-file-name) + (remote-id (file-remote-p buffer-file-name)) + (alist doom-auto-minor-mode-alist)) + ;; Remove backup-suffixes from file name. + (setq name (file-name-sans-versions name)) + ;; 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 #'doom|enable-minor-mode-maybe) + +(defun doom*set-indirect-buffer-filename (orig-fn base-buffer name &optional clone) + "In indirect buffers, `buffer-file-name' is nil, which can cause problems +with functions that require it (like modeline segments)." + (let ((file-name (buffer-file-name base-buffer)) + (buffer (funcall orig-fn base-buffer name clone))) + (when (and file-name buffer) + (with-current-buffer buffer + (unless buffer-file-name + (setq buffer-file-name file-name + buffer-file-truename (file-truename file-name))))) + buffer)) +(advice-add #'make-indirect-buffer :around #'doom*set-indirect-buffer-filename) + +(defun doom*no-authinfo-for-tramp (orig-fn &rest args) + "Don't look into .authinfo for local sudo TRAMP buffers." + (let ((auth-sources (if (equal tramp-current-method "sudo") nil auth-sources))) + (apply orig-fn args))) +(advice-add #'tramp-read-passwd :around #'doom*no-authinfo-for-tramp) + (provide 'core) ;;; core.el ends here diff --git a/modules/private/default/config.el b/modules/private/default/config.el index 795f15fba..dcce9d698 100644 --- a/modules/private/default/config.el +++ b/modules/private/default/config.el @@ -1,8 +1,23 @@ ;;; private/default/config.el -*- lexical-binding: t; -*- +;; +;; Plugins +;; + (def-package! emacs-snippets :after yasnippet) +;; +;; Config +;; + +(after! epa + (setq epa-file-encrypt-to (or epa-file-encrypt-to user-mail-address) + ;; With GPG 2.1, this forces gpg-agent to use the Emacs minibuffer to + ;; prompt for the key passphrase. + epa-pinentry-mode 'loopback)) + + ;; ;; Custom Ex-commands for `evil-mode' ;;