From fc78d46f301285be6f7733c151b50fcae3ecfa43 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 28 May 2016 21:51:21 -0400 Subject: [PATCH] v1.1.3 bump + sp: be quiet + popup: load *eval* rule earlier + evil-anzu: defer, due to long load time + Update makefile + Clean up core.el + line-spacing = 1, less rpadding on nlinum-format + Add *esup* popup rule + Refactor doom macro + Refactor doom-byte-compile + :big [SIZE] + use inconsolata in big-mode + :v TAB -> doom/yas-insert-snippet + eval: use pop-to-buffer instead of doom/popup-buffer + Refactor backspace fn; handle pair deletion issue with sp better + \#bringbackwindowsystem + db: remove unused var + Update init.el --- Makefile | 6 ++--- core/core-defuns.el | 34 +++++++++++++++----------- core/core-eval.el | 3 +-- core/core-evil.el | 1 + core/core-popup.el | 3 ++- core/core-scratch.el | 2 +- core/core-ui.el | 8 +++--- core/core-workgroups.el | 2 +- core/core.el | 19 +++++++------- core/defuns/defuns-buffers.el | 2 +- core/defuns/defuns-quickrun.el | 20 +++++++-------- core/defuns/defuns-whitespace.el | 18 ++++++-------- init.el | 13 +++++----- modules/extra-demo.el | 15 +++++++++--- modules/module-db.el | 6 +---- private/my-bindings.el | 4 +-- private/my-commands.el | 2 +- private/themes/doom-one-light-theme.el | 2 +- private/themes/doom-one-theme.el | 2 +- 19 files changed, 86 insertions(+), 76 deletions(-) diff --git a/Makefile b/Makefile index 44a068dd8..4ce99f4b0 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ all: install autoloads init.elc # If you run either of these with emacs open, run doom-reload afterwards install: autoloads _install init.elc -update: autoloads _update init.elc +update: autoloads _update core/core.elc init.elc autoloads: @$(EMACS) --batch -l init.el --eval '(doom-reload-autoloads)' 2>&1 @@ -31,11 +31,11 @@ clean-cache: _update: @cask update 2>&1 - @rm -f init.elc + @rm -f init.elc core/core.elc _install: @cask install 2>&1 - @rm -f init.elc + @rm -f init.elc core/core.elc @mkdir -p $(CACHE_DIR)/{undo,backup,workgroups} .PHONY: all diff --git a/core/core-defuns.el b/core/core-defuns.el index 675973e6d..9cfb7112e 100644 --- a/core/core-defuns.el +++ b/core/core-defuns.el @@ -1,34 +1,34 @@ ;;; core-defuns.el ;; Bootstrap macro -(defmacro doom (_ default-theme __ term-theme ___ font &rest packages) +(defmacro doom (_ theme __ font &rest packages) "Bootstrap DOOM emacs and initialize PACKAGES" - `(let ((gc-cons-threshold 339430400) - (gc-cons-percentage 0.6) - file-name-handler-alist) + `(let (file-name-handler-alist) ;; Local settings - (load "~/.emacs.local.el" t t) + ;; (load "~/.emacs.local.el" t t) ;; Global constants - (defvar doom-default-theme ,default-theme) - (defvar doom-terminal-theme ,term-theme) + (defvar doom-default-theme ,theme) (defvar doom-default-font (font-spec :family ,(nth 0 font) :size ,(nth 1 font) :antialias ,(not (nth 2 font)))) - (defvar doom-current-theme (if (display-graphic-p) doom-default-theme doom-terminal-theme)) + (defvar doom-current-theme doom-default-theme) (defvar doom-current-font doom-default-font) (unless noninteractive ,@(mapcar (lambda (pkg) `(require ',pkg)) packages) - (when (display-graphic-p) + (when window-system (require 'server) (unless (server-running-p) (server-start))) ;; Prevent any auto-displayed text + benchmarking (advice-add 'display-startup-echo-area-message :override 'ignore) - (message "")))) + (message "")) + + (setq-default gc-cons-threshold 4388608 + gc-cons-percentage 0.4))) ;; Backwards compatible `with-eval-after-load' (unless (fboundp 'with-eval-after-load) @@ -339,14 +339,20 @@ e.g. (doom-fix-unicode \"DejaVu Sans\" '(?⚠ ?★ ?λ ?➊ ?➋ ?➌ ?➍ ?➎ (font-spec :name font :size size) nil 'prepend)) chars)) -(defun doom-byte-compile () +(defun doom-byte-compile (&optional minimal) "Byte compile the core and library .el files in ~/.emacs.d" (interactive) (mapc (lambda (f) (byte-compile-file (concat doom-emacs-dir "/" f))) '("init.el" "private/my-commands.el" "private/my-bindings.el" - "core/core.el" "core/core-defuns.el" "core/core-ui.el")) - (byte-recompile-directory doom-core-dir 0 t) - (byte-recompile-directory doom-modules-dir 0 t) + "core/core.el" "core/core-defuns.el" "core/core-ui.el" + "core/core-os.el" "core/core-os-osx.el" "core/core-os-win32.el" + "core/core-os-linux.el")) + (unless minimal + (byte-recompile-directory doom-core-dir 0 t) + (byte-recompile-directory doom-modules-dir 0 t)) + (when minimal + (byte-recompile-directory (concat doom-core-dir "/defuns") 0 t) + (byte-recompile-directory (concat doom-modules-dir "/defuns") 0 t)) (message "Compiled!")) (provide 'core-defuns) diff --git a/core/core-eval.el b/core/core-eval.el index fe1c64f0a..4d5defe30 100644 --- a/core/core-eval.el +++ b/core/core-eval.el @@ -20,8 +20,7 @@ :init (add-hook 'quickrun/mode-hook 'linum-mode) :config (setq quickrun-focus-p nil) - (def-popup! "*quickrun*" :align below :size 10) - (def-popup! "*eval*" :align below :size 20)) + (def-popup! "*quickrun*" :align below :size 10)) (use-package repl-toggle :commands (rtog/toggle-repl rtog/add-repl) diff --git a/core/core-evil.el b/core/core-evil.el index 668053315..aff3a79e4 100644 --- a/core/core-evil.el +++ b/core/core-evil.el @@ -205,6 +205,7 @@ :commands (evil-numbers/inc-at-pt evil-numbers/dec-at-pt)) (use-package evil-anzu + :defer 1 :config (setq anzu-cons-mode-line-p nil anzu-minimum-input-length 1 diff --git a/core/core-popup.el b/core/core-popup.el index 2fe8681d5..8ddf55ff6 100644 --- a/core/core-popup.el +++ b/core/core-popup.el @@ -12,8 +12,9 @@ (setq shackle-rules `(;; Util ("^\\*.+-Profiler-Report .+\\*$" :align below :size 0.3 :regexp t) - ("*esup*" :align below :size 30 :noselect t) + ("*esup*" :align below :size 0.4 :noselect t) ("*minor-modes*" :align below :size 0.5 :noselect t) + ("*eval*" :align below :size 20) ;; Emacs ("*Pp Eval Output*" :align below :size 0.3) ("*Apropos*" :align below :size 0.3) diff --git a/core/core-scratch.el b/core/core-scratch.el index 69d1acbf3..63872433b 100644 --- a/core/core-scratch.el +++ b/core/core-scratch.el @@ -51,7 +51,7 @@ (erase-buffer) (setq doom-buffer-edited nil) (insert - (let* ((auto-detect-frame (or auto-detect-frame (not (display-graphic-p)))) + (let* ((auto-detect-frame (or auto-detect-frame (not window-system))) (width (max 3 (- (if auto-detect-frame (window-width) (cdr (assq 'width default-frame-alist))) 3))) diff --git a/core/core-ui.el b/core/core-ui.el index 5a55058b2..f4960d814 100644 --- a/core/core-ui.el +++ b/core/core-ui.el @@ -6,6 +6,7 @@ (fset 'yes-or-no-p 'y-or-n-p) (setq-default + line-spacing 1 indicate-buffer-boundaries nil ; don't show where buffer starts/ends indicate-empty-lines nil ; don't show empty lines fringes-outside-margins t ; switches order of fringe and margin @@ -42,7 +43,7 @@ ;; Initialize UI (load-theme doom-current-theme t) (tooltip-mode -1) ; show tooltips in echo area -(if (not (display-graphic-p)) +(if (not window-system) (menu-bar-mode -1) (scroll-bar-mode -1) ; no scrollbar (tool-bar-mode -1) ; no toolbar @@ -151,7 +152,7 @@ :commands nlinum-mode :preface (setq linum-format "%3d ") - (defvar nlinum-format "%4d ") + (defvar nlinum-format "%4d ") (defvar doom--hl-nlinum-overlay nil) (defvar doom--hl-nlinum-line nil) :init @@ -260,7 +261,8 @@ (spaceline-define-segment *anzu "Show the current match number and the total number of matches. Requires anzu to be enabled." - (when (evil-ex-hl-active-p 'evil-ex-search) + (when (and (featurep 'evil-anzu) + (evil-ex-hl-active-p 'evil-ex-search)) (powerline-raw (let ((here anzu--current-position) (total anzu--total-matched)) diff --git a/core/core-workgroups.el b/core/core-workgroups.el index 90c7453da..5ad25924c 100644 --- a/core/core-workgroups.el +++ b/core/core-workgroups.el @@ -14,7 +14,7 @@ defuns/defuns-workgroups.el.") automatically renamed to the project name.") (use-package workgroups2 - :when (display-graphic-p) + :when window-system :init (setq-default wg-session-file (concat doom-temp-dir "/workgroups/last") diff --git a/core/core.el b/core/core.el index b715524b5..55dc971ee 100644 --- a/core/core.el +++ b/core/core.el @@ -13,6 +13,10 @@ ;; ;;; Autoloaded functions are in {core,modules}/defuns/defuns-*.el +;; Premature optimization for faster startup +(setq-default gc-cons-threshold 339430400 + gc-cons-percentage 0.6) + (defalias '! 'eval-when-compile) (defconst doom-emacs-dir (! (expand-file-name user-emacs-directory))) @@ -27,6 +31,9 @@ emacs-major-version emacs-minor-version)) "Hostname and emacs-version-based elisp temp directories") +;; window-system is deprecated. Not on my watch! +(unless (boundp 'window-system) + (defvar window-system (framep-on-display))) ;; ;; Load path @@ -37,7 +44,7 @@ ;; Populate the load-path manually; cask shouldn't be an internal dependency (setq load-path - (! (defsubst --subdirs (path &optional include-self) + (! (defun --subdirs (path &optional include-self) (let ((result (if include-self (list path) (list)))) (mapc (lambda (file) (when (file-directory-p file) @@ -67,11 +74,6 @@ (prefer-coding-system 'utf-8) ; with sugar on top (setq default-process-coding-system '(utf-8-unix . utf-8-unix)) -;; Premature optimization for faster startup -(setq-default gc-cons-threshold 4388608 - gc-cons-percentage 0.3 - major-mode 'text-mode) - ;; stop package.el from being annoying. I rely solely on Cask. (setq package--init-file-ensured t package-enable-at-startup nil @@ -81,10 +83,10 @@ ("org" . "http://orgmode.org/elpa/")) ad-redefinition-action 'accept ; silence the advised function warnings - confirm-nonexistent-file-or-buffer t compilation-always-kill t ; kill compl. process before spawning another compilation-ask-about-save nil ; save all buffers before compiling compilation-scroll-output t ; scroll with output while compiling + confirm-nonexistent-file-or-buffer t delete-by-moving-to-trash t echo-keystrokes 0.02 ; show me what I type ediff-diff-options "-w" @@ -92,6 +94,7 @@ ediff-window-setup-function 'ediff-setup-windows-plain ; no extra frames enable-recursive-minibuffers nil ; no minibufferception idle-update-delay 5 ; update a little less often + major-mode 'text-mode ring-bell-function 'ignore ; silence of the bells! save-interprogram-paste-before-kill nil sentence-end-double-space nil @@ -120,8 +123,6 @@ (autoload 'use-package "use-package" "" nil 'macro) (require 'f) -(require 'dash) -(require 's) (require 'core-vars) (require 'core-defuns) (unless (require 'autoloads nil t) diff --git a/core/defuns/defuns-buffers.el b/core/defuns/defuns-buffers.el index 5ad9336ff..8397a520c 100644 --- a/core/defuns/defuns-buffers.el +++ b/core/defuns/defuns-buffers.el @@ -35,7 +35,7 @@ Inspired from http://demonastery.org/2013/04/emacs-evil-narrow-region/" ;; Buffer Life and Death ;;;;;;;;;;;;;;; -(unless (display-graphic-p) +(unless window-system (defalias 'wg-workgroup-associated-buffers 'ignore) (defalias 'wg-current-workgroup 'ignore) (defalias 'wg-save-session 'ignore)) diff --git a/core/defuns/defuns-quickrun.el b/core/defuns/defuns-quickrun.el index b277c9701..683c1c1cb 100644 --- a/core/defuns/defuns-quickrun.el +++ b/core/defuns/defuns-quickrun.el @@ -53,16 +53,16 @@ elisp buffer). Otherwise forward the region to Quickrun." (lines (length (s-lines out)))) (if (< lines 5) (princ out t) - (with-current-buffer (get-buffer-create "*eval*") - ;; (rename-buffer (buffer-name old-buf)) - (read-only-mode -1) - (setq-local scroll-margin 0) - (emacs-lisp-mode) - (erase-buffer) - (insert out) - (read-only-mode 1) - (goto-char (point-min)) - (doom/popup-buffer (current-buffer)))))) + (let ((buf (get-buffer-create "*eval*"))) + (with-current-buffer buf + (read-only-mode -1) + (setq-local scroll-margin 0) + (emacs-lisp-mode) + (erase-buffer) + (insert out) + (read-only-mode 1) + (goto-char (point-min))) + (pop-to-buffer buf))))) (t (quickrun-region beg end)))) ;;;###autoload (autoload 'doom:eval-region-and-replace "defuns-quickrun" nil t) diff --git a/core/defuns/defuns-whitespace.el b/core/defuns/defuns-whitespace.el index 1d5c38a36..10f63d6b2 100644 --- a/core/defuns/defuns-whitespace.el +++ b/core/defuns/defuns-whitespace.el @@ -54,24 +54,22 @@ already there, move it to the true bol." possible, or just one char if that's not possible." (interactive) (let* ((context (sp--get-pair-list-context 'navigate)) - (open-pair (sp--get-opening-regexp context)) - (close-pair (sp--get-closing-regexp context)) + (open-pair-re (sp--get-opening-regexp context)) + (close-pair-re (sp--get-closing-regexp context)) open-len close-len) (cond ;; When in strings (sp acts weird with quotes; this is the fix) ;; Also, skip closing delimiters - ((and (and (sp--looking-back open-pair) + ((and (and (sp--looking-back open-pair-re) (setq open-len (- (match-beginning 0) (match-end 0)))) - (and (looking-at close-pair) - (setq close-len (- (match-beginning 0) (match-end 0))))) + (and (looking-at close-pair-re) + (setq close-len (- (match-beginning 0) (match-end 0)))) + (string= (plist-get (sp-get-thing t) :op) + (plist-get (sp-get-thing) :cl))) (delete-backward-char open-len) (delete-char close-len)) - ;; If using tabs (or at bol), just delete normally - ((or indent-tabs-mode - (= (point-at-bol) (point))) - (call-interactively 'backward-delete-char-untabify)) ;; Delete up to the nearest tab column IF only whitespace between ;; point and bol. - ((sp--looking-back-p "^[\\t ]*" (point-at-bol)) + ((sp--looking-back-p "^[\\t ]*" (line-beginning-position)) (let ((movement (% (current-column) tab-width)) (p (point))) (when (= movement 0) diff --git a/init.el b/init.el index b860476b6..e582f8998 100644 --- a/init.el +++ b/init.el @@ -2,7 +2,7 @@ ;; ;; Author: Henrik Lissner ;; URL: https://github.com/hlissner/.emacs.d -;; Version: 1.1.2 +;; Version: 1.1.3 ;; ;; ================= =============== =============== ======== ======== ;; \\ . . . . . . .\\ //. . . . . . .\\ //. . . . . . .\\ \\. . .\\// . . // @@ -29,11 +29,10 @@ ;;; License: MIT (defconst emacs-start-time (current-time)) -(load (concat user-emacs-directory "core/core.el")) +(load (concat user-emacs-directory "core/core")) -(doom :default-theme 'doom-one - :terminal-theme 'doom-dark - :default-font ("Fira Mono" 12) +(doom :theme (if window-system 'doom-one 'doom-dark) + :font ("Inconsolata" 14) ;;; The heart of DOOM core-popup ; taming sudden and inevitable windows @@ -81,8 +80,8 @@ module-web ; The end is always near ;;; Experimental - ;; module-eshell ; for inferior OSes *cough*windows - ;; module-org ; for organized fearless leader + ;; module-eshell ; for inferior OSes *cough*windows + ;; module-org ; for organized fearless leader ;;; Extra libraries extra-demo ; allow me to demonstrate... diff --git a/modules/extra-demo.el b/modules/extra-demo.el index 32c669065..0bd188421 100644 --- a/modules/extra-demo.el +++ b/modules/extra-demo.el @@ -9,8 +9,8 @@ ;; + TODO peer programming collab ;; Big-mode settings -(defconst big-mode-font (font-spec :family "Hack" :size 16)) -(defconst big-mode-line-spacing 0) +(defconst big-mode-font (font-spec :family "Inconsolata" :size 18)) +(defconst big-mode-line-spacing 1) (defconst big-mode-modeline-height 35) ;; @@ -37,8 +37,15 @@ (setq neo-window-width 28) (remove-hook 'neo-after-create-hook 'doom|text-scale-1))) -(defun doom|text-scale-1 (&rest _) (text-scale-set -1) (setq line-spacing 0)) -(defun doom|text-scale+1 (&rest _) (text-scale-set +1)) +(defun doom|text-scale-1 (&rest _) + (text-scale-set -1) (setq line-spacing 0)) + +(evil-define-command doom:big-mode (&optional size) + (interactive "") + (let ((big-mode-font big-mode-font)) + (when (and size (not big-mode)) + (font-put big-mode-font :size (string-to-int size))) + (big-mode (if big-mode -1 +1)))) (provide 'extra-demo) ;;; extra-demo.el ends here diff --git a/modules/module-db.el b/modules/module-db.el index deba01e47..0a761ad96 100644 --- a/modules/module-db.el +++ b/modules/module-db.el @@ -12,11 +12,7 @@ sql-user "root" sql-password "")) -(defvar db-commands - '((mysql - (:listdb ) - ))) - +;; extract these (evil-define-command doom:db-select (product) (interactive "") (sql-set-product (intern product)) diff --git a/private/my-bindings.el b/private/my-bindings.el index 6dbfbeb67..fd93adc44 100644 --- a/private/my-bindings.el +++ b/private/my-bindings.el @@ -263,8 +263,8 @@ ;; yasnippet (:map yas-minor-mode-map - :i [(tab)] 'yas-expand - :v "" 'doom/yas-insert-snippet) + :i [(tab)] 'yas-expand + :v [(tab)] 'doom/yas-insert-snippet) ;; company-mode and vim-like omni-complete :i "C-SPC" 'doom/company-complete diff --git a/private/my-commands.el b/private/my-commands.el index 76b92d8c1..2b927ba95 100644 --- a/private/my-commands.el +++ b/private/my-commands.el @@ -80,7 +80,7 @@ (ex! "rm" 'doom:file-delete) ;; Presentation/demo -(ex! "big" 'big-mode) +(ex! "big" 'doom:big-mode) (ex! "full[scr]" 'doom:toggle-fullscreen) ;; Sessions/tabs diff --git a/private/themes/doom-one-light-theme.el b/private/themes/doom-one-light-theme.el index 66527222d..6bed52eac 100644 --- a/private/themes/doom-one-light-theme.el +++ b/private/themes/doom-one-light-theme.el @@ -22,7 +22,7 @@ (doom-blend color "#FFFFFF" (- 1 alpha))) -(when (display-graphic-p) +(when window-system (defface doom-default '((t (:inherit default))) "Face for source code windows." :group 'doom) diff --git a/private/themes/doom-one-theme.el b/private/themes/doom-one-theme.el index e1b9dfff1..85cf586cc 100644 --- a/private/themes/doom-one-theme.el +++ b/private/themes/doom-one-theme.el @@ -22,7 +22,7 @@ (doom-blend color "#FFFFFF" (- 1 alpha))) -(when (display-graphic-p) +(when window-system (defface doom-default '((t (:inherit default))) "Face for source code windows." :group 'doom)