Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add anything.el into the game.

  • Loading branch information...
commit 66abae9f04c58d13625cc650df97fc0bdae620f7 1 parent 76eb8b9
@jlouis authored
View
1,208 auto-install.el
@@ -0,0 +1,1208 @@
+;;; auto-install.el --- Auto install elisp file
+
+;; Filename: auto-install.el
+;; Description: Auto install elisp file
+;; Author: Andy Stewart <lazycat.manatee@gmail.com>
+;; rubikitch <rubikitch@ruby-lang.org>
+;; Maintainer: rubikitch <rubikitch@ruby-lang.org>
+;; Copyright (C) 2008, 2009, Andy Stewart, all rights reserved.
+;; Copyright (C) 2009, rubikitch, all rights reserved.
+;; Created: 2008-12-11 13:56:50
+;; Version: $Revision: 1.20 $
+;; Last-Updated: 2009/11/26 22:41:56 +0900
+;; By: Tomohiko KOSAKA
+;; URL: http://www.emacswiki.org/emacs/download/auto-install.el
+;; Keywords: auto-install
+;; Compatibility: GNU Emacs 22 ~ 23
+;;
+;; Features that might be required by this library:
+;;
+;; `backquote', `bytecomp', `dired', `find-func', `ietf-drums',
+;; `loadhist', `mail-parse', `mail-prsvr', `mailcap', `mm-util',
+;; `qp', `rfc2045', `rfc2047', `rfc2231', `thingatpt', `time-date',
+;; `timezone', `url', `url-cookie', `url-expand', `url-history',
+;; `url-methods', `url-parse', `url-privacy', `url-proxy',
+;; `url-util', `url-vars'.
+;;
+
+(defvar auto-install-version "$Id: auto-install.el,v 1.20 2009/11/26 22:41:56 +0900 Tomohiko KOSAKA Exp $")
+;;; 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 this program; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+;; Floor, Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+;;
+;; Automates the installation of Emacs Lisp files and packages.
+;;
+;; `auto-install' provides an automated way to:
+;;
+;; (1) Download Emacs Lisp files and packages from common sources
+;; (2) View them (diff) and save them to your repository
+;; (3) Compile and Load them
+;;
+
+;;; Commands:
+;;
+;; Below are complete command list:
+;;
+;; `auto-install-minor-mode'
+;; Auto Install minor mode.
+;; `auto-install-from-buffer'
+;; Install the elisp file in the current buffer.
+;; `auto-install-from-url'
+;; Install an elisp file from a given url.
+;; `auto-install-from-emacswiki'
+;; Install an elisp file from EmacsWiki.org.
+;; `auto-install-from-gist'
+;; Install an elisp file from gist.github.com.
+;; `auto-install-from-library'
+;; Update an elisp LIBRARY.
+;; `auto-install-from-directory'
+;; Update elisp files under DIRECTORY from EmacsWiki.
+;; `auto-install-from-dired'
+;; Update dired marked elisp files from EmacsWiki.org.
+;; `auto-install-update-emacswiki-package-name'
+;; Update the list of elisp package names from `EmacsWiki'.
+;; `auto-install-dired-mark-files'
+;; Mark dired files that contain at `EmacsWiki.org'.
+;; `auto-install-mode'
+;; Major mode for auto-installing elisp code.
+;; `auto-install-buffer-quit'
+;; Quit from `auto-install' temporary buffer.
+;; `auto-install-compatibility-setup'
+;; Install Compatibility commands for install-elisp.el users.
+;; `auto-install-batch'
+;; Batch install many libraries in some extension.
+;; `auto-install-buffer-diff'
+;; View different between old version.
+;; `auto-install-buffer-save'
+;; Save downloaded content to file FILENAME.
+;;
+;;; Customizable Options:
+;;
+;; Below are customizable option list:
+;;
+;; `auto-install-directory'
+;; The directory for saving elisp files.
+;; default = "~/.emacs.d/auto-install/"
+;; `auto-install-buffer-name'
+;; The temporary buffer for storing download content.
+;; default = "auto-install"
+;; `auto-install-emacswiki-base-url'
+;; The base emacswiki.org url from which to download elisp files.
+;; default = "http://www.emacswiki.org/cgi-bin/wiki/download/"
+;; `auto-install-gist-base-url'
+;; The base gist.github.com url from which to download elisp files.
+;; default = "http://gist.github.com/"
+;; `auto-install-filter-url'
+;; Alist mapping filter url for library.
+;; default = (quote (("color-grep" "http://www.bookshelf.jp/elc/")))
+;; `auto-install-save-confirm'
+;; Whether confirmation is needed to save downloaded content.
+;; default = t
+;; `auto-install-replace-confirm'
+;; Whether confirmation is needed to replace an existing elisp file.
+;; default = nil
+;; `auto-install-install-confirm'
+;; Whether confirmation is needed to install a downloaded elisp file.
+;; default = nil
+;; `auto-install-from-dired-confirm'
+;; Whether confirmation is needed to download marked files from Dired.
+;; default = t
+;; `auto-install-batch-list'
+;; This list contain packages information for batch install.
+;; default = (quote (("icicles" 21 10 ...) ("auto-complete development version" nil nil ...) ("anything" nil nil ...) ("sdcv" nil nil ...) ("lazy-search" nil nil ...) ...))
+
+;;; Tips:
+;;
+;; Downloading is asynchronous: you can do your work and download
+;; files at the same time. The download process won't hang
+;; Emacs.
+;;
+;; `auto-install-from-url' remembers previous installations. So if
+;; your search is the same as the previous search, you don't need
+;; to type it in, just hit RETURN.
+;;
+;; `auto-install-from-emacswiki' will complete then names of
+;; packages from those in the Elisp area in `EmacsWiki'.
+;;
+;; `auto-install-from-library' will prompt you library name in
+;; you load-path, then it try to download from EmacsWiki if it
+;; can't find match in `auto-install-filter-url'.
+;;
+;; `auto-install-from-directory' can install elisp file
+;; under specify directory.
+;;
+;; `auto-install-from-dired' can install marked files using dired.
+;; You can mark the files you want in dired and then use
+;; `auto-install-from-dired' to download those files
+;; asynchronously.
+;;
+;; `auto-install-from-buffer' can save and install the contents of
+;; the current buffer as a file. You need a valid elisp file name.
+;; The default name is the buffer name.
+;;
+;; `auto-install-from-emacswiki' and `auto-install-from-library'
+;; will try to pick up file around point, you can move
+;; cursor to file name, and just hit RET for install.
+;;
+;; Some extension (such as icicles) have many libraries to need install,
+;; and install one by one is painful, you can use command
+;; `auto-install-batch' install all icicles libraries.
+;; And `auto-install-batch' handle max connect limit with some website
+;; (such as EmacsWiki) to avoid download failed.
+;;
+;; All of the above functions support a filename filter. You can
+;; input any url to download an elisp file, if the file name suffix is
+;; `.el', it will download and install the file automatically.
+;; Otherwise, it won't install it unless you input a valid elisp
+;; file name.
+;;
+;; By default, if a file that you download does not exist on your
+;; system the file is downloaded to `auto-install-directory'. If
+;; you already have a file with the same name in your load
+;; directory, `auto-install' will try to replace that file.
+;;
+;; You can use command `auto-install-dired-mark-files' to mark files
+;; that contain at `EmacsWiki.org' for fast update.
+;;
+;; By default, command `auto-install-from-emacswiki' will initialization
+;; current symbol as default value, if default value is you want,
+;; just hit RET, so lazy!
+;;
+
+;;; Installation:
+;;
+;; (1) Put auto-install.el somewhere in your load-path.
+;;
+;; For example, put it into ~/elisp/.
+;; Then add the following to your ~/.emacs:
+;;
+;; (add-to-list 'load-path (expand-file-name "~/elisp"))
+;;
+;; (2) And put the following in your ~/.emacs startup file:
+;;
+;; (require 'auto-install)
+;;
+;; (3) Add this to your ~/.emacs to optionally specify a download directory:
+;;
+;; (setq auto-install-directory "~/.emacs.d/auto-install/")
+;;
+;; If you don't set this, "~/.emacs.d/auto-install/" will be used as the default,
+;; and will be created as needed.
+;;
+;; (4) Optionally, if your computer is always connected Internet when Emacs start up,
+;; I recommend you add below to your ~/.emacs, to update package name when start up:
+;;
+;; (auto-install-update-emacswiki-package-name t)
+;;
+;; And above setup is not necessary, because AutoInstall will automatically update
+;; package name when you just first call `auto-install-from-emacswiki',
+;; above setup just avoid *delay* when you first call `auto-install-from-emacswiki'.
+;;
+;; (5) I recommend you add below to your ~/.emacs for install-elisp users:
+;;
+;; (auto-install-compatibility-setup)
+;;
+;; This command `defalias'es `install-elisp',
+;; `install-elisp-from-emacswiki' and `install-elisp-from-gist' to
+;; `auto-install' ones.
+;;
+;; (6) If you want to use proxy server, set `url-proxy-services'. For example:
+;;
+;; (setq url-proxy-services '(("http" . "localhost:8339")))
+
+;;; Customize:
+;;
+;; `auto-install-directory'
+;; The default directory for keeping auto-downloaded elisp files.
+;;
+;; `auto-install-buffer-name'
+;; The base buffer name for temporarily storing downloaded download content.
+;;
+;; `auto-install-emacswiki-base-url'
+;; The base url for downloading from EmacsWiki.org.
+;;
+;; `auto-install-gist-base-url'
+;; The base url for downloading from gist.github.com
+;;
+;; `auto-install-filter-url'
+;; Filter url for downloading a special library.
+;;
+;; `auto-install-save-confirm'
+;; Whether to require confirmation when saving downloaded content.
+;;
+;; `auto-install-replace-confirm'
+;; Whether to require confirmation when replacing an already-installed
+;; file.
+;;
+;; `auto-install-install-confirm'
+;; Whether to require confirmation when installing a file.
+;;
+;; `auto-install-from-dired-confirm'
+;; Whether to require confirmation when downloading files marked in dired.
+;;
+;; `auto-install-batch-list'
+;; This list contain packages information for batch install.
+;; Anyone can add packages information in this list for batch install.
+;;
+;; And all above option can customize easy through:
+;; M-x RET customize-group RET auto-install RET
+;;
+
+;;; Change log:
+;;
+;; $Log: auto-install.el,v $
+;; Revision 1.20 2009/11/26 22:41:56 Tomohiko KOSAKA
+;; Fix `auto-install-buffer-save'.
+;;
+;; Revision 1.19 2009/05/22 13:04:56 dadams
+;; Split icicles-cmd.el into icicles-cmd[12].el.
+;;
+;; Revision 1.18 2009/05/20 15:42:54 rubikitch
+;; Add php-completion / perl-completion to auto-install-batch-list
+;;
+;; Revision 1.17 2009/05/20 01:19:15 rubikitch
+;; Add document for proxy server
+;;
+;; Revision 1.16 2009/05/15 20:28:18 rubikitch
+;; More readable temporary buffer name.
+;;
+;; Revision 1.15 2009/05/15 20:12:49 rubikitch
+;; Added missing require
+;;
+;; Revision 1.14 2009/05/15 20:11:44 rubikitch
+;; How to save
+;;
+;; Revision 1.13 2009/05/15 20:09:07 rubikitch
+;; Code cleanup
+;;
+;; Revision 1.12 2009/05/15 19:59:30 rubikitch
+;; Fixed a bug of single file installation
+;;
+;; Revision 1.11 2009/05/15 19:44:32 rubikitch
+;; Ordering `auto-install-batch'
+;;
+;; Revision 1.10 2009/05/15 17:48:09 rubikitch
+;; Replace `message' with `error' for error messages.
+;;
+;; Revision 1.9 2009/05/15 17:40:37 rubikitch
+;; refactoring
+;;
+;; Revision 1.8 2009/05/15 17:19:47 rubikitch
+;; refactoring
+;;
+;; Revision 1.7 2009/05/15 17:17:03 rubikitch
+;; Use `view-mode' if `view-read-only'.
+;;
+;; Revision 1.6 2009/05/15 17:10:22 rubikitch
+;; Adjust docstrings of commands to auto-document.
+;; Delete `It provides the following commands:' section because of duplication.
+;;
+;; Revision 1.5 2009/05/15 17:03:13 rubikitch
+;; Show downloaded URL in header-line.
+;;
+;; Revision 1.4 2009/05/15 16:59:32 rubikitch
+;; New internal variable: `auto-install-add-load-path-flag'
+;;
+;; Revision 1.3 2009/05/09 02:41:32 rubikitch
+;; Add `auto-install-directory' automatically.
+;;
+;; Revision 1.2 2009/05/09 02:37:14 rubikitch
+;; Changed `auto-install-get-buffer' format (including URL)
+;;
+;; Revision 1.1 2009/05/09 02:33:09 rubikitch
+;; Initial revision
+;;
+;; 2009/05/01
+;; * Andy Stewart:
+;; * Take over by rubikitch.
+;;
+;; 2009/04/15
+;; * rubikitch:
+;; * Encoding detection support.
+;;
+;; 2009/04/07
+;; * Andy Stewart:
+;; * Fix bug of `auto-install-batch'.
+;; * Add more sources to `auto-install-batch-list'.
+;;
+;; 2009/03/30
+;; * Andy Stewart:
+;; * Add new command: `auto-install-batch'.
+;; * Add new option: `auto-install-batch-list'.
+;;
+;; 2009/03/29
+;; * Andy Stewart:
+;; * Add new function: `auto-install-from-url-list'.
+;;
+;; 2009/03/11
+;; * Andy Stewart:
+;; * Fix bug of `auto-install-download'.
+;;
+;; 2009/03/03
+;; * rubikitch
+;; * Add new command `auto-install-compatibility-setup'
+;; for install-elisp users.
+;; * Andy Stewart:
+;; * `auto-install-region-or-thing' return region string
+;; just when `transient-mark-mode' is on.
+;; * Fix doc.
+;;
+;; 2009/02/17
+;; * Andy Stewart:
+;; * Modified keybindings, make it more easy to remember.
+;; * Make `auto-install-save-confirm' default with `t'
+;; for security problem.
+;; * Pick up current symbol when use `auto-install-from-library'.
+;; * Remove unnecessary completion name from `auto-install-from-library'.
+;; * Refactory code.
+;; * Fix doc.
+;;
+;; 2009/02/12
+;; * Andy Stewart:
+;; * Remove option `auto-install-update-emacswiki-package-name-when-startup'.
+;; * Make current symbol as initialization of `auto-install-from-emacswiki'.
+;; * Add option `unforced' to function `auto-install-update-emacswiki-package-name'.
+;; * Fix doc.
+;; * Fix bug of `auto-install-from-library'.
+;;
+;; 2009/02/10
+;; * Andy Stewart:
+;; * Automatically download package name list when
+;; variable `auto-install-package-name-list' is nil.
+;; * Reverse `auto-install-package-name-list' for `anything' interface.
+;; * New command `auto-install-dired-mark-files',
+;; mark files that contain at `EmacsWiki.org'.
+;; * New command `auto-install-buffer-diff',
+;; view different between current version and old version.
+;;
+;; 2009/02/06
+;; * Andy Stewart:
+;; * Add new command `auto-install-from-directory'.
+;; * Remove option `auto-install-create-directory', not necessary.
+;; * Documentation improvements (thanks Scot Becker)
+;;
+;; 2009/02/01
+;; * Andy Stewart:
+;; * Make command `auto-install-from-emacswiki' can
+;; completing package name for input.
+;; * Add new command `auto-install-update-emacswiki-package-name'.
+;; * Add new option `auto-install-update-emacswiki-package-name-when-startup'
+;;
+;; 2009/01/30
+;; * Andy Stewart:
+;; * Compatibility with GNU Emacs 22.
+;;
+;; 2009/01/26
+;; * Andy Stewart:
+;; * Add new command `auto-install-from-gist'.
+;;
+;; 2009/01/21
+;; * Andy Stewart:
+;; * Add emacs-lisp syntax highlight for download buffer.
+;; * Make notify message display at mode-line instead echo-area.
+;;
+;; 2009/01/10
+;; * Andy Stewart:
+;; * Add new option `auto-install-filter-url' and new function
+;; `auto-install-from-library', try to use it. ;)
+;;
+;; 2009/01/08
+;; * Andy Stewart:
+;; * Fix coding bug.
+;;
+;; 2009/01/07
+;; * Andy Stewart:
+;; * Move `w3m' code to file `auto-install-extension.el' to make all
+;; user can use this package with standard emacs.
+;;
+;; 2009/01/06
+;; * Andy Stewart:
+;; * Clean code.
+;;
+;; 2009/01/02
+;; * Andy Stewart:
+;; * Add new option `auto-install-create-directory' for create install directory
+;; automatically if it doesn't exist.
+;; * Improve many document make it more clear.
+;; * Thanks document improve and create directory advice of 'Drew Adams'!
+;;
+;; 2008/12/24
+;; * Andy Stewart:
+;; * Remove `auto-install-window-configuration-before-download', `auto-install-init-window-layout'
+;; and `auto-install-revert-window-layout'.
+;; It's not necessary to revert window layout, `winner-mode' can revert window layout more better,
+;; just type `winner-undo'.
+;;
+;; 2008/12/15
+;; * Andy Stewart:
+;; * Fix a little bug of `auto-install-window-configuration-before-download'.
+;;
+;; 2008/12/11
+;; * Andy Stewart:
+;; * Add new function `auto-install-from-buffer', to install elisp file from current buffer.
+;; Modified `auto-install-buffer-save' to use `auto-install-from-buffer'.
+;;
+;; * First released.
+;;
+
+;;; Acknowledgements:
+;;
+;; rubikitch <rubikitch@ruby-lang.org>
+;; For install-elisp.el
+;; Drew Adams <drew.adams@oracle.com>
+;; Scot Becker <scot.becker@gmail.com>
+;; Richard Riley <rileyrgdev@gmail.com>
+;; For documentation improvements and advices.
+;;
+
+;;; TODO
+;;
+;; Fix the problem parallel install process with recursive prompt.
+;; Redesign and give more friendly user interface.
+;; Scan RSS track package update and notify.
+;;
+
+;;; Require
+(require 'url)
+(require 'dired)
+(require 'find-func)
+(require 'bytecomp)
+(require 'thingatpt)
+(eval-when-compile (require 'cl))
+(when (<= emacs-major-version 22) ;Compatibility with 22.
+ (autoload 'ignore-errors "cl-macs"))
+
+;;; Code:
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Customize ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(defgroup auto-install nil
+ "Auto install elisp files."
+ :group 'external)
+
+(defcustom auto-install-directory "~/.emacs.d/auto-install/"
+ "The directory for saving elisp files.
+This directory is used when a downloaded
+elisp file does not already exist in other directory.
+Otherwise, the existing file of the same name is replaced."
+ :type 'string
+ :group 'auto-install)
+
+(defcustom auto-install-buffer-name "auto-install"
+ "The temporary buffer for storing download content."
+ :type 'string
+ :group 'auto-install)
+
+(defcustom auto-install-emacswiki-base-url "http://www.emacswiki.org/cgi-bin/wiki/download/"
+ "The base emacswiki.org url from which to download elisp files."
+ :type 'string
+ :group 'auto-install)
+
+(defcustom auto-install-gist-base-url "http://gist.github.com/"
+ "The base gist.github.com url from which to download elisp files."
+ :type 'string
+ :group 'auto-install)
+
+(defcustom auto-install-filter-url
+ '(("color-grep" "http://www.bookshelf.jp/elc/"))
+ "Alist mapping filter url for library.
+Default command `auto-install-from-library' will install from EmacsWiki,
+if it can't find match in this alist."
+ :type '(repeat (list (string :tag "Library")
+ (string :tag "Download URL")))
+ :group 'auto-install)
+
+(defcustom auto-install-save-confirm t
+ "Whether confirmation is needed to save downloaded content.
+Nil means no confirmation is needed.
+If non-nil, the downloaded content is shown in a buffer and you are
+prompted to confirm saving it to a file."
+ :type 'boolean
+ :group 'auto-install)
+
+(defcustom auto-install-replace-confirm nil
+ "Whether confirmation is needed to replace an existing elisp file.
+Nil means no confirmation is needed."
+ :type 'boolean
+ :group 'auto-install)
+
+(defcustom auto-install-install-confirm nil
+ "Whether confirmation is needed to install a downloaded elisp file.
+Nil means no confirmation is needed."
+ :type 'boolean
+ :group 'auto-install)
+
+(defcustom auto-install-from-dired-confirm t
+ "Whether confirmation is needed to download marked files from Dired.
+Nil means no confirmation is needed."
+ :type 'boolean
+ :group 'auto-install)
+
+(defcustom auto-install-batch-list
+ '(
+ ;; Icicles.
+ ("icicles" 21 10
+ (
+ "http://www.emacswiki.org/emacs/download/icicles.el" ; Main library
+ "http://www.emacswiki.org/emacs/download/icicles-chg.el" ; Change logs
+ "http://www.emacswiki.org/emacs/download/icicles-cmd1.el" ; Top-level Icicles commands, part 1
+ "http://www.emacswiki.org/emacs/download/icicles-cmd2.el" ; Top-level Icicles commands, part 2
+ "http://www.emacswiki.org/emacs/download/icicles-doc1.el" ; Doc, part 1
+ "http://www.emacswiki.org/emacs/download/icicles-doc2.el" ; Doc, part 2
+ "http://www.emacswiki.org/emacs/download/icicles-face.el" ; Faces
+ "http://www.emacswiki.org/emacs/download/icicles-fn.el" ; Non-interactive functions
+ "http://www.emacswiki.org/emacs/download/icicles-mac.el" ; Macros
+ "http://www.emacswiki.org/emacs/download/icicles-mcmd.el" ; Minibuffer commands
+ "http://www.emacswiki.org/emacs/download/icicles-mode.el" ; Icicle (Icy) mode
+ "http://www.emacswiki.org/emacs/download/icicles-opt.el" ; User options
+ "http://www.emacswiki.org/emacs/download/icicles-var.el" ; Internal variables
+ "http://www.emacswiki.org/emacs/download/lacarte.el" ; Menu-bar access from keyboard
+ "http://www.emacswiki.org/emacs/download/icomplete+.el" ; Enhancements to `icomplete.el'
+ "http://www.emacswiki.org/emacs/download/hexrgb.el" ; Color manipulation
+ "http://www.emacswiki.org/emacs/download/synonyms.el" ; Look up synonyms
+ ))
+ ;; AutoComplete development version.
+ ("auto-complete development version" nil nil
+ (
+ "http://www.cx4a.org/pub/auto-complete.el" ; Main library
+ "http://www.cx4a.org/pub/auto-complete-cpp.el" ; Completion for C++
+ "http://www.cx4a.org/pub/auto-complete-css.el" ; Completion for CSS
+ "http://www.cx4a.org/pub/auto-complete-emacs-lisp.el" ; Completion for elisp
+ "http://www.cx4a.org/pub/auto-complete-gtags.el" ; Completion for gtags
+ "http://www.cx4a.org/pub/auto-complete-python.el" ; Completion for python
+ "http://www.cx4a.org/pub/auto-complete-ruby.el" ; Completion for ruby
+ "http://www.cx4a.org/pub/auto-complete-semantic.el" ; Completion for semantic
+ "http://www.cx4a.org/pub/auto-complete-yasnippet.el" ; Completion for yasnippet
+ ))
+ ;; Anything
+ ("anything" nil nil
+ (
+ "http://www.emacswiki.org/emacs/download/anything.el" ; Main library
+ "http://www.emacswiki.org/emacs/download/anything-config.el" ; Configuration for anything.el
+ "http://www.emacswiki.org/emacs/download/anything-match-plugin.el" ; Matching algorithm humanely
+ ))
+ ;; SDCV (Interface for StartDict console version)
+ ("sdcv" nil nil
+ (
+ "http://www.emacswiki.org/emacs/download/showtip.el" ; Basic tooltip show library
+ "http://www.emacswiki.org/emacs/download/sdcv.el" ; sdcv.el
+ ))
+ ;; Lazy search
+ ("lazy-search" nil nil
+ (
+ "http://www.emacswiki.org/emacs/download/one-key.el" ; Basic library for lazy-search.el
+ "http://www.emacswiki.org/emacs/download/lazy-search.el" ; Main library
+ ))
+ ;; PHP completion
+ ("php-completion" nil nil
+ (
+ "http://www.emacswiki.org/emacs/download/anything.el"
+ "http://www.emacswiki.org/emacs/download/anything-match-plugin.el"
+ "http://www.emacswiki.org/emacs/download/anything-show-completion.el"
+ "http://www.emacswiki.org/emacs/download/php-completion.el"
+ ))
+ ;; Perl completion
+ ("perl-completion" nil nil
+ (
+ "http://www.emacswiki.org/emacs/download/anything.el"
+ "http://www.emacswiki.org/emacs/download/anything-match-plugin.el"
+ "http://www.emacswiki.org/emacs/download/anything-show-completion.el"
+ "http://www.emacswiki.org/emacs/download/perl-completion.el"
+ ))
+ )
+ "This list contain packages information for batch install.
+
+Have four arguments per list:
+First argument is extension name.
+Second argument is delay time for batch install.
+Third argument is libraries number limit in delay time.
+Fourth argument is libraries url list.
+
+Anyone can add information in this list for batch install."
+ :group 'auto-install)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Variable ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(defvar auto-install-download-buffer nil
+ "The download buffer used by `url-retrieve'.
+This variable is always buffer-local.")
+(make-variable-buffer-local 'auto-install-download-buffer)
+
+(defvar auto-install-download-url nil
+ "The url from which to download files.
+This variable is always buffer-local.")
+(make-variable-buffer-local 'auto-install-download-url)
+
+(defvar auto-install-last-url nil
+ "The last url used in `auto-install-from-url'.")
+
+(defvar auto-install-last-gist-id nil
+ "The last gist id you visit in `auto-install-from-gist'.")
+
+(defvar auto-install-package-name-list nil
+ "The package name list for completion input.")
+
+(defvar auto-install-minor-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map (kbd "C-c C-d") 'auto-install-buffer-diff) ;diff
+ (define-key map (kbd "C-c C-c") 'auto-install-buffer-save) ;save
+ (define-key map (kbd "C-c C-q") 'auto-install-buffer-quit) ;quit
+ map)
+ "Keymap used by variable `auto-install-minor-mode'.")
+
+(defvar auto-install-add-load-path-flag t
+ "If non-nil, add `auto-install-directory' to `load-path'.
+This variable is intended to be used in test.")
+
+(defvar auto-install-waiting-url-list nil
+ "URLs in downloading.")
+(defvar auto-install-url-queue nil
+ "Installation order.")
+(defvar auto-install-download-buffer-alist nil
+ "Pairs of URL and downloaded buffer.")
+
+
+(define-minor-mode auto-install-minor-mode
+ "Auto Install minor mode."
+ :init-value nil
+ :lighter " Auto-Install"
+ :keymap auto-install-minor-mode-map
+ :group 'auto-install)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Interactive Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(defun auto-install-from-buffer ()
+ "Install the elisp file in the current buffer."
+ (interactive)
+ (let (filename)
+ (setq filename (read-string (format "Filename (%s): " (buffer-name)) nil nil (buffer-name)))
+ (auto-install-mode)
+ (auto-install-buffer-save filename)))
+
+(defun auto-install-from-url (&optional url)
+ "Install an elisp file from a given url."
+ (interactive)
+ (or url (setq url (read-string (format "URL (%s): " (or auto-install-last-url "")) nil nil auto-install-last-url)))
+ (setq auto-install-last-url url)
+ (auto-install-download url))
+
+(defun auto-install-from-emacswiki (&optional file)
+ "Install an elisp file from EmacsWiki.org."
+ (interactive)
+ (cond (auto-install-package-name-list
+ ;; Install package if `auto-install-package-name-list' is non-nil.
+ (or file (setq file (auto-install-get-candidate "Package" auto-install-package-name-list)))
+ (auto-install-download (concat auto-install-emacswiki-base-url file)))
+ (t
+ ;; Otherwise update package name and install.
+ (auto-install-download "http://www.emacswiki.org/cgi-bin/emacs?action=index;raw=1"
+ 'auto-install-handle-emacswiki-package-install))))
+
+(defun auto-install-from-gist (&optional gistid)
+ "Install an elisp file from gist.github.com.
+Optional argument GISTID is gist ID for download elisp file from gist.github.com."
+ (interactive)
+ (or gistid (setq gistid (read-string (format "Gist ID (%s): " (or auto-install-last-gist-id ""))
+ nil nil
+ auto-install-last-gist-id)))
+ (setq auto-install-last-gist-id gistid)
+ (auto-install-download (format "%s%s.txt" auto-install-gist-base-url gistid)))
+
+(defun auto-install-from-library (&optional library)
+ "Update an elisp LIBRARY.
+Default this function will found 'download url' from `auto-install-filter-url',
+if not found, try to download from EmacsWiki."
+ (interactive
+ (let* ((dirs load-path)
+ (suffixes (find-library-suffixes)))
+ (list (auto-install-get-candidate "Library name" (auto-install-get-library-list)))))
+ (let ((filename (file-name-nondirectory (find-library-name library)))
+ (base-url auto-install-emacswiki-base-url)
+ (library-name (replace-regexp-in-string "\\(\\.el.*$\\)" "" library)))
+ (if (assoc library-name auto-install-filter-url)
+ (setq base-url (cadr (assoc library-name auto-install-filter-url))))
+ (auto-install-download (concat base-url filename))))
+
+(defun auto-install-from-directory (directory)
+ "Update elisp files under DIRECTORY from EmacsWiki.
+You can use this command to update elisp file under DIRECTORY."
+ (interactive "DDirectory: ")
+ (let (filename)
+ (dolist (file (directory-files directory t))
+ (if (file-directory-p file)
+ ;; Don't match . or .. directory.
+ (unless (string-match "^\\.\\.?$" (file-name-nondirectory file))
+ ;; Find files in sub-directory.
+ (auto-install-from-directory file))
+ ;; Get file name.
+ (setq filename (file-name-nondirectory file))
+ ;; Not backup file.
+ (unless (string-match "^\\.?#" filename)
+ ;; Match elisp file.
+ (if (string-match "^.*\\.el" filename)
+ (auto-install-download (concat auto-install-emacswiki-base-url filename))))))))
+
+(defun auto-install-from-dired ()
+ "Update dired marked elisp files from EmacsWiki.org.
+You can use this to download marked files in Dired asynchronously."
+ (interactive)
+ (if (eq major-mode 'dired-mode)
+ (if (or (not auto-install-from-dired-confirm)
+ (yes-or-no-p "Do you want install marked files from EmacsWiki.org?"))
+ (dolist (file (dired-get-marked-files))
+ (auto-install-download (concat auto-install-emacswiki-base-url (file-name-nondirectory file)))))
+ (error "This command is only for `dired-mode'.")))
+
+(defun auto-install-update-emacswiki-package-name (&optional unforced)
+ "Update the list of elisp package names from `EmacsWiki'.
+By default, this function will update package name forcibly.
+If UNFORCED is non-nil, just update package name when `auto-install-package-name-list' is nil."
+ (interactive)
+ (unless (and unforced
+ auto-install-package-name-list)
+ (auto-install-download "http://www.emacswiki.org/cgi-bin/emacs?action=index;raw=1"
+ 'auto-install-handle-emacswiki-package-name)))
+
+(defun auto-install-dired-mark-files ()
+ "Mark dired files that contain at `EmacsWiki.org'."
+ (interactive)
+ (if (eq major-mode 'dired-mode)
+ (if auto-install-package-name-list
+ ;; Mark files that exist at `EmacsWiki'.
+ (auto-install-dired-mark-files-internal)
+ ;; Or get package name list and match files.
+ (auto-install-download "http://www.emacswiki.org/cgi-bin/emacs?action=index;raw=1"
+ 'auto-install-handle-dired-mark-files))
+ (error "This command just use in `dired-mode'.")))
+
+(defun auto-install-mode ()
+ "Major mode for auto-installing elisp code."
+ (interactive)
+ ;; Load emacs-lisp syntax highlight.
+ (set-syntax-table emacs-lisp-mode-syntax-table)
+ (lisp-mode-variables)
+ (setq font-lock-mode t)
+ (font-lock-fontify-buffer)
+ ;; Read only.
+ (setq buffer-read-only t)
+ (and view-read-only (view-mode 1))
+ ;; Load `auto-install' mode.
+ (auto-install-minor-mode t)
+ (setq major-mode 'auto-install-minor-mode))
+
+(defun auto-install-buffer-quit ()
+ "Quit from `auto-install' temporary buffer."
+ (interactive)
+ ;; Quit buffer.
+ (if (eq major-mode 'auto-install-minor-mode)
+ (auto-install-quit)
+ (error "This command just use in `auto-install-minor-mode'.")))
+
+(defun auto-install-compatibility-setup ()
+ "Install Compatibility commands for install-elisp.el users."
+ (interactive)
+ (defalias 'install-elisp 'auto-install-from-url)
+ (if (require 'anything-auto-install nil t)
+ (defalias 'install-elisp-from-emacswiki 'anything-auto-install-from-emacswiki)
+ (defalias 'install-elisp-from-emacswiki 'auto-install-from-emacswiki))
+ (defalias 'install-elisp-from-gist 'auto-install-from-gist)
+ (message "Install-elisp compatibility installed.
+install-elisp = %s
+install-elisp-from-emacswiki = %s
+install-elisp-from-gist = %s"
+ (symbol-function 'install-elisp)
+ (symbol-function 'install-elisp-from-emacswiki)
+ (symbol-function 'install-elisp-from-gist)))
+
+(defun auto-install-batch (&optional extension-name)
+ "Batch install many libraries in some extension.
+EXTENSION-NAME is extension name for batch install."
+ (interactive)
+ (let (extension-info-list)
+ ;; Get extension information list.
+ (setq extension-info-list
+ (assoc (or
+ ;; Get information list from give extension name.
+ extension-name
+ ;; Otherwise completion from user select.
+ (completing-read "Extension name: " (mapcar 'car auto-install-batch-list)))
+ auto-install-batch-list))
+ (if extension-info-list
+ ;; Install extension libraries.
+ (let ((extension-delay-time (nth 1 extension-info-list))
+ (extension-limit-number (nth 2 extension-info-list))
+ (extension-library-list (car (last extension-info-list))))
+ (setq auto-install-waiting-url-list extension-library-list
+ auto-install-url-queue extension-library-list)
+ (if (not (and
+ ;; Delay time is above 0.
+ extension-delay-time
+ (> extension-delay-time 0)
+ ;; Limit number is above 0.
+ extension-limit-number
+ (> extension-limit-number 0)))
+ (auto-install-from-url-list extension-library-list)
+ (let ((delay-counter 0)
+ install-list)
+ (while extension-library-list
+ (if (> (length extension-library-list) extension-limit-number)
+ ;; Install apart libraries list under `extension-limit-number'
+ (progn
+ (setq install-list (nthcar extension-limit-number extension-library-list))
+ (run-with-timer
+ (* delay-counter extension-delay-time)
+ nil
+ 'auto-install-from-url-list install-list)
+ (setq extension-library-list (nthcdr+ extension-limit-number extension-library-list))
+ (incf delay-counter))
+ ;; Install remain libraries list.
+ (setq install-list extension-library-list)
+ (run-with-timer
+ (* delay-counter extension-delay-time)
+ nil
+ 'auto-install-from-url-list install-list)
+ (setq extension-library-list nil))))))
+ ;; Notify message when haven't install information
+ ;; for libraries that user given.
+ (message "Haven't install information for `%s'." extension-name))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Utilities Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(defun auto-install-download (url &optional handle-function)
+ "Download elisp file from URL.
+HANDLE-FUNCTION for handle download content,
+default is `auto-install-handle-download-content'."
+ ;; Check and create install directory.
+ (unless (file-exists-p auto-install-directory)
+ (make-directory auto-install-directory)
+ (when auto-install-add-load-path-flag
+ (add-to-list 'load-path auto-install-directory))
+ (message "Create directory %s for install elisp file." auto-install-directory))
+ ;; Download.
+ (let* ((url-request-method "GET")
+ (url-request-extra-headers nil)
+ (url-mime-accept-string "*/*")
+ (parsed-url (url-generic-parse-url url))
+ (download-buffer (auto-install-get-buffer url))
+ (download-buffer-name (buffer-name download-buffer)))
+ (with-current-buffer download-buffer
+ ;; Bind download url with local buffer.
+ (setq auto-install-download-url url)
+ ;; Bind download buffer with local buffer.
+ ;;
+ ;; Use buffer-local variable receive
+ ;; data from `url-retrieve' to make asynchronously
+ ;; download file with special buffer.
+ ;;
+ ;; Because the buffer name is unique that generate
+ ;; through `current-time', so can download many elisp file
+ ;; asynchronously and won't conflict each other.
+ (setq auto-install-download-buffer
+ (url-retrieve parsed-url
+ 'auto-install-download-callback
+ (list download-buffer-name handle-function))))))
+
+(defun auto-install-download-callback (&optional redirect download-buffer-name handle-function)
+ "The callback for `auto-install-download'.
+With `auto-install-download', this downloads elisp files asynchronously.
+REDIRECT is the argument for check download status.
+DOWNLOAD-BUFFER-NAME is the name of download buffer.
+HANDLE-FUNCTION is function for handle download content."
+ (if (eq (car redirect) ':error)
+ ;; Notify user and kill buffer when occur error.
+ (with-current-buffer (get-buffer download-buffer-name)
+ (message "Download from '%s' failed." auto-install-download-url)
+ (kill-buffer download-buffer-name))
+ ;; Otherwise continue install process.
+ (auto-install-retrieve-decode download-buffer-name) ;decode retrieve information.
+ (with-current-buffer (get-buffer download-buffer-name)
+ ;; Show successful message
+ (message "Download from '%s' successful." auto-install-download-url)
+ ;; Handle download content.
+ (funcall (or handle-function 'auto-install-handle-download-content)
+ (current-buffer)))))
+
+(defun auto-install-retrieve-decode (retrieve-buffer-name)
+ "Decode the RETRIEVE-BUFFER-NAME with coding detection."
+ (declare (special url-http-end-of-headers))
+ (with-current-buffer (get-buffer retrieve-buffer-name)
+ (insert
+ (with-current-buffer auto-install-download-buffer
+ (set-buffer-multibyte t)
+ (goto-char (1+ url-http-end-of-headers))
+ (decode-coding-region
+ (point) (point-max)
+ (coding-system-change-eol-conversion
+ ;; rubikitch: encoding detection is better because of
+ ;; non-utf8 Japanese encodings.
+ (detect-coding-region (point-min) (point-max) t) 'dos))
+ (buffer-substring (point) (point-max))))
+ (goto-char (point-min))))
+
+(defun auto-install-handle-download-content (download-buffer)
+ "Handle the content downloaded to buffer DOWNLOAD-BUFFER."
+ (with-current-buffer download-buffer
+ ;; Load mode.
+ (auto-install-mode)
+ ;; Display help information in mode-line.
+ (setq mode-line-format (list "Type C-c C-c to continue; Type C-c C-d for view diff; Type C-c C-q to quit."))
+
+ (setq header-line-format (list auto-install-download-url))
+ (setq auto-install-download-buffer-alist
+ (cons (cons auto-install-download-url download-buffer)
+ auto-install-download-buffer-alist))
+ (setq auto-install-waiting-url-list
+ (remove auto-install-download-url auto-install-waiting-url-list))
+ ;; When all files are downloaded
+ (unless auto-install-waiting-url-list
+ ;; Select first file
+ (switch-to-buffer (or (assoc-default (car auto-install-url-queue)
+ auto-install-download-buffer-alist)
+ ;; if single file
+ download-buffer))
+ (unless auto-install-save-confirm
+ (auto-install-buffer-save)))))
+
+(defun auto-install-handle-emacswiki-package-name (download-buffer &optional prompt-install)
+ "Handle elisp package name from `EmacsWiki'.
+DOWNLOAD-BUFFER is the name of download buffer.
+PROMPT-INSTALL is non-nil, will prompt package name for install."
+ ;; Update package name list.
+ (auto-install-update-emacswiki-package-list download-buffer)
+ ;; Prompt package name for install.
+ (when prompt-install
+ (auto-install-download
+ (concat auto-install-emacswiki-base-url
+ (auto-install-get-candidate "Package" auto-install-package-name-list)))))
+
+(defun auto-install-handle-dired-mark-files (download-buffer)
+ "Handle dired mark files that exist at `EmacsWiki'.
+DOWNLOAD-BUFFER is the name of download buffer."
+ ;; Update package name list.
+ (auto-install-update-emacswiki-package-list download-buffer)
+ ;; Mark dired files.
+ (auto-install-dired-mark-files-internal))
+
+(defun auto-install-handle-emacswiki-package-install (download-buffer)
+ "Handle elisp package install from `EmacsWiki'.
+DOWNLOAD-BUFFER is the name of download buffer."
+ (auto-install-handle-emacswiki-package-name download-buffer t))
+
+(defun auto-install-update-emacswiki-package-list (download-buffer)
+ "Filter and update package name list from `EmacsWiki'.
+DOWNLOAD-BUFFER is the name of download buffer."
+ (goto-char (point-min))
+ (setq auto-install-package-name-list
+ (loop while (re-search-forward "^.*\\.el$" nil t)
+ collect (match-string 0)))
+ ;; Kill buffer.
+ (kill-buffer download-buffer)
+ ;; Display successful message.
+ (message "Update package name from `EmacsWiki' successful."))
+
+(defun auto-install-buffer-diff ()
+ "View different between old version.
+This command just run when have exist old version."
+ (interactive)
+ (let* ((new-file (url-file-nondirectory auto-install-download-url))
+ (old-file (auto-install-get-path new-file)))
+ (if old-file
+ ;; View different when have old version exist.
+ (ediff-buffers (current-buffer) (find-file-noselect old-file))
+ ;; Otherwise notify user.
+ (message "Haven't old version exist."))))
+
+(defun auto-install-buffer-save (&optional filename)
+ "Save downloaded content to file FILENAME."
+ (interactive)
+ (if (eq major-mode 'auto-install-minor-mode)
+ (let (file-path)
+ ;; Get filename
+ (unless filename
+ (setq filename (url-file-nondirectory auto-install-download-url)))
+ ;; Make sure file suffix with `.el'.
+ (while (not (string-match ".*\.el$" filename))
+ (setq filename (read-string "Please input file name suffix with `.el': ")))
+ ;; Get file path.
+ (setq file-path
+ (or
+ ;; Replace file if have exist.
+ (auto-install-get-path filename)
+ ;; Otherwise, install in directory `auto-install-directory'.
+ (concat (file-name-as-directory auto-install-directory) filename)))
+ ;; Save file.
+ (if (and (file-exists-p file-path)
+ auto-install-replace-confirm
+ (not (yes-or-no-p (format "Do you want replace file: '%s' ?" file-path))))
+ (auto-install-quit)
+ (write-file file-path)
+ (auto-install-install file-path)))
+ (error "This command just use in `auto-install-minor-mode'.")))
+
+(defun auto-install-install (file-path)
+ "Install elisp file FILE-PATH."
+ (if (and auto-install-install-confirm
+ (not (yes-or-no-p (format "Do you want install file: '%s' ?" file-path))))
+ (auto-install-quit)
+ (let (byte-compile-warnings) ;; suppress compile warnings
+ ;; Compile and load file.
+ (setq auto-install-url-queue (cdr auto-install-url-queue))
+ (unless (ignore-errors (byte-compile-file file-path t))
+ ;; Show `ERROR' message if compile failed.
+ (message (format "Auto-Install ERROR: Compiled file '%s' failed." file-path)))
+ ;; Install next file.
+ (cond ((car auto-install-url-queue)
+ (switch-to-buffer (assoc-default (car auto-install-url-queue)
+ auto-install-download-buffer-alist))
+ (unless auto-install-save-confirm
+ (auto-install-buffer-save)))
+ (t ;completed
+ ;; cleanup
+ (setq auto-install-url-queue nil)
+ (setq auto-install-download-buffer-alist nil)
+ (message "Installation is completed."))))))
+
+(defun auto-install-quit ()
+ "Quit auto-install."
+ ;; Kill buffer
+ (kill-buffer (current-buffer))
+ ;; Show quit message.
+ (message "Quit auto-install process."))
+
+(defun auto-install-get-path (library)
+ "Return the absolute file path of the Lisp source of LIBRARY."
+ ;; If the library is byte-compiled, try to find a source library by
+ ;; the same name.
+ (if (string-match "\\.el\\(c\\(\\..*\\)?\\)\\'" library)
+ (setq library (replace-match "" t t library)))
+ (or
+ (locate-file library
+ (or find-function-source-path load-path)
+ (find-library-suffixes))
+ (locate-file library
+ (or find-function-source-path load-path)
+ load-file-rep-suffixes)))
+
+(defun auto-install-get-buffer (url)
+ "Get a buffer for temporary storage of downloaded content.
+Uses `current-time' to make buffer name unique."
+ (get-buffer-create (format "*%s %s <%s>*"
+ auto-install-buffer-name url
+ (format-time-string "%m/%d %H:%M:%S"))))
+
+(defun auto-install-dired-mark-files-internal ()
+ "Mark files that match `auto-install-package-name-list'."
+ ;; Set buffer visible in select window.
+ (set-buffer (window-buffer))
+ ;; Get mark files.
+ (save-excursion
+ (let (filename)
+ ;; Unmark all markes.
+ (dired-unmark-all-marks)
+ ;; Try to mark files.
+ (goto-char (point-min))
+ (while (not (eobp))
+ (setq filename (dired-get-filename nil t))
+ (if (and filename
+ (not (file-directory-p filename))
+ (member (file-name-nondirectory filename) auto-install-package-name-list))
+ (dired-mark 1))
+ (dired-next-line 1)))))
+
+(defun auto-install-region-or-thing (&optional thing)
+ "Return region or thing around point.
+If `mark-active' and variable `transient-mark-mode', return region.
+If THING is non-nil, return THING around point;
+otherwise return symbol around point."
+ ;; Return string.
+ (if (and mark-active
+ transient-mark-mode)
+ ;; Return region string just when
+ ;; `mark-active' and `transient-mark-mode' is on.
+ (buffer-substring-no-properties (region-beginning)
+ (region-end))
+ ;; Otherwise try to pick-up THING around point.
+ (setq thing (or thing 'symbol))
+ (ignore-errors
+ (save-excursion
+ (buffer-substring-no-properties (beginning-of-thing thing)
+ (end-of-thing thing))))))
+
+(defun auto-install-get-library-list (&optional dirs string)
+ "Do completion for file names passed to `locate-file'.
+DIRS is directory to search path.
+STRING is string to match."
+ ;; Use `load-path' as path when ignore `dirs'.
+ (or dirs (setq dirs load-path))
+ ;; Init with blank when ignore `string'.
+ (or string (setq string ""))
+ ;; Get library list.
+ (let ((string-dir (file-name-directory string))
+ name
+ names)
+ (dolist (dir dirs)
+ (unless dir
+ (setq dir default-directory))
+ (if string-dir
+ (setq dir (expand-file-name string-dir dir)))
+ (when (file-directory-p dir)
+ (dolist (file (file-name-all-completions
+ (file-name-nondirectory string) dir))
+ ;; Suffixes match `load-file-rep-suffixes'.
+ (setq name (if string-dir (concat string-dir file) file))
+ (if (string-match (format "^.*\\.el%s$" (regexp-opt load-file-rep-suffixes)) name)
+ (add-to-list 'names name)))))
+ names))
+
+(defun auto-install-get-candidate (prompt collection)
+ "Get candidate from completing list.
+PROMPT is string for prompt.
+COLLECTION is list for completing candidates."
+ (completing-read (format "%s (%s): " prompt (or (auto-install-region-or-thing) ""))
+ collection
+ nil nil nil nil
+ (auto-install-region-or-thing)))
+
+(defun auto-install-from-url-list (&optional url-list)
+ "Batch install many packages form URL-LIST."
+ (if (listp url-list)
+ (dolist (url url-list)
+ (auto-install-from-url url))
+ (error "Invalid url list for install.")))
+
+(defun nthcdr+ (n list)
+ "Take cdr N times on LIST, return the result.
+If LIST length below N, return entire list.
+If LIST is nil, return nil."
+ (if (or (null list)
+ (> n (length list)))
+ list
+ (nthcdr n list)))
+
+(defun nthcar (n list)
+ "Return first N elements of LIST.
+If LIST length below N, return entire list.
+If LIST is nil, return nil."
+ (reverse (nthcdr (- (length list) n) (reverse list))))
+
+(provide 'auto-install)
+
+;; How to save (DO NOT REMOVE!!)
+;; (emacswiki-post "auto-install.el")
+;;; auto-install.el ends here
+
+;;; LocalWords: el eol dirs fontify gistid txt func bytecomp DDirectory ediff
+;;; LocalWords: noselect Unmark unmark AutoInstall keybindings defalias'es
View
1,112 auto-install/anything-complete.el
@@ -0,0 +1,1112 @@
+;;; anything-complete.el --- completion with anything
+;; $Id: anything-complete.el,v 1.72 2009/12/14 00:13:28 rubikitch Exp rubikitch $
+
+;; Copyright (C) 2008 rubikitch
+
+;; Author: rubikitch <rubikitch@ruby-lang.org>
+;; Keywords: matching, convenience, anything
+;; URL: http://www.emacswiki.org/cgi-bin/wiki/download/anything-complete.el
+
+;; This file is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; 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:
+
+;; Completion with Anything interface.
+
+;;; Commands:
+;;
+;; Below are complete command list:
+;;
+;; `anything-lisp-complete-symbol'
+;; `lisp-complete-symbol' replacement using `anything'.
+;; `anything-lisp-complete-symbol-partial-match'
+;; `lisp-complete-symbol' replacement using `anything' (partial match).
+;; `anything-apropos'
+;; `apropos' replacement using `anything'.
+;; `anything-read-string-mode'
+;; If this minor mode is on, use `anything' version of `completing-read' and `read-file-name'.
+;; `anything-complete-shell-history'
+;; Select a command from shell history and insert it.
+;;
+;;; Customizable Options:
+;;
+;; Below are customizable option list:
+;;
+;; `anything-complete-sort-candidates'
+;; *Whether to sort completion candidates.
+;; default = nil
+
+;; * `anything-lisp-complete-symbol', `anything-lisp-complete-symbol-partial-match':
+;; `lisp-complete-symbol' with `anything'
+;; * `anything-apropos': `apropos' with `anything'
+;; * `anything-complete-shell-history': complete from .*sh_history
+;; * Many read functions:
+;; `anything-read-file-name', `anything-read-buffer', `anything-read-variable',
+;; `anything-read-command', `anything-completing-read'
+;; * `anything-read-string-mode' replaces default read functions with anything ones.
+;; * Many anything sources:
+;; [EVAL IT] (occur "defvar anything-c-source")
+
+;;; Installation:
+
+;; Put anything-complete.el to your load-path.
+;; The load-path is usually ~/elisp/.
+;; It's set in your ~/.emacs like this:
+;; (add-to-list 'load-path (expand-file-name "~/elisp"))
+;;
+;; Then install dependencies.
+;;
+;; Install anything-match-plugin.el (must).
+;; M-x install-elisp http://www.emacswiki.org/cgi-bin/wiki/download/anything-match-plugin.el
+;;
+;; shell-history.el / shell-command.el would help you (optional).
+;; M-x install-elisp http://www.emacswiki.org/cgi-bin/wiki/download/shell-history.el
+;; M-x install-elisp http://www.emacswiki.org/cgi-bin/wiki/download/shell-command.el
+;;
+;; If you want `anything-execute-extended-command' to show
+;; context-aware commands, use anything-kyr.el and
+;; anything-kyr-config.el (optional).
+;;
+;; M-x install-elisp http://www.emacswiki.org/cgi-bin/wiki/download/anything-kyr.el
+;; M-x install-elisp http://www.emacswiki.org/cgi-bin/wiki/download/anything-kyr-config.el
+
+;; And the following to your ~/.emacs startup file.
+;;
+;; (require 'anything-complete)
+;; ;; Automatically collect symbols by 150 secs
+;; (anything-lisp-complete-symbol-set-timer 150)
+;; ;; replace completion commands with `anything'
+;; (anything-read-string-mode 1)
+;; ;; Bind C-o to complete shell history
+;; (anything-complete-shell-history-setup-key "\C-o")
+
+;;; History:
+
+;; $Log: anything-complete.el,v $
+;; Revision 1.72 2009/12/14 00:13:28 rubikitch
+;; New command: `alcs-update-restart'
+;;
+;; Pressing `C-c C-u' in `anything-lisp-complete-symbol' and `anything-lisp-complete-symbol-partial-match' recollects symbols and reexecutes this command.
+;;
+;; Revision 1.71 2009/12/13 23:34:19 rubikitch
+;; Show timestamp of lisp symbols
+;;
+;; Revision 1.70 2009/12/13 23:17:18 rubikitch
+;; Make alcs-make-candidates timer singleton
+;;
+;; Revision 1.69 2009/12/13 23:06:34 rubikitch
+;; New variable `anything-lisp-complete-symbol-add-space-on-startup':
+;;
+;; If non-nil, `anything-lisp-complete-symbol' and `anything-lisp-complete-symbol-partial-match' adds space on startup.
+;; It utilizes anything-match-plugin's feature.
+;;
+;; Revision 1.68 2009/11/11 19:01:09 rubikitch
+;; Bug fix when completing at right side
+;;
+;; Revision 1.67 2009/11/11 18:03:49 rubikitch
+;; New implementation of `alcs-current-physical-column'
+;;
+;; Revision 1.66 2009/10/26 09:38:39 rubikitch
+;; `anything-completing-read': Show default source first when require-match and default is specified.
+;;
+;; Revision 1.65 2009/10/22 08:54:58 rubikitch
+;; `anything-complete-shell-history-setup-key': Use `minibuffer-local-shell-command-map' if any
+;;
+;; Revision 1.64 2009/10/13 05:40:51 rubikitch
+;; `anything-completing-read': Show completions first when require-match == t
+;;
+;; Revision 1.63 2009/10/11 20:27:22 rubikitch
+;; `alcs-transformer-prepend-spacer': use physical column instead of logical column
+;;
+;; Revision 1.62 2009/10/10 03:27:33 rubikitch
+;; New variable: `anything-complete-sort-candidates'
+;;
+;; Revision 1.61 2009/10/08 17:06:35 rubikitch
+;; `anything-complete-shell-history': taller window
+;;
+;; Revision 1.60 2009/10/08 05:12:27 rubikitch
+;; If anything-show-completion.el is available, candidates are shown near the point.
+;;
+;; Revision 1.59 2009/10/07 10:29:34 rubikitch
+;; `anything-find-file': use `anything-other-buffer' instead of `anything-complete'
+;;
+;; Revision 1.58 2009/10/01 03:07:44 rubikitch
+;; Fix an error in `anything-find-file'. Thanks to troter.
+;; http://d.hatena.ne.jp/troter/20090929/1254199115
+;;
+;; Revision 1.57 2009/08/02 04:19:52 rubikitch
+;; New variable: `anything-complete-persistent-action'
+;;
+;; Revision 1.56 2009/07/26 21:25:04 rubikitch
+;; New variable: `anything-completing-read-use-default'
+;; New variable: `anything-completing-read-history-first'
+;; `anything-completing-read', `anything-read-file-name': history order bug fix
+;;
+;; Revision 1.55 2009/07/19 07:33:33 rubikitch
+;; `anything-execute-extended-command': adjust to keyboard macro command
+;;
+;; Revision 1.54 2009/06/29 15:13:02 rubikitch
+;; New function: `anything-complete-shell-history-setup-key'
+;;
+;; Revision 1.53 2009/06/24 15:37:50 rubikitch
+;; `anything-c-source-complete-shell-history': require bug fix
+;;
+;; Revision 1.52 2009/05/30 05:04:30 rubikitch
+;; Set `anything-execute-action-at-once-if-one' to t
+;;
+;; Revision 1.51 2009/05/25 18:57:22 rubikitch
+;; Removed experimental tags
+;;
+;; Revision 1.50 2009/05/06 12:34:45 rubikitch
+;; `anything-complete': target is default input.
+;;
+;; Revision 1.49 2009/05/04 14:51:18 rubikitch
+;; use `define-anything-type-attribute' to add `anything-type-attributes' entry.
+;;
+;; Revision 1.48 2009/05/03 19:07:22 rubikitch
+;; anything-complete: `enable-recursive-minibuffers' = t
+;;
+;; Revision 1.47 2009/05/03 18:42:23 rubikitch
+;; Remove *-partial-match sources.
+;; They are aliased for compatibility.
+;;
+;; Revision 1.46 2009/05/03 18:33:35 rubikitch
+;; Remove dependency of `ac-candidates-in-buffer'
+;;
+;; Revision 1.45 2009/04/20 16:24:33 rubikitch
+;; Set anything-samewindow to nil for in-buffer completion.
+;;
+;; Revision 1.44 2009/04/18 10:07:35 rubikitch
+;; * auto-document.
+;; * Use anything-show-completion.el if available.
+;;
+;; Revision 1.43 2009/02/27 14:45:26 rubikitch
+;; Fix a read-only bug in `alcs-make-candidates'.
+;;
+;; Revision 1.42 2009/02/19 23:04:33 rubikitch
+;; * update doc
+;; * use anything-kyr if any
+;;
+;; Revision 1.41 2009/02/19 22:54:29 rubikitch
+;; refactoring
+;;
+;; Revision 1.40 2009/02/06 09:19:08 rubikitch
+;; Fix a bug when 2nd argument of `anything-read-file-name' (DIR) is not a directory.
+;;
+;; Revision 1.39 2009/01/28 20:33:31 rubikitch
+;; add persistent-action for `anything-read-file-name' and `anything-read-buffer'.
+;;
+;; Revision 1.38 2009/01/08 19:28:33 rubikitch
+;; `anything-completing-read': fixed a bug when COLLECTION is a non-nested list.
+;;
+;; Revision 1.37 2009/01/02 15:08:03 rubikitch
+;; `anything-execute-extended-command': show commands which are not collected.
+;;
+;; Revision 1.36 2008/11/27 08:12:36 rubikitch
+;; `anything-read-buffer': accept empty buffer name
+;;
+;; Revision 1.35 2008/11/02 06:30:06 rubikitch
+;; `anything-execute-extended-command': fixed a bug
+;;
+;; Revision 1.34 2008/10/30 18:45:27 rubikitch
+;; `arfn-sources': use `file-name-history' instead
+;;
+;; Revision 1.33 2008/10/30 16:39:17 rubikitch
+;; *** empty log message ***
+;;
+;; Revision 1.32 2008/10/30 11:09:17 rubikitch
+;; New command: `anything-find-file'
+;;
+;; Revision 1.31 2008/10/30 10:29:56 rubikitch
+;; `ac-new-input-source', `ac-default-source', `acr-sources', `arfn-sources', `arb-sources': changed args
+;;
+;; Revision 1.30 2008/10/30 09:33:50 rubikitch
+;; `anything-execute-extended-command': fixed a bug
+;;
+;; Revision 1.29 2008/10/27 10:55:55 rubikitch
+;; New command: `anything-execute-extended-command'
+;;
+;; Revision 1.28 2008/10/27 10:41:33 rubikitch
+;; use linkd tag (no code change)
+;;
+;; Revision 1.27 2008/10/21 18:02:39 rubikitch
+;; `anything-noresume': restore `anything-last-buffer'
+;;
+;; Revision 1.26 2008/10/03 09:55:45 rubikitch
+;; anything-read-file-name bug fix
+;;
+;; Revision 1.25 2008/09/30 22:49:22 rubikitch
+;; `anything-completing-read': handle empty input.
+;;
+;; Revision 1.24 2008/09/22 09:15:03 rubikitch
+;; *** empty log message ***
+;;
+;; Revision 1.23 2008/09/22 09:12:42 rubikitch
+;; set `anything-input-idle-delay'.
+;;
+;; Revision 1.22 2008/09/20 20:27:46 rubikitch
+;; s/anything-attr/anything-attr-defined/ because of `anything-attr' change
+;;
+;; Revision 1.21 2008/09/15 17:31:34 rubikitch
+;; *** empty log message ***
+;;
+;; Revision 1.20 2008/09/14 15:20:12 rubikitch
+;; set `anything-input-idle-delay'.
+;;
+;; Revision 1.19 2008/09/12 02:56:33 rubikitch
+;; Complete functions using `anything' restore `anything-last-sources'
+;; and `anything-compiled-sources' now, because resuming
+;; `anything'-complete session is useless.
+;;
+;; Revision 1.18 2008/09/10 23:27:09 rubikitch
+;; Use *anything complete* buffer instead
+;;
+;; Revision 1.17 2008/09/10 09:59:22 rubikitch
+;; arfn-sources: bug fix
+;;
+;; Revision 1.16 2008/09/10 09:40:31 rubikitch
+;; arfn-sources: paren bug fix
+;;
+;; Revision 1.15 2008/09/09 01:19:49 rubikitch
+;; add (require 'shell-history)
+;;
+;; Revision 1.14 2008/09/05 13:59:39 rubikitch
+;; bugfix
+;;
+;; Revision 1.13 2008/09/05 13:50:14 rubikitch
+;; * Use `keyboard-quit' when anything-read-* is quit.
+;; * Change keybinding of `anything-read-file-name-follow-directory' to Tab
+;; * `anything-read-file-name-follow-directory': smarter behavior
+;;
+;; Revision 1.12 2008/09/05 12:46:27 rubikitch
+;; bugfix
+;;
+;; Revision 1.11 2008/09/05 03:15:26 rubikitch
+;; *** empty log message ***
+;;
+;; Revision 1.10 2008/09/05 01:49:56 rubikitch
+;; `anything-completing-read' supports list collection only.
+;;
+;; Revision 1.9 2008/09/05 00:09:46 rubikitch
+;; New functions: moved from anything.el
+;; `anything-completing-read', `anything-read-file-name', `anything-read-buffer',
+;; `anything-read-variable', `anything-read-command', `anything-read-string-mode'.
+;;
+;; Revision 1.8 2008/09/04 16:54:59 rubikitch
+;; add commentary
+;;
+;; Revision 1.7 2008/09/04 08:36:08 rubikitch
+;; fixed a bug when `symbol-at-point' is nil.
+;;
+;; Revision 1.6 2008/09/04 08:29:40 rubikitch
+;; remove unneeded code.
+;;
+;; Revision 1.5 2008/09/04 08:12:05 rubikitch
+;; absorb anything-lisp-complete-symbol.el v1.13.
+;;
+;; Revision 1.4 2008/09/04 07:36:23 rubikitch
+;; Use type plug-in instead.
+;;
+;; Revision 1.3 2008/09/03 04:13:23 rubikitch
+;; `anything-c-source-complete-shell-history': deleted requires-pattern
+;;
+;; Revision 1.2 2008/09/01 22:27:45 rubikitch
+;; *** empty log message ***
+;;
+;; Revision 1.1 2008/09/01 22:23:55 rubikitch
+;; Initial revision
+;;
+
+;;; Code:
+
+(defvar anything-complete-version "$Id: anything-complete.el,v 1.72 2009/12/14 00:13:28 rubikitch Exp rubikitch $")
+(require 'anything-match-plugin)
+(require 'thingatpt)
+
+;; (@* "overlay")
+(when (require 'anything-show-completion nil t)
+ (dolist (f '(anything-complete
+ anything-lisp-complete-symbol
+ anything-lisp-complete-symbol-partial-match))
+ (use-anything-show-completion f '(length anything-complete-target))))
+
+;; (@* "core")
+(defvar anything-complete-target "")
+
+(defun ac-insert (candidate)
+ (let ((pt (point)))
+ (when (and (search-backward anything-complete-target nil t)
+ (string= (buffer-substring (point) pt) anything-complete-target))
+ (delete-region (point) pt)))
+ (insert candidate))
+
+(define-anything-type-attribute 'complete
+ '((candidates-in-buffer)
+ (action . ac-insert)))
+
+;; Warning: I'll change this function's interface. DON'T USE IN YOUR PROGRAM!
+(defun anything-noresume (&optional any-sources any-input any-prompt any-resume any-preselect any-buffer)
+ (let (anything-last-sources anything-compiled-sources anything-last-buffer)
+ (anything any-sources any-input any-prompt any-resume any-preselect any-buffer)))
+
+(defun anything-complete (sources target &optional limit idle-delay input-idle-delay)
+ "Basic completion interface using `anything'."
+ (let ((anything-candidate-number-limit (or limit anything-candidate-number-limit))
+ (anything-idle-delay (or idle-delay anything-idle-delay))
+ (anything-input-idle-delay (or input-idle-delay anything-input-idle-delay))
+ (anything-complete-target target)
+ (anything-execute-action-at-once-if-one t)
+ (enable-recursive-minibuffers t)
+ anything-samewindow)
+ (anything-noresume sources target nil nil nil "*anything complete*")))
+
+;; (@* "`lisp-complete-symbol' and `apropos' replacement")
+(defvar anything-lisp-complete-symbol-input-idle-delay 0.1
+ "`anything-input-idle-delay' for `anything-lisp-complete-symbol',
+`anything-lisp-complete-symbol-partial-match' and `anything-apropos'.")
+(defvar anything-lisp-complete-symbol-add-space-on-startup t
+ "If non-nil, `anything-lisp-complete-symbol' and `anything-lisp-complete-symbol-partial-match' adds space on startup.
+It utilizes anything-match-plugin's feature.")
+
+(defun alcs-create-buffer (name)
+ (let ((b (get-buffer-create name)))
+ (with-current-buffer b
+ (buffer-disable-undo)
+ (erase-buffer)
+ b)))
+
+(defvar alcs-variables-buffer " *variable symbols*")
+(defvar alcs-functions-buffer " *function symbols*")
+(defvar alcs-commands-buffer " *command symbols*")
+(defvar alcs-symbol-buffer " *other symbols*")
+
+(defvar alcs-symbols-time nil
+ "Timestamp of collected symbols")
+
+(defun alcs-make-candidates ()
+ (message "Collecting symbols...")
+ ;; To ignore read-only property.
+ (let ((inhibit-read-only t))
+ (setq alcs-symbols-time (current-time))
+ (alcs-create-buffer alcs-variables-buffer)
+ (alcs-create-buffer alcs-functions-buffer)
+ (alcs-create-buffer alcs-commands-buffer)
+ (alcs-create-buffer alcs-symbol-buffer)
+ (mapatoms
+ (lambda (sym)
+ (let ((name (symbol-name sym))
+ (fbp (fboundp sym)))
+ (cond ((commandp sym) (set-buffer alcs-commands-buffer) (insert name "\n"))
+ (fbp (set-buffer alcs-functions-buffer) (insert name "\n")))
+ (cond ((boundp sym) (set-buffer alcs-variables-buffer) (insert name "\n"))
+ ((not fbp) (set-buffer alcs-symbol-buffer) (insert name "\n")))))))
+ (message "Collecting symbols...done"))
+
+(defun alcs-header-name (name)
+ (format "%s at %s (Press `C-c C-u' to update)"
+ name (format-time-string "%H:%M:%S" alcs-symbols-time)))
+
+(defvar alcs-make-candidates-timer nil)
+(defun anything-lisp-complete-symbol-set-timer (update-period)
+ "Update Emacs symbols list when Emacs is idle,
+used by `anything-lisp-complete-symbol-set-timer' and `anything-apropos'"
+ (when alcs-make-candidates-timer
+ (cancel-timer alcs-make-candidates-timer))
+ (setq alcs-make-candidates-timer
+ (run-with-idle-timer update-period t 'alcs-make-candidates)))
+
+(defvar alcs-physical-column-at-startup nil)
+(defun alcs-init (bufname)
+ (declare (special anything-dabbrev-last-target))
+ (setq alcs-physical-column-at-startup nil)
+ (setq anything-complete-target
+ (if (loop for src in (anything-get-sources)
+ thereis (string-match "^dabbrev" (assoc-default 'name src)))
+ anything-dabbrev-last-target
+ (anything-aif (symbol-at-point) (symbol-name it) "")))
+ (anything-candidate-buffer (get-buffer bufname)))
+
+(defcustom anything-complete-sort-candidates nil
+ "*Whether to sort completion candidates."
+ :type 'boolean
+ :group 'anything-complete)
+
+(defun alcs-sort-maybe (candidates source)
+ (if anything-complete-sort-candidates
+ (sort candidates #'string<)
+ candidates))
+
+;;; borrowed from pulldown.el
+(defun alcs-current-physical-column ()
+ "Current physical column. (not logical column)"
+ ;; (- (point) (save-excursion (vertical-motion 0) (point)))
+ (car (posn-col-row (posn-at-point))))
+
+(defun alcs-transformer-prepend-spacer (candidates source)
+ "Prepend spaces according to `current-column' for each CANDIDATES."
+ (setq alcs-physical-column-at-startup
+ (or alcs-physical-column-at-startup
+ (with-current-buffer anything-current-buffer
+ (save-excursion
+ (backward-char (string-width anything-complete-target))
+ (alcs-current-physical-column)))))
+ (mapcar (lambda (cand) (cons (concat (make-string alcs-physical-column-at-startup ? ) cand) cand))
+ candidates))
+
+(defun alcs-transformer-prepend-spacer-maybe (candidates source)
+ ;; `anything-show-completion-activate' is defined in anything-show-completion.el
+ (if (and (boundp 'anything-show-completion-activate)
+ anything-show-completion-activate)
+ (alcs-transformer-prepend-spacer candidates source)
+ candidates))
+
+(defun alcs-describe-function (name)
+ (describe-function (intern name)))
+(defun alcs-describe-variable (name)
+ (describe-variable (intern name)))
+(defun alcs-find-function (name)
+ (find-function (intern name)))
+(defun alcs-find-variable (name)
+ (find-variable (intern name)))
+
+(defvar anything-c-source-complete-emacs-functions
+ '((name . "Functions")
+ (init . (lambda () (alcs-init alcs-functions-buffer)))
+ (candidates-in-buffer)
+ (type . complete-function)))
+(defvar anything-c-source-complete-emacs-commands
+ '((name . "Commands")
+ (init . (lambda () (alcs-init alcs-commands-buffer)))
+ (candidates-in-buffer)
+ (type . complete-function)))
+(defvar anything-c-source-complete-emacs-variables
+ '((name . "Variables")
+ (init . (lambda () (alcs-init alcs-variables-buffer)))
+ (candidates-in-buffer)
+ (type . complete-variable)))
+(defvar anything-c-source-complete-emacs-other-symbols
+ '((name . "Other Symbols")
+ (init . (lambda () (alcs-init alcs-symbol-buffer)))
+ (candidates-in-buffer)
+ (filtered-candidate-transformer . alcs-sort-maybe)
+ (action . ac-insert)))
+(defvar anything-c-source-apropos-emacs-functions
+ '((name . "Apropos Functions")
+ (init . (lambda () (alcs-init alcs-functions-buffer)))
+ (candidates-in-buffer)
+ (requires-pattern . 3)
+ (type . apropos-function)))
+(defvar anything-c-source-apropos-emacs-commands
+ '((name . "Apropos Commands")
+ (init . (lambda () (alcs-init alcs-commands-buffer)))
+ (candidates-in-buffer)
+ (requires-pattern . 3)
+ (type . apropos-function)))
+(defvar anything-c-source-apropos-emacs-variables
+ '((name . "Apropos Variables")
+ (init . (lambda () (alcs-init alcs-variables-buffer)))
+ (candidates-in-buffer)
+ (requires-pattern . 3)
+ (type . apropos-variable)))
+
+(defvar anything-c-source-emacs-function-at-point
+ '((name . "Function at point")
+ (candidates
+ . (lambda () (with-current-buffer anything-current-buffer
+ (anything-aif (function-called-at-point)
+ (list (symbol-name it))))))
+ (type . apropos-function)))
+
+(defvar anything-c-source-emacs-variable-at-point
+ '((name . "Variable at point")
+ (candidates
+ . (lambda () (with-current-buffer anything-current-buffer
+ (anything-aif (variable-at-point)
+ (unless (equal 0 it) (list (symbol-name it)))))))
+ (type . apropos-variable)))
+
+(defvar anything-lisp-complete-symbol-sources
+ '(anything-c-source-complete-emacs-commands
+ anything-c-source-complete-emacs-functions
+ anything-c-source-complete-emacs-variables))
+
+(defvar anything-apropos-sources
+ '(anything-c-source-apropos-emacs-commands
+ anything-c-source-apropos-emacs-functions
+ anything-c-source-apropos-emacs-variables))
+
+(define-anything-type-attribute 'apropos-function
+ '((filtered-candidate-transformer . alcs-sort-maybe)
+ (header-name . alcs-header-name)
+ (persistent-action . alcs-describe-function)
+ (action
+ ("Describe Function" . alcs-describe-function)
+ ("Find Function" . alcs-find-function))))
+(define-anything-type-attribute 'apropos-variable
+ '((filtered-candidate-transformer . alcs-sort-maybe)
+ (header-name . alcs-header-name)
+ (persistent-action . alcs-describe-variable)
+ (action
+ ("Describe Variable" . alcs-describe-variable)
+ ("Find Variable" . alcs-find-variable))))
+(define-anything-type-attribute 'complete-function
+ '((filtered-candidate-transformer alcs-sort-maybe alcs-transformer-prepend-spacer-maybe)
+ (header-name . alcs-header-name)
+ (action . ac-insert)
+ (persistent-action . alcs-describe-function)))
+(define-anything-type-attribute 'complete-variable
+ '((filtered-candidate-transformer alcs-sort-maybe alcs-transformer-prepend-spacer-maybe)
+ (header-name . alcs-header-name)
+ (action . ac-insert)
+ (persistent-action . alcs-describe-variable)))
+
+(defvar alcs-this-command nil)
+(defun anything-lisp-complete-symbol-1 (update sources input)
+ (setq alcs-this-command this-command)
+ (when (or update (null (get-buffer alcs-variables-buffer)))
+ (alcs-make-candidates))
+ (let (anything-samewindow
+ (anything-input-idle-delay
+ (or anything-lisp-complete-symbol-input-idle-delay
+ anything-input-idle-delay))
+ (anything-map (copy-keymap anything-map)))
+ (define-key anything-map "\C-c\C-u" 'alcs-update-restart)
+ (anything-noresume sources input nil nil nil "*anything complete*")))
+
+(defun alcs-update-restart ()
+ (interactive)
+ (alcs-make-candidates)
+ (anything-run-after-quit 'call-interactively alcs-this-command))
+
+(defun alcs-initial-input (partial-match)
+ (anything-aif (symbol-at-point)
+ (format "%s%s%s"
+ (if partial-match "" "^")
+ it
+ (if anything-lisp-complete-symbol-add-space-on-startup " " ""))
+ ""))
+
+(defun anything-lisp-complete-symbol (update)
+ "`lisp-complete-symbol' replacement using `anything'."
+ (interactive "P")
+ (anything-lisp-complete-symbol-1 update anything-lisp-complete-symbol-sources
+ (alcs-initial-input nil)))
+(defun anything-lisp-complete-symbol-partial-match (update)
+ "`lisp-complete-symbol' replacement using `anything' (partial match)."
+ (interactive "P")
+ (anything-lisp-complete-symbol-1 update anything-lisp-complete-symbol-sources
+ (alcs-initial-input t)))
+(defun anything-apropos (update)
+ "`apropos' replacement using `anything'."
+ (interactive "P")
+ (anything-lisp-complete-symbol-1 update anything-apropos-sources nil))
+
+;; (@* "anything-read-string-mode / read-* compatibility functions")
+;; moved from anything.el
+(defun anything-compile-source--default-value (source)
+ (anything-aif (assoc-default 'default-value source)
+ (append source
+ `((candidates ,it)
+ (filtered-candidate-transformer
+ . (lambda (cands source)
+ (if (string= anything-pattern "") cands nil)))))
+ source))
+(add-to-list 'anything-compile-source-functions 'anything-compile-source--default-value)
+
+(defun ac-new-input-source (prompt require-match &optional additional-attrs)
+ (unless require-match
+ `((name . ,prompt) (dummy) ,@additional-attrs)))
+(defun* ac-default-source (default &optional accept-empty (additional-attrs '((action . identity))))
+ `((name . "Default")
+ (default-value . ,(or default (and accept-empty "")))
+ ,@additional-attrs
+ ,(if accept-empty '(accept-empty))))
+;; (ac-default-source "a")
+;; (ac-default-source "a" t)
+;; (ac-default-source nil t)
+;; (ac-default-source nil)
+
+;; (@* "`completing-read' compatible read function ")
+(defun anything-completing-read (prompt collection &optional predicate require-match initial hist default inherit-input-method)
+ (if (or (arrayp collection) (functionp collection))
+ (anything-old-completing-read prompt collection predicate require-match initial hist default inherit-input-method)
+ ;; support only collection list.
+ (let* (anything-input-idle-delay
+ (result (or (anything-noresume (acr-sources
+ prompt
+ collection
+ predicate require-match initial
+ hist default inherit-input-method)
+ initial prompt nil nil "*anything complete*")
+ (keyboard-quit))))
+ (when (stringp result)
+ (prog1 result
+ (setq hist (or hist 'minibuffer-history))
+ (set hist (cons result (delete result (symbol-value hist)))))))))
+
+;; TODO obarray/predicate hacks: command/variable/symbol
+(defvar anything-completing-read-use-default t
+ "Whether to use default value source.")
+(defvar anything-completing-read-history-first nil
+ "Whether to display history source first.")
+(defvar anything-complete-persistent-action nil
+ "Persistent action function used by `anything-completing-read'.
+It accepts one argument, selected candidate.")
+
+(defun* acr-sources (prompt collection predicate require-match initial hist default inherit-input-method &optional (additional-attrs '((action . identity))))
+ "`anything' replacement for `completing-read'."
+ (let* ((transformer-func
+ (if predicate
+ `(candidate-transformer
+ . (lambda (cands)
+ (remove-if-not (lambda (c) (,predicate
+ (if (listp c) (car c) c))) cands)))))
+ (persistent-action
+ (if anything-complete-persistent-action
+ '(persistent-action
+ . (lambda (cand) (funcall anything-complete-persistent-action cand)))))
+ (new-input-source (ac-new-input-source prompt require-match additional-attrs))
+ (history-source (unless require-match
+ `((name . "History")
+ (candidates . ,(or hist 'minibuffer-history))
+ ,persistent-action
+ ,@additional-attrs)))
+ (default-source (and anything-completing-read-use-default (ac-default-source default t)))
+ (main-source `((name . "Completions")
+ (candidates . ,(mapcar (lambda (x) (or (car-safe x) x)) collection))
+ ,@additional-attrs
+ ,persistent-action
+ ,transformer-func)))
+ (cond ((and require-match default)
+ (list default-source main-source))
+ (require-match
+ (list main-source default-source))
+ (anything-completing-read-history-first
+ (list default-source history-source main-source new-input-source))
+ (t
+ (list default-source main-source history-source new-input-source)))))
+;; (anything-completing-read "Command: " obarray 'commandp t)
+;; (anything-completing-read "Test: " '(("hoge")("foo")("bar")) nil t)
+;; (anything-completing-read "Test: " '(("hoge")("foo")("bar")) nil t nil nil "foo")
+;; (let ((anything-complete-persistent-action 'message)) (anything-completing-read "Test: " '(("hoge")("foo")("bar")) nil t))
+;; (anything-old-completing-read "Test: " '(("hoge")("foo")("bar")) nil t)
+;; (anything-completing-read "Test: " '(("hoge")("foo")("bar")) nil nil "f" nil)
+;; (completing-read "Test: " '(("hoge")("foo")("bar")) nil nil "f" nil nil t)
+;; (anything-completing-read "Test: " '(("hoge")("foo")("bar")) nil nil nil nil "nana")
+;; (anything-completing-read "Test: " '("hoge" "foo" "bar"))
+
+;; (@* "`read-file-name' compatible read function ")
+(defvar anything-read-file-name-map nil)
+(defvar arfn-followed nil)
+(defvar arfn-dir nil)
+(defun anything-read-file-name-map ()
+ "Lazy initialization of `anything-read-file-name-map'."
+ (unless anything-read-file-name-map
+ (setq anything-read-file-name-map (copy-keymap anything-map))
+ (define-key anything-read-file-name-map "\C-i" 'anything-read-file-name-follow-directory)
+ (define-key anything-read-file-name-map [tab] 'anything-read-file-name-follow-directory))
+ anything-read-file-name-map)
+
+(defun anything-read-file-name-follow-directory ()
+ (interactive)
+ ;; These variables are bound by `arfn-sources' or `anything-find-file'.
+ (declare (special prompt default-filename require-match predicate additional-attrs))
+ (setq arfn-followed t)
+ (let* ((sel (anything-get-selection))
+ (f (expand-file-name sel arfn-dir)))
+ (cond ((and (file-directory-p f) (not (string-match "/\\.$" sel)))
+ (with-selected-window (minibuffer-window) (delete-minibuffer-contents))
+ (setq anything-pattern "")
+ ;;(setq arfn-dir f)
+ (anything-set-sources
+ (arfn-sources
+ prompt f default-filename require-match nil predicate additional-attrs))
+ (anything-update))
+ ((string-match "^\\(.+\\)/\\([^/]+\\)$" sel)
+ (with-selected-window (minibuffer-window)
+ (delete-minibuffer-contents)
+ (insert (match-string 2 sel)))
+ (anything-set-sources
+ (arfn-sources
+ prompt (expand-file-name (match-string 1 sel) arfn-dir) nil require-match (match-string 2 sel) predicate additional-attrs))
+ (anything-update)))))
+
+(defun* anything-read-file-name (prompt &optional dir default-filename require-match initial-input predicate (additional-attrs '((action . identity))))
+ "`anything' replacement for `read-file-name'."
+ (setq arfn-followed nil)
+ (let* ((anything-map (anything-read-file-name-map))
+ anything-input-idle-delay
+ (result (or (anything-noresume (arfn-sources
+ prompt dir default-filename require-match
+ initial-input predicate additional-attrs)
+ initial-input prompt nil nil "*anything complete*")
+ (keyboard-quit))))
+ (when (and require-match
+ (not (and (file-exists-p result)
+ (funcall (or predicate 'identity) result))))
+ (error "anything-read-file-name: file `%s' is not matched" result))
+ (when (stringp result)
+ (prog1 result
+ (add-to-list 'file-name-history result)
+ (setq file-name-history (cons result (delete result file-name-history)))))))
+
+(defun arfn-candidates (dir)
+ (if (file-directory-p dir)
+ (loop for (f _ _ _ _ _ _ _ _ perm _ _ _) in (directory-files-and-attributes dir t)
+ for basename = (file-name-nondirectory f)
+ when (string= "d" (substring perm 0 1))
+ collect (cons (concat basename "/") f)
+ else collect (cons basename f))))
+
+(defun* arfn-sources (prompt dir default-filename require-match initial-input predicate &optional (additional-attrs '((action . identity))))
+ (setq arfn-dir dir)
+ (let* ((dir (or dir default-directory))
+ (transformer-func
+ (if predicate
+ `(candidate-transformer
+ . (lambda (cands)
+ (remove-if-not
+ (lambda (c) (,predicate (if (consp c) (cdr c) c))) cands)))))
+ (new-input-source (ac-new-input-source
+ prompt nil
+ (append '((display-to-real . (lambda (f) (expand-file-name f arfn-dir))))
+ additional-attrs)))
+ (history-source (unless require-match
+ `((name . "History")
+ (candidates . file-name-history)
+ (persistent-action . find-file)
+ ,@additional-attrs))))
+ `(((name . "Default")
+ (candidates . ,(if default-filename (list default-filename)))
+ (persistent-action . find-file)
+ (filtered-candidate-transformer
+ . (lambda (cands source)
+ (if (and (not arfn-followed) (string= anything-pattern "")) cands nil)))
+ (display-to-real . (lambda (f) (expand-file-name f ,dir)))
+ ,@additional-attrs)
+ ((name . ,dir)
+ (candidates . (lambda () (arfn-candidates ,dir)))
+ (persistent-action . find-file)
+ ,@additional-attrs
+ ,transformer-func)
+ ,new-input-source
+ ,history-source)))
+;; (anything-read-file-name "file: " "~" ".emacs")
+;; (anything-read-file-name "file: " "~" ".emacs" t)
+;; (anything-read-file-name "file: " "~" )
+;; (anything-read-file-name "file: ")
+;; (read-file-name "file: " "/tmp")
+
+;; (@* "`read-buffer' compatible read function ")
+(defun anything-read-buffer (prompt &optional default require-match start matches-set)
+ "`anything' replacement for `read-buffer'."
+ (let (anything-input-idle-delay)
+ (anything-noresume (arb-sources prompt
+ (if (bufferp default) (buffer-name default) default)
+ require-match start matches-set)
+ start prompt nil nil "*anything complete*")))
+
+(defun* arb-sources (prompt default require-match start matches-set &optional (additional-attrs '((action . identity))))
+ `(,(ac-default-source default t)
+ ((name . ,prompt)
+ (persistent-action . switch-to-buffer)
+ (candidates . (lambda () (mapcar 'buffer-name (buffer-list))))
+ ,@additional-attrs)
+ ,(ac-new-input-source prompt require-match additional-attrs)))
+
+;; (anything-read-buffer "test: " nil)
+;; (anything-read-buffer "test: " "*scratch*" t)
+;; (anything-read-buffer "test: " "*scratch*" t "*")
+
+;; (read-variable "variable: " "find-file-hooks")
+;; (read-variable "variable: " 'find-file-hooks)
+;; (read-variable "variable: " )
+(defun anything-read-symbol-1 (prompt buffer default-value)
+ (let (anything-input-idle-delay anything-samewindow)
+ (intern (or (anything-noresume `(,(ac-default-source
+ (if default-value (format "%s" default-value)))
+ ((name . ,prompt)
+ (init . (lambda () (alcs-init ,buffer)))
+ (candidates-in-buffer)
+ (action . identity)))
+ nil prompt nil nil "*anything complete*")
+ (keyboard-quit)))))
+
+;; (@* "`read-variable' compatible read function ")
+(defun anything-read-variable (prompt &optional default-value)
+ (anything-read-symbol-1 prompt alcs-variables-buffer default-value))
+;; (anything-read-variable "variable: " 'find-file-hooks)
+
+;; (@* "`read-command' compatible read function ")
+(defun anything-read-command (prompt &optional default-value)
+ (anything-read-symbol-1 prompt alcs-commands-buffer default-value))
+;; (anything-read-variable "command: ")
+
+
+;; (@* "`anything-read-string-mode' initialization")
+(defvar anything-read-string-mode nil)
+(unless anything-read-string-mode
+ (defalias 'anything-old-completing-read (symbol-function 'completing-read))
+ (defalias 'anything-old-read-file-name (symbol-function 'read-file-name))
+ (defalias 'anything-old-read-buffer (symbol-function 'read-buffer))
+ (defalias 'anything-old-read-variable (symbol-function 'read-variable))
+ (defalias 'anything-old-read-command (symbol-function 'read-command))
+ (put 'anything-read-string-mode 'orig-read-buffer-function read-buffer-function))
+
+;; (anything-read-string-mode -1)
+;; (anything-read-string-mode 1)
+;; (anything-read-string-mode 0)
+(defun anything-read-string-mode (arg)
+ "If this minor mode is on, use `anything' version of `completing-read' and `read-file-name'."
+ (interactive "P")
+ (setq anything-read-string-mode (if arg (> (prefix-numeric-value arg) 0) (not anything-read-string-mode)))
+ (cond (anything-read-string-mode
+ ;; redefine to anything version
+ (defalias 'completing-read (symbol-function 'anything-completing-read))
+ (defalias 'read-file-name (symbol-function 'anything-read-file-name))
+ (setq read-buffer-function 'anything-read-buffer)
+ (defalias 'read-buffer (symbol-function 'anything-read-buffer))
+ (defalias 'read-variable (symbol-function 'anything-read-variable))
+ (defalias 'read-command (symbol-function 'anything-read-command))
+ (substitute-key-definition 'execute-extended-command 'anything-execute-extended-command global-map)
+ (substitute-key-definition 'find-file 'anything-find-file global-map)
+ (message "Installed anything version of read functions."))
+ (t
+ ;; restore to original version
+ (defalias 'completing-read (symbol-function 'anything-old-completing-read))
+ (defalias 'read-file-name (symbol-function 'anything-old-read-file-name))
+ (setq read-buffer-function (get 'anything-read-string-mode 'orig-read-buffer-function))
+ (defalias 'read-buffer (symbol-function 'anything-old-read-buffer))
+ (defalias 'read-variable (symbol-function 'anything-old-read-variable))
+ (defalias 'read-command (symbol-function 'anything-old-read-command))
+ (substitute-key-definition 'anything-execute-extended-command 'execute-extended-command global-map)
+ (substitute-key-definition 'anything-find-file 'find-file global-map)
+ (message "Uninstalled anything version of read functions."))))
+
+
+;; (@* " shell history")
+(defun anything-complete-shell-history ()
+ "Select a command from shell history and insert it."
+ (interactive)
+ (let ((anything-show-completion-minimum-window-height (/ (frame-height) 2)))
+ (anything-complete 'anything-c-source-complete-shell-history
+ (or (word-at-point) "")
+ 20)))
+(defun anything-complete-shell-history-setup-key (key)
+ ;; for Emacs22
+ (when (and (not (boundp 'minibuffer-local-shell-command-map))
+ (require 'shell-command nil t)
+ (boundp 'shell-command-minibuffer-map))
+ (shell-command-completion-mode)
+ (define-key shell-command-minibuffer-map key 'anything-complete-shell-history))
+ ;; for Emacs23
+ (when (boundp 'minibuffer-local-shell-command-map)
+ (define-key minibuffer-local-shell-command-map key 'anything-complete-shell-history))
+
+ (when (require 'background nil t)
+ (define-key background-minibuffer-map key 'anything-complete-shell-history))
+ (require 'shell)
+ (define-key shell-mode-map key 'anything-complete-shell-history))
+
+(defvar zsh-p nil)
+(defvar anything-c-source-complete-shell-history
+ '((name . "Shell History")
+ (init . (lambda ()
+ (require 'shell-history)
+ (with-current-buffer (anything-candidate-buffer (shell-history-buffer))
+ (revert-buffer t t)
+ (set (make-local-variable 'zsh-p)
+ (shell-history-zsh-extended-history-p)))))
+ (get-line . acsh-get-line)
+ (search-from-end)
+ (type . complete)))
+
+(defun acsh-get-line (s e)
+ (let ((extended-history (string= (buffer-substring s (+ s 2)) ": "))
+ (single-line (not (string= (buffer-substring (1- e) e) "\\"))))
+ (cond ((not zsh-p)
+ (buffer-substring s e))
+ ((and extended-history single-line)
+ (buffer-substring (+ s 15) e))
+ (extended-history ;zsh multi-line / 1st line
+ (goto-char e)
+ (let ((e2 (1- (if (re-search-forward "^: [0-9]+:[0-9];" nil t)
+ (match-beginning 0)
+ (point-max)))))
+ (prog1 (replace-regexp-in-string
+ "\\\\\n" ";" (buffer-substring (+ s 15) e2))
+ (goto-char s))))
+ (t ; zsh multi-line history / not 1st line
+ (goto-char s)
+ (re-search-backward "^: [0-9]+:[0-9];" nil t)
+ (let ((s2 (match-end 0)) e2)
+ (goto-char s2)
+ (setq e2 (1- (if (re-search-forward "^: [0-9]+:[0-9];" nil t)
+ (match-beginning 0)
+ (point-max))))
+ (prog1 (replace-regexp-in-string
+ "\\\\\n" ";" (buffer-substring s2 e2))
+ (goto-char s2)))))))
+
+;; I do not want to make anything-c-source-* symbols because they are
+;; private in `anything-execute-extended-command'.
+(defvar anything-execute-extended-command-sources
+ '(((name . "Emacs Commands History")
+ (candidates . extended-command-history)
+ (action . identity)
+ (persistent-action . alcs-describe-function))
+ ((name . "Commands")
+ (init . (lambda () (anything-candidate-buffer
+ (get-buffer alcs-commands-buffer))))
+ (candidates-in-buffer)
+ (action . identity)
+ (persistent-action . alcs-describe-function))
+ ((name . "Commands (by prefix)")
+ (candidates
+ . (lambda ()
+ (all-completions anything-pattern obarray 'commandp)))
+ (volatile)
+ (action . identity)
+ (persistent-action . alcs-describe-function))))
+
+(defun anything-execute-extended-command ()
+ (interactive)
+ (let ((cmd (anything
+ (if (require 'anything-kyr-config nil t)
+ (cons anything-c-source-kyr
+ anything-execute-extended-command-sources)
+ anything-execute-extended-command-sources))))
+ (when cmd
+ (setq extended-command-history (cons cmd (delete cmd extended-command-history)))
+ (setq cmd (intern cmd))
+ (if (stringp (symbol-function cmd))
+ (execute-kbd-macro (symbol-function cmd))
+ (call-interactively cmd)))))
+
+(defvar anything-find-file-additional-sources nil)
+(defun anything-find-file ()
+ (interactive)
+ (let ((anything-map (anything-read-file-name-map))
+ ;; anything-read-file-name-follow-directory uses these variables
+ (prompt "Find File: ")
+ default-filename require-match predicate
+ (additional-attrs '(;; because anything-c-skip-boring-files cannot
+ ;; handle (display . real) candidates
+ (candidate-transformer)
+ (type . file))))
+ (anything-other-buffer (append (arfn-sources prompt default-directory
+ nil nil nil nil additional-attrs)
+ anything-find-file-additional-sources)
+ "*anything find-file*")))
+;;(anything-find-file)
+
+(add-hook 'after-init-hook 'alcs-make-candidates)
+
+
+;;;; unit test
+;; (install-elisp "http://www.emacswiki.org/cgi-bin/wiki/download/el-expectations.el")
+;; (install-elisp "http://www.emacswiki.org/cgi-bin/wiki/download/el-mock.el")
+(dont-compile
+ (when (fboundp 'expectations)
+ (expectations
+ (desc "acsh-get-line command")
+ (expect "ls"
+ (let ((zsh-p t))
+ (with-temp-buffer
+ (insert ": 1118554690:0;cat ~/.zsh_history\n"
+ ": 1118554690:0;ls\n")
+ (forward-line -1)
+ (acsh-get-line (point-at-bol) (point-at-eol)))))
+ (expect "cd;ls -l"
+ (let ((zsh-p t))
+ (with-temp-buffer
+ (insert ": 1118554690:0;cat ~/.zsh_history\n"
+ ": 1118554690:0;cd\\\n"
+ "ls -l\n"
+ ": 1118554690:0;hoge\n")
+ (forward-line -2)
+ (acsh-get-line (point-at-bol) (point-at-eol)))))
+ (expect "cd;ls -l"
+ (let ((zsh-p t))
+ (with-temp-buffer
+ (insert ": 1118554690:0;cat ~/.zsh_history\n"
+ ": 1118554690:0;cd\\\n"
+ "ls -l\n"
+ ": 1118554690:0;hoge\n")
+ (forward-line -3)
+ (acsh-get-line (point-at-bol) (point-at-eol)))))
+ (expect "cd;ls -l"
+ (let ((zsh-p t))
+ (with-temp-buffer
+ (insert ": 1118554690:0;cat ~/.zsh_history\n"
+ ": 1118554690:0;cd\\\n"
+ "ls -l\n")
+ (forward-line -1)
+ (acsh-get-line (point-at-bol) (point-at-eol)))))
+ (expect "cd;ls -l"
+ (let ((zsh-p t))
+ (with-temp-buffer
+ (insert ": 1118554690:0;cat ~/.zsh_history\n"
+ ": 1118554690:0;cd\\\n"
+ "ls -l\n")
+ (forward-line -2)
+ (acsh-get-line (point-at-bol) (point-at-eol)))))
+ (expect "pwd"
+ (let ((zsh-p nil))
+ (with-temp-buffer
+ (insert "foo\n"
+ "pwd\n")
+ (forward-line -1)
+ (acsh-get-line (point-at-bol) (point-at-eol)))))
+ (desc "acsh-get-line lineno")
+ (expect 2
+ (let ((zsh-p t))
+ (with-temp-buffer
+ (insert ": 1118554690:0;cat ~/.zsh_history\n"
+ ": 1118554690:0;cd\\\n"
+ "ls -l\n"
+ ": 1118554690:0;hoge\n")
+ (forward-line -2)
+ (acsh-get-line (point-at-bol) (point-at-eol))
+ (line-number-at-pos))))
+ (expect 2
+ (let ((zsh-p t))
+ (with-temp-buffer
+ (insert ": 1118554690:0;cat ~/.zsh_history\n"
+ ": 1118554690:0;cd\\\n"
+ "ls -l\n"
+ ": 1118554690:0;hoge\n")
+ (forward-line -3)
+ (acsh-get-line (point-at-bol) (point-at-eol))
+ (line-number-at-pos))))
+
+ )))
+
+;;; for compatibility
+(defvaralias 'anything-c-source-complete-emacs-variables-partial-match
+ 'anything-c-source-complete-emacs-variables)
+(defvaralias 'anything-c-source-complete-emacs-commands-partial-match
+ 'anything-c-source-complete-emacs-commands)
+(defvaralias 'anything-c-source-complete-emacs-functions-partial-match
+ 'anything-c-source-complete-emacs-functions)
+
+
+
+(provide 'anything-complete)
+
+;; How to save (DO NOT REMOVE!!)
+;; (emacswiki-post "anything-complete.el")
+;;; anything-complete.el ends here
View
4,780 auto-install/anything-config.el
4,780 additions, 0 deletions not shown
View
428 auto-install/anything-etags.el
@@ -0,0 +1,428 @@
+;;; anything-etags.el --- Etags anything.el interface
+
+;; Filename: anything-etags.el
+;; Description: Etags anything.el interface
+;; Author: Kenichirou Oyama <k1lowxb@gmail.com>
+;; Andy Stewart <lazycat.manatee@gmail.com>
+;; rubikitch <rubikitch@ruby-lang.org>
+;; Thierry Volpiatto <thierry.volpiatto@gmail.com>
+;; Maintainer: Kenichirou Oyama <k1lowxb@gmail.com>
+;; Copyright (C) 2009, Kenichirou Oyama, all rights reserved.
+;; Copyright (C) 2009, Andy Stewart, all rights reserved.
+;; Copyright (C) 2009, rubikitch, all rights reserved.
+;; Copyright (C) 2009, Thierry Volpiatto, all rights reserved.
+;; Created: 2009-01-29 18:19:38
+;; Version: 1.1.6
+;; URL: http://www.emacswiki.org/emacs/download/anything-etags.el
+;; Keywords: anything, etags
+;; Compatibility: GNU Emacs 22 ~ 23
+;;
+;; Features that might be required by this library:
+;;
+;; `anything' `etags'
+;;
+
+;;; 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 this program; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+;; Floor, Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+;;
+;; This package use `anything' as a interface to find tag with Etags.
+;;
+;;
+;; You can also make this package integrate with `anything',
+;; just setup like below:
+;;
+;; (setq anything-sources
+;; '(anything-etags-c-source-etags-select
+;; ))
+;;
+;; If you want to use tag file in cache directory
+;; instead current directory, example you have a
+;; tag file in directory "~/MyEmacs/", and you want
+;; always search tag in this directory.
+;; You can setup like below:
+;;
+;; (setq anything-etags-enable-tag-file-dir-cache t)
+;; (setq anything-etags-cache-tag-file-dir "~/MyEmacs/")
+;;
+;;; Installation:
+;;
+;; Put anything-etags.el to your load-path.
+;; The load-path is usually ~/elisp/.
+;; It's set in your ~/.emacs like this:
+;; (add-to-list 'load-path (expand-file-name "~/elisp"))
+;;
+;; And the following to your ~/.emacs startup file.
+;;
+;; (require 'anything-etags)
+;;
+;; It is good to use anything-match-plugin.el to narrow candidates.
+;; http://www.emacswiki.org/cgi-bin/wiki/download/anything-match-plugin
+;;
+;; No need more.
+
+;;; Commands:
+;;
+;; Below are complete command list:
+;;
+;; `anything-etags-select'
+;; Tag jump using etags and `anything'.
+;; `anything-etags-select-from-here'
+;; Tag jump with current symbol using etags and `anything'.
+;; `anything-etags-enable-cache'
+;; Enable use tag file in cache directory.
+;; `anything-etags-disable-cache'
+;; Disable use tag file in cache directory.
+;; `anything-etags-toggle-cache'
+;; Toggle tag file cache directory status.
+;; `anything-etags-generate-tag-buffer'
+;; Do nothing. Only for compatibility.
+;;
+;;; Customizable Options:
+;;
+;; Below are customizable option list:
+;;
+;; `anything-etags-tag-file-name'
+;; Etags tag file name.
+;; default = "TAGS"
+;; `anything-etags-enable-tag-file-dir-cache'
+;; Whether use Etags tag file in cache directory.
+;; default = nil
+;; `anything-etags-cache-tag-file-dir'
+;; The cache directory that storage Etags tag file.
+;; default = nil
+;; `anything-etags-tag-file-search-limit'
+;; The limit level of directory that search tag file.
+;; default = 10
+
+
+;;; Change log:
+;;
+;; 2009/04/04
+;; * Thierry Volpiatto:
+;; * Regexp change in `anything-c-etags-get-line'.
+;;
+;; 2009/03/28
+;; * Thierry Volpiatto:
+;; * code cleanup.
+;; * rubikitch:
+;; * More beautiful line. (only show the line)
+;; * Show TAGS file name in header.
+;;
+;; 2009/03/23
+;; * rubikitch:
+;; * Use `expand-file-name' instead of `concat' to make full path.
+;; * Optionally highlight in persistent-action.
+;; * Fix doc.
+;;
+;; 2009/03/19
+;; * Kenichirou Oyama:
+;; * Fix bug.
+;;
+;; 2009/03/19
+;; * Kenichirou Oyama:
+;; * Use `etags-goto-tag-location'.
+;;
+;; 2009/03/18
+;; * Kenichirou Oyama:
+;; * Applied SUGAWARA's patch to make `anything-etags-generate-tag-buffer' to user command.
+;; * makes `anything-etags-generate-tag-buffer' to user command.
+;; * Fix doc.
+;;
+;; 2009/03/18
+;; * Kenichirou Oyama:
+;; * Applied SUGAWARA's patch to make multi TAGS buffer.
+;; * use separete tag buffer for each tag file.
+;; * create tag buffer only first visit time.
+;; * Fix doc.
+;; * Fix bug.
+;;
+;; 2009/03/07
+;; * rubikitch:
+;; * More kind error message.
+;;
+;; 2009/02/07
+;; * rubikitch:
+;; * Use `anything-quit-if-no-candidate' and
+;; `anything-execute-action-at-once-if-one' to suppress
+;; opening unneeded *anything* window.
+;; * New command `anything-etags-select-from-here'.
+;; * Suggestion of anything-match-plugin.el.
+;; * Fix bug.
+;; * Refactor code.
+;; * Andy Stewart
+;; * Remove option `anything-etags-enable-initial-pattern'
+;; not necessary.
+;; * Fix doc.
+;;
+;; 2009/02/01
+;; * Andy Stewart:
+;; * Applied IMAKADO's patch to fix the "infinite loop" bug
+;; when TAGS file in more than two levels upper directory.
+;;
+;; 2009/01/30
+;; * Andy Stewart:
+;; * Remove file patch that haven't contain tag information
+;; from tag buffer.
+;; * Don't show \x01 in *anything* buffer, beautiful <line>.
+;; * Fix bug.
+;;
+;; 2009/01/30
+;; * rubikitch:
+;; * Fix bug.
+;; * Refactor code.
+;;
+;; 2009/01/29
+;; * Andy Stewart:
+;; * Refactor source code and make it more readability.
+;; * Fix bug.
+;; * Fix doc.
+;; * Make user can use function `anything-etags-generate-tag-buffer'
+;; to generate tag buffer when startup.
+;; Then user doesn't need wait `anything' when first use.
+;;
+;; 2009/01/28
+;; * Kenichirou:
+;; * Patch from Andy Stewart.
+;; Refactor source code and speed up for
+;; `anything-c-source-etags-select' user.
+;; * New variable `anything-etags-enable-tag-file-dir-cache'.
+;;