From 6b69eaa39773e7bdefc62d31788ca5ea288a8b94 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 26 Apr 2019 17:42:44 -0400 Subject: [PATCH] Minor refactors across the board --- bin/doom-doctor | 3 +-- core/autoload/sessions.el | 28 ++++++++++++++---------- core/core-modules.el | 2 +- modules/config/default/+evil-bindings.el | 2 +- modules/emacs/dired/config.el | 3 --- modules/lang/emacs-lisp/config.el | 4 ++-- modules/ui/doom-dashboard/config.el | 13 ++++++----- 7 files changed, 29 insertions(+), 26 deletions(-) diff --git a/bin/doom-doctor b/bin/doom-doctor index b9dcc0a2f..5c235c178 100755 --- a/bin/doom-doctor +++ b/bin/doom-doctor @@ -329,11 +329,10 @@ (require 'core-projects) (require 'core-editor) (require 'core-packages) - (success! "Loaded Doom Emacs %s" doom-version) ;; ...and initialized (doom-initialize) - (success! "Initialized Doom Emacs" doom-version) + (success! "Initialized Doom Emacs %s" doom-version) (doom-initialize-modules) (if (hash-table-p doom-modules) diff --git a/core/autoload/sessions.el b/core/autoload/sessions.el index 1ba92fd85..3474fc3e1 100644 --- a/core/autoload/sessions.el +++ b/core/autoload/sessions.el @@ -3,6 +3,17 @@ ;; ;;; Helpers +;;;###autoload +(defun doom-session-file (&optional name) + "TODO" + (cond ((require 'persp-mode nil t) + (expand-file-name (or name persp-auto-save-fname) persp-save-dir)) + ((require 'desktop nil t) + (if name + (expand-file-name name (file-name-directory (desktop-full-file-name))) + (desktop-full-file-name))) + ((error "No session backend available")))) + ;;;###autoload (defun doom-save-session (&optional file) "TODO" @@ -20,7 +31,9 @@ (desktop-restore-eager t) desktop-file-modtime) (make-directory desktop-dirname t) - (desktop-save desktop-dirname t))) + ;; Prevents confirmation prompts + (let ((desktop-file-modtime (nth 5 (file-attributes (desktop-full-file-name))))) + (desktop-save desktop-dirname t)))) ((error "No session backend to save session with")))) ;;;###autoload @@ -29,22 +42,14 @@ (setq file (expand-file-name (or file (doom-session-file)))) (message "Attempting to load %s" file) (cond ((require 'persp-mode nil t) - (unless persp-mode (persp-mode +1)) + (unless persp-mode + (persp-mode +1)) (persp-load-state-from-file file)) ((and (require 'frameset nil t) (require 'restart-emacs nil t)) (restart-emacs--restore-frames-using-desktop file)) ((error "No session backend to load session with")))) -;;;###autoload -(defun doom-session-file () - "TODO" - (cond ((require 'persp-mode nil t) - (expand-file-name persp-auto-save-fname persp-save-dir)) - ((require 'desktop nil t) - (desktop-full-file-name)) - ((error "No session backend available")))) - ;; ;;; Command line switch @@ -114,6 +119,7 @@ (defun doom/restart-and-restore (&optional debug) "TODO" (interactive "P") + (setq doom-autosave-session nil) (doom/quicksave-session) (restart-emacs (delq nil (list (if debug "--debug-init") "--restore")))) diff --git a/core/core-modules.el b/core/core-modules.el index 8b7d4f66b..8a9b960a6 100644 --- a/core/core-modules.el +++ b/core/core-modules.el @@ -236,7 +236,7 @@ non-nil, return paths of possible modules, activated or otherwise." (after! use-package-core ;; :ensure and :pin don't work well with Doom, so we forcibly remove them. (dolist (keyword '(:ensure :pin)) - (setq use-package-keywords (delq keyword use-package-keywords))) + (delq! keyword use-package-keywords)) ;; Insert new deferring keywords (dolist (keyword '(:defer-incrementally :after-call)) diff --git a/modules/config/default/+evil-bindings.el b/modules/config/default/+evil-bindings.el index 69c200a24..74adc13e2 100644 --- a/modules/config/default/+evil-bindings.el +++ b/modules/config/default/+evil-bindings.el @@ -17,7 +17,7 @@ "M-;" #'eval-expression "A-;" #'eval-expression) - ;; Smart tab + ;; Smart tab, these will only work in GUI Emacs :i [tab] (general-predicate-dispatch nil ; fall back to nearest keymap (and (featurep! :editor snippets) (bound-and-true-p yas-minor-mode) diff --git a/modules/emacs/dired/config.el b/modules/emacs/dired/config.el index f919bbeca..9953b2a0b 100644 --- a/modules/emacs/dired/config.el +++ b/modules/emacs/dired/config.el @@ -34,9 +34,6 @@ (let (buffer-read-only) (forward-line 2) ;; beyond dir. header (sort-regexp-fields t "^.*$" "[ ]*." (point) (point-max)))) - (and (featurep 'xemacs) - (fboundp 'dired-insert-set-properties) - (dired-insert-set-properties (point-min) (point-max))) (set-buffer-modified-p nil)) (add-hook 'dired-after-readin-hook #'+dired|sort-directories-first) diff --git a/modules/lang/emacs-lisp/config.el b/modules/lang/emacs-lisp/config.el index 9b515a8d5..c6b298019 100644 --- a/modules/lang/emacs-lisp/config.el +++ b/modules/lang/emacs-lisp/config.el @@ -52,8 +52,8 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.") ;; initialization +emacs-lisp|extend-imenu)) - ;; Flycheck produces a *lot* of false positives in emacs configs, so disable - ;; it when you're editing them + ;; Flycheck's two emacs-lisp checkers produce a *lot* of false positives in + ;; emacs configs, so disable it when you're editing them (add-hook 'flycheck-mode-hook #'+emacs-lisp|disable-flycheck-maybe) ;; Special fontification for elisp diff --git a/modules/ui/doom-dashboard/config.el b/modules/ui/doom-dashboard/config.el index 194917c76..e09288365 100644 --- a/modules/ui/doom-dashboard/config.el +++ b/modules/ui/doom-dashboard/config.el @@ -137,6 +137,7 @@ PLIST can have the following properties: "Major mode for the DOOM dashboard buffer." :syntax-table nil :abbrev-table nil + (buffer-disable-undo) (setq truncate-lines t) (setq-local whitespace-style nil) (setq-local show-trailing-whitespace nil) @@ -265,7 +266,9 @@ project (which may be different across perspective)." (when (bound-and-true-p persp-mode) (set-persp-parameter 'last-project-root (doom-project-root) - (if (perspective-p persp) persp (get-current-persp))))) + (if (persp-p persp) + persp + (get-current-persp))))) ;; @@ -325,11 +328,9 @@ controlled by `+doom-dashboard-pwd-policy'." ((null lastcwd) default-directory) ((eq policy 'last-project) - (let ((cwd default-directory) - (default-directory lastcwd)) - (if (doom-project-p) - (doom-project-root) - cwd))) + (let ((cwd default-directory)) + (or (doom-project-root lastcwd) + cwd))) ((eq policy 'last) lastcwd) ((warn "`+doom-dashboard-pwd-policy' has an invalid value of '%s'"