From 7d44ea4db45b6400e8c15e513bdc373e774f0d39 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 20 May 2015 22:28:41 -0400 Subject: [PATCH] My name is Henrik and I'm an emacs addict. (Hello Henrik) --- .gitignore | 2 +- Cask | 6 +- Makefile | 6 +- contrib/smalltalk-mode/gst-mode.el | 389 ------- contrib/smalltalk-mode/smalltalk-mode.el | 1202 ---------------------- contrib/unityjs-mode.el | 0 contrib/yt-stopwatch/probe.scpt | Bin 2030 -> 0 bytes contrib/yt-stopwatch/yt-stopwatch.el | 39 - core/core-editor.el | 48 - core/core-linux.el | 3 - core/core.el | 326 ------ dict/android-mode | 4 + dict/java-mode | 3 +- dict/love-mode | 2 +- init.el | 42 +- init/core-editor.el | 173 ++++ {core => init}/core-evil.el | 134 +-- init/core-linux.el | 5 + {core => init}/core-osx.el | 5 +- {core => init}/core-ui.el | 81 +- init/core.el | 381 +++++++ {core => init}/defuns-buffers.el | 0 {core => init}/defuns-text.el | 0 {core => init}/defuns-ui.el | 0 {core => init}/defuns-util.el | 0 {core => init}/defuns.el | 4 + init/init-cc.el | 2 - init/init-company.el | 29 +- init/init-cscope.el | 3 +- init/init-csharp.el | 30 +- init/init-d.el | 7 - init/init-erlang.el | 14 - init/init-fly.el | 27 +- init/init-git.el | 109 +- init/init-helm.el | 215 ++-- init/init-ido.el | 14 +- init/init-java.el | 17 + init/init-php.el | 5 +- init/init-project.el | 75 +- init/init-python.el | 6 +- init/init-regex.el | 13 +- init/init-ruby.el | 54 +- init/init-smalltalk.el | 5 - init/init-workgroups.el | 2 +- init/init-yasnippet.el | 31 +- init/init-youtube.el | 6 - init/my-bindings.el | 137 ++- init/my-commands.el | 27 +- init/my-settings.el | 40 +- themes/v0-theme.el | 2 + 50 files changed, 1154 insertions(+), 2571 deletions(-) delete mode 100644 contrib/smalltalk-mode/gst-mode.el delete mode 100644 contrib/smalltalk-mode/smalltalk-mode.el mode change 100755 => 100644 contrib/unityjs-mode.el delete mode 100644 contrib/yt-stopwatch/probe.scpt delete mode 100644 contrib/yt-stopwatch/yt-stopwatch.el delete mode 100644 core/core-editor.el delete mode 100644 core/core-linux.el delete mode 100644 core/core.el create mode 100755 dict/android-mode create mode 100644 init/core-editor.el rename {core => init}/core-evil.el (72%) create mode 100644 init/core-linux.el rename {core => init}/core-osx.el (91%) rename {core => init}/core-ui.el (73%) create mode 100644 init/core.el rename {core => init}/defuns-buffers.el (100%) rename {core => init}/defuns-text.el (100%) rename {core => init}/defuns-ui.el (100%) rename {core => init}/defuns-util.el (100%) rename {core => init}/defuns.el (97%) delete mode 100644 init/init-d.el delete mode 100644 init/init-erlang.el delete mode 100644 init/init-smalltalk.el delete mode 100644 init/init-youtube.el diff --git a/.gitignore b/.gitignore index 21a50765a..6bfc7bec5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ eshell/ -core/autoloads.el +init/autoloads.el auto-save-list recentf savehist diff --git a/Cask b/Cask index 52d0790b0..678316eb2 100644 --- a/Cask +++ b/Cask @@ -12,9 +12,9 @@ (depends-on "fuzzy") (depends-on "use-package") (depends-on "smex") -(depends-on "floobits") (depends-on "pos-tip") -(depends-on "vim-empty-lines-mode") +;;(depends-on "vim-empty-lines-mode") +(depends-on "hlinum" :git "https://github.com/tom-tan/hlinum-mode") ;; OSX (depends-on "exec-path-from-shell") @@ -63,9 +63,7 @@ (depends-on "evil-indent-textobject") (depends-on "evil-jumper") (depends-on "evil-god-state") -;;(depends-on "evil-nerd-commenter") (depends-on "evil-snipe") -;; evil-nerd-commenter chokes if it's installed via cask for some reason... ;; Project management (depends-on "projectile") diff --git a/Makefile b/Makefile index 3953120b0..f664509ae 100644 --- a/Makefile +++ b/Makefile @@ -6,9 +6,9 @@ update: cask update clean: - @rm -rf init.elc init/*.elc contrib/*.elc core/*.elc + @rm -rf init.elc init/*.elc contrib/*.elc @rm -rf auto-save-list recentf places ido.last async-bytecomp.log elpa projectile-bookmarks.eld projectile.cache company-statistics-cache.el tramp smex-items autoloads: - @rm -rf core/autoloads.el - @cask exec ${EMACS} -Q --batch --eval '(progn (setq generated-autoload-file "~/.emacs.d/core/autoloads.el") (update-directory-autoloads "~/.emacs.d/init" "~/.emacs.d/core" "~/.emacs.d/contrib"))' + @rm -rf init/autoloads.el + @cask exec ${EMACS} -Q --batch --eval '(progn (setq generated-autoload-file "~/.emacs.d/init/autoloads.el") (update-directory-autoloads "~/.emacs.d/init" "~/.emacs.d/contrib"))' diff --git a/contrib/smalltalk-mode/gst-mode.el b/contrib/smalltalk-mode/gst-mode.el deleted file mode 100644 index 344a1663c..000000000 --- a/contrib/smalltalk-mode/gst-mode.el +++ /dev/null @@ -1,389 +0,0 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; -;;; Copyright 1988-92, 1994-95, 1999, 2000, 2003, 2007, 2008 -;;; Free Software Foundation, Inc. -;;; Written by Steve Byrne. -;;; -;;; This file is part of GNU Smalltalk. -;;; -;;; GNU Smalltalk is free software; you can redistribute it and/or modify it -;;; under the terms of the GNU General Public License as published by the Free -;;; Software Foundation; either version 2, or (at your option) any later -;;; version. -;;; -;;; GNU Smalltalk is distributed in the hope that it will be useful, but -;;; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -;;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -;;; for more details. -;;; -;;; You should have received a copy of the GNU General Public License along -;;; with GNU Smalltalk; see the file COPYING. If not, write to the Free -;;; Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;;; Incorporates Frank Caggiano's changes for Emacs 19. -;;; Updates and changes for Emacs 20 and 21 by David Forster - -(require 'comint) - -(defvar smalltalk-prompt-pattern "^st> *" - "Regexp to match prompts in smalltalk buffer.") - -(defvar *gst-process* nil - "Holds the GNU Smalltalk process") -(defvar gst-program-name "/usr/local/Cellar/gnu-smalltalk/3.2.5_1/bin/gst -V" - "GNU Smalltalk command to run. Do not use the -a, -f or -- options.") - -(defvar smalltalk-command-string nil - "Non nil means that we're accumulating output from Smalltalk") - -(defvar smalltalk-eval-data nil - "?") - -(defvar smalltalk-ctl-t-map - (let ((keymap (make-sparse-keymap))) - (define-key keymap "\C-d" 'smalltalk-toggle-decl-tracing) - (define-key keymap "\C-e" 'smalltalk-toggle-exec-tracing) - (define-key keymap "\C-v" 'smalltalk-toggle-verbose-exec-tracing) - keymap) - "Keymap of subcommands of C-c C-t, tracing related commands") - -(defvar gst-mode-map - (let ((keymap (copy-keymap comint-mode-map))) - (define-key keymap "\C-c\C-t" smalltalk-ctl-t-map) - - (define-key keymap "\C-\M-f" 'smalltalk-forward-sexp) - (define-key keymap "\C-\M-b" 'smalltalk-backward-sexp) - (define-key keymap "\C-cd" 'smalltalk-doit) - (define-key keymap "\C-cf" 'smalltalk-filein) - (define-key keymap "\C-cp" 'smalltalk-print) - (define-key keymap "\C-cq" 'smalltalk-quit) - (define-key keymap "\C-cs" 'smalltalk-snapshot) - keymap) - "Keymap used in Smalltalk interactor mode.") - -(defun gst (command-line) - "Invoke GNU Smalltalk" - (interactive (list (if (null current-prefix-arg) - gst-program-name - (read-smalltalk-command)))) - (setq gst-program-name command-line) - (funcall (if (not (eq major-mode 'gst-mode)) - #'switch-to-buffer-other-window - ;; invoked from a Smalltalk interactor window, so stay - ;; there - #'identity) - (apply 'make-gst "gst" (parse-smalltalk-command gst-program-name))) - (setq *smalltalk-process* (get-buffer-process (current-buffer)))) - -(defun read-smalltalk-command (&optional command-line) - "Reads the program name and arguments to pass to Smalltalk, -providing COMMAND-LINE as a default (which itself defaults to -`gst-program-name'), answering the string." - (read-string "Invoke Smalltalk: " (or command-line gst-program-name))) - -(defun smalltalk-file-name (str) - (if (file-name-directory str) (expand-file-name str) str)) - -(defun parse-smalltalk-command (&optional str) - "Parse a list of command-line arguments from STR (default -`gst-program-name'), adding --emacs-mode and answering the list." - (unless str (setq str gst-program-name)) - (let (start end result-args) - (while (setq start (string-match "[^ \t]" str)) - (setq end (or (string-match " " str start) (length str))) - (push (smalltalk-file-name (substring str start end)) result-args) - (if (null (cdr result-args)) (push "--emacs-mode" result-args)) - (setq str (substring str end))) - (nreverse result-args))) - -(defun make-gst (name &rest switches) - (let ((buffer (get-buffer-create (concat "*" name "*"))) - proc status size) - (setq proc (get-buffer-process buffer)) - (if proc (setq status (process-status proc))) - (save-excursion - (set-buffer buffer) - ;; (setq size (buffer-size)) - (if (memq status '(run stop)) - nil - (if proc (delete-process proc)) - (setq proc (apply 'start-process - name buffer - "env" - ;; I'm choosing to leave these here - ;;"-" - (format "TERMCAP=emacs:co#%d:tc=unknown:" - (frame-width)) - "TERM=emacs" - "EMACS=t" - switches)) - (setq name (process-name proc))) - (goto-char (point-max)) - (set-marker (process-mark proc) (point)) - (set-process-filter proc 'gst-filter) - (gst-mode)) - buffer)) - -(defun gst-filter (process string) - "Make sure that the window continues to show the most recently output -text." - (let (where ch command-str) - (setq where 0) ;fake to get through the gate - (while (and string where) - (if smalltalk-command-string - (setq string (smalltalk-accum-command string))) - (if (and string - (setq where (string-match "\C-a\\|\C-b" string))) - (progn - (setq ch (aref string where)) - (cond ((= ch ?\C-a) ;strip these out - (setq string (concat (substring string 0 where) - (substring string (1+ where))))) - ((= ch ?\C-b) ;start of command - (setq smalltalk-command-string "") ;start this off - (setq string (substring string (1+ where)))))))) - (save-excursion - (set-buffer (process-buffer process)) - (goto-char (point-max)) - (and string - (setq mode-status "idle") - (insert string)) - (if (process-mark process) - (set-marker (process-mark process) (point-max))))) - ;; (if (eq (process-buffer process) - ;; (current-buffer)) - ;; (goto-char (point-max))) - ; (save-excursion - ; (set-buffer (process-buffer process)) - ; (goto-char (point-max)) - ;; (set-window-point (get-buffer-window (current-buffer)) (point-max)) - ; (sit-for 0)) - (let ((buf (current-buffer))) - (set-buffer (process-buffer process)) - (goto-char (point-max)) (sit-for 0) - (set-window-point (get-buffer-window (current-buffer)) (point-max)) - (set-buffer buf))) - -(defun smalltalk-accum-command (string) - (let (where) - (setq where (string-match "\C-a" string)) - (setq smalltalk-command-string - (concat smalltalk-command-string (substring string 0 where))) - (if where - (progn - (unwind-protect ;found the delimiter...do it - (smalltalk-handle-command smalltalk-command-string) - (setq smalltalk-command-string nil)) - ;; return the remainder - (substring string where)) - ;; we ate it all and didn't do anything with it - nil))) - -(defun smalltalk-handle-command (str) - (eval (read str))) - -(defun gst-mode () - "Major mode for interacting Smalltalk subprocesses. - -Entry to this mode calls the value of gst-mode-hook with no arguments, -if that value is non-nil; likewise with the value of comint-mode-hook. -gst-mode-hook is called after comint-mode-hook." - (interactive) - (kill-all-local-variables) - (setq major-mode 'gst-mode) - (setq mode-name "GST") - (require 'comint) - (comint-mode) - (setq mode-line-format - '("" mode-line-modified mode-line-buffer-identification " " - global-mode-string " %[(" mode-name ": " mode-status - "%n" mode-line-process ")%]----" (-3 . "%p") "-%-")) - - (setq comint-prompt-regexp smalltalk-prompt-pattern) - (setq comint-use-prompt-regexp t) - (use-local-map gst-mode-map) - (make-local-variable 'mode-status) - (make-local-variable 'smalltalk-command-string) - (setq smalltalk-command-string nil) - (setq mode-status "starting-up") - (run-hooks 'comint-mode-hook 'gst-mode-hook)) - - -(defun smalltalk-print-region (start end &optional label) - (let (str filename line pos extra) - (save-excursion - (save-restriction - (goto-char (max start end)) - (smalltalk-backward-whitespace) - (setq pos (point)) - ;canonicalize - (while (progn (smalltalk-backward-whitespace) - (or (= (preceding-char) ?!) - (= (preceding-char) ?.))) - (backward-char 1)) - - (setq str (buffer-substring (min start end) (point))) - (setq extra (buffer-substring (point) pos)) - - ;; unrelated, but reusing save-excursion - (goto-char (min start end)) - (setq pos (1- (point))) - (setq filename (buffer-file-name)) - (widen) - (setq line (1+ (count-lines 1 (point)))))) - (send-to-smalltalk (format "(%s) printNl%s\n" str extra) - (or label "eval") - (smalltalk-pos line pos)))) - -(defun smalltalk-eval-region (start end &optional label) - "Evaluate START to END as a Smalltalk expression in Smalltalk window. -If the expression does not end with an exclamation point, one will be -added (at no charge)." - (let (str filename line pos) - (setq str (buffer-substring start end)) - (save-excursion - (save-restriction - (goto-char (min start end)) - (setq pos (point)) - (setq filename (buffer-file-name)) - (widen) - (setq line (1+ (count-lines 1 (point)))))) - (send-to-smalltalk (concat str "\n") - (or label "eval") - (smalltalk-pos line pos)))) - -(defun smalltalk-doit (use-line) - (interactive "P") - (let* ((start (or (mark) (point))) - (end (point)) - (rgn (if (or use-line - (= start end)) - (smalltalk-bound-expr) - (cons start end)))) - (smalltalk-eval-region (car rgn) (cdr rgn) "doIt"))) - -(defun smalltalk-print (use-line) - (interactive "P") - (let* ((start (or (mark) (point))) - (end (point)) - (rgn (if (or use-line - (= start end)) - (smalltalk-bound-expr) - (cons start end)))) - (smalltalk-print-region (car rgn) (cdr rgn) "printIt"))) - -(defun smalltalk-bound-expr () - "Returns a cons of the region of the buffer that contains a smalltalk expression." - (save-excursion - (beginning-of-line) - (cons - (point) - (progn (next-line) - (smalltalk-backward-whitespace) - (point))))) - -(defun smalltalk-pos (line pos) - (let ((filename (buffer-file-name))) - (if filename (list line filename pos) nil))) - -(defun smalltalk-compile (start end) - (interactive "r") - (let ((str (buffer-substring start end)) - (filename (buffer-file-name)) - (pos start) - (line (save-excursion - (save-restriction - (widen) - (setq line (1+ (line-number-at-pos start))))))) - (send-to-smalltalk str "compile" - (smalltalk-pos line pos)))) - -(defun smalltalk-quote-strings (str) - (let (new-str) - (save-excursion - (set-buffer (get-buffer-create " st-dummy ")) - (erase-buffer) - (insert str) - (goto-char 1) - (while (and (not (eobp)) - (search-forward "'" nil 'to-end)) - (insert "'")) - (buffer-string)))) - -(defun smalltalk-snapshot (&optional snapshot-name) - (interactive (if current-prefix-arg - (list (setq snapshot-name - (expand-file-name - (read-file-name "Snapshot to: ")))))) - (if snapshot-name - (send-to-smalltalk (format "ObjectMemory snapshot: '%s'\n" "Snapshot")) - (send-to-smalltalk "ObjectMemory snapshot\n" "Snapshot"))) - -(defun smalltalk-quit () - "Terminate the Smalltalk session and associated process. Emacs remains -running." - (interactive) - (send-to-smalltalk "! ! ObjectMemory quit!" "Quitting")) - -(defun smalltalk-filein (filename) - "Do a FileStream>>fileIn: on FILENAME." - (interactive "fSmalltalk file to load: ") - (send-to-smalltalk (format "FileStream fileIn: '%s'\n" - (expand-file-name filename)) - "fileIn")) - -(defun smalltalk-filein-buffer () - (interactive) - (send-to-smalltalk (buffer-string) "fileIn" (smalltalk-pos 1 1))) - -(defun smalltalk-toggle-decl-tracing () - (interactive) - (send-to-smalltalk - "Smalltalk declarationTrace: Smalltalk declarationTrace not\n")) - -(defun smalltalk-toggle-exec-tracing () - (interactive) - (send-to-smalltalk - "Smalltalk executionTrace: Smalltalk executionTrace not\n")) - - -(defun smalltalk-toggle-verbose-exec-tracing () - (interactive) - (send-to-smalltalk - "Smalltalk verboseTrace: Smalltalk verboseTrace not\n")) - -(defun send-to-smalltalk (str &optional mode fileinfo) - (save-window-excursion - (gst gst-program-name) - (save-excursion - (goto-char (point-max)) - (beginning-of-line) - (if (looking-at smalltalk-prompt-pattern) - (progn (end-of-line) - (insert "\n")))) - - (if mode (setq mode-status mode)) - - (if fileinfo - (let (temp-file buf switch-back old-buf) - (setq temp-file (concat "/tmp/" (make-temp-name "gst"))) - (save-excursion - (setq buf (get-buffer-create " zap-buffer ")) - (set-buffer buf) - (erase-buffer) - (princ str buf) - (write-region (point-min) (point-max) temp-file nil 'no-message) - ) - (kill-buffer buf) - (process-send-string - *smalltalk-process* - (format - "FileStream fileIn: '%s' line: %d from: '%s' at: %d\n" - temp-file (nth 0 fileinfo) (nth 1 fileinfo) (nth 2 fileinfo)))) - (comint-send-string *smalltalk-process* str)) - (switch-to-buffer-other-window (process-buffer *smalltalk-process*)))) - - -(provide 'gst-mode) diff --git a/contrib/smalltalk-mode/smalltalk-mode.el b/contrib/smalltalk-mode/smalltalk-mode.el deleted file mode 100644 index 14c749729..000000000 --- a/contrib/smalltalk-mode/smalltalk-mode.el +++ /dev/null @@ -1,1202 +0,0 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; -;;; Copyright 1988-92, 1994-95, 1999, 2000, 2003, 2007, 2008, 2009 -;;; Free Software Foundation, Inc. -;;; Written by Steve Byrne. -;;; -;;; This file is part of GNU Smalltalk. -;;; -;;; GNU Smalltalk is free software; you can redistribute it and/or modify it -;;; under the terms of the GNU General Public License as published by the Free -;;; Software Foundation; either version 2, or (at your option) any later -;;; version. -;;; -;;; GNU Smalltalk is distributed in the hope that it will be useful, but -;;; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -;;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -;;; for more details. -;;; -;;; You should have received a copy of the GNU General Public License along -;;; with GNU Smalltalk; see the file COPYING. If not, write to the Free -;;; Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;;; Incorporates Frank Caggiano's changes for Emacs 19. -;;; Updates and changes for Emacs 20 and 21 by David Forster - - -;; ===[ Variables and constants ]===================================== - -(defvar smalltalk-name-regexp "[A-z][A-z0-9_]*" - "A regular expression that matches a Smalltalk identifier") - -(defvar smalltalk-keyword-regexp (concat smalltalk-name-regexp ":") - "A regular expression that matches a Smalltalk keyword") - -(defvar smalltalk-name-chars "A-z0-9" - "The collection of character that can compose a Smalltalk identifier") - -(defvar smalltalk-whitespace " \t\n\f") - -(defconst smalltalk-indent-amount 4 - "*'Tab size'; used for simple indentation alignment.") - -;; ---[ Syntax Table ]------------------------------------------------ - -;; This may very well be a bug, but certin chars like ?+ are set to be -;; punctuation, when in fact one might think of them as words (that -;; is, they are valid selector names). Some functions will fail -;; however, (like smalltalk-begin-of-defun) so there punctuation. -;; Works for now... - -(defvar smalltalk-mode-syntax-table - (let ((table (make-syntax-table))) - ;; Make sure A-z0-9 are set to "w " for completeness - (let ((c 0)) - (setq c ?0) - (while (<= c ?9) - (setq c (1+ c)) - (modify-syntax-entry c "w " table)) - (setq c ?A) - (while (<= c ?Z) - (setq c (1+ c)) - (modify-syntax-entry c "w " table)) - (setq c ?a) - (while (<= c ?z) - (setq c (1+ c)) - (modify-syntax-entry c "w " table))) - (modify-syntax-entry 10 " > " table) ; Comment (generic) - (modify-syntax-entry ?: ". " table) ; Symbol-char - (modify-syntax-entry ?_ "_ " table) ; Symbol-char - (modify-syntax-entry ?\" "!1 " table) ; Comment (generic) - (modify-syntax-entry ?' "\" " table) ; String - (modify-syntax-entry ?# "' " table) ; Symbol or Array constant - (modify-syntax-entry ?\( "() " table) ; Grouping - (modify-syntax-entry ?\) ")( " table) ; Grouping - (modify-syntax-entry ?\[ "(] " table) ; Block-open - (modify-syntax-entry ?\] ")[ " table) ; Block-close - (modify-syntax-entry ?{ "(} " table) ; Array-open - (modify-syntax-entry ?} "){ " table) ; Array-close - (modify-syntax-entry ?$ "/ " table) ; Character literal - (modify-syntax-entry ?! ". " table) ; End message / Delimit defs - (modify-syntax-entry ?\; ". " table) ; Cascade - (modify-syntax-entry ?| ". " table) ; Temporaries - (modify-syntax-entry ?^ ". " table) ; Return - ;; Just to make sure these are not set to "w " - (modify-syntax-entry ?< ". " table) - (modify-syntax-entry ?> ". " table) - (modify-syntax-entry ?+ ". " table) ; math - (modify-syntax-entry ?- ". " table) ; math - (modify-syntax-entry ?* ". " table) ; math - (modify-syntax-entry ?/ ".2 " table) ; math - (modify-syntax-entry ?= ". " table) ; bool/assign - (modify-syntax-entry ?% ". " table) ; valid selector - (modify-syntax-entry ?& ". " table) ; boolean - (modify-syntax-entry ?\\ ". " table) ; ??? - (modify-syntax-entry ?~ ". " table) ; misc. selector - (modify-syntax-entry ?@ ". " table) ; Point - (modify-syntax-entry ?, ". " table) ; concat - table) - "Syntax table used by Smalltalk mode") - -;; ---[ Abbrev table ]------------------------------------------------ - -(defvar smalltalk-mode-abbrev-table nil - "Abbrev table in use in smalltalk-mode buffers.") -(define-abbrev-table 'smalltalk-mode-abbrev-table ()) - -;; ---[ Keymap ]------------------------------------------------------ - -(defvar smalltalk-template-map - (let ((keymap (make-sparse-keymap))) - (define-key keymap "p" 'smalltalk-private-template) - (define-key keymap "c" 'smalltalk-class-template) - (define-key keymap "i" 'smalltalk-instance-template) - keymap) - "Keymap of template creation keys") - -(defvar smalltalk-mode-map - (let ((keymap (make-sparse-keymap))) - (define-key keymap "\n" 'smalltalk-newline-and-indent) - (define-key keymap "\C-c\C-a" 'smalltalk-begin-of-defun) - (define-key keymap "\C-c\C-e" 'smalltalk-end-of-defun) - (define-key keymap "\C-c\C-f" 'smalltalk-forward-sexp) - (define-key keymap "\C-c\C-b" 'smalltalk-backward-sexp) - (define-key keymap "\C-c\C-p" 'smalltalk-goto-previous-keyword) - (define-key keymap "\C-c\C-n" 'smalltalk-goto-next-keyword) - ;; the following three are deprecated - (define-key keymap "\C-\M-a" 'smalltalk-begin-of-defun) - (define-key keymap "\C-\M-f" 'smalltalk-forward-sexp) - (define-key keymap "\C-\M-b" 'smalltalk-backward-sexp) - (define-key keymap "!" 'smalltalk-bang) - (define-key keymap ":" 'smalltalk-colon) - (define-key keymap "\C-ct" smalltalk-template-map) - - ;; ----- - - (define-key keymap "\C-cd" 'smalltalk-doit) - (define-key keymap "\C-cf" 'smalltalk-filein-buffer) - (define-key keymap "\C-cm" 'gst) - (define-key keymap "\C-cp" 'smalltalk-print) - (define-key keymap "\C-cq" 'smalltalk-quit) - (define-key keymap "\C-cs" 'smalltalk-snapshot) - - keymap) - "Keymap for Smalltalk mode") - -(defconst smalltalk-binsel "\\([-+*/~,<>=&?]\\{1,2\\}\\|:=\\|||\\)" - "Smalltalk binary selectors") - -(defconst smalltalk-font-lock-keywords - (list - '("#[A-z][A-z0-9_]*" . font-lock-constant-face) - '("\\<[A-z][A-z0-9_]*:" . font-lock-function-name-face) - (cons smalltalk-binsel 'font-lock-function-name-face) -; '("\\^" . font-lock-keyword-face) - '("\\$." . font-lock-string-face) ;; Chars - '("\\<[A-Z]\\sw*\\>" . font-lock-type-face)) - "Basic Smalltalk keywords font-locking") - -(defconst smalltalk-font-lock-keywords-1 - smalltalk-font-lock-keywords - "Level 1 Smalltalk font-locking keywords") - -(defconst smalltalk-font-lock-keywords-2 - (append smalltalk-font-lock-keywords-1 - (list - '("\\<\\(true\\|false\\|nil\\|self\\|super\\)\\>" - . font-lock-builtin-face) - '(":[a-z][A-z0-9_]*" . font-lock-variable-name-face) - '(" |" . font-lock-type-face) - '("<.*>" . font-lock-builtin-face))) - - "Level 2 Smalltalk font-locking keywords") - -(defvar smalltalk-last-category "" - "Category of last method") - -;; ---[ Interactive functions ]--------------------------------------- - -(defun smalltalk-mode () - "Major mode for editing Smalltalk code. - -Commands: -\\{smalltalk-mode-map} -" - (interactive) - (kill-all-local-variables) - (setq major-mode 'smalltalk-mode) - (setq mode-name "Smalltalk") - - (use-local-map smalltalk-mode-map) - (set-syntax-table smalltalk-mode-syntax-table) - (setq local-abbrev-table smalltalk-mode-abbrev-table) - - ;; Buffer locals - - (set (make-local-variable 'paragraph-start) - (concat "^$\\|" page-delimiter)) - (set (make-local-variable 'paragraph-separate) - paragraph-start) - (set (make-local-variable 'paragraph-ignore-fill-prefix) t) - (set (make-local-variable 'indent-line-function) - 'smalltalk-indent-line) - (set (make-local-variable 'require-final-newline) t) - (set (make-local-variable 'comment-start) "\"") - (set (make-local-variable 'comment-end) "\"") - (set (make-local-variable 'comment-column) 32) - (set (make-local-variable 'comment-start-skip) "\" *") - ;; Doesn't seem useful...? - (set (make-local-variable 'comment-indent-function) - 'smalltalk-comment-indent) - ;; For interactive f-b sexp - (set (make-local-variable 'parse-sexp-ignore-comments) t) - - ;; font-locking - (set (make-local-variable 'font-lock-defaults) - '((smalltalk-font-lock-keywords - smalltalk-font-lock-keywords-1 - smalltalk-font-lock-keywords-2) - nil nil nil nil)) - - ;; tags - (set (make-local-variable 'find-tag-default-function) - 'smalltalk-find-message) - ;; Run hooks, must be last - (run-hooks 'smalltalk-mode-hook)) - -(defun smalltalk-tab () - (interactive) - (let (col) - ;; round up, with overflow - (setq col (* (/ (+ (current-column) smalltalk-indent-amount) - smalltalk-indent-amount) - smalltalk-indent-amount)) - (indent-to-column col))) - -(defun smalltalk-bang-begin-of-defun () - (let ((parse-sexp-ignore-comments t) here delim start) - (setq here (point)) - (while (and (search-backward "!" nil 'to-end) - (setq delim (smalltalk-in-string))) - (search-backward delim)) - (setq start (point)) - (if (looking-at "!") - (forward-char 1)) - (smalltalk-forward-whitespace) - ;; check to see if we were already at the start of a method - ;; in which case, the semantics are to go to the one preceeding - ;; this one - (if (and (= here (point)) - (/= start (point-min))) - (progn - (goto-char start) - (smalltalk-backward-whitespace) ;may be at ! "foo" ! - (if (= (preceding-char) ?!) - (backward-char 1)) - (smalltalk-begin-of-defun))))) ;and go to the next one - -(defun smalltalk-scope-begin-of-defun () - (let (here prev (start (smalltalk-current-scope-point))) - (if (and start (/= (point) start)) - (progn - (backward-char 1) - (skip-chars-backward " \t") - (if (bolp) - (backward-char 1) - (end-of-line)) - (setq here (point)) - (goto-char start) - (skip-chars-forward "^[") - (forward-char 1) - (condition-case nil - (while (< (point) here) - (if (looking-at "[ \t]*\\[") (setq prev (point))) - (forward-sexp 1)) - (error t)) - (if prev - (progn - (goto-char prev) - (condition-case nil - (progn - (forward-sexp 1) - (if (and (< (point) here) - (= (char-before) ?\])) - (progn - (skip-syntax-forward " \t") - (setq prev (point))))) - (error t)) - (goto-char prev) - (beginning-of-line) - (skip-chars-forward " \t")) - (goto-char start)))))) - -(defun smalltalk-begin-of-defun () - "Skips to the beginning of the current method. If already at -the beginning of a method, skips to the beginning of the previous -one." - (interactive) - (if (smalltalk-in-bang-syntax) - (smalltalk-bang-begin-of-defun) - (smalltalk-scope-begin-of-defun))) - -(defun smalltalk-begin-of-scope () - "Skips to the beginning of the current method. If already at -the beginning of a method, skips to the beginning of the previous -one." - (interactive) - (let ((start (smalltalk-current-scope-point))) - (if start (goto-char start)))) - - -(defun smalltalk-forward-sexp (n) - "Move point left to the next smalltalk expression." - (interactive "p") - (let (i) - (cond ((< n 0) - (smalltalk-backward-sexp (- n))) - ((null parse-sexp-ignore-comments) - (forward-sexp n)) - (t - (while (> n 0) - (smalltalk-forward-whitespace) - (forward-sexp 1) - (setq n (1- n))))))) - -(defun smalltalk-backward-sexp (n) - "Move point right to the next smalltalk expression." - (interactive "p") - (let (i) - (cond ((< n 0) - (smalltalk-forward-sexp (- n))) - ((null parse-sexp-ignore-comments) - (backward-sexp n)) - (t - (while (> n 0) - (smalltalk-backward-whitespace) - (backward-sexp 1) - (setq n (1- n))))))) - -(defun smalltalk-reindent () - (interactive) - (smalltalk-indent-line)) - -(defun smalltalk-newline-and-indent () - "Called basically to do newline and indent. Sees if the current line is a -new statement, in which case the indentation is the same as the previous -statement (if there is one), or is determined by context; or, if the current -line is not the start of a new statement, in which case the start of the -previous line is used, except if that is the start of a new line in which case -it indents by smalltalk-indent-amount." - (interactive) - (newline) - (smalltalk-indent-line)) - -(defun smalltalk-colon () - "Possibly reindents a line when a colon is typed. -If the colon appears on a keyword that's at the start of the line (ignoring -whitespace, of course), then the previous line is examined to see if there -is a colon on that line, in which case this colon should be aligned with the -left most character of that keyword. This function is not fooled by nested -expressions." - (interactive) - (let (needs-indent state (parse-sexp-ignore-comments t)) - (setq state (parse-partial-sexp (point-min) (point))) - - (if (null (nth 3 state)) ;we're not in string or comment - (progn - (save-excursion - (skip-chars-backward "A-z0-9_") - (if (and (looking-at smalltalk-name-regexp) - (not (smalltalk-at-begin-of-defun))) - (setq needs-indent (smalltalk-white-to-bolp)))) - (and needs-indent - (smalltalk-indent-for-colon)))) - ;; out temporarily - ;; (expand-abbrev) ;I don't think this is the "correct" - ;; ;way to do this...I suspect that - ;; ;some flavor of "call interactively" - ;; ;is better. - (self-insert-command 1))) - -(defun smalltalk-bang () - "Go to the end of the method definition" - (interactive) - (cond ((or (smalltalk-in-string) (smalltalk-in-comment)) (insert "!")) - ((smalltalk-in-bang-syntax) - (progn (insert "!") - (save-excursion - (beginning-of-line) - (if (looking-at "^[ \t]+!") - (delete-horizontal-space))))) - (t (smalltalk-end-of-defun)))) - -(defun smalltalk-end-of-defun () - (interactive) - (if (smalltalk-in-bang-syntax) - (progn (search-forward "!") - (forward-char 1) - (if (looking-at "[ \t\n]+!") - (progn (search-forward 1) - (forward-char 1)))) - (progn (end-of-line) - (smalltalk-begin-of-defun) - (skip-chars-forward "^[") - (forward-sexp 1) - (skip-chars-forward " \t\n")))) - -(defun smalltalk-last-category-name () - smalltalk-last-category) - -(defun smalltalk-insert-indented-line (string) - (insert (format "%s\n" string)) - (save-excursion - (backward-char 1) - (smalltalk-indent-line))) - -(defun smalltalk-maybe-insert-spacing-line (n) - (if (not (save-excursion - (previous-line n) - (looking-at "^[ \t]*$"))) - (insert "\n"))) - -(defun smalltalk-insert-method-body (selector-name category-name) - (let (insert-at-top) - (beginning-of-line) - (smalltalk-forward-whitespace) - (beginning-of-line) - (setq insert-at-top (smalltalk-at-begin-of-defun)) - (if (not insert-at-top) - (progn (smalltalk-end-of-defun) - (beginning-of-line))) - (smalltalk-maybe-insert-spacing-line 1) - (smalltalk-insert-indented-line (format "%s [" selector-name)) - (save-excursion - (insert "\n") - (if (not (equal category-name "")) - (smalltalk-insert-indented-line (format "" category-name))) - (smalltalk-insert-indented-line "]") - (smalltalk-maybe-insert-spacing-line 0)) - (smalltalk-indent-line) - (end-of-line))) - -(defun smalltalk-instance-template-fn (class-name selector-name category-name) - (setq smalltalk-last-category category-name) - (smalltalk-exit-class-scope) - (smalltalk-insert-method-body - (if (equal class-name (smalltalk-current-class-name)) - selector-name - (format "%s >> %s" class-name selector-name)) - category-name)) - -(defun smalltalk-class-template-fn (class-name selector-name category-name) - (setq smalltalk-last-category category-name) - (if (and (equal selector-name "") - (equal class-name (smalltalk-current-class-name))) - (progn (smalltalk-insert-method-body (format " %s class" class-name) "") - (setq smalltalk-last-category "instance creation")) - (smalltalk-insert-method-body - (if (and (smalltalk-in-class-scope) - (equal class-name (smalltalk-current-class-name))) - selector-name - (format "%s class >> %s" class-name selector-name)) - category-name))) - -(defun smalltalk-private-template-fn (class-name selector-name) - (if (smalltalk-in-class-scope) - (smalltalk-class-template-fn class-name selector-name "private") - (smalltalk-instance-template-fn class-name selector-name "private"))) - -(defun smalltalk-maybe-read-class (with-class) - (if (= with-class 1) - (smalltalk-current-class-name) - (read-string "Class: " (smalltalk-current-class-name)))) - -(defun smalltalk-instance-template (with-class) - (interactive "p") - (smalltalk-instance-template-fn - (smalltalk-maybe-read-class with-class) - (read-string "Selector: ") - (read-string "Category: " (smalltalk-last-category-name)))) - -(defun smalltalk-class-template (with-class) - (interactive "p") - (let* ((class-name (smalltalk-maybe-read-class with-class)) - (selector-name (read-string "Selector: ")) - (category-name (if (equal selector-name "") "" - (read-string "Category: " - (smalltalk-last-category-name))))) - (smalltalk-class-template-fn class-name selector-name category-name))) - - -(defun smalltalk-private-template (with-class) - (interactive "p") - (smalltalk-private-template-fn - (smalltalk-maybe-read-class with-class) - (read-string "Selector: "))) - -;; ---[ Non-interactive functions ]----------------------------------- - -;; This is used by indent-for-comment -;; to decide how much to indent a comment in Smalltalk code -;; based on its context. -(defun smalltalk-comment-indent () - (if (looking-at "^\"") - 0 ;Existing comment at bol stays there. - (save-excursion - (skip-chars-backward " \t") - (max (1+ (current-column)) ;Else indent at comment column - comment-column)))) ; except leave at least one space. - -(defun smalltalk-indent-line () - (smalltalk-indent-to-column - (save-excursion - (beginning-of-line) - (skip-chars-forward " \t") - (if (and (not (smalltalk-in-comment)) - (looking-at "[A-z][A-z0-9_]*:") - (not (smalltalk-at-begin-of-defun))) - (smalltalk-indent-for-colon) - (smalltalk-calculate-indent))))) - -(defun smalltalk-toplevel-indent (for-scope) - (let (orig) - (condition-case nil - (save-excursion - (save-restriction - (widen) - (end-of-line) - (setq orig (line-number-at-pos)) - (if for-scope (smalltalk-begin-of-scope) (smalltalk-begin-of-defun)) - (smalltalk-forward-whitespace) - (if (= orig (line-number-at-pos)) - (smalltalk-current-column) - (+ smalltalk-indent-amount (smalltalk-current-column))))) - (error 0)))) - -(defun smalltalk-statement-indent () - (let (needs-indent indent-amount done c state orig start-of-line close - (parse-sexp-ignore-comments nil)) - (save-excursion - (save-restriction - (widen) - (beginning-of-line) - (setq close (looking-at "[ \t]*\]")) - (narrow-to-region (point-min) (point)) ;only care about what's before - (setq state (parse-partial-sexp (point-min) (point))) - (cond ((nth 4 state) ;in a comment - (save-excursion - (smalltalk-backward-comment) - (setq indent-amount - (+ (current-column) (if (= (current-column) 0) 0 1))))) - ((equal (nth 3 state) ?') ;in a string - (setq indent-amount 0)) - (close ;just before a closing bracket - (save-excursion - (condition-case nil - (progn (widen) - (smalltalk-forward-whitespace) - (forward-char) - (backward-sexp 1) - (beginning-of-line) - (smalltalk-forward-whitespace) - (setq indent-amount (current-column)))))) - (t - (save-excursion - (smalltalk-backward-whitespace) - (if (or (bobp) - (= (preceding-char) ?!)) - (setq indent-amount 0))))) - (if (null indent-amount) - (progn - (smalltalk-narrow-to-method) - (beginning-of-line) - (setq state (smalltalk-parse-sexp-and-narrow-to-paren)) - (smalltalk-backward-whitespace) - (cond ((bobp) ;must be first statment in block or exp - (if (nth 1 state) ;we're in a paren exp - (if (looking-at "$") - ;; block with no statements, indent by 4 - (setq indent-amount (+ (smalltalk-current-indent) - smalltalk-indent-amount)) - - ;; block with statements, indent to first non-whitespace - (setq indent-amount (smalltalk-current-column))) - - ;; we're top level - (setq indent-amount (smalltalk-toplevel-indent nil)))) - ((smalltalk-at-end-of-statement) ;end of statement or after temps - (smalltalk-find-statement-begin) - (setq indent-amount (smalltalk-current-column))) - ((= (preceding-char) ?:) - (beginning-of-line) - (smalltalk-forward-whitespace) - (setq indent-amount (+ (smalltalk-current-column) - smalltalk-indent-amount))) - ((= (preceding-char) ?>) ;maybe - (save-excursion - (beginning-of-line) - (if (looking-at "[ \t]*<[ \t]*[a-zA-Z]+:") - (setq indent-amount (smalltalk-toplevel-indent nil)))))))) - (or indent-amount - (save-excursion - (condition-case nil - (smalltalk-find-statement-begin) - (error (beginning-of-line))) - (+ (smalltalk-current-column) - smalltalk-indent-amount))))))) - -(defun smalltalk-at-end-of-statement () - (save-excursion - (or (= (preceding-char) ?.) - (and (= (preceding-char) ?|) - (progn - (backward-char 1) - (while (and (not (bobp)) (looking-back "[ \t\na-zA-Z]")) - (skip-chars-backward " \t\n") - (skip-chars-backward "a-zA-Z")) - (if (= (preceding-char) ?|) - (progn - (backward-char 1) - (skip-chars-backward " \t\n"))) - (bobp)))))) - -(defun smalltalk-calculate-indent () - (cond - ((smalltalk-at-begin-of-scope) (smalltalk-toplevel-indent t)) - ((smalltalk-at-begin-of-defun) (smalltalk-toplevel-indent t)) - (t (smalltalk-statement-indent)))) - - -(defun smalltalk-in-string () - "Returns non-nil delimiter as a string if the current location is -actually inside a string or string like context." - (let (state) - (setq state (parse-partial-sexp (point-min) (point))) - (and (nth 3 state) - (char-to-string (nth 3 state))))) - -(defun smalltalk-in-comment () - "Returns non-nil if the current location is inside a comment" - (let (state) - (setq state (parse-partial-sexp (point-min) (point))) - (nth 4 state))) - -(defun smalltalk-forward-whitespace () - "Skip white space and comments forward, stopping at end of buffer -or non-white space, non-comment character" - (while (looking-at (concat "[" smalltalk-whitespace "]")) - (skip-chars-forward smalltalk-whitespace) - (if (= (following-char) ?\") - (forward-comment 1)))) - -;; (defun smalltalk-forward-whitespace () -;; "Skip white space and comments forward, stopping at end of buffer -;; or non-white space, non-comment character" -;; (forward-comment 1) -;; (if (= (following-char) ?\n) -;; (forward-char))) - -(defun smalltalk-backward-whitespace () - "Like forward whitespace only going towards the start of the buffer" - (while (progn (skip-chars-backward smalltalk-whitespace) - (= (preceding-char) ?\")) - (search-backward "\"" nil t 2))) - -(defun smalltalk-current-column () - "Returns the current column of the given line, regardless of narrowed buffer." - (save-restriction - (widen) - (current-column))) ;this changed in 18.56 - -(defun smalltalk-current-indent () - "Returns the indentation of the given line, regardless of narrowed buffer." - (save-excursion - (save-restriction - (widen) - (beginning-of-line) - (skip-chars-forward " \t") - (current-column)))) - -(defun smalltalk-find-statement-begin () - "Leaves the point at the first non-blank, non-comment character of a new -statement. If begininning of buffer is reached, then the point is left there. -This routine only will return with the point pointing at the first non-blank -on a line; it won't be fooled by multiple statements on a line into stopping -prematurely. Also, goes to start of method if we started in the method -selector." - (let (start ch) - (if (= (preceding-char) ?.) ;if we start at eos - (backward-char 1)) ;we find the begin of THAT stmt - (while (and (null start) (not (bobp))) - (smalltalk-backward-whitespace) - (cond ((= (setq ch (preceding-char)) ?.) - (let (saved-point) - (setq saved-point (point)) - (smalltalk-forward-whitespace) - (if (smalltalk-white-to-bolp) - (setq start (point)) - (goto-char saved-point) - (smalltalk-backward-sexp 1)) - )) - ((= ch ?^) ;HACK -- presuming that when we back - ;up into a return that we're at the - ;start of a statement - (backward-char 1) - (setq start (point))) - ((= ch ?!) - (smalltalk-forward-whitespace) - (setq start (point))) - (t - (smalltalk-backward-sexp 1)))) - (if (null start) - (progn - (goto-char (point-min)) - (smalltalk-forward-whitespace) - (setq start (point)))) - start)) - -(defun smalltalk-match-paren (state) - "Answer the closest previous open paren. -Actually, skips over any block parameters, and skips over the whitespace -following on the same line." - (let ((paren-addr (nth 1 state)) - start c done) - (if (not paren-addr) - () - (save-excursion - (goto-char paren-addr) - (setq c (following-char)) - (cond ((or (eq c ?\() (eq c ?{)) - (1+ (point))) - ((eq c ?\[) - (forward-char 1) - - ;; Now skip over the block parameters, if any - (setq done nil) - (while (not done) - (skip-chars-forward " \t") - (setq c (following-char)) - (cond ((eq c ?:) - (smalltalk-forward-sexp 1)) - ((eq c ?|) - (forward-char 1) ;skip vbar - (skip-chars-forward " \t") - (setq done t)) ;and leave - (t - (setq done t)))) - - ;; Now skip over the block temporaries, if any - (cond ((eq (following-char) ?|) - (setq done nil) - (forward-char 1)) - (t - (setq done t))) - - (while (not done) - (skip-chars-forward " \t") - (setq c (following-char)) - (cond ((eq c ?|) - (forward-char 1) ;skip vbar - (skip-chars-forward " \t") - (setq done t)) ;and leave - (t - (smalltalk-forward-sexp 1)))) - - (point))))))) - -(defun smalltalk-parse-sexp-and-narrow-to-paren () - "Narrows the region to between point and the closest previous open paren. -Actually, skips over any block parameters, and skips over the whitespace -following on the same line." - (let* ((parse-sexp-ignore-comments t) - (state (parse-partial-sexp (point-min) (point))) - (start (smalltalk-match-paren state))) - (if (null start) () (narrow-to-region start (point))) - state)) - -(defun smalltalk-at-begin-of-scope () - "Returns T if at the beginning of a class or namespace definition, otherwise nil" - (save-excursion - (end-of-line) - (if (smalltalk-in-bang-syntax) - (let ((parse-sexp-ignore-comments t)) - (and (bolp) - (progn (smalltalk-backward-whitespace) - (= (preceding-char) ?!)))) - (let ((curr-line-pos (line-number-at-pos))) - (if (smalltalk-begin-of-scope) - (= curr-line-pos (line-number-at-pos))))))) - -(defun smalltalk-at-begin-of-defun () - "Returns T if at the beginning of a method definition, otherwise nil" - (save-excursion - (end-of-line) - (if (smalltalk-in-bang-syntax) - (let ((parse-sexp-ignore-comments t)) - (and (bolp) - (progn (smalltalk-backward-whitespace) - (= (preceding-char) ?!)))) - (let ((curr-line-pos (line-number-at-pos))) - (if (smalltalk-begin-of-defun) - (= curr-line-pos (line-number-at-pos))))))) - -(defun smalltalk-indent-for-colon () - (let (indent-amount c start-line state done default-amount - (parse-sexp-ignore-comments t)) - ;; we're called only for lines which look like "foo:" - (save-excursion - (save-restriction - (widen) - (beginning-of-line) - (smalltalk-end-of-paren) - (smalltalk-narrow-to-method) - (setq state (smalltalk-parse-sexp-and-narrow-to-paren)) - (narrow-to-region (point-min) (point)) - (setq start-line (point)) - (smalltalk-backward-whitespace) - (cond - ((bobp) - (setq indent-amount (smalltalk-toplevel-indent t))) - ((eq (setq c (preceding-char)) ?\;) ; cascade before, treat as stmt continuation - (smalltalk-find-statement-begin) - (setq indent-amount (+ (smalltalk-current-column) - smalltalk-indent-amount))) - ((eq c ?.) ; stmt end, indent like it (syntax error here?) - (smalltalk-find-statement-begin) - (setq indent-amount (smalltalk-current-column))) - (t ;could be a winner - (smalltalk-find-statement-begin) - ;; we know that since we weren't at bobp above after backing - ;; up over white space, and we didn't run into a ., we aren't - ;; at the beginning of a statement, so the default indentation - ;; is one level from statement begin - (setq default-amount - (+ (smalltalk-current-column) ;just in case - smalltalk-indent-amount)) - ;; might be at the beginning of a method (the selector), decide - ;; this here - (if (not (looking-at smalltalk-keyword-regexp )) - ;; not a method selector - (while (and (not done) (not (eobp))) - (smalltalk-forward-sexp 1) ;skip over receiver - (smalltalk-forward-whitespace) - (cond ((eq (following-char) ?\;) - (setq done t) - (setq indent-amount default-amount)) - ((and (null indent-amount) ;pick up only first one - (looking-at smalltalk-keyword-regexp)) - (setq indent-amount (smalltalk-current-column)))))) - (and (null indent-amount) - (setq indent-amount default-amount)))))) - (or indent-amount (smalltalk-current-indent)))) - -(defun smalltalk-end-of-paren () - (let ((prev-point (point))) - (smalltalk-safe-forward-sexp) - (while (not (= (point) prev-point)) - (setq prev-point (point)) - (smalltalk-safe-forward-sexp)))) - -(defun smalltalk-indent-to-column (col) - (if (/= col (smalltalk-current-indent)) - (save-excursion - (beginning-of-line) - (delete-horizontal-space) - (indent-to col))) - (if (bolp) - ;;delete horiz space may have moved us to bol instead of staying where - ;; we were. this fixes it up. - (move-to-column col))) - -(defun smalltalk-narrow-to-method () - "Narrows the buffer to the contents of the method, exclusive of the -method selector and temporaries." - (let ((end (point)) - (parse-sexp-ignore-comments t) - done handled) - (save-excursion - (smalltalk-begin-of-defun) - (if (looking-at "[a-zA-z]") ;either unary or keyword msg - ;; or maybe an immediate expression... - (progn - (forward-sexp) - (if (= (following-char) ?:) ;keyword selector - (progn ;parse full keyword selector - (backward-sexp 1) ;setup for common code - (smalltalk-forward-keyword-selector)) - ;; else maybe just a unary selector or maybe not - ;; see if there's stuff following this guy on the same line - (let (here eol-point) - (setq here (point)) - (end-of-line) - (setq eol-point (point)) - (goto-char here) - (smalltalk-forward-whitespace) - (if (< (point) eol-point) ;if there is, we're not a method - ; (a heuristic guess) - (beginning-of-line) - (goto-char here))))) ;else we're a unary method (guess) - ;; this must be a binary selector, or a temporary - (if (= (following-char) ?|) - (progn ;could be temporary - (end-of-line) - (smalltalk-backward-whitespace) - (if (= (preceding-char) ?|) - (progn - (setq handled t))) - (beginning-of-line))) - (if (not handled) - (progn - (skip-chars-forward (concat "^" smalltalk-whitespace)) - (smalltalk-forward-whitespace) - (skip-chars-forward smalltalk-name-chars)))) ;skip over operand - (if (not (smalltalk-in-bang-syntax)) - (progn (skip-chars-forward "^[") - (forward-char))) - (smalltalk-forward-whitespace) - - ;;sbb 6-Sep-93 14:58:54 attempted fix(skip-chars-forward smalltalk-whitespace) - (if (= (following-char) ?|) ;scan for temporaries - (progn - (forward-char) ;skip over | - (smalltalk-forward-whitespace) - (while (and (not (eobp)) - (looking-at "[a-zA-Z_]")) - (skip-chars-forward smalltalk-name-chars) - (smalltalk-forward-whitespace) - ) - (if (and (= (following-char) ?|) ;only if a matching | as a temp - (< (point) end)) ;and we're after the temps - (narrow-to-region (1+ (point)) end))) ;do we limit the buffer - ;; added "and <..." Dec 29 1991 as a test - (and (< (point) end) - (narrow-to-region (point) end)))))) - -(defun smalltalk-forward-keyword-selector () - "Starting on a keyword, this function skips forward over a keyword selector. -It is typically used to skip over the actual selector for a method." - (let (done) - (while (not done) - (if (not (looking-at "[a-zA-Z_]")) - (setq done t) - (skip-chars-forward smalltalk-name-chars) - (if (= (following-char) ?:) - (progn - (forward-char) - (smalltalk-forward-sexp 1) - (smalltalk-forward-whitespace)) - (setq done t) - (backward-sexp 1)))))) - -(defun smalltalk-white-to-bolp () - "Returns T if from the current position to beginning of line is whitespace. -Whitespace is defined as spaces, tabs, and comments." - (let (done is-white line-start-pos) - (save-excursion - (save-excursion - (beginning-of-line) - (setq line-start-pos (point))) - (while (not done) - (and (not (bolp)) - (skip-chars-backward " \t")) - (cond ((bolp) - (setq done t) - (setq is-white t)) - ((= (char-after (1- (point))) ?\") - (backward-sexp) - (if (< (point) line-start-pos) ;comment is multi line - (setq done t))) - (t - (setq done t)))) - is-white))) - - -(defun smalltalk-backward-comment () - (search-backward "\"") ;find its start - (while (= (preceding-char) ?\") ;skip over doubled ones - (backward-char 1) - (search-backward "\""))) - -(defun smalltalk-current-class () - (let ((here (point)) - curr-hit-point curr-hit new-hit-point new-hit) - (save-excursion - (if (setq curr-hit-point - (search-backward-regexp "^![ \t]*\\(\\(\\w+\\.\\)*\\w+\\)[ \t]+" nil t)) - (setq curr-hit (buffer-substring - (match-beginning 1) - (match-end 1))))) - - (save-excursion - (if (setq new-hit-point - (search-backward-regexp - "^[ \t]*\\(\\w+\\)[ \t]+class[ \t]+\\[" nil t)) - (setq new-hit (buffer-substring - (match-beginning 1) - (match-end 1))))) - (if (and new-hit-point - (or (not curr-hit-point) (> new-hit-point curr-hit-point)) - (smalltalk-in-class-scope-of here new-hit-point)) - (progn (setq curr-hit-point new-hit-point) - (setq curr-hit new-hit))) - - (save-excursion - (if (setq new-hit-point - (search-backward-regexp - "^[ \t]*\\(\\(\\w+\\.\\)*\\w+\\)[ \t]+extend[ \t]+\\[" nil t)) - (setq new-hit (buffer-substring - (match-beginning 1) - (match-end 1))))) - (if (and new-hit-point - (or (not curr-hit-point) (> new-hit-point curr-hit-point))) - (progn (setq curr-hit-point new-hit-point) - (setq curr-hit new-hit))) - - (save-excursion - (if (setq new-hit-point - (search-backward-regexp - "^[ \t]*\\(\\w+\\.\\)*\\w+[ \t]+\\(variable\\|variableWord\\|variableByte\\)?subclass:[ \t]+#?\\(\\w+\\)" nil t)) - (setq new-hit (buffer-substring - (match-beginning 3) - (match-end 3))))) - (if (and new-hit-point - (or (not curr-hit-point) (> new-hit-point curr-hit-point))) - (progn (setq curr-hit-point new-hit-point) - (setq curr-hit new-hit))) - (cons curr-hit curr-hit-point))) - -(defun smalltalk-current-scope-point () - (defun smalltalk-update-hit-point (current search) - (save-excursion - (let ((new-hit-point (funcall search))) - (if (and new-hit-point - (or (not current) (> new-hit-point current))) - new-hit-point - current)))) - (let ((curr-hit-point (smalltalk-current-class-point))) - (setq curr-hit-point - (smalltalk-update-hit-point curr-hit-point - #'(lambda ()(search-backward-regexp "^[ \t]*Eval[ \t]+\\[" nil t)))) - (setq curr-hit-point - (smalltalk-update-hit-point curr-hit-point - #'(lambda ()(search-backward-regexp "^[ \t]*Namespace[ \t]+current:[ \t]+[A-Za-z0-9_.]+[ \t]+\\[" nil t)))) - curr-hit-point)) - -(defun smalltalk-current-class-point () - (cdr (smalltalk-current-class))) - -(defun smalltalk-current-class-name () - (car (smalltalk-current-class))) - -(defun smalltalk-in-bang-syntax () - (let ((curr-hit-point (smalltalk-current-class-point))) - (and curr-hit-point - (save-excursion - (goto-char curr-hit-point) - (beginning-of-line) - (looking-at "!"))))) - -(defun smalltalk-in-class-scope-of (orig curr-hit-point) - (save-excursion - (goto-char curr-hit-point) - (skip-chars-forward " \t") - (skip-chars-forward smalltalk-name-chars) - (skip-chars-forward " \t") - (and (= (following-char) ?c) - ;; check if the class scope ends after the point - (condition-case nil - (progn (skip-chars-forward "^[") - (forward-sexp 1) - (> (point) orig)) - (error t))))) - -(defun smalltalk-in-class-scope () - (let ((curr-hit-point (smalltalk-current-class-point))) - (and curr-hit-point - (smalltalk-in-class-scope-of (point) curr-hit-point)))) - -(defun smalltalk-exit-class-scope () - (interactive) - (if (smalltalk-in-class-scope) - (progn (smalltalk-begin-of-scope) - (skip-chars-forward "^[") - (smalltalk-end-of-defun)))) - -(defun smalltalk-find-message () - (save-excursion - (smalltalk-goto-beginning-of-statement) - (cond - ((smalltalk-looking-at-unary-send) - (if (not (smalltalk-has-sender)) - (progn - (smalltalk-safe-forward-sexp) - (smalltalk-safe-forward-sexp) - (smalltalk-find-message)) - (buffer-substring-no-properties (point) (progn (smalltalk-safe-forward-sexp)(point))))) - ((smalltalk-looking-at-keyword-send) - (concat (smalltalk-find-beginning-of-keyword-send) (smalltalk-find-end-of-keyword-send)))))) - -(defun smalltalk-safe-backward-sexp () - (let (prev-point) - (condition-case nil - (progn - (setq prev-point (point)) - (smalltalk-backward-sexp 1)) - (error (goto-char prev-point))))) - -(defun smalltalk-safe-forward-sexp () - (let (prev-point) - (condition-case nil - (progn - (setq prev-point (point)) - (smalltalk-forward-sexp 1)) - (error (goto-char prev-point))))) - -(defun smalltalk-goto-beginning-of-statement () - (if (not (looking-back "[ \t\n]")) - (smalltalk-safe-backward-sexp))) - -(defun smalltalk-has-sender () - (save-excursion - (smalltalk-backward-whitespace) - (looking-back "[]})A-Za-z0-9']"))) - -(defun smalltalk-looking-at-binary-send () - (looking-at "[^]A-Za-z0-9:_(){}[;.\'\"]+[ \t\n]")) - -(defun smalltalk-looking-at-unary-send () - (looking-at "[A-Za-z][A-Za-z0-9]*[ \t\n]")) - -(defun smalltalk-looking-at-keyword-send () - (looking-at "[A-Za-z][A-Za-z0-9_]*:")) - -(defun smalltalk-looking-back-keyword-send () - (looking-back "[A-z][A-z0-9_]*:")) - -(defun smalltalk-find-end-of-keyword-send () - (save-excursion - (smalltalk-forward-whitespace) - (if (or (looking-at "[.;]") (= (smalltalk-next-keyword) (point))) - "" - (progn - (smalltalk-goto-next-keyword) - (concat (buffer-substring-no-properties (save-excursion (progn (smalltalk-safe-backward-sexp) (point))) (point)) - (smalltalk-find-end-of-keyword-send)))))) - -(defun smalltalk-find-beginning-of-keyword-send () - (save-excursion - (let ((begin-of-defun (smalltalk-at-begin-of-defun))) - (smalltalk-backward-whitespace) - (if (or (if begin-of-defun - (looking-back "[].;]") - (looking-back "[.;]")) - (= (smalltalk-previous-keyword) (point))) - "" - (progn - (smalltalk-goto-previous-keyword) - (concat (smalltalk-find-beginning-of-keyword-send) - (buffer-substring-no-properties (point) (progn (smalltalk-safe-forward-sexp)(+ (point) 1))))))))) - -(defun smalltalk-goto-previous-keyword () - "Go to the previous keyword of the current message send" - (goto-char (smalltalk-previous-keyword))) - -(defun smalltalk-goto-next-keyword () - "Go to the next keyword of the current message send" - (goto-char (smalltalk-next-keyword))) - -(defun smalltalk-previous-keyword-1 () - (smalltalk-backward-whitespace) - (if (looking-back "[>[({.^]") ;; not really ok when > is sent in a keyword arg - nil - (if (= (point) (save-excursion (smalltalk-safe-backward-sexp) (point))) - nil - (progn - (smalltalk-safe-backward-sexp) - (if (smalltalk-looking-at-keyword-send) - (point) - (smalltalk-previous-keyword-1)))))) - -(defun smalltalk-next-keyword-1 () - (smalltalk-forward-whitespace) - (if (looking-at "[])};.]") - nil - (if (= (point) (save-excursion (smalltalk-safe-forward-sexp) (point))) - nil - (progn - (smalltalk-safe-forward-sexp) - (skip-chars-forward ":") - (if (smalltalk-looking-back-keyword-send) - (point) - (smalltalk-next-keyword-1)))))) - -(defun smalltalk-previous-keyword () - (or (save-excursion (smalltalk-previous-keyword-1)) (point))) - -(defun smalltalk-next-keyword () - (or (save-excursion (smalltalk-next-keyword-1)) (point))) - -(provide 'smalltalk-mode) - diff --git a/contrib/unityjs-mode.el b/contrib/unityjs-mode.el old mode 100755 new mode 100644 diff --git a/contrib/yt-stopwatch/probe.scpt b/contrib/yt-stopwatch/probe.scpt deleted file mode 100644 index f9270315b1d5780983177dabd96ab9300243969b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2030 zcmZ=uEKUh^3|27IGc*8UJ_ZH`7XJVL85kLu7?>IV|7T#}Wng4r%w~W97A6K31||kp z1~y&>RtDxA1||ju1_K86|Ns8~l|H!XV7R&mh3dz|X*x2bSkz5M&VIWe{XwG-P04 z;9%hT|A*`U9|jh#g1p3BUIrlsCKCom1{Ma6|Gyc8x&HrVVBtzG&&=ax5N2S^Wnf@n zV_^UPi~0XA21Z^60R|>JMg|6M1|bF!22oxH5s0BY41E88a{d3wz{2I}qM*RbAPUjS z&mj2!2lM|Q|Nrwc@G&svgT2M@|2y~p?+p9~4BX|Jc`5nj@p*~4sSFHE3_J`>3}XMk z@iK@putYI1Fo-eeGl(-t{Qt@z$;%+lz+?*+lVp%$kmhBOf|w`9ApZXg_x~@L=J7H} zLtG)wAi*HR#~{PNxRF6tkUn2Yuy8p#I*0Hws3C0l$o>B#gMa}8PijtL zL2+tId`TuGgj5)q7}WoN;AK#U7^=ab&!EAe$;+U@z?8(mz@WjP%b>-e&C8$#<7+eM zFzE6!=s*nDV9@;kp8NlMY@wwK2?9+9Ee1V420c&^=nFFFGjK2{Fw`*AFevacXhTfV zX3+Wnj{E;REKcNQ(1fS~1=L&a|8LO(>H{dWzJWrE6Ji|$10#b0KZ60|1rA8+pe7mS z*v$7xJ^VF)%O)g4pMu%r0dB zg^vixH4NOIVGP`yjSSqJ4Gi3z^$bi5RxpoPsk)eR0fPtSuh=GG4k|Cd=m?4!R zmm!m(gdvqdh(Ra6phO?VbbXlN`eixE`e38=VI~VRFzPdae9HL$9|Hs9|G%KD&BnmQ zV8~#^%U}pA?->5S`TzR=E5`qCK#E?2h*uz$Mhr|0#{XaPG8iLNzWD$A|1-w_FF=Z( zgNSFKWb~4Ofe%!4@(VC9GqC-C%3#7^%3${Y34=M~|EHkvG+|)*|M>r-{}2B^;QIfV zK|(JvwX7sRv7jKYG$)6Fp@D&cVFH7emX;Rx|3{cPg8TnNED487v?L1*puoW@4}gRR#ZVGyT5}^4UF*&+dX;ZwVr- z7A{@?n4lfmZyjsMpfWEd3wU;BUc{}l#3uK%~7MK#y|o6zE%kHLlkREXbzmc-ou zuVeGrH54y!{l5w=gt-4-!Qy4X|92P+9|$q%YCX)>f28v``iV|VRHmh&>s9}w&lqGG zIG(%Sh-Bc`da2`j%m3(W)l;gjH$wUO7|cLLh^-)lEkgi<3qvYHF+(;(2}3?Z0fPdA z0fP~P9)kgc1%n=g5rYAPA%iJ{0)sAt0)rugIatP$L65-@EN{qQz@W$A!Vty~#GuEJ x%TT~z!u8bC3;of(&*Han!Z}R_HMpF&Hu!Cl)6cF)%Xl{JM8 ; for altering the visual state ;; ;;; Code: -(defvar DEBUG-MODE nil) +(defconst DEBUG-MODE nil) -(defvar my-dir user-emacs-directory) -(defvar my-core-dir (concat my-dir "core/")) -(defvar my-modules-dir (concat my-dir "init/")) -(defvar my-contrib-dir (concat my-dir "contrib/")) -(defvar my-themes-dir (concat my-dir "themes/")) -(defvar my-snippets-dir (concat my-dir "snippets/")) -(defvar my-tmp-dir (concat my-dir ".cache/")) +(defconst my-dir user-emacs-directory) +(defconst my-modules-dir (concat my-dir "init/")) +(defconst my-contrib-dir (concat my-dir "contrib/")) +(defconst my-themes-dir (concat my-dir "themes/")) +(defconst my-snippets-dir (concat my-dir "snippets/")) +(defconst my-tmp-dir (concat my-dir ".cache/")) -(defvar *dark-theme 'v0) -(defvar *light-theme 'github) ; wtb better light theme... -(defvar *fonts `(,(font-spec :family "Terminus (TTF)" :size 12 :antialias nil) - ,(font-spec :family "Inconsolata" :size 14 :antialias t) - ,(font-spec :family "Ubuntu Mono" :size 20 :antialias t) - )) +(defconst *dark-theme 'v0) +(defconst *light-theme 'github) ; wtb better light theme... +(defconst *fonts `(,(font-spec :family "Terminus (TTF)" :size 12 :antialias nil) + ,(font-spec :family "Inconsolata" :size 14 :antialias t) + ,(font-spec :family "Ubuntu Mono" :size 20 :antialias t) + )) -(push my-core-dir load-path) (push my-modules-dir load-path) (push my-contrib-dir load-path) -;; Add elisp and cask dirs to load-path -(let ((default-directory my-contrib-dir)) - (normal-top-level-add-subdirs-to-load-path)) +;; Add cask dirs to load-path (let ((default-directory (expand-file-name (concat ".cask/" emacs-version "/elpa/") my-dir))) (normal-top-level-add-subdirs-to-load-path)) +;;;; Load Packages ;;;;;;;;;;;;;;;;;;;;; (require 'use-package) (mapc 'require ;; ls init/{init,my}* | xargs basename | sed -e 's/\..*$//' '(core core-ui ; aesthetics core-evil ; evil-mode and its plugins - core-editor ; expand-region, rotate-text, smartparens + core-editor ; completing the editor - ;; init-auto-complete init-auto-insert ; for the lazy typis init-company ; see above init-fly ; fly(check|spell) @@ -60,10 +56,8 @@ init-project ; project tools: dired, neotree init-cc ; C/C++/Obj-C madness - ;; init-d ; D - It's C, but better! ;; init-cscope init-csharp - ;; init-erlang ;; init-eshell init-go init-java ; the poster child for carpal tunnel syndome @@ -75,17 +69,15 @@ init-regex ; /^[^\s](meaning)[^\n]*/ init-ruby ; <3 init-scss ; @include magic; - init-smalltalk ; nice weather we're having init-sh ; #!/bin/bash_your_head_in init-swift ; yay, emoji variables! init-text ; I got nothing... init-tmux ;; init-rust - ;; init-vala + ;; init-R init-web init-workgroups init-yasnippet ; type for me - init-youtube ; tools for youtube vids my-defuns my-bindings diff --git a/init/core-editor.el b/init/core-editor.el new file mode 100644 index 000000000..6fbbd7993 --- /dev/null +++ b/init/core-editor.el @@ -0,0 +1,173 @@ +;; Global editor behavior +(electric-indent-mode 1) +(setq electric-indent-chars '(? ?: ?{)) +(add-hook! 'org-mode-hook (electric-indent-mode -1)) + +(add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode) + +(setq-default fill-column 80) +;; Sane scroll settings +(setq scroll-margin 5) +(setq scroll-conservatively 9999) +(setq scroll-preserve-screen-position 1) +;; I'll use visual mode, kthxbai +(setq shift-select-mode nil) + +;;;; Modes 'n hooks ;;;;;;;;;;;;;;;;; +(associate-mode "/LICENSE[^/]*$" 'text-mode) +(associate-mode "zsh\\(env\\|rc\\)?$" 'sh-mode) +(associate-mode "z\\(profile\\|login\\|logout\\)?$" 'sh-mode) +(associate-mode "zsh/" 'sh-mode) +(associate-mode "\\.applescript$" 'applescript-mode) +(associate-mode "Cask$" 'emacs-lisp-mode) +(associate-mode "\\.el\\.gz$" 'emacs-lisp-mode) +(associate-mode "/Makefile$" 'makefile-gmake-mode) +(associate-mode "\\.plist$" 'nxml-mode) + +(add-hook 'help-mode-hook 'visual-line-mode) +(add-hook 'before-save-hook 'delete-trailing-whitespace) + +;; (setenv "SHELL" (s-trim (shell-command-to-string "which zsh"))) +(setenv "SHELL" "/usr/local/bin/zsh") +(setenv "EMACS" "1") + +;; show-paren faces +(set-face-background 'show-paren-match nil) +(set-face-foreground 'show-paren-match "orange") +(set-face-attribute 'show-paren-match nil :weight 'extra-bold) +(setq show-paren-delay 0) + +(let ((face 'evil-search-highlight-persist-highlight-face)) + (set-face-attribute face nil :inherit 'isearch-lazy-highlight-face) + (set-face-foreground face nil) + (set-face-background face nil)) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(use-package smartparens + :config + (progn + (require 'smartparens-config) + (smartparens-global-mode 1) + + (setq blink-matching-paren t) + (setq sp-autowrap-region nil ; let evil-surround handle this + sp-highlight-pair-overlay nil + sp-show-pair-delay 0 + sp-autoescape-string-quote nil) + + ;; Handle newlines + spaces + (sp-pair "{" "}" :post-handlers '(("||\n[i]" "RET") ("| " " ")) :unless '(sp-point-before-word-p sp-point-before-same-p)) + (sp-pair "(" ")" :post-handlers '(("||\n[i]" "RET") ("| " " ")) :unless '(sp-point-before-word-p sp-point-before-same-p)) + + ;; Auto-close more conservatively + (sp-pair "[" nil :unless '(sp-point-before-word-p sp-point-before-same-p)) + (sp-pair "'" nil :unless '(sp-point-after-word-p sp-point-before-word-p sp-point-before-same-p)) + (sp-pair "\"" nil :unless '(sp-point-after-word-p sp-point-before-word-p sp-point-before-same-p)) + + (sp-with-modes '(json-mode js2-mode ruby-mode enh-ruby-mode python-mode) + (sp-local-pair "[" nil :post-handlers '(("||\n[i]" "RET")))) + + (sp-with-modes '(c-mode c++-mode objc-mode java-mode scss-mode css-mode php-mode) + (sp-local-pair "/* " " */" :post-handlers '(("||\n[i]" "RET"))) + (sp-local-pair "/**" "*/" :post-handlers '(("||\n[i]" "RET")))) + + (sp-with-modes '(objc-mode scss-mode css-mode) + (sp-local-pair "/*\n" "\n */" :post-handlers '(("||[i]" "RET")))) + + (sp-with-modes '(c-mode c++-mode php-mode java-mode) + (sp-local-pair "/*" "" :post-handlers '((" ||\n[i]*/" "RET")))) + + (after "yasnippet" + (defadvice yas-expand (before advice-for-yas-expand activate) + (sp-remove-active-pair-overlay))))) + +(use-package rotate-text + :commands (rotate-word-at-point rotate-region)) + +(use-package smart-forward + :commands (smart-up smart-down smart-left smart-right)) + +(use-package expand-region + :commands (er/expand-region er/contract-region)) + +(use-package hl-todo + :commands hl-todo-mode + :init (add-hook 'prog-mode-hook 'hl-todo-mode)) + +(use-package emr + :commands (emr-initialize emr-show-refactor-menu) + :config (bind popup-menu-keymap [escape] 'keyboard-quit)) + +(use-package dash-at-point + :if is-mac + :commands (dash-at-point dash-at-point-with-docset) + :config + (add-to-list 'dash-at-point-mode-alist + '(java-mode . "java,droid,javafx,grails,groovy,playjava,spring,cvj,processing,javadoc"))) + +(use-package rainbow-delimiters + :commands rainbow-delimiters-mode + :init (add-hooks '(emacs-lisp-mode-hook js2-mode-hook scss-mode-hook) + 'rainbow-delimiters-mode) + :config + (progn + (setq rainbow-delimiters-outermost-only-face-count 1) + (set-face-attribute 'rainbow-delimiters-depth-1-face nil + :foreground 'unspecified + :inherit 'my-outermost-paren-face))) + +(use-package yaml-mode + :mode "\\.ya?ml$" + :init (add-hook 'yaml-mode-hook 'enable-tab-width-2)) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(progn ; Code building + (defvar my-build-command '("make %s" . "Makefile")) + (make-variable-buffer-local 'my-build-command) + + (defun set-build-command (command &optional file) + (when (or (null file) + (project-has-files file)) + (setq my-build-command `(,command . ,file)))) + + (evil-define-command my:build (arg) + "Call a build command in the current directory. +If ARG is nil this function calls `recompile', otherwise it calls +`compile' passing ARG as build command." + (interactive "") + (when (null my-build-command) + (user-error "No build command was set")) + (let ((build-file (cdr my-build-command)) + (build-cmd (car my-build-command))) + (if (project-has-files build-file) + (compile (format "cd '%s' && %s" build-file (format build-cmd (or arg "")))) + (error "Could not find Makefile"))))) + +(progn ; Code running + (evil-define-operator my:eval-region (beg end) + :move-point nil + (interactive "") + (cond ((eq major-mode 'emacs-lisp-mode) + (eval-region beg end)) + (t + (let ((interp (my--get-interpreter)) + (max-mini-window-height 1)) + (when interp (shell-command-on-region beg end interp)))))) + + (evil-define-command my:eval-buffer () + (interactive) + (cond ((eq major-mode 'emacs-lisp-mode) + (eval-buffer)) + (t + (let ((interp (my--get-interpreter)) + (max-mini-window-height 1)) + (when interp (shell-command-on-region (point-min) (point-max) interp)))))) + + (defun my--get-interpreter () + (car (--first (eq (cdr it) major-mode) interpreter-mode-alist)))) + + +(provide 'core-editor) +;;; core-editor.el ends here diff --git a/core/core-evil.el b/init/core-evil.el similarity index 72% rename from core/core-evil.el rename to init/core-evil.el index 324be59c3..26d757fed 100644 --- a/core/core-evil.el +++ b/init/core-evil.el @@ -1,5 +1,3 @@ -(provide 'core-evil) - ;;;; Eeeeeeevil ;;;;;;;;;;;;;;;;;;;;;;;; (use-package evil :config @@ -22,6 +20,7 @@ ;; Always ensure evil-shift-width is consistent with tab-width (add-hook! 'after-change-major-mode-hook (setq evil-shift-width tab-width)) + ;; Fix code folding (add-hook 'prog-mode-hook 'hs-minor-mode) ;; highlight matching delimiters where it's important @@ -46,16 +45,39 @@ (term-mode . emacs))) (evil-set-initial-state `,(car mode-map) `,(cdr mode-map))) + ;; predicate for visual line mode + (defun evil-visual-line-state-p () + "Returns non-nil if in visual-line mode, nil otherwise." + (and (evil-visual-state-p) + (eq (evil-visual-type) 'line))) + + (progn ; evil plugins - (use-package evil-ex-registers) (use-package evil-indent-textobject) ; vii/vai/vaI - (use-package evil-numbers) - (use-package evil-matchit :config (global-evil-matchit-mode 1)) - (use-package evil-surround :config (global-evil-surround-mode 1)) - (use-package evil-commentary :config (evil-commentary-mode 1)) + + ;; (use-package evil-ex-registers) + (use-package evil-surround + :commands (evil-surround-edit + evil-Surround-edit + evil-surround-region) + :config (global-evil-surround-mode 1)) + + (use-package evil-numbers + :commands (evil-numbers/inc-at-pt + evil-numbers/dec-at-pt)) + + (use-package evil-matchit + :commands (evilmi-jump-items) + :config (global-evil-matchit-mode 1)) + (use-package evil-search-highlight-persist - :config - (global-evil-search-highlight-persist t)) + :config (global-evil-search-highlight-persist t)) + + (use-package evil-commentary + :commands (evil-commentary + evil-commentary-yank + evil-commentary-line) + :config (evil-commentary-mode 1)) (use-package evil-jumper :init (setq evil-jumper-file (expand-file-name "jumplist" my-tmp-dir)) @@ -66,12 +88,16 @@ (define-key evil-motion-state-map (kbd "H-i") 'evil-jumper/forward))) (use-package evil-exchange + :commands (evil-exchange) :config (defadvice evil-force-normal-state (before evil-esc-quit-exchange activate) (when evil-exchange--overlays (evil-exchange-cancel)))) (use-package evil-visualstar + :commands (evil-visualstar/begin-search + evil-visualstar/begin-search-forward + evil-visualstar/begin-search-backward) :config (progn ;; I cut this down because the original visualstar wouldn't remember @@ -88,22 +114,17 @@ :config (progn (global-evil-snipe-mode +1) - (setq evil-snipe-smart-case t) - (setq evil-snipe-override-evil t) - (setq evil-snipe-scope 'line) - (setq evil-snipe-repeat-scope 'buffer) - (setq evil-snipe-override-evil-repeat-keys nil) + (setq evil-snipe-smart-case t + evil-snipe-override-evil t + evil-snipe-scope 'line + evil-snipe-repeat-scope 'buffer + evil-snipe-override-evil-repeat-keys nil) (setq-default evil-snipe-symbol-groups '((?\[ "[[{(]") (?\] "[]})]"))) - (bind 'motion "C-;" 'evil-snipe-repeat - "C-," 'evil-snipe-repeat-reverse - - 'visual - "z" 'evil-snipe-s - "Z" 'evil-snipe-S)))) + "C-," 'evil-snipe-repeat-reverse)))) (bind evil-ex-completion-map "C-r" #'evil-ex-paste-from-register ; registers in ex-mode @@ -128,67 +149,7 @@ (defadvice evil-window-split (after evil-window-split-jump activate) (evil-window-down 1)) (defadvice evil-window-vsplit (after evil-window-vsplit-jump activate) - (evil-window-right 1)) - - ;; Shut up undo-tree's constant complaining - (defadvice undo-tree-load-history-hook (around undo-tree-load-history-shut-up activate) - (shut-up ad-do-it)) - (defadvice undo-tree-save-history-hook (around undo-tree-save-history-shut-up activate) - (shut-up ad-do-it))) - - (progn ; extensions - (defun evil-visual-line-state-p () - "Returns non-nil if in visual-line mode, nil otherwise." - (and (evil-visual-state-p) - (eq (evil-visual-type) 'line))) - - (defun evil-ex-replace-special-filenames (file-name) - "Replace special symbols in FILE-NAME. - - % => full path to file (/project/src/thing.c) - # => alternative file path (/project/include/thing.h) - %:p => path to project root (/project/) - %:d => path to current directory (/project/src/) - %:e => the file's extension (c) - %:r => the full path without its extension (/project/src/thing) - %:t => the file's basename (thing.c)" - (let ((current-fname (buffer-file-name)) - (alternate-fname (and (other-buffer) - (buffer-file-name (other-buffer))))) - (setq file-name - ;; %:p:h => the project root (or current directory otherwise) - (replace-regexp-in-string "\\(^\\|[^\\\\]\\)\\(%:p\\)" - (project-root) file-name t t 2)) - (setq file-name - ;; %:p => the project root (or current directory otherwise) - (replace-regexp-in-string "\\(^\\|[^\\\\]\\)\\(%:d\\)" - default-directory file-name t t 2)) - (when current-fname - (setq file-name - ;; %:e => ext - (replace-regexp-in-string "\\(^\\|[^\\\\]\\)\\(%:e\\)" - (f-ext current-fname) file-name t t 2)) - (setq file-name - ;; %:r => filename - (replace-regexp-in-string "\\(^\\|[^\\\\]\\)\\(%:r\\)" - (f-no-ext current-fname) file-name t t 2)) - (setq file-name - ;; %:t => filename.ext - (replace-regexp-in-string "\\(^\\|[^\\\\]\\)\\(%:t\\)" - (f-base current-fname) file-name t t 2)) - (setq file-name - ;; % => file path for current frame - (replace-regexp-in-string "\\(^\\|[^\\\\]\\)\\(%\\)" - current-fname file-name t t 2))) - (when alternate-fname - (setq file-name - ;; # => file path for alternative frame - (replace-regexp-in-string "\\(^\\|[^\\\\]\\)\\(#\\)" - alternate-fname file-name t t 2))) - (setq file-name - (replace-regexp-in-string "\\\\\\([#%]\\)" - "\\1" file-name t))) - file-name)) + (evil-window-right 1))) (progn ; ex-commands (evil-define-command my:kill-buffers (&optional bang) @@ -221,9 +182,11 @@ (evil-define-command my:byte-compile (&optional bang) :repeat nil (interactive "") - (if bang - (byte-recompile-directory (concat my-dir ".cask") 0 t) - (byte-recompile-directory my-dir 0 t))) + (byte-recompile-file (expand-file-name "init.el" my-dir) bang 0) + (dolist (file (append (f-glob "core*.el" my-modules-dir) + (f-glob "defuns*.el" my-modules-dir) + (f-glob "my*.el" my-modules-dir))) + (byte-recompile-file file bang 0))) (evil-define-command my:cd (dir) :repeat nil @@ -326,3 +289,6 @@ provided." (interactive "") (evil-normal-state) (my-narrow-to-region-indirect beg end))))) + + +(provide 'core-evil) diff --git a/init/core-linux.el b/init/core-linux.el new file mode 100644 index 000000000..abdf3be9a --- /dev/null +++ b/init/core-linux.el @@ -0,0 +1,5 @@ +(when is-linux (add-to-list 'load-path "~/.cask")) + +(provide 'core-linux) + +;; Nothing here yet diff --git a/core/core-osx.el b/init/core-osx.el similarity index 91% rename from core/core-osx.el rename to init/core-osx.el index 4d2c70a9c..4924016a8 100644 --- a/core/core-osx.el +++ b/init/core-osx.el @@ -12,9 +12,8 @@ (setq mac-option-modifier 'alt) ;; fix emacs PATH on OSX (GUI only) -(use-package exec-path-from-shell - :if (memq window-system '(mac ns)) - :init (exec-path-from-shell-initialize)) +(require 'exec-path-from-shell) +(exec-path-from-shell-initialize) (after "evil" ;; On OSX, stop copying each visual state move to the clipboard: diff --git a/core/core-ui.el b/init/core-ui.el similarity index 73% rename from core/core-ui.el rename to init/core-ui.el index 079b8964d..e52755687 100644 --- a/core/core-ui.el +++ b/init/core-ui.el @@ -10,11 +10,26 @@ ;;;; GUI Settings ;;;;;;;;;;;;;;;;;;;;;; -(tooltip-mode -1) -(blink-cursor-mode -1) ; blink cursor -(global-hl-line-mode 1) ; highlight line +(when window-system + (scroll-bar-mode -1) ; no scrollbar + (tool-bar-mode -1) ; no toolbar + (menu-bar-mode -1)) ; no menubar -(setq linum-format " %3d") +(tooltip-mode -1) +(blink-cursor-mode 1) ; blink cursor +(global-hl-line-mode -1) ; highlight line + +;; Highlight curent line number +(use-package hlinum + :config + (progn + (hlinum-activate) + ;; A little excessive + (remove-hook 'pre-command-hook 'hlinum-unhighlight-current-line))) + +;; Line numbers +(setq linum-format " %4d ") +(add-hooks '(text-mode-hook prog-mode-hook) 'linum-mode) ;; Multiple cursors across buffers cause a strange redraw delay for ;; some things, like auto-complete or evil-mode's cursor color @@ -24,7 +39,6 @@ (setq-default visible-bell nil) ; silence of the bells (setq-default use-dialog-box nil) ; avoid GUI (setq-default redisplay-dont-pause t) -;; (setq window-combination-resize nil) ;; do not soft-wrap lines (setq-default truncate-lines t) @@ -32,11 +46,6 @@ (setq-default indicate-buffer-boundaries nil) (setq-default indicate-empty-lines nil) -(when (functionp 'scroll-bar-mode) (scroll-bar-mode -1)) ; no scrollbar -(when (functionp 'tool-bar-mode) (tool-bar-mode -1)) ; no toolbar -(when (functionp 'menu-bar-mode) (menu-bar-mode -1)) ; no menubar -(when (fboundp 'fringe-mode) (fringe-mode '(5 . 10))) ; no nonsense - (when window-system (setq frame-title-format '(buffer-file-name "%f" ("%b"))) (if (string-equal (system-name) "io") @@ -46,10 +55,13 @@ "Prevent annoying \"Active processes exist\" query when you quit Emacs." (flet ((process-list ())) ad-do-it)) +;; [pedantry intensifies] +(rename-mode-name emacs-lisp-mode "Elisp") + ;;;; Modeline ;;;;;;;;;;;;;;;;;;;;;;;;;; -(use-package vim-empty-lines-mode - :config (global-vim-empty-lines-mode +1)) +;; (use-package vim-empty-lines-mode +;; :config (global-vim-empty-lines-mode +1)) (use-package uniquify :config @@ -58,30 +70,29 @@ uniquify-ignore-buffers-re "^\\*")) (use-package smart-mode-line - :config - (setq rm-blacklist - (mapconcat 'identity - '(" SP" - " Fill" - " EvilOrg" - " Abbrev" - " snipe" - " company" - " Anaconda" - " WS" - " GitGutter" - " Undo-Tree" - " Projectile\\[.+\\]" - " hs" - " ElDoc" - " wg" - " ~" - " s-/" - ;; " yas" - " emr" - " Refactor" - ) "\\|")) :init + (defvar rm-blacklist + (mapconcat 'identity + '(" SP" + " Fill" + " EvilOrg" + " Abbrev" + " snipe" + " company" + " Anaconda" + " WS" + " GitGutter" + " Undo-Tree" + " Projectile\\[.+\\]" + " hs" + " ElDoc" + " wg" + " ~" + " s-/" + " emr" + " Refactor" + ) "\\|")) + :config (progn (setq sml/no-confirm-load-theme t sml/mode-width 'full diff --git a/init/core.el b/init/core.el new file mode 100644 index 000000000..f5d66fa27 --- /dev/null +++ b/init/core.el @@ -0,0 +1,381 @@ +(when (functionp 'scroll-bar-mode) (scroll-bar-mode -1)) ; no scrollbar +(when (functionp 'tool-bar-mode) (tool-bar-mode -1)) ; no toolbar +(when (functionp 'menu-bar-mode) (menu-bar-mode -1)) ; no menubar +(when (fboundp 'fringe-mode) (fringe-mode '(4 . 10))) ; no nonsense + +(defconst is-mac (eq system-type 'darwin)) +(defconst is-linux (eq system-type 'gnu/linux)) +(defconst is-windows (eq system-type 'windows-nt)) + +(setq use-package-verbose DEBUG-MODE) + +(cd "~") ; instead of / + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(require 'defuns) +(require 'autoloads) ; use make autoloads to generate autoloads file +(use-package shut-up + :config + (progn + (setq shut-up-ignore DEBUG-MODE) + (when noninteractive (shut-up-silence-emacs)))) ; http://youtu.be/Z6woIRLnbmE + +;; Make sure undo/backup folders exist +(defconst my-tmp-dir-undo (expand-file-name "undo" my-tmp-dir)) +(defconst my-tmp-dir-backup (expand-file-name "backup" my-tmp-dir)) +(defconst my-tmp-dir-autosave (expand-file-name "autosave" my-tmp-dir)) +(unless (file-directory-p my-tmp-dir) + (make-directory my-tmp-dir-undo t) + (make-directory my-tmp-dir-backup t) + (make-directory my-tmp-dir-autosave t)) + +;; (setq load-prefer-newer t) +(setq debug-on-quit DEBUG-MODE) + + ;;;; Sane defaults ;;;;;;;;;;;;;;;;;;;;;;; +(line-number-mode 1) ; hide line no in modeline +(column-number-mode 1) ; hide col no in modeline +(auto-compression-mode t) ; Transparently open compressed files +(global-font-lock-mode t) ; Enable syntax highlighting for older emacs +(global-auto-revert-mode 1) ; revert buffers for changed files + + ;;; window layout undo/redo +(setq winner-boring-buffers '("*Completions*" "*Compile-Log*" "*inferior-lisp*" + "*Fuzzy Completions*" "*Apropos*" "*Help*" "*cvs*" + "*Buffer List*" "*Ibuffer*" "*esh command on file*")) +(winner-mode 1) + +(use-package semantic + :commands semantic-mode + :init (add-hook 'prog-mode-hook 'semantic-mode) + :config + (progn + (semantic-mode 1) + (setq semanticdb-default-save-directory (expand-file-name "semanticdb" my-tmp-dir)))) + +;;; UTF-8 please +(setq locale-coding-system 'utf-8) ; pretty +(set-terminal-coding-system 'utf-8) ; pretty +(set-keyboard-coding-system 'utf-8) ; pretty +(set-selection-coding-system 'utf-8) ; please +(prefer-coding-system 'utf-8) ; with sugar on top +(fset 'yes-or-no-p 'y-or-n-p) ; y/n instead of yes/no + +;;; Show tab characters +;; (global-whitespace-mode 1) +(setq whitespace-style '(trailing face tabs tab-mark) ; needs to be re-set in every buffer + whitespace-display-mappings + '((tab-mark ?\t [?| ?\t] [?\\ ?\t]) + (newline-mark 10 [36 10]))) ; for whitespace-newline-mode + +;; avoid garbage collection (default is 400k) +(setq-default gc-cons-threshold 20000000) +(setq-default confirm-kill-emacs nil) + +;; minibufferception? Yay! +(setq-default enable-recursive-minibuffers t) + +;; Show me those keystrokes +(setq echo-keystrokes 0.02) + +(setq ring-bell-function 'ignore) + +(setq inhibit-startup-screen t) ; don't show EMACs start screen +(setq inhibit-splash-screen t) +(setq inhibit-startup-buffer-menu t) + +(setq initial-major-mode 'text-mode) ; initial scratch buffer mode +(setq initial-scratch-message nil) +(setq initial-scratch-buffer nil) ; empty scratch buffer + +(setq compilation-always-kill t) +(setq compilation-ask-about-save nil) +(setq compilation-scroll-output t) + +(setq sentence-end-double-space nil) ; sentences end with periods. Period. + +(setq ediff-diff-options "-w") +(setq ediff-split-window-function 'split-window-horizontally) ; side-by-side diffs +(setq ediff-window-setup-function 'ediff-setup-windows-plain) ; no extra frames + +;; Fixes C-i's synonymity with TAB +(keyboard-translate ?\C-i ?\H-i) + +;; Don't save clipboard contents into kill-ring before replacing them +(setq save-interprogram-paste-before-kill nil) + +;; don't let the cursor go into minibuffer prompt +;; Tip taken from Xah Lee: http://ergoemacs.org/emacs/emacs_stop_cursor_enter_prompt.html +(setq minibuffer-prompt-properties + '(read-only t point-entered minibuffer-avoid-prompt face minibuffer-prompt)) + +;; remove annoying ellipsis when printing sexp in message buffer +(setq eval-expression-print-length nil + eval-expression-print-level nil) + +;; Save history across sessions +(use-package savehist + :config + (progn + (setq savehist-file (concat my-tmp-dir "savehist") ; keep the home clean + history-length 1000 + savehist-additional-variables '(kill-ring + global-mark-ring + search-ring + regexp-search-ring + extended-command-history)) + (savehist-mode 1))) + +;; Save cursor location across sessions +(use-package saveplace + :config + (progn + (setq-default save-place-file (concat my-tmp-dir "saveplace")) + ;; activate save-place only for files that exist + (add-hook! 'find-file-hook (if (file-exists-p buffer-file-name) (setq save-place t))))) + +(use-package recentf + :config + (progn + (add-hook 'kill-emacs-hook 'recentf-cleanup) + (setq recentf-save-file (concat my-tmp-dir "recentf") + recentf-exclude '("/tmp/" "/ssh:" "\\.?ido\\.last$" "\\.revive$" "/TAGS$" "/\\.cache/.+" "emacs\\.d/workgroups/.+$" ".emacs.workgroup") + recentf-max-menu-items 0 + recentf-max-saved-items 1000 + recentf-auto-cleanup 'never) + (recentf-mode 1))) + + + ;;;; Backup ;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Disable all backups (that's what git/dropbox are for) +(setq bookmark-save-flag t) +(setq bookmark-default-file (expand-file-name "bookmarks" my-tmp-dir)) +(setq auto-save-default nil) +(setq auto-save-list-file-name (expand-file-name ".auto-save" my-tmp-dir-autosave)) +(setq auto-save-file-name-transforms `((".*" ,my-tmp-dir-autosave t))) +;; In case I want to reactivate backup files +(setq make-backup-files nil) +(setq create-lockfiles nil) +(setq backup-directory-alist `((".*" . ,my-tmp-dir-backup))) +;; Remember undo history +(setq-default undo-tree-auto-save-history t) +(setq-default undo-tree-history-directory-alist `(("." . ,my-tmp-dir-undo))) +;; Keep region when undoing in region +(defadvice undo-tree-undo (around keep-region activate) + (if (use-region-p) + (let ((m (set-marker (make-marker) (mark))) + (p (set-marker (make-marker) (point)))) + ad-do-it + (goto-char p) + (set-mark m) + (set-marker p nil) + (set-marker m nil)) + ad-do-it)) + +;; Keep region when undoing in region +(defadvice undo-tree-undo (around keep-region activate) + (if (use-region-p) + (let ((m (set-marker (make-marker) (mark))) + (p (set-marker (make-marker) (point)))) + ad-do-it + (goto-char p) + (set-mark m) + (set-marker p nil) + (set-marker m nil)) + ad-do-it)) + +;; Shut up undo-tree's constant complaining +(defadvice undo-tree-load-history-hook (around undo-tree-load-history-shut-up activate) + (shut-up ad-do-it)) +;; (defadvice undo-tree-save-history-hook (around undo-tree-save-history-shut-up activate) +;; (shut-up ad-do-it)) + +;; Silences an annoying error: +;; undo-tree-mapc: Wrong type argument: listp, \.\.\. +(defun undo-tree-position (node list) + (when (listp list) + (let ((i 0)) + (catch 'found + (while (progn + (when (eq node (car list)) (throw 'found i)) + (incf i) + (setq list (cdr list)))) + nil)))) + +;; What we do every night, Pinkie... +(defun display-startup-echo-area-message () + (message "What're we gonna do tonight, Brain? (Loaded in %s)" (emacs-init-time))) + + + ;;;; Editor behavior ;;;;;;;;;;;;;;;; +;; spaces instead of tabs +(setq-default indent-tabs-mode nil ; spaces instead of tabs + tab-always-indent t + tab-width 4) + +(setq require-final-newline t) +(setq delete-trailing-lines nil) +(add-hook! 'makefile-mode-hook (setq indent-tabs-mode t)) ; Use normal tabs in makefiles + +;; Project defuns ;;;;;;;;;;;;;;;;;;;;;; +(require 'f) + +(defvar project-root-files '(".git" ".hg" ".svn" ".project" "local.properties" "project.properties" "rebar.config" "project.clj" "SConstruct" "pom.xml" "build.sbt" "build.gradle" "Gemfile" "requirements.txt" "tox.ini" "package.json" "gulpfile.js" "Gruntfile.js" "bower.json" "composer.json" "Cargo.toml" "mix.exs") + "A list of files that count as 'project files', which determine whether a + folder is the root of a project or not.") +(defun project-root (&optional strict-p) + "Get the path to the root of your project. Uses `project-root-files' to +determine if a directory is a project." + (catch 'found + (f-traverse-upwards + (lambda (path) + (let ((path (file-truename path)) + (home (file-truename "~"))) + (if (f-equal? home path) + (throw 'found (if strict-p nil default-directory)) + (dolist (file project-root-files) + (when (f-exists? (expand-file-name file path)) + (throw 'found path)))))) default-directory) + default-directory)) + +(defun project-has-files (files &optional root) + "Return non-nil if `file' exists in the project root." + (let ((root (or root (project-root))) + (files (if (listp files) files (list files))) + found-p file) + (while (and files (not found-p)) + (setq file (pop files)) + (setq found-p (f-exists? (project-path-to file root)))) + found-p)) + +(defun project-path-to (file &optional root) + (let ((root (or root (project-root)))) + (expand-file-name file root))) + +(defun project-name () + (file-name-nondirectory (directory-file-name (project-root)))) + +(defun project-p () + (not (null (project-root t)))) + +;; Make sure scratch buffer is always "in a project" +(defvar project-scratch-buffer nil) +(defun project-create-scratch-buffer () + (let* ((scratch-buffer (get-buffer-create "*scratch*")) + (project-name (project-name)) + (root (project-root))) + (mapc (lambda (b) + (if (string-match-p "\\*scratch\\* (.+)" (buffer-name b)) + (kill-buffer b))) + (buffer-list)) + (save-window-excursion + (switch-to-buffer scratch-buffer) + (setq project-scratch-buffer scratch-buffer) + (erase-buffer) + (cd root) + (rename-buffer (format "*scratch* (%s)" project-name))))) +(add-hook 'find-file-hook 'project-create-scratch-buffer) + + +;; Automatic minor modes ;;;;;;;;;;; +(defvar auto-minor-mode-alist () + "Alist of filename patterns vs correpsonding minor mode functions, +see `auto-mode-alist' All elements of this alist are checked, meaning +you can enable multiple minor modes for the same regexp.") +(defun enable-minor-mode-based-on-path () + "check file name against auto-minor-mode-alist to enable minor modes +the checking happens for all pairs in auto-minor-mode-alist" + (when buffer-file-name + (let ((name buffer-file-name) + (remote-id (file-remote-p buffer-file-name)) + (alist auto-minor-mode-alist)) + ;; Remove backup-suffixes from file name. + (setq name (file-name-sans-versions name)) + ;; Remove remote file name identification. + (when (and (stringp remote-id) + (string-match-p (regexp-quote remote-id) name)) + (setq name (substring name (match-end 0)))) + (while (and alist (caar alist) (cdar alist)) + (if (string-match (caar alist) name) + (funcall (cdar alist) 1)) + (setq alist (cdr alist)))))) +(add-hook 'find-file-hook 'enable-minor-mode-based-on-path) + + +;;;; Utility plugins ;;;;;;;;;;;;;;;;;; + +(use-package smex + :commands (smex smex-major-mode-commands) + :config + (progn + (smex-initialize) + ;; Hook up smex to auto-update, rather than update on every run + (defun smex-update-after-load (unused) + (when (boundp 'smex-cache) (smex-update))) + (add-hook 'after-load-functions 'smex-update-after-load))) + +(use-package popwin + :config + (progn ; popwin config + (popwin-mode 1) + (setq popwin:popup-window-height 0.45) + ;; (setq display-buffer-function 'popwin:display-buffer) + + (push '("\\`\\*helm.*?\\*\\'" :regexp t :position bottom :height 15) popwin:special-display-config) + + (push '("^\\*Flycheck.*\\*$" :regexp t :position bottom :height 0.25 :noselect t) popwin:special-display-config) + (push '(inf-enh-ruby-mode :position bottom :stick t) popwin:special-display-config) + (push '(snippet-mode :position bottom :stick t) popwin:special-display-config) + (push '("^\\*eclim.*\\*" :regexp t :position bottom :height 0.25) popwin:special-display-config) + + (push '("*ansi-term*" :position bottom :height 0.45 :stick t) popwin:special-display-config) + (push '("*terminal*" :position bottom :height 0.45 :stick t) popwin:special-display-config) + (push '("*Async Shell Command*" :position bottom) popwin:special-display-config) + (push '("*Shell Command Output*" :position bottom :stick t :height 15) popwin:special-display-config) + + (push '("* Regexp Explain *" :position top :height 0.35) popwin:special-display-config) + + (push '("*anaconda-doc*" :position bottom :height 15 :noselect t) popwin:special-display-config) + (push '("*anaconda-nav*" :position bottom :height 15 :stick t) popwin:special-display-config) + (push '("^\\*Python.+\\*$" :regexp t :position bottom :height 20 :noselect t) popwin:special-display-config) + + (push '(help-mode :height 0.5 :position bottom :stick t) popwin:special-display-config) + (push '(compilation-mode :height 0.5 :position bottom :noselect t) popwin:special-display-config) + (push '(diff-mode :position bottom :stick t) popwin:special-display-config) + (push '("*Backtrace*") popwin:special-display-config) + (push '("*Warnings*") popwin:special-display-config) + (push '("*Process List*") popwin:special-display-config) + (push '("*Compile-Log*" :height 0.3 :position bottom :noselect t) popwin:special-display-config) + (push '(" *undo-tree*" :width 0.3 :position right) popwin:special-display-config) + (push '("^\\*scratch\\*.*" :regexp t :stick t) popwin:special-display-config) + (push '(image-mode) popwin:special-display-config) + + (push '("*NeoTree*" :position left :width 22 :stick t) popwin:special-display-config) + + (defun popwin:toggle-popup-window () + (interactive) + (if (popwin:popup-window-live-p) + (popwin:close-popup-window) + (popwin:popup-last-buffer))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(cond (is-mac (require 'core-osx)) + (is-linux (require 'core-linux)) + (is-windows (require 'core-windows))) + +;; Performance checks +(add-hook! 'find-file-hook + ;; If file is oversized... + (when (> (buffer-size) (* 1024 1024)) + (setq buffer-read-only t) + (buffer-disable-undo) + (fundamental-mode) + (visual-line-mode))) + +(use-package server + :config (unless (server-running-p) (server-start))) + + +(provide 'core) +;;; core.el ends here diff --git a/core/defuns-buffers.el b/init/defuns-buffers.el similarity index 100% rename from core/defuns-buffers.el rename to init/defuns-buffers.el diff --git a/core/defuns-text.el b/init/defuns-text.el similarity index 100% rename from core/defuns-text.el rename to init/defuns-text.el diff --git a/core/defuns-ui.el b/init/defuns-ui.el similarity index 100% rename from core/defuns-ui.el rename to init/defuns-ui.el diff --git a/core/defuns-util.el b/init/defuns-util.el similarity index 100% rename from core/defuns-util.el rename to init/defuns-util.el diff --git a/core/defuns.el b/init/defuns.el similarity index 97% rename from core/defuns.el rename to init/defuns.el index 3581b6502..7ef9d0a96 100644 --- a/core/defuns.el +++ b/init/defuns.el @@ -40,6 +40,10 @@ 'with-no-warnings) (with-eval-after-load ',feature ,@forms))) +(defmacro rename-mode-name (mode new-name) + `(defadvice ,mode (after rename-modeline activate) + (setq mode-name ,new-name))) + ;; Keybindings ;;;;;;;;;;;;;;;;;;;;;;;;; (defun bind (&rest keys) diff --git a/init/init-cc.el b/init/init-cc.el index 9f790119e..dd1b7cd43 100644 --- a/init/init-cc.el +++ b/init/init-cc.el @@ -64,10 +64,8 @@ (c-set-offset 'case-label '+) ; indent case labels by c-indent-level, too (c-set-offset 'access-label '-) (c-set-offset 'inclass 'my-c-lineup-inclass) - ;; DEL mapping interferes with smartparens and my.deflate-maybe (define-key c-mode-map (kbd "DEL") nil)) - (add-hook 'c-mode-hook 'my-c/c++-settings) (add-hook 'c++-mode-hook 'my-c/c++-settings) (after "flycheck" diff --git a/init/init-company.el b/init/init-company.el index 29758aad1..ff37c03e8 100644 --- a/init/init-company.el +++ b/init/init-company.el @@ -25,21 +25,18 @@ ;; Sort candidates by (add-to-list 'company-transformers 'company-sort-by-occurrence) - ;; (add-to-list 'company-transformers 'company-sort-by-backend-importance) (use-package company-statistics :config (progn (setq company-statistics-file (expand-file-name "company-statistics-cache.el" my-tmp-dir)) (company-statistics-mode))) - (progn ; frontends - (setq-default company-frontends '(company-pseudo-tooltip-unless-just-one-frontend - company-echo-metadata-frontend - company-preview-if-just-one-frontend))) + ;; frontends + (setq-default company-frontends '(company-pseudo-tooltip-unless-just-one-frontend + company-echo-metadata-frontend + company-preview-if-just-one-frontend)) (progn ; backends - (setq-default company-backends '((company-capf company-yasnippet) (company-dictionary company-keywords))) - (defun company--backend-on (hook &rest backends) (add-hook hook `(lambda() @@ -70,7 +67,7 @@ (defvar company-dictionary-alist '()) (defvar company-dictionary-major-minor-modes '()) (defun company-dictionary-active-minor-modes () - (-filter (lambda (mode) (symbol-value mode)) company-dictionary-major-minor-modes)) + (-filter (lambda (mode) (when (boundp mode) (symbol-value mode))) company-dictionary-major-minor-modes)) (defun company-dictionary-assemble () (let ((minor-modes (company-dictionary-active-minor-modes)) (dicts (cdr (assq major-mode company-dictionary-alist)))) @@ -94,20 +91,9 @@ (all-completions arg symbols))) (sorted t)))) - (progn ; keybinds - (bind 'insert company-mode-map - "C-SPC" 'company-complete-common - "C-x C-k" 'company-dictionary - "C-x C-f" 'company-files - "C-x C-]" 'company-etags - "C-x s" 'company-ispell - "C-x C-s" 'company-yasnippet - "C-x C-o" 'company-semantic - "C-x C-n" 'company-dabbrev-code - "C-x C-p" (λ (let ((company-selection-wrap-around t)) - (call-interactively 'company-dabbrev-code) - (company-select-previous-or-abort)))) + (setq-default company-backends '((company-capf company-yasnippet) (company-dictionary company-keywords))) + (progn ; keybinds (define-key company-active-map "C-w" nil) (bind company-active-map "C-o" 'company-search-kill-others @@ -127,7 +113,6 @@ "C-p" 'company-search-repeat-backward [escape] 'company-abort) - (bind company-mode-map "" 'helm-company) (bind company-active-map "" 'helm-company))))) diff --git a/init/init-cscope.el b/init/init-cscope.el index 332f462c1..716ad44fa 100644 --- a/init/init-cscope.el +++ b/init/init-cscope.el @@ -1,4 +1,3 @@ -(provide 'init-cscope) (use-package xcscope :init (cscope-setup) @@ -7,3 +6,5 @@ ) (add-hook 'ruby-mode-hook (function cscope-minor-mode)) + +(provide 'init-cscope) diff --git a/init/init-csharp.el b/init/init-csharp.el index 5cde76add..43701c0ea 100644 --- a/init/init-csharp.el +++ b/init/init-csharp.el @@ -1,20 +1,20 @@ -(use-package omnisharp - :defer t - :config - (progn - (setq omnisharp-server-executable-path - "~/Dropbox/projects/lib/Omnisharp/server/OmniSharp/bin/Debug/OmniSharp.exe") - - (bind 'normal omnisharp-mode-map - "gd" 'omnisharp-go-to-definition) - - (after "company" - (company--backend-on 'csharp-mode-hook 'company-omnisharp) - (add-hook 'csharp-mode-hook 'turn-on-eldoc-mode)))) - (use-package csharp-mode :mode "\\.cs$" :config - (after "flycheck" (add-hook 'csharp-mode-hook 'flycheck-mode))) + (progn + (after "flycheck" (add-hook 'csharp-mode-hook 'flycheck-mode)) + (use-package omnisharp + :defer t + :config + (progn + (setq omnisharp-server-executable-path + "~/Dropbox/projects/lib/Omnisharp/server/OmniSharp/bin/Debug/OmniSharp.exe") + + (bind 'normal omnisharp-mode-map + "gd" 'omnisharp-go-to-definition) + + (after "company" + (company--backend-on 'csharp-mode-hook 'company-omnisharp) + (add-hook 'csharp-mode-hook 'turn-on-eldoc-mode)))))) ;; unity shaders (use-package shaderlab-mode :mode "\\.shader$") diff --git a/init/init-d.el b/init/init-d.el deleted file mode 100644 index ff87f7b4d..000000000 --- a/init/init-d.el +++ /dev/null @@ -1,7 +0,0 @@ -(use-package d-mode - :disabled t - :mode "\\.d$") - - -(provide 'init-d) -;;; init-d.el ends here diff --git a/init/init-erlang.el b/init/init-erlang.el deleted file mode 100644 index 38b212d18..000000000 --- a/init/init-erlang.el +++ /dev/null @@ -1,14 +0,0 @@ -(use-package erlang-start - :mode (("\\.erl?$" . erlang-mode) - ("\\.hrl?$" . erlang-mode)) - :config - (progn - (setq erlang-root-dir "/opt/local/lib/erlang") - (setq erlang-man-root-dir "/opt/local/lib/erlang/man") - (add-to-list 'exec-path "/opt/local/lib/erlang/bin"))) - -;; TODO Install distel -;; TODO Esense? - -(provide 'init-erlang) -;;; init-erlang.el ends here diff --git a/init/init-fly.el b/init/init-fly.el index 00ab6d91e..ead16fcf6 100644 --- a/init/init-fly.el +++ b/init/init-fly.el @@ -1,20 +1,21 @@ (use-package flycheck + :commands (flycheck-mode flycheck-list-errors) :init - (setq-default flycheck-indication-mode 'right-fringe - ;; Removed checks on idle/change for snappiness - flycheck-check-syntax-automatically '(save mode-enabled idle-change) - flycheck-disabled-checkers '(emacs-lisp-checkdoc make)) + (add-hooks '(ruby-mode-hook + python-mode-hook + php-mode-hook + lua-mode-hook + shell-mode-hook + scss-mode-hook + c++-mode-hook + c-mode-hook) + 'flycheck-mode) :config (progn ; flycheck settings - (add-hooks '(ruby-mode-hook - python-mode-hook - php-mode-hook - lua-mode-hook - shell-mode-hook - scss-mode-hook - c++-mode-hook - c-mode-hook) - 'flycheck-mode) + (setq-default flycheck-indication-mode 'right-fringe + ;; Removed checks on idle/change for snappiness + flycheck-check-syntax-automatically '(save mode-enabled idle-change) + flycheck-disabled-checkers '(emacs-lisp-checkdoc make)) (my--cleanup-buffers-add "^\\*Flycheck.*\\*$") diff --git a/init/init-git.el b/init/init-git.el index ea43d6107..88257a89c 100644 --- a/init/init-git.el +++ b/init/init-git.el @@ -21,43 +21,42 @@ (use-package git-gutter-fringe+ :config (progn - (global-git-gutter+-mode +1) - + (global-git-gutter+-mode 1) ;; Fixes "git-gutter+-process-diff: Wrong number of arguments: nil" error (defadvice git-gutter+-process-diff (before git-gutter+-process-diff-advice activate) (ad-set-arg 0 (file-truename (ad-get-arg 0)))) (fringe-helper-define 'git-gutter-fr+-added nil - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......") + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......") (fringe-helper-define 'git-gutter-fr+-deleted nil - "XX......" - "XXXXXXXX" - "XX......" + ".X......" + ".XXXXXXX" + ".X......" "........" "........" "........" @@ -82,31 +81,31 @@ "........") (fringe-helper-define 'git-gutter-fr+-modified nil - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......" - "XX......"))) + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......" + ".X......"))) (evil-set-initial-state 'git-commit-mode 'insert) (evil-set-initial-state 'git-rebase-mode 'insert) diff --git a/init/init-helm.el b/init/init-helm.el index 7a533da42..c0d2e0f70 100644 --- a/init/init-helm.el +++ b/init/init-helm.el @@ -1,4 +1,62 @@ +(use-package projectile + :commands (projectile-ack + projectile-ag + projectile-compile-project + projectile-dired + projectile-grep + projectile-find-dir + projectile-find-file + projectile-find-tag + projectile-find-test-file + projectile-invalidate-cache + projectile-kill-buffers + projectile-multi-occur + projectile-project-root + projectile-recentf + projectile-regenerate-tags + projectile-replace + projectile-run-async-shell-command-in-root + projectile-run-shell-command-in-root + projectile-switch-project + projectile-switch-to-buffer + projectile-vc + projectile-project-p + helm-projectile-find-file + helm-projectile-recentf + helm-projectile-find-other-file + helm-projectile-switch-project) + :config + (progn + (setq-default projectile-enable-caching t) + (setq projectile-sort-order 'recentf + projectile-cache-file (concat my-tmp-dir "projectile.cache") + projectile-known-projects-file (concat my-tmp-dir "projectile.projects") + projectile-indexing-method 'alien + projectile-project-root-files project-root-files) + (add-to-list 'projectile-globally-ignored-files "ido.last") + (add-to-list 'projectile-globally-ignored-directories "assets") + (add-to-list 'projectile-other-file-alist '("scss" "css")) + (add-to-list 'projectile-other-file-alist '("css" "scss")) + (projectile-global-mode +1) + + (use-package helm-projectile) + ;; Don't show the project name in the prompts; I already know. + (defun projectile-prepend-project-name (string) helm-global-prompt))) + (use-package helm + :commands (helm + helm-M-x + helm-buffers-list + helm-semantic-or-imenu + helm-etags-select + helm-apropos + helm-recentf + helm-show-kill-ring + helm-bookmarks + helm-wg + my:helm-recentf) + :init + (evil-set-initial-state 'helm-mode 'emacs) :config (progn ; helm settings (defvar helm-global-prompt ">>> ") @@ -24,89 +82,7 @@ (my--cleanup-buffers-add "^\\*[Hh]elm.*\\*$") - (use-package helm-ag) - (use-package helm-css-scss ; https://github.com/ShingoFukuyama/helm-css-scss - :commands (helm-css-scss - helm-css-scss-multi - helm-css-scss-insert-close-comment)) - - (use-package helm-company :commands (helm-company)) - - ;; Ex-mode interface for `helm-ag'. If `bang', then `search' is interpreted as - ;; regexp. - (evil-define-operator my:helm-ag-search (beg end &optional search hidden-files-p pwd-p regex-p) - :type inclusive - :repeat nil - (interactive "") - (let* ((helm-ag-default-directory (if pwd-p default-directory (project-root))) - (helm-ag-command-option (concat (unless regex-p "-Q ") - (if hidden-files-p "--hidden "))) - (input "") - (header-name (format "Search in %s" helm-ag-default-directory))) - (if search - (progn - (helm-attrset 'search-this-file nil helm-ag-source) - (setq helm-ag--last-query search)) - (if (and beg end (/= beg (1- end))) - (setq input (buffer-substring-no-properties beg end)))) - (helm-attrset 'name header-name helm-ag-source) - (helm :sources (if search (helm-ag--select-source) '(helm-source-do-ag)) - :buffer "*helm-ag*" - :input input - :prompt helm-global-prompt))) - - (evil-define-operator my:helm-ag-regex-search (beg end &optional search bang) - :type inclusive :repeat nil - (interactive "") - (my:helm-ag-search beg end search bang nil t)) - (evil-define-operator my:helm-ag-search-cwd (beg end &optional search bang) - ;; Ex-mode interface for `helm-do-ag'. If `bang', then `search' is interpreted - ;; as regexp - :type inclusive :repeat nil - (interactive "") - (my:helm-ag-search beg end search bang t nil)) - (evil-define-operator my:helm-ag-regex-search-cwd (beg end &optional search bang) - :type inclusive :repeat nil - (interactive "") - (my:helm-ag-search beg end search bang t t)) - - (use-package helm-swoop ; https://github.com/ShingoFukuyama/helm-swoop - :commands (helm-swoop helm-multi-swoop) - :config - (setq helm-swoop-use-line-number-face t - helm-swoop-split-with-multiple-windows t - helm-swoop-speed-or-color t - ;; helm-swoop-split-window-function 'popwin:popup-buffer - )) - - ;; Ex-mode interface for `helm-swoop', `helm-multi-swoop-all' (if `bang'), or - ;; `helm-css-scss' and `helm-css-scss-multi' (if `bang') if major-mode is - ;; `scss-mode' - (evil-define-command my:helm-swoop (&optional search bang) - :repeat nil - (interactive "") - (if (eq major-mode 'scss-mode) - (if bang (helm-css-scss-multi search) (helm-css-scss search)) - (if bang (helm-multi-swoop-all search) (helm-swoop :$query search)))) - - (use-package projectile - :init (setq-default projectile-enable-caching t) - :config - (progn - (projectile-global-mode +1) - (setq projectile-sort-order 'recentf - projectile-cache-file (concat my-tmp-dir "projectile.cache") - projectile-known-projects-file (concat my-tmp-dir "projectile.projects") - projectile-indexing-method 'alien) - (add-to-list 'projectile-globally-ignored-files "ido.last") - (add-to-list 'projectile-globally-ignored-directories "assets") - (add-to-list 'projectile-other-file-alist '("scss" "css")) - (add-to-list 'projectile-other-file-alist '("css" "scss")) - - ;; Don't show the project name in the prompts; I already know. - (defun projectile-prepend-project-name (string) helm-global-prompt) - - (use-package helm-projectile))) + (require 'helm-files) (progn ; helm hacks ;; No persistent header @@ -142,8 +118,6 @@ (when force (force-mode-line-update)))) (progn ; evil - (evil-set-initial-state 'helm-mode 'emacs) - ;; Ex-mode interface for `helm-recentf' and `helm-projectile-recentf'. If ;; `bang', then `search' is interpreted as regexp (evil-define-command my:helm-recentf (&optional bang) @@ -157,6 +131,77 @@ "C-r" 'evil-ex-paste-from-register ; Evil registers in helm! Glorious! [escape] 'helm-keyboard-quit))) +(use-package helm-ag + :commands (helm-ag + my:helm-ag-search + my:helm-ag-regex-search + my:helm-ag-search-cwd + my:helm-ag-regex-search-cwd) + :config + (progn + ;; Ex-mode interface for `helm-ag'. If `bang', then `search' is interpreted as + ;; regexp. + (evil-define-operator my:helm-ag-search (beg end &optional search hidden-files-p pwd-p regex-p) + :type inclusive + :repeat nil + (interactive "") + (let* ((helm-ag-default-directory (if pwd-p default-directory (project-root))) + (helm-ag-command-option (concat (unless regex-p "-Q ") (if hidden-files-p "--hidden "))) + (input "") + (header-name (format "Search in %s" helm-ag-default-directory))) + (if search + (progn + (helm-attrset 'search-this-file nil helm-ag-source) + (setq helm-ag--last-query search)) + (if (and beg end (/= beg (1- end))) + (setq input (buffer-substring-no-properties beg end)))) + (helm-attrset 'name header-name helm-ag-source) + (helm :sources (if search (helm-ag--select-source) '(helm-source-do-ag)) + :buffer "*helm-ag*" + :input input + :prompt helm-global-prompt))) + + (evil-define-operator my:helm-ag-regex-search (beg end &optional search bang) + :type inclusive :repeat nil + (interactive "") + (my:helm-ag-search beg end search bang nil t)) + (evil-define-operator my:helm-ag-search-cwd (beg end &optional search bang) + ;; Ex-mode interface for `helm-do-ag'. If `bang', then `search' is interpreted + ;; as regexp + :type inclusive :repeat nil + (interactive "") + (my:helm-ag-search beg end search bang t nil)) + (evil-define-operator my:helm-ag-regex-search-cwd (beg end &optional search bang) + :type inclusive :repeat nil + (interactive "") + (my:helm-ag-search beg end search bang t t)))) + +(use-package helm-company :defer t) + +(use-package helm-css-scss ; https://github.com/ShingoFukuyama/helm-css-scss + :commands (helm-css-scss + helm-css-scss-multi + helm-css-scss-insert-close-comment)) + +(use-package helm-swoop ; https://github.com/ShingoFukuyama/helm-swoop + :commands (helm-swoop helm-multi-swoop my:helm-swoop) + :config + (progn + (setq helm-swoop-use-line-number-face t + helm-swoop-split-with-multiple-windows t + helm-swoop-speed-or-color t + ;; helm-swoop-split-window-function 'popwin:popup-buffer + ) + + ;; Ex-mode interface for `helm-swoop', `helm-multi-swoop-all' (if `bang'), or + ;; `helm-css-scss' and `helm-css-scss-multi' (if `bang') if major-mode is + ;; `scss-mode' + (evil-define-command my:helm-swoop (&optional search bang) + :repeat nil + (interactive "") + (if (eq major-mode 'scss-mode) + (if bang (helm-css-scss-multi search) (helm-css-scss search)) + (if bang (helm-multi-swoop-all search) (helm-swoop :$query search)))))) (provide 'init-helm) ;;; init-helm.el ends here diff --git a/init/init-ido.el b/init/init-ido.el index e23dd9bc6..0718cca75 100644 --- a/init/init-ido.el +++ b/init/init-ido.el @@ -16,8 +16,8 @@ (ido-everywhere 1) (use-package ido-vertical-mode :config (ido-vertical-mode 1)) -(use-package ido-ubiquitous :config (ido-ubiquitous-mode 1)) (use-package flx-ido :config (flx-ido-mode 1)) +(use-package ido-ubiquitous :config (ido-ubiquitous-mode 1)) (setq ido-use-faces nil ido-confirm-unique-completion t @@ -50,6 +50,18 @@ (lambda (x) (and (char-equal (string-to-char x) ?.) x)) ido-temp-list)))) +;; Press ~ to go to $HOME in ido +(add-hook 'ido-setup-hook + (lambda () + ;; Go straight home + (define-key ido-file-completion-map + (kbd "~") + (lambda () + (interactive) + (if (looking-back "/") + (insert "~/") + (call-interactively 'self-insert-command)))))) + (provide 'init-ido) ;;; init-ido.el ends here diff --git a/init/init-java.el b/init/init-java.el index 502015c1c..1644024a8 100644 --- a/init/init-java.el +++ b/init/init-java.el @@ -41,8 +41,25 @@ (use-package android-mode :defer t + :commands android-mode :init (progn + (defun android-mode-is-layout-file () + (and android-mode + (eq major-mode 'nxml-mode) + (string-equal (file-name-base (directory-file-name default-directory)) "layout"))) + (defun android-mode-in-tags (&rest tags) + (-contains? tags (android-mode-tag-name))) + (defun android-mode-tag-name () + (save-excursion + (let (beg end) + (nxml-backward-up-element) + (evil-forward-word-begin) + (setq beg (point)) + (evil-forward-WORD-end) + (setq end (1+ (point))) + (buffer-substring-no-properties beg end)))) + (defun my-android-mode-enable-maybe () (let ((root (project-root))) (when (or (project-has-files "local.properties" root) diff --git a/init/init-php.el b/init/init-php.el index 6919b1a97..cf8daeef7 100644 --- a/init/init-php.el +++ b/init/init-php.el @@ -10,7 +10,10 @@ ;; TODO Tie into emr (use-package php-refactor-mode - :config (add-hook 'php-mode-hook 'php-refactor-mode)))) + :config + (progn + (add-hook 'php-mode-hook 'emr-initialize) + (add-hook 'php-mode-hook 'php-refactor-mode))))) (provide 'init-php) diff --git a/init/init-project.el b/init/init-project.el index 3ba1ea547..f0ca5580e 100644 --- a/init/init-project.el +++ b/init/init-project.el @@ -1,39 +1,50 @@ ;; Project nav+search tools (projectile, helm, ag) (use-package neotree - :commands (neotree-show neotree-hide neotree-toggle) + :commands (neotree-show neotree-hide neotree-toggle neo-global--window-exists-p neotree-dir neotree-find) + :init + (progn + (defun my-neotree-open (&optional dir) + (interactive) + (neotree-dir (or dir (project-root)))) + + (defun my-neotree-toggle () + (interactive) + (if (neo-global--window-exists-p) + (neotree-hide) + (my-neotree-open))) + + (defun my-neotree-find () + (interactive) + (save-excursion (my-neotree-open)) + (neotree-find))) :config - (progn (setq neo-create-file-auto-open t - neo-smart-open t - neo-persist-show nil) - (add-hook! 'neotree-mode-hook - (setq mode-line-format nil) - (bind evil-motion-state-local-map - (kbd "TAB") 'neotree-enter - (kbd "RET") 'neotree-enter)))) + (progn + (setq neo-create-file-auto-open t + neo-mode-line-type 'neotree + neo-persist-show t + neo-window-width 28 + neo-show-updir-line nil + neo-auto-indent-point t) + (add-to-list 'evil-motion-state-modes 'neotree-mode) + (defun my-neotree-keymap () + (bind evil-motion-state-local-map + "\\\\" 'neotree-hide + "RET" 'neotree-enter + "J" 'neotree-select-next-sibling-node + "K" 'neotree-select-previous-sibling-node + "H" 'neotree-select-up-node + "L" 'neotree-select-down-node + "v" 'neotree-enter-vertical-split + "s" 'neotree-enter-horizontal-split + "c" 'neotree-create-node + "d" 'neotree-delete-node + "g" 'neotree-refresh + "q" 'neotree-hide + "r" 'neotree-rename-node + "R" 'neotree-change-root + "?" 'neotree-)) -(defun my-ido-find-project-file () - (interactive) - (let ((default-directory (project-root))) - (ido-find-file))) - - -;; (use-package dired -;; :disabled t -;; :config -;; (progn -;; (setq dired-recursive-deletes 'always -;; dired-recursive-copies 'always -;; dired-auto-revert-buffer t - -;; ;; if there is a dired buffer displayed in the next -;; ;; window, use its current subdir, instead of the -;; ;; current subdir of this dired buffer -;; dired-dwim-target t) - -;; (push '(dired-mode :position bottom :height 0.5 :stick t) popwin:special-display-config) - -;; (add-hook! 'dired-mode-hook -;; (use-package 'dired+ :config (toggle-diredp-find-file-reuse-dir 1))))) + (add-hook 'neotree-mode-hook 'my-neotree-keymap))) (provide 'init-project) diff --git a/init/init-python.el b/init/init-python.el index c601cfc90..3d6e93b4f 100644 --- a/init/init-python.el +++ b/init/init-python.el @@ -1,13 +1,15 @@ (use-package python :mode ("\\.py\\'" . python-mode) :interpreter ("python" . python-mode) - :init (add-hook 'python-mode-hook 'enable-tab-width-4) + :init + (progn + (add-hook 'python-mode-hook 'enable-tab-width-4) + (add-hook 'python-mode-hook 'emr-initialize)) :config (progn (setq-default python-indent-offset 4) (setq python-environment-directory my-tmp-dir) (setq python-shell-interpreter "ipython") - ;; interferes with smartparens (define-key python-mode-map (kbd "DEL") nil) diff --git a/init/init-regex.el b/init/init-regex.el index d171f3452..16d9915ae 100644 --- a/init/init-regex.el +++ b/init/init-regex.el @@ -13,6 +13,12 @@ (goto-char 2)) (add-hook 'reb-mode-hook 'my--reb-cleanup) + (use-package pcre2el + :config + (progn + (bind 'normal rxt-help-mode-map [escape] 'kill-buffer-and-window) + (setq reb-re-syntax 'pcre))) + (after "evil" (evil-set-initial-state 'reb-mode 'insert) ;; Either a) converts selected (or entered-in) pcre regex into elisp @@ -45,13 +51,6 @@ (t (re-builder)))))))) -(use-package pcre2el - :config - (progn - (bind 'normal rxt-help-mode-map [escape] 'kill-buffer-and-window) - - (after "re-builder" (setq reb-re-syntax 'pcre)))) - (provide 'init-regex) ;;; init-regex.el ends here diff --git a/init/init-ruby.el b/init/init-ruby.el index ed1d1bb36..bb4bf74b4 100644 --- a/init/init-ruby.el +++ b/init/init-ruby.el @@ -4,10 +4,10 @@ ("\\.rake$" . enh-ruby-mode) ("\\.gemspec$" . enh-ruby-mode) ("\\.?pryrc$" . enh-ruby-mode) - ("/Gemfile$" . enh-ruby-mode) - ("/Capfile$" . enh-ruby-mode) - ("/Vagrantfile$" . enh-ruby-mode) - ("/Rakefile$" . enh-ruby-mode)) + ("/Gemfile$" . enh-ruby-mode) + ("/Capfile$" . enh-ruby-mode) + ("/Vagrantfile$" . enh-ruby-mode) + ("/Rakefile$" . enh-ruby-mode)) :interpreter "ruby" :config (progn @@ -23,27 +23,31 @@ ;; Don't interfere with my custom RET behavior (define-key enh-ruby-mode-map [?\n] nil) - (after "emr" - (use-package ruby-refactor) - (emr-declare-command 'ruby-refactor-extract-to-method - :title "extract method" - :modes 'enh-ruby-mode - :predicate (lambda () (use-region-p))) - (emr-declare-command 'ruby-refactor-extract-local-variable - :title "extract local variable" - :modes 'enh-ruby-mode - :predicate (lambda () (use-region-p))) - (emr-declare-command 'ruby-refactor-extract-constant - :title "extract constant" - :modes 'enh-ruby-mode - :predicate (lambda () (use-region-p))) - (emr-declare-command 'ruby-refactor-add-parameter - :title "add parameter" - :modes 'enh-ruby-mode) - (emr-declare-command 'ruby-refactor-extract-to-let - :title "extract to let" - :modes 'enh-ruby-mode - :predicate (lambda () (use-region-p)))) + (use-package ruby-refactor + :init + (add-hook 'enh-ruby-mode-hook 'emr-initialize) + :config + (after "emr" + (emr-declare-command 'ruby-refactor-extract-to-method + :title "extract method" + :modes 'enh-ruby-mode + :predicate (lambda () (use-region-p))) + (emr-declare-command 'ruby-refactor-extract-local-variable + :title "extract local variable" + :modes 'enh-ruby-mode + :predicate (lambda () (use-region-p))) + (emr-declare-command 'ruby-refactor-extract-constant + :title "extract constant" + :modes 'enh-ruby-mode + :predicate (lambda () (use-region-p))) + (emr-declare-command 'ruby-refactor-add-parameter + :title "add parameter" + :modes 'enh-ruby-mode) + (emr-declare-command 'ruby-refactor-extract-to-let + :title "extract to let" + :modes 'enh-ruby-mode + :predicate (lambda () (use-region-p))))) + ;; Rakefiles ;;;;;;;;;;;;;;;;;;;;;;;;;;; (define-minor-mode rake-mode diff --git a/init/init-smalltalk.el b/init/init-smalltalk.el deleted file mode 100644 index 9ecac8cec..000000000 --- a/init/init-smalltalk.el +++ /dev/null @@ -1,5 +0,0 @@ -;; For GNU-Smalltalk -(use-package smalltalk-mode :mode "\\.g?st$") - -(provide 'init-smalltalk) -;;; init-smalltalk.el ends here diff --git a/init/init-workgroups.el b/init/init-workgroups.el index 993ac17e4..5359fdacb 100644 --- a/init/init-workgroups.el +++ b/init/init-workgroups.el @@ -1,7 +1,7 @@ (use-package workgroups2 :config (progn - (setq wg-session-file "~/.emacs.d/workgroups/.default") + (setq wg-session-file "~/.emacs.workgroup") (setq wg-workgroup-directory "~/.emacs.d/workgroups/") (setq wg-first-wg-name "main") diff --git a/init/init-yasnippet.el b/init/init-yasnippet.el index 3aeae503a..811c1ba11 100644 --- a/init/init-yasnippet.el +++ b/init/init-yasnippet.el @@ -1,36 +1,37 @@ (use-package yasnippet + :defer t + :commands (yas-minor-mode yas-minor-mode-on my--init-yas-mode my:snippets) :mode (("emacs\\.d/snippets/.+$" . snippet-mode)) - :demand t :init (progn (defvar yas-minor-mode-map - ;; Fix yasnippet keymaps so they only work in insert mode (let ((map (make-sparse-keymap))) (bind 'insert map [(tab)] 'yas-expand) - (bind 'insert map (kbd "TAB") 'yas-expand) - (bind 'visual map (kbd "") 'yas-insert-snippet) + (bind 'visual map "" 'yas-insert-snippet) map)) - ;; (add-hook 'snippet-mode-hook 'yas-minor-mode-on) - ;; (add-hook 'text-mode-hook 'yas-minor-mode-on) - ;; (add-hook 'prog-mode-hook 'yas-minor-mode-on) - ;; (add-hook 'org-mode-hook 'yas-minor-mode-on)) + (add-hook 'snippet-mode-hook 'yas-minor-mode-on) + (add-hook 'text-mode-hook 'yas-minor-mode-on) + (add-hook 'prog-mode-hook 'yas-minor-mode-on) + (add-hook 'org-mode-hook 'yas-minor-mode-on) (add-hook 'snippet-mode-hook 'disable-final-newline)) :config (progn + (bind 'insert [(tab)] nil) + (bind 'visual "" nil) + (setq yas-verbosity 0) (setq yas-indent-line 'auto) - (setq yas-also-auto-indent-first-line nil) + (setq yas-also-auto-indent-first-line t) (setq yas-wrap-around-region nil) + ;; Only load personal snippets (setq yas-snippet-dirs `(,my-snippets-dir)) (setq yas-prompt-functions '(yas-ido-prompt yas-no-prompt)) - (yas-global-mode 1) (yas-reload-all) - (after "helm" - (add-to-list 'yas-dont-activate 'helm-alive-p)) + (after "helm" (add-to-list 'yas-dont-activate 'helm-alive-p)) ;; Exit snippets on ESC in normal mode (defadvice evil-force-normal-state (before evil-esc-quit-yasnippet activate) @@ -55,8 +56,7 @@ (1- (region-end))))))) ;; Previous hook causes yas-selected-text to persist between expansions. ;; This little hack gets around it. - (add-hook! 'yas-after-exit-snippet-hook - (setq-local yas-selected-text nil)) + (add-hook! 'yas-after-exit-snippet-hook (setq-local yas-selected-text nil)) (evil-define-operator my:snippets (beg end &optional name) :motion nil @@ -67,8 +67,7 @@ (if (and beg end) (yas-insert-snippet) (if name - (popwin:find-file (concat my-snippets-dir - (symbol-name major-mode) "/" name)) + (popwin:find-file (concat my-snippets-dir (symbol-name major-mode) "/" name)) (yas-visit-snippet-file)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/init/init-youtube.el b/init/init-youtube.el deleted file mode 100644 index 9b7b47bd0..000000000 --- a/init/init-youtube.el +++ /dev/null @@ -1,6 +0,0 @@ - -(require 'yt-stopwatch) - -(provide 'init-youtube) -;;; init-youtube.el ends here - diff --git a/init/my-bindings.el b/init/my-bindings.el index eee7e0a16..6fc4624fe 100644 --- a/init/my-bindings.el +++ b/init/my-bindings.el @@ -25,6 +25,17 @@ "M-d" 'dash-at-point "M-R" 'my:eval-buffer) +(when is-mac + ;; Restore text nav keys + (bind "" 'backward-word + "" 'forward-word + "" 'my.backward-kill-to-bol-and-indent + "A-SPC" 'just-one-space + "M-a" 'mark-whole-buffer + "M-c" 'evil-yank + "M-s" 'save-buffer + "M-v" 'yank)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Local keymaps ;; @@ -40,20 +51,20 @@ "," (λ (if (projectile-project-p) (helm-projectile-switch-to-buffer) (helm-buffers-list))) "<" 'helm-buffers-list "." 'ido-find-file - ">" 'my-ido-find-project-file + ">" (λ (let ((default-directory (project-root))) (ido-find-file))) "/" 'helm-projectile-find-file ";" 'helm-semantic-or-imenu - "M" 'helm-projectile-recentf ; recent PROJECT files "]" 'helm-etags-select "a" 'helm-projectile-find-other-file "E" 'my:init-files "g" 'git-gutter+-show-hunk "h" 'helm-apropos "m" 'helm-recentf + "M" 'helm-projectile-recentf ; recent PROJECT files "p" 'helm-projectile-switch-project "r" 'emr-show-refactor-menu ; init-dev.el "qq" 'evil-save-and-quit - "QQ" 'evil-quit-all + "QQ" (λ (my:kill-buffers t) (evil-quit-all)) "oo" 'my-open-with "of" (λ (my-open-with "Finder.app" default-directory)) @@ -69,7 +80,8 @@ ;; (bind my-localleader-map - "\\" 'neotree-toggle + "\\" 'my-neotree-toggle + "." 'my-neotree-find ";" 'linum-mode "=" 'toggle-transparency "E" 'evil-emacs-state @@ -85,22 +97,24 @@ (bind 'normal - "," 'my-leader-map - "\\" 'my-localleader-map + "," 'my-leader-map + "\\" 'my-localleader-map ;; behave like D and C; yank to end of line - "Y" (λ (evil-yank (point) (point-at-eol))) - "zx" 'my-kill-real-buffer - "ZX" 'bury-buffer - "]b" 'my-next-real-buffer - "[b" 'my-previous-real-buffer - "]w" 'wg-switch-to-workgroup-right - "[w" 'wg-switch-to-workgroup-left + "Y" (λ (evil-yank (point) (point-at-eol))) + "zx" 'my-kill-real-buffer + "ZX" 'bury-buffer + "]b" 'my-next-real-buffer + "[b" 'my-previous-real-buffer + "]w" 'wg-switch-to-workgroup-right + "[w" 'wg-switch-to-workgroup-left ;; Increment/decrement number under cursor - "g=" 'evil-numbers/inc-at-pt - "g-" 'evil-numbers/dec-at-pt - "gR" 'my:eval-buffer ; init-dev.el + "g=" 'evil-numbers/inc-at-pt + "g-" 'evil-numbers/dec-at-pt + "gR" 'my:eval-buffer ; init-dev.el + "gc" 'evil-commentary + "gy" 'evil-commentary-yank 'visual ", =" 'align-regexp @@ -117,6 +131,9 @@ 'normal "X" 'evil-exchange 'motion + "%" 'evilmi-jump-items + [tab] 'evilmi-jump-items ; alias for % + "]g" 'git-gutter+-next-hunk "[g" 'git-gutter+-previous-hunk @@ -148,6 +165,29 @@ "j" 'my--maybe-exit-insert-mode "C-g" 'evil-normal-state + ;; Company-mode + "C-SPC" 'company-complete-common + "C-x C-k" 'company-dictionary + "C-x C-f" 'company-files + "C-x C-]" 'company-etags + "C-x s" 'company-ispell + "C-x C-s" 'company-yasnippet + "C-x C-o" 'company-semantic + "C-x C-n" 'company-dabbrev-code + "C-x C-p" (λ (let ((company-selection-wrap-around t)) + (call-interactively 'company-dabbrev-code) + (company-select-previous-or-abort))) + + 'operator + "s" 'evil-surround-edit + "S" 'evil-Surround-edit + + 'visual + "z" 'evil-snipe-s + "Z" 'evil-snipe-S + + "S" 'evil-surround-region + ;; Rotate-text (see elisp/rotate-text.el) 'normal "!" 'rotate-word-at-point 'visual "!" 'rotate-region @@ -155,17 +195,21 @@ 'emacs [escape] 'evil-normal-state) -;; Enable TAB to do matchit -(bind 'motion evil-matchit-mode-map [tab] 'evilmi-jump-items) - (bind evil-window-map - ;; winner-mode: window layout undo/redo (see init-core.el) + ;; winner-mode: window layout undo/redo (see core.el) "u" 'winner-undo "C-u" 'winner-undo "C-r" 'winner-redo) +;; Real go-to-definition for elisp +(bind 'motion emacs-lisp-mode-map + "gd" (λ (let ((func (function-called-at-point))) + (if func (find-function func)))) + "gD" (λ (let ((func (function-called-at-point))) + (if func (find-function-other-window func))))) + ;; Peek at file from dired -(bind dired-mode-map "o" (λ (popwin:find-file (dired-get-file-for-visit)))) +;; (bind dired-mode-map "o" (λ (popwin:find-file (dired-get-file-for-visit)))) (after "help-mode" (bind 'normal help-mode-map @@ -177,26 +221,14 @@ (kbd "") 'evil-open-below (kbd "") 'evil-open-above) -(when is-mac - ;; Restore text nav keys - (bind "" 'backward-word - "" 'forward-word - "" 'my.backward-kill-to-bol-and-indent - "M-a" 'mark-whole-buffer - "M-c" 'evil-yank - "M-s" 'save-buffer - "M-v" 'yank)) - ;; Fix osx keymappings and then some -(use-package smart-forward - :config - (bind 'insert - "" 'my.move-to-bol - "" 'my.move-to-eol - "" 'beginning-of-buffer - "" 'end-of-buffer - "" 'smart-up - "" 'smart-down)) +(bind 'insert + "" 'my.move-to-bol + "" 'my.move-to-eol + "" 'beginning-of-buffer + "" 'end-of-buffer + "" 'smart-up + "" 'smart-down) ;; Line selection via linum (bind " " 'my-select-linum @@ -204,6 +236,9 @@ " " 'my-select-linum " " 'my-select-block) +(bind 'visual + "*" 'evil-visualstar/begin-search-forward + "#" 'evil-visualstar/begin-search-backward) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Keymap fixes ;; @@ -217,7 +252,7 @@ (bind 'insert "" 'my.dumb-indent) (bind 'insert "" 'indent-for-tab-command) -;; Except for lisp +;; No dumb-tab for lisp (bind 'insert lisp-mode-map [remap my.dumb-indent] 'indent-for-tab-command) (bind 'insert emacs-lisp-mode-map [remap my.dumb-indent] 'indent-for-tab-command) @@ -246,7 +281,25 @@ minibuffer-local-completion-map minibuffer-local-must-match-map minibuffer-local-isearch-map)) - (bind map "" 'keyboard-escape-quit)) + (bind map [escape] 'my--minibuffer-quit)) +(bind 'emacs [escape] 'my--minibuffer-quit) + +;; Redefine to get rid of that silly delete-other-windows nonsense +(defun keyboard-escape-quit () + (interactive) + (cond ((eq last-command 'mode-exited) nil) + ((region-active-p) + (deactivate-mark)) + ((> (minibuffer-depth) 0) + (abort-recursive-edit)) + (current-prefix-arg + nil) + ((> (recursion-depth) 0) + (exit-recursive-edit)) + (buffer-quit-function + (funcall buffer-quit-function)) + ((string-match "^ \\*" (buffer-name (current-buffer))) + (bury-buffer)))) (dolist (map (list evil-ex-search-keymap minibuffer-local-map)) (bind map "\C-w" 'evil-delete-backward-word)) diff --git a/init/my-commands.el b/init/my-commands.el index f26332b0b..900643e5c 100644 --- a/init/my-commands.el +++ b/init/my-commands.el @@ -25,6 +25,17 @@ (exmap "t" 'my:tmux-run) (exmap "tcd" 'my:tmux-chdir) +(exmap "a" 'helm-projectile-find-other-file) +(exmap "proj[ect]" 'helm-projectile-switch-project) +(exmap "ag" 'my:helm-ag-search) +(exmap "agr" 'my:helm-ag-regex-search) +(exmap "ag[cw]d" 'my:helm-ag-search-cwd) +(exmap "agr[cw]d" 'my:helm-ag-regex-search-cwd) +(exmap "sw[oop]" 'my:helm-swoop) +(exmap "rec[ent]" 'my:helm-recentf) +(exmap "snip[pets]" 'my:snippets) +(exmap "ref[actor]" 'emr-show-refactor-menu) + (after "flycheck" (exmap "er[rors]" (λ (flycheck-buffer) (flycheck-list-errors)))) @@ -33,22 +44,6 @@ (exmap "grevert" 'git-gutter+-revert-hunks) (exmap "gdiff" 'git-gutter+-show-hunk)) -(after "helm" - (exmap "a" 'helm-projectile-find-other-file) - (exmap "proj[ect]" 'helm-projectile-switch-project) - (exmap "ag" 'my:helm-ag-search) - (exmap "agr" 'my:helm-ag-regex-search) - (exmap "ag[cw]d" 'my:helm-ag-search-cwd) - (exmap "agr[cw]d" 'my:helm-ag-regex-search-cwd) - (exmap "sw[oop]" 'my:helm-swoop) - (exmap "rec[ent]" 'my:helm-recentf)) - -(after "yasnippet" - (exmap "snip[pets]" 'my:snippets)) - -(after "emr" - (exmap "ref[actor]" 'emr-show-refactor-menu)) - (after "re-builder" (exmap "re[gex]" 'my:regex)) diff --git a/init/my-settings.el b/init/my-settings.el index 53bedc716..a175fdc7a 100644 --- a/init/my-settings.el +++ b/init/my-settings.el @@ -1,44 +1,7 @@ -;;;; Modes 'n hooks ;;;;;;;;;;;;;;;;; -(associate-mode "/LICENSE[^/]*$" 'text-mode) -(associate-mode "zsh\\(env\\|rc\\)?$" 'sh-mode) -(associate-mode "z\\(profile\\|login\\|logout\\)?$" 'sh-mode) -(associate-mode "zsh/" 'sh-mode) -(associate-mode "\\.applescript$" 'applescript-mode) -(associate-mode "Cask$" 'emacs-lisp-mode) -(associate-mode "\\.el\\.gz$" 'emacs-lisp-mode) -(associate-mode "/Makefile$" 'makefile-gmake-mode) -(associate-mode "\\.plist$" 'nxml-mode) - -;; (setenv "SHELL" (s-trim (shell-command-to-string "which zsh"))) -(setenv "SHELL" "/usr/local/bin/zsh") -(setenv "EMACS" "1") - -;; show-paren faces -(set-face-background 'show-paren-match nil) -(set-face-foreground 'show-paren-match "orange") -(set-face-attribute 'show-paren-match nil :weight 'extra-bold) -(let ((face 'evil-search-highlight-persist-highlight-face)) - (set-face-attribute face nil :inherit 'isearch-lazy-highlight-face) - (set-face-foreground face nil) - (set-face-background face nil)) - (set-register ?. "~/.dotfiles/") (set-register ?d "~/Dropbox/Projects/") (set-register ?@ "~/.emacs.d/init.el") -(add-hook 'help-mode-hook 'visual-line-mode) -(add-hook 'before-save-hook 'delete-trailing-whitespace) - -;; Performance checks -(add-hook! 'find-file-hook - ;; If file is oversized... - (when (> (buffer-size) (* 1024 1024)) - (setq buffer-read-only t) - (buffer-disable-undo) - (fundamental-mode) - (visual-line-mode))) - - ;;;; Keymap Fixes ;;;;;;;;;;;;;;;;;;;;;; ;; Implements some helpful keymappings for emacs sub-modes (add-hook! 'ido-setup-hook @@ -53,8 +16,7 @@ (dolist (map (list evil-ex-search-keymap minibuffer-local-map)) (bind map "\C-w" 'evil-delete-backward-word)) -(bind minibuffer-local-map - "\C-u" 'evil-delete-whole-line) +(bind minibuffer-local-map "\C-u" 'evil-delete-whole-line) ;; Redefine to get rid of that silly delete-other-windows nonsense ;; (defun keyboard-escape-quit () diff --git a/themes/v0-theme.el b/themes/v0-theme.el index 07ef054b7..60d79f55d 100644 --- a/themes/v0-theme.el +++ b/themes/v0-theme.el @@ -119,6 +119,8 @@ `(rainbow-delimiters-unmatched-face ((t (:inherit 'error)))) `(rainbow-delimiters-depth-1-face ((t (:foreground "#CCCCCC" :weight bold :bold t)))) + `(linum-highlight-face ((t (:background ,gutters-active)))) + ;; js2-mode ;; *****************************************************************************************