Merge branch 'narf'

* narf: (42 commits)
  makefile: Silence pull
  makefile: Generate autoloads on update
  Add private/cache
  Add file templates folderg
  Update evil-surround in Cask file
  Delegate compile defuns to scripts
  Cleanup
  Generate autoloads if missing
  Don't toggle fullscreen on new frame hook
  Add C-n/C-p keybindings for ido
  Remove temporary code
  Clean up and silence byte-compiler warnings
  Fix keybindings
  Clean up
  Add after-make-(window|console)-frame-hooks
  Update makefile and scripts
  Update readme
  Fix evil-org-mode keybindings
  Auto-compile elisp files & delete trailing whitespaces
  Add narf/is-compilable-p, fix narf:compile-(el|autoloads)
  ...
This commit is contained in:
Henrik Lissner 2015-06-20 22:59:25 +02:00
commit a42c869d1d
160 changed files with 4761 additions and 15599 deletions

3
.gitmodules vendored
View file

@ -13,3 +13,6 @@
[submodule "elisp/racer"]
path = elisp/racer
url = https://github.com/phildawes/racer
[submodule "private/snippets"]
path = private/snippets
url = git://github.com/hlissner/emacs-snippets.git

204
Cask
View file

@ -3,79 +3,84 @@
(source marmalade)
(source gnu)
;; Essentials
(depends-on "cask")
;; Core --- core/core.el
(depends-on "dash")
(depends-on "s")
(depends-on "f")
(depends-on "deferred")
(depends-on "fuzzy")
(depends-on "use-package")
(depends-on "smex")
(depends-on "pos-tip")
(depends-on "nlinum")
(depends-on "vim-empty-lines-mode")
(depends-on "hlinum" :git "https://github.com/tom-tan/hlinum-mode")
(depends-on "popwin")
(depends-on "help-fns+")
;; Themes
(depends-on "solarized-theme")
;; OSX
;; OSX --- core/core-os-osx.el
(depends-on "exec-path-from-shell")
(depends-on "dash-at-point")
(depends-on "applescript-mode")
;; Core
(depends-on "shut-up")
(depends-on "popwin")
(depends-on "saveplace")
;; Editing
;; UI --- core/core-ui.el
(depends-on "nlinum")
(depends-on "smart-mode-line")
(depends-on "dired+")
(depends-on "expand-region")
(depends-on "flycheck")
(depends-on "flyspell")
(depends-on "rainbow-delimiters")
(depends-on "smartparens")
(depends-on "yasnippet")
(depends-on "diff-hl")
(depends-on "ace-jump-mode")
(depends-on "ace-window")
(depends-on "ace-link")
(depends-on "pcre2el")
(depends-on "emr")
(depends-on "smart-forward")
(depends-on "anzu")
(depends-on "iedit")
(depends-on "quickrun")
(depends-on "goto-last-change")
;; Auto-completion
;; Evil --- core/core-evil.el
(depends-on "evil")
(depends-on "evil-anzu")
(depends-on "evil-commentary")
(depends-on "evil-exchange")
(depends-on "evil-iedit-state")
(depends-on "evil-indent-textobject")
(depends-on "evil-jumper")
(depends-on "evil-matchit")
(depends-on "evil-numbers")
(depends-on "evil-search-highlight-persist")
(depends-on "evil-snipe")
(depends-on "evil-space")
(depends-on "evil-surround")
(depends-on "evil-visualstar")
(depends-on "evil-plugins" :git "https://github.com/tarao/evil-plugins")
;; Editor --- core/core-editor.el
(depends-on "ace-jump-mode")
(depends-on "ace-link")
(depends-on "ace-window")
(depends-on "emr")
(depends-on "expand-region")
(depends-on "goto-last-change")
(depends-on "hl-todo" :git "https://github.com/tarsius/hl-todo")
(depends-on "rainbow-delimiters")
(depends-on "rotate-text" :git "https://github.com/debug-ito/rotate-text.el")
(depends-on "smart-forward")
(depends-on "smartparens")
(depends-on "smex")
;; Completion --- core/core-company.el
(depends-on "company")
(depends-on "company-c-headers")
(depends-on "company-cmake")
;; (depends-on "company-cmake")
(depends-on "company-tern")
(depends-on "company-anaconda")
(depends-on "company-inf-ruby")
(depends-on "company-statistics")
;; Eeeevil
(depends-on "evil")
(depends-on "evil-search-highlight-persist")
(depends-on "evil-commentary")
(depends-on "evil-matchit")
(depends-on "evil-numbers")
(depends-on "evil-exchange")
(depends-on "evil-visualstar")
(depends-on "evil-indent-textobject")
(depends-on "evil-jumper")
(depends-on "evil-iedit-state")
(depends-on "evil-anzu")
(depends-on "evil-snipe")
(depends-on "evil-surround")
(depends-on "evil-space")
;; Flycheck --- core/core-flycheck.el
(depends-on "flycheck")
(depends-on "flyspell")
;; Project management
;; Yasnippet --- core/core-yasnippet.el
(depends-on "yasnippet")
;; ...
;; Project --- core/core-project.el
(depends-on "flx-ido")
(depends-on "ido-ubiquitous")
(depends-on "ido-vertical-mode")
(depends-on "neotree" :git "https://github.com/jeffplang/emacs-neotree")
;; VCS --- core/core-vcs.el
(depends-on "diff-hl")
(depends-on "git-commit-mode")
(depends-on "git-rebase-mode")
(depends-on "gitconfig-mode")
(depends-on "gitignore-mode")
;; Helm -- core/core-helm.el
(depends-on "projectile")
(depends-on "helm")
(depends-on "helm-ag")
@ -84,70 +89,73 @@
(depends-on "helm-swoop")
(depends-on "helm-company")
(depends-on "helm-c-yasnippet")
(depends-on "neotree" :git "https://github.com/jeffplang/emacs-neotree")
(depends-on "ido-ubiquitous")
(depends-on "ido-vertical-mode")
(depends-on "flx-ido")
(depends-on "workgroups2")
(depends-on "xcscope")
;; Modes/mode-specific
(depends-on "org-plus-contrib")
(depends-on "org-opml" :git "https://github.com/edavis/org-opml")
;(depends-on "org-present")
;; Quickrun -- core/core-quickrun.el
(depends-on "quickrun")
;; Workgroups --- core/core-workgroups.el
(depends-on "workgroups2")
;;;; MODULES ;;;;;;;;;;;;;;;;;;;;;;;;;;;
(depends-on "rainbow-mode")
(depends-on "lua-mode")
;; Text
(depends-on "markdown-mode")
;; Webdev
(depends-on "haml-mode")
(depends-on "scss-mode")
(depends-on "sass-mode")
(depends-on "sws-mode")
(depends-on "json-mode")
(depends-on "yaml-mode")
(depends-on "markdown-mode")
(depends-on "glsl-mode")
(depends-on "groovy-mode")
(depends-on "swift-mode")
;; (depends-on "haxe-mode")
(depends-on "go-mode")
(depends-on "php-mode")
(depends-on "php-refactor-mode")
(depends-on "php-extras" :git "https://github.com/arnested/php-extras")
(depends-on "web-mode")
(depends-on "emmet-mode")
(depends-on "web-beautify")
(depends-on "tern")
;; JS
(depends-on "js2-mode")
(depends-on "js2-refactor")
(depends-on "tern")
;; Data
(depends-on "json-mode")
(depends-on "yaml-mode")
;; PHP
(depends-on "php-mode")
(depends-on "php-refactor-mode")
(depends-on "php-extras" :git "https://github.com/arnested/php-extras")
;; Ruby
(depends-on "enh-ruby-mode")
(depends-on "ruby-refactor")
(depends-on "rspec-mode")
(depends-on "inf-ruby")
(depends-on "robe")
;; Python
(depends-on "anaconda-mode")
(depends-on "omnisharp")
(depends-on "nose")
;; C#
(depends-on "csharp-mode")
(depends-on "omnisharp")
;; Java
(depends-on "emacs-eclim")
(depends-on "git-commit-mode")
(depends-on "git-rebase-mode")
(depends-on "gitconfig-mode")
(depends-on "gitignore-mode")
(depends-on "applescript-mode")
(depends-on "cmake-mode")
(depends-on "rust-mode")
(depends-on "d-mode")
(depends-on "groovy-mode")
(depends-on "android-mode")
;; C/C++
(depends-on "cmake-mode")
(depends-on "glsl-mode")
;; Sonic pi
(depends-on "osc")
(depends-on "sonic-pi" :git "https://github.com/repl-electric/sonic-pi.el")
;; Org
(depends-on "org-plus-contrib")
;;(depends-on "org-opml" :git "https://github.com/edavis/org-opml")
;; Other
(depends-on "go-mode")
(depends-on "swift-mode")
(depends-on "vimrc-mode")
;(depends-on "osh")
;(depends-on "sonic-pi" :git "https://github.com/repl-electric/sonic-pi.el")
;; (depends-on "haxe-mode")
;; (depends-on "rust-mode")
;; (depends-on "d-mode")
;; OTHER
;;(depends-on "shaderlab-mode" :git "https://bitbucket.org/bbbscarter/emacs-shaderlab-mode")
;;(depends-on "unityjs-mode" :git "https://github.com/naruse/EmacsUnityScript")

View file

@ -2,21 +2,19 @@ EMACS=emacs
all: update
update: install autoloads
cask update
install:
cask install
compile: clean
@cask exec ${EMACS} -f narf::byte-compile
update: autoloads
@git pull
@cask install
@cask update
clean: clean-extras
@rm -rf init.elc init/*.elc contrib/*.elc core/*.elc
@rm -f *.elc {core,modules,private,contrib}/*.elc {core,modules}/lib/*.elc
clean-extras:
@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 semanticdb
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"))'
@emacs --script scripts/generate-autoloads.el
compile: autoloads
@emacs --script scripts/byte-compile.el

View file

@ -1,15 +1,16 @@
# NARF Emacs
![Screenshot](screenshots/01.png)
![Screenshot](assets/screenshots/01.png)
> What we do every night, Pinky...
This is emacs for the stubborn vimmer, megalomaniac mouse and masochists alike.
It has been configured first: to emulate vim as best it can, and second: to
surpass it in any way possible; all this is built on top of
[Evil-mode](https://gitorious.org/evil/pages/Home), a vim emulator for emacs.
This is emacs for the stubborn vimmer, megalomaniac mouse and/or masochists
alike. It has been configured first: to emulate vim as best it can, and second:
to surpass it in any way possible. Narf uses
[Evil-mode](https://gitorious.org/evil/pages/Home), a vim-emulator for emacs, to
accomplish this.
This has only been tested on Emacs 24.5 on OSX, YMMV.
This has only seen testing on Emacs 24.5 in OSX. YMMV.
Any contributions or suggestions are welcome. The world won't take over itself.
@ -17,39 +18,35 @@ Any contributions or suggestions are welcome. The world won't take over itself.
`brew install cask`
Narf only requires [Cask](https://github.com/cask/cask) for managing its plugins
outside of emacs.
Narf uses [Cask](https://github.com/cask/cask) to manage plugins.
Also, though not strictly a requirement, I recommend the railwaycat/emacsmacport
build of emacs for OSX users, which you can get via homebrew:
build of emacs for OSX, which you can get via homebrew:
```sh
brew tap railwaycat/emacsmacport
brew install emacs-mac
brew install emacs-mac --HEAD --use-git-head --with-imagemagick --with-modern-icon
```
Lastly, a recursive clone will get everything you need:
A recursive clone of this repo will get you all you need.
```
git clone --recursive https://github.com/hlissner/emacs.d ~/.emacs.d
cd ~/.emacs.d
make # installs plugins via cask and generates autoloads
make compile # optional
make compile # optionally byte-compiles everything
```
## Features
A summary of what to expect can be found in these three files:
A summary of what to expect can be found in these four files:
```
./Cask # what packages are included
./init/narf-commands.el # what custom ex commands are defined
./init/narf-bindings.el # the keybindings
./Cask # what packages are used (and where)
./init.el # lists all core files and modules loaded
./private/my-bindings.el # the keybindings
./private/my-commands.el # what custom ex commands are defined
```
## Disclaimer
I am not an elisp guru. You have been warned.
## What about Windo-
![Windows, you say...](http://i3.kym-cdn.com/photos/images/newsfeed/000/549/293/504.gif)

View file

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Before After
Before After

View file

@ -1,65 +0,0 @@
;;; evil-ex-registers.el --- Command to paste from register in ex mode
;; Author: INA Lintaro <tarao.gnn at gmail.com>
;; URL: http://github.com/tarao/evil-plugins
;; Version: 0.1
;; Keywords: evil, plugin
;; This file is NOT part of GNU Emacs.
;;; License:
;;
;; This program 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 3 of the License, or
;; (at your option) any later version.
;;
;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'evil)
(eval-when-compile (require 'cl))
(defalias 'evil-orig-get-register (symbol-function 'evil-get-register))
(defun evil-get-spec-register (register &optional noerror)
"Return contents of REGISTER.
Signal an error if empty, unless NOERROR is non-nil.
Support some registers listed below in addition to
`evil-get-register'.
 the file name under the cursor
 the expanded file name under the cursor
 the word under the cursor
 the WORD under the cursor"
(cond
((or (= register ?\C-f) ; ^F the filename under the cursor
(= register ?\C-p)) ; ^P the expanded filename under the cursor
(let ((file (thing-at-point 'filename)))
(or (and file (= register ?\C-p) (expand-file-name file)) file)))
((or (= register ?\C-w) ; ^W the word under the cursor
(= register ?\C-a)) ; ^A the WORD under the cursor
(let* ((word (if (= register ?\C-a) #'evil-move-WORD #'evil-move-word))
(range (evil-inner-object-range nil nil nil nil word)))
(filter-buffer-substring (nth 0 range) (nth 1 range))))
(t (evil-orig-get-register register noerror))))
(defun evil-ex-paste-from-register (&optional register)
"Paste from REGISTER in command line."
(interactive)
(cl-flet ((evil-get-register (register &optional noerror)
(with-current-buffer evil-ex-current-buffer
(evil-get-spec-register register noerror))))
(if (called-interactively-p 'any)
(call-interactively #'evil-paste-from-register)
(evil-paste-from-register register))))
(provide 'evil-ex-registers)
;;; evil-ex-registers.el ends here

View file

@ -1,168 +0,0 @@
;;; flycheck-objc.el --- Flycheck for objc-mode. -*- lexical-binding: t; -*-
;; Copyright (C) 2014 Rafal Kowalski
;; Author: Rafal Kowalski <rafal.kowalski@mac.com>
;; Keywords: c, tools
;; This program 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 3 of the License, or
;; (at your option) any later version.
;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Flycheck settings for objc-mode.
;;; Code:
(require 'flycheck)
(flycheck-def-option-var flycheck-objc-clang-definitions nil objc-clang
"Additional preprocessor definitions for Clang.
The value of this variable is a list of strings, where each
string is an additional definition to pass to Clang, via the `-D'
option."
:type '(repeat (string :tag "Definition"))
:safe #'flycheck-string-list-p
:package-version '(flycheck . "0.15"))
(flycheck-def-option-var flycheck-objc-clang-include-path nil objc-clang
"A list of include directories for Clang.
Thae value of this variable is a list of strings, where each
string is a directory to add to the include path of Clang.
Relative paths are relative to the file being checked."
:type '(repeat (directory :tag "Include directory"))
:safe #'flycheck-string-list-p
:package-version '(flycheck . "0.14"))
(flycheck-def-option-var flycheck-objc-clang-framework-path nil objc-clang
"A list of frameworks for Clang.
Thae value of this variable is a list of strings, where each
string is a path to a frameworks directory to add to the frameworks
path of Clang. Relative paths are relative to the file being
checked."
:type '(repeat (directory :tag "Framework directory"))
:safe #'flycheck-string-list-p
:package-version '(flycheck . "0.14"))
(flycheck-def-option-var flycheck-objc-clang-includes nil objc-clang
"A list of additional include files for Clang.
The value of this variable is a list of strings, where each
string is a file to include before syntax checking. Relative
paths are relative to the file being checked."
:type '(repeat (file :tag "Include file"))
:safe #'flycheck-string-list-p
:package-version '(flycheck . "0.15"))
(flycheck-def-option-var flycheck-objc-clang-language-standard nil objc-clang
"The language standard to use in Clang.
The value of this variable is either a string denoting a language
standard, or nil, to use the default standard. When non-nil,
pass the language standard via the `-std' option."
:type '(choice (const :tag "Default standard" nil)
(string :tag "Language standard"))
:safe #'stringp
:package-version '(flycheck . "0.15"))
(flycheck-def-option-var flycheck-objc-clang-standard-library nil objc-clang
"The standard library to use for Clang.
The value of this variable is the name of a standard library as
string, or nil to use the default standard library.
Refer to the Clang manual at URL
`http://clang.llvm.org/docs/UsersManual.html' for more
information about the standard library."
:type '(choice (const "libc++")
(const :tag "GNU libstdc++" "libstdc++")
(string :tag "Library name"))
:safe #'stringp
:package-version '(flycheck . "0.15"))
(flycheck-def-option-var flycheck-objc-clang-archs nil objc-clang
"What architectures to use for clang.
When non-nil, set the architectures, via `-arch'."
:type '(repeat (file :tag "Architecture"))
:safe #'flycheck-string-list-p
:package-version '(flycheck . "0.15"))
(flycheck-def-option-var flycheck-objc-clang-sysroot nil objc-clang
"The system root to use in clang.
When non-nil,pass the language standard via the `-isysroot' option."
:type '(choice (const :tag "Default sysroot" nil)
(string :tag "Sysroot"))
:safe #'stringp
:package-version '(flycheck . "0.15"))
(flycheck-def-option-var flycheck-objc-clang-warnings '("all" "extra") objc-clang
"A list of additional warnings to enable in Clang.
The value of this variable is a list of strings, where each string
is the name of a warning category to enable. By default, all
recommended warnings and some extra warnings are enabled (as by
`-Wall' and `-Wextra' respectively).
Refer to the Clang manual at URL
`http://clang.llvm.org/docs/UsersManual.html' for more
information about warnings."
:type '(choice (const :tag "No additional warnings" nil)
(repeat :tag "Additional warnings"
(string :tag "Warning name")))
:safe #'flycheck-string-list-p
:package-version '(flycheck . "0.14"))
(flycheck-define-checker objc-clang
"A objc syntax checker using Clang.
See URL `http://clang.llvm.org/'."
:command ("clang"
"-fsyntax-only"
"-fno-color-diagnostics" ; Do not include color codes in output
"-fno-caret-diagnostics" ; Do not visually indicate the source
; location
"-fno-diagnostics-show-option" ; Do not show the corresponding
; warning group
(option "-isysroot" flycheck-objc-clang-sysroot)
(option-list "-arch" flycheck-objc-clang-archs)
(option "-std=" flycheck-objc-clang-language-standard)
(option "-stdlib=" flycheck-objc-clang-standard-library)
(option-list "-include" flycheck-objc-clang-includes)
(option-list "-W" flycheck-objc-clang-warnings s-prepend)
(option-list "-D" flycheck-objc-clang-definitions s-prepend)
(option-list "-I" flycheck-objc-clang-include-path)
(option-list "-F" flycheck-objc-clang-framework-path)
"-x" (eval
(cl-case major-mode
(objc-mode "objective-c")
(c-mode "c")))
;; We must stay in the same directory, to properly resolve #include
;; with quotes
source-inplace)
:error-patterns
((info line-start (file-name) ":" line ":" column
": note: " (message) line-end)
(warning line-start (file-name) ":" line ":" column
": warning: " (message) line-end)
(error line-start (file-name) ":" line ":" column
": " (or "fatal error" "error") ": " (message) line-end))
:modes (c-mode objc-mode)
:next-checkers ((warnings-only . objc-cppcheck)))
(provide 'flycheck-objc)
;;; objc-flycheck.el ends here

File diff suppressed because it is too large Load diff

View file

@ -1,252 +0,0 @@
;;; hide-mode-line.el --- Hides the mode line when there is only one frame and
;;; one buffer.
;;
;; Filename: hide-mode-line.el
;; Description: Hides the mode line when there is only one frame and one
;; buffer.
;; Author: Darren Embry
;; Copyright (c) 2008, 2011 Darren Embry
;; URL: http://webonastick.com/emacs-lisp/hide-mode-line.el
;; Keywords: mode line, writeroom
;; Compatibility: GNU Emacs 22.x, GNU Emacs 23.x
;;
;; Features that might be required by this library:
;;
;; None
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program 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.
;;
;; This program 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 this program; see the file COPYING. If not, write to the Free
;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
;; 02110-1301, USA.
;;
;; GPL 2 is available here:
;; http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Basically, automatically hides the mode-line if all of the following
;; are true:
;; - there is only one frame.
;; - there is only one window displayed in that frame.
;; - there is no minibuffer.
;; - the hide-mode-line variable is set.
;; and automatically shows the mode-line when any of the above isn't true.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; HOW TO USE
;;
;; Just put this file in your Emacs library directory and add this line to
;; your ~/.emacs:
;;
;; (autoload 'hide-mode-line "hide-mode-line" nil t)
;;
;; and use M-x hide-mode-line to toggle. Setting the hide-mode-line variable
;; won't automatically update the buffers' mode-line visibilities.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; MYSTERY BUG: every once in a while a few lines of text will be hidden
;; for some reason until you do a redraw-display. See if you can
;; reproduce this in a reliable fashion!
;;
;; MYSTERY BUG: not specific to this module, but... load linum, run M-x
;; linum-mode, then (setq mode-line-format nil) this triggers display
;; problems more reproducibly: sometimes the last line in the buffer
;; doesn't have the line number show up; and sometimes the cursor line
;; or the one after it doesn't have the line number show up. May be
;; related to above bug.
;;
;; CAVEAT: this code does not instruct your window system to make the
;; window full-screen.
;;
;; TODO: briefly show modeline for (example) 2 seconds when the following
;; happens:
;; - hide-mode-line is about to be activated
;; - you switch to another buffer
;;
;; TODO: Emacs 21 does not implement window-tree.
;;
;; BUG: if the hide-mode-line-window-configuration-change-hook function
;; displays a (message "moo") before it does its work, the screen is blanked
;; when you resize the window until you hit C-l.
;;
;; BUG: if a frame is closed and there is only one frame remaining, and
;; there is only one buffer in that window, mode lines are not hidden.
;;
;; SEE ALSO:
;; http://www.emacswiki.org/cgi-bin/wiki/LineNumbers
;; http://www.emacswiki.org/cgi-bin/wiki/WriteRoom
;;
;;=============================================================================
;;; History:
;;
;; 2008-01-31 r3090 initial version
;; 2008-02-01 r3097 explicitly defint default for
;; hide-mode-line-saved-mode-line-format
;; 2008-02-01 r3100 implement hide-mode-line-unaffected-by-minibuffer
;; 2008-02-01 r3101 more robust handling of case where mode-line-format is
;; nil before this code runs
;; 2008-02-01 r3106 disable in emacs21: window-tree function not available
;; 2011-03-08 r5835 fix emacsw32 bug
;;; Code:
(defvar hide-mode-line-saved-mode-line-format nil)
(make-variable-buffer-local 'hide-mode-line-saved-mode-line-format)
; TODO: add a hook of some kind when setting mode-line-format.
(defvar hide-mode-line nil)
; TODO: add a hook to run hide-mode-line-update when setting hide-mode-line.
; [or just use M-x hide-mode-line for now]
(defcustom hide-mode-line-unaffected-by-minibuffer nil
"If non-nil, a minibuffer by itself does not un-hide the modeline."
:group 'hide-mode-line
:type 'boolean)
(defun there-is-only-one-frame ()
"Return non-nil if there is only one frame, nil otherwise."
(let ((frames (frames-on-display-list)))
(if (= (length frames) 1)
(car frames)
nil)))
(defun there-is-only-one-window-in (frame)
"Return non-nil if there is only one window in the specified FRAME."
(let ((root (car (window-tree frame)))) ;FIXME: does not work with emacs21
(not (listp root))))
(defun there-is-only-one-frame-and-one-window ()
"Return non-nil if there is only one frame and one window."
(let ((the-only-frame (there-is-only-one-frame)))
(and the-only-frame
(or hide-mode-line-unaffected-by-minibuffer
(= (minibuffer-depth) 0))
(there-is-only-one-window-in the-only-frame))))
(defun hide-mode-line-in (buffer)
"Hide the specified BUFFER's mode line.
Saves the buffer's previous `mode-line-format' value if it's not
already hidden."
(with-current-buffer buffer
(if (and (not hide-mode-line-saved-mode-line-format)
;; minibuffers don't have modelines :p
(not (minibufferp buffer)))
(progn (setq hide-mode-line-saved-mode-line-format
(list mode-line-format))
(setq mode-line-format nil)
;; bug workaround
(redraw-modeline)))))
(defun show-mode-line-in (buffer)
"If the specified BUFFER's mode line is hidden, un-hides it.
Restores the buffer's `mode-line-format' from what was saved when
hide-mode-line-in was called."
(with-current-buffer buffer
(if (and hide-mode-line-saved-mode-line-format
;; minibuffers don't have modelines :p
(not (minibufferp buffer)))
(progn (setq mode-line-format
(car hide-mode-line-saved-mode-line-format))
(setq hide-mode-line-saved-mode-line-format nil)))))
(defun hide-mode-lines ()
"Hide all buffers' mode lines using hide-mode-line-in."
(mapcar 'hide-mode-line-in (buffer-list)))
(defun show-mode-lines ()
"Show all buffers' mode lines using show-mode-line-in."
(mapcar 'show-mode-line-in (buffer-list))
(if (equal window-system 'w32)
;; bug workaround
(redraw-display)))
(defun hide-mode-line-update ()
"Update the state of all buffers' mode lines.
This uses hide-mode-lines or show-mode-lines."
(if hide-mode-line
(if (there-is-only-one-frame-and-one-window)
(hide-mode-lines)
(show-mode-lines))
(show-mode-lines)))
(defun hide-mode-line-minibuffer-setup-hook ()
"Internal function."
(hide-mode-line-update))
(defun hide-mode-line-minibuffer-exit-hook ()
"Internal function."
(hide-mode-line-update))
(defun hide-mode-line-make-frame-function (new-frame)
"Internal function."
(hide-mode-line-update))
(defun hide-mode-line-delete-frame-function (dead-frame-walking)
"Internal function."
(hide-mode-line-update))
(defun hide-mode-line-window-configuration-change-hook ()
"Internal function."
(hide-mode-line-update))
(defun hide-mode-line-add-hooks ()
"Internal function."
(interactive)
(add-hook 'minibuffer-setup-hook
'hide-mode-line-minibuffer-setup-hook)
(add-hook 'minibuffer-exit-hook
'hide-mode-line-minibuffer-exit-hook)
(add-hook 'after-make-frame-functions
'hide-mode-line-make-frame-function)
(add-hook 'delete-frame-functions
'hide-mode-line-delete-frame-function)
(add-hook 'window-configuration-change-hook
'hide-mode-line-window-configuration-change-hook))
(defun hide-mode-line-remove-hooks ()
"Internal function."
(interactive)
(remove-hook 'minibuffer-setup-hook
'hide-mode-line-minibuffer-setup-hook)
(remove-hook 'minibuffer-exit-hook
'hide-mode-line-minibuffer-exit-hook)
(remove-hook 'after-make-frame-functions
'hide-mode-line-make-frame-function)
(remove-hook 'delete-frame-functions
'hide-mode-line-delete-frame-function)
(remove-hook 'window-configuration-change-hook
'hide-mode-line-window-configuration-change-hook))
;;;###autoload
(defun hide-mode-line ()
"Toggle the hide-mode-line functionality."
(interactive)
(if (functionp 'window-tree)
(progn
(if hide-mode-line
(hide-mode-line-remove-hooks)
(hide-mode-line-add-hooks))
(setq hide-mode-line (not hide-mode-line))
(hide-mode-line-update))
(error (concat "Your Emacs does not provide the window-tree function. "
"Please upgrade to GNU Emacs 22 "
"or to some other version of Emacs that provides it."))))
(provide 'hide-mode-line)
;;; hide-mode-line.el ends here

View file

@ -1,107 +0,0 @@
;;; hl-todo.el --- highlight TODO keywords
;; Copyright (C) 2013-2014 Jonas Bernoulli
;; Author: Jonas Bernoulli <jonas@bernoul.li>
;; Created: 20130310
;; Homepage: http://github.com/tarsius/hl-todo
;; Keywords: convenience
;; This file is not part of GNU Emacs.
;; This file 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 3, or (at your option)
;; any later version.
;; This file 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.
;; For a full copy of the GNU General Public License
;; see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Hightlight TODO keywords. There are many minor modes like it
;; but this one is mine. It also happens to be simpler than the
;; alternatives.
;; For now at least -- I might extend it. Or I might abandon it
;; in favor of one of the following -- so you might be better of
;; going straight for one of these:
;; - [[http://emacswiki.org/fic-ext-mode.el][fic-ext-mode]]
;; - [[https://github.com/lewang/fic-mode][fic-mode]]
;; - [[http://emacswiki.org/FixmeMode][fixme-mode]]
;; - [[https://github.com/rolandwalker/fixmee][fixmee]]
;; - see http://emacswiki.org/FixmeMode for more alternatives
;; If you like this you might also like [[https://github.com/tarsius/orglink][orglink]].
;;; Code:
(defgroup hl-todo nil
"Highlight TODO keywords in comments."
:group 'font-lock-extra-types)
(defface hl-todo
'((t (:bold t :foreground "#cc9393")))
"Face used to highlight TODO keywords."
:group 'hl-todo)
(defcustom hl-todo-activate-in-modes '(emacs-lisp-mode)
"Major modes in which `hl-todo-mode' should be activated.
This is used by `global-hl-todo-mode'."
:group 'hl-todo
:type '(repeat function))
(defvar hl-todo-keywords nil)
(defcustom hl-todo-keyword-faces
'(("\\(\\bTODO\\((.*)\\)?:?\\)" . "#cc9393")
("\\(\\bNOTE\\((.*)\\)?:?\\)" . "#d0bf8f")
("\\(\\bFIXME\\((.*)\\)?:?\\)" . "#cc9393"))
"Faces used to highlight specific TODO keywords."
:group 'hl-todo
:type '(repeat (cons (string :tag "Keyword")
(choice :tag "Face "
(string :tag "Color")
(sexp :tag "Face"))))
:set (lambda (symbol value)
(set-default symbol value)
(setq hl-todo-keywords
`((,(concat "\\_<\\("
(mapconcat 'car value "\\|")
"\\)\\_>")
(1 (hl-todo-get-face) t))))))
(defun hl-todo-get-face ()
(let ((f (cdr (assoc (match-string 1) hl-todo-keyword-faces))))
(if (stringp f) (list :inherit 'hl-todo :foreground f) f)))
;;;###autoload
(define-minor-mode hl-todo-mode
"Highlight TODO tags in comments."
:lighter ""
:group 'hl-todo
(if hl-todo-mode
(font-lock-add-keywords nil hl-todo-keywords 'append)
(font-lock-remove-keywords nil hl-todo-keywords))
(when (called-interactively-p 'any)
(font-lock-fontify-buffer)))
;;;###autoload
(define-globalized-minor-mode global-hl-todo-mode
hl-todo-mode turn-on-hl-todo-mode-if-desired)
(defun turn-on-hl-todo-mode-if-desired ()
(when (apply 'derived-mode-p hl-todo-activate-in-modes)
(hl-todo-mode 1)))
(provide 'hl-todo)
;; Local Variables:
;; indent-tabs-mode: nil
;; End:
;;; hl-todo.el ends here

View file

@ -1,195 +0,0 @@
;;; ruby-mode-indent-fix.el ---
;; this file is not part of Emacs
;; Copyright (C) 2012 Le Wang
;; Author: Le Wang
;; Maintainer: Le Wang
;; Description:
;; Author: Le Wang
;; Maintainer: Le Wang
;; Created: Sun Feb 26 23:27:17 2012 (+0800)
;; Version: 0.1
;; Last-Updated: Mon Mar 26 11:23:48 2012 (+0800)
;; By: Le Wang
;; Update #: 29
;; URL:
;; Keywords:
;; Compatibility:
;;; Installation:
;; (eval-after-load "ruby-mod" '(require 'ruby-mode-indent-fix))
;;
;;
;;; Commentary:
;; Fix some indentation issues with ruby-mode with advices.
;;
;; Based on work by Dmitry Gutov(dgutov)
;; - http://stackoverflow.com/a/7622971/903943 and
;; - https://gist.github.com/1274520
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program 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 3, or
;; (at your option) any later version.
;;
;; This program 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 this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Code:
(eval-when-compile (require 'cl))
(defvar ruby--paren-closings-regex
"[])}\"']"
"regex matching closing paren or string delimiter.")
;; We make this advice around to avoid unnecessary buffer modifications.
(defadvice ruby-indent-line (around fix-closing-paren activate)
"indent closing paren to line up properly.
i.e.
foo_function( {:a => 'foo',
:b => 'bar'
}
)
Note that the closing paren is vertically aligned with the opening paren.
note: `ruby-deep-indent-paren' has to be enabled for this to work."
(let ((column (current-column))
indent)
(when ruby-deep-indent-paren
(save-excursion
(back-to-indentation)
(let ((state (syntax-ppss)))
(when (and (or (memq (sp-get-pair (char-after)) ruby-deep-indent-paren)
(and (eq (char-after) ?\})
(eq 'brace (ruby--point-in-braced-proc))))
(not (zerop (car state))))
(goto-char (cadr state))
(setq indent (current-column))))))
(if indent
(indent-line-to indent)
ad-do-it)))
(defun ruby--indent-before-all-sexps ()
"
1. search backwards for a closing delimiter ON THIS LINE, then
find the matching opening
2. if found, recurse, else the point is at a place we don't need
to worry about sexps.
"
(if (re-search-backward ruby--paren-closings-regex (point-at-bol) t)
(let ((ppss (syntax-ppss))
beg)
(goto-char (match-beginning 0))
(cond ((setq beg (nth 1 ppss)) ; brace
(goto-char beg))
((nth 3 ppss) ; string
(goto-char (nth 8 ppss))))
(ruby--indent-before-all-sexps))))
(defun ruby--point-in-braced-proc ()
"returns 'proc if point is in braces where starting bracs is EOL or followed by arg-list
i.e.
arr.each { |foo|
// do stuff
}
or
1.times {
// do stuff
}
returns 'brace if point in brace
return nil otherwise
"
(save-excursion
(let ((ppss (syntax-ppss))
beg)
(cond ((nth 3 ppss) ; string
nil)
((setq beg (nth 1 ppss)) ; brace
(goto-char beg)
(if (looking-at-p "{[\t ]*\\(?:$\\||\\)")
'proc
(when (looking-at-p "{")
'brace)))))))
(defadvice ruby-indent-line (around line-up-args activate)
"indent new line after comma at EOL properly:
i.e.
foo_function a_param,
b_param,
c_param
Note that all params line up after the function.
"
(let (indent ppss)
(save-excursion
(back-to-indentation)
(skip-chars-backward " \t\n")
(setq ppss (syntax-ppss))
;; check for inside comment, string, or inside braces
(when (and (eq ?, (char-before))
(not (memq (syntax-ppss-context ppss) '(comment string)))
(zerop (car ppss)))
(ruby--indent-before-all-sexps)
(back-to-indentation)
(if (save-excursion
(skip-chars-backward " \t\n")
(eq (char-before) ?,))
(setq indent (current-column))
(skip-syntax-forward "w_.")
(skip-chars-forward " ")
;; if the first symbol on the line is followed, by a comma, then this
;; line must be a continuation
(setq indent (current-column)))))
(if indent
(indent-line-to indent)
ad-do-it)))
;; (defadvice ruby-indent-line (around indent-no-brace-args activate)
;; "indent new line after comma at EOL properly:
;; i.e.
;; foo_function a_param,
;; b_param,
;; c_param
;; Note that all params line up after the function."
;; (let ((res (ruby--point-in-braced-proc)))
;; (cond ((eq 'brace res)
;; (let ((ruby-deep-indent-paren '(?\[ ?\( ?\{ t)))
;; ad-do-it))
;; (t
;; ad-do-it))))
(provide 'ruby-mode-indent-fix)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; ruby-mode-indent-fix.el ends here

View file

@ -1,425 +0,0 @@
;;; shaderlab-mode-el -- Major mode for editing Shaderlab files
;; Author: Simon Carter <bbbscarter@gmail.com>
;; Created: 1 August 2011
;; Keywords: Shaderlab languages
;; Copyright (C) 2011 Simon Carter <bbbscarter@gmail.com>
;; This program 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 of
;; the License, or (at your option) any later version.
;; This program 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 this program; if not, write to the Free
;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
;; MA 02111-1307 USA
;;; Commentary:
;; Borrows heavily from cg-mode.el for syntax highlighting.
;; In addition, provides custom indentation, and works with other
;; shaderlab structures, such as material blocks, subshaders, etc.
;;; Code:
(defconst shaderlab-font-lock-keywords-1 nil
"Subdued level highlighting for shaderlab mode.")
(defconst shaderlab-font-lock-keywords-2 nil
"Medium level highlighting for Shaderlab mode.
See also `shaderlab-font-lock-extra-types'.")
(defconst shaderlab-font-lock-keywords-3 nil
"Gaudy level highlighting for Shaderlab mode.
See also `shaderlab-font-lock-extra-types'.")
;; taken largely from the c mode from font-lock.el
(let* ((shaderlab-keywords
(eval-when-compile
(regexp-opt '("break" "continue" "do" "else" "for" "if" "return"
"while"
"asm" "asm_fragment"
"technique" "pass" "compile"
"in" "out" "inout"
"typedef" "static" "const" "uniform" "packed"
"Shader" "Properties" "SubShader" "Pass"
"Material"
"Tags" "LOD" "Cull"
"CGPROGRAM" "ENDCG"
"Fallback"))))
(shaderlab-type-specs
(eval-when-compile
(regexp-opt '("struct" "interface"))))
(shaderlab-type-specs-depth
(regexp-opt-depth shaderlab-type-specs))
(shaderlab-type-names
`(mapconcat 'identity
(cons
,(eval-when-compile
(regexp-opt
'("void" "string"
"fragout" "fragout_float"
"sampler" "sampler1D" "sampler2D" "sampler3D"
"samplerCube" "samplerRECT"
"SurfaceOutput")))
'("\\(bool\\|double\\|c?float\\|fixed\\|half\\|c?int\\)\\([1234]\\(x[1234]\\)?\\)?"))
"\\|"))
(shaderlab-type-names-depth
`(regexp-opt-depth ,shaderlab-type-names))
(shaderlab-reserved-names
(eval-when-compile
(regexp-opt
;; reserved but not supported (Cg is UGLY!)
'("short" "dword" "long" "signed"
"auto" "catch" "char" "class" "column major"
"const_cast" "decl" "default" "delete"
"discard" "dynamic_cast" "emit" "enum" "explicit"
"extern" "friend" "get" "goto" "inline"
"long" "mutable" "namespace" "new" "operator"
"pixelfragment" "pixelshader" "private"
"protected" "public" "register" "reinterpret_cast"
"row_major" "sampler_state" "shared" "sizeof"
"static_cast" "template" "this" "throw"
"try" "typeid" "typename" "union" "using"
"virtual" "volatile" "__identifier"
"switch" "case" "default"))))
(shaderlab-reserved-names-depth
`(regexp-opt-depth ,shaderlab-reserved-names))
(shaderlab-bindings
(eval-when-compile
(regexp-opt
'("COLOR" "COLOR0" "COLOR1" "COLOR2" "COLOR3"
"POSITION" "BLENDWEIGHT" "NORMAL" "DIFFUSE"
"SPECULAR" "FOGCOORD" "PSIZE" "ATTR6" "TANGENT"
"TEXCOORD0" "TEXCOORD1" "TEXCOORD2" "TEXCOORD3"
"TEXCOORD4" "TEXCOORD5" "TEXCOORD6" "TEXCOORD7"
"HPOS" "PSIZ" "FOG" "FOGC" "COL0" "COL1" "BCOL0"))))
(shaderlab-bindings-depth
(regexp-opt-depth shaderlab-bindings))
(shaderlab-math-calls
(eval-when-compile
(regexp-opt
'(;; Mathmatical Functions
"abs" "acos" "all" "any" "asin" "atan" "atan2" "ceil" "clamp"
"cos" "cosh" "cross" "degrees" "determinant" "dot" "exp" "exp2"
"floor" "fmod" "frac" "frexp" "isfinite" "isinf" "isnan" "ldexp"
"lerp" "lit" "log" "log2" "log10" "max" "min" "modf" "mul" "noise"
"pow" "radians" "round" "rsqrt" "saturate" "sign" "sin" "sincos"
"sinh" "smoothstep" "step" "sqrt" "tan" "tanh" "transpose"
;; Geometric Functions
"distance" "faceforward" "length" "normalize" "reflect" "refract"
;; Texture Map Functions
"tex1D" "tex1Dproj" "tex2D" "tex2Dproj" "texRECT" "texRECTproj"
"tex3D" "tex3Dproj" "texCUBE texCUBEproj"
;; Derivitive Functions
"ddx" "ddy"
;; Debugging Function
"debug"
))))
(shaderlab-math-calls-depth
(regexp-opt-depth shaderlab-math-calls))
(shaderlab-preprocessor-directives
(eval-when-compile
(regexp-opt
'("define" "else" "endif" "if" "ifdef" "elif"
"ifndef" "include" "line" "pragma" "undef"))))
(shaderlab-preprocessor-directives-depth
(regexp-opt-depth shaderlab-preprocessor-directives)))
(setq shaderlab-font-lock-keywords-1
(list
;;
;; These are all anchored at the beginning of line for speed.
;;
;; Fontify function name definitions (GNU style; without type on line).
'("^\\(\\sw+\\)[ \t]*(" 1 font-lock-function-name-face)
;;
;'("\".*\"" . font-lock-string-face)
;; Fontify error directives.
'("^#[ \t]*error[ \t]+\\(.+\\)" 1 font-lock-warning-face prepend)
;;
;; Fontify filenames in #include <...> preprocessor directives as strings.
'("^#[ \t]*\\(import\\|include\\)[ \t]*\\(<[^>\"\n]*>?\\)"
2 font-lock-string-face)
;;
;; Fontify function macro names.
'("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face)
;;
;; Fontify symbol names in #if ... defined preprocessor directives.
'("^#[ \t]*\\(elif\\|if\\)\\>"
("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil
(1 font-lock-builtin-face) (2 font-lock-variable-name-face nil t)))
;;
;; Fontify otherwise as symbol names, and the preprocessor directive names.
(list
(concat "^#[ \t]*\\(" shaderlab-preprocessor-directives
"\\)\\>[ \t!]*\\(\\sw+\\)?")
'(1 font-lock-builtin-face)
(list (+ 2 shaderlab-preprocessor-directives-depth)
'font-lock-variable-name-face nil t))))
(setq shaderlab-font-lock-keywords-2
(append shaderlab-font-lock-keywords-1
(list
;;
;; Simple regexps for speed.
;;
;; Fontify all type names.
`(eval .
(cons (concat "\\<\\(" ,shaderlab-type-names "\\)\\>") 'font-lock-type-face))
;;
;; Fontify all bindings.
`(eval .
(cons (concat "\\<\\(" ,shaderlab-bindings "\\)\\>") 'font-lock-constant-face))
;;
;; Fontify all math calls.
`(eval .
(cons (concat "\\<\\(" ,shaderlab-math-calls "\\)\\>") 'font-lock-builtin-face))
;;
;; Fontify reserved but unimplemented keywords
`(eval .
(cons (concat "\\<\\(" ,shaderlab-reserved-names "\\)\\>") 'font-lock-warning-face))
;;
;; Fontify all builtin keywords (except case, default and goto; see below).
(concat "\\<\\(" shaderlab-keywords "\\|" shaderlab-type-specs "\\)\\>")
;;
;; Fontify case/goto keywords and targets, and case default/goto tags.
'("\\<\\(case\\|goto\\)\\>"
(1 font-lock-keyword-face)
("\\(-[0-9]+\\|\\sw+\\)"
;; Return limit of search.
(save-excursion (skip-chars-forward "^:\n") (point))
nil
(1 font-lock-constant-face nil t)))
;; Anders Lindgren <andersl@andersl.com> points out that it is quicker to
;; use MATCH-ANCHORED to effectively anchor the regexp on the left.
;; This must come after the one for keywords and targets.
'(":" ("^[ \t]*\\(\\sw+\\)[ \t]*:[ \t]*$"
(beginning-of-line) (end-of-line)
(1 font-lock-constant-face)))
)))
(setq shaderlab-font-lock-keywords-3
(append shaderlab-font-lock-keywords-2
;;
;; More complicated regexps for more complete highlighting for types.
;; We still have to fontify type specifiers individually, as C is so hairy.
(list
;;
;; Fontify builtin true and false constants
'("\\(true\\|false\\)" 1 font-lock-constant-face)
;;
;; Fontify all storage types, plus their items.
`(eval .
(list (concat "\\<\\(" ,shaderlab-type-names "\\)\\>"
"\\([ \t*&]+\\sw+\\>\\)*")
;; Fontify each declaration item.
(list 'font-lock-match-c-style-declaration-item-and-skip-to-next
;; Start with point after all type specifiers.
(list 'goto-char (list 'or
(list 'match-beginning
(+ ,shaderlab-type-names-depth 2))
'(match-end 1)))
;; Finish with point after first type specifier.
'(goto-char (match-end 1))
;; Fontify as a variable or function name.
'(1 (if (match-beginning 2)
font-lock-function-name-face
font-lock-variable-name-face)))))
;;
;; Fontify all storage specs and types, plus their items.
`(eval .
(list (concat "\\<\\(" ,shaderlab-type-specs "\\)\\>"
"[ \t]*\\(\\sw+\\)?")
(list 1 'font-lock-keyword-face)
(list ,(+ shaderlab-type-specs-depth 2) 'font-lock-type-face nil t)
(list 'font-lock-match-c-style-declaration-item-and-skip-to-next
nil
;; Finish with point after the variable name if
;; there is one.
`(if (match-end 2)
(goto-char (match-end 2)))
;; Fontify as a variable or function name.
'(1 (if (match-beginning 2)
font-lock-function-name-face
font-lock-variable-name-face) nil t))))
;;
;; Fontify structures, or typedef names, plus their items.
'("\\(}\\)[ \t*]*\\sw"
(font-lock-match-c-style-declaration-item-and-skip-to-next
(goto-char (match-end 1)) nil
(1 font-lock-type-face)))
;;
;; Fontify anything at beginning of line as a declaration or definition.
'("^\\(\\sw+\\)\\>\\([ \t*]+\\sw+\\>\\)*"
(1 font-lock-type-face)
(font-lock-match-c-style-declaration-item-and-skip-to-next
(goto-char (or (match-beginning 2) (match-end 1))) nil
(1 (if (match-beginning 2)
font-lock-function-name-face
font-lock-variable-name-face))))
)))
)
(defvar shaderlab-font-lock-keywords shaderlab-font-lock-keywords-3
"Default expressions to highlight in C mode.
See also `shaderlab-font-lock-extra-types'.")
(defvar shaderlab-mode-hook nil)
(defvar shaderlab-mode-map
(let ((shaderlab-mode-map (make-keymap)))
(define-key shaderlab-mode-map "\C-j" 'newline-and-indent)
shaderlab-mode-map)
"Keymap for SHADERLAB major mode")
(define-derived-mode shaderlab-mode text-mode "Shaderlab"
"Major mode for editing shaderlab shaders.
\\{shaderlab-mode-map}"
(set-syntax-table shaderlab-mode-syntax-table2)
(set (make-local-variable 'font-lock-defaults) '(shaderlab-font-lock-keywords))
;; Register our indentation function
(set (make-local-variable 'indent-line-function) 'shaderlab-indent-line)
)
(add-to-list 'auto-mode-alist '("\\.shader" . shaderlab-mode))
(defun shaderlab-indent-line ()
"Indent current line as SHADERLAB code."
(interactive)
(beginning-of-line)
(let ((regexp-closing-brace "^[^ \\W\n]*};?\\w*")
(regexp-opening-brace "^.*{\\w*$")
(regexp-empty-line "^[\t ]*\n"))
(let ((not-indented t) cur-indent)
(cond ((bobp)
;(message "bobp")
(setq cur-indent 0))
((looking-at regexp-closing-brace) ; If the line we are looking at is the end of a block, then decrease the indentation
;(message "Closing brace")
(save-excursion
;Look backwards for a non-whitespace block or an opening brace
(let ((looking-for-line t))
(while looking-for-line
(forward-line -1)
(cond ((looking-at regexp-opening-brace)
(setq cur-indent (current-indentation))
(setq looking-for-line nil))
((not (looking-at regexp-empty-line))
(setq cur-indent (- (current-indentation) tab-width))
(setq looking-for-line nil))))))
(when (< cur-indent 0) ; We can't indent past the left margin
(setq cur-indent 0)))
((looking-at "^\\W*#")
(message "preprocessor")
(setq cur-indent 0))
(t (save-excursion
(while not-indented ; Iterate backwards until we find an indentation hint
(forward-line -1)
(cond ((looking-at regexp-closing-brace) ; This hint indicates that we need to indent at the level of the END_ token
;(message "Found closing brace at %s" (what-line))
(setq cur-indent (current-indentation))
(setq not-indented nil))
((looking-at regexp-opening-brace) ; This hint indicates that we need to indent an extra level
;(message "Found opening brace at %s" (what-line))
(setq cur-indent (+ (current-indentation) tab-width)) ; Do the actual indenting
(setq not-indented nil))
((bobp)
(setq not-indented nil)))))))
(if cur-indent
(progn
;(message "Indenting to %d" cur-indent)
(indent-line-to cur-indent))
;(message "not indenting!")
(indent-line-to 0))))) ; If we didn't see an indentation hint, then allow no indentation
(defvar shaderlab-mode-syntax-table
(let ((table (make-syntax-table)))
;; Populate the syntax TABLE
(modify-syntax-entry ?_ "_" table)
;(modify-syntax-entry ?_ "w" table)
(modify-syntax-entry ?\\ "\\" table)
(modify-syntax-entry ?+ "." table)
(modify-syntax-entry ?- "." table)
(modify-syntax-entry ?= "." table)
(modify-syntax-entry ?% "." table)
(modify-syntax-entry ?< "." table)
(modify-syntax-entry ?> "." table)
(modify-syntax-entry ?& "." table)
(modify-syntax-entry ?| "." table)
(modify-syntax-entry ?\' "\"" table)
;; Set up block and line oriented comments. The new C standard
;; mandates both comment styles even in C, so since all languages
;; now require dual comments, we make this the default.
;;(cond
;; Emacs 22 and higher do nothing
;; ((>= emacs-major-version 22))
;; XEmacs 19 & 20
;; ((memq '8-bit c-emacs-features)
;; (modify-syntax-entry ?/ ". 1456" table)
;; (modify-syntax-entry ?* ". 23" table))
;; Emacs 19 & 20
;; ((memq '1-bit c-emacs-features)
;; (modify-syntax-entry ?/ ". 124b" table)
;; (modify-syntax-entry ?* ". 23" table))
;; incompatible
;; (t (error "Shaderlab Mode is incompatible with this version of Emacs"))
;; )
(modify-syntax-entry ?\n "> b" table)
;; Give CR the same syntax as newline, for selective-display
(modify-syntax-entry ?\^m "> b" table)
table)
"Syntax table for shaderlab-mode")
(provide 'shaderlab-mode)
(defun shaderlab-populate-syntax-table (table)
"Populate the given syntax table as necessary for a C-like language.
This includes setting ' and \" as string delimiters, and setting up
the comment syntax to handle both line style \"//\" and block style
\"/*\" \"*/\" comments."
(modify-syntax-entry ?_ "w" table)
;(modify-syntax-entry ?_ "_" table)
(modify-syntax-entry ?\\ "\\" table)
(modify-syntax-entry ?+ "." table)
(modify-syntax-entry ?- "." table)
(modify-syntax-entry ?= "." table)
(modify-syntax-entry ?% "." table)
(modify-syntax-entry ?< "." table)
(modify-syntax-entry ?> "." table)
(modify-syntax-entry ?& "." table)
(modify-syntax-entry ?| "." table)
(modify-syntax-entry ?\' "\"" table)
(modify-syntax-entry ?\240 "." table)
;; Set up block and line oriented comments. The new C
;; standard mandates both comment styles even in C, so since
;; all languages now require dual comments, we make this the
;; default.
(modify-syntax-entry ?/ ". 124b" table)
(modify-syntax-entry ?* ". 23" table)
(modify-syntax-entry ?\n "> b" table)
;; Give CR the same syntax as newline, for selective-display
(modify-syntax-entry ?\^m "> b" table)
table)
(defvar shaderlab-mode-syntax-table2
(let ((shaderlab-mode-syntax-table2 (shaderlab-populate-syntax-table (make-syntax-table))))
shaderlab-mode-syntax-table2)
"Syntax table for shaderlab-mode")
;;; shaderlab-mode.el ends here

View file

@ -1,532 +0,0 @@
;;; autoloads.el --- automatically extracted autoloads
;;
;;; Code:
;;;### (autoloads nil "../contrib/goto-last-change" "../contrib/goto-last-change.el"
;;;;;; (21865 37510 0 0))
;;; Generated autoloads from ../contrib/goto-last-change.el
(autoload 'goto-last-change "../contrib/goto-last-change" "\
Go to the point where the last edit was made in the current buffer.
Repeat the command to go to the second last edit, etc.
To go back to more recent edit, the reverse of this command, use \\[goto-last-change-reverse]
or precede this command with \\[universal-argument] - (minus).
It does not go to the same point twice even if there has been many edits
there. I call the minimal distance between distinguishable edits \"span\".
Set variable `glc-default-span' to control how close is \"the same point\".
Default span is 8.
The span can be changed temporarily with \\[universal-argument] right before \\[goto-last-change]:
\\[universal-argument] <NUMBER> set current span to that number,
\\[universal-argument] (no number) multiplies span by 4, starting with default.
The so set span remains until it is changed again with \\[universal-argument], or the consecutive
repetition of this command is ended by any other command.
When span is zero (i.e. \\[universal-argument] 0) subsequent \\[goto-last-change] visits each and
every point of edit and a message shows what change was made there.
In this case it may go to the same point twice.
This command uses undo information. If undo is disabled, so is this command.
At times, when undo information becomes too large, the oldest information is
discarded. See variable `undo-limit'.
\(fn ARG)" t nil)
(autoload 'goto-last-change-reverse "../contrib/goto-last-change" "\
Go back to more recent changes after \\[goto-last-change] have been used.
See `goto-last-change' for use of prefix argument.
\(fn ARG)" t nil)
;;;***
;;;### (autoloads nil "../contrib/help-fns+" "../contrib/help-fns+.el"
;;;;;; (21631 21029 0 0))
;;; Generated autoloads from ../contrib/help-fns+.el
(autoload 'describe-command "../contrib/help-fns+" "\
Describe an Emacs command (interactive function).
Equivalent to using a prefix arg with `describe-function'.
If you use Icicles then in Icicle mode keys bound to the commands are
shown next to them in `*Completions*. You can toggle this keys
display on/off using `C-x C-a'.
\(fn FUNCTION)" t nil)
(autoload 'describe-option "../contrib/help-fns+" "\
Describe an Emacs user variable (option).
Same as using a prefix arg with `describe-variable'.
\(fn VARIABLE &optional BUFFER)" t nil)
(autoload 'describe-option-of-type "../contrib/help-fns+" "\
Describe an Emacs user OPTION (variable) of a given `defcustom' TYPE.
A prefix argument determines the type-checking behavior:
- None: OPTION is defined with TYPE or a subtype of TYPE.
- Plain `C-u': OPTION is defined with TYPE or a subtype of TYPE,
or its current value is compatible with TYPE.
- Negative: OPTION is defined with TYPE (exact match).
- Non-negative: OPTION is defined with TYPE (exact match),
or its current value is compatible with TYPE.
If TYPE is nil (default value) then *all* `defcustom' variables are
potential candidates. That is different from using `describe-option',
because `describe-option' includes user-variable candidates not
defined with `defcustom' (with `*'-prefixed doc strings).
\(fn TYPE OPTION)" t nil)
(autoload 'describe-file "../contrib/help-fns+" "\
Describe the file named FILENAME.
If FILENAME is nil, describe current directory (`default-directory').
Starting with Emacs 22, if the file is an image file then:
* Show a thumbnail of the image as well.
* If you have command-line tool `exiftool' installed and in your
`$PATH' or `exec-path', then show EXIF data (metadata) about the
image. See standard Emacs library `image-dired.el' for more
information about `exiftool'.
If FILENAME is the name of an autofile bookmark and you use library
`Bookmark+', then show also the bookmark information (tags etc.). In
this case, a prefix arg shows the internal form of the bookmark.
In Lisp code:
Non-nil optional arg INTERNAL-FORM-P shows the internal form.
Non-nil optional arg NO-ERROR-P prints an error message but does not
raise an error.
\(fn FILENAME &optional INTERNAL-FORM-P NO-ERROR-P)" t nil)
;;;***
;;;### (autoloads nil "../contrib/hide-mode-line" "../contrib/hide-mode-line.el"
;;;;;; (21641 7940 0 0))
;;; Generated autoloads from ../contrib/hide-mode-line.el
(autoload 'hide-mode-line "../contrib/hide-mode-line" "\
Toggle the hide-mode-line functionality.
\(fn)" t nil)
;;;***
;;;### (autoloads nil "../contrib/hl-todo" "../contrib/hl-todo.el"
;;;;;; (21835 1957 0 0))
;;; Generated autoloads from ../contrib/hl-todo.el
(autoload 'hl-todo-mode "../contrib/hl-todo" "\
Highlight TODO tags in comments.
\(fn &optional ARG)" t nil)
(defvar global-hl-todo-mode nil "\
Non-nil if Global-Hl-Todo mode is enabled.
See the command `global-hl-todo-mode' for a description of this minor mode.
Setting this variable directly does not take effect;
either customize it (see the info node `Easy Customization')
or call the function `global-hl-todo-mode'.")
(custom-autoload 'global-hl-todo-mode "../contrib/hl-todo" nil)
(autoload 'global-hl-todo-mode "../contrib/hl-todo" "\
Toggle Hl-Todo mode in all buffers.
With prefix ARG, enable Global-Hl-Todo mode if ARG is positive;
otherwise, disable it. If called from Lisp, enable the mode if
ARG is omitted or nil.
Hl-Todo mode is enabled in all buffers where
`turn-on-hl-todo-mode-if-desired' would do it.
See `hl-todo-mode' for more information on Hl-Todo mode.
\(fn &optional ARG)" t nil)
;;;***
;;;### (autoloads nil "../contrib/rotate-text" "../contrib/rotate-text.el"
;;;;;; (21631 59390 0 0))
;;; Generated autoloads from ../contrib/rotate-text.el
(autoload 'rotate-region "../contrib/rotate-text" "\
Rotate all matches in `rotate-text-rotations' between point and mark.
\(fn BEG END)" t nil)
(autoload 'rotate-word-at-point "../contrib/rotate-text" "\
Rotate word at point based on sets in `rotate-text-rotations'.
\(fn)" t nil)
;;;***
;;;### (autoloads nil "defuns-buffers" "defuns-buffers.el" (21869
;;;;;; 43589 0 0))
;;; Generated autoloads from defuns-buffers.el
(autoload 'narf:narrow-to-region-indirect "defuns-buffers" "\
Restrict editing in this buffer to the current region, indirectly.
\(fn START END)" t nil)
(autoload 'narf:widen "defuns-buffers" "\
\(fn)" t nil)
(autoload 'narf:set-region-read-only "defuns-buffers" "\
See http://stackoverflow.com/questions/7410125
\(fn BEGIN END)" nil nil)
(autoload 'narf:set-region-writeable "defuns-buffers" "\
See http://stackoverflow.com/questions/7410125
\(fn BEGIN END)" nil nil)
(autoload 'narf/living-buffer-list "defuns-buffers" "\
\(fn &optional BUFFER-LIST)" nil nil)
(autoload 'narf/add-throwaway-buffer "defuns-buffers" "\
\(fn REGEXP)" nil nil)
(autoload 'narf:cleanup-buffers "defuns-buffers" "\
Kill left-over temporary, dired or buried special buffers
\(fn)" t nil)
(autoload 'narf:cleanup-processes "defuns-buffers" "\
\(fn)" t nil)
(autoload 'narf:kill-matching-buffers "defuns-buffers" "\
\(fn REGEXP &optional BUFFER-LIST)" t nil)
(autoload 'narf:next-real-buffer "defuns-buffers" "\
Switch to the next buffer and avoid special buffers.
\(fn)" t nil)
(autoload 'narf:previous-real-buffer "defuns-buffers" "\
Switch to the previous buffer and avoid special buffers.
\(fn)" t nil)
(autoload 'narf:kill-real-buffer "defuns-buffers" "\
Kill buffer (but only bury scratch buffer)
\(fn)" t nil)
(autoload 'narf::save-session "defuns-buffers")
(autoload 'narf::load-session "defuns-buffers")
(autoload 'narf::new-workgroup "defuns-buffers")
(autoload 'narf::rename-workgroup "defuns-buffers")
(autoload 'narf::rename-this-file "defuns-buffers")
(autoload 'narf::delete-this-file "defuns-buffers")
(autoload 'narf::create-file "defuns-buffers")
(autoload 'narf::scratch-buffer "defuns-buffers")
(autoload 'narf::kill-buried-buffers "defuns-buffers")
(autoload 'narf::kill-buffers "defuns-buffers")
(autoload 'narf::cd "defuns-buffers")
;;;***
;;;### (autoloads nil "defuns-code" "defuns-code.el" (21871 23781
;;;;;; 0 0))
;;; Generated autoloads from defuns-code.el
(autoload 'narf/set-build-command "defuns-code" "\
\(fn COMMAND &optional FILE)" nil nil)
(autoload 'narf::build "defuns-code")
(autoload 'narf::eval "defuns-code")
(autoload 'narf::eval-region "defuns-code")
(autoload 'narf::eval-buffer "defuns-code")
(autoload 'narf::eval-region-and-replace "defuns-code")
(autoload 'narf/get-interpreter "defuns-code" "\
\(fn)" nil nil)
;;;***
;;;### (autoloads nil "defuns-debug" "defuns-debug.el" (21867 64619
;;;;;; 0 0))
;;; Generated autoloads from defuns-debug.el
(autoload 'what-face "defuns-debug" "\
Tells you the name of the face (point) is on.
\(fn POS)" t nil)
(autoload 'what-col "defuns-debug" "\
\(fn)" t nil)
(autoload 'what-bindings "defuns-debug" "\
\(fn KEY)" nil nil)
(autoload 'narf::echo "defuns-debug")
;;;***
;;;### (autoloads nil "defuns-edit" "defuns-edit.el" (21869 43444
;;;;;; 0 0))
;;; Generated autoloads from defuns-edit.el
(autoload 'narf:replace-ms-word-chars "defuns-edit" "\
Replace smart quotes and other MS Word verbiage into plain text
\(fn BEG END)" t nil)
(autoload 'narf:replace-email2mailto "defuns-edit" "\
Email address with mailto link
\(fn BEG END)" t nil)
(autoload 'narf:replace-url2anchor "defuns-edit" "\
Link with anchor
\(fn BEG END)" t nil)
(autoload 'narf:goto-line "defuns-edit" "\
\(fn)" t nil)
(autoload 'narf::align "defuns-edit")
(autoload 'narf::retab "defuns-edit")
(autoload 'narf::narrow-indirect-or-widen "defuns-edit")
(autoload 'narf:toggle-delete-trailing-whitespace "defuns-edit" "\
\(fn)" t nil)
;;;***
;;;### (autoloads nil "defuns-extern" "defuns-extern.el" (21869 43359
;;;;;; 0 0))
;;; Generated autoloads from defuns-extern.el
(autoload 'narf/tmux-send "defuns-extern" "\
\(fn COMMAND)" nil nil)
(autoload 'narf::tmux-run "defuns-extern")
(autoload 'narf::tmux-chdir "defuns-extern")
;;;***
;;;### (autoloads nil "defuns-mouse" "defuns-mouse.el" (21865 57645
;;;;;; 0 0))
;;; Generated autoloads from defuns-mouse.el
(autoload 'narf/mouse-line-at-click "defuns-mouse" "\
Determine the line number at click
\(fn)" nil nil)
(autoload 'narf/mouse-select-line "defuns-mouse" "\
Set point as *linum-mdown-line*
\(fn EVENT)" t nil)
(autoload 'narf/mouse-select-block "defuns-mouse" "\
Select the current block of text between blank lines.
\(fn)" t nil)
;;;***
;;;### (autoloads nil "defuns-org" "defuns-org.el" (21869 43512 0
;;;;;; 0))
;;; Generated autoloads from defuns-org.el
(autoload 'narf/project-org-filename "defuns-org" "\
\(fn CAT)" t nil)
(autoload 'narf--org-in-list-p "defuns-org" "\
\(fn)" nil nil)
(autoload 'narf/org-insert-item-after "defuns-org" "\
Inserts a new heading or item, depending on the context.
\(fn)" t nil)
(autoload 'narf/org-insert-item-before "defuns-org" "\
Inserts a new heading or item, depending on the context.
\(fn)" t nil)
(autoload 'narf/org-toggle-checkbox "defuns-org" "\
\(fn)" t nil)
(autoload 'narf/org-surround "defuns-org" "\
\(fn DELIM)" nil nil)
(autoload 'narf::org-insert-image-url "defuns-org")
(autoload 'narf::org-insert-image "defuns-org")
;;;***
;;;### (autoloads nil "defuns-search" "defuns-search.el" (21869 45131
;;;;;; 0 0))
;;; Generated autoloads from defuns-search.el
(autoload 'narf:ido-find-file "defuns-search" "\
\(fn &optional DIR)" t nil)
(autoload 'narf:ido-find-file-other-window "defuns-search" "\
\(fn &optional DIR)" t nil)
(autoload 'narf:ido-find-project-file "defuns-search" "\
\(fn)" t nil)
(autoload 'narf::initfiles "defuns-search")
(autoload 'narf::notes "defuns-search")
(autoload 'narf::recentf "defuns-search")
(autoload 'narf::ag-search "defuns-search")
(autoload 'narf::ag-regex-search "defuns-search")
(autoload 'narf::ag-regex-cwd "defuns-search")
(autoload 'narf::ag-regex-search-cwd "defuns-search")
(autoload 'narf::swoop "defuns-search")
(autoload 'narf::snippets "defuns-search")
;;;***
;;;### (autoloads nil "defuns-text" "defuns-text.el" (21869 14495
;;;;;; 0 0))
;;; Generated autoloads from defuns-text.el
(autoload 'narf--point-at-bol-non-blank "defuns-text" "\
\(fn)" nil nil)
(autoload 'narf/surrounded-p "defuns-text" "\
\(fn)" nil nil)
(autoload 'narf:backward-kill-to-bol-and-indent "defuns-text" "\
Kill line to the first non-blank character. If invoked again
afterwards, kill line to column 1.
\(fn)" t nil)
(autoload 'narf:move-to-bol "defuns-text" "\
Moves cursor to the first non-blank character on the line. If
already there, move it to the true bol.
\(fn)" t nil)
(autoload 'narf:move-to-eol "defuns-text" "\
\(fn)" t nil)
(autoload 'narf:backward-delete-whitespace-to-column "defuns-text" "\
Delete back to the previous column of whitespace, or as much
whitespace as possible, or just one char if that's not possible.
\(fn)" t nil)
(autoload 'narf:dumb-indent "defuns-text" "\
Inserts a tab character (or spaces x tab-width). Checks if the
auto-complete window is open.
\(fn)" t nil)
(autoload 'narf:inflate-space-maybe "defuns-text" "\
Checks if point is surrounded by {} [] () delimiters and adds a
space on either side of the point if so.
\(fn)" t nil)
(autoload 'narf:deflate-space-maybe "defuns-text" "\
Checks if point is surrounded by {} [] () delimiters, and deletes
spaces on either side of the point if so. Resorts to
`narf:backward-delete-whitespace-to-column' otherwise.
\(fn)" t nil)
(autoload 'narf:newline-and-indent "defuns-text" "\
\(fn)" t nil)
;;;***
;;;### (autoloads nil "defuns-ui" "defuns-ui.el" (21865 64034 0 0))
;;; Generated autoloads from defuns-ui.el
(autoload 'narf:toggle-transparency "defuns-ui" "\
\(fn)" t nil)
(autoload 'narf:toggle-fullscreen "defuns-ui" "\
\(fn)" t nil)
(autoload 'narf:toggle-big-mode "defuns-ui" "\
\(fn)" t nil)
;;;***
;;;### (autoloads nil nil ("../contrib/evil-ex-registers.el" "../contrib/flycheck-objc.el"
;;;;;; "../contrib/ruby-mode-indent-fix.el" "../contrib/shaderlab-mode.el"
;;;;;; "../contrib/unityjs-mode.el" "../init/autoloads.el" "../init/init-auto-insert.el"
;;;;;; "../init/init-cc.el" "../init/init-cscope.el" "../init/init-csharp.el"
;;;;;; "../init/init-data.el" "../init/init-eshell.el" "../init/init-fly.el"
;;;;;; "../init/init-go.el" "../init/init-helm.el" "../init/init-ido.el"
;;;;;; "../init/init-java.el" "../init/init-js.el" "../init/init-lisp.el"
;;;;;; "../init/init-lua.el" "../init/init-org.el" "../init/init-php.el"
;;;;;; "../init/init-project.el" "../init/init-python.el" "../init/init-r.el"
;;;;;; "../init/init-regex.el" "../init/init-ruby.el" "../init/init-rust.el"
;;;;;; "../init/init-scss.el" "../init/init-sh.el" "../init/init-swift.el"
;;;;;; "../init/init-text.el" "../init/init-vc.el" "../init/init-vim.el"
;;;;;; "../init/init-web.el" "../init/init-workgroups.el" "../init/init-yasnippet.el"
;;;;;; "../init/narf-bindings.el" "../init/narf-commands.el" "../init/narf-settings.el"
;;;;;; "benchmark.el" "core-company.el" "core-editor.el" "core-evil.el"
;;;;;; "core-linux.el" "core-osx.el" "core-splash.el" "core-ui.el"
;;;;;; "core.el" "defuns.el" "startup.el") (21873 3804 549513 0))
;;;***
(provide 'autoloads)
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; autoloads.el ends here

78
core/core-auto-insert.el Normal file
View file

@ -0,0 +1,78 @@
;;; core-auto-insert.el --- file templates
(use-package autoinsert
:after yasnippet
:init
(setq auto-insert-query nil) ; Don't prompt before insertion
(setq auto-insert-alist '())
:config
(auto-insert-mode 1)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (add-template! "/\\.gitignore$" "%%" 'gitignore-mode)
;; C/C++
;; (add-template! "/Makefile$" "%%" 'makefile-gmake-mode)
;; (add-template! "/main\\.\\(cc\\|cpp\\)$" "%main.cpp%" 'c++-mode)
;; (add-template! "/win32_\\.\\(cc\\|cpp\\)$" "%winmain.cpp%" 'c++-mode)
;; (add-template! "\\.\\([Hh]\\|hpp\\)$" "%.h%" 'c++-mode)
;; (add-template! "\\.\\([Cc]\\|cc\\|cpp\\)$" "%.cpp%" 'c++-mode)
;; Shell scripts
;; (add-template! "\\.z?sh$" "%%" 'sh-mode)
;; Ruby
;; (add-template! "/spec_helper\\.rb$" "%helper%" 'rspec-mode t)
;; (add-template! "_spec\\.rb$" "%%" 'rspec-mode t)
;; (add-template! "/\\.rspec$" "%.rspec%" 'rspec-mode)
;; (add-template! "/Rakefile$" "%Rakefile%" 'ruby-mode t)
;; (add-template! "/Gemfile$" "%Gemfile%" 'ruby-mode t)
;; (add-template! "\\.gemspec$" "%.gemspec%" 'ruby-mode t)
;; (add-template! "/lib/.+\\.rb$" "%module%" 'ruby-mode t)
;; (add-template! "\\.rb$" "%%" 'ruby-mode)
;; ;; Python
;; (add-template! "tests?/test_.+\\.py$" "%%" 'nose-mode)
;; (add-template! "/setup\\.py$" "%setup%" 'python-mode)
;; (add-template! "\\.py$" "%%" 'python-mode)
;; ;; PHP
;; (add-template! "\\.class\\.php$" %class%" 'php-mode)
;; (add-template! "\\.php$" %%" 'php-mode)
;; ;; Markdown
;; (add-template! "\\.md$" "%%" 'markdown-mode)
;; (add-template! "/_posts/.+\\.md$" "%jekyll-post" 'markdown-mode)
;; (add-template! "/_layouts/.+\\.html$" "%jekyll-layout%" 'web-mode)
;; ;; Javascript
;; (add-template! "\\.lbaction/.+/Info.plist$" "%Info.plst%" 'lb6-mode)
;; (add-template! "\\.lbaction/.+/\\(default\\|suggestions\\)\\.js$" "%default.js%" 'lb6-mode)
;; (add-template! "/package\\.json$" "%package.json%" 'json-mode)
;; (add-template! "\\.\\(json\\|jshintrc\\)$" "%%" 'json-mode)
;; ;; SCSS
;; (add-template! "/master\\.scss$" "%master%" 'scss-mode)
;; (add-template! "/normalize\\.scss$" "%normalize%" 'scss-mode)
;; (add-template! "\\.scss$" "%%" 'scss-mode)
;; ;; HTML
;; (add-template! "\\.html$" "%%" 'web-mode)
;; Lua
;; (add-template! "\\.love/main\\.lua$" "%love.main%" 'lua-mode)
;; (add-template! "/conf\\.lua$" "@@love.conf" 'love-mode)
;; (add-template! "\\.lua$" "%%" 'lua-mode)
;; ;; Java
;; (add-template! "/src/.+/.+\\.java$" "@@" 'java-mode)
;; (add-template! "/build\\.gradle$" "@@gradle" 'android-mode)
;; ;; Elisp
(add-template! "\\.emacs\\.d/.+\\.el$" "@@initfile" 'emacs-lisp-mode)
;; (add-template! "\\.emacs\\.d/snippets/.+$" "@@" 'snippet-mode)
)
(provide 'core-auto-insert)
;;; core-auto-insert.el ends here

View file

@ -1,95 +1,51 @@
;;; core-company.el --- auto completion backend (Company-mode)
;; see lib/company-macros.el
(eval-when-compile (require 'core))
(use-package company
:diminish (company-mode . "=")
:commands global-company-mode
:init
(progn
(defvar company-dictionary-alist '())
(defvar company-dictionary-major-minor-modes '())
(defvar company-dictionary-dir (concat BASE-DIR "dict/")))
(after "abbrev" (diminish 'abbrev-mode "A"))
(after! abbrev (diminish 'abbrev-mode "A"))
(setq company-idle-delay nil
company-minimum-prefix-length 1
company-show-numbers nil
company-tooltip-limit 20
company-dabbrev-downcase nil
company-dabbrev-ignore-case nil
company-tooltip-align-annotations t
company-require-match 'never
company-global-modes '(not eshell-mode comint-mode org-mode erc-mode
message-mode help-mode)
company-frontends '(company-pseudo-tooltip-unless-just-one-frontend
company-echo-metadata-frontend
company-preview-if-just-one-frontend)
company-dict-dir (concat narf-private-dir "dict/"))
(add-hook! after-init 'global-company-mode)
:config
(progn
(global-company-mode +1)
(setq company-idle-delay nil
company-minimum-prefix-length 1
company-show-numbers nil
company-tooltip-limit 20
company-dabbrev-downcase nil
company-dabbrev-ignore-case nil
company-tooltip-align-annotations t
company-require-match 'never
company-global-modes
'(not eshell-mode comint-mode org-mode erc-mode message-mode help-mode))
;; (use-package company-dict :defer t)
;; (setq-default company-backends (append '(company-dict company-keywords) company-backends))
;; sort candidates by
(setq-default company-frontends
'(company-pseudo-tooltip-unless-just-one-frontend
company-echo-metadata-frontend
company-preview-if-just-one-frontend))
(setq-default company-backends (append '(company-keywords) company-backends))
;; TODO: Investigate yasnippet
(after! yasnippet
(setq-default company-backends (append '(company-capf company-yasnippet) company-backends)))
(add-to-list 'company-transformers 'company-sort-by-occurrence)
(progn ; Rewrite evil-complete to use company-dabbrev
(setq company-dabbrev-code-other-buffers t)
(setq company-dabbrev-code-buffers nil)
(setq evil-complete-next-func
(lambda(arg)
(call-interactively 'company-dabbrev)
(if (eq company-candidates-length 1)
(company-complete))))
(setq evil-complete-previous-func
(lambda (arg)
(let ((company-selection-wrap-around t))
(call-interactively 'company-dabbrev)
(if (eq company-candidates-length 1)
(company-complete)
(call-interactively 'company-select-previous))))))
(add-company-backend! nxml-mode (nxml yasnippet))
(add-company-backend! emacs-lisp-mode (elisp yasnippet))
(progn ; backends
(setq-default company-backends (append '(company-dictionary company-keywords) company-backends))
(add-to-list 'company-transformers 'company-sort-by-occurrence)
(after "yasnippet"
(setq-default company-backends (append '(company-capf company-yasnippet) company-backends)))
(defmacro narf/add-company-backend (hook backends)
"Register a company backend for a mode."
(let ((def-name (intern (format "narf--init-%s" hook))))
`(progn
(defun ,def-name ()
(set (make-local-variable 'company-backends)
(append '((,@backends company-semantic)) company-backends)))
(add-hook ',(intern (format "%s-hook" hook)) ',def-name))))
(narf/add-company-backend nxml-mode (company-nxml company-yasnippet))
(narf/add-company-backend emacs-lisp-mode (company-elisp company-yasnippet))
;; Simulates ac-source-dictionary (without global dictionary)
(defun company-dictionary (command &optional arg &rest ignored)
"`company-mode' back-end for user-provided dictionaries."
(interactive (list 'interactive))
(unless company-dictionary-alist
;; initialize dictionary
(dolist (file (f-files company-dictionary-dir))
(add-to-list 'company-dictionary-alist `(,(intern (f-base file)) ,@(s-split "\n" (f-read file) t)))))
(let ((dict (let ((minor-modes (-filter (lambda (mode) (when (boundp mode) (symbol-value mode)))
company-dictionary-major-minor-modes))
(dicts (cdr (assq major-mode company-dictionary-alist))))
(dolist (mode minor-modes)
(setq dicts (append dicts (cdr (assq mode company-dictionary-alist)))))
dicts)))
(cl-case command
(interactive (company-begin-backend 'company-dictionary))
(prefix (and dict (or (company-grab-symbol) 'stop)))
(candidates
(let ((completion-ignore-case nil)
(symbols dict))
(all-completions arg symbols)))
(sorted t)))))
(use-package company-statistics
:config
(shut-up
(setq company-statistics-file (expand-file-name "company-statistics-cache.el" TMP-DIR))
(company-statistics-mode)))))
;; Rewrite evil-complete to use company-dabbrev
(setq company-dabbrev-code-other-buffers t
company-dabbrev-code-buffers nil
evil-complete-next-func 'narf/company-evil-complete-next
evil-complete-previous-func 'narf/company-evil-complete-previous)
(shut-up!
(setq company-statistics-file (! (concat narf-temp-dir "company-statistics-cache.el")))
(require 'company-statistics)
(company-statistics-mode)))
(provide 'core-company)
;;; core-company.el ends here

266
core/core-defuns.el Normal file
View file

@ -0,0 +1,266 @@
(eval-when-compile (require 'cl-lib))
;; Backwards compatible `with-eval-after-load'
(unless (fboundp 'with-eval-after-load)
(defmacro with-eval-after-load (file &rest body)
`(eval-after-load ,file (lambda () ,@body))))
(defmacro λ (&rest body)
"A shortcut for: `(lambda () (interactive) ,@body)"
`(lambda () (interactive) ,@body))
(defmacro shut-up! (&rest body)
"Silence message output from code."
(declare (indent defun))
`(let (message-log-max) ,@body (message "")))
(defmacro after! (feature &rest forms)
"A smart wrapper around `with-eval-after-load', that supresses warnings
during compilation."
(declare (indent defun) (debug t))
`(,(if (or (not (boundp 'byte-compile-current-file))
(not byte-compile-current-file)
(if (symbolp feature)
(require feature nil :no-error)
(load feature :no-message :no-error)))
'progn
(message "after: cannot find %s" feature)
'with-no-warnings)
(with-eval-after-load ',feature ,@forms)))
(defmacro add-hook! (hook &rest func-or-forms)
"A convenience macro for `add-hook'.
HOOK can be one hook or a list of hooks. If the hook(s) are not quoted, -hook is
appended to them automatically. If they are quoted, they are used verbatim.
FUNC-OR-FORMS can be one quoted symbol, a list of quoted symbols, or a series of
forms. Forms will be wrapped in one lambda. A list of symbols will expand into a
series of add-hook calls.
Examples:
(add-hook! 'some-mode-hook 'enable-something)
=> (add-hook 'some-mode-hook 'enable-something)
(add-hook! some-mode '(enable-something and-another))
=> (add-hook 'some-mode-hook 'enable-something)
(add-hook 'some-mode-hook 'and-another)
(add-hook! '(one-mode-hook second-mode-hook) 'enable-something)
=> (add-hook 'one-mode-hook 'enable-something)
(add-hook 'second-mode-hook 'enable-something)
(add-hook! (one-mode second-mode) 'enable-something)
=> (add-hook 'one-mode-hook 'enable-something)
(add-hook 'second-mode-hook 'enable-something)
(add-hook! (one-mode second-mode) (setq v 5) (setq a 2))
=> (add-hook 'one-mode-hook (lambda () (setq v 5) (setq a 2)))
(add-hook 'second-mode-hook (lambda () (setq v 5) (setq a 2)))"
(declare (indent defun) (debug t))
(unless func-or-forms
(error "add-hook!: FUNC-OR-FORMS is empty"))
(let* ((val (car func-or-forms))
(quoted (eq (car-safe hook) 'quote))
(hook (if quoted (cadr hook) hook))
(funcs (if (eq (car-safe val) 'quote)
(if (cdr-safe (cadr val))
(cadr val)
(list (cadr val)))
(list func-or-forms)))
(forms '()))
(mapc
(lambda (f) (let ((func (cond ((symbolp f) `(quote ,f))
(t `(lambda () ,@func-or-forms)))))
(mapc
(lambda (h) (push `(add-hook ',(if quoted h (intern (format "%s-hook" h))) ,func) forms))
(if (listp hook) hook (list hook))))) funcs)
`(progn ,@forms)))
(cl-defmacro associate! (mode &key in
&key match
&key files
&allow-other-keys)
"Associate a major or minor mode to certain patterns and project files."
(declare (indent 1))
(let* ((minor-p (assoc mode minor-mode-alist)))
`(progn
(,@(when match
`(add-to-list ',(if minor-p 'narf-auto-minor-mode-alist 'auto-mode-alist)
(cons ,match ',mode))))
(,@(when files
(unless (or (listp files) (stringp files))
(user-error "associate! :files expects a string or list of strings"))
(let ((hook-name (intern (format "narf--init-mode-%s" mode))))
`(progn
(defun ,hook-name ()
(when (and (not ,mode)
(narf/project-has-files ,@(-list files)))
(,mode 1)))
,@(if (and in (listp in))
(mapcar (lambda (h) `(add-hook ',h ',hook-name))
(mapcar (lambda (m) (intern (format "%s-hook" m))) in))
`((add-hook 'find-file-hook ',hook-name))))))))))
(after! evil
;; Register keywords for proper indentation (see `bind!')
(put ':prefix 'lisp-indent-function 'defun)
(put ':map 'lisp-indent-function 'defun)
(put ':after 'lisp-indent-function 'defun)
(put ':when 'lisp-indent-function 'defun)
(put ':unless 'lisp-indent-function 'defun)
(defmacro bind! (&rest rest)
(let ((i 0)
key def
first-set
prefix
internal
(default-keymaps '(narf-mode-map))
(keymaps (if (boundp 'keymaps) keymaps))
(states (if (boundp 'states) states '()))
(forms '())
(state-map '(("n" . normal)
("v" . visual)
("i" . insert)
("e" . emacs)
("o" . operator)
("m" . motion)
("r" . replace)
("I" . iedit))))
(unless keymaps
(setq keymaps default-keymaps))
(while rest
(setq key (pop rest))
(add-to-list
'forms
(cond ((eq key '-) nil) ; skip this
((listp key) ; it's a sub exp
`((bind! ,@key)))
((keywordp key)
(pcase key
;; TODO: Data checks
(:prefix (setq prefix (kbd (pop rest)))
(if (= i 0) (setq first-set `(:prefix . ,prefix)))
nil)
(:map (setq keymaps (-list (pop rest)))
(if (= i 0) (setq first-set `(:map . ,keymaps)))
nil)
(:unset `((bind! ,(kbd (pop rest)) nil)))
(:after (prog1 `((after! ,(pop rest) (bind! ,@rest))) (setq rest '())))
(:when (prog1 `((if ,(pop rest) (bind! ,@rest))) (setq rest '())))
(:unless (prog1 `((if (not ,(pop rest)) (bind! ,@rest))) (setq rest '())))
(otherwise ; might be a state prefix
(mapc (lambda (letter)
(if (assoc letter state-map)
(add-to-list 'states (cdr (assoc letter state-map)))
(user-error "Invalid mode prefix %s in key %s" letter key)))
(s-split "" (substring (symbol-name key) 1) t))
(unless states
(user-error "Unrecognized keyword %s" key)) nil)))
;; It's a key-def pair
((or (stringp key)
(characterp key)
(vectorp key))
(when (stringp key)
(setq key (kbd key)))
(when prefix
(setq key (cond ((vectorp key) (vconcat prefix key))
(t (concat prefix key)))))
(unless (> (length rest) 0)
(user-error "Map has no definition for %s" key))
(setq def (pop rest))
(let ((first-key (car first-set))
(first-value (cdr first-set))
out-forms)
(dolist (keymap keymaps)
(if (not states)
;; (add-to-list 'out-forms `(define-key ,keymap ,key ,def) t)
(add-to-list 'out-forms `(evil-define-key nil ,keymap ,key ,def) t)
(dolist (state states)
(add-to-list 'out-forms `(evil-define-key ',state ,keymap ,key ,def) t))))
;; (add-to-list 'out-forms `(define-key (evil-get-auxiliary-keymap ,keymap ',state) ,key ,def) t))))
(setq prefix (if (eq first-key :prefix) first-value))
(setq keymaps (if (eq first-key :map) first-value default-keymaps))
(setq states '())
out-forms))
(t (user-error "Invalid key %s" key)))
t)
(cl-incf i))
`(progn ,@(apply #'nconc (delete nil (delete (list nil) forms)))))))
;; Hooks ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun narf|enable-comment-hard-wrap ()
(set (make-local-variable 'comment-auto-fill-only-comments) t)
(turn-on-auto-fill))
(defun narf|enable-hard-wrap ()
(turn-on-auto-fill))
(defun narf|enable-tab-width-2 ()
(setq tab-width 2 evil-shift-width 2))
(defun narf|enable-tab-width-4 ()
(setq tab-width 4 evil-shift-width 4))
(defun narf|disable-final-newline ()
(set (make-local-variable 'require-final-newline) nil))
(defun narf|enable-tabs ()
(setq indent-tabs-mode t))
(defun narf|disable-tabs ()
(setq indent-tabs-mode nil))
(defun narf|disable-delete-trailing-whitespace ()
(remove-hook 'before-save-hook 'delete-trailing-whitespace))
(defun narf|update-scratch-buffer-cwd () ; see core-editor.el
"Make sure scratch buffer is always 'in a project.'"
(let ((dir (narf/project-root)))
(with-current-buffer (get-buffer-create "*scratch*")
(cd dir))))
;;;; Global Defuns ;;;;;;;;;;;;;;;;;;;;;
(defun narf-minibuffer-quit ()
"Abort recursive edit. In Delete Selection mode, if the mark is
active, just deactivate it; then it takes a second \\[keyboard-quit]
to abort the minibuffer."
(interactive)
(let (message-log-max)
(if (and delete-selection-mode transient-mark-mode mark-active)
(setq deactivate-mark t)
(when (get-buffer "*Completions*")
(delete-windows-on "*Completions*"))
(abort-recursive-edit))))
(after! evil
(evil-define-command narf:exit-mode-maybe ()
"Exits insert/replace mode using jk without the momentary pause caused by
key-chord-define."
:repeat change
(interactive)
(let ((modified (buffer-modified-p)))
(call-interactively 'self-insert-command)
(let ((evt (read-event nil nil 0.4)))
(cond
((null evt) (message ""))
((and (integerp evt) (or (char-equal evt ?k)
(char-equal evt ?K)))
(if (evil-replace-state-p)
(evil-replace-backspace)
(delete-char -1))
(set-buffer-modified-p modified)
(push 'escape unread-command-events))
(t
(setq unread-command-events (append unread-command-events (list evt)))))))))
(provide 'core-defuns)
;;; core-defuns.el ends here

View file

@ -1,162 +1,231 @@
;;; Global editor behavior
;;; core-editor.el
;; see lib/editor-defuns.el
(electric-indent-mode -1)
(setq electric-indent-chars '(? ?: ?{))
(add-hook 'python-mode-hook 'electric-indent-local-mode)
(add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
(add-hook! 'eldoc-mode-hook (diminish 'eldoc-mode " ?"))
;;;; Editor behavior ;;;;;;;;;;;;;;;;
(setq-default
;; spaces instead of tabs
indent-tabs-mode nil
tab-always-indent t
tab-width 4
(setq-default fill-column 80)
(diminish 'auto-fill-function)
;; Sane scroll settings
(setq scroll-margin 5
scroll-conservatively 9999
scroll-preserve-screen-position t)
;; I'll use visual mode, kthxbai
(setq shift-select-mode nil)
require-final-newline t
delete-trailing-lines 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)
fill-column 80
(add-hook 'help-mode-hook 'visual-line-mode)
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(add-hook 'makefile-mode-hook 'narf|enable-tabs) ; Use normal tabs in makefiles
;; Sane scroll settings
scroll-margin 0
scroll-conservatively 9999
scroll-preserve-screen-position t
(after "isearch" (diminish 'isearch-mode))
shift-select-mode nil
;; Fix code folding
;; (defun narf|init-hs-minor-mode-maybe ()
;; (unless (bound-and-true-p hs-minor-mode)
;; (hs-minor-mode 1)
;; (diminish 'hs-minor-mode)))
;; (add-hook 'prog-mode-hook 'narf|init-hs-minor-mode-maybe)
whitespace-style '(trailing face tabs tab-mark)
whitespace-display-mappings
'((tab-mark ?\t [?| ?\t] [?\\ ?\t])
(newline-mark 10 [36 10]))
truncate-lines t ; do not soft-wrap lines
truncate-partial-width-windows nil)
;; Automatic minor modes ;;;;;;;;;;;
(defun narf|enable-minor-mode-maybe ()
"Check file name against `narf-auto-minor-mode-alist'."
(when buffer-file-name
(let ((name buffer-file-name)
(remote-id (file-remote-p buffer-file-name))
(alist narf-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 'narf|enable-minor-mode-maybe)
;; Modes 'n hooks ;;;;;;;;;;;;;;;;;;;
(associate! text-mode :match "/LICENSE[^/]*$")
(associate! sh-mode :match "/\\.?z\\(profile\\|login\\|logout\\|shrc\\|shenv\\)?$")
(associate! sh-mode :match "/\\.?zsh/")
(associate! applescript-mode :match "\\.applescript$")
(associate! emacs-lisp-mode :match "Cask$")
(associate! emacs-lisp-mode :match "\\.el\\.gz$")
(associate! makefile-gmake-mode :match "/Makefile$")
(associate! nxml-mode :match "\\.plist$")
(add-hook! help-mode 'visual-line-mode)
(add-hook! python-mode 'electric-indent-local-mode)
(add-hook! makefile-mode 'narf|enable-tabs) ; Use normal tabs in makefiles
(add-hook! before-save 'delete-trailing-whitespace)
(add-hook! eldoc-mode (diminish 'eldoc-mode " ?"))
;; Line wrapping
(add-hook! text-mode 'narf|enable-hard-wrap)
(add-hook! prog-mode 'narf|enable-comment-hard-wrap)
(add-hook! auto-fill-mode (diminish 'auto-fill-function))
;; If file is oversized...
(add-hook! find-file
(when (> (buffer-size) (* 1024 1024))
(setq buffer-read-only t)
(buffer-disable-undo)
(fundamental-mode)
(visual-line-mode)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package smartparens
:diminish smartparens-mode
;; (global-whitespace-mode 1) ; Show whitespace
(global-font-lock-mode t) ; Enable syntax highlighting for older emacs
(global-auto-revert-mode 1) ; revert buffers for changed files
(electric-indent-mode -1)
;; window config undo/redo
(winner-mode 1)
(add-hook! after-init (setq winner-boring-buffers narf-ignore-buffers))
;; Plugins ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package undo-tree
:defer t
:config
(progn
(use-package smartparens-config)
(smartparens-global-mode 1)
;; Shut up undo-tree's constant complaining: http://youtu.be/Z6woIRLnbmE
(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)))
(setq blink-matching-paren t
sp-autowrap-region nil ; let evil-surround handle this
sp-highlight-pair-overlay nil
sp-show-pair-delay 0)
(use-package ace-jump-mode
:functions (ace-jump-char-category ace-jump-do)
:commands (ace-jump-line-mode ace-jump-char-mode
ace-jump-word-mode ace-jump-two-chars-mode)
:init (setq ace-jump-mode-scope 'window
ace-jump-mode-gray-background t)
:config
(defun ace-jump-two-chars-mode (&optional query-char query-char-2)
"AceJump two chars mode"
(interactive)
;; 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))
(evil-half-cursor)
(setq query-char (or query-char (read-char ">")))
(setq query-char-2 (or query-char-2 (read-char (concat ">" (string query-char)))))
(if (eq (ace-jump-char-category query-char) 'other)
(error "[AceJump] Non-printable character"))
;; 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 '(c-mode c++-mode objc-mode java-mode) ; Support for generics
(sp-local-pair "<" ">" :when '(sp-point-after-word-p) :unless '(sp-point-before-same-p)))
(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"))))
;; others : digit , alpha, punc
(setq ace-jump-query-char query-char)
(setq ace-jump-current-mode 'ace-jump-char-mode)
(ace-jump-do (regexp-quote (concat (char-to-string query-char)
(char-to-string query-char-2))))))
(after "yasnippet" (advice-add 'yas-expand :before 'sp-remove-active-pair-overlay))))
(use-package ace-link
:commands (ace-link-info ace-link-help ace-link-compilation ace-link-custom ace-link-org)
:init
(bind!
(:after help-mode :map help-mode-map :m "go" 'ace-link-help)
(:after compile :map compilation-mode-map :m "go" 'ace-link-compilation)
(:after info :map Info-mode-map :m "go" 'ace-link-info)
(:after org :map org-mode-map :m "go" 'ace-link-org)))
(use-package rotate-text
:commands (rotate-word-at-point rotate-region))
(use-package ace-window
:commands ace-window
:config (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)
aw-scope 'frame
aw-background nil))
(use-package smart-forward
:commands (smart-up smart-down smart-left smart-right))
;; (use-package emr
;; :commands (emr-initialize emr-show-refactor-menu emr-declare-command)
;; :bind (:map popup-menu-keymap [escape] 'keyboard-quit))
(use-package expand-region
:commands (er/expand-region er/contract-region er/mark-symbol er/mark-word))
(use-package goto-last-change
:commands goto-last-change)
(use-package hl-todo
:commands hl-todo-mode
:init (add-hook 'prog-mode-hook 'hl-todo-mode))
:init
(add-hook! prog-mode 'hl-todo-mode)
(defvar hl-todo-keyword-faces
'(("TODO" . "#cc9393")
("NOTE" . "#d0bf8f")
("FIXME" . "#cc9393"))))
(use-package emr
:commands (emr-initialize emr-show-refactor-menu emr-declare-command)
:config (bind :map popup-menu-keymap [escape] 'keyboard-quit))
(use-package hideshow
:commands (hs-minor-mode hs-toggle-hiding hs-already-hidden-p)
:diminish hs-minor-mode)
(use-package rainbow-delimiters
:commands rainbow-delimiters-mode
:init (add-to-hooks 'rainbow-delimiters-mode '(emacs-lisp-mode js2-mode scss-mode))
:init (add-hook! (emacs-lisp-mode js2-mode scss-mode) 'rainbow-delimiters-mode)
:config (setq rainbow-delimiters-outermost-only-face-count 1))
(use-package ace-window
:commands ace-window
(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 smartparens
:diminish smartparens-mode
:functions sp-insert-pair
:commands (smartparens-global-mode
sp-pair
sp-local-pair
sp-point-in-string-or-comment)
:init (add-hook! evil-insert-state-entry (unless smartparens-global-mode (smartparens-global-mode 1)))
:config
(setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)
aw-scope 'frame
aw-background nil))
(setq blink-matching-paren t
sp-autowrap-region nil ; let evil-surround handle this
sp-highlight-pair-overlay nil
sp-show-pair-delay 0)
(use-package ace-jump-mode
:functions (ace-jump-char-category ace-jump-do)
:commands (ace-jump-line-mode
ace-jump-char-mode
ace-jump-word-mode
ace-jump-two-chars-mode)
:config
(progn
(defun ace-jump-two-chars-mode (&optional query-char query-char-2)
"AceJump two chars mode"
(interactive)
(require 'smartparens-config)
(evil-half-cursor)
(setq query-char (or query-char (read-char ">")))
(setq query-char-2 (or query-char-2 (read-char (concat ">" (string query-char)))))
;; 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 '(c-mode c++-mode objc-mode java-mode) ; Support for generics
(sp-local-pair "<" ">" :when '(sp-point-after-word-p) :unless '(sp-point-before-same-p)))
(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"))))
(if (eq (ace-jump-char-category query-char) 'other)
(error "[AceJump] Non-printable character"))
(after! yasnippet
(advice-add 'yas-expand :before 'sp-remove-active-pair-overlay)))
;; others : digit , alpha, punc
(setq ace-jump-query-char query-char)
(setq ace-jump-current-mode 'ace-jump-char-mode)
(ace-jump-do (regexp-quote (concat (char-to-string query-char)
(char-to-string query-char-2)))))
(setq ace-jump-mode-scope 'window
ace-jump-mode-gray-background t)))
(use-package ace-link
:commands (ace-link-info
ace-link-help
ace-link-compilation
ace-link-custom
ace-link-org)
:init
(progn
(after "help-mode"
(bind motion :map help-mode-map "go" 'ace-link-help))
(after "compile"
(bind motion :map compilation-mode-map "go" 'ace-link-compilation))
(after "info"
(bind motion :map Info-mode-map "go" 'ace-link-info))
(after "org"
(bind motion :map org-mode-map "go" 'ace-link-org))))
(use-package quickrun
:commands (quickrun
quickrun-region
quickrun-with-arg
quickrun-shell
quickrun-compile-only
quickrun-replace-region
helm-quickrun))
(use-package smex
:commands (smex smex-major-mode-commands smex-initialize smex-update)
:init (setq smex-save-file (! (concat narf-temp-dir "smex-items")))
:config (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))
(provide 'core-editor)
;;; core-editor.el ends here

View file

@ -1,305 +1,228 @@
;;;; Eeeeeeevil ;;;;;;;;;;;;;;;;;;;;;;;;
;;; core-evil.el --- the root of all evil
;; see lib/evil-defuns.el
(use-package evil
:init
(progn
(use-package goto-last-change)
;; highlight matching delimiters where it's important
(defun show-paren-mode-off () (show-paren-mode -1))
(add-hook! evil-insert-state-entry 'show-paren-mode)
(add-hook! evil-insert-state-exit 'show-paren-mode-off)
(add-hook! evil-visual-state-entry 'show-paren-mode)
(add-hook! evil-visual-state-exit 'show-paren-mode-off)
(add-hook! evil-motion-state-entry 'show-paren-mode)
(add-hook! evil-motion-state-exit 'show-paren-mode-off)
(add-hook! evil-operator-state-entry 'show-paren-mode)
(add-hook! evil-operator-state-exit 'show-paren-mode-off)
;; highlight matching delimiters where it's important
(defun show-paren-mode-off () (show-paren-mode -1))
(add-hook 'evil-insert-state-entry-hook 'show-paren-mode)
(add-hook 'evil-insert-state-exit-hook 'show-paren-mode-off)
(add-hook 'evil-visual-state-entry-hook 'show-paren-mode)
(add-hook 'evil-visual-state-exit-hook 'show-paren-mode-off)
(add-hook 'evil-motion-state-entry-hook 'show-paren-mode)
(add-hook 'evil-motion-state-exit-hook 'show-paren-mode-off)
(add-hook 'evil-operator-state-entry-hook 'show-paren-mode)
(add-hook 'evil-operator-state-exit-hook 'show-paren-mode-off)
;; Disable highlights on insert-mode
(add-hook! evil-insert-state-entry 'evil-ex-nohighlight)
;; Disable highlights on insert-mode
(add-hook 'evil-insert-state-entry-hook 'evil-ex-nohighlight)
(add-hook! 'undo-tree-mode-hook (diminish 'undo-tree-mode))
;; Always ensure evil-shift-width is consistent with tab-width
(add-hook! 'evil-local-mode-hook (setq evil-shift-width tab-width)))
(add-hook! undo-tree-mode (diminish 'undo-tree-mode))
;; Always ensure evil-shift-width is consistent with tab-width
(add-hook! evil-local-mode (setq evil-shift-width tab-width))
:config
(progn
(progn ; open/close fold mods
;; Instead of `evil-open-folds'. Accepts COUNT for dictating fold level.
(evil-define-command narf:open-folds (count)
(interactive "P")
(if count (hs-hide-level count) (evil-open-folds)))
(setq evil-magic t
evil-want-C-u-scroll t ; enable C-u for scrolling
evil-ex-visual-char-range t ; column range for ex commands
evil-want-fine-undo nil
evil-want-visual-char-semi-exclusive nil
evil-ex-search-vim-style-regexp t
evil-ex-interactive-search-highlight 'selected-window
;; Instead of `evil-close-folds'. Accepts COUNT for dictating fold level.
(evil-define-command narf:close-folds (count)
(interactive "P")
(if count (hs-hide-level count) (evil-close-folds))))
;; Color-coded state cursors
evil-normal-state-cursor '("white" box)
evil-emacs-state-cursor '("cyan" bar)
evil-insert-state-cursor '("white" bar)
evil-visual-state-cursor '("white" hollow)
evil-iedit-state-cursor '("orange" box))
(setq evil-magic t
evil-want-C-u-scroll t ; enable C-u for scrolling
evil-ex-visual-char-range t ; column range for ex commands
evil-want-fine-undo nil
evil-want-visual-char-semi-exclusive nil
evil-ex-search-vim-style-regexp t
evil-ex-interactive-search-highlight 'selected-window
(evil-mode 1)
(evil-select-search-module 'evil-search-module 'evil-search)
;; Color-coded state cursors
evil-normal-state-cursor '("white" box)
evil-emacs-state-cursor '("cyan" bar)
evil-insert-state-cursor '("white" bar)
evil-visual-state-cursor '("white" hollow)
evil-iedit-state-cursor '("orange" box))
(bind! :map evil-command-window-mode-map :n [escape] 'kill-buffer-and-window)
(add-to-list 'evil-overriding-maps '(narf-mode-map))
(evil-mode 1)
(evil-select-search-module 'evil-search-module 'evil-search)
(defadvice evil-ex-hl-do-update-highlight (around evil-ex-hl-shut-up activate)
"Silence 'Error running timer `evil-ex-hl-do-update-highlight': (error
\"Invalid use of `\\' in replacement text\") errors.
(defadvice evil-ex-hl-do-update-highlight (around evil-ex-hl-shut-up activate)
(ignore-errors ad-do-it))
See `https://bitbucket.org/lyro/evil/issue/527'"
(ignore-errors ad-do-it))
;; modes to map to different default states
(dolist (mode-map '((cider-repl-mode . emacs)
(comint-mode . emacs)
(term-mode . emacs)
(fundamental-mode . normal)
(help-mode . normal)
(message-mode . normal)
(compilation-mode . normal)
(text-mode . normal)))
(evil-set-initial-state `,(car mode-map) `,(cdr mode-map)))
;; modes to map to different default states
(dolist (mode-map '((cider-repl-mode . emacs)
(comint-mode . emacs)
(term-mode . emacs)
(fundamental-mode . motion)
(help-mode . normal)
(message-mode . normal)
(compilation-mode . normal)
(text-mode . normal)))
(evil-set-initial-state `,(car mode-map) `,(cdr mode-map)))
;; Ace Jump
;; https://github.com/winterTTr/ace-jump-mode/issues/23
(evil-define-motion evil-ace-jump-two-chars-mode (count)
:type exclusive
:repeat abort
(evil-without-repeat
(evil-enclose-ace-jump-for-motion
(call-interactively 'ace-jump-two-chars-mode))))
(progn ; evil hacks
(defadvice evil-force-normal-state (before evil-esc-quit activate)
(ignore-errors
(popwin:close-popup-window) ; close popups, if any
(evil-search-highlight-persist-remove-all) ; turn off highlights
(evil-ex-nohighlight)
;; Exit minibuffer if alive
(if (minibuffer-window-active-p (minibuffer-window))
(narf/minibuffer-quit))))
(progn ; evil helpers
(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))))
;; Jump to new splits
(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))
(progn ; evil plugins
(use-package evil-anzu)
;; Restore vimmish ex-mode keymaps to isearch
;; Hide keystroke display while isearch is active
(add-hook! isearch-mode (setq echo-keystrokes 0))
(add-hook! isearch-mode-end (setq echo-keystrokes 0.02))
(bind! :map isearch-mode-map
"C-r" nil
(use-package evil-iedit-state
:functions (iedit-current-occurrence-string iedit-restrict-region)
:commands (evil-iedit-state evil-iedit-state/iedit-mode)
:config
(progn
(bind :map evil-iedit-state-map ; Don't interfere with evil-snipe
"s" nil
"S" nil)
(bind iedit
"V" 'evil-visual-line
"C" 'evil-iedit-state/substitute ; instead of s/S
"za" 'iedit-toggle-unmatched-lines-visible
"C-r %" (λ (narf/isearch-paste-from-register ?%))
"C-r #" (λ (narf/isearch-paste-from-register ?#))
"C-r /" (λ (narf/isearch-paste-from-register ?/))
"C-r :" (λ (narf/isearch-paste-from-register ?:))
"C-r ." (λ (narf/isearch-paste-from-register ?.))
"C-r -" (λ (narf/isearch-paste-from-register ?-))
"C-r _" (λ (narf/isearch-paste-from-register ?_))
"C-r =" (λ (narf/isearch-paste-from-register ?=))
"C-r +" 'narf/isearch-paste-from-clipboard
visual "SPC" (λ (if (iedit-current-occurrence-string)
(let ((current-prefix-arg '(4)))
(iedit-done)
(call-interactively 'iedit-mode)
(save-excursion (iedit-restrict-region (region-beginning) (region-end)))
(evil-previous-line))
(call-interactively 'evil-ret))))))
"C-w" 'narf/isearch-delete-word
"C-u" 'narf/isearch-delete-line
"M-v" 'narf/isearch-paste-from-clipboard)))
;; evil plugins
(use-package evil-anzu)
(use-package evil-search-highlight-persist
:config (global-evil-search-highlight-persist t))
(use-package evil-commentary
:diminish evil-commentary-mode
:commands (evil-commentary
evil-commentary-yank
evil-commentary-line)
:config (evil-commentary-mode 1))
(use-package evil-indent-textobject ; vii/vai/vaI
:commands (evil-indent-i-indent
evil-indent-a-indent
evil-indent-a-indent-lines)
:init
(bind :map evil-inner-text-objects-map
"i" 'evil-indent-i-indent
"i" 'evil-indent-a-indent
"I" 'evil-indent-a-indent-lines))
(use-package evil-ex-registers
:commands (evil-get-spec-register
evil-ex-paste-from-register))
(use-package evil-ex-registers
:commands (evil-get-spec-register
evil-ex-paste-from-register))
(use-package evil-exchange
:commands evil-exchange
:config
(advice-add 'evil-force-normal :after 'narf*evil-exchange-off))
(use-package evil-surround
:commands (global-evil-surround-mode
evil-surround-edit
evil-Surround-edit
evil-surround-region)
:config
(progn
(evil-define-motion evil-surround-line (count)
"Move COUNT - 1 lines down but return exclusive character motion."
:type exclusive
(let ((beg (line-beginning-position)))
(evil-line count)
(end-of-line)
(let ((range (evil-range beg (point) 'exclusive)))
(evil-expand-range range)
range)))
(use-package evil-iedit-state
:functions (iedit-current-occurrence-string iedit-restrict-region)
:commands (evil-iedit-state evil-iedit-state/iedit-mode)
:config
(bind! ; Don't interfere with evil-snipe
:I :unset "s"
:I :unset "S"
:I "V" 'evil-visual-line
:I "C" 'evil-iedit-state/substitute ; instead of s/S
:I "za" 'iedit-toggle-unmatched-lines-visible
:v "SPC" 'narf:iedit-restrict-to-region))
;; Escaped surround characters
(defun evil-surround-escaped ()
(let* ((char (string (read-char "\\")))
(pair (cond ((string-match "[]})[{(]" char)
(let ((-pair (cdr (assoc (string-to-char char) evil-surround-pairs-alist))))
`(,(car -pair) . ,(cdr -pair))))
(t
`(,char . ,char))))
(format (if (sp-point-in-string) "\\\\%s" "\\%s")))
(cons (format format (car pair))
(format format (cdr pair)))))
(use-package evil-indent-textobject
:commands (evil-indent-i-indent
evil-indent-a-indent
evil-indent-a-indent-lines)
:init
(bind! :map evil-inner-text-objects-map
"i" 'evil-indent-i-indent
"i" 'evil-indent-a-indent
"I" 'evil-indent-a-indent-lines))
(global-evil-surround-mode 1)
(use-package evil-jumper
:init
(setq evil-jumper-file (! (concat narf-temp-dir "jumplist"))
evil-jumper-auto-center t
evil-jumper-auto-save-interval 3600))
(push '(?\C-\[ . ("" . "")) evil-surround-pairs-alist)))
(use-package evil-matchit
:commands (evilmi-jump-items global-evil-matchit-mode)
:config (global-evil-matchit-mode 1))
(use-package evil-numbers
:commands (evil-numbers/inc-at-pt
evil-numbers/dec-at-pt))
(use-package evil-numbers
:commands (evil-numbers/inc-at-pt
evil-numbers/dec-at-pt))
(use-package evil-matchit
:commands (evilmi-jump-items global-evil-matchit-mode)
:config (global-evil-matchit-mode 1))
(use-package evil-search-highlight-persist
:config (global-evil-search-highlight-persist t))
(use-package evil-commentary
:diminish evil-commentary-mode
:commands (evil-commentary
evil-commentary-mode
evil-commentary-yank
evil-commentary-line)
:config (evil-commentary-mode 1))
(use-package evil-snipe
:diminish evil-snipe-mode
:commands (evil-snipe-s evil-snipe-S
evil-snipe-x evil-snipe-X
evil-snipe-f evil-snipe-F
evil-snipe-t evil-snipe-T
evil-snipe-repeat evil-snipe-repeat-reverse)
:init
(bind! :m "s" 'evil-snipe-s
:m "S" 'evil-snipe-S
:m "f" 'evil-snipe-f
:m "F" 'evil-snipe-F
:m "t" 'evil-snipe-t
:m "T" 'evil-snipe-T
:o "z" 'evil-snipe-s
:o "Z" 'evil-snipe-S
:o "x" 'evil-snipe-x
:o "X" 'evil-snipe-X)
(define-key evil-normal-state-map "s" nil)
(define-key evil-normal-state-map "S" nil)
:config
(setq-default
evil-snipe-smart-case t
evil-snipe-scope 'line
evil-snipe-repeat-scope 'buffer
evil-snipe-override-evil-repeat-keys nil
evil-snipe-symbol-groups '((?\[ "[[{(]")
(?\] "[]})]")))
(evil-snipe-mode 1)
(evil-snipe-override-mode 1))
(use-package evil-jumper
:init (setq evil-jumper-file (expand-file-name "jumplist" TMP-DIR))
:config
(setq evil-jumper-auto-center t
evil-jumper-auto-save-interval 3600))
(use-package evil-space
:diminish (evil-space-mode . "_")
:init (setq evil-space-auto-setup nil)
:config
(evil-space-mode 1)
(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))))
(evil-space-setup "/" "n" "N")
(evil-space-setup "?" "N" "n")
(use-package evil-visualstar
:commands (global-evil-visualstar-mode
evil-visualstar/begin-search-forward
evil-visualstar/begin-search-backward)
:config
(global-evil-visualstar-mode 1))
(after! evil-snipe
(evil-space-setup 'evil-snipe-f 'evil-snipe-repeat 'evil-snipe-repeat-reverse)
(evil-space-setup 'evil-snipe-F 'evil-snipe-repeat 'evil-snipe-repeat-reverse)
(evil-space-setup 'evil-snipe-t 'evil-snipe-repeat 'evil-snipe-repeat-reverse)
(evil-space-setup 'evil-snipe-T 'evil-snipe-repeat 'evil-snipe-repeat-reverse)
(evil-space-setup 'evil-snipe-s 'evil-snipe-repeat 'evil-snipe-repeat-reverse)
(evil-space-setup 'evil-snipe-S 'evil-snipe-repeat 'evil-snipe-repeat-reverse))
(use-package evil-snipe
:diminish evil-snipe-mode
:init
(setq evil-snipe-smart-case t
evil-snipe-scope 'line
evil-snipe-repeat-scope 'buffer
evil-snipe-symbol-groups '((?\[ "[[{(]")
(?\] "[]})]")))
:config
(progn
(evil-snipe-mode 1)
(evil-snipe-override-mode 1)
(after! evil-visualstar
(evil-space-setup 'evil-visualstar/begin-search-forward "n" "N")
(evil-space-setup 'evil-visualstar/begin-search-backward "n" "N")))
(bind motion :map evil-snipe-mode-map
"C-;" 'evil-snipe-repeat
"C-," 'evil-snipe-repeat-reverse)))
(use-package evil-space
:diminish (evil-space-mode . "_")
:init (setq evil-space-auto-setup nil)
:config
(progn
(evil-space-mode 1)
(evil-space-setup "/" "n" "N")
(evil-space-setup "?" "n" "N")
(after evil-snipe
(evil-space-setup evil-snipe-f evil-snipe-repeat evil-snipe-repeat-reverse)
(evil-space-setup evil-snipe-F evil-snipe-repeat evil-snipe-repeat-reverse)
(evil-space-setup evil-snipe-t evil-snipe-repeat evil-snipe-repeat-reverse)
(evil-space-setup evil-snipe-T evil-snipe-repeat evil-snipe-repeat-reverse)
(evil-space-setup evil-snipe-s evil-snipe-repeat evil-snipe-repeat-reverse)
(evil-space-setup evil-snipe-S evil-snipe-repeat evil-snipe-repeat-reverse))
(after evil-numbers
(let ((map (evil-get-auxiliary-keymap narf-mode-map 'normal)))
(evil-space-setup "g=" "g=" "g-" map)
(evil-space-setup "g-" "g-" "g=" map)))
(after evil-visualstar
(evil-space-setup evil-visualstar/begin-search-forward "n" "N")
(evil-space-setup evil-visualstar/begin-search-backward "n" "N")))))
(progn ; evil hacks
(defadvice evil-force-normal-state (before evil-esc-quit activate)
(ignore-errors
(popwin:close-popup-window) ; close popups, if any
(evil-search-highlight-persist-remove-all) ; turn off highlights
(evil-ex-nohighlight)
;; Exit minibuffer if alive
(if (minibuffer-window-active-p (minibuffer-window))
(narf/minibuffer-quit))))
;; Jump to new splits
(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))
(progn ; Restore vimmish ex-mode keymaps to isearch
(defun narf:isearch-delete-word ()
(interactive)
(let ((num (length isearch-string))
(string (s-reverse isearch-string)))
(when (string-match "[^a-zA-Z0-9]" string 1)
(setq num (match-beginning 0)))
(dotimes (i num)
(isearch-pop-state))
(isearch-update)))
(defun narf:isearch-delete-line ()
(interactive)
(let ((num (length isearch-string)))
(dotimes (i num) (isearch-pop-state))
(isearch-update)))
(defun narf:isearch-paste-from-register (reg)
(interactive)
(let ((str (evil-get-register reg t)))
(when (> (length str) 0)
(isearch-yank-string str))))
(defun narf:isearch-paste-from-clipboard ()
(interactive)
(narf:isearch-paste-from-register ?+))
;; Hide keystroke display while isearch is active
(add-hook! 'isearch-mode-hook (setq echo-keystrokes 0))
(add-hook! 'isearch-mode-end-hook (setq echo-keystrokes 0.02))
(bind :map isearch-mode-map
"C-r" nil
"C-r %" (λ (narf:isearch-paste-from-register ?%))
"C-r #" (λ (narf:isearch-paste-from-register ?#))
"C-r /" (λ (narf:isearch-paste-from-register ?/))
"C-r :" (λ (narf:isearch-paste-from-register ?:))
"C-r ." (λ (narf:isearch-paste-from-register ?.))
"C-r -" (λ (narf:isearch-paste-from-register ?-))
"C-r _" (λ (narf:isearch-paste-from-register ?_))
"C-r =" (λ (narf:isearch-paste-from-register ?=))
"C-r +" 'narf:isearch-paste-from-clipboard
"C-w" 'narf:isearch-delete-word
"C-u" 'narf:isearch-delete-line
"M-v" 'narf:isearch-paste-from-clipboard)))))
(use-package evil-surround
:commands (global-evil-surround-mode
evil-surround-edit
evil-Surround-edit
evil-surround-region)
:config
(global-evil-surround-mode 1)
;; Escaped surround characters
(push '(?\\ . narf/evil-surround-escaped) evil-surround-pairs-alist))
(use-package evil-visualstar
:commands (global-evil-visualstar-mode
evil-visualstar/begin-search
evil-visualstar/begin-search-forward
evil-visualstar/begin-search-backward)
:config
(global-evil-visualstar-mode 1))
(provide 'core-evil)
;;; core-evil.el ends here

40
core/core-flycheck.el Normal file
View file

@ -0,0 +1,40 @@
;;; core-flycheck.el --- check yourself before you shrek yourself
;; Related to: lib/defuns-flycheck.el
(use-package flycheck
:functions (flycheck-buffer)
:commands (flycheck-mode flycheck-list-errors)
:init
(setq 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-hook! (ruby-mode
python-mode
php-mode
lua-mode
shell-mode
scss-mode
c++-mode
c-mode) 'flycheck-mode)
:config
;; TODO: Implement this
(add-unreal-buffer! "^\\*Flycheck.*\\*$")
(bind! :map flycheck-error-list-mode-map
:n [escape] 'kill-this-buffer
:n "q" 'kill-this-buffer)
(evil-initial-state 'flycheck-error-list-mode 'emacs)
;; Check buffer when normal mode is entered
(add-hook! evil-normal-state-entry 'narf*flycheck-buffer)
;; And on ESC in normal mode.
(advice-add 'evil-force-normal-state :after 'narf*flycheck-buffer)
(advice-add 'flycheck-mode-line-status-text :filter-return 'narf*fly-shorter-status))
(use-package flyspell :commands flyspell-mode)
(provide 'core-flycheck)
;;; core-flycheck.el ends here

128
core/core-helm.el Normal file
View file

@ -0,0 +1,128 @@
;;; core-helm.el
(use-package helm
:commands (helm
helm-etags-select
helm-show-kill-ring
helm-bookmarks
helm-wg
helm-ag
helm-alive-p
helm-attrset)
:init
(defvar helm-global-prompt ">>> ")
(setq helm-quick-update t
helm-idle-delay 0.05
helm-input-idle-delay 0.05
helm-reuse-last-window-split-state t
helm-buffers-fuzzy-matching t
helm-candidate-number-limit 40
helm-bookmark-show-location t
;; let popwin handle this
helm-split-window-default-side 'other
helm-split-window-preferred-function 'narf/helm-split-window)
:config
(require 'helm-ag)
(require 'helm-grep)
(evil-set-initial-state 'helm-mode 'emacs)
(add-popwin-rule! "\\`\\*helm.*?\\*\\'" :regexp t :position bottom :height 15)
(add-unreal-buffer! "^\\*[Hh]elm.*\\*$")
(after! winner
;; Tell winner-mode to ignore helm buffers
(dolist (bufname '("*helm recentf*"
"*helm projectile*"
"*helm imenu*"
"*helm company*"
"*helm buffers*"
;; "*helm tags*"
"*helm-ag*"
"*Helm Swoop*"))
(push bufname winner-boring-buffers)))
(bind! :map helm-map
"C-w" 'evil-delete-backward-word
"C-u" 'helm-delete-minibuffer-contents
"C-r" 'evil-ex-paste-from-register ; Evil registers in helm! Glorious!
[escape] 'helm-keyboard-quit)
(advice-add 'helm-display-mode-line :override 'narf*helm-hide-modeline))
(use-package helm-org
:commands (helm-org-in-buffer-headings
helm-org-agenda-files-headings
helm-org-capture-templates))
(use-package helm-files
:commands helm-recentf
:config
(defun helm-recentf ()
"Reconfigured `helm-recentf' to use `helm', instead of `helm-other-buffer'"
(interactive)
(let ((helm-ff-transformer-show-only-basename nil))
(helm :sources '(helm-source-recentf)
:buffer "*helm recentf*"
:prompt helm-global-prompt))))
(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
:defines (helm-swoop-last-prefix-number)
:commands (helm-swoop helm-multi-swoop helm-multi-swoop-all)
:config
(setq helm-swoop-use-line-number-face t
helm-swoop-split-with-multiple-windows t
helm-swoop-speed-or-color t))
(use-package projectile
:diminish projectile-mode
: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 projectile-global-mode)
:config
(add-hook! kill-emacs 'narf|projectile-invalidate-cache-maybe)
(setq-default projectile-enable-caching t)
(setq projectile-sort-order 'recentf
projectile-cache-file (! (concat narf-temp-dir "projectile.cache"))
projectile-known-projects-file (! (concat narf-temp-dir "projectile.projects"))
projectile-indexing-method 'alien
projectile-project-root-files narf-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)
(advice-add 'projectile-prepend-project-name :override 'narf*projectile-replace-prompt))
(use-package helm-projectile
:commands (helm-projectile-switch-to-buffer
helm-projectile-find-file
helm-projectile-recentf
helm-projectile-find-other-file
helm-projectile-switch-project)
:config
(require 'helm)
(require 'projectile))
;; (use-package helm-c-yasnippet :commands helm-yas-visit-snippet-file)
(use-package helm-buffers :commands helm-buffers-list)
(use-package helm-semantic :commands helm-semantic-or-imenu)
(use-package helm-elisp :commands helm-apropos)
(use-package helm-command :commands helm-M-x)
(use-package helm-company :defer t)
(provide 'core-helm)
;;; core-helm.el ends here

View file

@ -1,4 +0,0 @@
(provide 'core-linux)
;; Nothing here yet

8
core/core-os-linux.el Normal file
View file

@ -0,0 +1,8 @@
;;; core-os-linux.el --- Debian-specific settings
(defun narf-open-with (&optional app-name path)
(interactive)
(error "Not yet implemented"))
(provide 'core-os-linux)
;;; core-os-linux.el ends here

View file

@ -1,4 +1,4 @@
;; Mac-specific settings
;;; core-os-osx.el --- Mac-specific settings
;; Use a shared clipboard
(setq x-select-enable-clipboard t
@ -11,20 +11,17 @@
mac-option-modifier 'alt)
;; fix emacs PATH on OSX (GUI only)
(when window-system
(add-hook! 'after-make-window-system-frame-hooks
(setenv "SHELL" "/usr/local/bin/zsh")
(setenv "EMACS" "1")
(setenv "EMACS" "1") ; make sure the world knows
(defmacro narf/init-exec-path ()
"Initialize shell path via `exec-path-from-shell'."
(require 'exec-path-from-shell)
(exec-path-from-shell-initialize)
`(setq exec-path ',exec-path))
(setq exec-path (! (require 'exec-path-from-shell)
(exec-path-from-shell-initialize)
exec-path)))
(narf/init-exec-path))
;; OSX Related Plugins ;;;;;;;;;;;;;;;;;
(use-package applescript-mode
:mode "\\.applescript$")
(use-package applescript-mode :mode "\\.applescript$")
(use-package dash-at-point
:commands (dash-at-point dash-at-point-with-docset)
@ -32,7 +29,9 @@
(add-to-list 'dash-at-point-mode-alist
'(java-mode . "java,droid,javafx,grails,groovy,playjava,spring,cvj,processing,javadoc")))
(after "evil"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(after! evil
(when (featurep 'ns)
;; On OSX, stop copying each visual state move to the clipboard:
;; https://bitbucket.org/lyro/evil/issue/336/osx-visual-state-copies-the-region-on
@ -41,14 +40,13 @@
(defadvice evil-visual-update-x-selection (around clobber-x-select-text activate)
(unless (featurep 'ns) ad-do-it))))
;; Send current file to OSX apps
(defun narf:osx-open-with (&optional app-name path)
(defun narf-open-with (&optional app-name path)
"Send PATH to APP-NAME on OSX."
(interactive)
(let* ((path (f-full (s-replace "'" "\\'" (or path (if (eq major-mode 'dired-mode) (dired-get-file-for-visit) (buffer-file-name))))))
(command (concat "open " (when app-name (concat "-a " (shell-quote-argument app-name))) " '" path "'")))
(message "Running: %s" command)
(shell-command command)))
(provide 'core-osx)
;;; core-osx.el ends here
(provide 'core-os-osx)
;;; core-os-osx.el ends here

8
core/core-os-win32.el Normal file
View file

@ -0,0 +1,8 @@
;;; core-os-win32.el --- Windows-specific settings
(defun narf-open-with (&optional app-name path)
(interactive)
(error "Not yet implemented"))
(provide 'core-os-win32)
;;; core-os-win32.el ends here

98
core/core-project.el Normal file
View file

@ -0,0 +1,98 @@
;;; core-project.el --- all your (basic) project navigational needs
(use-package ido
:defines (flx-ido-mode ido-ubiquitous-debug-mode ido-context-switch-command ido-temp-list)
:functions (ido-to-end)
:commands (ido-mode ido-everywhere ido-vertical-mode
flx-ido-mode ido-ubiquitous-mode ido-find-file
ido-find-file-in-dir)
:init
(setq ido-ignore-buffers
'("\\` " "^\\*ESS\\*" "^\\*Messages\\*" "^\\*Help\\*" "^\\*Buffer"
"^\\*.*Completions\\*$" "^\\*Ediff" "^\\*tramp" "^\\*cvs-"
"_region_" " output\\*$" "^TAGS$" "^\*Ido")
ido-use-faces nil
ido-confirm-unique-completion t
ido-case-fold t
ido-enable-tramp-completion nil
ido-enable-flex-matching t
ido-create-new-buffer 'always
ido-enable-tramp-completion t
ido-enable-last-directory-history t
ido-save-directory-list-file (! (concat narf-temp-dir "ido.last")))
:config
(add-to-list 'ido-ignore-files "\\`.DS_Store$")
(add-to-list 'ido-ignore-files "Icon\\?$")
(add-hook! ido-setup
(bind! :map (ido-common-completion-map ido-completion-map ido-file-completion-map)
"C-n" 'ido-next-match
"C-p" 'ido-prev-match
"C-w" 'ido-delete-backward-word-updir))
(ido-mode 1)
(ido-everywhere 1)
(require 'ido-vertical-mode)
(ido-vertical-mode 1)
(require 'flx-ido)
(flx-ido-mode 1)
(require 'ido-ubiquitous)
(ido-ubiquitous-mode 1)
(advice-add 'ido-sort-mtime :override 'narf*ido-sort-mtime)
(add-hook! (ido-make-file-list ido-make-dir-list) 'narf*ido-sort-mtime)
(add-hook! ido-setup 'narf|ido-setup-home-keybind))
(use-package neotree
:commands (neotree-show
neotree-hide
neotree-toggle
neotree-dir
neotree-find
neo-global--window-exists-p)
:functions (neo-buffer--unlock-width neo-buffer--lock-width)
:init
(setq neo-create-file-auto-open t
neo-mode-line-type 'none
neo-persist-show t
neo-window-width 22
neo-show-updir-line nil
neo-auto-indent-point t
neo-banner-message nil
;; requires <https://github.com/jeffplang/emacs-neotree> fork of
;; neotree (at least, until the PR is accepted). Causes neotree to
;; open in a vertical split that consumes the entire height of the
;; frame.
neo-modern-sidebar t)
:config
(defun narf|neotree-init-keymap ()
(bind! :map evil-motion-state-local-map
"ESC" 'neotree-hide
"\\\\" '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))
(add-hook! neotree-mode 'narf|neotree-init-keymap)
(add-hook! window-configuration-change 'narf|neotree-close-on-window-change)
(evil-set-initial-state 'neotree-mode 'motion)
(after! projectile
(setq projectile-switch-project-action 'neotree-projectile-action))
(advice-add 'neo-buffer--insert-fold-symbol :override 'narf*neo-buffer-fold-symbol))
(provide 'core-project)
;;; core-project.el ends here

13
core/core-quickrun.el Normal file
View file

@ -0,0 +1,13 @@
;;; core-quickrun.el
(use-package quickrun
:commands (quickrun
quickrun-region
quickrun-with-arg
quickrun-shell
quickrun-compile-only
quickrun-replace-region
helm-quickrun))
(provide 'core-quickrun)
;;; core-quickrun.el ends here

View file

@ -1,145 +0,0 @@
(define-derived-mode narf-splash-mode special-mode "NARF"
"Splash screen for Narf emacs.")
(defun narf/splash-init ()
)
(defun narf/random-comeback ()
(let ((replies '("I think so, Brain, but where are we going to find a duck and a hose at this hour?"
"I think so, but where will we find an open tattoo parlor at this time of night?"
"Wuh, I think so, Brain, but if we didn't have ears, we'd look like weasels."
"Uh... yeah, Brain, but where are we going to find rubber pants our size?"
"Uh, I think so, Brain, but balancing a family and a career ... ooh, it's all too much for me."
"Wuh, I think so, Brain, but isn't Regis Philbin already married?"
"Wuh, I think so, Brain, but burlap chafes me so."
"Sure, Brain, but how are we going to find chaps our size?"
"Uh, I think so, Brain, but we'll never get a monkey to use dental floss."
"Are you pondering cheesesticks?"
"Uh, I think so Brain, but this time, you wear the tutu."
"I think so, Brain, but culottes have a tendency to ride up so."
"I think so, Brain, but if we covered the world in salad dressing wouldn't the aspargus feel left out?"
"I think so, Brain, but if they called them 'Sad Meals', kids wouldn't buy them!"
"I think so, Brain, but me and Pippi Longstocking -- I mean, what would the children look like?"
"I think so, Brain, but what would Pippi Longstocking look like with her hair straight?"
"I think so, Brain, but this time you put the trousers on the chimp."
"Well, I think so, Brain, but I can't memorize a whole opera in Yiddish."
"I think so, Brain, but there's still a bug stuck in here from last time."
"Uh, I think so, Brain, but I get all clammy inside the tent."
"I think so, Brain, but I don't think Kaye Ballard's in the union."
"I think so, Brain, but, the Rockettes? I mean, it's mostly girls, isn't it?"
"I think so, Brain, but pants with horizontal stripes make me look chubby."
"Well, I think so -POIT- but where do you stick the feather and call it macaroni?"
"Well, I think so, Brain, but pantyhose are so uncomfortable in the summertime."
"Well, I think so, Brain, but it's a miracle that this one grew back."
"Well, I think so, Brain, but first you'd have to take that whole bridge apart, wouldn't you?"
"Well, I think so, Brain, but 'apply North Pole' to what?"
"I think so, Brain, but 'Snowball for Windows'?"
"Well, I think so, Brain, but snort no, no, it's too stupid!"
"Umm, I think so, Don Cerebro, but, umm, why would Sophia Loren do a musical?"
"Umm, I think so, Brain, but what if the chicken won't wear the nylons?"
"I think so, Brain, but isn't that why they invented tube socks?"
"Well, I think so Brain, but what if we stick to the seat covers?"
"I think so Brain, but if you replace the 'P' with an 'O', my name would be Oinky, wouldn't it?"
"Oooh, I think so Brain, but I think I'd rather eat the Macarena."
"Well, I think so hiccup, but Kevin Costner with an English accent?"
"I think so, Brain, but don't you need a swimming pool to play Marco Polo?"
"Well, I think so, Brain, but do I really need two tongues?"
"I think so, Brain, but we're already naked."
"Well, I think so, Brain, but if Jimmy cracks corn, and no one cares, why does he keep doing it?"
"I think so, Brain NARF, but don't camels spit a lot?"
"I think so, Brain, but how will we get a pair of Abe Vigoda's pants?"
"I think so, Brain, but Pete Rose? I mean, can we trust him?"
"I think so, Brain, but why would Peter Bogdanovich?"
"I think so, Brain, but isn't a cucumber that small called a gherkin?"
"I think so, Brain, but if we get Sam Spade, we'll never have any puppies."
"I think so, Larry, and um, Brain, but how can we get seven dwarves to shave their legs?"
"I think so, Brain, but calling it pu-pu platter? Huh, what were they thinking?"
"I think so, Brain, but how will we get the Spice Girls into the paella?"
"I think so, Brain, but if we give peas a chance, won't the lima beans feel left out?"
"I think so, Brain, but I am running for mayor of Donkeytown and Tuesdays are booked."
"I think so, Brain, but if we had a snowmobile, wouldn't it melt before summer?"
"I think so, Brain, but what kind of rides do they have in Fabioland?"
"I think so, Brain, but can the Gummi Worms really live in peace with the Marshmallow Chicks?"
"Wuh, I think so, Brain, but wouldn't anything lose its flavor on the bedpost overnight?"
"I think so, Brain, but three round meals a day wouldn't be as hard to swallow."
"I think so, Brain, but if the plural of mouse is mice, wouldn't the plural of spouse be spice?"
"Umm, I think so, Brain, but three men in a tub? Ooh, that's unsanitary!"
"Yes, but why does the chicken cross the road, huh, if not for love? I do not know."
"Wuh, I think so, Brain, but I prefer Space Jelly."
"Yes Brain, but if our knees bent the other way, how would we ride a bicycle?"
"Wuh, I think so, Brain, but how will we get three pink flamingos into one pair of Capri pants?"
"I think so, Brain, but Tuesday Weld isn't a complete sentence."
"I think so, Brain, but why would anyone want to see Snow White and the Seven Samurai?"
"I think so, Brain, but wouldn't mustard make it sting?"
"I think so, Brain, but can you use the word 'asphalt' in polite society?"
"I think so, Mr. Brain, but if the sun'll come out tomorrow, what's it doing right now?"
"I think so, Brain, but aren't we out of shaving cream?"
"Oh yes, Brain! Remind me to tape all our phone calls!"
"Um, I think so, Brain, but I hear Hillary is the jealous type."
"I think so, Brain, but Madonna's stock is sinking."
"I think so, Brain. But does 'Chunk o' Cheesy's' deliver packing material?"
"I think so, Brainwulf, but if we're Danish, where's the cream cheese? Narf!"
"I think so, Bwain, but I don't think newspaper will fit in my underoos."
"Uh, I think so, Brain--but after eating newspaper all day, do I really need the extra fiber?"
"I think so, Brain! But isn't a dreadlock hair extension awfully expensive?"
"I think so, Brain. But will anyone other than Eskimos buy blubber-flavored chewing gum?"
"I think so, Brain, but the ointment expired weeks ago!"
"Uh, I think so Brain, but how are we gonna teach a goat to dance with flippers on?"
"Wuhh... I think so, Brain! But let's use safflower oil this time! It's ever so much healthier!"
"Wuh... I think so, Brain. But Cream of Gorilla Soup—well, we'd have to sell it in awfully big cans, wouldn't we?"
"I think so, Brain. But if he left chocolate bullets instead of silver, they'd get all runny and gooey!"
"Yes, Brain, I think so, but do nuts go with pudding?"
"I think so, Brain, but a codpiece made from a real fish would get smelly after a while, wouldnt it?"
"I think... so, Brain... *gag* ...but I didn't know Annette used peanut butter in that way."
"I think so, Brain, but do those roost in this neighborhood?"
"I think so, Brain, but is the world ready for angora bellbottoms? I mean I can see wearing them inside out, but that would--"
"I think so, Commander Brain from Outer Space! But do we have time to grease the rockets?"
"I think so, Doctor. But are these really the legs of a show girl?"
"Whuh... I think so, Brain. But this time I get to play the dishwasher repairman!"
"I think so, Brainius. But what if a sudden wind were to blow up my toga?"
"I think so, Brain. But Trojans wont arrive on the scene for another 300 years."
"I think so, Brain... but where would a yak put PVC tubing?"
"Whuh... I think so, Brain, but... but if Charlton Heston doesn't eat Soylent Green, what will he eat?"
"I think so, Brain, but would Danish flies work just as well?"
"We think so, Brain! But dressing like twins is so tacky."
"I think so, Brain, but practicing docking procedures with a goat at zero G's—it's never been done!"
"I think so, Brain! But shouldn't we let the silk worms finish the boxer shorts before we put them on?"
"I think so, Brain! You draw the bath and I'll fetch the alka-seltzers and candles!"
"I think so, Brain. But the real trick will be getting Demi Moore out of the creamed corn!"
"Wuhhh... I think so, Brain, but if a ham can operate a radio, why can't a pig set a VCR?"
"I think so, Brain, you'd think [Lyndon Johnson would] have left room for baby-kissing, wouldn't you?"
"I think so, Brain! But won't Mr. Hoover notice a missing evening gown?"
"I think so, Brain! But what's the use of having a heart-shaped tattoo if it's going to be covered by hair?"
"I think so, Brain, but couldn't the constant use of a henna rinse lead to premature baldness?"
"I think so, Brain. Just make sure we don't swallow each other's bubbles!"
"I think so, Brain! But ruby-studded stockings would be mighty uncomfortable wouldn't they?"
"I think so, Brain, but if I have my portrait drawn, will we have time to make it to the lifeboats?"
"I think so, Brain! But is Chippendale's ready for 'The Full Pinky?'"
"I think so, Brain! But do I have what it take to be the 'Lord of the Dance'?"
"I think so, Brain! How much deeper would the ocean be if there weren't sponges down there?"
"Oh, I think so, Brain! But doing a clog dance in actual clogs will give me awful blisters."
"I think so, Brain, but nose rings are kinda passé by now."
"I think so, Brain, but where are we going to get a trained octopus at this time of night?"
"I think so, Brain! But no more eels in jelly for me, thanks—I like my gelatin after lunch."
"I think so, Brain, but I didnt know 90210 was a real zip code! Will Tori be there?"
"I think so, Brain. But if Pinocchio were carved out of bacon it wouldn't be the same story, would it?"
"Um, I think so, Brain, but wasn't Dicky Ducky released on his own recognaissance?"
"I think so, Brain, but Pepper Ann makes me sneeze."
"I think so, Brain. But suppose we do the hokey pokey and turn ourselves around, is that what it's really all about?"
"I think so, Brain, but just how will we get the weasel to hold still?"
"I think so, Brain, but how are we going to get the bacon flavoring into the pencils?"
"I think so, Brain, but instant karma's always so lumpy."
)))
(nth (random (length replies)) replies)))
;; TODO: Move this to external file
(add-hook 'after-init-hook
(lambda () (setq initial-scratch-message
(format "\n\n\n\n NARF!\n Emacs: %s\n\n >> Loaded in %s\n >>> %s"
emacs-version
(emacs-init-time)
(narf/random-comeback)))))
(provide 'core-splash)
;;; core-splash.el ends here

View file

@ -1,6 +1,24 @@
;;; core-ui.el -- User interface layout & behavior
;;; core-ui.el --- interface settings
;; see lib/ui-defuns.el
(when (fboundp 'fringe-mode) (fringe-mode '(2 . 8)))
;; This is kept separate so it can jumpstart emacs; this prevents the unstyled
;; flash of emacs pre-makeover.
(add-hook! 'after-make-console-frame-hooks
(load-theme narf-term-theme t)
(menu-bar-mode -1)) ; no menubar
(add-hook! 'after-make-window-system-frame-hooks
(load-theme narf-default-theme t)
(set-frame-font (apply #'font-spec narf-default-font))
(scroll-bar-mode -1) ; no scrollbar
(tool-bar-mode -1) ; no toolbar
(menu-bar-mode -1) ; no menubar
(set-frame-parameter nil 'fullscreen 'fullboth)
(fringe-mode '(2 . 8))
;; more informative window title
(setq frame-title-format '(buffer-file-name "%f" ("%b"))))
;; theme and GUI elements are loaded in init.el early
(setq show-paren-delay 0)
@ -18,200 +36,171 @@
(setq-default
cursor-in-non-selected-windows nil
visible-bell nil ; silence of the bells
use-dialog-box nil ; avoid GUI
use-dialog-box nil ; avoid GUI
redisplay-dont-pause t
;; do not soft-wrap lines
truncate-lines t
truncate-partial-width-windows nil
indicate-buffer-boundaries nil
indicate-empty-lines nil
fringes-outside-margins t)
fringes-outside-margins t) ; fringes on the other side of line numbers
(use-package nlinum
:commands nlinum-mode
:init
(progn
(defface linum '((t (:inherit default)))
"Face for line numbers"
:group 'nlinum-mode)
(defface linum-highlight-face '((t (:inherit linum)))
"Face for line highlights"
:group 'nlinum-mode)
;; Preset width nlinum
(add-hook! 'nlinum-mode-hook
(setq nlinum--width (length (number-to-string (count-lines (point-min)
(point-max))))))
;; Highlight line number
(defvar narf--hl-nlinum-overlay nil)
(defvar narf--hl-nlinum-line nil)
(defun narf/nlinum-unhl-line ()
(when narf--hl-nlinum-overlay
(let* ((ov narf--hl-nlinum-overlay)
(disp (get-text-property 0 'display (overlay-get ov 'before-string)))
(str (nth 1 disp)))
(put-text-property 0 (length str) 'face 'linum str)
(setq narf--hl-nlinum-overlay nil
narf--hl-nlinum-line nil))))
(defun narf/nlinum-hl-line (&optional line)
(let ((line-no (or line (line-number-at-pos (point)))))
(when (and nlinum-mode (not (eq line-no narf--hl-nlinum-line)))
(let* ((pbol (if line (save-excursion (goto-char (point-min))
(forward-line line-no)
(point-at-bol))
(point-at-bol)))
(peol (1+ pbol)))
;; Handle EOF case
(when (>= peol (point-max))
(setq peol (point-max)))
(jit-lock-fontify-now pbol peol)
(let* ((overlays (overlays-in pbol peol))
(ov (-first (lambda (item) (overlay-get item 'nlinum)) overlays)))
(when ov
(narf/nlinum-unhl-line)
(let* ((disp (get-text-property 0 'display (overlay-get ov 'before-string)))
(str (nth 1 disp)))
(put-text-property 0 (length str) 'face 'linum-highlight-face str)
(put-text-property 0 (length str) 'face 'linum-highlight-face str)
(setq narf--hl-nlinum-overlay ov
narf--hl-nlinum-line line-no))))))))
(defun narf:nlinum-toggle ()
(interactive)
(if nlinum-mode
(narf/nlinum-disable)
(narf/nlinum-enable)))
(defun narf/nlinum-enable ()
(nlinum-mode +1)
(add-hook 'post-command-hook 'narf/nlinum-hl-line))
(defun narf/nlinum-disable ()
(nlinum-mode -1)
(remove-hook 'post-command-hook 'narf/nlinum-hl-line)
(narf/nlinum-unhl-line))
(add-hook 'prog-mode-hook 'narf/nlinum-enable)
(add-hook 'org-mode-hook 'narf/nlinum-disable))
:config
(setq-default nlinum-format " %4d "))
(when window-system
(setq frame-title-format '(buffer-file-name "%f" ("%b")))
(if (string-equal (system-name) "io")
(set-frame-size (selected-frame) 326 119)))
(add-hook! 'after-init-hook
(add-hook! after-init
(defadvice save-buffers-kill-emacs (around no-query-kill-emacs activate)
"Prevent annoying \"Active processes exist\" query when you quit Emacs."
(flet ((process-list ())) ad-do-it)))
(use-package nlinum ; line numbers
:defer t
:defines nlinum--width
:preface
(defface linum '((t (:inherit default)))
"Face for line numbers" :group 'nlinum-mode)
(defface linum-highlight-face '((t (:inherit linum)))
"Face for line highlights" :group 'nlinum-mode)
(defvar narf--hl-nlinum-overlay nil)
(defvar narf--hl-nlinum-line nil)
(defvar nlinum-format " %4d ")
:init
;; Highlight line number
(defun narf|nlinum-unhl-line ()
(when narf--hl-nlinum-overlay
(let* ((ov narf--hl-nlinum-overlay)
(disp (get-text-property 0 'display (overlay-get ov 'before-string)))
(str (nth 1 disp)))
(put-text-property 0 (length str) 'face 'linum str)
(setq narf--hl-nlinum-overlay nil
narf--hl-nlinum-line nil))))
;;;; Modeline ;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package smart-mode-line
(defun narf|nlinum-hl-line (&optional line)
(let ((line-no (or line (line-number-at-pos (point)))))
(when (and nlinum-mode (not (eq line-no narf--hl-nlinum-line)))
(let* ((pbol (if line (save-excursion (goto-char (point-min))
(forward-line line-no)
(point-at-bol))
(point-at-bol)))
(peol (1+ pbol)))
;; Handle EOF case
(when (>= peol (point-max))
(setq peol (point-max)))
(jit-lock-fontify-now pbol peol)
(let* ((overlays (overlays-in pbol peol))
(ov (-first (lambda (item) (overlay-get item 'nlinum)) overlays)))
(when ov
(narf|nlinum-unhl-line)
(let* ((disp (get-text-property 0 'display (overlay-get ov 'before-string)))
(str (nth 1 disp)))
(put-text-property 0 (length str) 'face 'linum-highlight-face str)
(put-text-property 0 (length str) 'face 'linum-highlight-face str)
(setq narf--hl-nlinum-overlay ov
narf--hl-nlinum-line line-no))))))))
(defun narf|nlinum-enable ()
(nlinum-mode +1)
(add-hook 'post-command-hook 'narf|nlinum-hl-line))
(defun narf|nlinum-disable ()
(nlinum-mode -1)
(remove-hook 'post-command-hook 'narf|nlinum-hl-line)
(narf|nlinum-unhl-line))
(add-hook! text-mode 'narf|nlinum-enable)
(add-hook! prog-mode 'narf|nlinum-enable)
(add-hook! org-mode 'narf|nlinum-disable)
;; Preset width nlinum
(add-hook! nlinum-mode
(setq nlinum--width (length (number-to-string (count-lines (point-min) (point-max)))))))
(use-package smart-mode-line ; customized modeline
:init (setq-default
sml/no-confirm-load-theme t
sml/mode-width 'full
sml/extra-filler -7
sml/show-remote nil
sml/encoding-format nil
sml/modified-char "*"
sml/numbers-separator "/"
sml/line-number-format "%3l"
sml/col-number-format "%2c"
sml/pre-modes-separator " : "
sml/pre-minor-modes-separator " "
sml/pos-minor-modes-separator ": "
sml/replacer-regexp-list '(("^~/.emacs.d/" "EMACS.D:")
("^~/Dropbox/Projects/" "PROJECTS:")
("^~/Dropbox/notes/" "NOTES:")
("^/usr/local/Cellar/" "HOMEBREW:")))
:config
(progn
(setq sml/no-confirm-load-theme t
sml/mode-width 'full
sml/extra-filler -7
sml/show-remote nil
sml/modified-char "*"
sml/encoding-format nil
sml/replacer-regexp-list '(("^~/Dropbox/Projects/" "PROJECTS:")
("^~/.emacs.d/" "EMACS.D:")
("^~/Dropbox/notes/" "NOTES:")
("^/usr/local/Cellar/" "HOMEBREW:"))
sml/pre-modes-separator " : "
sml/pre-minor-modes-separator " "
sml/pos-minor-modes-separator ": "
sml/numbers-separator "/"
sml/line-number-format "%3l"
sml/col-number-format "%2c")
;; Hide evil state indicator
(after! evil (setq evil-mode-line-format nil))
;; Hide evil state indicator
(after "evil" (setq evil-mode-line-format nil))
(sml/setup)
(sml/apply-theme 'respectful)
;; (setq-default mode-line-misc-info
;; '((which-func-mode ("" which-func-format ""))
;; (global-mode-string ("" global-mode-string ""))))
;; Hack modeline to be more vim-like, and right-aligned
(defun sml/generate-minor-modes ()
(if sml/simplified
""
(let* ((nameList (rm--mode-list-as-string-list))
(last nil)
(concatList (mapconcat (lambda (mode)
(setq mode (s-trim mode))
(if (> (length mode) 1)
(prog1 (concat (if last " ") mode " ")
(setq last nil))
(prog1 mode
(setq last t))))
nameList ""))
(size (sml/fill-width-available))
(finalNameList concatList)
needs-removing filling)
(when (and sml/shorten-modes (> (length finalNameList) size))
(setq needs-removing
(1+ (sml/count-occurrences-starting-at
" " finalNameList
(- size (string-width sml/full-mode-string))))))
(when needs-removing
(setcdr (last nameList (1+ needs-removing))
(list t sml/propertized-full-mode-string)))
(unless sml/shorten-modes
(add-to-list 'nameList sml/propertized-shorten-mode-string t))
(setq filling (- size (+ (length (format-mode-line concatList)) (length mode-name) (length vc-mode))))
(setq filling (make-string (max 0 filling) sml/fill-char))
(list (propertize filling 'face 'sml/modes)
(propertize (or vc-mode "") 'face 'sml/vc)
(propertize sml/pre-modes-separator 'face 'font-lock-comment-delimiter-face)
(propertize mode-name)
'sml/pre-minor-modes-separator
concatList
(propertize sml/pos-minor-modes-separator 'face
'font-lock-comment-delimiter-face)))))
(sml/setup)
(sml/apply-theme 'respectful)
;; Remove extra spaces in format lists
(pop mode-line-modes)
(nbutlast mode-line-modes)
;; Hack modeline to be more vim-like, and right-aligned
(defun sml/generate-minor-modes ()
(if sml/simplified
""
(let* ((nameList (rm--mode-list-as-string-list))
(last nil)
(concatList (mapconcat (lambda (mode)
(setq mode (s-trim mode))
(if (> (length mode) 1)
(prog1 (concat (if last " ") mode " ")
(setq last nil))
(prog1 mode
(setq last t))))
nameList ""))
(size (sml/fill-width-available))
(finalNameList concatList)
needs-removing filling)
(when (and sml/shorten-modes (> (length finalNameList) size))
(setq needs-removing
(1+ (sml/count-occurrences-starting-at
" " finalNameList
(- size (string-width sml/full-mode-string))))))
(when needs-removing
(setcdr (last nameList (1+ needs-removing))
(list t sml/propertized-full-mode-string)))
(unless sml/shorten-modes
(add-to-list 'nameList sml/propertized-shorten-mode-string t))
;; Remove spacing in mode-line position so we can put it elsewhere
(setq mode-line-position
'((sml/position-percentage-format
(-3 (:propertize (:eval sml/position-percentage-format)
face sml/position-percentage help-echo "Buffer Relative Position\nmouse-1: Display Line and Column Mode Menu")))))
;; Padding
(setq filling (- size (+ (length (format-mode-line concatList)) (length mode-name) (length vc-mode))))
(setq filling (make-string (max 0 filling) sml/fill-char))
(list (propertize filling 'face 'sml/modes)
(propertize (or vc-mode "") 'face 'sml/vc)
(propertize sml/pre-modes-separator 'face 'font-lock-comment-delimiter-face)
(propertize mode-name)
'sml/pre-minor-modes-separator
concatList
(propertize sml/pos-minor-modes-separator 'face
'font-lock-comment-delimiter-face)))))
;; Remove extra spaces in format lists
(pop mode-line-modes)
(nbutlast mode-line-modes)
;; Remove spacing in mode-line position so we can put it elsewhere
(setq mode-line-position
'((sml/position-percentage-format
(-3 (:propertize (:eval sml/position-percentage-format)
face sml/position-percentage help-echo "Buffer Relative Position\nmouse-1: Display Line and Column Mode Menu")))))
(after "anzu"
;; Add small gap for anzu
(defun narf/anzu-update-mode-line (here total)
(concat (anzu--update-mode-line-default here total) " "))
(setq anzu-mode-line-update-function 'narf/anzu-update-mode-line))
;; Rearrange and cleanup
(setq-default mode-line-format
'("%e "
mode-line-mule-info
mode-line-client
mode-line-remote
mode-line-frame-identification
mode-line-buffer-identification
mode-line-modified
mode-line-misc-info
mode-line-modes
mode-line-front-space
mode-line-end-spaces
" "
":" mode-line-position
))))
(after! anzu ; Add small gap for anzu
(defun narf--anzu-update-mode-line (here total)
(concat (anzu--update-mode-line-default here total) " "))
(setq anzu-mode-line-update-function 'narf--anzu-update-mode-line))
;; Rearrange and cleanup
(setq-default mode-line-format
'("%e"
mode-line-mule-info
mode-line-client
;; mode-line-remote
mode-line-frame-identification
mode-line-buffer-identification
mode-line-modified
mode-line-misc-info
mode-line-modes
mode-line-front-space
mode-line-end-spaces
" "
":" mode-line-position)))
(provide 'core-ui)
;;; core-ui.el ends here

70
core/core-vars.el Normal file
View file

@ -0,0 +1,70 @@
;;; core-vars.el --- narf emacs configuration
(defgroup narf nil
"Narf variables."
:group 'convenience
:prefix 'narf-)
(defcustom narf-leader-key "," "The prefix for leader keybindings."
:group 'narf :type 'string)
(defcustom narf-localleader-key "\\" "The prefix for localleader keybindings."
:group 'narf)
;; Buffers/Files ;;;;;;;;;;;;;;;;;;;;;;;
(defconst narf--splash-buffer-name "*narf*")
(defvar narf-auto-minor-mode-alist '()
"Alist of filename patterns vs corresponding 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.")
(defvar narf-unreal-buffers '("^ \\*"
"^\\*scratch\\*"
"^\\*Backtrace\\*$"
"^\\*Warnings\\*$"
"^\\*Compile-Log\\*$"
"^\\*Ediff.*\\*$"
"^\\*helm.*\\*$"
"^\\*eval\\*$"
"^\\*Shell Command Output\\*$"
"^\\*Async Shell Command\\*$"
help-mode
image-mode
dired-mode
reb-mode
messages-buffer-mode)
"A list of regexps or modes whose buffers are considered unreal, and will be
ignored when using `narf:next-real-buffer' and `narf:previous-real-buffer', and
killed by `narf:kill-unreal-buffers'.
`narf:kill-this-buffer' will also gloss over these buffers when finding a new
buffer to display.")
(defvar narf-ignore-buffers '("*Completions*" "*Compile-Log*" "*inferior-lisp*"
"*Fuzzy Completions*" "*Apropos*" "*Help*" "*cvs*"
"*Buffer List*" "*Ibuffer*" "*esh command on file*"
"*helm*")
"List of buffer names to ignore when using `winner-undo', or `winner-redo'")
(defvar narf-cleanup-processes-alist '(("pry" . ruby-mode)
("irb" . ruby-mode)
("ipython" . python-mode))
"An alist of (process-name . major-mode), that `narf:cleanup-processes' checks
before killing processes. If there are no buffers with matching major-modes, it
gets killed.")
(defvar narf-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.")
(provide 'core-vars)
;;; core-vars.el ends here

BIN
core/core-vars.elc Normal file

Binary file not shown.

View file

@ -1,3 +1,5 @@
;;; core-vcs.el --- version control awareness
(use-package git-commit-mode ;
:mode (("/COMMIT_EDITMSG\\'" . git-commit-mode)
("/NOTES_EDITMSG\\'" . git-commit-mode)
@ -23,11 +25,8 @@
("/git/ignore\\'" . gitignore-mode)))
(use-package diff-hl
:config
(progn
(setq diff-hl-draw-borders nil)
(global-diff-hl-mode +1)))
:init (setq diff-hl-draw-borders nil)
:config (global-diff-hl-mode +1))
(provide 'init-vc)
;;; init-vc.el ends here
(provide 'core-vcs)
;;; core-vcs.el ends here

32
core/core-workgroups.el Normal file
View file

@ -0,0 +1,32 @@
;;; core-workgroups.el
;; see lib/workgroup-defuns.el
(use-package workgroups2
:init
(setq wg-session-file (! (expand-file-name "wg-default" narf-temp-dir))
wg-workgroup-directory (! (expand-file-name "workgroups" narf-temp-dir))
wg-first-wg-name "main"
wg-session-load-on-start t
wg-mode-line-display-on nil
wg-mess-with-buffer-list t
;; What to do on Emacs exit / workgroups-mode exit?
wg-emacs-exit-save-behavior 'save ; Options: 'save 'ask nil
wg-workgroups-mode-exit-save-behavior 'save)
:config
(defvar narf/helm-source-wg
'((name . "Workgroups")
(candidates . wg-workgroup-names)
(action . narf/wg-helm-switch-to-workgroup)))
(after! projectile
;; Turns projectile switch-project interface (or helm's interface to it)
;; create a new workgroup for the new project.
(setq projectile-switch-project-action 'narf/wg-projectile-switch-project))
;; Initialize!
(add-hook! after-init
(workgroups-mode 1)
(diminish 'workgroups-mode)))
(provide 'core-workgroups)
;;; core-workgroups.el ends here

74
core/core-yasnippet.el Normal file
View file

@ -0,0 +1,74 @@
;;; core-yasnippet.el --- For the lazy typist
;; see lib/yasnippet-defuns.el
;; see lib/yasnippet-macros.el
(use-package yasnippet
:mode (("emacs\\.d/snippets/.+$" . snippet-mode))
:diminish (yas-minor-mode . "Y")
:commands (yas-minor-mode
yas-minor-mode-on
yas-expand
yas-insert-snippet
yas-new-snippet
yas-visit-snippet-file)
:init
(add-hook! (prog-mode snippet-mode markdown-mode org-mode) 'yas-minor-mode-on)
(add-hook! snippet-mode 'narf|disable-final-newline)
(setq yas-verbosity 0
yas-indent-line 'auto
yas-also-auto-indent-first-line t
yas-wrap-around-region nil
;; Only load personal snippets
yas-snippet-dirs `(,@narf-snippet-dirs)
yas-prompt-functions '(yas-ido-prompt yas-no-prompt))
(bind! :i [(tab)] 'yas-expand
:v "<backtab>" 'narf/yas-insert-snippet)
(defvar yas-minor-mode-map
(let ((map (make-sparse-keymap)))
(evil-define-key 'insert map [(tab)] 'yas-expand)
(evil-define-key 'visual map (kbd "<backtab>") 'narf/yas-insert-snippet)
map))
:config
(after! helm (add-to-list 'yas-dont-activate 'helm-alive-p))
(yas-reload-all)
;; Simpler `yas-selected-text' alias for templates
(defvaralias '% 'yas-selected-text)
;; Undo global maps
(bind! :i [(tab)] nil
:v "<backtab>" nil)
;; keybinds
(bind! :map yas-keymap
"C-e" 'narf/yas-goto-end-of-field
"C-a" 'narf/yas-goto-start-of-field
"<M-right>" 'narf/yas-goto-end-of-field
"<M-left>" 'narf/yas-goto-start-of-field
"<S-tab>" 'yas-prev-field
"<M-backspace>" 'narf/yas-clear-to-sof
[backspace] 'narf/yas-backspace
"<delete>" 'narf/yas-delete)
;; Once you're in normal mode, you're out
(add-hook! evil-normal-state-entry 'yas-abort-snippet)
;; Strip out the shitespace before a line selection
(add-hook! yas-before-expand-snippet 'narf|yas-before-expand)
;; Previous hook causes yas-selected-text to persist between expansions.
;; This little hack gets around it.
(add-hook! yas-after-exit-snippet 'narf|yas-after-expand)
;; Exit snippets on ESC in normal mode
(advice-add 'evil-force-normal-state :before 'yas-exit-all-snippets)
;; Prevents evil's visual-line from mode gobbling up the newline on the
;; right due to an off-by-one issue.
(defadvice yas-expand-snippet (around yas-expand-snippet-visual-line activate)
(when (narf/evil-visual-line-state-p)
(ad-set-arg 2 (1- (ad-get-arg 2)))) ad-do-it))
(provide 'core-yasnippet)
;;; core-yasnippet.el ends here

View file

@ -1,320 +1,195 @@
;;; The core of Narfy Emacs
;;; core.el --- The heart of the beast
;;
;;; Naming Conventions
;;; Naming conventions:
;;
;; narf/* public defun/variable
;; narf--* private defun/variable
;; narf|* hook defuns
;; narf:* interactive/keybind defuns
;; :* ex commands
;; narf-... A public variable/constant or function
;; narf--... An internal variable or function (non-interactive)
;; narf/... An autoloaded interactive function
;; narf:... An ex command
;; narf|... A hook
;; narf*... An advising function
;; ...! Macro
;;
;;; Bootstrap:
(setq package-enable-at-startup nil
debug-on-quit DEBUG-MODE)
(cd "~") ; instead of /
(require 'core-splash)
(unless (require 'autoloads nil t)
(load (concat narf-emacs-dir "scripts/generate-autoloads.el"))
(require 'autoloads))
;; This is kept separate so it can jumpstart emacs; this prevents the unstyled
;; flash of emacs pre-makeover.
(load-theme (if window-system DEFAULT-THEME TERM-THEME) t)
(when window-system
(set-frame-font DEFAULT-FONT)
(scroll-bar-mode -1) ; no scrollbar
(tool-bar-mode -1) ; no toolbar
(menu-bar-mode -1)) ; no menubar
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message ">> %s" "Are you pondering what I'm pondering, Pinky?")
(message "-----------------------------------------------------------------------------------")
(defun display-startup-echo-area-message ()
(message "-----------------------------------------------------------------------------------")
(message ">> %s\n>> Loaded in %s" (narf/random-comeback) (emacs-init-time)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defconst IS-MAC (eq system-type 'darwin))
(defconst IS-LINUX (eq system-type 'gnu/linux))
(defconst IS-WINDOWS (eq system-type 'windows-nt))
(require 'defuns)
(require 'core-vars)
(require 'core-defuns)
(require 'diminish)
;; NARF!
(defvar narf-mode-map (make-sparse-keymap))
(define-minor-mode narf-mode
"Narf, yoink, poit."
:global t :init-value t :lighter "NARF" :keymap narf-mode-map)
(defvar narf/leader-key ",")
(defvar narf/localleader-key "\\")
;; Make sure undo/backup folders exist
(defconst TMP-DIR-UNDO (expand-file-name "undo" TMP-DIR))
(defconst TMP-DIR-BACKUP (expand-file-name "backup" TMP-DIR))
(defconst TMP-DIR-AUTOSAVE (expand-file-name "autosave" TMP-DIR))
(unless (file-directory-p TMP-DIR)
(make-directory TMP-DIR-UNDO t)
(make-directory TMP-DIR-BACKUP t)
(make-directory TMP-DIR-AUTOSAVE t))
(fset 'yes-or-no-p 'y-or-n-p) ; y/n instead of yes/no
;;;; Sane defaults ;;;;;;;;;;;;;;;;;;;;;;;
(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)
;;; 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
;;; 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
confirm-kill-emacs nil
;; minibufferception? Yay!
enable-recursive-minibuffers t)
;; Show me those keystrokes
(setq echo-keystrokes 0.02
ring-bell-function 'ignore
inhibit-startup-screen t ; don't show EMACs start screen
inhibit-splash-screen t
;; inhibit-startup-message t
inhibit-startup-echo-area-message "hlissner"
;; inhibit-startup-buffer-menu t
initial-major-mode 'text-mode ; initial scratch buffer mode
initial-scratch-message nil
compilation-always-kill t
compilation-ask-about-save nil
compilation-scroll-output t
sentence-end-double-space nil ; sentences end with periods. Period.
ediff-diff-options "-w"
ediff-split-window-function 'split-window-horizontally ; side-by-side diffs
ediff-window-setup-function 'ediff-setup-windows-plain) ; no extra frames
;; 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 cursor location across sessions. Only save for files that exist.
(use-package saveplace
:init (defvar save-place-file (concat TMP-DIR "saveplace"))
:config (add-hook! 'find-file-hook (if (file-exists-p (buffer-file-name)) (setq save-place t))))
;; Save history across sessions
(use-package savehist
:config
(progn
(setq savehist-file (concat 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)))
(use-package recentf
:config
(progn
(setq recentf-save-file (concat TMP-DIR "recentf")
recentf-exclude '("/tmp/" "/ssh:" "\\.?ido\\.last$" "\\.revive$" "/TAGS$"
"/\\.cache/.+" "emacs\\.d/workgroups/.+$" ".emacs.workgroup"
"/company-statistics-cache.el$")
recentf-max-menu-items 0
recentf-max-saved-items 250
recentf-auto-cleanup 600)
(recentf-mode 1)))
;;;; Backup ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Disable all backups (that's what git/dropbox are for)
(setq bookmark-save-flag t
bookmark-default-file (concat TMP-DIR "bookmarks")
auto-save-default nil
auto-save-list-file-name (concat TMP-DIR-AUTOSAVE "auto-save")
auto-save-file-name-transforms `((".*" ,TMP-DIR-AUTOSAVE t))
;; In case I want to reactivate backup files
make-backup-files nil
create-lockfiles nil
backup-directory-alist `((".*" . ,TMP-DIR-BACKUP)))
;;;; Undo Tree ;;;;;;;;;;;;;;;;;;;;;;;;;
(setq-default ; Remember undo history
undo-tree-auto-save-history t
undo-tree-history-directory-alist `(("." . ,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))
;; Shut up undo-tree's constant complaining: http://youtu.be/Z6woIRLnbmE
(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, \.\.\.
(defadvice undo-tree-position (around undo-tree-position-silence-type-error activate)
(when (listp (ad-get-args 1)) ad-do-it))
;;;; Editor behavior ;;;;;;;;;;;;;;;;
(setq-default ; spaces instead of tabs
indent-tabs-mode nil
tab-always-indent t
tab-width 4)
(setq require-final-newline t
delete-trailing-lines nil)
;; Automatic minor modes ;;;;;;;;;;;
(defvar narf/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 narf|enable-minor-mode-maybe ()
"Check file name against `narf/auto-minor-mode-alist'."
(when buffer-file-name
(let ((name buffer-file-name)
(remote-id (file-remote-p buffer-file-name))
(alist narf/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 'narf|enable-minor-mode-maybe)
;;;; Utility plugins ;;;;;;;;;;;;;;;;;;
(use-package smex
:functions (smex-initialize smex-update)
:commands (smex smex-major-mode-commands)
:config
(progn
(setq smex-save-file (expand-file-name "smex-items" TMP-DIR))
(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
popwin:special-display-config
(append '(("\\`\\*helm.*?\\*\\'" :regexp t :position bottom :height 15)
("^\\*Flycheck.*\\*$" :regexp t :position bottom :height 0.25 :noselect t)
(inf-enh-ruby-mode :position bottom :stick t)
(snippet-mode :position bottom :stick t)
("^\\*eclim.*\\*" :regexp t :position bottom :height 0.25)
("*ansi-term*" :position bottom :height 0.45 :stick t)
("*terminal*" :position bottom :height 0.45 :stick t)
("*Async Shell Command*" :position bottom)
("*Shell Command Output*" :position bottom :stick t :height 15)
("* Regexp Explain *" :position top :height 0.35)
("*anaconda-doc*" :position bottom :height 15 :noselect t)
("*anaconda-nav*" :position bottom :height 15 :stick t)
("^\\*Python.+\\*$" :regexp t :position bottom :height 20 :noselect t)
("*Pp Eval Output*" :position bottom :height 10 :noselect t)
("*eval*" :position bottom :noselect t)
(help-mode :height 25 :position bottom :stick t)
(compilation-mode :height 0.5 :position bottom :noselect t)
(diff-mode :position bottom :stick t)
("*Backtrace*")
("*Warnings*")
("*Process List*")
("*Compile-Log*" :height 0.3 :position bottom :noselect t)
(" *undo-tree*" :width 0.3 :position right)
("^\\*scratch\\*.*" :regexp t :stick t)
(image-mode))
popwin:special-display-config))
(defun popwin:toggle-popup-window ()
(interactive)
(if (popwin:popup-window-live-p)
(popwin:close-popup-window)
(popwin:popup-last-buffer)))))
(use-package semantic
:commands semantic-mode
:init
(progn
(add-hook 'c-mode-common-hook 'semantic-mode)
(defvar semanticdb-default-system-save-directory (concat TMP-DIR "semanticdb"))
(defvar semanticdb-default-save-directory (concat TMP-DIR "semanticdb")))
:config
(semantic-mode 1))
;; Improved help commands
(use-package help-fns+
:commands (describe-buffer
describe-command
describe-file
describe-keymap
describe-option
describe-option-of-type))
(use-package server
:config (unless (server-running-p) (server-start)))
(define-minor-mode narf-mode "Narf, yoink, poit."
:global t
:init-value t
:lighter "NARF"
:keymap (make-sparse-keymap))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(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)))
(eval-when-compile
(require 's)
(require 'dash)
(require 'f)
(defvar use-package-verbose narf-debug-mode)
;; (setq use-package-expand-minimally (not narf-debug-mode))
(require 'use-package)
(defun use-package--add-keyword (keyword after)
(setq use-package-keywords
(-insert-at (-find-index (lambda (key) (eq key after)) use-package-keywords)
keyword use-package-keywords)))
(progn ; remap :bind to bind! macro instead of bind-keys
;; (defun use-package-handler/:bind
;; (name-symbol keyword arg rest state &optional override)
;; (let ((commands (mapcar #'cdr arg)))
;; (use-package-concat
;; (use-package-process-keywords name-symbol
;; (use-package-sort-keywords
;; (use-package-plist-maybe-put rest :defer t))
;; (use-package-plist-append state :commands commands))
;; `((ignore (,bind! ,@arg))))))
)
(progn ; add :after to use-package
(use-package--add-keyword :after :load-path)
(defalias 'use-package-normalize/:after 'use-package-normalize-symlist)
(defun use-package-handler/:after (name-symbol keyword arg rest state)
(let ((body (use-package-process-keywords name-symbol rest state)))
(if (null arg)
body
(use-package-concat
(use-package-process-keywords name-symbol
(use-package-sort-keywords (use-package-plist-maybe-put rest :defer t)) state)
(apply #'nconc
(mapcar (lambda (feature)
`((after! ,feature (require ',name-symbol))))
(delete-dups arg))))))))
;; Make any folders needed
(dolist (file '("" "undo" "backup"))
(let ((path (concat narf-temp-dir file)))
(unless (file-exists-p path)
(make-directory path t)))))
(defvar after-make-console-frame-hooks '()
"Hooks to run after creating a new TTY frame")
(defvar after-make-window-system-frame-hooks '()
"Hooks to run after creating a new window-system frame")
(defun run-after-make-frame-hooks (frame)
"Selectively run either `after-make-console-frame-hooks' or
`after-make-window-system-frame-hooks'"
(select-frame frame)
(run-hooks (if window-system
'after-make-window-system-frame-hooks
'after-make-console-frame-hooks)))
(add-hook 'after-make-frame-functions 'run-after-make-frame-hooks)
(add-hook! after-init (run-after-make-frame-hooks (selected-frame)))
;; Emacs configuration ;;;;;;;;;;;;;;;;;
;;; 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
(setq-default
confirm-kill-emacs (lambda (prompt) (y-or-n-p ">> Gee, I dunno Brain... Are you sure?"))
gc-cons-threshold 20000000 ; avoid garbage collection
enable-recursive-minibuffers t ; minibufferception
echo-keystrokes 0.02 ; show me those keystrokes
ring-bell-function 'ignore ; silence of the bells!
inhibit-startup-screen t ; don't show emacs start screen
inhibit-startup-echo-area-message "hlissner" ; username shuts up emacs
initial-major-mode 'text-mode ; initial scratch buffer mode
initial-scratch-message nil
compilation-always-kill t
compilation-ask-about-save nil
compilation-scroll-output t
sentence-end-double-space nil ; sentences end with periods. period.
ediff-diff-options "-w"
ediff-split-window-function 'split-window-horizontally ; side-by-side diffs
ediff-window-setup-function 'ediff-setup-windows-plain ; no extra frames
;; Don't save clipboard contents into kill-ring before replacing them
save-interprogram-paste-before-kill nil
;; Don't let the cursor go into minibuffer prompt
;; from Xah Lee: http://ergoemacs.org/emacs/emacs_stop_cursor_enter_prompt.html
minibuffer-prompt-properties
'(read-only t point-entered minibuffer-avoid-prompt face minibuffer-prompt)
;; remove annoying ellipsis when printing sexp in message buffer
eval-expression-print-length nil
eval-expression-print-level nil
history-length 1000
;; Backups ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Disable all backups (that's what git/dropbox are for)
bookmark-save-flag t
bookmark-default-file (! (concat narf-temp-dir "bookmarks"))
auto-save-default nil
auto-save-list-file-name (! (concat narf-temp-dir "autosave"))
;; In case I want to reactivate backup files
make-backup-files nil
create-lockfiles nil
backup-directory-alist `((".*" . ,(! (concat narf-temp-dir "backup/"))))
;; Remember undo history
undo-tree-auto-save-history t
undo-tree-history-directory-alist `(("." . ,(! (concat narf-temp-dir "undo/")))))
;; Save cursor location across sessions. Only save for files that exist.
(require 'saveplace)
(setq save-place-file (! (concat narf-temp-dir "saveplace")))
(add-hook! find-file (if (file-exists-p (buffer-file-name)) (setq save-place t)))
;; Save history across sessions
(require 'savehist)
(setq savehist-file (! (concat narf-temp-dir "savehist"))
savehist-additional-variables
'(kill-ring global-mark-ring search-ring regexp-search-ring extended-command-history))
(savehist-mode 1)
(require 'recentf)
(setq recentf-save-file (! (concat narf-temp-dir "recentf"))
recentf-exclude '("/tmp/" "/ssh:" "\\.?ido\\.last$" "\\.revive$" "/TAGS$"
"/\\.cache/.+" "emacs\\.d/workgroups/.+$" ".emacs.workgroup"
"/company-statistics-cache.el$")
recentf-max-menu-items 0
recentf-max-saved-items 250
recentf-auto-cleanup 600)
(recentf-mode 1)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package help-fns+ ; Improved help commands
:commands (describe-buffer describe-command describe-file
describe-keymap describe-option describe-option-of-type))
(use-package popwin :config (popwin-mode 1))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'server)
(unless (server-running-p)
(server-start))
(provide 'core)
;;; core.el ends here

View file

@ -1,289 +0,0 @@
;; Inspired by http://demonastery.org/2013/04/emacs-evil-narrow-region/
;;;###autoload
(defun narf:narrow-to-region-indirect (start end)
"Restrict editing in this buffer to the current region, indirectly."
(interactive "r")
(deactivate-mark)
(let ((buf (clone-indirect-buffer nil nil)))
(with-current-buffer buf
(narrow-to-region start end))
(switch-to-buffer buf)))
;;;###autoload
(defun narf:widen ()
(interactive)
(when (buffer-narrowed-p)
(widen)))
;;;###autoload
(defun narf:set-region-read-only (begin end)
"See http://stackoverflow.com/questions/7410125"
(let ((modified (buffer-modified-p)))
(add-text-properties begin end '(read-only t))
(set-buffer-modified-p modified)))
;;;###autoload
(defun narf:set-region-writeable (begin end)
"See http://stackoverflow.com/questions/7410125"
(let ((modified (buffer-modified-p))
(inhibit-read-only t))
(remove-text-properties begin end '(read-only t))
(set-buffer-modified-p modified)))
;;;###autoload
(defun narf/living-buffer-list (&optional buffer-list)
(-remove 'get-buffer-window (or buffer-list (buffer-list))))
;; Killing Buffers ;;;;;;;;;;;;;;;;;;;;;
;; Buffer defuns
(defvar narf/cleanup-buffers-list '("^ \\*"
"^\\*Backtrace\\*$"
"^\\*Warnings\\*$"
"^\\*Compile-Log\\*$"
"^\\*Ediff.*\\*$"
help-mode
image-mode
dired-mode
reb-mode)
"A list of buffer name regexps or major-mode symbols. If buried buffers
match/have that mode active, `narf:cleanup-buffers' will kill them.")
(defvar narf/cleanup-processes-alist '(("pry" . ruby-mode)
("irb" . ruby-mode)
("ipython" . python-mode))
"An alist of (process-name . major-mode), that `narf:cleanup-processes' checks
before killing processes. If there are no buffers with matching major-modes, it
gets killed.")
;;;###autoload
(defun narf/add-throwaway-buffer (regexp)
(add-to-list 'narf/cleanup-buffers-list regexp))
;;;###autoload
(defun narf:cleanup-buffers ()
"Kill left-over temporary, dired or buried special buffers"
(interactive)
(let* ((this-frame (selected-frame))
(kill-list (buffer-list this-frame)))
(setq kill-list
(-filter (lambda (b)
(unless (get-buffer-window b) ; don't kill if visible
(-any? (lambda (pred)
(cond ((stringp pred)
(s-matches? pred (buffer-name b)))
((symbolp pred)
(eq (buffer-local-value 'major-mode b) pred))))
narf/cleanup-buffers-list)))
kill-list))
(message "Cleaned up %s buffers" (length kill-list))
(mapc 'kill-buffer kill-list)
(narf:cleanup-processes)))
;;;###autoload
(defun narf:cleanup-processes ()
(interactive)
(let ((buffer-list (buffer-list)))
(dolist (p (process-list))
(let* ((process-name (process-name p))
(assoc (assoc process-name narf/cleanup-processes-alist)))
(when (and assoc
(not (string= process-name "server"))
(process-live-p p)
(not (-any? (lambda (b)
(let ((mode (buffer-local-value 'major-mode b)))
(eq mode (cdr assoc))))
buffer-list)))
(message "Cleanup: killing %s" process-name)
(delete-process p))))))
;;;###autoload
(defun narf:kill-matching-buffers (regexp &optional buffer-list)
(interactive)
(mapc (lambda (b)
(if (string-match-p regexp (buffer-name b))
(kill-buffer b)))
(if buffer-list buffer-list (buffer-list))))
(defun narf--cycle-real-buffer (&optional n)
"Switch to the previous buffer and avoid special buffers."
(interactive)
(let ((start-buffer (current-buffer))
(move-func (if (< n 0) 'switch-to-next-buffer 'switch-to-prev-buffer)))
(funcall move-func)
(let ((i 0))
(while (let ((current-buffer (current-buffer)))
(and (not (eq current-buffer start-buffer))
(not (eq current-buffer narf--project-scratch-buffer))
(< i 15)
(string-equal "*" (substring (buffer-name) 0 1))))
(cl-incf i)
(funcall move-func)))))
;; From spacemacs <https://github.com/syl20bnr/spacemacs/blob/master/spacemacs/funcs.el>
;;;###autoload
(defun narf:next-real-buffer ()
"Switch to the next buffer and avoid special buffers."
(interactive)
(narf--cycle-real-buffer +1))
;;;###autoload
(defun narf:previous-real-buffer ()
"Switch to the previous buffer and avoid special buffers."
(interactive)
(narf--cycle-real-buffer -1))
;;;###autoload
(defun narf:kill-real-buffer ()
"Kill buffer (but only bury scratch buffer)"
(interactive)
(let ((bname (buffer-name)))
(cond ((string-match-p "^\\*scratch\\*" bname)
(erase-buffer)
(bury-buffer))
((string-equal "*" (substring bname 0 1))
(previous-buffer))
(t (kill-this-buffer)))))
;;;###autoload (autoload 'narf::save-session "defuns-buffers")
(evil-define-command narf::save-session (&optional bang session-name)
(interactive "<!><a>")
(if session-name
(wg-save-session-as (concat wg-workgroup-directory session-name) (not bang))
(wg-save-session)))
;;;###autoload (autoload 'narf::load-session "defuns-buffers")
(evil-define-command narf::load-session (&optional bang session-name)
(interactive "<!><a>")
(wg-open-session (if session-name
(concat wg-workgroup-directory session-name)
wg-session-file)))
;;;###autoload (autoload 'narf::new-workgroup "defuns-buffers")
(evil-define-command narf::new-workgroup (bang name)
(interactive "<!><a>")
(unless name
(user-error "No name specified for new workgroup"))
(if bang
(wg-clone-workgroup (wg-current-workgroup) name)
(wg-create-workgroup name t)))
;;;###autoload (autoload 'narf::rename-workgroup "defuns-buffers")
(evil-define-command narf::rename-workgroup (new-name)
(interactive "<a>")
(wg-rename-workgroup new-name))
;;;###autoload (autoload 'narf::rename-this-file "defuns-buffers")
(evil-define-command narf::rename-this-file (new-name)
"Renames current buffer and file it is visiting. Replaces %, # and other
variables (see `evil-ex-replace-special-filenames')"
:repeat nil
(interactive "<f>")
(let ((name (buffer-name))
(filename (buffer-file-name)))
(if (not (and filename (file-exists-p filename)))
(error "Buffer '%s' is not visiting a file!" name)
(let ((new-name
(expand-file-name
(evil-ex-replace-special-filenames (if new-name
new-name
(read-file-name "New name: " filename)))
(f-dirname filename))))
(if (get-buffer new-name)
(error "A buffer named '%s' already exists!" new-name)
(rename-file filename new-name 1)
(rename-buffer new-name)
(set-visited-file-name new-name)
(set-buffer-modified-p nil)
(save-place-forget-unreadable-files)
(message "File '%s' successfully renamed to '%s'"
name (file-name-nondirectory new-name)))))))
;;;###autoload (autoload 'narf::delete-this-file "defuns-buffers")
(evil-define-command narf::delete-this-file (&optional bang)
"Delete current buffer's file. If bang, then kill the buffer afterwards as well."
:repeat nil
(interactive "<!>")
(let ((filename (file-truename (buffer-file-name))))
(if (not (file-exists-p filename))
(error "File doesn't exist: %s" filename)
(delete-file filename)
(when bang (kill-this-buffer))
(save-place-forget-unreadable-files)
(message "File successfully deleted: %s" filename))))
(defun narf--save-exit() (save-buffer) (kill-buffer) (remove-hook 'yas-after-exit-snippet-hook '--save-exit))
;;;###autoload (autoload 'narf::create-file "defuns-buffers")
(evil-define-command narf::create-file (path &optional bang)
"Deploy files (and their associated templates) quickly. Will prompt
you to fill in each snippet field before buffer closes unless BANG is
provided."
:repeat nil
(interactive "<f><!>")
(let ((dir (f-dirname path))
(fullpath (f-full path))
(is-auto t))
(when (and bang (not (file-exists-p dir))) (f-mkdir dir))
(if (file-exists-p dir)
(if (file-exists-p fullpath)
(error "File already exists: %s" path)
(find-file fullpath)
(add-hook 'yas-after-exit-snippet-hook 'narf--save-exit)
(if bang (--save-exit)))
(error "Directory doesn't exist: %s" dir))))
;;;###autoload (autoload 'narf::scratch-buffer "defuns-buffers")
(evil-define-operator narf::scratch-buffer (&optional beg end bang)
"Send a selection to the scratch buffer. If BANG, then send it to org-capture
instead."
:move-point nil
:type inclusive
(interactive "<r><!>")
(let ((mode major-mode)
(text (when (and (evil-visual-state-p) beg end)
(buffer-substring beg end))))
(if bang
;; use org-capture with bang
(if text
(org-capture-string text)
(org-capture))
;; or scratch buffer by default
(let* ((project-dir (narf/project-root t))
(buffer-name (if project-dir
(format "*scratch* (%s)" (narf/project-name))
"*scratch*")))
(popwin:popup-buffer (get-buffer-create buffer-name))
(when (eq (get-buffer buffer-name) (current-buffer))
(when project-dir
(cd project-dir))
(if text (insert text))
(funcall mode))))))
;;;###autoload (autoload 'narf::kill-buried-buffers "defuns-buffers")
(evil-define-command narf::kill-buried-buffers (&optional bang)
:repeat nil
(interactive "<!>")
(mapc 'kill-buffer
(narf/living-buffer-list (if bang (projectile-project-buffers) (buffer-list)))))
;;;###autoload (autoload 'narf::kill-buffers "defuns-buffers")
(evil-define-command narf::kill-buffers (&optional bang)
:repeat nil
(interactive "<!>")
(if (and (not bang) (projectile-project-p))
(projectile-kill-buffers)
(mapc 'kill-buffer (buffer-list)))
(delete-other-windows)
(switch-to-buffer (if (buffer-live-p narf--project-scratch-buffer)
narf--project-scratch-buffer
(get-buffer-create "*scratch*"))))
;;;###autoload (autoload 'narf::cd "defuns-buffers")
(evil-define-command narf::cd (dir)
:repeat nil
(interactive "<f>")
(cd (if (zerop (length dir)) "~" dir)))
(provide 'defuns-buffers)
;;; defuns-buffers.el ends here

View file

@ -1,126 +0,0 @@
;;;; HTML ;;;;
;;;###autoload
(defun narf:replace-ms-word-chars (beg end)
"Replace smart quotes and other MS Word verbiage into plain text"
(interactive "r")
(replace-regexp "" "..." nil beg end)
(replace-regexp "[]" "'" nil beg end)
(replace-regexp "[“”]" "\"" nil beg end))
;;;###autoload
(defun narf:replace-email2mailto (beg end)
"Email address with mailto link"
(interactive "r")
(replace-regexp "\\b\\([a-zA-Z0-9._+-%]+@[a-zA-Z0-9-.]+\\.[a-zA-Z]+\\)\\b"
"<a href=\"mailto:\\1\">\\1</a>"
nil beg end))
;;;###autoload
(defun narf:replace-url2anchor (beg end)
"Link with anchor"
(interactive "r")
(replace-regexp "\\bhttps?://.+?\\b"
"<a href=\"\\1\">\\1</a>"
nil beg end))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; A hacky attempt to replace ace-jump line mode that incrementally shows where
;; you will land as you type the line number.
(defun narf--goto-line (line)
(let ((lines (count-lines (point-min) (point-max))))
(if (and (<= line (1+ lines))
(> line 0))
(narf/nlinum-hl-line line)
(narf/nlinum-hl-line))))
;;;###autoload
(defun narf:goto-line ()
(interactive)
(let ((keys '())
(orig-point (point))
(echo-keystrokes 0))
(evil-save-echo-area
(catch 'abort
(while t
(let* ((keystr (concat keys))
(key (read-event (concat ":" keystr))))
(cond ((eq key 'escape)
(message "%s" key)
(throw 'abort t))
((eq key 'return)
(when keys
(goto-line (string-to-number keystr)))
(throw 'abort t))
((eq key 'backspace)
(let ((key-len (length keys)))
(if (= key-len 0)
(throw 'abort t)
(if (> key-len 1)
(progn
(nbutlast keys)
(narf--goto-line (string-to-number (concat keys))))
(setq keys '())
(narf/nlinum-hl-line)))))
((and (characterp key)
(s-numeric? (char-to-string key)))
(setq keys (append keys (list key)))
(narf--goto-line (string-to-number (concat keys))))
(t
(if (or (char-equal key ?\C-n)
(char-equal key ?\C-j))
(progn
(setq keys (number-to-string (1+ (string-to-number (concat keys)))))
(narf--goto-line (string-to-number (concat keys))))
(when (or (char-equal key ?\C-p)
(char-equal key ?\C-k))
(setq keys (number-to-string (1- (string-to-number (concat keys)))))
(narf--goto-line (string-to-number (concat keys)))))))))))))
;;;###autoload (autoload 'narf::align "defuns-edit")
(evil-define-command narf::align (beg end &optional regexp bang)
:repeat nil
(interactive "<r><a><!>")
(when regexp
(align-regexp beg end
(concat "\\(\\s-*\\)" (rxt-pcre-to-elisp regexp)) 1 1)))
;;;###autoload (autoload 'narf::retab "defuns-edit")
(evil-define-operator narf::retab (beg end)
"Akin to vim's narf::retab, this changes all tabs-to-spaces or spaces-to-tabs,
depending on `indent-tab-mode'. Untested."
:motion nil
:move-point nil
:type line
(interactive "<r>")
(unless (and beg end)
(setq beg (point-min))
(setq end (point-max)))
(if indent-tabs-mode
(tabify beg end)
(untabify beg end)))
;;;###autoload (autoload 'narf::narrow-indirect-or-widen "defuns-edit")
(evil-define-operator narf::narrow-indirect-or-widen (beg end)
"Indirectly narrow the region from BEG to END."
:move-point nil
:type exclusive
:repeat nil
(interactive "<r>")
(evil-normal-state)
(if (buffer-narrowed-p)
(narf:widen)
(narf:narrow-to-region-indirect beg end)))
;;;###autoload
(defun narf:toggle-delete-trailing-whitespace ()
(interactive)
(if (-contains-p before-save-hook 'delete-trailing-whitespace)
(progn (narf|disable-delete-trailing-whitespace)
(message "delete-trailing-whitespaces OFF"))
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(message "delete-trailing-whitespaces ON")))
(provide 'defuns-edit)
;;; defuns-edit.el ends here

View file

@ -1,39 +0,0 @@
;;;###autoload
(defun narf/mouse-line-at-click ()
"Determine the line number at click"
(save-excursion
(let ((click-y (cddr (mouse-position)))
(debug-on-error t)
(line-move-visual t))
(goto-char (window-start))
(next-line (1- click-y))
(1+ (line-number-at-pos)))))
;;;###autoload
(defun narf/mouse-select-line (event)
"Set point as *linum-mdown-line*"
(interactive "e")
(mouse-select-window event)
(goto-line (narf/mouse-line-at-click))
(evil-visual-line)
(setq *linum-mdown-line* (line-number-at-pos)))
;;;###autoload
(defun narf/mouse-select-block ()
"Select the current block of text between blank lines."
(interactive)
(let (p1 p2)
(progn
(if (re-search-backward "\n[ \t]*\n" nil "move")
(progn (re-search-forward "\n[ \t]*\n")
(setq p1 (point)))
(setq p1 (point)))
(if (re-search-forward "\n[ \t]*\n" nil "move")
(progn (re-search-backward "\n[ \t]*\n")
(setq p2 (point)))
(setq p2 (point))))
(set-mark p1)))
(provide 'defuns-mouse)
;;; defuns-mouse.el ends here

View file

@ -1,106 +0,0 @@
;;;###autoload
(defun narf:ido-find-file (&optional dir)
(interactive)
(let ((default-directory (or dir default-directory)))
(ido-find-file)))
;;;###autoload
(defun narf:ido-find-file-other-window (&optional dir)
(interactive)
(let ((default-directory (or dir default-directory)))
(ido-find-file-other-window)))
;;;###autoload
(defun narf:ido-find-project-file ()
(interactive)
(let ((default-directory (narf/project-root)))
(ido-find-file)))
;;;###autoload (autoload 'narf::initfiles "defuns-search")
(evil-define-command narf::initfiles (&optional bang) :repeat nil
(interactive "<!>")
(if bang
(ido-find-file-in-dir MODULES-DIR)
(ido-find-file-in-dir BASE-DIR)))
;;;###autoload (autoload 'narf::notes "defuns-search")
(evil-define-command narf::notes () :repeat nil
(interactive)
(require 'org)
(ido-find-file-in-dir org-directory))
;; Ex-mode interface for `helm-recentf' and `helm-projectile-recentf'. If
;; `bang', then `search' is interpreted as regexp
;;;###autoload (autoload 'narf::recentf "defuns-search")
(evil-define-command narf::recentf (&optional bang)
:repeat nil
(interactive "<!>")
(if bang (helm-recentf) (helm-projectile-recentf)))
;; Ex-mode interface for `helm-ag'. If `bang', then `search' is interpreted as
;; regexp.
;;;###autoload (autoload 'narf::ag-search "defuns-search")
(evil-define-operator narf::ag-search (beg end &optional search hidden-files-p pwd-p regex-p)
:type inclusive
:repeat nil
(interactive "<r><a><!>")
(helm-alive-p)
(let* ((helm-ag-default-directory (if pwd-p default-directory (narf/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)))
;;;###autoload (autoload 'narf::ag-regex-search "defuns-search")
(evil-define-operator narf::ag-regex-search (beg end &optional search bang)
:type inclusive :repeat nil
(interactive "<r><a><!>")
(narf::ag-search beg end search bang nil t))
;;;###autoload (autoload 'narf::ag-regex-cwd "defuns-search")
(evil-define-operator narf::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 "<r><a><!>")
(narf::ag-search beg end search bang t nil))
;;;###autoload (autoload 'narf::ag-regex-search-cwd "defuns-search")
(evil-define-operator narf::ag-regex-search-cwd (beg end &optional search bang)
:type inclusive :repeat nil
(interactive "<r><a><!>")
(narf::ag-search beg end search bang t t))
;; 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'
;;;###autoload (autoload 'narf::swoop "defuns-search")
(evil-define-command narf::swoop (&optional search bang)
:repeat nil
(interactive "<a><!>")
(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))))
;; TODO: Implement helm-find-file
;;;###autoload (autoload 'narf::snippets "defuns-search")
(evil-define-command narf::snippets (&optional bang)
(interactive "<!><a>")
(if bang
(narf:ido-find-file SNIPPETS-DIR)
(helm-yas-visit-snippet-file)))
(provide 'defuns-search)
;;; defuns-search.el ends here

View file

@ -1,299 +0,0 @@
(require 's)
(require 'dash)
(require 'f)
;; Compatibility ;;;;;;;;;;;;;;;;;;;
;; Backwards compatible `with-eval-after-load'
(unless (fboundp 'with-eval-after-load)
(defmacro with-eval-after-load (file &rest body)
`(eval-after-load ,file
`(funcall (function ,(lambda () ,@body))))))
(defmacro after (feature &rest forms)
(declare (indent defun))
`(,(if (or (not (boundp 'byte-compile-current-file))
(not byte-compile-current-file)
(if (symbolp feature)
(require feature nil :no-error)
(load feature :no-message :no-error)))
'progn
(message "after: cannot find %s" feature)
'with-no-warnings)
(with-eval-after-load ',feature ,@forms)))
(defmacro shut-up (&rest body)
"Silence message output from code."
(declare (indent defun))
`(let (message-log-max)
,@body
(message "")))
(eval-when-compile
;; Convenience ;;;;;;;;;;;;;;;;;;;;;
(defmacro λ (&rest body)
"A shortcut for: `(lambda () (interactive) ,@body)"
`(lambda () (interactive) ,@body))
(defmacro associate-mode (match mode)
"Associate a major mode with a filepath through `auto-mode-alist'"
`(add-to-list 'auto-mode-alist (cons ,match ,mode)))
(defmacro associate-minor-mode (match mode)
"Associate a minor mode with a filepath through `auto-minor-mode-alist'"
`(add-to-list 'narf/auto-minor-mode-alist (cons ,match ,mode)))
;; (defmacro add-to-mode (mode funcs))
;; (defmacro add-to-modes (func modes)
;; (add-to-hooks))
(defmacro add-to-hook (hook funcs)
"Add a series of FUNCS to a hook. FUNCS can be a list."
(declare (indent 1))
`(progn ,@(mapcar (lambda (func) `(add-hook ',(eval hook) ',func)) (eval funcs))))
(defmacro add-to-hooks (func hooks)
"Add one FUNC to a series of hooks. HOOKS can be a list."
(declare (indent 1))
`(progn ,@(mapcar (lambda (hook) `(add-hook ',hook ',(eval func))) (eval hooks))))
(defmacro add-hook! (hook &rest body)
"A shortcut macro for `add-hook' that auto-wraps `body' in a lambda"
(declare (indent 1))
`(add-hook ,hook (lambda() ,@body)))
;; Keybindings ;;;;;;;;;;;;;;;;;;;;;;;;;
(after "evil"
(defmacro excmd (command func)
"An alternative to `evil-ex-define-cmd' that won't choke on autoload
functions being registered as ex commands."
`(evil-ex-define-cmd ,command ,func))
(defmacro excmd! (command func)
`(evil-ex-define-cmd ,command (lambda () (interactive) (call-interactively ,func))))
(defmacro bind (&rest keys)
"A minimalistic and evil-centric way of binding keys. KEYS is
made up of either:
1. Any of the following keywords:
:if CONDITION Determines where these keymaps should be set.
:prefix PREFIX Key(s) to prefix keymappings with
:map KEYMAP Keymaps to bind keys to. Can be a list.
:global Tags these keymaps for the global keymap
:local Ditto, but for local keymap
:leader Like :prefix ?,
:localleader Like :prefix ?\\
:<evil state> e.g. :normal ;visual and so on. Anything that
`evil-state-p' recognizes You can stack to
make a key present in more than one state.
2. A key (as a vector e.g. [escape], a string \"<escape>\", or
character ?\^?).
3. A key definition: a symbol or a lambda function. "
(declare (indent 9999))
(let* ((condition t)
(default-keymaps '(narf-mode-map))
(keymaps default-keymaps)
(forms '())
(consecutive t)
(states '())
prefix local-p
key def)
(while keys
(setq key (pop keys))
(cond ((or (evil-state-p key)
(and (listp key)
(--all? (evil-state-p it) key)))
(setq states (-list key)))
((keywordp key)
(cl-case key
(:prefix
(let ((val (pop keys)))
(cond ((or (stringp val)
(characterp val)
(vectorp val))
(setq prefix val))
((eq val 'leader)
(setq prefix narf/leader-key))
((eq val 'localleader)
(setq prefix narf/localleader-key))
(t (signal 'bind-invalid-prefix prefix)))))
(:map
(let ((val (pop keys)))
(cond ((or (symbolp val) (listp val))
(setq keymaps (-list val)))
((null val)
(setq keymaps default-keymaps))
(t (signal 'bind-invalid-keymaps '(key val))))))
(:if (setq condition (pop keys)))
(:local (setq local-p (pop keys)))
;; TODO: Deprecated
(otherwise
(let ((keyword (intern-soft (substring (symbol-name key) 1)))
(next-key (cadr keys)))
(when (evil-state-p keyword)
(setq local-p nil)
(if consecutive
(cl-pushnew keyword states)
(setq states (list keyword))))
(setq consecutive t)))))
;; key-definition pairs
((or (stringp key)
(vectorp key)
(characterp key))
(unless keys (signal 'bind-no-definition key))
(setq def (pop keys))
(when condition
;; Process the key
(cond ((stringp key) (setq key (kbd key)))
((characterp key) (setq key (string key))))
(when prefix
(setq key (if (vectorp key)
(vconcat prefix key)
(concat (kbd prefix) key))))
;; Do the binding
(if (null states)
(dolist (keymap keymaps)
(add-to-list 'forms `(define-key ,keymap ,key ,def) t))
(dolist (state (-list states))
(when local-p
(setq keymaps (list (make-symbol (format "evil-%s-state-local-mode-map" state)))))
(dolist (keymap keymaps)
(add-to-list 'forms `(define-key ,(if local-p keymap `(evil-get-auxiliary-keymap ,keymap ',state t)) ,key ,def) t)))))
(setq consecutive nil))
;; fallback
(t (signal 'bind-invalid-key key))))
(when DEBUG-MODE (message "%s" forms))
`(progn ,@forms)))))
(after "evil"
(evil-define-command narf:exit-mode-maybe ()
"Exits insert mode using jk without the momentary pause caused by
key-chord-define."
:repeat change
(interactive)
(let ((modified (buffer-modified-p)))
(call-interactively 'self-insert-command)
(let ((evt (read-event nil nil 0.4)))
(cond
((null evt) (message ""))
((and (integerp evt) (char-equal evt ?k))
(if (evil-replace-state-p)
(evil-replace-backspace)
(delete-char -1))
(set-buffer-modified-p modified)
(push 'escape unread-command-events))
(t
(setq unread-command-events (append unread-command-events (list evt)))))))))
;; Hooks ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun narf|enable-comment-hard-wrap ()
(set (make-local-variable 'comment-auto-fill-only-comments) t)
(turn-on-auto-fill))
(defun narf|enable-hard-wrap ()
(turn-on-auto-fill))
(defun narf|enable-tab-width-2 ()
(setq tab-width 2 evil-shift-width 2))
(defun narf|enable-tab-width-4 ()
(setq tab-width 4 evil-shift-width 4))
(defun narf|disable-final-newline ()
(set (make-local-variable 'require-final-newline) nil))
(defun narf|enable-tabs ()
(setq indent-tabs-mode t))
(defun narf|disable-tabs ()
(setq indent-tabs-mode nil))
(defun narf|disable-delete-trailing-whitespace ()
(remove-hook 'before-save-hook 'delete-trailing-whitespace))
;;;; Global Defuns ;;;;;;;;;;;;;;;;;;;;;
(defun narf/minibuffer-quit ()
"Abort recursive edit. In Delete Selection mode, if the mark is
active, just deactivate it; then it takes a second \\[keyboard-quit]
to abort the minibuffer."
(interactive)
(let (message-log-max)
(if (and delete-selection-mode transient-mark-mode mark-active)
(setq deactivate-mark t)
(when (get-buffer "*Completions*")
(delete-windows-on "*Completions*"))
(abort-recursive-edit))))
;;;; Project defuns ;;;;;;;;;;;;;;;;;;;;
(defvar narf/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 narf/project-root (&optional strict-p)
"Get the path to the root of your project. Uses `narf/project-root-files' to
determine if a directory is a project."
(let ((home (file-truename "~")))
(catch 'found
(f-traverse-upwards
(lambda (path)
(let ((path (file-truename path)))
(if (file-equal-p home path)
(throw 'found (if strict-p nil default-directory))
(dolist (file narf/project-root-files)
(when (file-exists-p (expand-file-name file path))
(throw 'found path)))))) default-directory)
default-directory)))
(defun narf/project-has-files (files &optional root)
"Return non-nil if `file' exists in the project root."
(let ((root (or root (narf/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 (file-exists-p (narf/project-path-to file root))))
found-p))
(defun narf/project-path-to (file &optional root)
(let ((root (or root (narf/project-root))))
(expand-file-name file root)))
(defun narf/project-name (&optional root)
(file-name-nondirectory (directory-file-name (or root (narf/project-root)))))
(defun narf/project-p ()
(not (null (narf/project-root t))))
;; Make sure scratch buffer is always "in a project"
(defvar narf--project-scratch-buffer nil)
(defun narf/project-create-scratch-buffer ()
(let* ((scratch-buffer (get-buffer-create "*scratch*"))
(root (narf/project-root t))
(project-name (narf/project-name root))
(current-buffer (current-buffer)))
(when root
(mapc (lambda (b)
(when (and (string-match-p "\\*scratch\\* (.+)" (buffer-name b))
(not (eq current-buffer b))
(= (buffer-size b) 0))
(kill-buffer b)))
(buffer-list))
(save-window-excursion
(switch-to-buffer scratch-buffer)
(setq narf--project-scratch-buffer scratch-buffer)
(erase-buffer)
(cd root)
(rename-buffer (format "*scratch* (%s)" project-name))))))
(add-hook 'find-file-hook 'narf/project-create-scratch-buffer)
(provide 'defuns)
;; defuns.el ends here

214
core/lib/defuns-buffers.el Normal file
View file

@ -0,0 +1,214 @@
;;; defuns-buffers.el
;;;###autoload
(defun narf:narrow (start end)
"Restrict editing in this buffer to the current region, indirectly.
Inspired from http://demonastery.org/2013/04/emacs-evil-narrow-region/"
(interactive "r")
(deactivate-mark)
(let ((buf (clone-indirect-buffer nil nil)))
(with-current-buffer buf
(narrow-to-region start end))
(switch-to-buffer buf)))
;;;###autoload
(defun narf:widen ()
(interactive)
(when (buffer-narrowed-p)
(widen)))
;;;###autoload
(defun narf/set-read-only-region (begin end)
"See http://stackoverflow.com/questions/7410125"
(let ((modified (buffer-modified-p)))
(add-text-properties begin end '(read-only t))
(set-buffer-modified-p modified)))
;;;###autoload
(defun narf/set-region-writeable (begin end)
"See http://stackoverflow.com/questions/7410125"
(let ((modified (buffer-modified-p))
(inhibit-read-only t))
(remove-text-properties begin end '(read-only t))
(set-buffer-modified-p modified)))
;; Killing Life and Death ;;;;;;;;;;;;;;
;;;###autoload
(defun narf:kill-real-buffer ()
"Kill buffer (but only bury scratch buffer), then switch to a living buffer."
(interactive)
(let ((bname (buffer-name)))
(cond ((string-match-p "^\\*scratch\\*" bname)
(erase-buffer)
(bury-buffer))
((string-equal "*" (substring bname 0 1)))
(t (kill-this-buffer))))
(unless (narf/real-buffer-p (current-buffer))
(narf/previous-real-buffer)))
;;;###autoload
(defun narf/get-visible-buffers (&optional buffer-list)
"Get a list of buffers that are not buried (i.e. visible)"
(-remove #'get-buffer-window (or buffer-list (buffer-list))))
;;;###autoload
(defun narf/get-buried-buffers (&optional buffer-list)
"Get a list of buffers that are buried (i.e. not visible)"
(-filter #'get-buffer-window (or buffer-list (buffer-list))))
;;;###autoload
(defun narf/get-matching-buffers (pattern &optional buffer-list)
"Get a list of buffers that match the pattern"
(--filter (string-match-p pattern (buffer-name it)) (or buffer-list (buffer-list))))
;;;###autoload
(defun narf/get-real-buffers(&optional buffer-list)
(-filter (lambda (buffer)
(not (--any? (if (stringp it)
(string-match-p it (buffer-name buffer))
(eq (buffer-local-value 'major-mode buffer) it))
narf-unreal-buffers)))
(or buffer-list (buffer-list))))
;;;###autoload
(defun narf:kill-unreal-buffers ()
"Kill all buried, unreal buffers in current frame. See `narf-unreal-buffers'"
(interactive)
(let* ((real-buffers (narf/get-real-buffers))
(kill-list (--filter (not (memq it real-buffers)) narf/get-buried-buffers)))
(message "Cleaned up %s buffers" (length kill-list))
(mapc 'kill-buffer kill-list)
(narf:kill-process-buffers)))
;;;###autoload
(defun narf:kill-process-buffers ()
"Kill all buffers that represent running processes and aren't visible."
(interactive)
(let ((buffer-list (buffer-list)))
(dolist (p (process-list))
(let* ((process-name (process-name p))
(assoc (assoc process-name narf-cleanup-processes-alist)))
(when (and assoc
(not (string= process-name "server"))
(process-live-p p)
(not (--any? (let ((mode (buffer-local-value 'major-mode it)))
(eq mode (cdr assoc)))
buffer-list)))
(message "Cleanup: killing %s" process-name)
(delete-process p))))))
;;;###autoload
(defun narf:kill-matching-buffers (regexp &optional buffer-list)
(interactive)
(mapc (lambda (b)
(if (string-match-p regexp (buffer-name b))
(kill-buffer b)))
(if buffer-list buffer-list (buffer-list))))
;;;###autoload
(defun narf/cycle-real-buffers (&optional n)
"Switch to the previous buffer and avoid special buffers. If there's nothing
left, create a scratch buffer."
(let ((start-buffer (current-buffer))
(move-func (if (< n 0) 'switch-to-next-buffer 'switch-to-prev-buffer))
(real-buffers (narf/get-real-buffers)))
(funcall move-func)
(while (let ((current-buffer (current-buffer)))
(and (if (eq current-buffer start-buffer)
(ignore (switch-to-buffer "*scratch*"))
t)
(not (= n 0))
(not (eq current-buffer start-buffer))
(not (memq current-buffer real-buffers))))
(setq n (1- n))
(funcall move-func))))
;;;###autoload
(defun narf/real-buffer-p (&optional buffer-or-name)
(let ((buffer (if buffer-or-name (get-buffer buffer-or-name) (current-buffer))))
(when (buffer-live-p buffer)
(not (--any? (if (stringp it)
(string-match-p it (buffer-name buffer))
(eq (buffer-local-value 'major-mode buffer) it))
narf-unreal-buffers)))))
;; From spacemacs <https://github.com/syl20bnr/spacemacs/blob/master/spacemacs/funcs.el>
;;;###autoload
(defun narf/next-real-buffer ()
"Switch to the next buffer and avoid special buffers."
(interactive)
(narf/cycle-real-buffers +1))
;;;###autoload
(defun narf/previous-real-buffer ()
"Switch to the previous buffer and avoid special buffers."
(interactive)
(narf/cycle-real-buffers -1))
;;;###autoload (autoload 'narf:kill-buried-buffers "defuns-buffers" nil t)
(evil-define-command narf:kill-buried-buffers (&optional bang)
:repeat nil
(interactive "<!>")
(narf:kill-buried-buffers)
(mapc 'kill-buffer
(narf/get-buried-buffers (if bang (projectile-project-buffers) (buffer-list)))))
;;;###autoload (autoload 'narf:kill-all-buffers "defuns-buffers" nil t)
(evil-define-command narf:kill-all-buffers (&optional bang)
"Kill all project buffers. If BANG, kill *all* buffers."
:repeat nil
(interactive "<!>")
(if (and (not bang) (projectile-project-p))
(projectile-kill-buffers)
(mapc 'kill-buffer (buffer-list)))
(delete-other-windows)
(unless (narf/real-buffer-p)
(narf/previous-real-buffer)))
;;;###autoload (autoload 'narf:scratch-buffer "defuns-buffers" nil t)
(evil-define-operator narf:scratch-buffer (&optional beg end bang)
"Send a selection to the scratch buffer. If BANG, then send it to org-capture
instead."
:move-point nil
:type inclusive
(interactive "<r><!>")
(let ((mode major-mode)
(text (when (and (evil-visual-state-p) beg end)
(buffer-substring beg end))))
(if bang
;; use org-capture with bang
(if text
(org-capture-string text)
(org-capture))
;; or scratch buffer by default
(let* ((project-dir (narf/project-root t))
(buffer-name "*scratch*"))
(popwin:popup-buffer (get-buffer-create buffer-name))
(when (eq (get-buffer buffer-name) (current-buffer))
(when project-dir
(cd project-dir))
(if text (insert text))
(funcall mode))))))
;;;###autoload (autoload 'narf:cd "defuns-buffers" nil t)
(evil-define-command narf:cd (dir)
:repeat nil
(interactive "<f>")
(cd (if (zerop (length dir)) "~" dir)))
;;;###autoload
(defun narf/kill-all-buffers-do-not-remember ()
(interactive)
(let ((confirm-kill-emacs nil))
(mapc 'kill-buffer (buffer-list))
(kill-this-buffer)
(delete-other-windows)
(wg-save-session t)
(save-buffers-kill-terminal)))
(provide 'defuns-buffers)
;;; defuns-buffers.el ends here

View file

@ -0,0 +1,18 @@
;;; defuns-company.el
;;;###autoload
(defun narf/company-evil-complete-next ()
(call-interactively 'company-dabbrev)
(if (eq company-candidates-length 1)
(company-complete)))
;;;###autoload
(defun narf/company-evil-complete-previous ()
(let ((company-selection-wrap-around t))
(call-interactively 'company-dabbrev)
(if (eq company-candidates-length 1)
(company-complete)
(call-interactively 'company-select-previous))))
(provide 'defuns-company)
;;; defuns-company.el ends here

View file

@ -0,0 +1,33 @@
;;; defuns-compile.el
;; (eval-when-compile (require 'core))
;;;###autoload
(defun narf/is-compilable-p ()
(let ((file-name (buffer-file-name)))
;; TODO Detect init.el and init-load-path.el
(--any? (f-child-of? file-name it)
(append (list narf-core-dir narf-contrib-dir)
(list (concat narf-modules-dir "lib/")
(concat narf-core-dir "lib/"))
(list narf-modules-dir narf-private-dir)))))
;;;###autoload (autoload 'narf:compile-el "defuns-compile" nil t)
(evil-define-command narf:compile-el (&optional bang)
:repeat nil
(interactive "<!>")
(byte-recompile-file (f-expand "init.el" narf-emacs-dir) nil 0)
(byte-recompile-file (f-expand "init-load-path.el" narf-emacs-dir) nil 0)
(byte-recompile-file (f-expand "core.el" narf-core-dir) t 0)
(if (and (eq major-mode 'emacs-lisp-mode) (not bang))
(byte-recompile-file (buffer-file-name) t 0)
(load (concat narf-script-dir "byte-compile.el"))))
;;;###autoload (autoload 'narf:compile-autoloads "defuns-compile" nil t)
(evil-define-command narf:compile-autoloads (&optional bang)
:repeat nil
(interactive "<!>")
(load (concat narf-script-dir "generate-autoloads.el")))
(provide 'defuns-compile)
;;; defuns-compile.el ends here

View file

@ -1,4 +1,5 @@
;; Misc Defuns ;;;;;;;;;;;;;;;;;;;;;;;;;
;;; defuns-debug.el
;;;###autoload
(defun what-face (pos)
"Tells you the name of the face (point) is on."
@ -19,12 +20,12 @@
(local-key-binding key)
(global-key-binding key)))
;;;###autoload (autoload 'narf::echo "defuns-debug")
(evil-define-command narf::echo (message)
;;;###autoload (autoload 'narf:echo "defuns-debug" nil t)
(evil-define-command narf:echo (bang message)
"Display MSG in echo-area without logging it in *Messages* buffer."
(interactive "<a>")
(interactive "<!><a>")
(let (message-log-max)
(message "%s" message)))
(message "%s%s" (if bang ">> " "") message)))
(provide 'defuns-debug)
;;; defuns-debug.el ends here

57
core/lib/defuns-editor.el Normal file
View file

@ -0,0 +1,57 @@
;;; defuns-editor.el
;; for ../core-editor.el
;; A hacky attempt to replace ace-jump line mode that incrementally shows where
;; you will land as you type the line number.
(defun narf--goto-line (line)
(let ((lines (count-lines (point-min) (point-max))))
(if (and (<= line (1+ lines))
(> line 0))
(narf/nlinum-hl-line line)
(narf/nlinum-hl-line))))
;;;###autoload
(defun narf/editor-goto-line ()
(interactive)
(let ((keys '())
(orig-point (point))
(echo-keystrokes 0))
(evil-save-echo-area
(catch 'abort
(while t
(let* ((keystr (concat keys))
(key (read-event (concat ":" keystr))))
(cond ((eq key 'escape)
(message "%s" key)
(throw 'abort t))
((eq key 'return)
(when keys
(goto-line (string-to-number keystr)))
(throw 'abort t))
((eq key 'backspace)
(let ((key-len (length keys)))
(if (= key-len 0)
(throw 'abort t)
(if (> key-len 1)
(progn
(nbutlast keys)
(narf--goto-line (string-to-number (concat keys))))
(setq keys '())
(narf/nlinum-hl-line)))))
((and (characterp key)
(s-numeric? (char-to-string key)))
(setq keys (append keys (list key)))
(narf--goto-line (string-to-number (concat keys))))
(t
(if (or (char-equal key ?\C-n)
(char-equal key ?\C-j))
(progn
(setq keys (number-to-string (1+ (string-to-number (concat keys)))))
(narf--goto-line (string-to-number (concat keys))))
(when (or (char-equal key ?\C-p)
(char-equal key ?\C-k))
(setq keys (number-to-string (1- (string-to-number (concat keys)))))
(narf--goto-line (string-to-number (concat keys)))))))))))))
(provide 'defuns-editor)
;;; defuns-editor.el ends here

66
core/lib/defuns-evil.el Normal file
View file

@ -0,0 +1,66 @@
;;; defuns-evil.el
;; for ../core-evil.el
;;;###autoload (autoload 'narf:evil-open-folds "defuns-evil" nil t)
(evil-define-command narf/evil-open-folds (count)
"Instead of `evil-open-folds'. Accepts COUNT for dictating fold level."
(interactive "P")
(unless (bound-and-true-p hs-minor-mode)
(hs-minor-mode 1))
(if count (hs-hide-level count) (evil-open-folds)))
;;;###autoload (autoload 'narf:evil-open-folds "defuns-evil" nil t)
(evil-define-command narf/evil-close-folds (count)
"Instead of `evil-close-folds'. Accepts COUNT for dictating fold level."
(interactive "P")
(unless (bound-and-true-p hs-minor-mode)
(hs-minor-mode 1))
(if count (hs-hide-level count) (evil-close-folds)))
;;;; Ace Jump ;;;;;;;;;;;;;;;;;;;;;;;;;;
;; https://github.com/winterTTr/ace-jump-mode/issues/23
;;;###autoload (autoload 'narf:evil-ace-jump-two-chars "defuns-evil" nil t)
(evil-define-motion narf/evil-ace-jump-two-chars (count)
:type exclusive
:repeat abort
(evil-without-repeat
(evil-enclose-ace-jump-for-motion
(call-interactively 'ace-jump-two-chars-mode))))
;;;###autoload
(defun narf/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)))
;;;###autoload
(defun narf:iedit-restrict-to-region ()
(interactive)
(if (iedit-current-occurrence-string)
(let ((current-prefix-arg '(4)))
(iedit-done)
(call-interactively 'iedit-mode)
(save-excursion (iedit-restrict-region (region-beginning) (region-end)))
(evil-previous-line))
(call-interactively 'evil-ret)))
;;;###autoload
(defun narf*evil-exchange-off ()
(when evil-exchange--overlays
(evil-exchange-cancel)))
;;;###autoload
(defun narf/evil-surround-escaped ()
"Escaped surround characters."
(let* ((char (string (read-char "\\")))
(pair (cond ((string-match "[]})[{(]" char)
(let ((-pair (cdr (assoc (string-to-char char) evil-surround-pairs-alist))))
`(,(car -pair) . ,(cdr -pair))))
(t
`(,char . ,char))))
(format (if (sp-point-in-string) "\\\\%s" "\\%s")))
(cons (format format (car pair))
(format format (cdr pair)))))
(provide 'defuns-evil)
;;; defuns-evil.el ends here

61
core/lib/defuns-file.el Normal file
View file

@ -0,0 +1,61 @@
;;; defuns-file.el
;;;###autoload (autoload 'narf:file-delete "defuns-file" nil t)
(evil-define-command narf:file-delete (&optional bang filename)
"Delete current buffer's file. If bang, then kill the buffer afterwards as well."
:repeat nil
(interactive "<!><f>")
(let ((filename (file-truename (or filename (buffer-file-name)))))
(if (not (file-exists-p filename))
(error "File doesn't exist: %s" filename)
(delete-file filename)
(when bang
(kill-this-buffer)
(unless (narf/real-buffer-p)
(narf/previous-real-buffer)))
(save-place-forget-unreadable-files)
(message "File successfully deleted: %s" filename))))
(defun narf--save-exit() (save-buffer) (kill-buffer) (remove-hook 'yas-after-exit-snippet-hook '--save-exit))
;;;###autoload (autoload 'narf:file-create "defuns-file" nil t)
(evil-define-command narf:file-create (path &optional bang)
"Deploy files (and their associated templates) quickly. Will prompt
you to fill in each snippet field before buffer closes unless BANG is
provided."
:repeat nil
(interactive "<f><!>")
(let ((dir (f-dirname path))
(fullpath (f-full path))
(is-auto t))
(when (and bang (not (file-exists-p dir))) (f-mkdir dir))
(if (file-exists-p dir)
(if (file-exists-p fullpath)
(error "File already exists: %s" path)
(find-file fullpath)
(add-hook 'yas-after-exit-snippet-hook 'narf--save-exit)
(if bang (narf--save-exit)))
(error "Directory doesn't exist: %s" dir))))
;;;###autoload (autoload 'narf:file-move "defuns-file" nil t)
(evil-define-command narf:file-move (path)
"Move current buffer's file to PATH. Replaces %, # and other variables (see
`evil-ex-replace-special-filenames')"
:repeat nil
(interactive "<f>")
(let* ((old-path (buffer-file-name))
(new-path (cond ((f-dir? path)
(f-expand (f-filename old-path) path))
((f-dir? (f-dirname path))
(f-full path))
(t (user-error "Not a valid destination: %s" path))))
(project-root (narf/project-root)))
(rename-file old-path new-path 1)
(rename-buffer (f-filename new-path))
(set-visited-file-name new-path)
(set-buffer-modified-p nil)
(save-place-forget-unreadable-files)
(message "File '%s' successfully renamed to '%s'"
(f-relative old-path project-root) (f-relative new-path project-root))))
(provide 'defuns-file)
;;; defuns-file.el ends here

View file

@ -0,0 +1,30 @@
;;; defuns-flycheck.el
;; for ../core-flycheck.el
;;;###autoload
(defun narf*fly-shorter-status (result)
(format "[%s]" (replace-regexp-in-string " FlyC:?" "" result)))
;;;###autoload
(defun narf*flycheck-buffer ()
(if (and (featurep 'flycheck) flycheck-mode)
(flycheck-buffer)))
;;;###autoload
(defun narf/flycheck-next-error ()
(interactive)
(call-interactively
(if (bound-and-true-p flycheck-mode)
'flycheck-next-error
'next-error)))
;;;###autoload
(defun narf/flycheck-previous-error ()
(interactive)
(call-interactively
(if (bound-and-true-p flycheck-mode)
'flycheck-previous-error
'previous-error)))
(provide 'defuns-flycheck)
;;; defuns-flycheck.el ends here

115
core/lib/defuns-helm.el Normal file
View file

@ -0,0 +1,115 @@
;;; defuns-helm.el
;; see ../core-helm.el
;;;###autoload
(defun narf|projectile-invalidate-cache-maybe ()
(when (narf/project-p)
(projectile-invalidate-cache nil)))
;;;###autoload
(defun narf*projectile-replace-prompt (&optional string)
"Don't show the project name in the prompts; I already know."
helm-global-prompt)
;;;###autoload
(defun narf*helm-hide-modeline (source &optional force)
"No persistent header."
(setq mode-line-format nil)
(setq header-line-format nil))
;;;###autoload
(defun narf/helm-split-window (window)
"Minimalistic split-fn; leaves popwin to handle helm buffers."
(if (one-window-p t)
(let ((helm-full-frame t))
(selected-window))
(other-window-for-scrolling)))
;;;###autoload
(defun narf/helm-get-org-candidates-in-file (filename min-depth max-depth &optional fontify nofname)
(with-current-buffer (pcase filename
((pred bufferp) filename)
((pred stringp) (find-file-noselect filename)))
(and fontify (jit-lock-fontify-now))
(let ((match-fn (if fontify 'match-string 'match-string-no-properties)))
(save-excursion
(goto-char (point-min))
(cl-loop with width = (window-width)
while (re-search-forward org-complex-heading-regexp nil t)
if (let ((num-stars (length (match-string-no-properties 1))))
(and (>= num-stars min-depth) (<= num-stars max-depth)))
collect `(,(let ((heading (funcall match-fn 4))
(file (unless nofname
(concat (f-no-ext (f-relative filename org-directory)) ":")))
(level (length (match-string-no-properties 1))))
(org-format-outline-path
(append (org-get-outline-path t level heading)
(list heading)) width file))
. ,(point-marker)))))))
;;;###autoload (autoload 'narf:helm-recentf "defuns-helm" nil t)
(evil-define-command narf:helm-recentf (&optional bang)
"Ex-mode interface for `helm-recentf' and `helm-projectile-recentf'. If
`bang', then `search' is interpreted as regexp."
:repeat nil
(interactive "<!>")
(if bang (helm-recentf) (helm-projectile-recentf)))
;; Ex-mode interface for `helm-ag'. If `bang', then `search' is interpreted as
;; regexp.
;;;###autoload (autoload 'narf:helm-search "defuns-helm" nil t)
(evil-define-operator narf:helm-search (beg end &optional search hidden-files-p pwd-p regex-p)
:type inclusive
:repeat nil
(interactive "<r><a><!>")
(require 'helm-ag)
(let* ((helm-ag--default-directory (if pwd-p default-directory (concat (narf/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)))
;;;###autoload (autoload 'narf:helm-regex-search "defuns-helm" nil t)
(evil-define-operator narf:helm-regex-search (beg end &optional search bang)
:type inclusive :repeat nil
(interactive "<r><a><!>")
(narf:helm-search beg end search bang nil t))
;;;###autoload (autoload 'narf:helm-regex-cwd "defuns-helm" nil t)
(evil-define-operator narf:helm-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 "<r><a><!>")
(narf:helm-search beg end search bang t nil))
;;;###autoload (autoload 'narf:helm-regex-search-cwd "defuns-helm" nil t)
(evil-define-operator narf:helm-regex-search-cwd (beg end &optional search bang)
:type inclusive :repeat nil
(interactive "<r><a><!>")
(narf:helm-search beg end search bang t t))
;; 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'
;;;###autoload (autoload 'narf:helm-swoop "defuns-helm" nil t)
(evil-define-command narf:helm-swoop (&optional search bang)
:repeat nil
(interactive "<a><!>")
(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 'defuns-helm)
;;; defuns-helm.el ends here

65
core/lib/defuns-ido.el Normal file
View file

@ -0,0 +1,65 @@
;;; defuns-ido.el
;;;###autoload
(defun narf*ido-sort-mtime ()
"Sort ido filelist by mtime instead of alphabetically."
(setq ido-temp-list
(sort ido-temp-list
(lambda (a b)
(time-less-p
(sixth (file-attributes (concat ido-current-directory b)))
(sixth (file-attributes (concat ido-current-directory a)))))))
(ido-to-end ;; move . files to end (again)
(delq nil (mapcar
(lambda (x) (and (char-equal (string-to-char x) ?.) x))
ido-temp-list))))
;;;###autoload
(defun narf|ido-setup-home-keybind ()
"Go to $HOME with ~"
(define-key ido-file-completion-map (kbd "~")
(λ (if (looking-back "/")
(insert "~/")
(call-interactively 'self-insert-command)))))
;;;###autoload
(defun narf/ido-find-file (&optional dir)
(interactive)
(let ((default-directory (or dir default-directory)))
(ido-find-file)))
;;;###autoload
(defun narf/ido-find-file-other-window (&optional dir)
(interactive)
(let ((default-directory (or dir default-directory)))
(ido-find-file-other-window)))
;;;###autoload
(defun narf/ido-find-project-file ()
(interactive)
(let ((default-directory (narf/project-root)))
(ido-find-file)))
;;;###autoload
(defun narf/ido-find-org-file ()
(interactive)
(let ((default-directory org-directory))
(ido-find-file)))
;;;###autoload
(defun narf/ido-recentf ()
"Use `ido-completing-read' to \\[find-file] a recent file"
(interactive)
(if (find-file (ido-completing-read "Find recent file: " recentf-list))
(message "Opening file...")
(message "Aborting")))
;;;###autoload (autoload 'narf:ido-find-file-in-emacsd "defuns-ido" nil t)
(evil-define-command narf:ido-find-file-in-emacsd (&optional bang) :repeat nil
(interactive "<!>")
(if bang
(ido-find-file-in-dir narf-modules-dir)
(ido-find-file-in-dir narf-emacs-dir)))
(provide 'defuns-ido)
;;; defuns-ido.el ends here

View file

@ -0,0 +1,34 @@
;;; defuns-isearch.el
;;;###autoload
(defun narf/isearch-delete-word ()
(interactive)
(let ((num (length isearch-string))
(string (s-reverse isearch-string)))
(when (string-match "[^a-zA-Z0-9]" string 1)
(setq num (match-beginning 0)))
(dotimes (i num)
(isearch-pop-state))
(isearch-update)))
;;;###autoload
(defun narf/isearch-delete-line ()
(interactive)
(let ((num (length isearch-string)))
(dotimes (i num) (isearch-pop-state))
(isearch-update)))
;;;###autoload
(defun narf/isearch-paste-from-register (reg)
(interactive)
(let ((str (evil-get-register reg t)))
(when (> (length str) 0)
(isearch-yank-string str))))
;;;###autoload
(defun narf/isearch-paste-from-clipboard ()
(interactive)
(narf:isearch-paste-from-register ?+))
(provide 'defuns-isearch)
;;; defuns-isearch.el ends here

View file

@ -0,0 +1,40 @@
;;; defuns-neotree.el
;; for ../core-project.el
;;;###autoload
(defun narf/neotree-open (&optional dir)
(interactive)
(neotree-dir (or dir (narf/project-root))))
;;;###autoload
(defun narf/neotree-toggle ()
(interactive)
(if (neo-global--window-exists-p)
(neotree-hide)
(narf/neotree-open)))
;;;###autoload
(defun narf/neotree-find ()
(interactive)
(save-excursion (narf/neotree-open))
(neotree-find))
;;;###autoload
(defun narf|neotree-close-on-window-change ()
"Close neotree to prevent ensuing mindow buggery."
(unless (and (neo-global--window-exists-p)
(eq (current-buffer) (neo-global--get-buffer)))
(neotree-hide)))
;;;###autoload
(defun narf*neo-buffer-fold-symbol (name)
"Custom hybrid ascii theme with leading whitespace."
(let ((n-insert-symbol (lambda (n)
(neo-buffer--insert-with-face
n 'neo-expand-btn-face))))
(or (and (equal name 'open) (funcall n-insert-symbol "- "))
(and (equal name 'close) (funcall n-insert-symbol "> "))
(and (equal name 'leaf) (funcall n-insert-symbol " ")))))
(provide 'defuns-neotree)
;;; defuns-neotree.el ends here

11
core/lib/defuns-nlinum.el Normal file
View file

@ -0,0 +1,11 @@
;;; defuns-nlinum.el
;;;###autoload
(defun narf/nlinum-toggle ()
(interactive)
(if nlinum-mode
(narf|nlinum-disable)
(narf|nlinum-enable)))
(provide 'defuns-nlinum)
;;; defuns-nlinum.el ends here

11
core/lib/defuns-popwin.el Normal file
View file

@ -0,0 +1,11 @@
;;; defuns-popwin.el
;;;###autoload
(defun narf/popwin-toggle ()
(interactive)
(if (popwin:popup-window-live-p)
(popwin:close-popup-window)
(popwin:popup-last-buffer)))
(provide 'defuns-popwin)
;;; defuns-popwin.el ends here

View file

@ -0,0 +1,44 @@
;;; defuns-project.el
;;;###autoload
(defun narf/project-root (&optional strict-p)
"Get the path to the root of your project. Uses `narf-project-root-files' to
determine if a directory is a project."
(let ((home (file-truename "~")))
(catch 'found
(f-traverse-upwards
(lambda (path)
(let ((path (file-truename path)))
(if (file-equal-p home path)
(throw 'found (if strict-p nil default-directory))
(dolist (file narf-project-root-files)
(when (file-exists-p (expand-file-name file path))
(throw 'found path)))))) default-directory)
default-directory)))
;;;###autoload
(defun narf/project-has-files (files &optional root)
"Return non-nil if `file' exists in the project root."
(let ((root (or root (narf/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 (file-exists-p (narf/project-path-to file root))))
found-p))
;;;###autoload
(defun narf/project-path-to (file &optional root)
(let ((root (or root (narf/project-root))))
(expand-file-name file root)))
;;;###autoload
(defun narf/project-name (&optional root)
(file-name-nondirectory (directory-file-name (or root (narf/project-root)))))
;;;###autoload
(defun narf/project-p ()
(not (null (narf/project-root t))))
(provide 'defuns-project)
;;; defuns-project.el ends here

View file

@ -1,4 +1,7 @@
;;; defuns-quickrun.el
;;;; Code building ;;;;;;;;;;;;;;;;;;;;;;
;;;###autoload
(defvar narf--build-command '("make %s" . "Makefile"))
(make-variable-buffer-local 'narf--build-command)
@ -8,8 +11,8 @@
(narf/project-has-files file))
(setq narf--build-command `(,command . ,file))))
;;;###autoload (autoload 'narf::build "defuns-code")
(evil-define-command narf::build (arg)
;;;###autoload (autoload 'narf:build "defuns-quickrun" nil t)
(evil-define-command narf: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."
@ -22,18 +25,17 @@ If ARG is nil this function calls `recompile', otherwise it calls
(compile (format "cd '%s' && %s" build-file (format build-cmd (or arg ""))))
(error "Could not find Makefile"))))
;;;; Code running ;;;;;;;;;;;;;;;;;;;;;;
;;;###autoload (autoload 'narf::eval "defuns-code")
(evil-define-operator narf::eval ()
;;;###autoload (autoload 'narf:eval-buffer "defuns-quickrun" nil t)
(evil-define-command narf:eval-buffer ()
:move-point nil
(interactive)
(cond ((region-active-p)
(narf::eval-region (region-beginning) (region-end)))
(t (narf::eval-buffer))))
(cond ((eq major-mode 'emacs-lisp-mode)
(narf:eval-region (point-min) (point-max)))
(t (quickrun))))
;;;###autoload (autoload 'narf::eval-region "defuns-code")
(evil-define-operator narf::eval-region (beg end)
;;;###autoload (autoload 'narf:eval-region "defuns-quickrun" nil t)
(evil-define-operator narf:eval-region (beg end)
:move-point nil
(interactive "<r>")
(cond ((eq major-mode 'emacs-lisp-mode)
@ -49,21 +51,13 @@ If ARG is nil this function calls `recompile', otherwise it calls
(setq-local scroll-margin 0)
(erase-buffer)
(insert out)
(beginning-of-buffer)
(goto-char (point-min))
(read-only-mode 1)
(popwin:popup-buffer buf :height (if (> lines 25) 25 (1+ lines))))))))
(t (quickrun-region beg end))))
;;;###autoload (autoload 'narf::eval-buffer "defuns-code")
(evil-define-command narf::eval-buffer ()
:move-point nil
(interactive)
(cond ((eq major-mode 'emacs-lisp-mode)
(narf::eval-region (point-min) (point-max)))
(t (quickrun))))
;;;###autoload (autoload 'narf::eval-region-and-replace "defuns-code")
(evil-define-operator narf::eval-region-and-replace (beg end)
;;;###autoload (autoload 'narf:eval-region-and-replace "defuns-quickrun" nil t)
(evil-define-operator narf:eval-region-and-replace (beg end)
(interactive "<r>")
(cond ((eq major-mode 'emacs-lisp-mode)
(kill-region beg end)
@ -74,10 +68,5 @@ If ARG is nil this function calls `recompile', otherwise it calls
(insert (current-kill 0)))))
(t (quickrun-replace-region beg end))))
;;;###autoload
(defun narf/get-interpreter ()
(car (--first (eq (cdr it) major-mode) interpreter-mode-alist)))
(provide 'defuns-code)
;;; defuns-code.el ends here
(provide 'defuns-quickrun)
;;; defuns-quickrun.el ends here

View file

@ -1,7 +1,6 @@
;;; defuns-extern.el -- for external operations
;;; defuns-tmux.el
;;;###autoload
(defun narf/tmux-send (command)
(defun narf--tmux-send (command)
(shell-command (format "tmux send-keys %s" command)))
(evil-define-interactive-code "<tmux>"
@ -9,8 +8,8 @@
:ex-arg shell
(list (when (evil-ex-p) (evil-ex-file-arg))))
;;;###autoload (autoload 'narf::tmux-run "defuns-extern")
(evil-define-command narf::tmux-run (&optional command bang)
;;;###autoload (autoload 'narf:tmux-run "defuns-tmux" nil t)
(evil-define-command narf:tmux-run (&optional command bang)
"Sends input to tmux. Use `bang' to append to tmux"
(interactive "<tmux><!>")
(nerf/tmux-send (format (if bang "C-u %s Enter" "%s")
@ -18,8 +17,8 @@
(when (evil-ex-p)
(message "[Tmux] %s" command)))
;;;###autoload (autoload 'narf::tmux-chdir "defuns-extern")
(evil-define-command narf::tmux-chdir (&optional path bang)
;;;###autoload (autoload 'narf:tmux-chdir "defuns-tmux" nil t)
(evil-define-command narf:tmux-chdir (&optional path bang)
"CDs in tmux using `narf/project-root'"
(interactive "<f><!>")
(let ((dir (shell-quote-argument
@ -32,6 +31,5 @@
(when (evil-ex-p)
(message "[Tmux] cd %s" dir))))
(provide 'defuns-extern)
;;; defuns-extern.el ends here
(provide 'defuns-tmux)
;;; defuns-tmux.el ends here

View file

@ -1,4 +1,5 @@
(eval-when-compile (require 'cl))
;;; defuns-ui.el
;; for ../core-ui.el
;;;###autoload
(defun narf:toggle-transparency ()
@ -15,13 +16,14 @@
(set-frame-parameter nil 'fullscreen
(when (not (frame-parameter nil 'fullscreen)) 'fullboth)))
(defconst BIG-FONT (font-spec :family "Inconsolata" :size 18 :antialias t))
(defvar narf--big-mode nil)
;;;###autoload
(defun narf:toggle-big-mode ()
(interactive)
(if narf--big-mode
(set-frame-font DEFAULT-FONT)
(set-frame-font BIG-FONT))
(set-frame-font (apply #'font-spec narf-default-font))
(set-frame-font (apply #'font-spec narf-big-font)))
(setq narf--big-mode (not narf--big-mode)))
(provide 'defuns-ui)
;;; defuns-ui.el ends here

View file

@ -1,3 +1,5 @@
;;; defuns-whitespace.el
;;;###autoload
(defun narf--point-at-bol-non-blank()
(save-excursion (evil-first-non-blank) (point)))
@ -10,7 +12,7 @@
(looking-at-p match-str))))
;;;###autoload
(defun narf:backward-kill-to-bol-and-indent ()
(defun narf/backward-kill-to-bol-and-indent ()
"Kill line to the first non-blank character. If invoked again
afterwards, kill line to column 1."
(interactive)
@ -20,7 +22,7 @@ afterwards, kill line to column 1."
(indent-according-to-mode))))
;;;###autoload
(defun narf:move-to-bol ()
(defun narf/move-to-bol ()
"Moves cursor to the first non-blank character on the line. If
already there, move it to the true bol."
(interactive)
@ -33,7 +35,7 @@ already there, move it to the true bol."
(evil-first-non-blank))))))
;;;###autoload
(defun narf:move-to-eol ()
(defun narf/move-to-eol ()
(interactive)
(evil-save-goal-column
(let ((old-point (point)))
@ -46,7 +48,7 @@ already there, move it to the true bol."
;; Mimic expandtab in vim
;;;###autoload
(defun narf:backward-delete-whitespace-to-column ()
(defun narf/backward-delete-whitespace-to-column ()
"Delete back to the previous column of whitespace, or as much
whitespace as possible, or just one char if that's not possible."
(interactive)
@ -67,13 +69,13 @@ whitespace as possible, or just one char if that's not possible."
(save-match-data
(if (string-match "\\w*\\(\\s-+\\)$"
(buffer-substring-no-properties (- p movement) p))
(sp-backward-delete-char (- (match-end 1) (match-beginning 1)))
(backward-delete-char (- (match-end 1) (match-beginning 1)))
(backward-delete-char-untabify 1)))))
;; Otherwise do a regular delete
(t (backward-delete-char-untabify 1))))
;;;###autoload
(defun narf:dumb-indent ()
(defun narf/dumb-indent ()
"Inserts a tab character (or spaces x tab-width). Checks if the
auto-complete window is open."
(interactive)
@ -84,7 +86,7 @@ auto-complete window is open."
(insert (s-repeat spaces " ")))))
;;;###autoload
(defun narf:inflate-space-maybe ()
(defun narf/inflate-space-maybe ()
"Checks if point is surrounded by {} [] () delimiters and adds a
space on either side of the point if so."
(interactive)
@ -94,10 +96,10 @@ space on either side of the point if so."
(call-interactively 'self-insert-command)))
;;;###autoload
(defun narf:deflate-space-maybe ()
(defun narf/deflate-space-maybe ()
"Checks if point is surrounded by {} [] () delimiters, and deletes
spaces on either side of the point if so. Resorts to
`narf:backward-delete-whitespace-to-column' otherwise."
`narf/backward-delete-whitespace-to-column' otherwise."
(interactive)
(save-match-data
(if (narf/surrounded-p)
@ -110,26 +112,56 @@ spaces on either side of the point if so. Resorts to
(save-excursion (delete-char 1)))
(t
(just-one-space 0))))
(narf:backward-delete-whitespace-to-column))))
(narf/backward-delete-whitespace-to-column))))
;;;###autoload
(defun narf:newline-and-indent ()
(defun narf/newline-and-indent ()
(interactive)
(cond
((sp-point-in-string)
(newline))
((sp-point-in-comment)
(cond ((eq major-mode 'js2-mode)
(js2-line-break))
((-contains? '(java-mode php-mode) major-mode)
(c-indent-new-comment-line))
((-contains? '(c-mode c++-mode objc-mode css-mode scss-mode) major-mode)
(newline-and-indent)
(insert "* ")
(indent-according-to-mode))
(t (indent-new-comment-line))))
(t (newline-and-indent))))
(cond ((sp-point-in-string)
(newline))
((sp-point-in-comment)
(cond ((eq major-mode 'js2-mode)
(js2-line-break))
((-contains? '(java-mode php-mode) major-mode)
(c-indent-new-comment-line))
((-contains? '(c-mode c++-mode objc-mode css-mode scss-mode) major-mode)
(newline-and-indent)
(insert "* ")
(indent-according-to-mode))
(t (indent-new-comment-line))))
(t (newline-and-indent))))
;;;###autoload (autoload 'narf:whitespace-retab "defuns-whitespace" nil t)
(evil-define-operator narf:whitespace-retab (beg end)
"Akin to vim's retab, this changes all tabs-to-spaces or spaces-to-tabs,
depending on `indent-tab-mode'. Untested."
:motion nil
:move-point nil
:type line
(interactive "<r>")
(unless (and beg end)
(setq beg (point-min))
(setq end (point-max)))
(if indent-tabs-mode
(tabify beg end)
(untabify beg end)))
(provide 'defuns-text)
;;; defuns-text.el ends here
;;;###autoload (autoload 'narf:whitespace-align "defuns-whitespace" nil t)
(evil-define-command narf:whitespace-align (beg end &optional regexp bang)
:repeat nil
(interactive "<r><a><!>")
(when regexp
(align-regexp beg end
(concat "\\(\\s-*\\)" (rxt-pcre-to-elisp regexp)) 1 1)))
;;;###autoload
(defun narf:toggle-delete-trailing-whitespace ()
(interactive)
(if (memq 'delete-trailing-whitespace before-save-hook)
(progn (message "Remove trailing whitespace: OFF")
(remove-hook 'before-save-hook 'delete-trailing-whitespace))
(message "Remove trailing whitespace: ON")
(add-hook 'before-save-hook 'delete-trailing-whitespace)))
(provide 'defuns-whitespace)
;;; defuns-whitespace.el ends here

View file

@ -0,0 +1,56 @@
;;; defuns-workgroup.el
;;;###autoload
(defun narf/wg-helm-switch-to-workgroup (name)
(wg-switch-to-workgroup (wg-get-workgroup name)))
;;;###autoload
(defun narf:helm-wg ()
(interactive)
(helm :sources '(narf/helm-source-wg)))
;;;###autoload
(defun narf/wg-projectile-switch-project ()
(let ((workgroup-name (file-name-nondirectory (directory-file-name (narf/project-root)))))
(wg-create-workgroup workgroup-name t)
(helm-projectile-find-file)))
;;;###autoload (autoload 'narf:save-session "defuns-workgroup" nil t)
(evil-define-command narf:save-session (&optional bang session-name)
(interactive "<!><a>")
(if session-name
(wg-save-session-as (concat wg-workgroup-directory session-name) (not bang))
(wg-save-session)))
;;;###autoload (autoload 'narf:load-session "defuns-workgroup" nil t)
(evil-define-command narf:load-session (&optional bang session-name)
(interactive "<!><a>")
(wg-open-session (if session-name
(concat wg-workgroup-directory session-name)
wg-session-file)))
;;;###autoload (autoload 'narf:workgroup-new "defuns-workgroup" nil t)
(evil-define-command narf:workgroup-new (bang name)
(interactive "<!><a>")
(unless name
(user-error "No name specified for new workgroup"))
(if bang
(wg-clone-workgroup (wg-current-workgroup) name)
(wg-create-workgroup name t)))
;;;###autoload (autoload 'narf:workgroup-rename "defuns-workgroup" nil t)
(evil-define-command narf:workgroup-rename (new-name)
(interactive "<a>")
(wg-rename-workgroup new-name))
;;;###autoload
(defun narf:kill-other-workgroups ()
"Kill all other workgroups."
(interactive)
(let (workgroup (wg-current-workgroup))
(dolist (w (wg-workgroup-list))
(unless (wg-current-workgroup-p w)
(wg-kill-workgroup w)))))
(provide 'defuns-workgroup)
;;; defuns-workgroup.el ends here

View file

@ -0,0 +1,120 @@
;;; defuns-yasnippet.el
;; for ../core-yasnippet.el
;;;###autoload
(defun narf|yas-before-expand ()
"Switch to insert mode when expanding a template via backtab, or go back to
normal mode if there are no fields."
;; Strip out the shitespace before a line selection.
(when (narf/evil-visual-line-state-p)
(setq yas-selected-text
(replace-regexp-in-string
"\\(^ *\\|\n? $\\)" ""
(buffer-substring-no-properties (region-beginning)
(1- (region-end))))))
(evil-insert-state +1))
;;;###autoload
(defun narf|yas-after-expand ()
"Switch to insert mode when expanding a template via backtab, or go back to
normal mode if there are no fields."
(setq yas-selected-text nil))
;;;###autoload
(defun narf/yas-insert-snippet ()
"Switch to insert mode when expanding a template via backtab, or go back to
normal mode if there are no fields."
(interactive)
(yas-insert-snippet)
(evil-insert-state +1))
;;;###autoload
(defun narf/yas-goto-start-of-field ()
"Go to the beginning of a field."
(interactive)
(let* ((snippet (car (yas--snippets-at-point)))
(position (yas--field-start (yas--snippet-active-field snippet))))
(if (= (point) position)
(move-beginning-of-line 1)
(goto-char position))))
;;;###autoload
(defun narf/yas-goto-end-of-field ()
(interactive)
(let* ((snippet (car (yas--snippets-at-point)))
(position (yas--field-end (yas--snippet-active-field snippet))))
(if (= (point) position)
(move-end-of-line 1)
(goto-char position))))
;;;###autoload
(defun narf/yas-backspace (&optional field)
"Prevents Yas from stepping on my toes when I use backspace."
(interactive)
(let ((field (or field (and yas--active-field-overlay
(overlay-buffer yas--active-field-overlay)
(overlay-get yas--active-field-overlay 'yas--field)))))
(cond ((eq (point) (marker-position (yas--field-start field))) nil)
(t (delete-char -1)))))
;;;###autoload
(defun narf/yas-delete (&optional field)
(interactive)
(let ((field (or field (and yas--active-field-overlay
(overlay-buffer yas--active-field-overlay)
(overlay-get yas--active-field-overlay 'yas--field)))))
(cond ((and field
(not (yas--field-modified-p field))
(eq (point) (marker-position (yas--field-start field))))
(yas--skip-and-clear field)
(yas-next-field 1))
((eq (point) (marker-position (yas--field-end field))) nil)
(t (delete-char 1)))))
;;;###autoload
(defun narf/yas-clear-to-sof (&optional field)
(interactive)
(let* ((field (or field (and yas--active-field-overlay
(overlay-buffer yas--active-field-overlay)
(overlay-get yas--active-field-overlay 'yas--field))))
(sof (marker-position (yas--field-start field))))
(when (and field (> (point) sof))
(delete-region sof (point)))))
;; Snippet helpers ;;;;;;;;;;;;;;;;;;;;;
;;;###autoload
(defun !%! ()
"Snippet function. Shorthand defun to surround text with newlines if more
than one line."
(when %
(if (> (length (s-lines %)) 1)
(concat "\n" % "\n")
(s-trim %))))
;;;###autoload
(defun !% ()
"Snippet function. Shorthand defun for snippets: prepends a newline to
`yas-selected-text' IF it contains more than one line."
(when %
(if (> (length (s-lines %)) 1)
(concat "\n" %)
(s-trim %))))
;;;###autoload
(defun %1 ()
"Trim selection; do no further processing."
(s-trim %))
;;;###autoload (autoload 'narf:yas-snippets "defuns-yasnippet" nil t)
(evil-define-command narf:yas-snippets (&optional bang)
(interactive "<!>")
(if bang
(narf/ido-find-file (car narf-snippet-dirs))
(yas-visit-snippet-file)))
;;;###autoload
(defun narf:yas-file-templates ()
(interactive)
(narf/ido-find-file (cdr narf-snippet-dirs)))
(provide 'defuns-yasnippet)
;;; nlinum-defuns.el ends here

View file

@ -0,0 +1,18 @@
;;; macros-auto-insert.el
;; for ../core-auto-insert.el
;;;###autoload
(defmacro add-template! (regexp-or-major-mode uuid yas-mode &optional project-only)
`(define-auto-insert ,regexp-or-major-mode
(lambda ()
(unless (or (and ,project-only (not (narf/project-p)))
(not (or (eq major-mode ,yas-mode)
(symbol-value ,yas-mode))))
(insert ,uuid)
(yas-expand-from-trigger-key)
(if (string-equal ,uuid (s-trim (buffer-string)))
(erase-buffer)
(evil-insert-state 1))))))
(provide 'macros-auto-insert)
;;; macros-auto-insert.el ends here

View file

@ -0,0 +1,8 @@
;;; defuns-buffers.el
;;;###autoload
(defun add-unreal-buffer! (regexp)
(add-to-list 'narf-unreal-buffers regexp))
(provide 'defuns-buffers)
;;; defuns-buffers.el ends here

View file

@ -0,0 +1,22 @@
;;; macros-company.el --- macros for company-mode
;; for ../core-company.el
;;;###autoload
(defmacro add-company-backend! (hook backends)
"Register a company backend for a mode."
(let ((def-name (intern (format "narf--init-company-%s" hook)))
(quoted (eq (car-safe backends) 'quote)))
`(progn
(defun ,def-name ()
(set (make-local-variable 'company-backends)
(append '((,@(mapcar (lambda (backend)
(if quoted
backend
(intern (format "company-%s" backend))))
(if quoted (cadr backends) backends))
company-semantic))
company-backends)))
(add-hook ',(intern (format "%s-hook" hook)) ',def-name))))
(provide 'macros-company)
;;; macros-company.el ends here

13
core/lib/macros-popwin.el Normal file
View file

@ -0,0 +1,13 @@
;;; macros-popwin.el
;;;###autoload
(defmacro add-popwin-rule! (&rest forms)
"Register a rule for popwin. See `popwin:special-display-config'.
Example:
(add-popwin-rule! \"^\\*Flycheck.*\\*$\" :regexp t :position bottom :height 0.25 :noselect t)"
(declare (indent defun))
`(push '(,@forms) popwin:special-display-config))
(provide 'macros-popwin)
;;; macros-popwin.el ends here

View file

@ -0,0 +1,13 @@
;;; macros-quickrun.el
;;;###autoload
(defmacro build-for! (mode command build-file)
"Register major/minor MODE with build COMMAND. If FILES are provided, do an
additional check to make sure they exist in the project root."
`(add-hook! ,mode
(when (or (null ,build-file)
(narf/project-has-files ,build-file))
(setq narf--build-command '(,command . ,build-file)))))
(provide 'macros-quickrun)
;;; macros-quickrun.el ends here

View file

@ -0,0 +1,17 @@
;;; macros-yasnippet.el
;; for ../core-yasnippet.el
;;;###autoload
(defmacro add-yas-minor-mode! (&rest modes)
"Register minor MODES in yasnippet."
`(after! yasnippet
(when (boundp 'yas-extra-modes)
,@(mapcar (lambda (mode)
`(after! ,(cadr mode)
(if (symbol-value ,mode)
(yas-activate-extra-mode ,mode)
(setq yas-extra-modes (delq ,mode yas-extra-modes)))))
modes))))
(provide 'macros-yasnippet)
;;; macros-yasnippet.el ends here

View file

@ -1,39 +0,0 @@
(defconst BASE-DIR user-emacs-directory)
(defconst CORE-DIR (eval-when-compile (concat BASE-DIR "core/")))
(defconst MODULES-DIR (eval-when-compile (concat BASE-DIR "init/")))
(defconst CONTRIB-DIR (eval-when-compile (concat BASE-DIR "contrib/")))
(defconst THEMES-DIR (eval-when-compile (concat BASE-DIR "themes/")))
(defconst SNIPPETS-DIR (eval-when-compile (concat BASE-DIR "snippets/")))
(defconst ELPA-DIR (eval-when-compile (concat BASE-DIR ".cask/" emacs-version "/elpa/")))
(defconst TMP-DIR (eval-when-compile (concat BASE-DIR ".cache-" (system-name) "/")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(eval-when-compile
(defmacro narf/init-load-path ()
"Collect and verify `load-path'. Compile me!"
(let (paths '())
(dolist (dir (append (directory-files ELPA-DIR t "^[^.]" t)
(directory-files CONTRIB-DIR t "^[^.]" t)))
(when (file-directory-p dir)
(push dir paths)))
`(setq load-path ',(append (list CORE-DIR CONTRIB-DIR MODULES-DIR)
(if (listp load-path) load-path (list load-path))
paths))))
;; Are you pondering what I'm pondering?
(defmacro narf/init (packages)
`(progn ,@(mapcar (lambda (pkg) `(require ',pkg)) (eval packages)))))
(narf/init-load-path)
;; (require 'benchmark)
(require 'autoloads nil t) ; use `make autoloads` to generate autoloads file
(setq custom-theme-directory THEMES-DIR)
(setq use-package-verbose DEBUG-MODE)
;;(setq use-package-expand-minimally (not DEBUG-MODE))
(eval-when-compile (require 'use-package))
(require 'diminish)
;;; startup.el ends here

View file

@ -1,4 +0,0 @@
RelativeLayout
LinearLayout
ImageView
TextView

View file

@ -1,75 +0,0 @@
and
and_eq
asm
auto
bitand
bitor
bool
break
case
catch
char
class
compl
const
const_cast
continue
default
delete
do
double
dynamic_cast
else
enum
explicit
export
extern
false
float
for
friend
goto
if
inline
int
internal
long
mutable
namespace
new
not
not_eq
operator
or
or_eq
private
protected
public
register
reinterpret_cast
return
short
signed
sizeof
static
static_cast
struct
switch
template
this
throw
true
try
typedef
typeid
typename
union
unsigned
using
virtual
void
volatile
wchar_t
while
xor
xor_eq

View file

@ -1,37 +0,0 @@
auto
_Bool
break
case
char
_Complex
const
continue
default
do
double
else
enum
extern
float
for
goto
if
_Imaginary
inline
int
long
register
restrict
return
short
signed
sizeof
static
struct
switch
typedef
union
unsigned
void
volatile
while

View file

@ -1,677 +0,0 @@
!important
_azimuth
_background
_background-position-x
_background-position-y
_border
_bottom
_caption
_clear
_clip
_color
_content
_counter
_cue
_cursor
_direction
_display
_elevation
_empty
_filter
_filter:progid:DXImageTransform.Microsoft
_float
_font
_height
_ime
_ime-mode
_layout
_layout-flow
_layout-grid
_layout-grid-char
_layout-grid-line
_layout-grid-mode
_layout-grid-type
_left
_letter
_line
_line-break
_list
_margin
_orphans
_outline
_overflow
_overflow-x
_overflow-y
_padding
_page
_pause
_pitch
_play
_position
_quotes
_richness
_right
_ruby
_ruby-align
_ruby-overhang
_ruby-position
_scrollbar
_scrollbar-3dlight-color
_scrollbar-arrow-color
_scrollbar-base-color
_scrollbar-darkshadow-color
_scrollbar-face-color
_scrollbar-highlight-color
_scrollbar-track-color
_speak
_speech
_stress
_table
_text
_text-align-last
_text-autospace
_text-justify
_text-kashida-space
_text-overflow
_text-underline-position
_top
_unicode
_vertical
_visibility
_voice
_volume
_white
_widows
_width
_word
_word-break
_word-wrap
_writing
_writing-mode
_z
_zoom
above
active
adjust
after
aliceblue
align
always
antiquewhite
aqua
aquamarine
armenian
arrow
attachment
auto
autospace
avoid
azimuth
azure
background
background-attachment
background-color
background-image
background-position
background-repeat
bar
base
baseline
before
behind
beige
below
bidi
bidi-override
bisque
black
blanchedalmond
blink
block
blue
blueviolet
bold
bolder
border
border-bottom
border-bottom-color
border-bottom-style
border-bottom-width
border-collapse
border-color
border-left
border-left-color
border-left-style
border-left-width
border-right
border-right-color
border-right-style
border-right-width
border-spacing
border-style
border-top
border-top-color
border-top-style
border-top-width
border-width
both
bottom
box
break
brown
burlwood
cadetblue
capitalize
caps
caption
caption-side
cell
cells
center
center-left
center-right
char
chartreuse
chocolate
circle
cjk
cjk-ideographic
clear
clip
close
close-quote
cm
code
collapse
color
column
compact
condensed
content
continuous
coral
cornflowerblue
cornsilk
counter
counter-increment
counter-reset
crimson
crop
cross
crosshair
cue
cue-after
cue-before
cursive
cursor
cyan
darkblue
darkcyan
darkgoldenrod
darkgray
darkgreen
darkkhaki
darkmagenta
darkolivegreen
darkorange
darkorchid
darkred
darksalmon
darkseagreen
darkshadow
darkslateblue
darkslategray
darkturquoise
darkviolet
dashed
decimal
decimal-leading-zero
decoration
deeppink
deepskyblue
default
deg
digits
dimgray
direction
disc
display
dodgerblue
dotted
double
during
e
e-resize
elevation
em
embed
empty
empty-cells
ex
expanded
extra
extra-condensed
extra-expanded
face
family
fantasy
far
far-left
far-right
fast
faster
firebrick
first
first-child
first-letter
first-line
fixed
float
floralwhite
flow
focus
font
font-family
font-size
font-size-adjust
font-stretch
font-style
font-variant
font-weight
footer
forestgreen
fuchsia
gainsboro
georgian
ghostwhite
gold
goldenrod
gray
greek
green
greenyellow
grid
groove
group
header
hebrew
height
help
hidden
hide
high
higher
hiragana
hiragana-iroha
honeydew
hotpink
hover
icon
ideographic
image
in
increment
indent
index
indianred
indigo
inherit
inline
inline-block
inline-table
inset
inside
iroha
italic
item
ivory
justify
kHz
kashida
katakana
katakana-iroha
khaki
landscape
lang()
large
larger
last
latin
lavender
lavenderblush
lawngreen
layout
leading
left
left-side
leftwards
lenonchiffon
letter
letter-spacing
level
lightblue
lightcoral
lightcyan
lighter
lightgoldenrodyellow
lightgray
lightgreen
lightgrey
lightpink
lightsalmon
lightseagreen
lightskyblue
lightslategray
lightsteelblue
lightyellow
lime
limegreen
line
line-height
line-through
linen
link
list
list-item
list-style
list-style-image
list-style-position
list-style-type
loud
low
lower
lower-alpha
lower-greek
lower-latin
lower-roman
lowercase
ltr
magenta
margin
margin-bottom
margin-left
margin-right
margin-top
marker
marker-offset
marks
maroon
max
max-height
max-width
medium
mediumaquamarine
mediumblue
mediumorchid
mediumpurple
mediumseagreen
mediumslateblue
mediumspringgreen
mediumturquoise
mediumvioletred
menu
message
message-box
middle
midnightblue
min
min-height
min-width
mintcream
mistyrose
mix
mm
moccasin
mode
monospace
move
ms
n
n-resize
naby
narrower
navajowhite
ne
ne-resize
no
no-close-quote
no-open-quote
no-repeat
none
normal
nowrap
number
numeral
nw
nw-resize
oblique
offset
oldlace
olive
olivedrab
once
open
open-quote
orange
orangered
orchid
orphans
out
outline
outline-color
outline-style
outline-width
outset
outside
overflow
overhang
overline
override
padding
padding-bottom
padding-left
padding-right
padding-top
page
page-break-after
page-break-before
page-break-inside
palegoldenrod
palegreen
paleturquoise
palevioletred
papayawhip
pause
pause-after
pause-before
pc
peachpuff
peru
pink
pitch
pitch-range
play
play-during
plum
pointer
portarait
position
powderblue
pre
pre-line
pre-wrap
progid
progress
pt
punctuation
purple
px
quote
quotes
rad
range
rate
red
relative
repeat
repeat-x
repeat-y
reset
resize
richness
ridge
right
right-side
rightwards
roman
rosybrown
row
royalblue
rtl
run
run-in
s
s-resize
saddlebrown
salmon
sandybrown
sans-serif
scroll
se
se-resize
seagreen
seashell
semi
semi-condensed
semi-expanded
separate
serif
shadow
show
side
sienna
silent
silever
silver
size
skyblue
slateblue
slategray
slow
slower
small
small-caps
small-caption
smaller
snow
soft
solid
space
spacing
speak
speak-header
speak-numeral
speak-punctuation
specific
specific-voice
speech
speech-rate
spell
spell-out
springgreen
square
static
status
status-bar
steelblue
stress
stretch
style
sub
super
sw
sw-resize
table
table-caption
table-cell
table-column
table-column-group
table-footer-group
table-header-group
table-layout
table-row
table-row-group
tan
teal
text
text-align
text-bottom
text-decoration
text-indent
text-shadow
text-top
text-transform
thick
thin
thistle
through
tomato
top
track
transform
transparent
turquoise
type
ultra
ultra-condensed
ultra-expanded
underline
unicode
unicode-bidi
upper
upper-alpha
upper-latin
upper-roman
uppercase
variant
vertical
vertical-align
violet
visibility
visible
visited
voice
voice-family
volume
w
w-resize
wait
weight
wheat
white
white-space
whitesmoke
wider
widows
width
word
word-spacing
wrap
x
x-fast
x-high
x-large
x-loud
x-low
x-slow
x-small
x-soft
xx
xx-large
xx-small
y
yellow
yellowgreen
z
z-index
zero

File diff suppressed because it is too large Load diff

View file

@ -1,2 +0,0 @@
JSON.stringify
JSON.parse

View file

@ -1,7 +0,0 @@
JSON
JSON.stringify
JSON.parse
LaunchBar
include
HTTP
File

View file

@ -1,30 +0,0 @@
love.keyboard.isDown
love.draw
love.update
love.conf
love.load
draw
focus
joystickpressed
joystickreleased
keypressed
keyreleased
load
mousepressed
mousereleased
quit
run
update
audio
event
filesystem
font
graphics
image
joystick
keyboard
mouse
physics
sound
thread
timer

View file

@ -1,21 +0,0 @@
and
break
do
else
elseif
end
false
for
function
if
in
local
nil
not
or
repeat
return
then
true
until
while

View file

@ -1,34 +0,0 @@
CFBundleName
CFBundleShortVersionString
CFBundleVersion
CFBundleIdentifier
CFBundleIconFile
LSMinimumSystemVersion
LBMinimumLaunchBarVersion
LBDebugLogEnabled
LBAbbreviation
LBRequiredApplication
LBAssociatedApplication
LBTextInputTitle
LBScripts
LBDefaultScript
LBScriptName
LBRunInBackground
LBLiveFeedbackEnabled
LBBackgroundKillEnabled
LBRequiresArgument
LBAcceptedArgumentTypes
LBReturnsResult
LBResultType
LBKeepWindowActive
LBSuggestionsScript
LBActionURLScript
LBDescription
LBAuthor
LBWebsite
LBEmail
LBTwitter
LBSummary
LBArgument
LBResult
LBRequirements

View file

@ -1,62 +0,0 @@
and
array
as
break
case
catch
cfunction
class
clone
const
continue
declare
default
die
do
echo
else
elseif
empty
enddeclare
endfor
endforeach
endif
endswitch
endwhile
eval
exit
extends
final
for
foreach
function
global
goto
if
implements
include
include_once
instanceof
interface
isset
list
namespace
new
old_function
or
print
private
protected
public
require
require_once
return
static
switch
throw
try
unset
use
var
while
xor

View file

@ -1,181 +0,0 @@
$!
$"
$$
$&
$'
$*
$+
$,
$-0
$-F
$-I
$-K
$-a
$-d
$-i
$-l
$-p
$-v
$-w
$.
$/
$0
$1
$10
$11
$2
$3
$4
$5
$6
$7
$8
$9
$:
$;
$<
$=
$>
$?
$@
$DEBUG
$FILENAME
$KCODE
$LOADED_FEATURES
$LOAD_PATH
$PROGRAM_NAME
$SAFE
$VERBOSE
$\
$_
$`
$deferr
$defout
$stderr
$stdin
$stdout
$~
ARGF
ARGV
Array
BEGIN
DATA
END
ENV
FALSE
Float
Integer
NIL
PLATFORM
RELEASE_DATE
RUBY_COPYRIGHT
RUBY_DESCRIPTION
RUBY_PATCHLEVEL
RUBY_PLATFORM
RUBY_RELEASE_DATE
RUBY_VERSION
SCRIPT_LINES__
STDERR
STDIN
STDOUT
String
TOPLEVEL_BINDING
TRUE
VERSION
__method__
`
abort
alias
and
at_exit
autoload
autoload?
begin
binding
block_given
break
callcc
caller
case
catch
chomp
chomp!
chop
chop
class
def
defined?
do
else
elsif
end
ensure
eval
exec
exit
exit!
fail
false
for
fork
format
getc
gets
global_variables
gsub
gsub!
if
in
iterator?
lambda
load
local_varaibles
loop
module
next
nil
not
open
or
p
printf
proc
putc
puts
raise
rand
readline
readlines
redo
require
require_relative
rescue
retry
return
scan
select
self
set_trace_func
sleep
split
sprintf
srand
sub
sub!
super
syscall
system
test
then
throw
trace_var
trap
true
undef
unless
until
untrace_var
warn
when
while
yield

View file

@ -1,680 +0,0 @@
@import
@mixin
@extend
!important
_azimuth
_background
_background-position-x
_background-position-y
_border
_bottom
_caption
_clear
_clip
_color
_content
_counter
_cue
_cursor
_direction
_display
_elevation
_empty
_filter
_filter:progid:DXImageTransform.Microsoft
_float
_font
_height
_ime
_ime-mode
_layout
_layout-flow
_layout-grid
_layout-grid-char
_layout-grid-line
_layout-grid-mode
_layout-grid-type
_left
_letter
_line
_line-break
_list
_margin
_orphans
_outline
_overflow
_overflow-x
_overflow-y
_padding
_page
_pause
_pitch
_play
_position
_quotes
_richness
_right
_ruby
_ruby-align
_ruby-overhang
_ruby-position
_scrollbar
_scrollbar-3dlight-color
_scrollbar-arrow-color
_scrollbar-base-color
_scrollbar-darkshadow-color
_scrollbar-face-color
_scrollbar-highlight-color
_scrollbar-track-color
_speak
_speech
_stress
_table
_text
_text-align-last
_text-autospace
_text-justify
_text-kashida-space
_text-overflow
_text-underline-position
_top
_unicode
_vertical
_visibility
_voice
_volume
_white
_widows
_width
_word
_word-break
_word-wrap
_writing
_writing-mode
_z
_zoom
above
active
adjust
after
aliceblue
align
always
antiquewhite
aqua
aquamarine
armenian
arrow
attachment
auto
autospace
avoid
azimuth
azure
background
background-attachment
background-color
background-image
background-position
background-repeat
bar
base
baseline
before
behind
beige
below
bidi
bidi-override
bisque
black
blanchedalmond
blink
block
blue
blueviolet
bold
bolder
border
border-bottom
border-bottom-color
border-bottom-style
border-bottom-width
border-collapse
border-color
border-left
border-left-color
border-left-style
border-left-width
border-right
border-right-color
border-right-style
border-right-width
border-spacing
border-style
border-top
border-top-color
border-top-style
border-top-width
border-width
both
bottom
box
break
brown
burlwood
cadetblue
capitalize
caps
caption
caption-side
cell
cells
center
center-left
center-right
char
chartreuse
chocolate
circle
cjk
cjk-ideographic
clear
clip
close
close-quote
cm
code
collapse
color
column
compact
condensed
content
continuous
coral
cornflowerblue
cornsilk
counter
counter-increment
counter-reset
crimson
crop
cross
crosshair
cue
cue-after
cue-before
cursive
cursor
cyan
darkblue
darkcyan
darkgoldenrod
darkgray
darkgreen
darkkhaki
darkmagenta
darkolivegreen
darkorange
darkorchid
darkred
darksalmon
darkseagreen
darkshadow
darkslateblue
darkslategray
darkturquoise
darkviolet
dashed
decimal
decimal-leading-zero
decoration
deeppink
deepskyblue
default
deg
digits
dimgray
direction
disc
display
dodgerblue
dotted
double
during
e
e-resize
elevation
em
embed
empty
empty-cells
ex
expanded
extra
extra-condensed
extra-expanded
face
family
fantasy
far
far-left
far-right
fast
faster
firebrick
first
first-child
first-letter
first-line
fixed
float
floralwhite
flow
focus
font
font-family
font-size
font-size-adjust
font-stretch
font-style
font-variant
font-weight
footer
forestgreen
fuchsia
gainsboro
georgian
ghostwhite
gold
goldenrod
gray
greek
green
greenyellow
grid
groove
group
header
hebrew
height
help
hidden
hide
high
higher
hiragana
hiragana-iroha
honeydew
hotpink
hover
icon
ideographic
image
in
increment
indent
index
indianred
indigo
inherit
inline
inline-block
inline-table
inset
inside
iroha
italic
item
ivory
justify
kHz
kashida
katakana
katakana-iroha
khaki
landscape
lang()
large
larger
last
latin
lavender
lavenderblush
lawngreen
layout
leading
left
left-side
leftwards
lenonchiffon
letter
letter-spacing
level
lightblue
lightcoral
lightcyan
lighter
lightgoldenrodyellow
lightgray
lightgreen
lightgrey
lightpink
lightsalmon
lightseagreen
lightskyblue
lightslategray
lightsteelblue
lightyellow
lime
limegreen
line
line-height
line-through
linen
link
list
list-item
list-style
list-style-image
list-style-position
list-style-type
loud
low
lower
lower-alpha
lower-greek
lower-latin
lower-roman
lowercase
ltr
magenta
margin
margin-bottom
margin-left
margin-right
margin-top
marker
marker-offset
marks
maroon
max
max-height
max-width
medium
mediumaquamarine
mediumblue
mediumorchid
mediumpurple
mediumseagreen
mediumslateblue
mediumspringgreen
mediumturquoise
mediumvioletred
menu
message
message-box
middle
midnightblue
min
min-height
min-width
mintcream
mistyrose
mix
mm
moccasin
mode
monospace
move
ms
n
n-resize
naby
narrower
navajowhite
ne
ne-resize
no
no-close-quote
no-open-quote
no-repeat
none
normal
nowrap
number
numeral
nw
nw-resize
oblique
offset
oldlace
olive
olivedrab
once
open
open-quote
orange
orangered
orchid
orphans
out
outline
outline-color
outline-style
outline-width
outset
outside
overflow
overhang
overline
override
padding
padding-bottom
padding-left
padding-right
padding-top
page
page-break-after
page-break-before
page-break-inside
palegoldenrod
palegreen
paleturquoise
palevioletred
papayawhip
pause
pause-after
pause-before
pc
peachpuff
peru
pink
pitch
pitch-range
play
play-during
plum
pointer
portarait
position
powderblue
pre
pre-line
pre-wrap
progid
progress
pt
punctuation
purple
px
quote
quotes
rad
range
rate
red
relative
repeat
repeat-x
repeat-y
reset
resize
richness
ridge
right
right-side
rightwards
roman
rosybrown
row
royalblue
rtl
run
run-in
s
s-resize
saddlebrown
salmon
sandybrown
sans-serif
scroll
se
se-resize
seagreen
seashell
semi
semi-condensed
semi-expanded
separate
serif
shadow
show
side
sienna
silent
silever
silver
size
skyblue
slateblue
slategray
slow
slower
small
small-caps
small-caption
smaller
snow
soft
solid
space
spacing
speak
speak-header
speak-numeral
speak-punctuation
specific
specific-voice
speech
speech-rate
spell
spell-out
springgreen
square
static
status
status-bar
steelblue
stress
stretch
style
sub
super
sw
sw-resize
table
table-caption
table-cell
table-column
table-column-group
table-footer-group
table-header-group
table-layout
table-row
table-row-group
tan
teal
text
text-align
text-bottom
text-decoration
text-indent
text-shadow
text-top
text-transform
thick
thin
thistle
through
tomato
top
track
transform
transparent
turquoise
type
ultra
ultra-condensed
ultra-expanded
underline
unicode
unicode-bidi
upper
upper-alpha
upper-latin
upper-roman
uppercase
variant
vertical
vertical-align
violet
visibility
visible
visited
voice
voice-family
volume
w
w-resize
wait
weight
wheat
white
white-space
whitesmoke
wider
widows
width
word
word-spacing
wrap
x
x-fast
x-high
x-large
x-loud
x-low
x-slow
x-small
x-soft
xx
xx-large
xx-small
y
yellow
yellowgreen
z
z-index
zero

View file

@ -1,162 +0,0 @@
alias
bg
bind
break
builtin
caller
cd
command
compgen
complete
compopt
continue
declare
dirs
disown
echo
enable
eval
exec
exit
export
fc
fg
getopts
hash
help
history
jobs
kill
let
local
logout
mapfile
popd
printf
pushd
pwd
read
readarray
readonly
return
set
shift
shopt
source
suspend
test
times
trap
type
typeset
ulimit
umask
unalias
unset
wait
case
do
done
elif
else
esac
fi
for
function
if
in
select
then
time
until
while
BASH
BASH_ALIASES
BASH_ARGC
BASH_ARGV
BASH_CMDS
BASH_COMMAND
BASH_ENV
BASH_EXECUTION_STRING
BASH_LINENO
BASH_REMATCH
BASH_SOURCE
BASH_SUBSHELL
BASH_VERSINFO
BASH_VERSION
BASH_XTRACEFD
BASHOPTS
BASHPID
CDPATH
COLUMNS
COMP_CWORD
COMP_KEY
COMP_LINE
COMP_POINT
COMP_TYPE
COMP_WORDBREAKS
COMP_WORDS
COMPREPLY
DIRSTACK
EMACS
EUID
FCEDIT
FIGNORE
FUNCNAME
GLOBIGNORE
GROUPS
HISTCMD
HISTCONTROL
HISTFILE
HISTFILESIZE
HISTIGNORE
HISTSIZE
HISTTIMEFORMAT
HOME
HOSTFILE
HOSTNAME
HOSTTYPE
IFS
IGNOREEOF
INPUTRC
LANG
LC_ALL
LC_COLLATE
LC_CTYPE
LC_MESSAGES
LC_MESSAGES
LC_NUMERIC
LINENO
LINES
MACHTYPE
MAIL
MAILCHECK
MAILPATH
OLDPWD
OPTARG
OPTERR
OPTIND
OSTYPE
PATH
PIPESTATUS
POSIXLY_CORRECT
PPID
PROMPT_COMMAND
PROMPT_DIRTRIM
PS1
PS2
PS3
PS4
PWD
RANDOM
REPLY
SECONDS
SHELL
SHELLOPTS
SHLVL
TEXTDOMAIN
TEXTDOMAINDIR
TIMEFORMAT
TMOUT
TMPDIR
UID

41
init-load-path.el Normal file
View file

@ -0,0 +1,41 @@
;;; init-load-path.el
(fset '! 'eval-when-compile)
(defconst narf-emacs-dir user-emacs-directory)
(defconst narf-core-dir (! (concat narf-emacs-dir "core/")))
(defconst narf-modules-dir (! (concat narf-emacs-dir "modules/")))
(defconst narf-contrib-dir (! (concat narf-emacs-dir "contrib/")))
(defconst narf-private-dir (! (concat narf-emacs-dir "private/")))
(defconst narf-elpa-dir (! (concat narf-emacs-dir ".cask/" emacs-version "/elpa/")))
(defconst narf-temp-dir (! (concat narf-private-dir "cache/" (system-name) "/")))
(defconst narf-script-dir (! (concat narf-emacs-dir "scripts/")))
(defconst narf-snippet-dirs (! (list (concat narf-private-dir "snippets/")
(concat narf-private-dir "templates/"))))
(! (defun --subdirs (path)
(let ((result '())
(paths (ignore-errors (directory-files path t "^[^.]" t))))
(dolist (file paths)
(when (file-directory-p file)
(add-to-list 'result file)))
result)))
;; Scan various folders to populate the load-dirs
(setq custom-theme-load-path
(! (append (--subdirs (concat narf-private-dir "themes/"))
custom-theme-load-path)))
(setq load-path
(! (require 'cask)
(cask-initialize)
(setq load-path (append (list narf-core-dir narf-contrib-dir narf-modules-dir narf-private-dir)
(list (concat narf-core-dir "lib"))
(list (concat narf-modules-dir "lib"))
(--subdirs narf-contrib-dir)
load-path))))
(defconst IS-MAC (eq system-type 'darwin))
(defconst IS-LINUX (eq system-type 'gnu/linux))
(defconst IS-WINDOWS (eq system-type 'windows-nt))
;;; init-load-path.el ends here

125
init.el
View file

@ -1,18 +1,19 @@
;;; NARF! Emacs for the jaded vimmer
;;; init.el --- NARF bootstrap
;;
;; Author: Henrik Lissner <henrik@lissner>
;; URL: https://github.com/hlissner/emacs.d
;; Author: Henrik Lissner <henrik@lissner.net>
;; URL: https://github.com/hlissner/emacs.d
;; Version: 0.1.0
;;
;;; Narf!
;;; Are you pondering what I'm pondering, Pinky?
;;
;; ,,, !/:.
;; /::\". !!:::
;; :::::\". ," \:,::
;; ::::::\ ". ,","\::.
;; \:::::":\ "/""V' :'
;; \:::::":\ "/""v' :'
;; !::::\ ! \ \ __
;; "::::\ \ ! \.&&&&,
;; ," __ ", CD,&&&&&&'
;; ," __ ", cd,&&&&&&'
;; \ ". "" / \&&&" _,---
;; "",__\_ / _,:":::::
;; _," ,"" ,-,__,/":,_ ,",":::::::
@ -22,73 +23,81 @@
;; / ,"_!:::::::/, ," _,,--, /::::::/
;; / "" _,"\:::::::' ! ," ){:::::/
;; ! _," \ "", \,"""-,____,"__,,,"_," _/
;; ""T" \\ \ "-,_(*)&&&&(*)," \ ."
;; ""t" \\ \ "-,_(*)&&&&(*)," \ ."
;; / \", ! , \ ! - )
;; ! \ "" ! !==!"-,__,'
;; ! \ """_""""`, ", /"_
;; \ , .L /" " ", \! ,_/
;; \ , .l /" " ", \! ,_/
;; ), \ / \ \/ ,, /! !
;; ,::\ \," \ ! \/ ! !
;; _,::::" ) )\ ," ___ \ -,_, ,"",! !
;; __,,,::::"" ," ,":::,-:::--:" __\_!__/_""-,_!
;; ,,:::""""""" ,:_,""__...._"""::::"" /:::::" ""::::::
;; (:._ L::::::::::::\\/ "" ""
;; (:._ l::::::::::::\\/ "" ""
;; """"--,,,--- """"
;;
;;; Code:
(defconst DEBUG-MODE nil)
;; These mice are not part of GNU Emacs.
;;
;;; License: GPLv3
(defconst DEFAULT-FONT (font-spec :family "Terminus (TTF)" :size 12 :antialias nil))
(defconst DEFAULT-THEME 'narf-dark) ; for GUI client
(defconst TERM-THEME 'wombat) ; for <256 color terminals
(defconst narf-debug-mode nil)
(load (concat user-emacs-directory "core/startup.el"))
(narf/init
'(core ; yoink @ core.el
core-ui ; aesthetics
core-evil ; evil-mode and its plugins
core-editor ; completing the editor
core-company ; for the lazy typist
(defconst narf-default-theme 'narf-dark)
(defconst narf-term-theme 'wombat)
(defconst narf-default-font '(:family "terminus (ttf)" :size 12 :antialias nil))
(defconst narf-big-font '(:family "Inconsolata" :size 18 :antialias t))
init-auto-insert ; see above
init-fly ; fly(check|spell)
init-vc ; version control gutter + git modes
init-ido ; a search engine for your car keys
init-helm ; a search engine for your life
init-project ; dired, neotree
(load (concat user-emacs-directory "init-load-path.el"))
(mapc 'require
`(;; benchmark ; records load times in `require-times'; see `list-times'
core ; core/core.el
init-cc ; C/C++/Obj-C madness
;; init-cscope
;; init-csharp ; unity, mono and xamarin
init-data ; DBs 'n data formats
;; init-eshell
;; init-go
init-java ; the poster child for carpal tunnel syndome
init-js ; alert("not java, javascript!")
init-lisp ; elisp, clisp and clojure
init-lua ; one-based indices? One-based indices.
init-org ; for fearless [organized] leader
init-php ; making php less painful to work with
init-python ; beautiful is better than ugly
init-regex ; /^[^\s](meaning)[^\n]*/
init-ruby ; <3
init-scss ; @include magic;
init-sh ; #!/bin/bash_your_head_in
,(cond (IS-MAC 'core-os-osx)
(IS-LINUX 'core-os-linux)
(IS-WINDOWS 'core-os-win32))
;; init-sonicpi ;
;; init-swift ; yay, emoji variabless!
init-text ; I got nothing...
;; init-rust
;; init-r ; for science!
init-vim ; the confessional
init-web ; for the 2.0'er
init-workgroups ; session management I can understand
init-yasnippet ; type for me
core-ui ; draw me like one of your French editors
core-evil ; come to the dark side, we have cookies
core-editor ; filling the editor-shaped hole in the emacs OS
core-company ; for the lazy typist
core-yasnippet ; for the lazier typist
core-auto-insert ; for the laziest typist
core-flycheck ; remember that semicolon you forgot?
core-project ; whose project am I in?
core-vcs ; version control is a programmer's best friend
core-helm ; a search engine for life and love
core-quickrun ; run code, run.
core-workgroups ; cure Emacs alzheimers
narf-bindings
narf-commands
narf-settings
))
module-cc ; c/c++/obj-c madness
module-csharp ; unity, mono and xamarin
module-data ; dbs 'n data formats
module-eshell ; eshell
module-go
module-java ; the poster child for carpal tunnel syndome
module-js ; alert("not java, javascript!")
module-elisp ;
module-lua ; one-based indices? one-based indices.
module-lb6 ; LaunchBar 6 development
module-org ; for fearless [organized] leader
module-php ; making php less painful to work with
module-python ; beautiful is better than ugly
module-regex ; /^[^\s](meaning)[^\n]*/
module-ruby ; <3
module-sass ; @include magic;
module-sonicpi ; the funk soul brotha
module-swift ; yay, emoji variabless!
module-markdown ; markdown
;; module-rust
;; module-r ; for science!
module-vim ; the confessional
module-web ; for the 2.0'er
my-bindings
my-commands
))
;;; Are you pondering what I'm pondering Pinky?
(defun display-startup-echo-area-message ()
(message ">>> Loaded in %s" (emacs-init-time)))
;;; I think so Brain...

View file

@ -1,91 +0,0 @@
(use-package autoinsert
:config
(progn
;; (setq auto-insert-directory "%/.emacs.d/templates/")
(setq auto-insert-query nil) ; Don't prompt before insertion
(setq auto-insert-alist '())
(auto-insert-mode 1)))
(after "yasnippet"
(defun add-template (regexp-or-major-mode uuid yas-mode &optional project-only)
(define-auto-insert regexp-or-major-mode
`(lambda () (insert-template ,uuid ',yas-mode ,project-only))))
(defun insert-template (uuid mode &optional project-only)
"Expand snippet template in MODE by its UUID"
(unless (or (and project-only (not (narf/project-p)))
(not (or (eq major-mode mode)
(symbol-value mode))))
(insert uuid)
(yas-expand-from-trigger-key)
(if (string-equal uuid (s-trim (buffer-string)))
(erase-buffer)
(evil-insert-state 1))))
(add-template "/\\.gitignore$" "%%" 'gitignore-mode)
;; C/C++
(add-template "/Makefile$" "%%" 'makefile-gmake-mode)
(add-template "/main\\.\\(cc\\|cpp\\)$" "%main.cpp%" 'c++-mode)
(add-template "/win32_\\.\\(cc\\|cpp\\)$" "%winmain.cpp%" 'c++-mode)
(add-template "\\.\\([Hh]\\|hpp\\)$" "%.h%" 'c++-mode)
(add-template "\\.\\([Cc]\\|cc\\|cpp\\)$" "%.cpp%" 'c++-mode)
;; Shell scripts
(add-template "\\.z?sh$" "%%" 'sh-mode)
;; Ruby
(add-template "/spec_helper\\.rb$" "%helper%" 'rspec-mode t)
(add-template "_spec\\.rb$" "%%" 'rspec-mode t)
(add-template "/\\.rspec$" "%.rspec%" 'rspec-mode)
(add-template "/Rakefile$" "%Rakefile%" 'ruby-mode t)
(add-template "/Gemfile$" "%Gemfile%" 'ruby-mode t)
;; (add-template "\\.gemspec$" "%.gemspec%" 'ruby-mode t)
(add-template "/lib/.+\\.rb$" "%module%" 'ruby-mode t)
(add-template "\\.rb$" "%%" 'ruby-mode)
;; ;; Python
;; (add-template "tests?/test_.+\\.py$" "%%" 'nose-mode)
;; (add-template "/setup\\.py$" "%setup%" 'python-mode)
(add-template "\\.py$" "%%" 'python-mode)
;; ;; PHP
;; (add-template "\\.class\\.php$" "%class%" 'php-mode)
;; (add-template "\\.php$" "%%" 'php-mode)
;; ;; Markdown
(add-template "\\.md$" "%%" 'markdown-mode)
;; (add-template "/_posts/.+\\.md$" "%jekyll-post" 'markdown-mode)
;; (add-template "/_layouts/.+\\.html$" "%jekyll-layout%" 'web-mode)
;; ;; Javascript
(add-template "\\.lbaction/Contents/Info.plist$" "%Info.plst%" 'lb6-mode)
(add-template "\\.lbaction/.+/\\(default\\|suggestions\\)\\.js$" "%default.js%" 'lb6-mode)
;; (add-template "/package\\.json$" "%package.json%" 'json-mode)
;; (add-template "\\.\\(json\\|jshintrc\\)$" "%%" 'json-mode)
;; ;; SCSS
;; (add-template "/master\\.scss$" "%master%" 'scss-mode)
;; (add-template "/normalize\\.scss$" "%normalize%" 'scss-mode)
;; (add-template "\\.scss$" "%%" 'scss-mode)
;; ;; HTML
;; (add-template "\\.html$" "%%" 'web-mode)
;; Lua
;; (add-template "\\.love/main\\.lua$" "%love.main%" 'lua-mode)
(add-template "/conf\\.lua$" "%love.conf%" 'love-mode)
;; (add-template "\\.lua$" "%%" 'lua-mode)
;; ;; Java
(add-template "/src/.+/.+\\.java$" "%%" 'java-mode)
(add-template "/build\\.gradle$" "%gradle%" 'android-mode)
;; ;; Elisp
(add-template "\\.emacs\\.d/.+\\.el$" "%initfile%" 'emacs-lisp-mode)
(add-template "\\.emacs\\.d/snippets/.+$" "%%" 'snippet-mode))
(provide 'init-auto-insert)
;;; init-auto-insert.el ends here

View file

@ -1,153 +0,0 @@
(use-package cmake-mode
:mode "CMakeLists\\.txt$"
:config
(progn
(after "company"
(use-package company-cmake
:config
(narf/add-company-backend cmake-mode (company-cmake company-yasnippet))))))
(use-package glsl-mode
:mode (("\\.glsl\\'" . glsl-mode)
("\\.vert\\'" . glsl-mode)
("\\.frag\\'" . glsl-mode)
("\\.geom\\'" . glsl-mode)))
(use-package cc-mode
:defines (c-syntactic-context)
:functions (c-toggle-electric-state c-toggle-auto-newline
c-skip-comments-and-strings c-forward-sws c-end-of-macro
c-font-lock-invalid-string csharp-log c-font-lock-declarators
c-get-lang-constant c-forward-keyword-clause
c-fontify-recorded-types-and-refs c-forward-type imenu--split
c-backward-sws c-determine-limit c-beginning-of-decl-1)
:commands (c-mode c++-mode objc-mode java-mode)
:init
(progn
(associate-mode "\\.h$" 'c++-mode)
(associate-mode "\\.mm$" 'objc-mode))
:config
(progn
;; Settings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq c-basic-offset 4
c-tab-always-indent nil
c-electric-flag nil)
(progn ; C/C++ Settings
(after "flycheck"
(when IS-MAC
(setq flycheck-clang-language-standard "c++11"
flycheck-clang-standard-library "libc++"
flycheck-c/c++-clang-executable "clang++"
flycheck-clang-include-path '("/usr/local/include"))))
(after "company"
;; TODO Clang is *really* slow in larger projects, maybe replace it with irony-mode or ycmd?
(narf/add-company-backend c-mode (company-c-headers company-clang))
(narf/add-company-backend c++-mode (company-c-headers company-clang))
(narf/add-company-backend objc-mode (company-c-headers company-xcode)))
(defun narf--c-lineup-inclass (langelem)
(let ((inclass (assoc 'inclass c-syntactic-context)))
(save-excursion
(goto-char (c-langelem-pos inclass))
(if (or (looking-at "struct")
(looking-at "typedef struct"))
'+
'++))))
(defun narf|init-c/c++-settings ()
(c-toggle-electric-state -1)
(c-toggle-auto-newline -1)
(c-set-offset 'substatement-open '0) ; brackets should be at same indentation level as the statements they open
(c-set-offset 'inline-open '+)
(c-set-offset 'block-open '+)
(c-set-offset 'brace-list-open '+) ; all "opens" should be indented by the c-indent-level
(c-set-offset 'case-label '+) ; indent case labels by c-indent-level, too
(c-set-offset 'access-label '-)
(c-set-offset 'inclass 'narf--c-lineup-inclass)
;; DEL mapping interferes with smartparens and my custom DEL binding
(define-key c-mode-map (kbd "DEL") nil))
(add-hook 'c-mode-hook 'narf|init-c/c++-settings)
(add-hook 'c++-mode-hook 'narf|init-c/c++-settings)
;; C++11 syntax support (until cc-mode is updated)
(require 'font-lock)
(defun --copy-face (new-face face)
"Define NEW-FACE from existing FACE."
(copy-face face new-face)
(eval `(defvar ,new-face nil))
(set new-face new-face))
(--copy-face 'font-lock-label-face ; labels, case, public, private, proteced, namespace-tags
'font-lock-keyword-face)
(--copy-face 'font-lock-doc-markup-face ; comment markups such as Javadoc-tags
'font-lock-doc-face)
(--copy-face 'font-lock-doc-string-face ; comment markups
'font-lock-comment-face)
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
(add-hook! 'c++-mode-hook
;; We could place some regexes into `c-mode-common-hook', but
;; note that their evaluation order matters.
(font-lock-add-keywords
nil '(;; complete some fundamental keywords
("\\<\\(void\\|unsigned\\|signed\\|char\\|short\\|bool\\|int\\|long\\|float\\|double\\)\\>" . font-lock-keyword-face)
;; namespace names and tags - these are rendered as constants by cc-mode
("\\<\\(\\w+::\\)" . font-lock-function-name-face)
;; new C++11 keywords
("\\<\\(alignof\\|alignas\\|constexpr\\|decltype\\|noexcept\\|nullptr\\|static_assert\\|thread_local\\|override\\|final\\)\\>" . font-lock-keyword-face)
("\\<\\(char16_t\\|char32_t\\)\\>" . font-lock-keyword-face)
;; PREPROCESSOR_CONSTANT, PREPROCESSORCONSTANT
("\\<[A-Z]*_[A-Z_]+\\>" . font-lock-constant-face)
("\\<[A-Z]\\{3,\\}\\>" . font-lock-constant-face)
;; hexadecimal numbers
("\\<0[xX][0-9A-Fa-f]+\\>" . font-lock-constant-face)
;; integer/float/scientific numbers
("\\<[\\-+]*[0-9]*\\.?[0-9]+\\([ulUL]+\\|[eE][\\-+]?[0-9]+\\)?\\>" . font-lock-constant-face)
;; c++11 string literals
;; L"wide string"
;; L"wide string with UNICODE codepoint: \u2018"
;; u8"UTF-8 string", u"UTF-16 string", U"UTF-32 string"
("\\<\\([LuU8]+\\)\".*?\"" 1 font-lock-keyword-face)
;; R"(user-defined literal)"
;; R"( a "quot'd" string )"
;; R"delimiter(The String Data" )delimiter"
;; R"delimiter((a-z))delimiter" is equivalent to "(a-z)"
("\\(\\<[uU8]*R\"[^\\s-\\\\()]\\{0,16\\}(\\)" 1 font-lock-keyword-face t) ; start delimiter
( "\\<[uU8]*R\"[^\\s-\\\\()]\\{0,16\\}(\\(.*?\\))[^\\s-\\\\()]\\{0,16\\}\"" 1 font-lock-string-face t) ; actual string
( "\\<[uU8]*R\"[^\\s-\\\\()]\\{0,16\\}(.*?\\()[^\\s-\\\\()]\\{0,16\\}\"\\)" 1 font-lock-keyword-face t) ; end delimiter
;; user-defined types (rather project-specific)
("\\<[A-Za-z_]+[A-Za-z_0-9]*_\\(type\\|ptr\\)\\>" . font-lock-type-face)
("\\<\\(xstring\\|xchar\\)\\>" . font-lock-type-face)
)) t)
;; Fix enum and C++11 lambda indentation
(defadvice c-lineup-arglist (around c-lineup-arglist-indent-fix activate)
"Improve indentation of continued C++11 lambda function opened as argument."
(setq ad-return-value
(if (and (equal major-mode 'c++-mode)
(ignore-errors
(save-excursion
(goto-char (c-langelem-pos langelem))
;; Detect "[...](" or "[...]{". preceded by "," or "(",
;; and with unclosed brace.
(looking-at ".*[(,][ \t]*\\[[^]]*\\][ \t]*[({][^}]*$"))))
0 ; no additional indent
ad-do-it))))
(progn ; Obj-C
(add-to-list 'magic-mode-alist
`(,(lambda ()
(and (string= (file-name-extension buffer-file-name) "h")
(re-search-forward "@\\<interface\\>"
magic-mode-regexp-match-limit t)))
. objc-mode))
(after "flycheck"
(add-hook! 'objc-mode-hook (use-package flycheck-objc))))
))
(provide 'init-cc)
;;; init-cc.el ends here

View file

@ -1,11 +0,0 @@
(use-package xcscope
:init (cscope-setup)
:config
;; (push '("*cscope*" :position bottom) popwin:special-display-config)
)
(add-hook 'ruby-mode-hook (function cscope-minor-mode))
(provide 'init-cscope)

View file

@ -1,25 +0,0 @@
(use-package csharp-mode :mode "\\.cs$"
:init
(add-hook 'csharp-mode-hook 'flycheck-mode)
:config
(progn
(use-package omnisharp
:defer t
:config
(progn
(setq omnisharp-server-executable-path
"~/Dropbox/projects/lib/Omnisharp/server/OmniSharp/bin/Debug/OmniSharp.exe")
(bind :normal :map omnisharp-mode-map
"gd" 'omnisharp-go-to-definition)
(after "company"
(narf/add-company-backend csharp-mode (company-omnisharp))
(add-hook 'csharp-mode-hook 'turn-on-eldoc-mode))))))
;; unity shaders
(use-package shaderlab-mode :mode "\\.shader$")
(provide 'init-csharp)
;;; init-csharp.el ends here

View file

@ -1,11 +0,0 @@
(use-package yaml-mode
:mode "\\.ya?ml$"
:init (add-hook 'yaml-mode-hook 'narf|enable-tab-width-2))
(use-package json-mode
:mode (("\\.json$" . json-mode)
("\\.jshintrc$" . json-mode)))
(provide 'init-data)
;;; init-data.el ends here

View file

@ -1,50 +0,0 @@
;; (evil-set-initial-state 'eshell-mode 'emacs)
;; (push '("*eshell*" :position left :width 80 :stick t) popwin:special-display-config)
;; ;; eshell
;; (setq eshell-directory-name (concat TMP-DIR "eshell"))
;; (setq eshell-scroll-to-bottom-on-input 'all)
;; (setq eshell-buffer-shorthand t)
;; ;; em-alias
;; (setq eshell-aliases-file (concat TMP-DIR ".eshell-aliases"))
;; ;; em-glob
;; (setq eshell-glob-case-insensitive t)
;; (setq eshell-error-if-no-glob t)
;; ;; em-hist
;; (setq eshell-history-size 1024)
;; ;; plan 9 smart shell
;; ;; (after "esh-module"
;; ;; (add-to-list 'eshell-modules-list 'eshell-smart)
;; ;; (setq eshell-where-to-jump 'begin)
;; ;; (setq eshell-review-quick-commands nil)
;; ;; (setq eshell-smart-space-goes-to-end t))
;; (defun my-current-git-branch ()
;; (let ((branch (car (loop for match in (split-string (shell-command-to-string "git branch") "\n")
;; when (string-match "^\*" match)
;; collect match))))
;; (if (not (eq branch nil))
;; (concat " [" (substring branch 2) "]")
;; "")))
;; (defun my-eshell-prompt ()
;; (concat (propertize (abbreviate-file-name (eshell/pwd)) 'face 'eshell-prompt)
;; (propertize (my-current-git-branch) 'face 'font-lock-function-name-face)
;; (propertize " $ " 'face 'font-lock-constant-face)))
;; ;; em-prompt
;; (setq eshell-prompt-function 'my-eshell-prompt)
(provide 'init-eshell)
;;; init-eshell.el ends here

View file

@ -1,45 +0,0 @@
(use-package flycheck
:functions (flycheck-buffer)
:commands (flycheck-mode flycheck-list-errors)
:init
(add-to-hooks 'flycheck-mode '(ruby-mode-hook
python-mode-hook
php-mode-hook
lua-mode-hook
shell-mode-hook
scss-mode-hook
c++-mode-hook
c-mode-hook))
:config
(progn ; flycheck settings
(defun my-shorter-fly-status (result)
(format "[%s]" (replace-regexp-in-string " FlyC:?" "" result)))
(advice-add 'flycheck-mode-line-status-text :filter-return 'my-shorter-fly-status)
(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))
(narf/add-throwaway-buffer "^\\*Flycheck.*\\*$")
(bind :normal :map flycheck-error-list-mode-map
[escape] 'kill-this-buffer
"q" 'kill-this-buffer)
(evil-initial-state 'flycheck-error-list-mode 'emacs)
(defun narf/evil-flycheck-buffer ()
(if (and (featurep 'flycheck) flycheck-mode)
(flycheck-buffer)))
;; Check buffer when normal mode is entered
(add-hook 'evil-normal-state-entry-hook 'narf/evil-flycheck-buffer)
;; And on ESC in normal mode.
(advice-add 'evil-force-normal-state :after 'narf/evil-flycheck-buffer)))
(use-package flyspell :commands flyspell-mode)
(provide 'init-fly)
;;; init-fly.el ends here

View file

@ -1,14 +0,0 @@
(use-package go-mode
:mode "\\.go$"
:interpreter "go"
:config
(progn
(bind normal :map go-mode-map "gd" 'godef-jump)
(use-package company-go
:config
(narf/add-company-backend go-mode (company-go company-yasnippet)))))
(provide 'init-go)
;;; init-go.el ends here

View file

@ -1,176 +0,0 @@
(use-package helm
:commands (helm
helm-etags-select
helm-show-kill-ring
helm-bookmarks
helm-wg
helm-ag
helm-alive-p
helm-attrset)
:init
(progn
(defvar helm-global-prompt ">>> ")
(evil-set-initial-state 'helm-mode 'emacs))
:config
(progn
(use-package helm-grep)
(use-package helm-ag
:functions (helm-ag--select-source)
:defines (helm-ag-source helm-ag--last-query))
;; No persistent header
(defun narf--helm-display-mode-line (source &optional force)
(setq mode-line-format nil)
(setq header-line-format nil))
(advice-add 'helm-display-mode-line :override 'narf--helm-display-mode-line)
;; Minimalistic split-fn; leaves popwin to handle helm buffers
(defun narf--helm-split-window-fn (window)
(if (one-window-p t)
(let ((helm-full-frame t))
(selected-window))
(other-window-for-scrolling)))
(setq helm-quick-update t
helm-idle-delay 0.05
helm-input-idle-delay 0.05
helm-reuse-last-window-split-state t
helm-buffers-fuzzy-matching t
helm-candidate-number-limit 40
helm-bookmark-show-location t
helm-split-window-default-side 'other
helm-split-window-preferred-function 'narf--helm-split-window-fn) ; let popwin handle this
(after "winner"
;; Tell winner-mode to ignore helm buffers
(dolist (bufname '("*helm recentf*"
"*helm projectile*"
"*helm imenu*"
"*helm company*"
"*helm buffers*"
;; "*helm tags*"
"*helm-ag*"
"*Helm Swoop*"))
(push bufname winner-boring-buffers)))
(narf/add-throwaway-buffer "^\\*[Hh]elm.*\\*$")
(bind :map helm-map
"C-w" 'evil-delete-backward-word
"C-u" 'helm-delete-minibuffer-contents
"C-r" 'evil-ex-paste-from-register ; Evil registers in helm! Glorious!
[escape] 'helm-keyboard-quit)))
(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
projectile-global-mode
helm-projectile-switch-to-buffer
helm-projectile-find-file
helm-projectile-recentf
helm-projectile-find-other-file
helm-projectile-switch-project)
:diminish projectile-mode
:config
(progn
(defun narf/project-invalidate-cache-maybe ()
(when (projectile-project-p) (projectile-invalidate-cache nil)))
(add-hook 'kill-emacs-hook 'narf/project-invalidate-cache-maybe)
(setq-default projectile-enable-caching t)
(setq projectile-sort-order 'recentf
projectile-cache-file (concat TMP-DIR "projectile.cache")
projectile-known-projects-file (concat TMP-DIR "projectile.projects")
projectile-indexing-method 'alien
projectile-project-root-files narf/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"))
(use-package helm-projectile)
(projectile-global-mode +1)
;; Don't show the project name in the prompts; I already know.
(defun projectile-prepend-project-name (string) helm-global-prompt)))
(use-package helm-org
:commands (helm-org-in-buffer-headings
helm-org-agenda-files-headings
helm-org-capture-templates)
:config
(defun helm-get-org-candidates-in-file (filename min-depth max-depth
&optional fontify nofname)
(with-current-buffer (pcase filename
((pred bufferp) filename)
((pred stringp) (find-file-noselect filename)))
(and fontify (jit-lock-fontify-now))
(let ((match-fn (if fontify 'match-string 'match-string-no-properties)))
(save-excursion
(goto-char (point-min))
(cl-loop with width = (window-width)
while (re-search-forward org-complex-heading-regexp nil t)
if (let ((num-stars (length (match-string-no-properties 1))))
(and (>= num-stars min-depth) (<= num-stars max-depth)))
collect `(,(let ((heading (funcall match-fn 4))
(file (unless nofname
(concat (f-no-ext (f-relative filename org-directory)) ":")))
(level (length (match-string-no-properties 1))))
(org-format-outline-path
(append (org-get-outline-path t level heading)
(list heading)) width file))
. ,(point-marker))))))))
(use-package helm-files
:commands helm-recentf
:config
(progn
;; Reconfigured `helm-recentf' to use `helm', instead of `helm-other-buffer'
(defun helm-recentf ()
(interactive)
(let ((helm-ff-transformer-show-only-basename nil))
(helm :sources '(helm-source-recentf)
:buffer "*helm recentf*"
:prompt helm-global-prompt)))))
(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
:defines (helm-swoop-last-prefix-number)
:commands (helm-swoop helm-multi-swoop helm-multi-swoop-all)
:config
(setq helm-swoop-use-line-number-face t
helm-swoop-split-with-multiple-windows t
helm-swoop-speed-or-color t))
(use-package helm-c-yasnippet :commands helm-yas-visit-snippet-file)
(use-package helm-buffers :commands helm-buffers-list)
(use-package helm-semantic :commands helm-semantic-or-imenu)
(use-package helm-elisp :commands helm-apropos)
(use-package helm-command :commands helm-M-x)
(use-package helm-company :defer t)
(provide 'init-helm)
;;; init-helm.el ends here

View file

@ -1,62 +0,0 @@
(use-package ido
:defines (flx-ido-mode ido-ubiquitous-debug-mode ido-context-switch-command ido-temp-list)
:functions (ido-to-end)
:commands (ido-mode
ido-everywhere
ido-vertical-mode
flx-ido-mode
ido-ubiquitous-mode
ido-find-file
ido-find-file-in-dir)
:config
(progn
(ido-mode 1)
(ido-everywhere 1)
(use-package ido-vertical-mode :config (ido-vertical-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
ido-case-fold t
ido-enable-tramp-completion nil
ido-enable-flex-matching t
ido-create-new-buffer 'always
ido-enable-tramp-completion t
ido-enable-last-directory-history t
ido-save-directory-list-file (concat TMP-DIR "ido.last"))
(add-to-list 'ido-ignore-files "\\`.DS_Store$")
(add-to-list 'ido-ignore-files "Icon\\?$")
(setq ido-ignore-buffers
'("\\` " "^\\*ESS\\*" "^\\*Messages\\*" "^\\*Help\\*" "^\\*Buffer"
"^\\*.*Completions\\*$" "^\\*Ediff" "^\\*tramp" "^\\*cvs-"
"_region_" " output\\*$" "^TAGS$" "^\*Ido"))
; sort ido filelist by mtime instead of alphabetically
(add-hook 'ido-make-file-list-hook 'ido-sort-mtime)
(add-hook 'ido-make-dir-list-hook 'ido-sort-mtime)
(defun ido-sort-mtime ()
(setq ido-temp-list
(sort ido-temp-list
(lambda (a b)
(time-less-p
(sixth (file-attributes (concat ido-current-directory b)))
(sixth (file-attributes (concat ido-current-directory a)))))))
(ido-to-end ;; move . files to end (again)
(delq nil (mapcar
(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
;; Go straight home
(define-key ido-file-completion-map (kbd "~")
(λ (if (looking-back "/")
(insert "~/")
(call-interactively 'self-insert-command)))))))
(provide 'init-ido)
;;; init-ido.el ends here

View file

@ -1,84 +0,0 @@
(defun narf/java-project-package ()
(if (eq major-mode 'java-mode)
(s-chop-suffix "." (s-replace "/" "." (f-dirname (f-relative (buffer-file-name)
(concat (narf/project-root) "/src/")))))
""))
(defun narf/java-class-name ()
(if (eq major-mode 'java-mode)
(f-no-ext (f-base (buffer-file-name)))
""))
(use-package eclim
:functions (eclim--project-dir eclim--project-name)
:commands (eclim-mode global-eclim-mode)
:init
(progn
(setq eclim-eclipse-dirs '("/Applications/eclipse")
eclim-executable "/Applications/eclipse/eclim")
(when (file-exists-p eclim-executable)
(add-hook 'java-mode-hook 'eclim-mode)))
:config
(progn
;; (use-package eclim-ant)
;; (use-package eclim-maven)
(use-package eclim-problems)
(use-package eclim-project)
(use-package eclimd)
(setq help-at-pt-display-when-idle t)
(setq help-at-pt-timer-delay 0.1)
(help-at-pt-set-timer)
(push "*eclim: problems*" winner-boring-buffers)
(after "company"
(use-package company-emacs-eclim
:config (company-emacs-eclim-setup)))
(bind :motion :map java-mode-map "gd" 'eclim-java-find-declaration)))
(use-package android-mode
:commands android-mode
:init
(progn
;; yasnippet defuns
(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 narf|android-mode-enable-maybe ()
(let ((root (narf/project-root)))
(when (or (narf/project-has-files "local.properties" root)
(narf/project-has-files "AndroidManifest.xml" root)
(narf/project-has-files "src/main/AndroidManifest.xml" root))
(android-mode +1)
(narf/set-build-command "./gradlew %s" "build.gradle"))))
(after "company" (add-to-list 'company-dictionary-major-minor-modes 'android-mode))
(add-hook 'java-mode-hook 'narf|android-mode-enable-maybe)
(add-hook 'groovy-mode-hook 'narf|android-mode-enable-maybe)
(add-hook 'nxml-mode-hook 'narf|android-mode-enable-maybe)
(add-hook! 'android-mode-hook (narf/init-yas-mode 'android-mode))))
(use-package groovy-mode
:functions (is-groovy-mode)
:mode "\\.gradle$")
(provide 'init-java)
;;; init-java.el ends here

View file

@ -1,57 +0,0 @@
(use-package js2-mode
:mode "\\.js$"
:interpreter "node"
:config
(progn
(setq js2-skip-preprocessor-directives t)
(setq-default js2-show-parse-errors nil)
(setq-default js2-global-externs '("module" "require" "buster" "sinon" "assert"
"refute" "setTimeout" "clearTimeout"
"setInterval" "clearInterval" "location"
"__dirname" "console" "JSON" "jQuery" "$"
;; Launchbar API
"LaunchBar" "File" "Action" "HTTP" "include"))
(after "web-beautify"
(add-hook! 'js2-mode-hook (setenv "jsbeautify_indent_size" "4"))
(bind :motion :map js2-mode-map "gQ" 'web-beautify-js))
(after "emr" (use-package js2-refactor))
;; [pedantry intensifies]
(defadvice js2-mode (after js2-mode-rename-modeline activate)
(setq mode-name "Javascript2"))
(use-package tern
:diminish (tern-mode . "tern")
:commands tern-mode
:init
(add-hook 'js2-mode-hook 'tern-mode)
:config
(after "company"
(use-package company-tern
:config
(narf/add-company-backend js2-mode (company-tern)))))))
;; For UnityScript
(use-package unityjs-mode
:mode "/Assets/*.js$"
:config
(progn
(add-hook 'unityjs-mode-hook 'flycheck-mode)
(add-hook! 'unityjs-mode-hook
(narf|enable-tab-width-2)
(setq js-indent-level 2))))
;; For launchbar script development
(define-minor-mode lb6-mode
"Launchbar development mode."
:init-value nil
:lighter "lb6"
:keymap (make-sparse-keymap)
(narf/init-yas-mode 'lb6-mode))
(associate-minor-mode "\\.lb\\(action\\|ext\\)/.*$" 'lb6-mode)
(provide 'init-js)
;;; init-js.el ends here

View file

@ -1,19 +0,0 @@
;; TODO: Do this later
(add-hook! 'hs-minor-mode-hook (when hs-minor-mode (hs-hide-level 3)))
;; [pedantry intensifies]
(defadvice emacs-lisp-mode (after emacs-lisp-mode-rename-modeline activate)
(setq mode-name "Elisp"))
;; Real go-to-definition for elisp
(bind :motion :map 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)))))
(provide 'init-lisp)
;;; init-lisp.el ends here

View file

@ -1,28 +0,0 @@
(use-package lua-mode
:mode "\\.lua$"
:interpreter "lua"
:init
(progn
(setq lua-indent-level tab-width)
(when (file-exists-p "/Applications/love.app")
(define-minor-mode love-mode
"Buffer local minor mode for Love2D"
:init-value nil
:lighter " <3"
:keymap (make-sparse-keymap)
(narf/init-yas-mode 'love-mode))
(add-hook! 'lua-mode-hook
(narf/set-build-command "open -a love.app '%s'" "main.lua")
(when (narf/project-has-files "main.lua")
(love-mode +1))))
(after "company" (add-to-list 'company-dictionary-major-minor-modes 'love-mode))
(add-hook! 'lua-mode-hook
(narf|enable-tab-width-2)
(setq lua-indent-level 2))))
(provide 'init-lua)
;;; init-lua.el ends here

View file

@ -1,255 +0,0 @@
(define-minor-mode evil-org-mode
"Evil-mode bindings for org-mode."
:init-value nil
:lighter "!"
:keymap (make-sparse-keymap) ; defines evil-org-mode-map
:group 'evil-org)
(use-package org
:defines (org-directory)
:functions (org-bookmark-jump-unhide outline-next-heading org-end-of-subtree
outline-flag-region org-remove-inline-images org-display-inline-images
org-at-item-checkbox-p org-toggle-checkbox org-entry-is-todo-p org-todo
org-format-outline-path org-get-outline-path)
:commands (org-capture
org-capture-string)
:mode (("\\.org$" . org-mode)
("\\.opml$" . org-mode))
:init
(progn
(add-hook 'org-mode-hook 'narf|enable-tab-width-2)
(add-hook 'org-mode-hook 'narf|enable-hard-wrap)
(add-hook 'org-mode-hook 'iimage-mode)
(add-hook 'org-mode-hook 'org-indent-mode)
(add-hook 'org-mode-hook 'evil-org-mode)
(add-hook! 'org-mode-hook (hl-line-mode -1)))
:config
(progn
(after "org-indent" (diminish 'org-indent-mode))
(after "iimage" (diminish 'iimage-mode))
(setq org-directory "~/Dropbox/notes")
(setq org-project-directory (expand-file-name "projects" org-directory) ; custom variable
org-default-notes-file (expand-file-name "notes.org" org-directory)
org-agenda-files (f-entries org-directory (lambda (path) (and (f-ext? path "org")
(not (f-same? path (f-expand "inbox.org" org-directory))))) t)
org-archive-location (concat org-directory "/archive/%s::")
org-confirm-babel-evaluate nil
org-src-tab-acts-natively t
org-image-actual-width 250
org-startup-with-inline-images t
org-completion-use-ido t
org-hidden-keywords '(title)
org-special-ctrl-a/e t
org-hide-leading-stars t
org-hierarchical-todo-statistics t
org-checkbox-hierarchical-statistics t
org-tags-column -87
org-log-done t
org-confirm-elisp-link-function nil
org-startup-folded 'content
org-todo-keywords '((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
(sequence "DOING(s)" "PENDING(p)")
(sequence "|" "CANCELLED(c)"))
org-mobile-directory "~/Dropbox/Apps/MobileOrg"
org-mobile-inbox-for-pull (expand-file-name "mobile.org" org-directory))
(setq org-src-fontify-natively t
org-blank-before-new-entry '((heading . auto) (plain-list-item . auto))
org-export-backends '(ascii html latex md opml))
(add-to-list 'org-link-frame-setup '(file . find-file))
(setq org-tag-alist '(("@home" . ?h)
("@daily" . ?d)
("@invoices" . ?i)
("@personal" . ?p)
("@learning" . ?l)
("@dev" . ?v)
("@writing" . ?w)
("@projects" . ?r)))
(setq org-capture-templates
'(("t" "TODO" entry (file+headline "~/Dropbox/notes/todo.org" "Inbox") "* TODO %? %u\n%i")
("T" "Project TODO" entry (file+headline (narf/project-org-filename) "Tasks") "** TODO %?\n%i" :prepend t)
("N" "Project Note" entry (file+headline (narf/project-org-filename) "Notes") "** %u %?\n%i")
("c" "Changelog" entry (file+datetree (narf/project-org-filename)) "** %<%H:%M>: %? :unsorted:\n%i" :prepend t)
("n" "Note" entry (file+datetree org-default-notes-file) "** %<%H:%M>: %?\n%i" :prepend t)
("j" "Journal" entry (file+datetree "~/Dropbox/notes/journal.org") "** %?%^g\nAdded: %U\n%i")
("a" "Trivia" entry (file "~/Dropbox/notes/trivia.org") "* %u %?\n%i" :prepend t)
("s" "Writing Scraps" entry (file "~/Dropbox/notes/writing.org") "* %u %?\n%i" :prepend t)
("v" "Vocab" entry (file "~/Dropbox/notes/vocab.org") "* %?\n%i" :prepend t)
("e" "Excerpt" entry (file "~/Dropbox/notes/excerpts.org") "* %u %?\n%i" :prepend t)))
(setq iimage-mode-image-regex-alist
'(("\\(`?file://\\|\\[\\[\\|<\\|`\\)?\\([-+./_0-9a-zA-Z]+\\.\\(GIF\\|JP\\(?:E?G\\)\\|P\\(?:BM\\|GM\\|N[GM]\\|PM\\)\\|SVG\\|TIFF?\\|X\\(?:[BP]M\\)\\|gif\\|jp\\(?:e?g\\)\\|p\\(?:bm\\|gm\\|n[gm]\\|pm\\)\\|svg\\|tiff?\\|x\\(?:[bp]m\\)\\)\\)\\(\\]\\]\\|>\\|'\\)?" . 2)
("<\\(http://.+\\.\\(GIF\\|JP\\(?:E?G\\)\\|P\\(?:BM\\|GM\\|N[GM]\\|PM\\)\\|SVG\\|TIFF?\\|X\\(?:[BP]M\\)\\|gif\\|jp\\(?:e?g\\)\\|p\\(?:bm\\|gm\\|n[gm]\\|pm\\)\\|svg\\|tiff?\\|x\\(?:[bp]m\\)\\)\\)>" . 1)))
(org-babel-do-load-languages 'org-babel-load-languages
'((python . t)
(ruby . t)
(sh . t)
(emacs-lisp . t)
(matlab . t)
(latex . t)))
;; Remove occur highlights on ESC in normal mode
(advice-add 'evil-force-normal-state :before 'org-remove-occur-highlights)
;; (progn ; opml support
;; (defun set-buffer-file-format-to-opml ()
;; (when (string-match "\.opml$" (buffer-file-name))
;; (setq buffer-file-format '(opml))))
;; (defun my--opml-encode (begin end buffer)
;; "Export Org mode buffer to OPML."
;; (let ((org-export-show-temporary-export-buffer nil)
;; (name "*OPML Export Buffer*"))
;; (org-export-to-buffer 'opml name)
;; (erase-buffer)
;; (insert-buffer-substring (get-buffer name))
;; (point-max)))
;; (add-hook 'find-file-hooks 'set-buffer-file-format-to-opml)
;; (add-to-list 'format-alist '(opml "Outline Processor Markup Language"
;; "<[?]xml version=\"1.0\"[^>]*[?]>[\n]?.*[\n]?.*[\n]?<opml version=\"[1|2].0\">"
;; "~/.emacs.d/elisp/org-opml/opml2org.py" my--opml-encode t))
;; (shut-up (load-library "ox-opml")))
(progn ; key bindings
;; Hide properties PERMANENTLY
(defun org-cycle-hide-drawers (state)
"Re-hide all drawers after a visibility state change."
(when (and (derived-mode-p 'org-mode)
(not (memq state '(overview folded contents))))
(save-excursion
(let* ((globalp (memq state '(contents all)))
(beg (if globalp (point-min) (point)))
(end (if globalp (point-max)
(if (eq state 'children)
(save-excursion (outline-next-heading) (point))
(org-end-of-subtree t)))))
(goto-char beg)
(while (re-search-forward org-drawer-regexp end t)
(save-excursion
(beginning-of-line 1)
(backward-char 1)
(let ((b (point)))
(if (re-search-forward
"^[ \t]*:END:"
(save-excursion (outline-next-heading) (point)) t)
(outline-flag-region b (point-at-eol) t)
(user-error ":END: line missing at position %s" b)))))))))
(use-package org-agenda
:config
(setq org-agenda-restore-windows-after-quit t
org-agenda-custom-commands '(("x" agenda)
("y" agenda*)
("w" todo "WAITING")
("W" todo-tree "WAITING")
("to" todo)
("tp" tags "+Projects")
("tg" tags-todo "+gamedev")
("tw" tags-tree "+webdev"))))
(bind :map org-mode-map
"RET" nil
"C-j" nil
"C-k" nil
insert [remap narf:inflate-space-maybe] 'self-insert-command
normal insert
:map evil-org-mode-map
"A-l" 'org-metaright ; M-j
"A-h" 'org-metaleft ; M-h
"A-k" 'org-metaup ; M-k
"A-j" 'org-metadown ; M-j
"A-l" 'org-shiftmetaright ; M-L
"A-h" 'org-shiftmetaleft ; M-H
"A-k" 'org-shiftmetaup ; M-K
"A-j" 'org-shiftmetadown ; M-J
"<M-left>" 'org-beginning-of-line
"<M-right>" 'org-end-of-line
"<M-up>" 'org-up-element
"<M-down>" 'org-down-element
",;" 'helm-org-in-buffer-headings
"M-a" 'mark-whole-buffer
", l" 'org-insert-link
insert
"C-e" 'org-end-of-line
"C-a" 'org-beginning-of-line
;; Add new header line before this line
"<S-M-return>" 'narf/org-insert-item-before
;; Add new header line after this line
"<M-return>" 'narf/org-insert-item-after
"M-b" (λ (narf/org-surround "*")) ; bold
"M-u" (λ (narf/org-surround "_")) ; underline
"M-i" (λ (narf/org-surround "/")) ; italics
"M-`" (λ (narf/org-surround "+")) ; strikethrough
visual
"M-b" "S*"
"M-u" "S_"
"M-i" "S/"
"M-`" "S+"
normal
",=" 'org-align-all-tags
",/" 'org-sparse-tree
",?" 'org-tags-view
",a" 'org-attach
",D" 'org-time-stamp-inactive
",T" 'org-show-todo-tree
",d" 'org-time-stamp
",r" 'org-refile
",s" 'org-schedule
",t" 'org-todo
"gr" 'org-babel-execute-src-block-maybe
"gh" 'outline-up-heading
"gj" 'org-forward-heading-same-level
"gk" 'org-backward-heading-same-level
"gl" 'outline-next-visible-heading
"go" 'org-open-at-point
"gO" 'org-attach-open
"gC-o" 'org-attach-reveal
"gI" (λ (if (> (length org-inline-image-overlays) 0)
(org-remove-inline-images)
(org-display-inline-images nil t (line-beginning-position) (line-end-position))))
"gQ" 'org-fill-paragraph
"ga" 'org-attach
"gA" 'org-agenda
"gt" 'org-show-todo-tree
"]l" 'org-next-link
"[l" 'org-previous-link
"$" 'org-end-of-line
"^" 'org-beginning-of-line
"<" 'org-metaleft
">" 'org-metaright
"-" 'org-cycle-list-bullet
",SPC" 'narf/org-toggle-checkbox
",<return>" 'org-archive-subtree
"<S-M-return>" 'narf/org-insert-item-before
"<M-return>" 'narf/org-insert-item-after
"RET" (λ (cond ((org-at-item-checkbox-p)
(org-toggle-checkbox))
((org-entry-is-todo-p)
(org-todo 'done))))
[tab] 'org-cycle)
(after "org-agenda"
(bind emacs :map org-agenda-mode-map
"<escape>" 'org-agenda-Quit
"C-j" 'org-agenda-next-item
"C-k" 'org-agenda-previous-item
"C-n" 'org-agenda-next-item
"C-p" 'org-agenda-previous-item)))))
(provide 'init-org)
;;; init-org.el ends here

View file

@ -1,21 +0,0 @@
(use-package php-mode
:mode "\\.\\(php\\|inc\\)$"
:config
(progn
(setq php-template-compatibility nil)
(add-hook 'php-mode-hook 'turn-on-eldoc-mode)
(use-package php-extras
:config
(narf/add-company-backend php-mode (php-extras-company)))
;; TODO Tie into emr
(use-package php-refactor-mode
:config
(progn
(add-hook 'php-mode-hook 'emr-initialize)
(add-hook 'php-mode-hook 'php-refactor-mode)))))
(provide 'init-php)
;;; init-php.el ends here

View file

@ -1,86 +0,0 @@
;; Project nav+search tools (projectile, helm, ag)
(use-package neotree
:functions (neo-buffer--unlock-width neo-buffer--lock-width
projectile-current-project-dirs projectile-file-cached-p
projectile-purge-file-from-cache neo-buffer--insert-with-face
neo-global--get-buffer)
:commands (neotree-show
neotree-hide
neotree-toggle
neo-global--window-exists-p
neotree-dir
neotree-find)
:init
(progn
(defun narf:neotree-open (&optional dir)
(interactive)
(neotree-dir (or dir (narf/project-root))))
(defun narf:neotree-toggle ()
(interactive)
(if (neo-global--window-exists-p)
(neotree-hide)
(narf:neotree-open)))
(defun narf:neotree-find ()
(interactive)
(save-excursion (narf:neotree-open))
(neotree-find))
(add-hook 'neotree-mode-hook 'narf|init-neotree-keymap))
:config
(progn
(setq neo-create-file-auto-open t
neo-mode-line-type 'none
neo-persist-show t
neo-window-width 22
neo-show-updir-line nil
neo-auto-indent-point t
neo-banner-message nil
;; requires <https://github.com/jeffplang/emacs-neotree> fork of
;; neotree (at least, until the PR is accepted). Causes neotree to
;; open in a vertical split that consumes the entire height of the
;; frame.
neo-modern-sidebar t)
;; Redefinition for custom ascii theme
(defun narf/neo-buffer-fold-symbol (name)
(let ((n-insert-symbol (lambda (n)
(neo-buffer--insert-with-face
n 'neo-expand-btn-face))))
(or (and (equal name 'open) (funcall n-insert-symbol "- "))
(and (equal name 'close) (funcall n-insert-symbol "> "))
(and (equal name 'leaf) (funcall n-insert-symbol " ")))))
(advice-add 'neo-buffer--insert-fold-symbol :override 'narf/neo-buffer-fold-symbol)
;; Close neotree on window changes, to prevent ensuing mindbuggery
(add-hook! 'window-configuration-change-hook
(unless (and (neo-global--window-exists-p)
(eq (current-buffer) (neo-global--get-buffer)))
(neotree-hide)))
(after "projectile"
(setq projectile-switch-project-action 'neotree-projectile-action))
(add-to-list 'evil-motion-state-modes 'neotree-mode)
(defun narf|init-neotree-keymap ()
(bind :map evil-motion-state-local-map
"ESC" 'neotree-hide
"\\\\" '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-))))
(provide 'init-project)
;;; init-project.el ends here

Some files were not shown because too many files have changed in this diff Show more