Minor refactors across the board

This commit is contained in:
Henrik Lissner 2019-04-26 17:42:44 -04:00
parent ac55b6a826
commit 6b69eaa397
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
7 changed files with 29 additions and 26 deletions

View file

@ -329,11 +329,10 @@
(require 'core-projects) (require 'core-projects)
(require 'core-editor) (require 'core-editor)
(require 'core-packages) (require 'core-packages)
(success! "Loaded Doom Emacs %s" doom-version)
;; ...and initialized ;; ...and initialized
(doom-initialize) (doom-initialize)
(success! "Initialized Doom Emacs" doom-version) (success! "Initialized Doom Emacs %s" doom-version)
(doom-initialize-modules) (doom-initialize-modules)
(if (hash-table-p doom-modules) (if (hash-table-p doom-modules)

View file

@ -3,6 +3,17 @@
;; ;;
;;; Helpers ;;; 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 ;;;###autoload
(defun doom-save-session (&optional file) (defun doom-save-session (&optional file)
"TODO" "TODO"
@ -20,7 +31,9 @@
(desktop-restore-eager t) (desktop-restore-eager t)
desktop-file-modtime) desktop-file-modtime)
(make-directory desktop-dirname t) (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")))) ((error "No session backend to save session with"))))
;;;###autoload ;;;###autoload
@ -29,22 +42,14 @@
(setq file (expand-file-name (or file (doom-session-file)))) (setq file (expand-file-name (or file (doom-session-file))))
(message "Attempting to load %s" file) (message "Attempting to load %s" file)
(cond ((require 'persp-mode nil t) (cond ((require 'persp-mode nil t)
(unless persp-mode (persp-mode +1)) (unless persp-mode
(persp-mode +1))
(persp-load-state-from-file file)) (persp-load-state-from-file file))
((and (require 'frameset nil t) ((and (require 'frameset nil t)
(require 'restart-emacs nil t)) (require 'restart-emacs nil t))
(restart-emacs--restore-frames-using-desktop file)) (restart-emacs--restore-frames-using-desktop file))
((error "No session backend to load session with")))) ((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 ;;; Command line switch
@ -114,6 +119,7 @@
(defun doom/restart-and-restore (&optional debug) (defun doom/restart-and-restore (&optional debug)
"TODO" "TODO"
(interactive "P") (interactive "P")
(setq doom-autosave-session nil)
(doom/quicksave-session) (doom/quicksave-session)
(restart-emacs (restart-emacs
(delq nil (list (if debug "--debug-init") "--restore")))) (delq nil (list (if debug "--debug-init") "--restore"))))

View file

@ -236,7 +236,7 @@ non-nil, return paths of possible modules, activated or otherwise."
(after! use-package-core (after! use-package-core
;; :ensure and :pin don't work well with Doom, so we forcibly remove them. ;; :ensure and :pin don't work well with Doom, so we forcibly remove them.
(dolist (keyword '(:ensure :pin)) (dolist (keyword '(:ensure :pin))
(setq use-package-keywords (delq keyword use-package-keywords))) (delq! keyword use-package-keywords))
;; Insert new deferring keywords ;; Insert new deferring keywords
(dolist (keyword '(:defer-incrementally :after-call)) (dolist (keyword '(:defer-incrementally :after-call))

View file

@ -17,7 +17,7 @@
"M-;" #'eval-expression "M-;" #'eval-expression
"A-;" #'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 :i [tab] (general-predicate-dispatch nil ; fall back to nearest keymap
(and (featurep! :editor snippets) (and (featurep! :editor snippets)
(bound-and-true-p yas-minor-mode) (bound-and-true-p yas-minor-mode)

View file

@ -34,9 +34,6 @@
(let (buffer-read-only) (let (buffer-read-only)
(forward-line 2) ;; beyond dir. header (forward-line 2) ;; beyond dir. header
(sort-regexp-fields t "^.*$" "[ ]*." (point) (point-max)))) (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)) (set-buffer-modified-p nil))
(add-hook 'dired-after-readin-hook #'+dired|sort-directories-first) (add-hook 'dired-after-readin-hook #'+dired|sort-directories-first)

View file

@ -52,8 +52,8 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
;; initialization ;; initialization
+emacs-lisp|extend-imenu)) +emacs-lisp|extend-imenu))
;; Flycheck produces a *lot* of false positives in emacs configs, so disable ;; Flycheck's two emacs-lisp checkers produce a *lot* of false positives in
;; it when you're editing them ;; emacs configs, so disable it when you're editing them
(add-hook 'flycheck-mode-hook #'+emacs-lisp|disable-flycheck-maybe) (add-hook 'flycheck-mode-hook #'+emacs-lisp|disable-flycheck-maybe)
;; Special fontification for elisp ;; Special fontification for elisp

View file

@ -137,6 +137,7 @@ PLIST can have the following properties:
"Major mode for the DOOM dashboard buffer." "Major mode for the DOOM dashboard buffer."
:syntax-table nil :syntax-table nil
:abbrev-table nil :abbrev-table nil
(buffer-disable-undo)
(setq truncate-lines t) (setq truncate-lines t)
(setq-local whitespace-style nil) (setq-local whitespace-style nil)
(setq-local show-trailing-whitespace 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) (when (bound-and-true-p persp-mode)
(set-persp-parameter (set-persp-parameter
'last-project-root (doom-project-root) 'last-project-root (doom-project-root)
(if (perspective-p persp) persp (get-current-persp))))) (if (persp-p persp)
persp
(get-current-persp)))))
;; ;;
@ -325,10 +328,8 @@ controlled by `+doom-dashboard-pwd-policy'."
((null lastcwd) ((null lastcwd)
default-directory) default-directory)
((eq policy 'last-project) ((eq policy 'last-project)
(let ((cwd default-directory) (let ((cwd default-directory))
(default-directory lastcwd)) (or (doom-project-root lastcwd)
(if (doom-project-p)
(doom-project-root)
cwd))) cwd)))
((eq policy 'last) ((eq policy 'last)
lastcwd) lastcwd)