From 4317392ea143aa542df4a4baef87ace997e11efe Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 29 Sep 2014 15:25:45 -0400 Subject: [PATCH] Various fixes --- init/core-editor.el | 22 +++++++++++++++------- init/defuns/text.el | 8 +++----- init/init-csharp.el | 2 +- init/init-fly.el | 3 +-- init/init-snippets.el | 1 - init/my-commands.el | 2 +- init/my-keymaps.el | 42 ++++++++---------------------------------- 7 files changed, 29 insertions(+), 51 deletions(-) diff --git a/init/core-editor.el b/init/core-editor.el index 6e917d119..5f57bea71 100644 --- a/init/core-editor.el +++ b/init/core-editor.el @@ -50,6 +50,8 @@ (progn (evil-mode 1) + (add-hook! 'find-file-hook (setq evil-shift-width tab-width)) + (setq evil-search-module 'evil-search) (setq evil-magic 'very-magic) ;; Color-coded state cursors @@ -87,9 +89,11 @@ (defun my.evil-surround-escaped-pair () "Evil-surround function to allow escaped delimiters. e.g. \"...\"" (let* ((input (format "\\%s" (char-to-string (read-char "\\"))))) - (cons input input))) - (setq-default evil-surround-pairs-alist (cons '(?\\ . my.evil-surround-escaped-pair) evil-surround-pairs-alist)) - )) + ;; Type \\ to simply surround in single backslashes + (if (= input "\\\\") + (cons "\\" "\\") + (cons input input)))) + (setq-default evil-surround-pairs-alist (cons '(?\\ . my.evil-surround-escaped-pair) evil-surround-pairs-alist)))) (use-package god-mode) (use-package evil-god-state :diminish god-local-mode) @@ -108,7 +112,7 @@ (evil-half-cursor)) ;; Exit evil-exchange mode with (silently) -- and close - ;; minibuffer remotely if it happens to be open + ;; minibuffer remotely if it happens to be left open (defadvice evil-force-normal-state (before evil-esc-quit-exchange activate) (shut-up (evil-exchange-cancel) (if (minibufferp) @@ -186,7 +190,8 @@ returns nil." ;; Highjacks backspace and space to: ;; a) expand spaces between delimiters intelligently: (|) -> ( | ) ;; b) the reverse of A: ( | ) -> (|) -;; c) And allow backspace to delete indented blocks intelligently +;; c) allow backspace to delete indented blocks intelligently +;; d) and not do any of this magic when inside a string (-imap (kbd "SPC") 'my.inflate-space-maybe [remap backward-delete-char-untabify] 'my.deflate-space-maybe [remap delete-backward-char] 'my.deflate-space-maybe @@ -246,12 +251,15 @@ returns nil." (setq sp-autowrap-region nil ; let evil-surround handle this sp-highlight-pair-overlay nil sp-show-pair-delay 0 - sp-autoescape-string-quote t) + sp-autoescape-string-quote nil) (sp-pair "{" nil :post-handlers '(("||\n[i]" "RET"))) (sp-pair "[" nil :post-handlers '(("||\n[i]" "RET"))) - (sp-local-pair 'emacs-lisp-mode "[" nil :post-handlers '(("|" "RET"))) + (sp-with-modes '(emacs-lisp-mode lisp-mode) + (sp-local-pair "[" nil :post-handlers '(("|" "RET")))) + (sp-pair "[" nil :unless '(sp-point-before-word-p)) + (sp-pair "(" nil :unless '(sp-point-before-word-p)) (sp-pair "\"" nil :unless '(sp-point-after-word-p sp-point-before-word-p)) (sp-pair "'" nil :unless '(sp-point-after-word-p sp-point-before-word-p)) diff --git a/init/defuns/text.el b/init/defuns/text.el index e793c2fe2..7f4b1239b 100644 --- a/init/defuns/text.el +++ b/init/defuns/text.el @@ -39,11 +39,9 @@ already there, move it to the true bol." "Delete back to the previous column of whitespace, or as much whitespace as possible, or just one char if that's not possible." (interactive) - (cond ;; If in a string (workaround for smartparen bug) + (cond ;; If in a string ((sp-point-in-string) - (if (sp-point-in-empty-sexp) - (call-interactively 'sp-backward-delete-char) - (call-interactively 'backward-delete-char-untabify))) + (call-interactively 'backward-delete-char-untabify)) ;; If using tabs (or at bol), just delete normally ((or indent-tabs-mode (= (point-at-bol) (point))) @@ -99,7 +97,7 @@ spaces on either side of the point if so. Resorts to "Newline and indent; if in a comment, auto-comment and properly indent the next line." (interactive) - (cond ((in-string-p) + (cond ((sp-point-in-string) (evil-ret)) ((evil-in-comment-p) (indent-new-comment-line)) diff --git a/init/init-csharp.el b/init/init-csharp.el index db8cdf068..acd9c8a6d 100644 --- a/init/init-csharp.el +++ b/init/init-csharp.el @@ -20,4 +20,4 @@ :init (progn (setq csharp-want-imenu nil) - (add-hook 'csharp-mode-hook (lambda() (omnisharp-mode t) (flycheck-mode t))))) + (add-hook! 'csharp-mode-hook (omnisharp-mode t) (flycheck-mode t)))) diff --git a/init/init-fly.el b/init/init-fly.el index fb36cbfdf..07e39bae6 100644 --- a/init/init-fly.el +++ b/init/init-fly.el @@ -8,12 +8,11 @@ '(save new-line mode-enabled) flycheck-disabled-checkers '(emacs-lisp emacs-lisp-checkdoc)) - :idle + :init (add-hook 'after-init-hook #'global-flycheck-mode)) (use-package flyspell :commands flyspell-mode - :diminish (flyspell-mode . " @") :config (setq ispell-program-name "aspell" ispell-list-command "--list")) diff --git a/init/init-snippets.el b/init/init-snippets.el index 5ec5e13f6..cb10cd59b 100644 --- a/init/init-snippets.el +++ b/init/init-snippets.el @@ -1,7 +1,6 @@ (provide 'init-snippets) (use-package yasnippet - :diminish (yas-minor-mode . " $") :mode (("emacs.+/snippets/" . snippet-mode)) :pre-load (progn diff --git a/init/my-commands.el b/init/my-commands.el index 4098b2dee..f1271582a 100644 --- a/init/my-commands.el +++ b/init/my-commands.el @@ -202,7 +202,7 @@ to abort the minibuffer." :move-point nil :type inclusive :repeat nil - (interactive "") + (interactive "") (let ((mode major-mode) (text (when (and beg end) (buffer-substring beg end)))) (if text diff --git a/init/my-keymaps.el b/init/my-keymaps.el index 6495cf3e0..f57ca42ce 100644 --- a/init/my-keymaps.el +++ b/init/my-keymaps.el @@ -6,7 +6,7 @@ (global-set-key (kbd "M-x") 'smex) (global-set-key (kbd "M-X") 'smex-major-mode-commands) -(global-set-key (kbd "C-;") 'eval-expression) +(global-set-key (kbd "C-:") 'eval-expression) (global-set-key (kbd "C-j") "5j") (global-set-key (kbd "C-k") "5k") @@ -63,9 +63,7 @@ (vmap! ",r" 'my:run-code-region ",R" 'my:send-region-to-repl) -(nvmap! ",x" 'my:ex:scratch-buffer - ",X" 'my:ex:org-capture - ",=" 'align-regexp) +(nvmap! ",=" 'align-regexp) ;;;; ;;;;;;;;;;;;;;;;;;;;; (-nmap "\\" 'evil-execute-in-god-state) @@ -240,43 +238,17 @@ ",tV" 'nosetests-pdb-module)) (after org - ;; normal & insert state shortcuts. - ;; (mapc (lambda (state) - ;; (evil-define-key state evil-org-mode-map - ;; (kbd "M--") 'my/org-insert-list-item - ;; (kbd "M-l") 'org-metaright - ;; (kbd "M-h") 'org-metaleft - ;; (kbd "M-k") 'org-metaup - ;; (kbd "M-j") 'org-metadown - ;; (kbd "M-L") 'org-shiftmetaright - ;; (kbd "M-H") 'org-shiftmetaleft - ;; (kbd "M-K") 'org-shiftmetaup - ;; (kbd "M-J") 'org-shiftmetadown - ;; (kbd "") '(lambda () (interactive) - ;; (my/org-eol-call - ;; '(lambda() - ;; (org-insert-heading) - ;; (org-metaright)))) - ;; (kbd "M-t") '(lambda () (interactive) - ;; (my/org-eol-call - ;; '(lambda() - ;; (org-insert-todo-heading nil) - ;; (org-metaright)))) - ;; )) - ;; '(normal insert)) - - ;; Formatting shortcuts - + (define-key org-mode-map (kbd "RET") nil) (define-key org-mode-map (kbd "C-j") nil) (define-key org-mode-map (kbd "C-k") nil) + ;; Formatting shortcuts (imap evil-org-mode-map (kbd "s-b") (λ (my/org-surround "*")) ; bold (kbd "s-u") (λ (my/org-surround "_")) ; underline (kbd "s-i") (λ (my/org-surround "/")) ; italics (kbd "s-`") (λ (my/org-surround "+")) ; strikethrough - - (kbd "") 'org-insert-heading-after-current) + ) (nvmap evil-org-mode-map ",l" 'org-insert-link) @@ -311,8 +283,9 @@ ">" 'org-metaright "-" 'org-cycle-list-bullet (kbd ", SPC") 'org-archive-subtree + (kbd "") (λ (evil-move-beginning-of-line) (org-insert-heading) (evil-insert-state)) (kbd "") (λ (org-insert-heading-after-current) (evil-insert-state)) - (kbd "RET") (λ (org-todo 'done)) + (kbd "RET") (λ (if (org-entry-is-todo-p) (org-todo 'done))) (kbd "TAB") 'org-cycle)) (after ruby-mode @@ -368,6 +341,7 @@ (exmap "ag" 'my:ex:ag-search) (exmap "agr" 'my:ex:ag-regex-search) (exmap "x" 'my:ex:scratch-buffer) +(exmap "X" 'my:ex:org-capture) (exmap "a" 'projectile-find-other-file) (exmap "bx" 'my:ex:kill-buffers) (exmap "tcd" 'my:ex:tmux-chdir)