Added emacs starter kit.

This commit is contained in:
Ivan Malison 2013-03-24 12:56:49 -07:00
parent 82103ae761
commit 58a9a9d0ba
39 changed files with 5589 additions and 18 deletions

4
.gitignore vendored
View File

@ -1,4 +1,6 @@
ac-comphist.dat
auto-save-list
eproject.lst
*.elc
*.elc
.smex-items
places

View File

@ -18,8 +18,8 @@
[(0 4 1)
nil "Major mode for CoffeeScript files" tar])
(company .
[(0 5)
nil "Flexible inline text and code completion" tar])
[(0 6 2)
nil "Modular in-buffer completion framework" tar])
(csv-mode .
[(1 1)
nil "Major mode for editing comma/char separated values" single])
@ -54,7 +54,7 @@
[(1 1)
nil "Parse and browse f90 interfaces" single])
(ggtags .
[(0 6)
[(0 6 2)
nil "GNU Global source code tagging system" single])
(heap .
[(0 3)
@ -74,7 +74,7 @@
[(1 0)
nil "Lexical analyser construction" single])
(lmc .
[(1 0)
[(1 1)
nil "Little Man Computer in Elisp" single])
(load-dir .
[(0 0 3)
@ -107,7 +107,7 @@
[(0 8)
nil "OAuth 2.0 Authorization Protocol" single])
(org .
[(20130311)
[(20130318)
nil "Outline-based notes management and organizer" tar])
(quarter-plane .
[(0 1)

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,38 @@
;;; elisp-slime-nav-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
;;;### (autoloads (elisp-slime-nav-find-elisp-thing-at-point elisp-slime-nav-mode)
;;;;;; "elisp-slime-nav" "elisp-slime-nav.el" (20815 22617 0 0))
;;; Generated autoloads from elisp-slime-nav.el
(autoload 'elisp-slime-nav-mode "elisp-slime-nav" "\
Enable Slime-style navigation of elisp symbols using M-. and M-,
\(fn &optional ARG)" t nil)
(autoload 'elisp-slime-nav-find-elisp-thing-at-point "elisp-slime-nav" "\
Jump to the elisp thing at point, be it a function,variable, library or face.
With a prefix arg, prompt for the symbol to jump to.
Argument SYM-NAME thing to find.
\(fn SYM-NAME)" t nil)
;;;***
;;;### (autoloads nil nil ("elisp-slime-nav-pkg.el") (20815 22617
;;;;;; 967506 0))
;;;***
(provide 'elisp-slime-nav-autoloads)
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; elisp-slime-nav-autoloads.el ends here

View File

@ -0,0 +1 @@
(define-package "elisp-slime-nav" "0.3" "Make M-. and M-, work in elisp like they do in slime" (quote nil))

View File

@ -0,0 +1,82 @@
;;; elisp-slime-nav.el --- Make M-. and M-, work in elisp like they do in slime
;;
;; Author: Steve Purcell <steve@sanityinc.com>
;; Keywords: navigation slime elisp emacs-lisp
;; URL: https://github.com/purcell/elisp-slime-nav
;; Version: 0.3
;;
;;; Commentary
;;
;; This package provides Slime's convenient "M-." and "M-," navigation
;; in `emacs-lisp-mode'.
;;
;; Additionally, C-u M-. will prompt for the symbol to which to jump.
;;
;; Usage:
;;
;; (require 'elisp-slime-nav)
;; (add-hook 'emacs-lisp-mode-hook (lambda () (elisp-slime-nav-mode t)))
;;
;; Known issues:
;;
;; When navigating into Emacs' C source, "M-," will not be bound to
;; the same command, but "M-*" will typically do the trick.
;;
;;; Code
(defvar elisp-slime-nav-mode-map (make-keymap))
;;;###autoload
(define-minor-mode elisp-slime-nav-mode
"Enable Slime-style navigation of elisp symbols using M-. and M-,"
nil " SliNav" elisp-slime-nav-mode-map)
(eval-when-compile (require 'cl))
(require 'etags)
(defun elisp-slime-nav--all-navigable-symbol-names ()
"Return a list of strings for the symbols to which navigation is possible."
(loop for x being the symbols
if (or (fboundp x) (boundp x) (symbol-plist x) (facep x))
collect (symbol-name x)))
;;;###autoload
(defun elisp-slime-nav-find-elisp-thing-at-point (sym-name)
"Jump to the elisp thing at point, be it a function,variable, library or face.
With a prefix arg, prompt for the symbol to jump to.
Argument SYM-NAME thing to find."
(interactive
(list
(let* ((sym-at-point (symbol-at-point))
(at-point (and sym-at-point (symbol-name sym-at-point))))
(if current-prefix-arg
(completing-read "Symbol: "
(elisp-slime-nav--all-navigable-symbol-names)
nil t at-point)
at-point))))
(when sym-name
(let ((sym (intern sym-name)))
(message "search for %s" (pp-to-string sym))
(ring-insert find-tag-marker-ring (point-marker))
(cond
((fboundp sym) (find-function sym))
((boundp sym) (find-variable sym))
((or (featurep sym) (locate-library sym-name))
(find-library sym-name))
((facep sym)
(find-face-definition sym))
(:else
(progn
(pop-tag-mark)
(error "Don't know how to find '%s'" sym)))))))
(define-key elisp-slime-nav-mode-map (kbd "M-.") 'elisp-slime-nav-find-elisp-thing-at-point)
(define-key elisp-slime-nav-mode-map (kbd "M-,") 'pop-tag-mark)
(provide 'elisp-slime-nav)
;;; elisp-slime-nav.el ends here

View File

@ -0,0 +1,47 @@
;;; find-file-in-project-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
;;;### (autoloads (find-file-in-project) "find-file-in-project" "find-file-in-project.el"
;;;;;; (20815 21543 0 0))
;;; Generated autoloads from find-file-in-project.el
(autoload 'find-file-in-project "find-file-in-project" "\
Prompt with a completing list of all files in the project to find one.
The project's scope is defined as the first directory containing
an `.emacs-project' file. You can override this by locally
setting the variable `ffip-project-root'.
\(fn)" t nil)
(defalias 'ffip 'find-file-in-project)
(put 'ffip-patterns 'safe-local-variable 'listp)
(put 'ffip-find-options 'safe-local-variable 'stringp)
(put 'ffip-project-file 'safe-local-variable 'stringp)
(put 'ffip-project-root 'safe-local-variable 'stringp)
(put 'ffip-project-root-function 'safe-local-variable 'functionp)
(put 'ffip-limit 'safe-local-variable 'integerp)
;;;***
;;;### (autoloads nil nil ("find-file-in-project-pkg.el") (20815
;;;;;; 21543 166996 0))
;;;***
(provide 'find-file-in-project-autoloads)
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; find-file-in-project-autoloads.el ends here

View File

@ -0,0 +1 @@
(define-package "find-file-in-project" "3.2" "Find files in a project quickly." (quote nil))

View File

@ -0,0 +1,171 @@
;;; find-file-in-project.el --- Find files in a project quickly.
;; Copyright (C) 2006-2009, 2011-2012
;; Phil Hagelberg, Doug Alcorn, and Will Farrington
;; Author: Phil Hagelberg, Doug Alcorn, and Will Farrington
;; URL: http://www.emacswiki.org/cgi-bin/wiki/FindFileInProject
;; Git: git://github.com/technomancy/find-file-in-project.git
;; Version: 3.2
;; Created: 2008-03-18
;; Keywords: project, convenience
;; EmacsWiki: FindFileInProject
;; 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, 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 GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; This library provides a couple methods for quickly finding any file
;; in a given project. It depends on GNU find.
;; A project is found by searching up the directory tree until a file
;; is found that matches `ffip-project-file'. (".git" by default.)
;; You can set `ffip-project-root-function' to provide an alternate
;; function to search for the project root. By default, it looks only
;; for files whose names match `ffip-patterns',
;; If you have so many files that it becomes unwieldy, you can set
;; `ffip-find-options' to a string which will be passed to the `find'
;; invocation in order to exclude irrelevant subdirectories. For
;; instance, in a Ruby on Rails project, you may be interested in all
;; .rb files that don't exist in the "vendor" directory. In that case
;; you could set `ffip-find-options' to "-not -regex \".*vendor.*\"".
;; All these variables may be overridden on a per-directory basis in
;; your .dir-locals.el. See (info "(Emacs) Directory Variables") for
;; details.
;; Recommended binding: (global-set-key (kbd "C-x f") 'find-file-in-project)
;;; TODO:
;; Add compatibility with BSD find (PDI; I can't virtualize OS X)
;;; Code:
(defvar ffip-project-file ".git"
"The file that should be used to define a project root.
May be set using .dir-locals.el. Checks each entry if set to a list.")
(defvar ffip-patterns
'("*.html" "*.org" "*.txt" "*.md" "*.el" "*.clj" "*.py" "*.rb" "*.js" "*.pl"
"*.sh" "*.erl" "*.hs" "*.ml")
"List of patterns to look for with `find-file-in-project'.")
(defvar ffip-find-options ""
"Extra options to pass to `find' when using `find-file-in-project'.
Use this to exclude portions of your project: \"-not -regex \\\".*svn.*\\\"\".")
(defvar ffip-project-root nil
"If non-nil, overrides the project root directory location.")
(defvar ffip-project-root-function nil
"If non-nil, this function is called to determine the project root.
This overrides variable `ffip-project-root' when set.")
(defvar ffip-limit 512
"Limit results to this many files.")
(defvar ffip-full-paths nil
"If non-nil, show fully project-relative paths.")
(defun ffip-project-root ()
"Return the root of the project."
(let ((project-root (or ffip-project-root
(if (functionp ffip-project-root-function)
(funcall ffip-project-root-function)
(if (listp ffip-project-file)
(some (apply-partially 'locate-dominating-file
default-directory)
ffip-project-file)
(locate-dominating-file default-directory
ffip-project-file))))))
(or project-root
(progn (message "No project was defined for the current file.")
nil))))
(defun ffip-uniqueify (file-cons)
"Set the car of FILE-CONS to include the directory name plus the file name."
(setcar file-cons
(concat (cadr (reverse (split-string (cdr file-cons) "/"))) "/"
(car file-cons))))
(defun ffip-join-patterns ()
"Turn `ffip-paterns' into a string that `find' can use."
(mapconcat (lambda (pat) (format "-name \"%s\"" pat))
ffip-patterns " -or "))
(defun ffip-project-files ()
"Return an alist of all filenames in the project and their path.
Files with duplicate filenames are suffixed with the name of the
directory they are found in so that they are unique."
(let ((file-alist nil)
(root (expand-file-name (or ffip-project-root (ffip-project-root)
(error "No project root found")))))
(mapcar (lambda (file)
(if ffip-full-paths
(cons (substring (expand-file-name file) (length root))
(expand-file-name file))
(let ((file-cons (cons (file-name-nondirectory file)
(expand-file-name file))))
(when (assoc (car file-cons) file-alist)
(ffip-uniqueify (assoc (car file-cons) file-alist))
(ffip-uniqueify file-cons))
(add-to-list 'file-alist file-cons)
file-cons)))
(split-string (shell-command-to-string
(format "find %s -type f \\( %s \\) %s | head -n %s"
root (ffip-join-patterns)
ffip-find-options ffip-limit))))))
;;;###autoload
(defun find-file-in-project ()
"Prompt with a completing list of all files in the project to find one.
The project's scope is defined as the first directory containing
an `.emacs-project' file. You can override this by locally
setting the variable `ffip-project-root'."
(interactive)
(let* ((project-files (ffip-project-files))
(files (mapcar 'car project-files))
(file (if (and (boundp 'ido-mode) ido-mode)
(ido-completing-read "Find file in project: " files)
(completing-read "Find file in project: " files))))
(find-file (cdr (assoc file project-files)))))
;;;###autoload
(defalias 'ffip 'find-file-in-project)
;; safe locals
;;;###autoload
(progn
(put 'ffip-patterns 'safe-local-variable 'listp)
(put 'ffip-find-options 'safe-local-variable 'stringp)
(put 'ffip-project-file 'safe-local-variable 'stringp)
(put 'ffip-project-root 'safe-local-variable 'stringp)
(put 'ffip-project-root-function 'safe-local-variable 'functionp)
(put 'ffip-limit 'safe-local-variable 'integerp))
(provide 'find-file-in-project)
;;; find-file-in-project.el ends here

View File

@ -0,0 +1,29 @@
;;; idle-highlight-mode-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
;;;### (autoloads (idle-highlight-mode) "idle-highlight-mode" "idle-highlight-mode.el"
;;;;;; (20815 21543 0 0))
;;; Generated autoloads from idle-highlight-mode.el
(autoload 'idle-highlight-mode "idle-highlight-mode" "\
Idle-Highlight Minor Mode
\(fn &optional ARG)" t nil)
;;;***
;;;### (autoloads nil nil ("idle-highlight-mode-pkg.el") (20815 21543
;;;;;; 721828 0))
;;;***
(provide 'idle-highlight-mode-autoloads)
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; idle-highlight-mode-autoloads.el ends here

View File

@ -0,0 +1 @@
(define-package "idle-highlight-mode" "1.1.2" "highlight the word the point is on" (quote nil))

View File

@ -0,0 +1,104 @@
;;; idle-highlight-mode.el --- highlight the word the point is on
;; Copyright (C) 2008-2011 Phil Hagelberg, Cornelius Mika
;; Author: Phil Hagelberg, Cornelius Mika
;; URL: http://www.emacswiki.org/cgi-bin/wiki/IdleHighlight
;; Version: 1.1.2
;; Created: 2008-05-13
;; Keywords: convenience
;; EmacsWiki: IdleHighlight
;; 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, 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 GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; Based on some snippets by fledermaus from the #emacs channel.
;; M-x idle-highlight-mode sets an idle timer that highlights all
;; occurences in the buffer of the word under the point.
;; Enabling it in a hook is recommended. But you don't want it enabled
;; for all buffers, just programming ones.
;;
;; Example:
;;
;; (defun my-coding-hook ()
;; (make-local-variable 'column-number-mode)
;; (column-number-mode t)
;; (if window-system (hl-line-mode t))
;; (idle-highlight t))
;;
;; (add-hook 'emacs-lisp-mode-hook 'my-coding-hook)
;; (add-hook 'ruby-mode-hook 'my-coding-hook)
;; (add-hook 'js2-mode-hook 'my-coding-hook)
;;; Code:
(require 'thingatpt)
(defgroup idle-highlight nil
"Highlight other occurrences of the word at point."
:group 'faces)
(defface idle-highlight
'((t (:inherit region)))
"Face used to highlight other occurrences of the word at point."
:group 'idle-highlight)
(defvar idle-highlight-regexp nil
"Buffer-local regexp to be idle-highlighted.")
(defvar idle-highlight-global-timer nil
"Timer to trigger highlighting.")
(defun idle-highlight-word-at-point ()
"Highlight the word under the point."
(if idle-highlight-mode
(let* ((target-symbol (symbol-at-point))
(target (symbol-name target-symbol)))
(if (and target-symbol
(not (in-string-p))
(looking-at-p "\\s_\\|\\sw") ;; Symbol characters
;; TODO: no need to highlight keywords like if
(not (equal target "end")))
(progn (idle-highlight-unhighlight)
(setq idle-highlight-regexp (concat "\\<" (regexp-quote target) "\\>"))
(highlight-regexp idle-highlight-regexp 'idle-highlight))
(idle-highlight-unhighlight)
(setq idle-highlight-regexp nil)))))
(defsubst idle-highlight-unhighlight ()
(if idle-highlight-regexp (unhighlight-regexp idle-highlight-regexp)))
;;;###autoload
(define-minor-mode idle-highlight-mode
"Idle-Highlight Minor Mode"
:group 'idle-highlight
(if idle-highlight-mode
(progn (unless idle-highlight-global-timer
(setq idle-highlight-global-timer
(run-with-idle-timer 0.5 :repeat 'idle-highlight-word-at-point)))
(set (make-local-variable 'idle-highlight-regexp) nil))
(idle-highlight-unhighlight)))
(provide 'idle-highlight-mode)
;;; idle-highlight-mode.el ends here

View File

@ -0,0 +1,118 @@
;;; ido-ubiquitous-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
;;;### (autoloads (ido-ubiquitous-function-compatibility-exceptions
;;;;;; ido-ubiquitous-command-compatibility-exceptions ido-ubiquitous-function-exceptions
;;;;;; ido-ubiquitous-command-exceptions ido-ubiquitous-mode ido-ubiquitous)
;;;;;; "ido-ubiquitous" "ido-ubiquitous.el" (20815 21541 0 0))
;;; Generated autoloads from ido-ubiquitous.el
(let ((loads (get 'ido-ubiquitous 'custom-loads))) (if (member '"ido-ubiquitous" loads) nil (put 'ido-ubiquitous 'custom-loads (cons '"ido-ubiquitous" loads))))
(defvar ido-ubiquitous-mode nil "\
Non-nil if Ido-Ubiquitous mode is enabled.
See the command `ido-ubiquitous-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 `ido-ubiquitous-mode'.")
(custom-autoload 'ido-ubiquitous-mode "ido-ubiquitous" nil)
(autoload 'ido-ubiquitous-mode "ido-ubiquitous" "\
Use `ido-completing-read' instead of `completing-read' almost everywhere.
This mode has no effect unles `ido-mode' is also enabled.
If this mode causes problems for a function, you can force the
function to use the original completing read by using the macro
`ido-ubiquitous-disable-in'. For example, if a
function `foo' cannot work with ido-style completion, evaluate
the following (for example by putting it in your .emacs file):
(ido-ubiquitous-disable-in foo)
\(fn &optional ARG)" t nil)
(define-obsolete-variable-alias 'ido-ubiquitous 'ido-ubiquitous-mode "0.8")
(define-obsolete-function-alias 'ido-ubiquitous 'ido-ubiquitous-mode "0.8")
(defvar ido-ubiquitous-command-exceptions 'nil "\
List of commands that should not be affected by `ido-ubiquitous'.
Even when `ido-ubiquitous' mode is enabled, these commands will
continue to use `completing-read' instead of
`ido-completing-read'.
Only *interactive* commands should go here. To disable
ido-ubiquitous in non-interactive functions, customize
`ido-ubiquitous-function-exceptions'.
Note: this feature depends on the variable `this-command' being
properly set to the name of the currently executing command.
Depending on how the command is onvoked, this may or may not
happen, so this feature may simply not work in some cases.")
(custom-autoload 'ido-ubiquitous-command-exceptions "ido-ubiquitous" t)
(define-obsolete-variable-alias 'ido-ubiquitous-exceptions 'ido-ubiquitous-command-exceptions "0.4")
(defvar ido-ubiquitous-function-exceptions '(grep-read-files) "\
List of functions in which to disable ido-ubiquitous.
If you need to add a function to this list, please also file a
bug report at
https://github.com/DarwinAwardWinner/ido-ubiquitous/issues
Note that certain functions, such as `read-file-name', must
always have ido-ubiquitous disabled, and cannot be added
here. (They are effectively a permanent part of this list
already.)")
(custom-autoload 'ido-ubiquitous-function-exceptions "ido-ubiquitous" nil)
(defvar ido-ubiquitous-command-compatibility-exceptions 'nil "\
List of commands in which to disable compatibility.
See `ido-ubiquitous-enable-compatibility' for a description of
the compatibility behavior. If this behavior causes a command to
break, add that command to this list to disable compatibility
mode for just that command.
Only *interactive* commands should go here. To disable
compatibility mode in non-interactive functions, customize
`ido-ubiquitous-function-compatibility-exceptions'.")
(custom-autoload 'ido-ubiquitous-command-compatibility-exceptions "ido-ubiquitous" t)
(defvar ido-ubiquitous-function-compatibility-exceptions 'nil "\
List of functions in which to disable ido-ubiquitous compatibility mode.
See `ido-ubiquitous-enable-compatibility' for a description of
the compatibility behavior. If this behavior causes a function to
break, add that function to this list to disable compatibility
mode for just that command.
If you need to add a function to this list, please also file a
bug report at
https://github.com/DarwinAwardWinner/ido-ubiquitous/issues")
(custom-autoload 'ido-ubiquitous-function-compatibility-exceptions "ido-ubiquitous" nil)
;;;***
;;;### (autoloads nil nil ("ido-ubiquitous-pkg.el") (20815 21541
;;;;;; 802909 0))
;;;***
(provide 'ido-ubiquitous-autoloads)
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; ido-ubiquitous-autoloads.el ends here

View File

@ -0,0 +1 @@
(define-package "ido-ubiquitous" "1.6" "Use ido (nearly) everywhere." (quote nil))

View File

@ -0,0 +1,466 @@
;;; ido-ubiquitous.el --- Use ido (nearly) everywhere.
;; Author: Ryan C. Thompson
;; URL: https://github.com/DarwinAwardWinner/ido-ubiquitous
;; Version: 1.6
;; Created: 2011-09-01
;; Keywords: convenience
;; EmacsWiki: InteractivelyDoThings
;; This file is NOT part of GNU Emacs.
;;; Commentary:
;; You may have seen the `ido-everywhere' variable in ido.el and got
;; excited that you could use ido completion for everything. Then you
;; were probably disappointed when you realized that it only applied
;; to *file names* and nothing else. Well, ido-ubiquitous is here to
;; fulfill the original promise and let you use ido completion for
;; (almost) any command that uses `completing-read' to offer you a
;; choice of several alternatives.
;; This even works in M-x, but for that, you might prefer the "smex"
;; package instead.
;; As of version 0.7, this package also makes a small modification to
;; ido's behavior so as to support a strange corner case of
;; `completing-read' that some functions rely on. Since the goal of
;; this package is to replace `completing-read' everywhere instead of
;; just selectively (as ido itself does), compatibility with all the
;; quriks of `completing-read' is important here.
;; If you find a case where enabling ido-ubiquitous causes a command
;; not to work correctly, please report it by creating an issue on
;; GitHub: https://github.com/DarwinAwardWinner/ido-ubiquitous/issues
;;; 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, 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 GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Code:
(require 'ido)
(require 'advice)
(defvar ido-ubiquitous-orig-completing-read-function
(bound-and-true-p completing-read-function)
"The value of `completing-read-function' before ido-ubiquitous-mode was enabled.
This value will be restored when `ido-ubiquitous-mode' is
deactivated. It will also be used as a fallback if ido-ubiquitous
detects something that ido cannot handle.")
;;;###autoload
(defgroup ido-ubiquitous nil
"Use ido for (almost) all completion."
:group 'ido)
;;;###autoload
(define-minor-mode ido-ubiquitous-mode
"Use `ido-completing-read' instead of `completing-read' almost everywhere.
This mode has no effect unles `ido-mode' is also enabled.
If this mode causes problems for a function, you can force the
function to use the original completing read by using the macro
`ido-ubiquitous-disable-in'. For example, if a
function `foo' cannot work with ido-style completion, evaluate
the following (for example by putting it in your .emacs file):
(ido-ubiquitous-disable-in foo)"
nil
:global t
:group 'ido-ubiquitous
(when ido-ubiquitous-mode
(unless (bound-and-true-p ido-mode)
(warn "Ido-ubiquitous-mode enabled without ido mode.")))
(if (and (boundp 'completing-read-function)
ido-ubiquitous-orig-completing-read-function)
;; Emacs 24 and later
(progn
;; Ensure emacs 23 code disabled
(ad-disable-advice 'completing-read 'around 'ido-ubiquitous-legacy)
(ad-activate 'completing-read)
(setq completing-read-function
(if ido-ubiquitous-mode
'completing-read-ido
ido-ubiquitous-orig-completing-read-function)))
;; Emacs 23 and earlier
(funcall (if ido-ubiquitous-mode 'ad-enable-advice 'ad-disable-advice)
'completing-read 'around 'ido-ubiquitous-legacy)
(ad-activate 'completing-read)))
;;;###autoload
(define-obsolete-variable-alias 'ido-ubiquitous
'ido-ubiquitous-mode "0.8")
;;;###autoload
(define-obsolete-function-alias 'ido-ubiquitous
'ido-ubiquitous-mode "0.8")
;;;###autoload
(defcustom ido-ubiquitous-command-exceptions '()
"List of commands that should not be affected by `ido-ubiquitous'.
Even when `ido-ubiquitous' mode is enabled, these commands will
continue to use `completing-read' instead of
`ido-completing-read'.
Only *interactive* commands should go here. To disable
ido-ubiquitous in non-interactive functions, customize
`ido-ubiquitous-function-exceptions'.
Note: this feature depends on the variable `this-command' being
properly set to the name of the currently executing command.
Depending on how the command is onvoked, this may or may not
happen, so this feature may simply not work in some cases."
:type '(repeat (symbol :tag "Command"))
:group 'ido-ubiquitous)
;;;###autoload
(define-obsolete-variable-alias 'ido-ubiquitous-exceptions
'ido-ubiquitous-command-exceptions "0.4")
(defvar ido-next-call-replaces-completing-read nil)
(defvar ido-this-call-replaces-completing-read nil)
;; Emacs 23-
(defadvice completing-read (around ido-ubiquitous-legacy activate)
"Ido-based method for reading from the minibuffer with completion.
See `completing-read' for the meaning of the arguments."
(if (or inherit-input-method ; Can't handle this arg
(not ido-mode)
(not ido-ubiquitous-mode)
;; Avoid infinite recursion from ido calling completing-read
(boundp 'ido-cur-item)
(memq this-command ido-ubiquitous-command-exceptions))
ad-do-it
(let ((allcomp (all-completions "" collection predicate)))
;; Only use ido completion if there are actually any completions
;; to offer.
(if allcomp
(let ((ido-next-call-replaces-completing-read t))
(setq ad-return-value
(ido-completing-read prompt allcomp
nil require-match initial-input hist def)))
ad-do-it))))
(ad-disable-advice 'completing-read 'around 'ido-ubiquitous-legacy)
(ad-activate 'completing-read)
;; Emacs 24+
(defun completing-read-ido (prompt collection &optional predicate
require-match initial-input
hist def inherit-input-method)
"Ido-based method for reading from the minibuffer with completion.
See `completing-read' for the meaning of the arguments.
This function is a wrapper for `ido-completing-read' designed to
be used as the value of `completing-read-function'."
(if (or inherit-input-method ; Can't handle this arg
(not ido-mode)
(not ido-ubiquitous-mode)
(memq this-command ido-ubiquitous-command-exceptions))
(funcall ido-ubiquitous-orig-completing-read-function
prompt collection predicate
require-match initial-input
hist def inherit-input-method)
(let ((allcomp (all-completions "" collection predicate)))
;; Only use ido completion if there are actually any completions
;; to offer.
(if allcomp
(let ((ido-next-call-replaces-completing-read t))
(ido-completing-read prompt allcomp
nil require-match initial-input hist def))
(funcall ido-ubiquitous-orig-completing-read-function
prompt collection predicate
require-match initial-input
hist def inherit-input-method)))))
(defadvice ido-completing-read (around detect-replacing-cr activate)
"Detect whether this call was done through `completing-read-ido'."
(let* ((ido-this-call-replaces-completing-read ido-next-call-replaces-completing-read)
(ido-next-call-replaces-completing-read nil))
(when ido-this-call-replaces-completing-read
;; If DEF is a list, prepend it to CHOICES and set DEF to just the
;; car of the default list.
(when (and def (listp def))
(setq choices (delete-dups (append def choices))
def (car def))) ;; Work around a bug in ido when both INITIAL-INPUT and DEF are provided
;; More info: https://github.com/technomancy/ido-ubiquitous/issues/18
(let ((initial (cond ((null initial-input) "")
((stringp initial-input) initial-input)
((consp initial-input) (car initial-input))
(t initial-input)))
(deflist (if (listp def)
def
(list def))))
(when (and deflist initial
(stringp initial)
(not (string= initial "")))
;; Both default and initial input were provided. So keep the
;; initial input and preprocess the choices list to put the
;; default at the head, then proceed with default = nil.
(setq choices (delete-dups (append deflist (remove def choices)))
def nil))))
ad-do-it))
(defmacro ido-ubiquitous-disable-in (func)
"Disable ido-ubiquitous in FUNC."
(let ((docstring
(format "Disable ido-ubiquitous in %s" func)))
`(defadvice ,func (around disable-ido-ubiquitous activate)
,docstring
(let (ido-ubiquitous-mode) ad-do-it))))
(define-obsolete-function-alias
'disable-ido-ubiquitous-in
'ido-ubiquitous-disable-in
"0.4")
(defmacro ido-ubiquitous-enable-in (func)
"Re-enable ido-ubiquitous in FUNC.
This reverses the effect of a previous call to
`ido-ubiquitous-disable-in'."
`(when (ad-find-advice ',func 'around 'disable-ido-ubiquitous)
(ad-disable-advice ',func 'around 'disable-ido-ubiquitous)
(ad-activate ',func)))
(define-obsolete-function-alias
'enable-ido-ubiquitous-in
'ido-ubiquitous-enable-in
"0.4")
;; Always disable ido-ubiquitous in `find-file' and similar functions,
;; because they are not supposed to use ido.
(defvar ido-ubiquitous-permanent-function-exceptions
'(read-file-name
read-file-name-internal
read-buffer
gnus-emacs-completing-read
gnus-iswitchb-completing-read
man)
"Functions in which ido-ubiquitous should always be disabled.
If you want to disable ido in a specific function or command, do
not modify this variable. Instead, try `M-x customize-group
ido-ubiquitous.")
(dolist (func ido-ubiquitous-permanent-function-exceptions)
(eval `(ido-ubiquitous-disable-in ,func)))
(defun ido-ubiquitous--set-difference (list1 list2)
"Replacement for `set-difference' from `cl'."
(apply #'nconc
(mapcar (lambda (elt) (unless (memq elt list2) (list elt)))
list1)))
(defun ido-ubiquitous-set-function-exceptions (sym newval)
(let* ((oldval (when (boundp sym) (eval sym))))
;; Filter out the permanent exceptions so we never act on them.
(setq oldval (ido-ubiquitous--set-difference oldval ido-ubiquitous-permanent-function-exceptions))
(setq newval (ido-ubiquitous--set-difference newval ido-ubiquitous-permanent-function-exceptions))
;; Re-enable ido-ubiquitous on all old functions, in case they
;; were removed from the list.
(dolist (oldfun oldval)
(eval `(ido-ubiquitous-enable-in ,oldfun)))
;; Set the new value
(set-default sym newval)
;; Disable ido-ubiquitous on all new functions
(dolist (newfun newval)
(eval `(ido-ubiquitous-disable-in ,newfun)))))
;;;###autoload
(defcustom ido-ubiquitous-function-exceptions
'(grep-read-files)
"List of functions in which to disable ido-ubiquitous.
If you need to add a function to this list, please also file a
bug report at
https://github.com/DarwinAwardWinner/ido-ubiquitous/issues
Note that certain functions, such as `read-file-name', must
always have ido-ubiquitous disabled, and cannot be added
here. (They are effectively a permanent part of this list
already.)"
:group 'ido-ubiquitous
:type '(repeat :tag "Functions"
(symbol :tag "Function"))
:set 'ido-ubiquitous-set-function-exceptions)
(defcustom ido-ubiquitous-enable-compatibility t
"Allow ido to emulate a quirk of `completing-read'.
From the `completing-read' docstring:
> If the input is null, `completing-read' returns DEF, or the
> first element of the list of default values, or an empty string
> if DEF is nil, regardless of the value of REQUIRE-MATCH.
If this variable is non-nil, then ido-ubiquitous will attempt to
emulate this behavior. Specifically, if RET is pressed
immediately upon entering completion, an empty string will be
returned instead of the first element in the list. This behavior
is only enabled when ido is being used as a substitute for
`completing-read', and not when it is used directly.
This odd behavior is required for compatibility with an old-style
usage pattern whereby the default was requested by returning an
empty string. In this mode, the caller receives the empty string
and handles the default case manually, while `completing-read'
never has any knowledge of the default. This is a problem for
ido, which always returns the first element in the list when the
input is empty. Without knowledge of the default, it cannot
ensure that the default is first on the list, so returning the
first item is not the correct behavior. Instead, it must return
an empty string like `completing-read'.
When this mode is enabled, you can still select the first item on
the list by prefixing \"RET\" with \"C-u\"."
:type 'boolean
:group 'ido-ubiquitous)
;;;###autoload
(defcustom ido-ubiquitous-command-compatibility-exceptions '()
"List of commands in which to disable compatibility.
See `ido-ubiquitous-enable-compatibility' for a description of
the compatibility behavior. If this behavior causes a command to
break, add that command to this list to disable compatibility
mode for just that command.
Only *interactive* commands should go here. To disable
compatibility mode in non-interactive functions, customize
`ido-ubiquitous-function-compatibility-exceptions'."
:type '(repeat (symbol :tag "Command"))
:group 'ido-ubiquitous)
(defvar ido-ubiquitous-initial-item nil
"The first item selected when ido starts.")
(defadvice ido-read-internal (before clear-initial-item activate)
(setq ido-ubiquitous-initial-item nil))
(defadvice ido-make-choice-list (after set-initial-item activate)
(when (and ad-return-value (listp ad-return-value))
(setq ido-ubiquitous-initial-item (car ad-return-value))))
(defadvice ido-next-match (after clear-initial-item activate)
(setq ido-ubiquitous-initial-item nil))
(defadvice ido-prev-match (after clear-initial-item activate)
(setq ido-ubiquitous-initial-item nil))
(defadvice ido-exit-minibuffer (around compatibility activate)
"Emulate a quirk of `completing-read'.
> If the input is null, `completing-read' returns DEF, or the
> first element of the list of default values, or an empty string
> if DEF is nil, regardless of the value of REQUIRE-MATCH.
See `ido-ubiquitous-enable-compatibility', which controls whether
this advice has any effect."
(if (and (eq ido-cur-item 'list)
ido-ubiquitous-enable-compatibility
;; Only enable if we are replacing `completing-read'
ido-this-call-replaces-completing-read
;; Disable in command exceptions
(not (memq this-command ido-ubiquitous-command-compatibility-exceptions))
;; Input is empty
(string= ido-text "")
;; Default is nil
(null ido-default-item)
;; Prefix disables compatibility
(not current-prefix-arg)
(string= (car ido-cur-list)
ido-ubiquitous-initial-item))
(ido-select-text)
ad-do-it)
(setq ido-ubiquitous-initial-item nil))
(defmacro ido-ubiquitous-disable-compatibility-in (func)
"Disable ido-ubiquitous compatibility mode in FUNC."
(let ((docstring
(format "Disable ido-ubiquitous in %s" func)))
`(defadvice ,func (around disable-ido-ubiquitous-compatibility activate)
,docstring
(let (ido-ubiquitous-enable-compatibility) ad-do-it))))
(defmacro ido-ubiquitous-enable-compatibility-in (func)
"Re-enable ido-ubiquitous comaptibility mode in FUNC.
This reverses the effect of a previous call to
`ido-ubiquitous-disable-compatibility-in'."
`(when (ad-find-advice ',func 'around 'disable-ido-ubiquitous-compatibility)
(ad-disable-advice ',func 'around 'disable-ido-ubiquitous-compatibility)
(ad-activate ',func)))
(defun ido-ubiquitous-set-function-compatibility-exceptions (sym newval)
(let* ((oldval (when (boundp sym) (eval sym))))
;; Re-enable compatibility on all old functions, in case they
;; were removed from the list.
(dolist (oldfun oldval)
(eval `(ido-ubiquitous-enable-compatibility-in ,oldfun)))
;; Set the new value
(set-default sym newval)
;; Disable compatibility on all new functions
(dolist (newfun newval)
(eval `(ido-ubiquitous-disable-compatibility-in ,newfun)))))
;;;###autoload
(defcustom ido-ubiquitous-function-compatibility-exceptions
'()
"List of functions in which to disable ido-ubiquitous compatibility mode.
See `ido-ubiquitous-enable-compatibility' for a description of
the compatibility behavior. If this behavior causes a function to
break, add that function to this list to disable compatibility
mode for just that command.
If you need to add a function to this list, please also file a
bug report at
https://github.com/DarwinAwardWinner/ido-ubiquitous/issues"
:group 'ido-ubiquitous
:type '(repeat :tag "Functions"
(symbol :tag "Function"))
:set 'ido-ubiquitous-set-function-exceptions)
(defun ido-ubiquitous-initialize ()
"Do initial setup for ido-ubiquitous.
This only needs to be called once when the file is first loaded."
;; Clean up old versions of ido-ubiquitous (1.3 and earlier) that
;; defined advice on `completing-read' instead of modifying
;; `completing-read-function'.
(when (ad-find-advice 'completing-read 'around 'ido-ubiquitous)
(ad-remove-advice 'completing-read 'around 'ido-ubiquitous)
(ad-activate 'completing-read))
;; Make sure all exceptions are activated
(ido-ubiquitous-set-function-exceptions
'ido-ubiquitous-function-exceptions
ido-ubiquitous-function-exceptions)
(ido-ubiquitous-set-function-compatibility-exceptions
'ido-ubiquitous-function-compatibility-exceptions
ido-ubiquitous-function-compatibility-exceptions)
;; Make sure the mode is turned on/off as specified by the value of
;; the mode variable
(ido-ubiquitous-mode (if ido-ubiquitous-mode 1 0)))
(ido-ubiquitous-initialize)
(provide 'ido-ubiquitous) ;;; ido-ubiquitous.el ends here

View File

@ -0,0 +1,50 @@
;;; inf-ruby-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
;;;### (autoloads (run-ruby inf-ruby inf-ruby-setup-keybindings)
;;;;;; "inf-ruby" "inf-ruby.el" (20815 21577 0 0))
;;; Generated autoloads from inf-ruby.el
(autoload 'inf-ruby-setup-keybindings "inf-ruby" "\
Set local key defs to invoke inf-ruby from ruby-mode.
\(fn)" nil nil)
(autoload 'inf-ruby "inf-ruby" "\
Run an inferior Ruby process in a buffer.
With prefix argument, prompts for which Ruby implementation
\(from the list `inf-ruby-implementations') to use. Runs the
hooks `inf-ruby-mode-hook' (after the `comint-mode-hook' is
run).
\(fn &optional IMPL)" t nil)
(autoload 'run-ruby "inf-ruby" "\
Run an inferior Ruby process, input and output via buffer *ruby*.
If there is a process already running in `*ruby*', switch to that buffer.
With argument, allows you to edit the command line (default is value
of `ruby-program-name'). Runs the hooks `inferior-ruby-mode-hook'
\(after the `comint-mode-hook' is run).
\(Type \\[describe-mode] in the process buffer for a list of commands.)
\(fn &optional COMMAND NAME)" t nil)
(eval-after-load 'ruby-mode '(inf-ruby-setup-keybindings))
;;;***
;;;### (autoloads nil nil ("inf-ruby-pkg.el") (20815 21577 72596
;;;;;; 0))
;;;***
(provide 'inf-ruby-autoloads)
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; inf-ruby-autoloads.el ends here

View File

@ -0,0 +1 @@
(define-package "inf-ruby" "2.2.4" "Run a ruby process in a buffer" (quote nil))

View File

@ -0,0 +1,387 @@
;;; inf-ruby.el --- Run a ruby process in a buffer
;; Copyright (C) 1999-2008 Yukihiro Matsumoto, Nobuyoshi Nakada
;; Author: Yukihiro Matsumoto, Nobuyoshi Nakada
;; URL: http://github.com/nonsequitur/inf-ruby
;; Created: 8 April 1998
;; Keywords: languages ruby
;; Version: 2.2.4
;;; Commentary:
;;
;; inf-ruby.el provides a REPL buffer connected to an IRB subprocess.
;;
;; If you're installing manually, you'll need to:
;; * drop the file somewhere on your load path (perhaps ~/.emacs.d)
;; * Add the following lines to your .emacs file:
;; (autoload 'inf-ruby "inf-ruby" "Run an inferior Ruby process" t)
;; (autoload 'inf-ruby-setup-keybindings "inf-ruby" "" t)
;; (eval-after-load 'ruby-mode
;; '(add-hook 'ruby-mode-hook 'inf-ruby-setup-keybindings))
;;; TODO:
;;
;; inferior-ruby-error-regexp-alist doesn't match this example
;; SyntaxError: /home/eschulte/united/org/work/arf/arf/lib/cluster.rb:35: syntax error, unexpected '~', expecting kEND
;; similarity = comparison_cache[m][n] ||= clusters[m] ~ clusters[n]
;;
;; M-p skips the first entry in the input ring.
;;
(require 'comint)
(require 'compile)
(require 'ruby-mode)
(defvar inf-ruby-default-implementation "ruby"
"Which ruby implementation to use if none is specified.")
(defvar inf-ruby-first-prompt-pattern "^irb(.*)[0-9:]+0> *"
"First prompt regex pattern of ruby interpreter.")
(defvar inf-ruby-prompt-pattern "^\\(irb(.*)[0-9:]+[>*\"'] *\\)+"
"Prompt regex pattern of ruby interpreter.")
(defvar inf-ruby-mode-hook nil
"*Hook for customising inf-ruby mode.")
(defvar inf-ruby-mode-map
(let ((map (copy-keymap comint-mode-map)))
(define-key map (kbd "C-c C-l") 'inf-ruby-load-file)
(define-key map (kbd "C-x C-e") 'ruby-send-last-sexp)
(define-key map (kbd "TAB") 'inf-ruby-complete)
map)
"*Mode map for inf-ruby-mode")
(defvar inf-ruby-implementations
'(("ruby" . "irb --inf-ruby-mode -r irb/completion")
("jruby" . "jruby -S irb -r irb/completion")
("rubinius" . "rbx -r irb/completion")
("yarv" . "irb1.9 --inf-ruby-mode -r irb/completion")) ;; TODO: ironruby?
"An alist of ruby implementations to irb executable names.")
;; TODO: do we need these two defvars?
(defvar ruby-source-modes '(ruby-mode)
"*Used to determine if a buffer contains Ruby source code.
If it's loaded into a buffer that is in one of these major modes, it's
considered a ruby source file by ruby-load-file.
Used by these commands to determine defaults.")
(defvar ruby-prev-l/c-dir/file nil
"Caches the last (directory . file) pair.
Caches the last pair used in the last ruby-load-file command.
Used for determining the default in the
next one.")
(defvar inf-ruby-at-top-level-prompt-p t)
(defconst inf-ruby-error-regexp-alist
'(("SyntaxError: compile error\n^\\([^\(].*\\):\\([1-9][0-9]*\\):" 1 2)
("^\tfrom \\([^\(].*\\):\\([1-9][0-9]*\\)\\(:in `.*'\\)?$" 1 2)))
;;;###autoload
(defun inf-ruby-setup-keybindings ()
"Set local key defs to invoke inf-ruby from ruby-mode."
(define-key ruby-mode-map "\M-\C-x" 'ruby-send-definition)
(define-key ruby-mode-map "\C-x\C-e" 'ruby-send-last-sexp)
(define-key ruby-mode-map "\C-c\C-b" 'ruby-send-block)
(define-key ruby-mode-map "\C-c\M-b" 'ruby-send-block-and-go)
(define-key ruby-mode-map "\C-c\C-x" 'ruby-send-definition)
(define-key ruby-mode-map "\C-c\M-x" 'ruby-send-definition-and-go)
(define-key ruby-mode-map "\C-c\C-r" 'ruby-send-region)
(define-key ruby-mode-map "\C-c\M-r" 'ruby-send-region-and-go)
(define-key ruby-mode-map "\C-c\C-z" 'ruby-switch-to-inf)
(define-key ruby-mode-map "\C-c\C-l" 'ruby-load-file)
(define-key ruby-mode-map "\C-c\C-s" 'inf-ruby))
(defvar inf-ruby-buffer nil "Current irb process buffer.")
(defun inf-ruby-mode ()
"Major mode for interacting with an inferior ruby (irb) process.
The following commands are available:
\\{inf-ruby-mode-map}
A ruby process can be fired up with M-x inf-ruby.
Customisation: Entry to this mode runs the hooks on comint-mode-hook and
inf-ruby-mode-hook (in that order).
You can send text to the inferior ruby process from other buffers containing
Ruby source.
ruby-switch-to-inf switches the current buffer to the ruby process buffer.
ruby-send-definition sends the current definition to the ruby process.
ruby-send-region sends the current region to the ruby process.
ruby-send-definition-and-go, ruby-send-region-and-go,
switch to the ruby process buffer after sending their text.
Commands:
Return after the end of the process' output sends the text from the
end of process to point.
Return before the end of the process' output copies the sexp ending at point
to the end of the process' output, and sends it.
Delete converts tabs to spaces as it moves back.
Tab indents for ruby; with arugment, shifts rest
of expression rigidly with the current line.
C-M-q does Tab on each line starting within following expression.
Paragraphs are separated only by blank lines. # start comments.
If you accidentally suspend your process, use \\[comint-continue-subjob]
to continue it."
(interactive)
(comint-mode)
(setq comint-prompt-regexp inf-ruby-prompt-pattern)
(ruby-mode-variables)
(setq major-mode 'inf-ruby-mode)
(setq mode-name "Inf-Ruby")
(setq mode-line-process '(":%s"))
(use-local-map inf-ruby-mode-map)
(setq comint-input-filter (function inf-ruby-input-filter))
(add-to-list 'comint-output-filter-functions 'inf-ruby-output-filter)
(setq comint-get-old-input (function inf-ruby-get-old-input))
(make-local-variable 'compilation-error-regexp-alist)
(setq compilation-error-regexp-alist inf-ruby-error-regexp-alist)
(compilation-shell-minor-mode t)
(run-hooks 'inf-ruby-mode-hook))
(defvar inf-ruby-filter-regexp "\\`\\s *\\S ?\\S ?\\s *\\'"
"*Input matching this regexp are not saved on the history list.
Defaults to a regexp ignoring all inputs of 0, 1, or 2 letters.")
(defun inf-ruby-input-filter (str)
"Don't save anything matching inf-ruby-filter-regexp"
(not (string-match inf-ruby-filter-regexp str)))
(defun inf-ruby-output-filter (output)
"Check if the current prompt is a top-level prompt"
(setq inf-ruby-at-top-level-prompt-p
(string-match inf-ruby-prompt-pattern
(car (last (split-string output "\n"))))))
;; adapted from replace-in-string in XEmacs (subr.el)
(defun inf-ruby-remove-in-string (str regexp)
"Remove all matches in STR for REGEXP and returns the new string."
(let ((rtn-str "") (start 0) match prev-start)
(while (setq match (string-match regexp str start))
(setq prev-start start
start (match-end 0)
rtn-str (concat rtn-str (substring str prev-start match))))
(concat rtn-str (substring str start))))
(defun inf-ruby-get-old-input ()
"Snarf the sexp ending at point"
(save-excursion
(let ((end (point)))
(re-search-backward inf-ruby-first-prompt-pattern)
(inf-ruby-remove-in-string (buffer-substring (point) end)
inf-ruby-prompt-pattern))))
;;;###autoload
(defun inf-ruby (&optional impl)
"Run an inferior Ruby process in a buffer.
With prefix argument, prompts for which Ruby implementation
\(from the list `inf-ruby-implementations') to use. Runs the
hooks `inf-ruby-mode-hook' \(after the `comint-mode-hook' is
run)."
(interactive (list (if current-prefix-arg
(completing-read "Ruby Implementation: "
(mapc #'car inf-ruby-implementations))
inf-ruby-default-implementation)))
(setq impl (or impl "ruby"))
(let ((command (cdr (assoc impl inf-ruby-implementations))))
(run-ruby command impl)))
;;;###autoload
(defun run-ruby (&optional command name)
"Run an inferior Ruby process, input and output via buffer *ruby*.
If there is a process already running in `*ruby*', switch to that buffer.
With argument, allows you to edit the command line (default is value
of `ruby-program-name'). Runs the hooks `inferior-ruby-mode-hook'
\(after the `comint-mode-hook' is run).
\(Type \\[describe-mode] in the process buffer for a list of commands.)"
(interactive)
(setq command (or command (cdr (assoc inf-ruby-default-implementation
inf-ruby-implementations))))
(setq name (or name "ruby"))
(if (not (comint-check-proc inf-ruby-buffer))
(let ((commandlist (split-string-and-unquote command)))
(set-buffer (apply 'make-comint name (car commandlist)
nil (cdr commandlist)))
(inf-ruby-mode)))
(pop-to-buffer (setq inf-ruby-buffer (format "*%s*" name))))
(defun inf-ruby-proc ()
"Returns the current IRB process. See variable inf-ruby-buffer."
(or (get-buffer-process (if (eq major-mode 'inf-ruby-mode)
(current-buffer)
inf-ruby-buffer))
(error "No current process. See variable inf-ruby-buffer")))
;; These commands are added to the ruby-mode keymap:
(defconst ruby-send-terminator "--inf-ruby-%x-%d-%d-%d--"
"Template for irb here document terminator.
Must not contain ruby meta characters.")
(defconst inf-ruby-eval-binding "IRB.conf[:MAIN_CONTEXT].workspace.binding")
(defconst ruby-eval-separator "")
(defun ruby-send-region (start end)
"Send the current region to the inferior Ruby process."
(interactive "r")
(let (term (file (or buffer-file-name (buffer-name))) line)
(save-excursion
(save-restriction
(widen)
(goto-char start)
(setq line (+ start (forward-line (- start)) 1))
(goto-char start)
(while (progn
(setq term (apply 'format ruby-send-terminator (random) (current-time)))
(re-search-forward (concat "^" (regexp-quote term) "$") end t)))))
;; compilation-parse-errors parses from second line.
(save-excursion
(let ((m (process-mark (inf-ruby-proc))))
(set-buffer (marker-buffer m))
(goto-char m)
(insert ruby-eval-separator "\n")
(set-marker m (point))))
(comint-send-string (inf-ruby-proc) (format "eval <<'%s', %s, %S, %d\n"
term inf-ruby-eval-binding
file line))
(comint-send-region (inf-ruby-proc) start end)
(comint-send-string (inf-ruby-proc) (concat "\n" term "\n"))))
(defun ruby-send-definition ()
"Send the current definition to the inferior Ruby process."
(interactive)
(save-excursion
(ruby-end-of-defun)
(let ((end (point)))
(ruby-beginning-of-defun)
(ruby-send-region (point) end))))
(defun ruby-send-last-sexp ()
"Send the previous sexp to the inferior Ruby process."
(interactive)
(ruby-send-region (save-excursion (backward-sexp) (point)) (point)))
(defun ruby-send-block ()
"Send the current block to the inferior Ruby process."
(interactive)
(save-excursion
(ruby-end-of-block)
(end-of-line)
(let ((end (point)))
(ruby-beginning-of-block)
(ruby-send-region (point) end))))
(defun ruby-switch-to-inf (eob-p)
"Switch to the ruby process buffer.
With argument, positions cursor at end of buffer."
(interactive "P")
(if (get-buffer inf-ruby-buffer)
(pop-to-buffer inf-ruby-buffer)
(error "No current process buffer. See variable inf-ruby-buffer."))
(cond (eob-p
(push-mark)
(goto-char (point-max)))))
(defun ruby-send-region-and-go (start end)
"Send the current region to the inferior Ruby process.
Then switch to the process buffer."
(interactive "r")
(ruby-send-region start end)
(ruby-switch-to-inf t))
(defun ruby-send-definition-and-go ()
"Send the current definition to the inferior Ruby.
Then switch to the process buffer."
(interactive)
(ruby-send-definition)
(ruby-switch-to-inf t))
(defun ruby-send-block-and-go ()
"Send the current block to the inferior Ruby.
Then switch to the process buffer."
(interactive)
(ruby-send-block)
(ruby-switch-to-inf t))
(defun ruby-load-file (file-name)
"Load a Ruby file into the inferior Ruby process."
(interactive (comint-get-source "Load Ruby file: " ruby-prev-l/c-dir/file
ruby-source-modes t)) ;; T because LOAD needs an exact name
(comint-check-source file-name) ; Check to see if buffer needs saved.
(setq ruby-prev-l/c-dir/file (cons (file-name-directory file-name)
(file-name-nondirectory file-name)))
(comint-send-string (inf-ruby-proc) (concat "(load \""
file-name
"\"\)\n")))
(defun ruby-escape-single-quoted (str)
(replace-regexp-in-string "'" "\\\\'"
(replace-regexp-in-string "\n" "\\\\n"
(replace-regexp-in-string "\\\\" "\\\\\\\\" str))))
(defun inf-ruby-fix-completions-on-windows ()
"On Windows, the string received by `accept-process-output'
starts with the last line that was sent to the Ruby process.
The reason for this is unknown. Remove this line from `completions'."
(if (eq system-type 'windows-nt)
(setq completions (cdr completions))))
(defun inf-ruby-completions (seed)
"Return a list of completions for the line of ruby code starting with SEED."
(let* ((proc (get-buffer-process inf-ruby-buffer))
(comint-filt (process-filter proc))
(kept "") completions)
(set-process-filter proc (lambda (proc string) (setq kept (concat kept string))))
(process-send-string proc (format "puts IRB::InputCompletor::CompletionProc.call('%s').compact\n"
(ruby-escape-single-quoted seed)))
(while (and (not (string-match inf-ruby-prompt-pattern kept))
(accept-process-output proc 2)))
(setq completions (butlast (split-string kept "\r?\n") 2))
(inf-ruby-fix-completions-on-windows)
(set-process-filter proc comint-filt)
completions))
(defun inf-ruby-completion-at-point ()
(if inf-ruby-at-top-level-prompt-p
(let* ((curr (replace-regexp-in-string "\n$" "" (thing-at-point 'line)))
(completions (inf-ruby-completions curr)))
(if completions
(if (= (length completions) 1)
(car completions)
(completing-read "possible completions: "
completions nil t curr))))
(message "Completion aborted: Not at a top-level prompt")
nil))
(defun inf-ruby-complete (command)
"Complete the ruby code at point. Relies on the irb/completion
Module used by readline when running irb through a terminal"
(interactive (list (inf-ruby-completion-at-point)))
(when command
(kill-whole-line 0)
(insert command)))
(defun inf-ruby-complete-or-tab (&optional command)
"Either complete the ruby code at point or call
`indent-for-tab-command' if no completion is available."
(interactive (list (inf-ruby-completion-at-point)))
(if (not command)
(call-interactively 'indent-for-tab-command)
(inf-ruby-complete command)))
;;;###autoload
(eval-after-load 'ruby-mode
'(inf-ruby-setup-keybindings))
(provide 'inf-ruby)
;;; inf-ruby.el ends here

View File

@ -0,0 +1,35 @@
;;; paredit-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
;;;### (autoloads (paredit-mode) "paredit" "paredit.el" (20815 21545
;;;;;; 0 0))
;;; Generated autoloads from paredit.el
(autoload 'paredit-mode "paredit" "\
Minor mode for pseudo-structurally editing Lisp code.
With a prefix argument, enable Paredit Mode even if there are
imbalanced parentheses in the buffer.
Paredit behaves badly if parentheses are imbalanced, so exercise
caution when forcing Paredit Mode to be enabled, and consider
fixing imbalanced parentheses instead.
\\<paredit-mode-map>
\(fn &optional ARG)" t nil)
;;;***
;;;### (autoloads nil nil ("paredit-pkg.el") (20815 21545 400291
;;;;;; 0))
;;;***
(provide 'paredit-autoloads)
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; paredit-autoloads.el ends here

View File

@ -0,0 +1 @@
(define-package "paredit" "22" "minor mode for editing parentheses -*- Mode: Emacs-Lisp -*-" (quote nil))

2541
elpa/paredit-22/paredit.el Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,33 @@
;;; smex-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
;;;### (autoloads (smex-initialize smex) "smex" "smex.el" (20815
;;;;;; 21542 0 0))
;;; Generated autoloads from smex.el
(autoload 'smex "smex" "\
\(fn)" t nil)
(autoload 'smex-initialize "smex" "\
\(fn)" t nil)
;;;***
;;;### (autoloads nil nil ("smex-pkg.el") (20815 21542 636315 0))
;;;***
(provide 'smex-autoloads)
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; smex-autoloads.el ends here

View File

@ -0,0 +1 @@
(define-package "smex" "2.0" "M-x interface with Ido-style fuzzy matching." (quote nil))

493
elpa/smex-2.0/smex.el Normal file
View File

@ -0,0 +1,493 @@
;;; smex.el --- M-x interface with Ido-style fuzzy matching.
;; Copyright (C) 2009-2012 Cornelius Mika
;;
;; Author: Cornelius Mika <cornelius.mika@gmail.com>
;; URL: http://github.com/nonsequitur/smex/
;; Version: 2.0
;; Keywords: convenience, usability
;; This file is not part of GNU Emacs.
;;; License:
;; Licensed under the same terms as Emacs.
;;; Commentary:
;; Quick start:
;; run (smex-initialize)
;;
;; Bind the following commands:
;; smex, smex-major-mode-commands
;;
;; For a detailed introduction see:
;; http://github.com/nonsequitur/smex/blob/master/README.markdown
;;; Code:
(require 'ido)
(defgroup smex nil
"M-x interface with Ido-style fuzzy matching and ranking heuristics."
:group 'extensions
:group 'convenience
:link '(emacs-library-link :tag "Lisp File" "smex.el"))
(defcustom smex-auto-update t
"If non-nil, `Smex' checks for new commands each time it is run.
Turn it off for minor speed improvements on older systems."
:type 'boolean
:group 'smex)
(defcustom smex-save-file "~/.smex-items"
"File in which the smex state is saved between Emacs sessions.
Variables stored are: `smex-data', `smex-history'.
Must be set before initializing Smex."
:type 'string
:group 'smex)
(defcustom smex-history-length 7
"Determines on how many recently executed commands
Smex should keep a record.
Must be set before initializing Smex."
:type 'integer
:group 'smex)
(defcustom smex-prompt-string "M-x "
"String to display in the Smex prompt."
:type 'string
:group 'smex)
(defcustom smex-key-advice-ignore-menu-bar nil
"If non-nil, `smex-key-advice' ignores `menu-bar' bindings"
:type 'boolean
:group 'smex)
(defcustom smex-flex-matching t
"Enables Ido flex matching. On by default.
Set this to nil to disable fuzzy matching."
:type 'boolean
:group 'smex)
(defvar smex-initialized-p nil)
(defvar smex-cache)
(defvar smex-ido-cache)
(defvar smex-data)
(defvar smex-history)
(defvar smex-command-count 0)
(defvar smex-custom-action nil)
;;--------------------------------------------------------------------------------
;; Smex Interface
;;;###autoload
(defun smex ()
(interactive)
(unless smex-initialized-p
(smex-initialize))
(if (smex-already-running)
(smex-update-and-rerun)
(and smex-auto-update
(smex-detect-new-commands)
(smex-update))
(smex-read-and-run smex-ido-cache)))
(defsubst smex-already-running ()
(and (boundp 'ido-choice-list) (eql ido-choice-list smex-ido-cache)))
(defsubst smex-update-and-rerun ()
(smex-do-with-selected-item
(lambda (ignore) (smex-update) (smex-read-and-run smex-ido-cache ido-text))))
(defun smex-read-and-run (commands &optional initial-input)
(let ((chosen-item (intern (smex-completing-read commands initial-input))))
(if smex-custom-action
(let ((action smex-custom-action))
(setq smex-custom-action nil)
(funcall action chosen-item))
(unwind-protect
(progn (setq prefix-arg current-prefix-arg)
(setq this-command chosen-item)
(command-execute chosen-item 'record))
(smex-rank chosen-item)
(smex-show-key-advice chosen-item)
;; Todo: Is there a better way to manipulate 'last-repeatable-command'
;; from the inside of an interactively called function?
(run-at-time 0.01 nil (lambda (cmd) (setq last-repeatable-command cmd))
chosen-item)))))
(defun smex-major-mode-commands ()
"Like `smex', but limited to commands that are relevant to the active major mode."
(interactive)
(let ((commands (delete-dups (append (extract-commands-from-keymap (current-local-map))
(extract-commands-from-features major-mode)))))
(setq commands (smex-sort-according-to-cache commands))
(setq commands (mapcar #'symbol-name commands))
(smex-read-and-run commands)))
(defun smex-completing-read (choices initial-input)
(let ((ido-completion-map ido-completion-map)
(ido-setup-hook (cons 'smex-prepare-ido-bindings ido-setup-hook))
(ido-enable-prefix nil)
(ido-enable-flex-matching smex-flex-matching)
(ido-max-prospects 10))
(ido-completing-read (smex-prompt-with-prefix-arg) choices nil nil
initial-input nil (car choices))))
(defun smex-prompt-with-prefix-arg ()
(if (not current-prefix-arg)
smex-prompt-string
(concat
(if (eq current-prefix-arg '-)
"- "
(if (integerp current-prefix-arg)
(format "%d " current-prefix-arg)
(if (= (car current-prefix-arg) 4)
"C-u "
(format "%d " (car current-prefix-arg)))))
smex-prompt-string)))
(defun smex-prepare-ido-bindings ()
(define-key ido-completion-map (kbd "C-h f") 'smex-describe-function)
(define-key ido-completion-map (kbd "C-h w") 'smex-where-is)
(define-key ido-completion-map (kbd "M-.") 'smex-find-function)
(define-key ido-completion-map (kbd "C-a") 'move-beginning-of-line))
;;--------------------------------------------------------------------------------
;; Cache and Maintenance
(defun smex-rebuild-cache ()
(interactive)
(setq smex-cache nil)
;; Build up list 'new-commands' and later put it at the end of 'smex-cache'.
;; This speeds up sorting.
(let (new-commands)
(mapatoms (lambda (symbol)
(when (commandp symbol)
(let ((known-command (assq symbol smex-data)))
(if known-command
(setq smex-cache (cons known-command smex-cache))
(setq new-commands (cons (list symbol) new-commands)))))))
(if (eq (length smex-cache) 0)
(setq smex-cache new-commands)
(setcdr (last smex-cache) new-commands)))
(setq smex-cache (sort smex-cache 'smex-sorting-rules))
(smex-restore-history)
(setq smex-ido-cache (smex-convert-for-ido smex-cache)))
(defun smex-convert-for-ido (command-items)
(mapcar (lambda (command-item) (symbol-name (car command-item))) command-items))
(defun smex-restore-history ()
"Rearranges `smex-cache' according to `smex-history'"
(if (> (length smex-history) smex-history-length)
(setcdr (nthcdr (- smex-history-length 1) smex-history) nil))
(mapc (lambda (command)
(unless (eq command (caar smex-cache))
(let ((command-cell-position (smex-detect-position smex-cache (lambda (cell)
(eq command (caar cell))))))
(if command-cell-position
(let ((command-cell (smex-remove-nth-cell command-cell-position smex-cache)))
(setcdr command-cell smex-cache)
(setq smex-cache command-cell))))))
(reverse smex-history)))
(defun smex-sort-according-to-cache (list)
"Sorts a list of commands by their order in `smex-cache'"
(let (sorted)
(dolist (command-item smex-cache)
(let ((command (car command-item)))
(when (memq command list)
(setq sorted (cons command sorted))
(setq list (delq command list)))))
(nreverse (append list sorted))))
(defun smex-update ()
(interactive)
(smex-save-history)
(smex-rebuild-cache))
(defun smex-detect-new-commands ()
(let ((i 0))
(mapatoms (lambda (symbol) (if (commandp symbol) (setq i (1+ i)))))
(unless (= i smex-command-count)
(setq smex-command-count i))))
(defun smex-auto-update (&optional idle-time)
"Update Smex when Emacs has been idle for IDLE-TIME."
(unless idle-time (setq idle-time 60))
(run-with-idle-timer idle-time t
'(lambda () (if (smex-detect-new-commands) (smex-update)))))
;;;###autoload
(defun smex-initialize ()
(interactive)
(unless ido-mode (smex-initialize-ido))
(smex-load-save-file)
(smex-detect-new-commands)
(smex-rebuild-cache)
(add-hook 'kill-emacs-hook 'smex-save-to-file)
(setq smex-initialized-p t))
(defun smex-initialize-ido ()
"Sets up a minimal Ido environment for `ido-completing-read'."
(ido-init-completion-maps)
(add-hook 'minibuffer-setup-hook 'ido-minibuffer-setup))
(defun smex-load-save-file ()
"Loads `smex-history' and `smex-data' from `smex-save-file'"
(let ((save-file (expand-file-name smex-save-file)))
(if (file-readable-p save-file)
(with-temp-buffer
(insert-file-contents save-file)
(condition-case nil
(setq smex-history (read (current-buffer))
smex-data (read (current-buffer)))
(error (if (save-file-not-empty-p)
(error "Invalid data in smex-save-file (%s). Can't restore history."
smex-save-file)
(if (not (boundp 'smex-history)) (setq smex-history))
(if (not (boundp 'smex-data)) (setq smex-data))))))
(setq smex-history nil smex-data nil))))
(defsubst save-file-not-empty-p ()
(string-match-p "\[^[:space:]\]" (buffer-string)))
(defun smex-save-history ()
"Updates `smex-history'"
(setq smex-history nil)
(let ((cell smex-cache))
(dotimes (i smex-history-length)
(setq smex-history (cons (caar cell) smex-history))
(setq cell (cdr cell))))
(setq smex-history (nreverse smex-history)))
(defun smex-save-to-file ()
(interactive)
(smex-save-history)
(with-temp-file (expand-file-name smex-save-file)
(ido-pp 'smex-history)
(ido-pp 'smex-data)))
;;--------------------------------------------------------------------------------
;; Ranking
(defun smex-sorting-rules (command-item other-command-item)
"Returns true if COMMAND-ITEM should sort before OTHER-COMMAND-ITEM."
(let* ((count (or (cdr command-item ) 0))
(other-count (or (cdr other-command-item) 0))
(name (car command-item))
(other-name (car other-command-item))
(length (length (symbol-name name)))
(other-length (length (symbol-name other-name))))
(or (> count other-count) ; 1. Frequency of use
(and (= count other-count)
(or (< length other-length) ; 2. Command length
(and (= length other-length)
(string< name other-name))))))) ; 3. Alphabetical order
(defun smex-rank (command)
(let ((command-item (or (assq command smex-cache)
;; Update caches and try again if not found.
(progn (smex-update)
(assq command smex-cache)))))
(when command-item
(smex-update-counter command-item)
;; Don't touch the cache order if the chosen command
;; has just been execucted previously.
(unless (eq command-item (car smex-cache))
(let (command-cell
(pos (smex-detect-position smex-cache (lambda (cell)
(eq command-item (car cell))))))
;; Remove the just executed command.
(setq command-cell (smex-remove-nth-cell pos smex-cache))
;; And put it on top of the cache.
(setcdr command-cell smex-cache)
(setq smex-cache command-cell)
;; Repeat the same for the ido cache. Should this be DRYed?
(setq command-cell (smex-remove-nth-cell pos smex-ido-cache))
(setcdr command-cell smex-ido-cache)
(setq smex-ido-cache command-cell)
;; Now put the last history item back to its normal place.
(smex-sort-item-at smex-history-length))))))
(defun smex-update-counter (command-item)
(let ((count (cdr command-item)))
(setcdr command-item
(if count
(1+ count)
;; Else: Command has just been executed for the first time.
;; Add it to `smex-data'.
(if smex-data
(setcdr (last smex-data) (list command-item))
(setq smex-data (list command-item)))
1))))
(defun smex-sort-item-at (n)
"Sorts item at position N in `smex-cache'."
(let* ((command-cell (nthcdr n smex-cache))
(command-item (car command-cell))
(command-count (cdr command-item)))
(let ((insert-at (smex-detect-position command-cell (lambda (cell)
(smex-sorting-rules command-item (car cell))))))
;; TODO: Should we handle the case of 'insert-at' being nil?
;; This will never happen in practice.
(when (> insert-at 1)
(setq command-cell (smex-remove-nth-cell n smex-cache))
;; smex-cache just got shorter by one element, so subtract '1' from insert-at.
(setq insert-at (+ n (- insert-at 1)))
(smex-insert-cell command-cell insert-at smex-cache)
;; Repeat the same for the ido cache. DRY?
(setq command-cell (smex-remove-nth-cell n smex-ido-cache))
(smex-insert-cell command-cell insert-at smex-ido-cache)))))
(defun smex-detect-position (cell function)
"Detects, relatively to CELL, the position of the cell
on which FUNCTION returns true.
Only checks cells after CELL, starting with the cell right after CELL.
Returns nil when reaching the end of the list."
(let ((pos 1))
(catch 'break
(while t
(setq cell (cdr cell))
(if (not cell)
(throw 'break nil)
(if (funcall function cell) (throw 'break pos))
(setq pos (1+ pos)))))))
(defun smex-remove-nth-cell (n list)
"Removes and returns the Nth cell in LIST."
(let* ((previous-cell (nthcdr (- n 1) list))
(result (cdr previous-cell)))
(setcdr previous-cell (cdr result))
result))
(defun smex-insert-cell (new-cell n list)
"Inserts cell at position N in LIST."
(let* ((cell (nthcdr (- n 1) list))
(next-cell (cdr cell)))
(setcdr (setcdr cell new-cell) next-cell)))
;;--------------------------------------------------------------------------------
;; Help and Reference
(defun smex-do-with-selected-item (fn)
(setq smex-custom-action fn)
(ido-exit-minibuffer))
(defun smex-describe-function ()
(interactive)
(smex-do-with-selected-item (lambda (chosen)
(describe-function chosen)
(pop-to-buffer "*Help*"))))
(defun smex-where-is ()
(interactive)
(smex-do-with-selected-item 'where-is))
(defun smex-find-function ()
(interactive)
(smex-do-with-selected-item 'find-function))
(defvar smex-old-message nil
"A temporary storage used by `smex-show-key-advice'")
(defun smex-show-key-advice (command)
"Shows the keybinding for command, if available. Like `execute-extended-command'."
(let ((advice (smex-key-advice command)))
(when advice
(if (current-message)
(progn
(run-at-time 2 nil (lambda (advice)
(setq smex-old-message (current-message))
(smex-unlogged-message advice)) advice)
(run-at-time 4.5 nil (lambda (advice)
(if (equal (current-message) advice)
(smex-unlogged-message smex-old-message))) advice))
(smex-unlogged-message advice)))))
(defun smex-key-advice (command)
(let ((keys (where-is-internal command)))
(if smex-key-advice-ignore-menu-bar
(setq keys (smex-filter-out-menu-bar-bindings keys)))
(if keys
(format "You can run the command `%s' with %s"
command
(mapconcat 'key-description keys ", ")))))
(defsubst smex-filter-out-menu-bar-bindings (keys)
(delq nil (mapcar (lambda (key-vec)
(unless (equal (aref key-vec 0) 'menu-bar)
key-vec))
keys)))
(defun smex-unlogged-message (string)
"Bypasses logging in *Messages*"
(let (message-log-max)
(message "%s" string)))
(defun extract-commands-from-keymap (map)
(let (commands)
(parse-keymap map)
commands))
(defun parse-keymap (map)
(map-keymap (lambda (binding element)
(if (and (listp element) (eq 'keymap (car element)))
(parse-keymap element)
; Strings are commands, too. Reject them.
(if (and (symbolp element) (commandp element))
(setq commands (cons element commands)))))
map))
(defun extract-commands-from-features (mode)
(let ((library-path (symbol-file mode))
(mode-name (symbol-name mode))
commands)
(string-match "\\(.+?\\)\\(-mode\\)?$" mode-name)
;; 'lisp-mode' -> 'lisp'
(setq mode-name (match-string 1 mode-name))
(if (string= mode-name "c") (setq mode-name "cc"))
(setq mode-name (regexp-quote mode-name))
(dolist (feature load-history)
(let ((feature-path (car feature)))
(when (and feature-path (or (equal feature-path library-path)
(string-match mode-name (file-name-nondirectory
feature-path))))
(dolist (item (cdr feature))
(if (and (listp item) (eq 'defun (car item)))
(let ((function (cdr item)))
(when (commandp function)
(setq commands (append commands (list function))))))))))
commands))
(defun smex-show-unbound-commands ()
"Shows unbound commands in a new buffer,
sorted by frequency of use."
(interactive)
(setq smex-data (sort smex-data 'smex-sorting-rules))
(let ((unbound-commands (delq nil
(mapcar (lambda (command-item)
(unless (where-is-internal (car command-item))
command-item))
smex-data))))
(view-buffer-other-window "*Smex: Unbound Commands*")
(setq buffer-read-only t)
(let ((inhibit-read-only t))
(erase-buffer)
(ido-pp 'unbound-commands))
(set-buffer-modified-p nil)
(goto-char (point-min))))
(provide 'smex)
;;; smex.el ends here

View File

@ -0,0 +1,44 @@
;;; starter-kit-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
;;;### (autoloads nil "starter-kit" "starter-kit.el" (20815 21546
;;;;;; 0 0))
;;; Generated autoloads from starter-kit.el
(dolist (mode '(menu-bar-mode tool-bar-mode scroll-bar-mode)) (when (fboundp mode) (funcall mode -1)))
(mapc 'require '(uniquify starter-kit-defuns starter-kit-misc))
(setq esk-system-config (concat user-emacs-directory system-name ".el") esk-user-config (concat user-emacs-directory user-login-name ".el") esk-user-dir (concat user-emacs-directory user-login-name))
(add-to-list 'load-path esk-user-dir)
(setq smex-save-file (concat user-emacs-directory ".smex-items"))
(smex-initialize)
(global-set-key (kbd "M-x") 'smex)
(when (file-exists-p esk-system-config) (load esk-system-config))
(when (file-exists-p esk-user-config) (load esk-user-config))
(when (file-exists-p esk-user-dir) (mapc 'load (directory-files esk-user-dir nil "^[^#].*el$")))
;;;***
;;;### (autoloads nil nil ("starter-kit-defuns.el" "starter-kit-misc.el"
;;;;;; "starter-kit-pkg.el") (20815 21546 307327 0))
;;;***
(provide 'starter-kit-autoloads)
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; starter-kit-autoloads.el ends here

View File

@ -0,0 +1,175 @@
;;; starter-kit-defuns.el --- Saner defaults and goodies: function defs.
;;
;; Copyright (c) 2008-2010 Phil Hagelberg and contributors
;;
;; Author: Phil Hagelberg <technomancy@gmail.com>
;; URL: http://www.emacswiki.org/cgi-bin/wiki/StarterKit
;; Version: 2.0.2
;; Keywords: convenience
;; This file is not part of GNU Emacs.
;;; Commentary:
;; "Emacs outshines all other editing software in approximately the
;; same way that the noonday sun does the stars. It is not just bigger
;; and brighter; it simply makes everything else vanish."
;; -Neal Stephenson, "In the Beginning was the Command Line"
;; This file contains all the function definitions for the starter kit.
;;; 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 GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Code:
;;; These belong in prog-mode-hook:
;; We have a number of turn-on-* functions since it's advised that lambda
;; functions not go in hooks. Repeatedly evaling an add-to-list with a
;; hook value will repeatedly add it since there's no way to ensure
;; that a byte-compiled lambda doesn't already exist in the list.
(defun esk-local-column-number-mode ()
(make-local-variable 'column-number-mode)
(column-number-mode t))
(defun esk-local-comment-auto-fill ()
(set (make-local-variable 'comment-auto-fill-only-comments) t)
(auto-fill-mode t))
(defun esk-turn-on-hl-line-mode ()
(when (> (display-color-cells) 8)
(hl-line-mode t)))
(defun esk-turn-on-save-place-mode ()
(require 'saveplace)
(setq save-place t))
(defun esk-turn-on-whitespace ()
(whitespace-mode t))
(defun esk-turn-on-paredit ()
(paredit-mode t))
(defun esk-turn-on-idle-highlight-mode ()
(idle-highlight-mode t))
(defun esk-pretty-lambdas ()
(font-lock-add-keywords
nil `(("(?\\(lambda\\>\\)"
(0 (progn (compose-region (match-beginning 1) (match-end 1)
,(make-char 'greek-iso8859-7 107))
nil))))))
(defun esk-add-watchwords ()
(font-lock-add-keywords
nil '(("\\<\\(FIX\\|TODO\\|FIXME\\|HACK\\|REFACTOR\\|NOCOMMIT\\)"
1 font-lock-warning-face t))))
(add-hook 'prog-mode-hook 'esk-local-column-number-mode)
(add-hook 'prog-mode-hook 'esk-local-comment-auto-fill)
(add-hook 'prog-mode-hook 'esk-turn-on-hl-line-mode)
(add-hook 'prog-mode-hook 'esk-turn-on-save-place-mode)
(add-hook 'prog-mode-hook 'esk-pretty-lambdas)
(add-hook 'prog-mode-hook 'esk-add-watchwords)
(add-hook 'prog-mode-hook 'esk-turn-on-idle-highlight-mode)
(defun esk-prog-mode-hook ()
(run-hooks 'prog-mode-hook))
(defun esk-turn-off-tool-bar ()
(tool-bar-mode -1))
(defun esk-untabify-buffer ()
(interactive)
(untabify (point-min) (point-max)))
(defun esk-indent-buffer ()
(interactive)
(indent-region (point-min) (point-max)))
(defun esk-cleanup-buffer ()
"Perform a bunch of operations on the whitespace content of a buffer."
(interactive)
(esk-indent-buffer)
(esk-untabify-buffer)
(delete-trailing-whitespace))
;; Commands
(defun esk-eval-and-replace ()
"Replace the preceding sexp with its value."
(interactive)
(backward-kill-sexp)
(condition-case nil
(prin1 (eval (read (current-kill 0)))
(current-buffer))
(error (message "Invalid expression")
(insert (current-kill 0)))))
(defun esk-sudo-edit (&optional arg)
(interactive "p")
(if (or arg (not buffer-file-name))
(find-file (concat "/sudo:root@localhost:" (ido-read-file-name "File: ")))
(find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name))))
(defun esk-lorem ()
"Insert a lorem ipsum."
(interactive)
(insert "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do "
"eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim"
"ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut "
"aliquip ex ea commodo consequat. Duis aute irure dolor in "
"reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla "
"pariatur. Excepteur sint occaecat cupidatat non proident, sunt in "
"culpa qui officia deserunt mollit anim id est laborum."))
(defun esk-suck-it (suckee)
"Insert a comment of appropriate length about what can suck it."
(interactive "MWhat can suck it? ")
(let ((prefix (concat ";; " suckee " can s"))
(postfix "ck it!")
(col (current-column)))
(insert prefix)
(dotimes (_ (- 80 col (length prefix) (length postfix))) (insert "u"))
(insert postfix)))
(defun esk-insert-date ()
"Insert a time-stamp according to locale's date and time format."
(interactive)
(insert (format-time-string "%c" (current-time))))
(defun esk-pairing-bot ()
"If you can't pair program with a human, use this instead."
(interactive)
(message (if (y-or-n-p "Do you have a test for that? ") "Good." "Bad!")))
(defun esk-paredit-nonlisp ()
"Turn on paredit mode for non-lisps."
(interactive)
(set (make-local-variable 'paredit-space-for-delimiter-predicates)
'((lambda (endp delimiter) nil)))
(paredit-mode 1))
;; A monkeypatch to cause annotate to ignore whitespace
(defun vc-git-annotate-command (file buf &optional rev)
(let ((name (file-relative-name file)))
(vc-git-command buf 0 name "blame" "-w" rev)))
(provide 'starter-kit-defuns)
;;; starter-kit-defuns.el ends here

View File

@ -0,0 +1,135 @@
;;; starter-kit-misc.el --- Saner defaults and goodies: miscellany
;;
;; Copyright (c) 2008-2010 Phil Hagelberg and contributors
;;
;; Author: Phil Hagelberg <technomancy@gmail.com>
;; URL: http://www.emacswiki.org/cgi-bin/wiki/StarterKit
;; Version: 2.0.2
;; Keywords: convenience
;; This file is not part of GNU Emacs.
;;; Commentary:
;; "Emacs outshines all other editing software in approximately the
;; same way that the noonday sun does the stars. It is not just bigger
;; and brighter; it simply makes everything else vanish."
;; -Neal Stephenson, "In the Beginning was the Command Line"
;; This file contains setqs and things that aren't bindings or defuns.
;;; 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 GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Code:
(when window-system
(setq frame-title-format '(buffer-file-name "%f" ("%b")))
(tooltip-mode -1)
(mouse-wheel-mode t)
(blink-cursor-mode -1))
;; can't do it at launch or emacsclient won't always honor it
(add-hook 'before-make-frame-hook 'esk-turn-off-tool-bar)
(setq visible-bell t
inhibit-startup-message t
color-theme-is-global t
sentence-end-double-space nil
shift-select-mode nil
mouse-yank-at-point t
uniquify-buffer-name-style 'forward
whitespace-style '(face trailing lines-tail tabs)
whitespace-line-column 80
ediff-window-setup-function 'ediff-setup-windows-plain
oddmuse-directory "~/.emacs.d/oddmuse"
save-place-file "~/.emacs.d/places"
backup-directory-alist `(("." . ,(expand-file-name "~/.emacs.d/backups")))
diff-switches "-u")
(add-to-list 'safe-local-variable-values '(lexical-binding . t))
(add-to-list 'safe-local-variable-values '(whitespace-line-column . 80))
;; Set this to whatever browser you use
;; (setq browse-url-browser-function 'browse-url-firefox)
;; (setq browse-url-browser-function 'browse-default-macosx-browser)
;; (setq browse-url-browser-function 'browse-default-windows-browser)
;; (setq browse-url-browser-function 'browse-default-kde)
;; (setq browse-url-browser-function 'browse-default-epiphany)
;; (setq browse-url-browser-function 'browse-default-w3m)
;; (setq browse-url-browser-function 'browse-url-generic
;; browse-url-generic-program "~/src/conkeror/conkeror")
;; Highlight matching parentheses when the point is on them.
(show-paren-mode 1)
;; ido-mode is like magic pixie dust!
(ido-mode t)
(ido-ubiquitous t)
(setq ido-enable-prefix nil
ido-enable-flex-matching t
ido-auto-merge-work-directories-length nil
ido-create-new-buffer 'always
ido-use-filename-at-point 'guess
ido-use-virtual-buffers t
ido-handle-duplicate-virtual-buffers 2
ido-max-prospects 10)
(set-default 'indent-tabs-mode nil)
(set-default 'indicate-empty-lines t)
(set-default 'imenu-auto-rescan t)
(add-hook 'text-mode-hook 'turn-on-auto-fill)
(add-hook 'text-mode-hook 'turn-on-flyspell)
(defalias 'yes-or-no-p 'y-or-n-p)
(defalias 'auto-tail-revert-mode 'tail-mode)
(random t) ;; Seed the random-number generator
;; Hippie expand: at times perhaps too hip
(dolist (f '(try-expand-line try-expand-list try-complete-file-name-partially))
(delete f hippie-expand-try-functions-list))
;; Add this back in at the end of the list.
(add-to-list 'hippie-expand-try-functions-list 'try-complete-file-name-partially t)
(eval-after-load 'grep
'(when (boundp 'grep-find-ignored-files)
(add-to-list 'grep-find-ignored-files "*.class")))
;; Cosmetics
(eval-after-load 'diff-mode
'(progn
(set-face-foreground 'diff-added "green4")
(set-face-foreground 'diff-removed "red3")))
(eval-after-load 'magit
'(progn
(set-face-foreground 'magit-diff-add "green4")
(set-face-foreground 'magit-diff-del "red3")))
;; Get around the emacswiki spam protection
(eval-after-load 'oddmuse
(add-hook 'oddmuse-mode-hook
(lambda ()
(unless (string-match "question" oddmuse-post)
(setq oddmuse-post (concat "uihnscuskc=1;" oddmuse-post))))))
(provide 'starter-kit-misc)
;;; starter-kit-misc.el ends here

View File

@ -0,0 +1,4 @@
(define-package "starter-kit" "2.0.3"
"Saner defaults and goodies."
'((paredit "22") (idle-highlight-mode "1.1.1") (find-file-in-project "3.0")
(smex "1.1.1") (ido-ubiquitous "0.3") (magit "0.8.1")))

View File

@ -0,0 +1,66 @@
;;; starter-kit.el --- Saner defaults and goodies.
;;
;; Copyright (c) 2008-2011 Phil Hagelberg and contributors
;;
;; Author: Phil Hagelberg <technomancy@gmail.com>
;; URL: http://www.emacswiki.org/cgi-bin/wiki/StarterKit
;; Version: 2.0.2
;; Keywords: convenience
;; This file is not part of GNU Emacs.
;;; Commentary:
;; "Emacs outshines all other editing software in approximately the
;; same way that the noonday sun does the stars. It is not just bigger
;; and brighter; it simply makes everything else vanish."
;; -Neal Stephenson, "In the Beginning was the Command Line"
;; This file just brings together other pieces of the starter kit plus
;; user- and host-specific configs.
;;; 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 GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Code:
;;;###autoload
(progn
;; Turn off mouse interface early in startup to avoid momentary display
(dolist (mode '(menu-bar-mode tool-bar-mode scroll-bar-mode))
(when (fboundp mode) (funcall mode -1)))
(mapc 'require '(uniquify starter-kit-defuns starter-kit-misc))
;; You can keep system- or user-specific customizations here
(setq esk-system-config (concat user-emacs-directory system-name ".el")
esk-user-config (concat user-emacs-directory user-login-name ".el")
esk-user-dir (concat user-emacs-directory user-login-name))
(add-to-list 'load-path esk-user-dir)
(setq smex-save-file (concat user-emacs-directory ".smex-items"))
(smex-initialize)
(global-set-key (kbd "M-x") 'smex)
(when (file-exists-p esk-system-config) (load esk-system-config))
(when (file-exists-p esk-user-config) (load esk-user-config))
(when (file-exists-p esk-user-dir)
(mapc 'load (directory-files esk-user-dir nil "^[^#].*el$"))))
(provide 'starter-kit)
;;; starter-kit.el ends here

View File

@ -0,0 +1,80 @@
;;; starter-kit-bindings-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
;;;### (autoloads nil "starter-kit-bindings" "starter-kit-bindings.el"
;;;;;; (20815 22619 0 0))
;;; Generated autoloads from starter-kit-bindings.el
(global-set-key (kbd "C-c f") 'find-file-in-project)
(global-set-key (kbd "C-M-h") 'backward-kill-word)
(global-set-key (kbd "M-/") 'hippie-expand)
(global-set-key (kbd "C-c n") 'esk-cleanup-buffer)
(global-set-key (kbd "C-<f10>") 'menu-bar-mode)
(define-key global-map (kbd "C-+") 'text-scale-increase)
(define-key global-map (kbd "C--") 'text-scale-decrease)
(global-set-key (kbd "C-s") 'isearch-forward-regexp)
(global-set-key (kbd "") 'isearch-backward-regexp)
(global-set-key (kbd "C-M-s") 'isearch-forward)
(global-set-key (kbd "C-M-r") 'isearch-backward)
(global-set-key (kbd "C-x C-i") 'imenu)
(global-set-key (kbd "C-x M-f") 'ido-find-file-other-window)
(global-set-key (kbd "C-c y") 'bury-buffer)
(global-set-key (kbd "C-c r") 'revert-buffer)
(windmove-default-keybindings)
(global-set-key (kbd "C-x O") (lambda nil (interactive) (other-window -1)))
(global-set-key (kbd "C-x C-o") (lambda nil (interactive) (other-window 2)))
(global-set-key (kbd "C-x m") 'eshell)
(global-set-key (kbd "C-x M") (lambda nil (interactive) (eshell t)))
(global-set-key (kbd "C-x C-m") 'shell)
(global-set-key (kbd "C-c x") 'execute-extended-command)
(global-set-key (kbd "C-h a") 'apropos)
(global-set-key (kbd "C-c e") 'esk-eval-and-replace)
(global-set-key (kbd "C-c q") 'join-line)
(global-set-key (kbd "C-c g") 'magit-status)
(eval-after-load 'vc (define-key vc-prefix-map "i" '(lambda nil (interactive) (if (not (eq 'Git (vc-backend buffer-file-name))) (vc-register) (shell-command (format "git add %s" buffer-file-name)) (message "Staged changes.")))))
(define-key isearch-mode-map (kbd "C-o") (lambda nil (interactive) (let ((case-fold-search isearch-case-fold-search)) (occur (if isearch-regexp isearch-string (regexp-quote isearch-string))))))
;;;***
;;;### (autoloads nil nil ("starter-kit-bindings-pkg.el") (20815
;;;;;; 22619 431347 0))
;;;***
(provide 'starter-kit-bindings-autoloads)
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; starter-kit-bindings-autoloads.el ends here

View File

@ -0,0 +1 @@
(define-package "starter-kit-bindings" "2.0.2" "Saner defaults and goodies: bindings" (quote ((starter-kit "2.0.2"))))

View File

@ -0,0 +1,121 @@
;;; starter-kit-bindings.el --- Saner defaults and goodies: bindings
;;
;; Copyright (c) 2008-2010 Phil Hagelberg and contributors
;;
;; Author: Phil Hagelberg <technomancy@gmail.com>
;; URL: http://www.emacswiki.org/cgi-bin/wiki/StarterKit
;; Version: 2.0.2
;; Keywords: convenience
;; Package-Requires: ((starter-kit "2.0.2"))
;; This file is not part of GNU Emacs.
;;; Commentary:
;; "Emacs outshines all other editing software in approximately the
;; same way that the noonday sun does the stars. It is not just bigger
;; and brighter; it simply makes everything else vanish."
;; -Neal Stephenson, "In the Beginning was the Command Line"
;; This file just contains key bindings.
;;; 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 GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Code:
;;;###autoload
(progn
;; It's all about the project.
(global-set-key (kbd "C-c f") 'find-file-in-project)
;; You know, like Readline.
(global-set-key (kbd "C-M-h") 'backward-kill-word)
;; Completion that uses many different methods to find options.
(global-set-key (kbd "M-/") 'hippie-expand)
;; Perform general cleanup.
(global-set-key (kbd "C-c n") 'esk-cleanup-buffer)
;; Turn on the menu bar for exploring new modes
(global-set-key (kbd "C-<f10>") 'menu-bar-mode)
;; Font size
(define-key global-map (kbd "C-+") 'text-scale-increase)
(define-key global-map (kbd "C--") 'text-scale-decrease)
;; Use regex searches by default.
(global-set-key (kbd "C-s") 'isearch-forward-regexp)
(global-set-key (kbd "\C-r") 'isearch-backward-regexp)
(global-set-key (kbd "C-M-s") 'isearch-forward)
(global-set-key (kbd "C-M-r") 'isearch-backward)
;; Jump to a definition in the current file. (Protip: this is awesome.)
(global-set-key (kbd "C-x C-i") 'imenu)
;; File finding
(global-set-key (kbd "C-x M-f") 'ido-find-file-other-window)
(global-set-key (kbd "C-c y") 'bury-buffer)
(global-set-key (kbd "C-c r") 'revert-buffer)
;; Window switching. (C-x o goes to the next window)
(windmove-default-keybindings) ;; Shift+direction
(global-set-key (kbd "C-x O") (lambda () (interactive) (other-window -1))) ;; back one
(global-set-key (kbd "C-x C-o") (lambda () (interactive) (other-window 2))) ;; forward two
;; Start eshell or switch to it if it's active.
(global-set-key (kbd "C-x m") 'eshell)
;; Start a new eshell even if one is active.
(global-set-key (kbd "C-x M") (lambda () (interactive) (eshell t)))
;; Start a regular shell if you prefer that.
(global-set-key (kbd "C-x C-m") 'shell)
;; If you want to be able to M-x without meta (phones, etc)
(global-set-key (kbd "C-c x") 'execute-extended-command)
;; Help should search more than just commands
(global-set-key (kbd "C-h a") 'apropos)
;; Should be able to eval-and-replace anywhere.
(global-set-key (kbd "C-c e") 'esk-eval-and-replace)
;; M-S-6 is awkward
(global-set-key (kbd "C-c q") 'join-line)
;; So good!
(global-set-key (kbd "C-c g") 'magit-status)
;; This is a little hacky since VC doesn't support git add internally
(eval-after-load 'vc
(define-key vc-prefix-map "i"
'(lambda () (interactive)
(if (not (eq 'Git (vc-backend buffer-file-name)))
(vc-register)
(shell-command (format "git add %s" buffer-file-name))
(message "Staged changes.")))))
;; Activate occur easily inside isearch
(define-key isearch-mode-map (kbd "C-o")
(lambda () (interactive)
(let ((case-fold-search isearch-case-fold-search))
(occur (if isearch-regexp isearch-string (regexp-quote isearch-string)))))))
(provide 'starter-kit-bindings)
;;; starter-kit-bindings.el ends here

View File

@ -0,0 +1,52 @@
;;; starter-kit-lisp-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
;;;### (autoloads nil "starter-kit-lisp" "starter-kit-lisp.el" (20815
;;;;;; 22618 0 0))
;;; Generated autoloads from starter-kit-lisp.el
(add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
(add-hook 'emacs-lisp-mode-hook 'esk-remove-elc-on-save)
(add-hook 'emacs-lisp-mode-hook 'esk-prog-mode-hook)
(add-hook 'emacs-lisp-mode-hook 'elisp-slime-nav-mode)
(defun esk-remove-elc-on-save nil "\
If you're saving an elisp file, likely the .elc is no longer valid." (make-local-variable (quote after-save-hook)) (add-hook (quote after-save-hook) (lambda nil (if (file-exists-p (concat buffer-file-name "c")) (delete-file (concat buffer-file-name "c"))))))
(define-key emacs-lisp-mode-map (kbd "C-c v") 'eval-buffer)
(define-key read-expression-map (kbd "TAB") 'lisp-complete-symbol)
(define-key lisp-mode-shared-map (kbd "RET") 'reindent-then-newline-and-indent)
(defface esk-paren-face '((((class color) (background dark)) (:foreground "grey50")) (((class color) (background light)) (:foreground "grey55"))) "\
Face used to dim parentheses." :group (quote starter-kit-faces))
(eval-after-load 'paredit '(define-key paredit-mode-map (kbd "M-)") 'paredit-forward-slurp-sexp))
(dolist (mode '(scheme emacs-lisp lisp clojure)) (when (> (display-color-cells) 8) (font-lock-add-keywords (intern (concat (symbol-name mode) "-mode")) '(("(\\|)" quote esk-paren-face)))) (add-hook (intern (concat (symbol-name mode) "-mode-hook")) 'esk-turn-on-paredit) (add-hook (intern (concat (symbol-name mode) "-mode-hook")) 'esk-turn-on-paredit))
(defun esk-pretty-fn nil (font-lock-add-keywords nil `(("(\\(fn\\>\\)" (0 (progn (compose-region (match-beginning 1) (match-end 1) "ƒ") nil))))))
(add-hook 'clojure-mode-hook 'esk-pretty-fn)
;;;***
;;;### (autoloads nil nil ("starter-kit-lisp-pkg.el") (20815 22618
;;;;;; 616623 0))
;;;***
(provide 'starter-kit-lisp-autoloads)
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; starter-kit-lisp-autoloads.el ends here

View File

@ -0,0 +1 @@
(define-package "starter-kit-lisp" "2.0.3" "Saner defaults and goodies for lisp languages" (quote ((starter-kit "2.0.2") (elisp-slime-nav "0.1"))))

View File

@ -0,0 +1,95 @@
;;; starter-kit-lisp.el --- Saner defaults and goodies for lisp languages
;;
;; Copyright (c) 2008-2011 Phil Hagelberg and contributors
;;
;; Author: Phil Hagelberg <technomancy@gmail.com>
;; URL: http://www.emacswiki.org/cgi-bin/wiki/StarterKit
;; Version: 2.0.3
;; Keywords: convenience
;; Package-Requires: ((starter-kit "2.0.2") (elisp-slime-nav "0.1"))
;; This file is not part of GNU Emacs.
;;; Commentary:
;; "Emacs outshines all other editing software in approximately the
;; same way that the noonday sun does the stars. It is not just bigger
;; and brighter; it simply makes everything else vanish."
;; -Neal Stephenson, "In the Beginning was the Command Line"
;; This file contains tweaks specific to Lisp languages.
;;; 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 GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Code:
;; Emacs Lisp
;;;###autoload
(progn
(add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
(add-hook 'emacs-lisp-mode-hook 'esk-remove-elc-on-save)
(add-hook 'emacs-lisp-mode-hook 'esk-prog-mode-hook)
(add-hook 'emacs-lisp-mode-hook 'elisp-slime-nav-mode)
(defun esk-remove-elc-on-save ()
"If you're saving an elisp file, likely the .elc is no longer valid."
(make-local-variable 'after-save-hook)
(add-hook 'after-save-hook
(lambda ()
(if (file-exists-p (concat buffer-file-name "c"))
(delete-file (concat buffer-file-name "c"))))))
(define-key emacs-lisp-mode-map (kbd "C-c v") 'eval-buffer)
;;; Enhance Lisp Modes
(define-key read-expression-map (kbd "TAB") 'lisp-complete-symbol)
(define-key lisp-mode-shared-map (kbd "RET") 'reindent-then-newline-and-indent)
;; TODO: look into parenface package
(defface esk-paren-face
'((((class color) (background dark))
(:foreground "grey50"))
(((class color) (background light))
(:foreground "grey55")))
"Face used to dim parentheses."
:group 'starter-kit-faces)
(eval-after-load 'paredit
;; need a binding that works in the terminal
'(define-key paredit-mode-map (kbd "M-)") 'paredit-forward-slurp-sexp))
(dolist (mode '(scheme emacs-lisp lisp clojure))
(when (> (display-color-cells) 8)
(font-lock-add-keywords (intern (concat (symbol-name mode) "-mode"))
'(("(\\|)" . 'esk-paren-face))))
(add-hook (intern (concat (symbol-name mode) "-mode-hook"))
'esk-turn-on-paredit)
(add-hook (intern (concat (symbol-name mode) "-mode-hook"))
'esk-turn-on-paredit))
(defun esk-pretty-fn ()
(font-lock-add-keywords nil `(("(\\(fn\\>\\)"
(0 (progn (compose-region (match-beginning 1)
(match-end 1)
"\u0192") nil))))))
(add-hook 'clojure-mode-hook 'esk-pretty-fn))
(provide 'starter-kit-lisp)
;;; starter-kit-lisp.el ends here

View File

@ -0,0 +1,65 @@
;;; starter-kit-ruby-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
;;;### (autoloads nil "starter-kit-ruby" "starter-kit-ruby.el" (20815
;;;;;; 21578 0 0))
;;; Generated autoloads from starter-kit-ruby.el
(eval-after-load 'ruby-mode '(progn (ignore-errors (require 'ruby-compilation)) (setq ruby-use-encoding-map nil) (add-hook 'ruby-mode-hook 'inf-ruby-keys) (define-key ruby-mode-map (kbd "RET") 'reindent-then-newline-and-indent) (define-key ruby-mode-map (kbd "C-M-h") 'backward-kill-word)))
(global-set-key (kbd "C-h S-r") 'ri)
(add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.thor$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.gemspec$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.ru$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Thorfile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Gemfile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Capfile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Vagrantfile$" . ruby-mode))
(add-to-list 'completion-ignored-extensions ".rbc")
(add-to-list 'completion-ignored-extensions ".rbo")
(defun pcomplete/rake nil "\
Completion rules for the `ssh' command." (pcomplete-here (pcmpl-rake-tasks)))
(defun pcmpl-rake-tasks nil "\
Return a list of all the rake tasks defined in the current
projects. I know this is a hack to put all the logic in the
exec-to-string command, but it works and seems fast" (delq nil (mapcar (quote (lambda (line) (if (string-match "rake \\([^ ]+\\)" line) (match-string 1 line)))) (split-string (shell-command-to-string "rake -T") "[
]"))))
(defun rake (task) (interactive (list (completing-read "Rake (default: default): " (pcmpl-rake-tasks)))) (shell-command-to-string (concat "rake " (if (= 0 (length task)) "default" task))))
(eval-after-load 'ruby-compilation '(progn (defadvice ruby-do-run-w/compilation (before kill-buffer (name cmdlist)) (let ((comp-buffer-name (format "*%s*" name))) (when (get-buffer comp-buffer-name) (with-current-buffer comp-buffer-name (delete-region (point-min) (point-max)))))) (ad-activate 'ruby-do-run-w/compilation)))
(setq rinari-major-modes (list 'mumamo-after-change-major-mode-hook 'dired-mode-hook 'ruby-mode-hook 'css-mode-hook 'yaml-mode-hook 'javascript-mode-hook))
;;;***
;;;### (autoloads nil nil ("starter-kit-ruby-pkg.el") (20815 21578
;;;;;; 150254 0))
;;;***
(provide 'starter-kit-ruby-autoloads)
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; starter-kit-ruby-autoloads.el ends here

View File

@ -0,0 +1 @@
(define-package "starter-kit-ruby" "2.0.3" "Saner defaults and goodies for Ruby" (quote ((inf-ruby "2.2.3") (starter-kit "2.0.1"))))

View File

@ -0,0 +1,106 @@
;;; starter-kit-ruby.el --- Saner defaults and goodies for Ruby
;;
;; Copyright (c) 2008-2010 Phil Hagelberg and contributors
;;
;; Author: Phil Hagelberg <technomancy@gmail.com>
;; URL: http://www.emacswiki.org/cgi-bin/wiki/StarterKit
;; Version: 2.0.3
;; Keywords: convenience
;; Package-Requires: ((inf-ruby "2.2.3") (starter-kit "2.0.1"))
;; This file is not part of GNU Emacs.
;;; Commentary:
;; "Emacs outshines all other editing software in approximately the
;; same way that the noonday sun does the stars. It is not just bigger
;; and brighter; it simply makes everything else vanish."
;; -Neal Stephenson, "In the Beginning was the Command Line"
;; This file contains tweaks specific to Ruby.
;; This file is in need of a maintainer.
;;; 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 GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Code:
;;;###autoload
(progn
(eval-after-load 'ruby-mode
'(progn
;; work around possible elpa bug
(ignore-errors (require 'ruby-compilation))
(setq ruby-use-encoding-map nil)
(add-hook 'ruby-mode-hook 'inf-ruby-keys)
(define-key ruby-mode-map (kbd "RET") 'reindent-then-newline-and-indent)
(define-key ruby-mode-map (kbd "C-M-h") 'backward-kill-word)))
(global-set-key (kbd "C-h S-r") 'ri)
;; Rake files are ruby, too, as are gemspecs, rackup files, etc.
(add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.thor$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.gemspec$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.ru$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Thorfile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Gemfile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Capfile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Vagrantfile$" . ruby-mode))
;; We never want to edit Rubinius bytecode or MacRuby binaries
(add-to-list 'completion-ignored-extensions ".rbc")
(add-to-list 'completion-ignored-extensions ".rbo")
;;; Rake
(defun pcomplete/rake ()
"Completion rules for the `ssh' command."
(pcomplete-here (pcmpl-rake-tasks)))
(defun pcmpl-rake-tasks ()
"Return a list of all the rake tasks defined in the current
projects. I know this is a hack to put all the logic in the
exec-to-string command, but it works and seems fast"
(delq nil (mapcar '(lambda(line)
(if (string-match "rake \\([^ ]+\\)" line) (match-string 1 line)))
(split-string (shell-command-to-string "rake -T") "[\n]"))))
(defun rake (task)
(interactive (list (completing-read "Rake (default: default): "
(pcmpl-rake-tasks))))
(shell-command-to-string (concat "rake " (if (= 0 (length task)) "default" task))))
;; Clear the compilation buffer between test runs.
(eval-after-load 'ruby-compilation
'(progn
(defadvice ruby-do-run-w/compilation (before kill-buffer (name cmdlist))
(let ((comp-buffer-name (format "*%s*" name)))
(when (get-buffer comp-buffer-name)
(with-current-buffer comp-buffer-name
(delete-region (point-min) (point-max))))))
(ad-activate 'ruby-do-run-w/compilation)))
;; Rinari (Minor Mode for Ruby On Rails)
(setq rinari-major-modes
(list 'mumamo-after-change-major-mode-hook 'dired-mode-hook 'ruby-mode-hook
'css-mode-hook 'yaml-mode-hook 'javascript-mode-hook)))
(provide 'starter-kit-ruby)
;;; starter-kit-ruby.el ends here

44
init.el
View File

@ -87,16 +87,16 @@
(require 'multi-line-it)
;; Pymacs
(require 'pymacs)
(autoload 'pymacs-apply "pymacs")
(autoload 'pymacs-call "pymacs")
(autoload 'pymacs-eval "pymacs" nil t)
(autoload 'pymacs-exec "pymacs" nil t)
(autoload 'pymacs-load "pymacs" nil t)
(autoload 'pymacs-autoload "pymacs")
;; Rope
(pymacs-load "ropemacs" "rope-")
(add-hook 'python-mode-hook
(lambda ()
(require 'pymacs)
(autoload 'pymacs-apply "pymacs")
(autoload 'pymacs-call "pymacs")
(autoload 'pymacs-eval "pymacs" nil t)
(autoload 'pymacs-exec "pymacs" nil t)
(autoload 'pymacs-load "pymacs" nil t)
(autoload 'pymacs-autoload "pymacs")
(pymacs-load "ropemacs" "rope-")))
(defun python-tabs ()
(setq tab-width 4,
@ -134,6 +134,24 @@
'("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)
;; (when (not package-archive-contents)
;; (package-refresh-contents))
;; Add in your own as you wish:
;; (defvar my-packages '(starter-kit starter-kit-bindings)
;; "A list of packages to ensure are installed at launch.")
;; (when (not package-archive-contents)
;; (package-refresh-contents))
;; ;; Add in your own as you wish:
;; (defvar my-packages '(starter-kit starter-kit-lisp starter-kit-bindings)
;; "A list of packages to ensure are installed at launch.")
;; (dolist (p my-packages)
;; (when (not (package-installed-p p))
;; (package-install p)))
;; =============================================================================
;; elisp Helpers
;; =============================================================================
@ -178,4 +196,8 @@
'(rainbow-delimiters-depth-8-face ((t (:foreground "yellow"))))
'(rainbow-delimiters-depth-9-face ((t (:foreground "magenta")))))
(load-file "~/.emacs.d/emacs-for-python/epy-init.el")
;; =============================================================================
;; Starter Kits
;; =============================================================================
(load-file "~/.emacs.d/emacs-for-python/epy-init.el")