Initial commit (brand new NARF)

This commit is contained in:
Henrik Lissner 2015-06-06 06:40:33 -04:00
parent de70863bed
commit d0628e018a
105 changed files with 1837 additions and 16026 deletions

View file

View file

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