diff --git a/core/core-editor.el b/core/core-editor.el index d37d3096c..c8834b96f 100644 --- a/core/core-editor.el +++ b/core/core-editor.el @@ -16,6 +16,9 @@ scroll-conservatively 1001 scroll-preserve-screen-position t + hscroll-step 5 + hscroll-margin 6 + shift-select-mode nil tabify-regexp "^\t* [ \t]+" whitespace-style '(face tabs tab-mark newline newline-mark) diff --git a/core/core-evil.el b/core/core-evil.el index 7c52c5c7e..74e170172 100644 --- a/core/core-evil.el +++ b/core/core-evil.el @@ -230,16 +230,16 @@ (?\] "[]})]") (?\; "[;:]"))) - (define-key evil-normal-state-map (kbd "s") nil) - (define-key evil-normal-state-map (kbd "S") nil) - (define-key evil-motion-state-map (kbd "s") 'evil-snipe-s) - (define-key evil-motion-state-map (kbd "S") 'evil-snipe-S) - (define-key evil-motion-state-map (kbd "f") 'evil-snipe-f) - (define-key evil-motion-state-map (kbd "F") 'evil-snipe-F) - (define-key evil-motion-state-map (kbd "t") 'evil-snipe-t) - (define-key evil-motion-state-map (kbd "T") 'evil-snipe-T) - (define-key evil-operator-state-map (kbd "z") 'evil-snipe-s) - (define-key evil-operator-state-map (kbd "Z") 'evil-snipe-S) + (define-key evil-normal-state-map "s" nil) + (define-key evil-normal-state-map "S" nil) + (define-key evil-motion-state-map "s" 'evil-snipe-s) + (define-key evil-motion-state-map "S" 'evil-snipe-S) + (define-key evil-motion-state-map "f" 'evil-snipe-f) + (define-key evil-motion-state-map "F" 'evil-snipe-F) + (define-key evil-motion-state-map "t" 'evil-snipe-t) + (define-key evil-motion-state-map "T" 'evil-snipe-T) + (define-key evil-operator-state-map "z" 'evil-snipe-s) + (define-key evil-operator-state-map "Z" 'evil-snipe-S) :config (evil-snipe-mode 1) (evil-snipe-override-mode 1)) @@ -251,6 +251,19 @@ evil-surround-region) :config (global-evil-surround-mode 1) + + (add-hook! org-mode + (mapc (lambda (p) (add-to-list 'evil-surround-pairs-alist p)) + '((?l . narf/evil-surround-latex)))) + + (add-hook! emacs-lisp-mode + (setq evil-surround-pairs-alist + (cons '(?\` . ("`" . "*")) evil-surround-pairs-alist))) + + (add-hook! python-mode + (setq evil-surround-pairs-alist + (cons '(?d . ("\"\"\"" . "\"\"\"")) evil-surround-pairs-alist))) + ;; Escaped surround characters (setq-default evil-surround-pairs-alist (cons '(?\\ . narf/evil-surround-escaped) diff --git a/core/core-os-osx.el b/core/core-os-osx.el index ab24fb20a..e8aa4c78b 100644 --- a/core/core-os-osx.el +++ b/core/core-os-osx.el @@ -9,9 +9,11 @@ mac-option-modifier 'alt ;; sane trackpad/mouse scroll settings + mac-redisplay-dont-reset-vscroll t mac-mouse-wheel-smooth-scroll nil mouse-wheel-scroll-amount '(8 ((shift) . 2)) ;; one line at a time - mouse-wheel-progressive-speed nil ;; don't accelerate scrolling + mouse-wheel-progressive-speed nil ;; don't accelerate scrolling + ;;; NOTE These mean nothing to railwaycat's emacs-mac build on OSX ;; Curse Lion and its sudden but inevitable fullscreen mode! @@ -42,8 +44,8 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(after! evil - (when (featurep 'ns) +(when (featurep 'ns) + (after! evil ;; On OSX, stop copying each visual state move to the clipboard: ;; https://bitbucket.org/lyro/evil/issue/336/osx-visual-state-copies-the-region-on ;; Most of this code grokked from: diff --git a/core/lib/defuns-evil.el b/core/lib/defuns-evil.el index 51b775b7b..ecb7c0735 100644 --- a/core/lib/defuns-evil.el +++ b/core/lib/defuns-evil.el @@ -17,13 +17,13 @@ (hs-minor-mode 1)) (if count (hs-hide-level count) (evil-close-folds))) -;;;###autoload (autoload 'narf-multi-next-line "defuns-evil" nil t) -(evil-define-motion narf-multi-next-line (count) +;;;###autoload (autoload 'narf/multi-next-line "defuns-evil" nil t) +(evil-define-motion narf/multi-next-line (count) "Move down 6 lines" :type line (evil-line-move 6)) -;;;###autoload (autoload 'narf-multi-previous-line "defuns-evil" nil t) -(evil-define-motion narf-multi-previous-line (count) +;;;###autoload (autoload 'narf/multi-previous-line "defuns-evil" nil t) +(evil-define-motion narf/multi-previous-line (count) "Move up 6 lines" :type line (evil-line-move -6)) @@ -52,15 +52,21 @@ ;;;###autoload (defun narf/evil-surround-escaped () "Escaped surround characters." - (let* ((char (string (read-char "\\"))) - (pair (cond ((string-match "[]})[{(]" char) - (let ((-pair (cdr (assoc (string-to-char char) evil-surround-pairs-alist)))) - `(,(car -pair) . ,(cdr -pair)))) - (t - `(,char . ,char)))) - (format (if (sp-point-in-string) "\\\\%s" "\\%s"))) - (cons (format format (car pair)) - (format format (cdr pair))))) + (let* ((char (string (read-char "\\"))) + (pair (cond ((string-match-p "[]})[{(]" char) + (let ((-pair (cdr (assoc (string-to-char char) evil-surround-pairs-alist)))) + `(,(car -pair) . ,(cdr -pair)))) + (t + `(,char . ,char)))) + (format (if (sp-point-in-string) "\\\\%s" "\\%s"))) + (cons (format format (car pair)) + (format format (cdr pair))))) + +;;;###autoload +(defun narf/evil-surround-latex () + "LaTeX commands" + (let* ((command (read-string "\\"))) + (cons (format "\\%s{" command) "}"))) ;;;###autoload (autoload 'narf/evil-macro-on-all-lines "defuns-evil" nil t) (evil-define-operator narf/evil-macro-on-all-lines (beg end &optional arg) @@ -75,5 +81,17 @@ (single-key-description (read-char "What macro?")))))) +;;;###autoload +(defun narf/evil-window-split () + (interactive) + (call-interactively 'evil-window-split) + (evil-window-down 1)) + +;;;###autoload +(defun narf/evil-window-vsplit () + (interactive) + (call-interactively 'evil-window-vsplit) + (evil-window-right 1)) + (provide 'defuns-evil) ;;; defuns-evil.el ends here diff --git a/core/lib/defuns-ui.el b/core/lib/defuns-ui.el index 383f45263..2e40a3ed6 100644 --- a/core/lib/defuns-ui.el +++ b/core/lib/defuns-ui.el @@ -15,8 +15,38 @@ (interactive "") (if bang (writeroom-mode (if writeroom-mode -1 1)) - (set-frame-parameter nil 'fullscreen - (when (not (frame-parameter nil 'fullscreen)) 'fullboth)))) + (set-frame-parameter nil 'fullscreen (if (not (frame-parameter nil 'fullscreen)) 'fullboth)))) + +;;;###autoload +(defvar narf--write-mode nil) +(defun narf:toggle-write-mode () + (interactive) + (require 'writeroom-mode) + (let ((writeroom-width 100) + (writeroom-extra-line-spacing 12)) + (writeroom-mode (if writeroom-mode -1 1)) + (setq narf--write-mode writeroom-mode) + + ;; (setq truncate-lines (not narf--write-mode)) + ;; (setq word-wrap narf--write-mode) + (variable-pitch-mode narf--write-mode) + + (if narf--write-mode + (narf/load-theme 'solarized-light) + (narf/reset-theme)) + + (fringe-mode (if narf--write-mode 0 '(3 . 6))) + (auto-fill-mode (if narf--write-mode -1 +1)) + (text-scale-set (if narf--write-mode 2.5 0)) + (scroll-bar-mode (if narf--write-mode 1 -1)) + + (when IS-MAC + (setq ;; sane trackpad/mouse scroll settings + mac-mouse-wheel-smooth-scroll narf--write-mode + mouse-wheel-progressive-speed narf--write-mode)) + + (when (eq major-mode 'org-mode) + (org-indent-mode (if narf--write-mode -1 1))))) (defvar narf--big-mode nil) ;;;###autoload @@ -28,7 +58,15 @@ ;;;###autoload (defun narf/reset-theme () (interactive) - (load-theme (if window-system narf-theme narf-term-theme) t)) + (narf/load-theme 'narf-dark)) + +;;;###autoload +(defun narf/load-theme (theme) + (interactive) + (mapc (lambda (th) + (when (custom-theme-enabled-p th) (disable-theme th))) + custom-enabled-themes) + (load-theme theme t)) ;;;###autoload (defun narf/default-font () @@ -40,5 +78,14 @@ (interactive) (set-frame-font narf-big-font)) +;;;###autoload +(defun narf/show-as (how &optional pred) + (let* ((beg (match-beginning 1)) + (end (match-end 1)) + (ok (or (not pred) (funcall pred beg end)))) + (when ok + (compose-region beg end how 'decompose-region)) + nil)) + (provide 'defuns-ui) ;;; defuns-ui.el ends here diff --git a/core/lib/macros-auto-insert.el b/core/lib/macros-auto-insert.el index 9809cd3e6..b10d0d2c1 100644 --- a/core/lib/macros-auto-insert.el +++ b/core/lib/macros-auto-insert.el @@ -3,7 +3,9 @@ ;;;###autoload (defmacro add-template! (regexp-or-major-mode uuid yas-mode &optional project-only) - `(define-auto-insert ,regexp-or-major-mode + `(define-auto-insert ,(if (stringp regexp-or-major-mode) + regexp-or-major-mode + (eval regexp-or-major-mode)) (lambda () (unless (or (and ,project-only (not (narf/project-p))) (not (or (eq major-mode ,yas-mode) diff --git a/init-load-path.el b/init-load-path.el index cddfad41a..45ac5bedd 100644 --- a/init-load-path.el +++ b/init-load-path.el @@ -1,6 +1,6 @@ ;;; init-load-path.el -(setq gc-cons-threshold 84857600) +(setq gc-cons-threshold 169715200) (eval-and-compile (defconst narf-emacs-dir user-emacs-directory) diff --git a/init.el b/init.el index 4b976f3a3..e74323267 100644 --- a/init.el +++ b/init.el @@ -2,7 +2,7 @@ ;; ;; Author: Henrik Lissner ;; URL: https://github.com/hlissner/emacs.d -;; Version: 0.4.0 +;; Version: 0.5.0 ;; ;;; Are you pondering what I'm pondering, Pinky? ;; @@ -41,9 +41,8 @@ ;;; License: GPLv3 (defconst narf-theme 'narf-dark) -(defconst narf-term-theme 'wombat) -(defconst narf-default-font (font-spec :family "DejaVu Sans Mono" :size 12)) -(defconst narf-big-font (font-spec :family "Ubuntu Mono" :size 18)) +(defconst narf-default-font (font-spec :family "DejaVu Sans Mono" :size 12 :antialias t)) +(defconst narf-big-font (font-spec :family "Inconsolata" :size 20 :antialias t)) (scroll-bar-mode -1) ; no scrollbar (tool-bar-mode -1) ; no toolbar @@ -51,7 +50,7 @@ ;; prematurely optimize for faster startup (let (file-name-handler-alist) (load (concat user-emacs-directory "init-load-path.el")) - (load-theme (if window-system narf-theme narf-term-theme) t) + (load-theme narf-theme t) (mapc 'require `(core ; core/core.el @@ -78,7 +77,7 @@ module-collab ; wonewy, I'm so wonewy~ module-data ; dbs 'n data formats module-elisp ; drowning in parentheses - module-eshell ; eshell (on windows) + ;; module-eshell ; eshell (on windows) module-go ; a hipster dialect module-java ; the poster child for carpal tunnel syndome module-js ; alert("not java, javascript!") diff --git a/modules/module-elisp.el b/modules/module-elisp.el index adac0398b..f94f56430 100644 --- a/modules/module-elisp.el +++ b/modules/module-elisp.el @@ -27,6 +27,9 @@ `((,(concat "(\\s-*" (regexp-opt keywords 'paren) "\\_>") 1 font-lock-keyword-face)) 'append)) +(font-lock-add-keywords + 'emacs-lisp-mode `(("\\(lambda\\)" (0 (narf/show-as ?λ))))) + ;; Real go-to-definition for elisp (bind! :map emacs-lisp-mode-map :m "gd" 'narf/elisp-find-function-at-pt diff --git a/private/my-bindings.el b/private/my-bindings.el index db2241784..888a0713a 100644 --- a/private/my-bindings.el +++ b/private/my-bindings.el @@ -50,8 +50,8 @@ "C-h" 'evil-window-left "C-l" 'evil-window-right - :m "M-j" 'narf-multi-next-line - :m "M-k" 'narf-multi-previous-line + :m "M-j" 'narf/multi-next-line + :m "M-k" 'narf/multi-previous-line :n "M-r" 'narf:eval-buffer :v "M-r" 'narf:eval-region @@ -97,7 +97,7 @@ ;; (:prefix "," :nv "," (λ (if (narf/project-p) (helm-projectile-switch-to-buffer) (helm-buffers-list))) - :nv "<" 'helm-mini + :nv "<" 'helm-buffers-list :nv "." 'helm-find-files :nv ">" 'helm-projectile-find-file-in-known-projects :nv "/" 'helm-projectile-find-file @@ -118,16 +118,16 @@ :nv "qq" 'evil-save-and-quit :nv "QQ" 'narf/kill-all-buffers-do-not-remember - :n "oo" 'narf-open-with - :n "ob" (λ (narf-open-with "Google Chrome")) - :n "of" (λ (narf-open-with "Finder.app" default-directory)) - :n "oF" (λ (narf-open-with "Finder.app" (narf/project-root))) - :n "ou" (λ (narf-open-with "Transmit")) - :n "oU" (λ (narf-open-with "Transmit" default-directory)) - :n "ol" (λ (narf-open-with "LaunchBar")) - :n "oL" (λ (narf-open-with "LaunchBar" default-directory)) - :n "ot" (λ (narf:tmux-chdir nil t)) - :n "oT" 'narf:tmux-chdir) + :n "oo" 'narf-open-with + :n "ob" (λ (narf-open-with "Google Chrome")) + :n "of" (λ (narf-open-with "Finder.app" default-directory)) + :n "oF" (λ (narf-open-with "Finder.app" (narf/project-root))) + :n "ou" (λ (narf-open-with "Transmit")) + :n "oU" (λ (narf-open-with "Transmit" default-directory)) + :n "ol" (λ (narf-open-with "LaunchBar")) + :n "oL" (λ (narf-open-with "LaunchBar" default-directory)) + :n "ot" (λ (narf:tmux-chdir nil t)) + :n "oT" 'narf:tmux-chdir) ;; (:prefix "\\" @@ -219,10 +219,9 @@ :m "%" 'evilmi-jump-items :m [tab] (λ (cond ((eq major-mode 'org-mode) (org-cycle)) - (t - (if (ignore-errors (hs-already-hidden-p)) - (hs-toggle-hiding) - (call-interactively 'evilmi-jump-items))))) + (t (if (ignore-errors (hs-already-hidden-p)) + (hs-toggle-hiding) + (call-interactively 'evilmi-jump-items))))) ;; Restore osx text objects :i "" 'evil-delete-backward-word @@ -247,6 +246,11 @@ (:map evil-window-map ; prefix "C-w" "u" 'winner-undo + + ;; Jump to new splits + "s" 'narf/evil-window-split + "v" 'narf/evil-window-vsplit + "C-u" 'winner-undo "C-r" 'winner-redo "C-h" 'evil-window-left ; don't accidentally invoke help @@ -276,7 +280,7 @@ "C-o" 'company-search-kill-others "C-n" 'company-select-next-or-abort "C-p" 'company-select-previous-or-abort - "C-h" 'company-show-doc-buffer + "C-h" 'company-quickhelp-manual-begin "C-S-h" 'company-show-location "C-S-s" 'company-search-candidates "C-s" 'company-filter-candidates @@ -311,6 +315,10 @@ (global-set-key (kbd " ") 'narf/mouse-select-line) (global-set-key (kbd " ") 'narf/mouse-select-line) +;; Horizontal Scrolling +(global-set-key (kbd "") (λ (evil-scroll-column-right 2))) +(global-set-key (kbd "") (λ (evil-scroll-column-left 2))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Keymap fixes ;; @@ -321,8 +329,8 @@ ;; Restores "dumb" indentation to the tab key. This rustles a lot of ;; peoples' jimmies, apparently, but it's how I like it. -(bind! :i "" 'narf/dumb-indent - :i "" 'indent-for-tab-command +(bind! :i "