diff --git a/emacs b/emacs index e33be29..e8dd625 100644 --- a/emacs +++ b/emacs @@ -51,13 +51,6 @@ (setq projectile-enable-caching t) (projectile-global-mode t) -(elpy-enable) - -;call gofmt on the script when saving -(add-hook 'go-mode-hook - '(lambda () - (add-hook 'before-save-hook 'gofmt))) - ;js-mode overwrites json-mode when loading .json files, so this is ; to force json-mode for .json files (add-to-list 'auto-mode-alist '("\\.json$" . json-mode)) @@ -69,16 +62,3 @@ (color-theme-clarity) (require 'powerline) (powerline-default-theme) - -; http://blog.lathi.net/articles/2007/11/07/sharing-the-mac-clipboard-with-emacs -(defun copy-from-osx () - (shell-command-to-string "pbpaste")) - -(defun paste-to-osx (text &optional push) - (let ((process-connection-type nil)) - (let ((proc (start-process "pbcopy" "*Messages*" "pbcopy"))) - (process-send-string proc text) - (process-send-eof proc)))) - -(setq interprogram-cut-function 'paste-to-osx) -(setq interprogram-paste-function 'copy-from-osx) diff --git a/emacs.d/elpa/ack-1.2/ChangeLog b/emacs.d/elpa/ack-1.2/ChangeLog deleted file mode 100644 index a687261..0000000 --- a/emacs.d/elpa/ack-1.2/ChangeLog +++ /dev/null @@ -1,73 +0,0 @@ -2013-05-04 Leo Liu - - * ack: bump to version 1.2 to make the archiver happy - - Fix http://debbugs.gnu.org/14338 - -2013-04-21 Leo Liu - - * ack: doc fix and release 1.01 - - Support the silver search (ag) - https://github.com/ggreer/the_silver_searcher which is an order of - magnitude faster than ack. - -2013-04-20 Leo Liu - - * ack: Release v1.0 - -2013-02-26 Leo Liu - - * ack.el: work around bug http://debbugs.gnu.org/13811 - - Use setq-local and enhance minibuffer prompt update feature. - -2013-02-07 Leo Liu - - * ack: release v0.9 - - - remove emacs 23 support - - add a new command ack-mode-display-match - -2013-01-13 Leo Liu - - New command ack-yank-symbol-at-point and bind it to M-Y - - Thanks to scottj@irc.freenode.net for request and testing. - Also update copyright years. - -2012-11-19 Leo Liu - - * ack.el (ack-buffer-name-function): New user variable - - Thanks to scottj@irc.freenode.net for request and testing. - -2012-10-21 Leo Liu - - * ack.el: Make minibuffer prompt more informative - -2012-10-08 Leo Liu - - * README (Usage): Doc fix - -2012-10-08 Chong Yidong - - Fix copyright headers for ack package - -2012-10-08 Chong Yidong - - Convert packages/ack/README.rst to a package.el compatible README. - Tweak the description of the ack package in packages/ack/ack-pkg.el. - -2012-10-04 Leo Liu - - Add file ack-pkg.el - -2012-10-04 Leo Liu - - Sync ack.el and pcmpl-ack.el to version 0.8 - -2012-10-01 Leo Liu - - Add ack - diff --git a/emacs.d/elpa/ack-1.2/README b/emacs.d/elpa/ack-1.2/README deleted file mode 100644 index 35503de..0000000 --- a/emacs.d/elpa/ack-1.2/README +++ /dev/null @@ -1,34 +0,0 @@ -This package provides an interface to ack http://beyondgrep.com -- a -tool like grep, designed for programmers with large trees of -heterogeneous source code. It builds on standard packages `compile.el' -and `ansi-color.el' and lets you seamlessly run `ack' with its large -set of options. - -Ack-like tools such as the silver search (ag) and git/hg/bzr grep are -well supported too. - -Usage: -Type `M-x ack' and provide a pattern to search. -Type `C-u M-x ack' to search from current project root. -Type `C-u C-u M-x ack' to interactively choose a directory to search. - -While reading ack command and args from the minibuffer, the following -key bindings may be useful: - -- `M-I' inserts a template for case-insensitive file name search -- `M-G' inserts a template for `git grep', `hg grep' or `bzr grep' -- `M-Y' inserts the symbol at point from the window before entering - the minibuffer -- `TAB' completes ack options - -This package does not require `--nogroup' nor `--noheading'. -Coloring is performed using the standard library ansi-color.el. - -Screenshots: -http://i.imgur.com/VwWyzAe.png -http://i.imgur.com/rwjC4pa.png - -Bugs: -https://github.com/leoliu/ack-el/issues - -ack.el was written by Leo Liu, with contributions from Phillip Lord. diff --git a/emacs.d/elpa/ack-1.2/ack-autoloads.el b/emacs.d/elpa/ack-1.2/ack-autoloads.el deleted file mode 100644 index 92a9ebc..0000000 --- a/emacs.d/elpa/ack-1.2/ack-autoloads.el +++ /dev/null @@ -1,49 +0,0 @@ -;;; ack-autoloads.el --- automatically extracted autoloads -;; -;;; Code: - - -;;;### (autoloads (ack) "ack" "ack.el" (20884 64193)) -;;; Generated autoloads from ack.el - -(autoload 'ack "ack" "\ -Run ack using COMMAND-ARGS and collect output in a buffer. -When called interactively, the value of DIRECTORY is provided by -`ack-default-directory-function'. - -The following keys are available while reading from the -minibuffer: - -\\{ack-minibuffer-local-map} - -\(fn COMMAND-ARGS &optional DIRECTORY)" t nil) - -;;;*** - -;;;### (autoloads (pcomplete/ack) "pcmpl-ack" "pcmpl-ack.el" (20884 -;;;;;; 64193)) -;;; Generated autoloads from pcmpl-ack.el - -(autoload 'pcomplete/ack "pcmpl-ack" "\ -Completion for the `ack' command. -Start an argument with '-' to complete short options and '--' for -long options. - -\(fn)" nil nil) - -(defalias 'pcomplete/ack-grep 'pcomplete/ack) - -;;;*** - -;;;### (autoloads nil nil ("ack-pkg.el") (20884 64193 379608)) - -;;;*** - -(provide 'ack-autoloads) -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; coding: utf-8 -;; End: -;;; ack-autoloads.el ends here diff --git a/emacs.d/elpa/ack-1.2/ack-pkg.el b/emacs.d/elpa/ack-1.2/ack-pkg.el deleted file mode 100644 index dc627cb..0000000 --- a/emacs.d/elpa/ack-1.2/ack-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "ack" "1.2" "Interface to ack-like source code search tools") diff --git a/emacs.d/elpa/ack-1.2/ack-pkg.elc b/emacs.d/elpa/ack-1.2/ack-pkg.elc deleted file mode 100644 index e3e212f..0000000 Binary files a/emacs.d/elpa/ack-1.2/ack-pkg.elc and /dev/null differ diff --git a/emacs.d/elpa/ack-1.2/ack.el b/emacs.d/elpa/ack-1.2/ack.el deleted file mode 100644 index e749355..0000000 --- a/emacs.d/elpa/ack-1.2/ack.el +++ /dev/null @@ -1,387 +0,0 @@ -;;; ack.el --- interface to ack-like tools -*- lexical-binding: t; -*- - -;; Copyright (C) 2012-2013 Free Software Foundation, Inc. - -;; Author: Leo Liu -;; Version: 1.2 -;; Keywords: tools, processes, convenience -;; Created: 2012-03-24 -;; URL: https://github.com/leoliu/ack-el - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: - -;; This package provides an interface to ack http://beyondgrep.com -- -;; a tool like grep, designed for programmers with large trees of -;; heterogeneous source code. It builds on standard packages -;; `compile.el' and `ansi-color.el' and lets you seamlessly run `ack' -;; with its large set of options. -;; -;; Ack-like tools such as the silver search (ag) and git/hg/bzr grep -;; are well supported too. - -;;; Usage: - -;; + Type `M-x ack' and provide a pattern to search. -;; + Type `C-u M-x ack' to search from current project root. -;; + Type `C-u C-u M-x ack' to interactively choose a directory to -;; search. -;; -;; Note: use `ack-default-directory-function' for customised -;; behaviour. -;; -;; When in the minibuffer the following key bindings may be useful: -;; -;; + `M-I' inserts a template for case-insensitive file name search -;; + `M-G' inserts a template for `git grep', `hg grep' or `bzr grep' -;; + `M-Y' inserts the symbol at point from the window before entering -;; the minibuffer -;; + `TAB' completes ack options - -;;; Bugs: https://github.com/leoliu/ack-el/issues - -;;; Code: - -(require 'compile) -(require 'ansi-color) -(autoload 'shell-completion-vars "shell") - -(eval-when-compile - (unless (fboundp 'setq-local) - (defmacro setq-local (var val) - (list 'set (list 'make-local-variable (list 'quote var)) val)))) - -(defgroup ack nil - "Run `ack' and display the results." - :group 'tools - :group 'processes) - -;; Used implicitly by `define-compilation-mode' -(defcustom ack-scroll-output nil - "Similar to `compilation-scroll-output' but for the *Ack* buffer." - :type 'boolean - :group 'ack) - -(defcustom ack-command - ;; Note: on GNU/Linux ack may be renamed to ack-grep - (concat (file-name-nondirectory (or (executable-find "ack-grep") - (executable-find "ack") - (executable-find "ag") - "ack")) " ") - "The default command for \\[ack]. - -Note also options to ack can be specified in ACK_OPTIONS -environment variable and .ackrc, which you can disable by the ---noenv switch." - :type 'string - :safe 'stringp - :group 'ack) - -(defcustom ack-buffer-name-function nil - "If non-nil, a function to compute the name of an ack buffer. -See `compilation-buffer-name-function' for details." - :type '(choice function (const nil)) - :group 'ack) - -(defcustom ack-vc-grep-commands - '((".git" . "git --no-pager grep --color -n -i") - (".hg" . "hg grep -n -i") - ;; Plugin bzr-grep required for bzr < 2.6 - (".bzr" . "bzr grep --color=always -n -i")) - "An alist of vc grep commands for `ack-skel-vc-grep'. -Each element is of the form (VC_DIR . CMD)." - :type '(repeat (cons string string)) - :group 'ack) - -(defcustom ack-default-directory-function 'ack-default-directory - "A function to return the default directory for `ack'. -It is called with one arg, the prefix arg to `ack'." - :type 'function - :group 'ack) - -(defcustom ack-project-root-patterns - (list (concat "\\`" (regexp-quote dir-locals-file) "\\'") - "\\`Project\\.ede\\'" - "\\.xcodeproj\\'" ; xcode - "\\`\\.ropeproject\\'" ; python rope - "\\`\\.\\(?:CVS\\|bzr\\|git\\|hg\\|svn\\)\\'") - "A list of regexps to match files in a project root. -Used by `ack-guess-project-root'." - :type '(repeat string) - :group 'ack) - -(defcustom ack-minibuffer-setup-hook nil - "Ack-specific hook for `minibuffer-setup-hook'." - :type 'hook - :group 'ack) - -;;; ======== END of USER OPTIONS ======== - -(defvar ack-history nil "History list for ack.") - -(defvar ack-first-column 0 - "Value to use for `compilation-first-column' in ack buffers.") - -(defvar ack-error-screen-columns nil - "Value to use for `compilation-error-screen-columns' in ack buffers.") - -(defvar ack-error "ack match" - "Stem of message to print when no matches are found.") - -(defun ack-filter () - "Handle match highlighting escape sequences inserted by the ack process. -This function is called from `compilation-filter-hook'." - (save-excursion - (let ((ansi-color-apply-face-function - (lambda (beg end face) - (when face - (ansi-color-apply-overlay-face beg end face) - (put-text-property beg end 'ack-color t))))) - (ansi-color-apply-on-region compilation-filter-start (point))))) - -(defvar ack-mode-font-lock-keywords - '(("^--$" 0 'shadow) - ;; Command output lines. - (": \\(.+\\): \\(?:Permission denied\\|No such \\(?:file or directory\\|device or address\\)\\)$" - 1 'compilation-error) - ;; Remove match from ack-error-regexp-alist before fontifying - ("^Ack \\(?:started\\|finished\\) at.*" - (0 '(face nil compilation-message nil message nil help-echo nil mouse-face nil) t)) - ("^Ack \\(exited abnormally\\|interrupt\\|killed\\|terminated\\)\\(?:.*with code \\([0-9]+\\)\\)?.*" - (0 '(face nil compilation-message nil message nil help-echo nil mouse-face nil) t) - (1 'compilation-error) - (2 'compilation-error nil t))) - "Additional things to highlight in ack output. -This gets tacked on the end of the generated expressions.") - -(defun ack--column-start () - (or (let* ((beg (match-end 0)) - (end (save-excursion - (goto-char beg) - (line-end-position))) - (mbeg (text-property-any beg end 'ack-color t))) - (when mbeg (- mbeg beg))) - ;; Use column number from `ack' itself if available - (when (match-string 4) - (1- (string-to-number (match-string 4)))))) - -(defun ack--column-end () - (let* ((beg (match-end 0)) - (end (save-excursion - (goto-char beg) - (line-end-position))) - (mbeg (text-property-any beg end 'ack-color t)) - (mend (and mbeg (next-single-property-change - mbeg 'ack-color nil end)))) - (when mend (- mend beg)))) - -(defun ack--file () - (let (file) - (save-excursion - (while (progn - (forward-line -1) - (looking-at-p "^--$"))) - (setq file (or (get-text-property (line-beginning-position) 'ack-file) - (progn - (put-text-property (line-beginning-position) - (line-end-position) - 'font-lock-face compilation-info-face) - (buffer-substring-no-properties - (line-beginning-position) (line-end-position)))))) - (put-text-property (line-beginning-position) - (min (1+ (line-end-position)) (point-max)) 'ack-file file) - (list file))) - -;;; `compilation-mode-font-lock-keywords' -> -;;; `compilation--ensure-parse' -> `compilation--parse-region' -> -;;; `compilation-parse-errors' -> `compilation-error-properties'. -;;; `compilation-error-properties' returns nil if a previous pattern -;;; in the regexp alist has already been applied in a region. - -(defconst ack-error-regexp-alist - `(;; grouping line (--group or --heading) - ("^\\([1-9][0-9]*\\)\\(:\\|-\\)\\(?:\\(?4:[1-9][0-9]*\\)\\2\\)?" - ack--file 1 (ack--column-start . ack--column-end) - nil nil (4 compilation-column-face nil t)) - ;; none grouping line (--nogroup or --noheading) - ("^\\(.+?\\)\\(:\\|-\\)\\([1-9][0-9]*\\)\\2\\(?:\\(?4:[1-9][0-9]*\\)\\2\\)?" - 1 3 (ack--column-start . ack--column-end) - nil nil (4 compilation-column-face nil t)) - ("^Binary file \\(.+\\) matches$" 1 nil nil 0 1)) - "Ack version of `compilation-error-regexp-alist' (which see).") - -(defvar ack-process-setup-function 'ack-process-setup) - -(defun ack-process-setup () - ;; Handle `hg grep' output - (when (string-match-p "^[ \t]*hg[ \t]" (car compilation-arguments)) - (setq compilation-error-regexp-alist - '(("^\\(.+?:[0-9]+:\\)\\(?:\\([0-9]+\\):\\)?" 1 2))) - (setq-local compilation-parse-errors-filename-function - (lambda (file) - (save-match-data - (if (string-match "\\(.+\\):\\([0-9]+\\):" file) - (match-string 1 file) - file))))) - ;; Handle `bzr grep' output - (when (string-match-p "^[ \t]*bzr[ \t]" (car compilation-arguments)) - (setq-local compilation-parse-errors-filename-function - (lambda (file) - (save-match-data - ;; 'bzr grep -r' has files like `termcolor.py~147' - (if (string-match "\\(.+\\)~\\([0-9]+\\)" file) - (match-string 1 file) - file)))))) - -(define-compilation-mode ack-mode "Ack" - "A compilation mode tailored for ack." - (setq-local compilation-disable-input t) - (setq-local compilation-error-face 'compilation-info) - (add-hook 'compilation-filter-hook 'ack-filter nil t)) - -;;; `compilation-display-error' is introduced in 24.4 -(unless (fboundp 'compilation-display-error) - (defun ack-mode-display-match () - "Display in another window the match in current line." - (interactive) - (setq compilation-current-error (point)) - (next-error-no-select 0)) - (define-key ack-mode-map "\C-o" #'ack-mode-display-match)) - -(defun ack-skel-file () - "Insert a template for case-insensitive file name search." - (interactive) - (delete-minibuffer-contents) - (let ((ack (or (car (split-string ack-command nil t)) "ack"))) - (if (equal ack "ag") - (skeleton-insert `(nil ,ack " -ig '" _ "'")) - (skeleton-insert `(nil ,ack " -g '(?i:" _ ")'"))))) - -;; Work around bug http://debbugs.gnu.org/13811 -(defvar ack--project-root nil) ; dynamically bound in `ack' - -(defun ack-skel-vc-grep () - "Insert a template for vc grep search." - (interactive) - (let* ((regexp (concat "\\`" (regexp-opt - (mapcar 'car ack-vc-grep-commands)) - "\\'")) - (root (or (ack-guess-project-root default-directory regexp) - (error "Cannot locate vc project root"))) - (which (car (directory-files root nil regexp))) - (backend (downcase (substring which 1))) - (cmd (or (cdr (assoc which ack-vc-grep-commands)) - (error "No command provided for `%s grep'" backend)))) - (setq ack--project-root root) - (delete-minibuffer-contents) - (skeleton-insert `(nil ,cmd " '" _ "'")))) - -(defun ack-yank-symbol-at-point () - "Yank the symbol from the window before entering the minibuffer." - (interactive) - (let ((symbol (and (minibuffer-selected-window) - (with-current-buffer - (window-buffer (minibuffer-selected-window)) - (thing-at-point 'symbol))))) - (if symbol (insert symbol) - (minibuffer-message "No symbol found")))) - -(defvar ack-minibuffer-local-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map minibuffer-local-map) - (define-key map "\t" 'completion-at-point) - (define-key map "\M-I" 'ack-skel-file) - (define-key map "\M-G" 'ack-skel-vc-grep) - (define-key map "\M-Y" 'ack-yank-symbol-at-point) - (define-key map "'" 'skeleton-pair-insert-maybe) - map) - "Keymap used for reading `ack' command and args in minibuffer.") - -(defun ack-guess-project-root (start-directory &optional regexp) - (let ((regexp (or regexp - (mapconcat 'identity ack-project-root-patterns "\\|"))) - (parent (file-name-directory - (directory-file-name (expand-file-name start-directory))))) - (if (directory-files start-directory nil regexp) - start-directory - (unless (equal parent start-directory) - (ack-guess-project-root parent regexp))))) - -(defun ack-default-directory (arg) - "A function for `ack-default-directory-function'. -With no \\[universal-argument], return `default-directory'; -With one \\[universal-argument], find the project root according to -`ack-project-root-patterns'; -Otherwise, interactively choose a directory." - (cond - ((not arg) default-directory) - ((= (prefix-numeric-value arg) 4) - (or (ack-guess-project-root default-directory) - (ack-default-directory '(16)))) - (t (read-directory-name "In directory: " nil nil t)))) - -(defun ack-update-minibuffer-prompt (&optional _beg _end _len) - (when (minibufferp) - (let ((inhibit-read-only t)) - (save-excursion - (goto-char (minibuffer-prompt-end)) - (when (looking-at "\\(\\w+\\)\\s-") - (put-text-property - (point-min) (minibuffer-prompt-end) - 'display - (format "Run %s in `%s': " - (match-string-no-properties 1) - (file-name-nondirectory - (directory-file-name ack--project-root))))))))) - -(defun ack-minibuffer-setup-function () - (shell-completion-vars) - (add-hook 'after-change-functions - #'ack-update-minibuffer-prompt nil t) - (ack-update-minibuffer-prompt) - (run-hooks 'ack-minibuffer-setup-hook)) - -;;;###autoload -(defun ack (command-args &optional directory) - "Run ack using COMMAND-ARGS and collect output in a buffer. -When called interactively, the value of DIRECTORY is provided by -`ack-default-directory-function'. - -The following keys are available while reading from the -minibuffer: - -\\{ack-minibuffer-local-map}" - (interactive - (let ((ack--project-root (or (funcall ack-default-directory-function - current-prefix-arg) - default-directory)) - ;; Disable completion cycling; see http://debbugs.gnu.org/12221 - (completion-cycle-threshold nil)) - (list (minibuffer-with-setup-hook 'ack-minibuffer-setup-function - (read-from-minibuffer "Ack: " - ack-command - ack-minibuffer-local-map - nil 'ack-history)) - ack--project-root))) - (let ((default-directory (expand-file-name - (or directory default-directory)))) - ;; Change to the compilation buffer so that `ack-buffer-name-function' can - ;; make use of `compilation-arguments'. - (with-current-buffer (compilation-start command-args 'ack-mode) - (when ack-buffer-name-function - (rename-buffer (funcall ack-buffer-name-function "ack")))))) - -(provide 'ack) -;;; ack.el ends here diff --git a/emacs.d/elpa/ack-1.2/ack.elc b/emacs.d/elpa/ack-1.2/ack.elc deleted file mode 100644 index 8644b26..0000000 Binary files a/emacs.d/elpa/ack-1.2/ack.elc and /dev/null differ diff --git a/emacs.d/elpa/ack-1.2/pcmpl-ack.el b/emacs.d/elpa/ack-1.2/pcmpl-ack.el deleted file mode 100644 index 3029367..0000000 --- a/emacs.d/elpa/ack-1.2/pcmpl-ack.el +++ /dev/null @@ -1,141 +0,0 @@ -;;; pcmpl-ack.el --- completion for ack -*- lexical-binding: t; -*- - -;; Copyright (C) 2012-2013 Free Software Foundation, Inc. - -;; Author: Leo Liu -;; Keywords: tools, processes, convenience -;; Created: 2012-09-26 -;; URL: https://github.com/leoliu/ack-el - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: - -;; Provide pcompletion support for the cli tool `ack' which can be -;; downloaded from http://beyondgrep.com. -;; -;; Install: -;; (autoload 'pcomplete/ack "pcmpl-ack") -;; -;; Usage: -;; - To complete short options type '-' first -;; - To complete long options type '--' first -;; - Color name completion is supported following -;; --color-filename=, --color-match= and --color-lineno= -;; - Type completion is supported following --type= - -;;; Code: - -(require 'pcomplete) - -(defcustom pcmpl-ack-program - (file-name-nondirectory (or (executable-find "ack-grep") - (executable-find "ack") - "ack")) - "Name of the ack program." - :type 'file - :group 'pcomplete) - -(defvar pcmpl-ack-color-options - '("clear" - "reset" - "dark" - "bold" - "underline" - "underscore" - "blink" - "reverse" - "concealed" - "black" - "red" - "green" - "yellow" - "blue" - "magenta" - "on_black" - "on_red" - "on_green" - "on_yellow" - "on_blue" - "on_magenta" - "on_cyan" - "on_white") - "Color names for the `ack' command.") - -(defun pcmpl-ack-run (buffer &rest args) - "Run ack with ARGS and send the output to BUFFER." - (condition-case nil - (apply 'call-process (or pcmpl-ack-program "ack") nil buffer nil args) - (file-error -1))) - -(defun pcmpl-ack-short-options () - "Short options for the `ack' command." - (with-temp-buffer - (let (options) - (when (zerop (pcmpl-ack-run t "--help")) - (goto-char (point-min)) - (while (re-search-forward "^ -\\([^-]\\)" nil t) - (push (match-string 1) options)) - (mapconcat 'identity (nreverse options) ""))))) - -(defun pcmpl-ack-long-options (&optional arg) - "Long options for the `ack' command." - (with-temp-buffer - (let (options) - (when (zerop (pcmpl-ack-run t (or arg "--help"))) - (goto-char (point-min)) - (while (re-search-forward - "\\(?: ?\\|, \\)\\(--\\(\\[no\\]\\)?\\([[:alnum:]-]+=?\\)\\)" - nil t) - (if (not (match-string 2)) - (push (match-string 1) options) - (push (concat "--" (match-string 3)) options) - (push (concat "--no" (match-string 3)) options))) - (nreverse options))))) - -(defun pcmpl-ack-type-options () - "A list of types for the `ack' command." - (pcmpl-ack-long-options "--help-types")) - -;;;###autoload -(defun pcomplete/ack () - "Completion for the `ack' command. -Start an argument with '-' to complete short options and '--' for -long options." - ;; No space after = - (while t - (if (pcomplete-match "^-" 0) - (cond - ((pcomplete-match "^--color-\\w+=\\(\\S-*\\)" 0) - (pcomplete-here* pcmpl-ack-color-options - (pcomplete-match-string 1 0) t)) - ((pcomplete-match "^--\\(?:no\\)?ignore-dir=\\(\\S-*\\)" 0) - (pcomplete-here* (pcomplete-dirs) - (pcomplete-match-string 1 0) t)) - ((pcomplete-match "^--type=\\(\\S-*\\)" 0) - (pcomplete-here* (mapcar (lambda (type-option) - (substring type-option 2)) - (pcmpl-ack-type-options)) - (pcomplete-match-string 1 0) t)) - ((pcomplete-match "^--" 0) - (pcomplete-here* (append (pcmpl-ack-long-options) - (pcmpl-ack-type-options)))) - (t (pcomplete-opt (pcmpl-ack-short-options)))) - (pcomplete-here* (pcomplete-dirs-or-entries))))) - -;;;###autoload -(defalias 'pcomplete/ack-grep 'pcomplete/ack) - -(provide 'pcmpl-ack) -;;; pcmpl-ack.el ends here diff --git a/emacs.d/elpa/ack-1.2/pcmpl-ack.elc b/emacs.d/elpa/ack-1.2/pcmpl-ack.elc deleted file mode 100644 index e3b3834..0000000 Binary files a/emacs.d/elpa/ack-1.2/pcmpl-ack.elc and /dev/null differ diff --git a/emacs.d/elpa/elpy-1.2.1/LICENSE b/emacs.d/elpa/elpy-1.2.1/LICENSE deleted file mode 100644 index 94a9ed0..0000000 --- a/emacs.d/elpa/elpy-1.2.1/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/emacs.d/elpa/elpy-1.2.1/README b/emacs.d/elpa/elpy-1.2.1/README deleted file mode 100644 index 656cb2c..0000000 --- a/emacs.d/elpa/elpy-1.2.1/README +++ /dev/null @@ -1,57 +0,0 @@ -======================================= -Elpy, the Emacs Lisp Python Environment -======================================= - -Elpy is an Emacs package to bring powerful Python editing to Emacs. It -combines a number of other packages, both written in Emacs Lisp as -well as Python. - -.. image:: https://secure.travis-ci.org/jorgenschaefer/elpy.png - :alt: Build Status - :target: http://travis-ci.org/jorgenschaefer/elpy - :width: 77px - :height: 19px - -Documentation -============= - -You can find the documentation `on the wiki`__. - -.. __: https://github.com/jorgenschaefer/elpy/wiki - -Quick Installation -================== - -You can also read the `detailed installation instructions`__. - -.. __: https://github.com/jorgenschaefer/elpy/wiki/Installation - -First, install the required Python packages::: - - pip install elpy rope - -(Note: If you are installing the development version of elpy, do not -install the elpy Python package, but simply put the repository in your -``PYTHONPATH``.) - -Evaluate this in your ``*scratch*`` buffer: - -.. code-block:: lisp - - (require 'package) - (add-to-list 'package-archives - '("marmalade" . "http://marmalade-repo.org/packages/")) - - -Then run ``M-x package-refresh-contents`` to load the contents of the -new repository, and ``M-x package-install RET elpy RET`` to install -elpy. - -Finally, add the following to your ``.emacs``: - -.. code-block:: lisp - - (package-initialize) - (elpy-enable) - -Done. diff --git a/emacs.d/elpa/elpy-1.2.1/elpy-autoloads.el b/emacs.d/elpa/elpy-1.2.1/elpy-autoloads.el deleted file mode 100644 index 57f6e05..0000000 --- a/emacs.d/elpa/elpy-1.2.1/elpy-autoloads.el +++ /dev/null @@ -1,54 +0,0 @@ -;;; elpy-autoloads.el --- automatically extracted autoloads -;; -;;; Code: - - -;;;### (autoloads (elpy-mode elpy-disable elpy-enable) "elpy" "elpy.el" -;;;;;; (21139 23652 0 0)) -;;; Generated autoloads from elpy.el - -(autoload 'elpy-enable "elpy" "\ -Enable Elpy in all future Python buffers. - -When SKIP-INITIALIZE-VARIABLES is non-nil, this will NOT call -`elpy-initialize-variables' to configure various modes in a way -that the Elpy author considers sensible. If you'd rather -configure those modes yourself, pass t here. - -\(fn &optional SKIP-INITIALIZE-VARIABLES)" t nil) - -(autoload 'elpy-disable "elpy" "\ -Disable Elpy in all future Python buffers. - -\(fn)" t nil) - -(autoload 'elpy-mode "elpy" "\ -Minor mode in Python buffers for the Emacs Lisp Python Environment. - -This mode fully supports virtualenvs. Once you switch a -virtualenv using \\[virtualenv-workon], you can use -\\[elpy-rpc-restart] to make the elpy Python process use your -virtualenv. - -See https://github.com/jorgenschaefer/elpy/wiki/Keybindings for a -more structured list. - -\\{elpy-mode-map} - -\(fn &optional ARG)" t nil) - -;;;*** - -;;;### (autoloads nil nil ("elpy-pkg.el" "elpy-refactor.el") (21139 -;;;;;; 23652 758883 0)) - -;;;*** - -(provide 'elpy-autoloads) -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; coding: utf-8 -;; End: -;;; elpy-autoloads.el ends here diff --git a/emacs.d/elpa/elpy-1.2.1/elpy-pkg.el b/emacs.d/elpa/elpy-1.2.1/elpy-pkg.el deleted file mode 100644 index 3aa8c12..0000000 --- a/emacs.d/elpa/elpy-1.2.1/elpy-pkg.el +++ /dev/null @@ -1,12 +0,0 @@ -(define-package "elpy" "1.2.1" - "Emacs Python Development Environment" - '((auto-complete "1.4") - (find-file-in-project "3.2") - (fuzzy "0.1") ;; For auto-complete - (highlight-indentation "0.5.0") - (idomenu "0.1") - (iedit "0.97") - (nose "0.1.1") - (virtualenv "1.2") - (yasnippet "0.8.0")) - ) diff --git a/emacs.d/elpa/elpy-1.2.1/elpy-pkg.elc b/emacs.d/elpa/elpy-1.2.1/elpy-pkg.elc deleted file mode 100644 index c377d77..0000000 Binary files a/emacs.d/elpa/elpy-1.2.1/elpy-pkg.elc and /dev/null differ diff --git a/emacs.d/elpa/elpy-1.2.1/elpy-refactor.el b/emacs.d/elpa/elpy-1.2.1/elpy-refactor.el deleted file mode 100644 index 27f9842..0000000 --- a/emacs.d/elpa/elpy-1.2.1/elpy-refactor.el +++ /dev/null @@ -1,284 +0,0 @@ -;;; elpy-refactor.el --- Refactoring mode for Elpy - -;; Copyright (C) 2013 Jorgen Schaefer - -;; Author: Jorgen Schaefer -;; URL: https://github.com/jorgenschaefer/elpy - -;; This program is free software; you can redistribute it and/or -;; modify it under the terms of the GNU General Public License -;; as published by the Free Software Foundation; either version 3 -;; of the License, or (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: - -;; This file provides an interface, including a major mode, to use -;; refactoring options provided by the Rope library. - -;;; Code: - -;; We require elpy, but elpy loads us, so we shouldn't load it back. -;; (require 'elpy) - -(defvar elpy-refactor-changes nil - "Changes that will be commited on \\[elpy-refactor-commit].") -(make-variable-buffer-local 'elpy-refactor-current-changes) - -(defvar elpy-refactor-window-configuration nil - "The old window configuration. Will be restored after commit.") -(make-variable-buffer-local 'elpy-refactor-window-configuration) - -(defun elpy-refactor () - "Run the Elpy refactoring interface for Python code." - (interactive) - (save-some-buffers) - (let* ((selection (elpy-refactor-select - (elpy-refactor-rpc-get-options))) - (method (car selection)) - (args (cdr selection))) - (when method - (elpy-refactor-create-change-buffer - (elpy-refactor-rpc-get-changes method args))))) - -(defun elpy-refactor-select (options) - "Show the user the refactoring options and let her choose one. - -Depending on the chosen option, ask the user for further -arguments and build the argument. - -Return a cons cell of the name of the option and the arg list -created." - (let ((buf (get-buffer-create "*Elpy Refactor*")) - (pos (vector (1- (point)) - (ignore-errors - (1- (region-beginning))) - (ignore-errors - (1- (region-end))))) - (inhibit-read-only t) - (options (sort options - (lambda (a b) - (let ((cata (cdr (assq 'category a))) - (catb (cdr (assq 'category b)))) - (if (equal cata catb) - (string< (cdr (assq 'description a)) - (cdr (assq 'description b))) - (string< cata catb)))))) - (key ?a) - last-category - option-alist) - (with-current-buffer buf - (erase-buffer) - (dolist (option options) - (let ((category (cdr (assq 'category option))) - (description (cdr (assq 'description option))) - (name (cdr (assq 'name option))) - (args (cdr (assq 'args option)))) - (when (not (equal category last-category)) - (when last-category - (insert "\n")) - (insert (propertize category 'face 'bold) "\n") - (setq last-category category)) - (insert " (" key ") " description "\n") - (setq option-alist (cons (list key name args) - option-alist)) - (setq key (1+ key)))) - (let ((window-conf (current-window-configuration))) - (unwind-protect - (progn - (with-selected-window (display-buffer buf) - (goto-char (point-min))) - (fit-window-to-buffer (get-buffer-window buf)) - (let* ((key (read-key "Refactoring action? ")) - (entry (cdr (assoc key option-alist)))) - (kill-buffer buf) - (cons (car entry) ; name - (elpy-refactor-build-arguments (cadr entry) - pos)))) - (set-window-configuration window-conf)))))) - -(defun elpy-refactor-build-arguments (args pos) - "Translate an argument list specification to an argument list. - -POS is a vector of three elements, the current offset, the offset -of the beginning of the region, and the offset of the end of the -region. - -ARGS is a list of triples, each triple containing the name of an -argument (ignored), the type of the argument, and a possible -prompt string. - -Available types: - - offset - The offset in the buffer, (1- (point)) - start_offset - Offset of the beginning of the region - end_offset - Offset of the end of the region - string - A free-form string - filename - A non-existing file name - directory - An existing directory name - boolean - A boolean question" - (mapcar (lambda (arg) - (let ((type (cadr arg)) - (prompt (caddr arg))) - (cond - ((equal type "offset") - (aref pos 0)) - ((equal type "start_offset") - (aref pos 1)) - ((equal type "end_offset") - (aref pos 2)) - ((equal type "string") - (read-from-minibuffer prompt)) - ((equal type "filename") - (expand-file-name - (read-file-name prompt))) - ((equal type "directory") - (expand-file-name - (read-directory-name prompt))) - ((equal type "boolean") - (y-or-n-p prompt))))) - args)) - -(defun elpy-refactor-create-change-buffer (changes) - "Show the user a buffer of changes. - -The user can review the changes and confirm them with -\\[elpy-refactor-commit]." - (when (not changes) - (error "No changes for this refactoring action.")) - (with-current-buffer (get-buffer-create "*Elpy Refactor*") - (elpy-refactor-mode) - (setq elpy-refactor-changes changes - elpy-refactor-window-configuration (current-window-configuration)) - (let ((inhibit-read-only t)) - (erase-buffer) - (elpy-refactor-insert-changes changes)) - (select-window (display-buffer (current-buffer))) - (goto-char (point-min)))) - -(defun elpy-refactor-insert-changes (changes) - "Format and display the changes described in CHANGES." - (insert (propertize "Use C-c C-c to apply the following changes." - 'face 'bold) - "\n\n") - (dolist (change changes) - (let ((action (cdr (assq 'action change)))) - (cond - ((equal action "change") - (insert (cdr (assq 'diff change)) - "\n")) - ((equal action "create") - (let ((type (cdr (assq 'type change)))) - (if (equal type "file") - (insert "+++ " (cdr (assq 'file change)) "\n" - "Create file " (cdr (assq 'file change)) "\n" - "\n") - (insert "+++ " (cdr (assq 'path change)) "\n" - "Create directory " (cdr (assq 'path change)) "\n" - "\n")))) - ((equal action "move") - (insert "--- " (cdr (assq 'source change)) "\n" - "+++ " (cdr (assq 'destination change)) "\n" - "Rename " (cdr (assq 'type change)) "\n" - "\n")) - ((equal action "delete") - (let ((type (cdr (assq 'type change)))) - (if (equal type "file") - (insert "--- " (cdr (assq 'file change)) "\n" - "Delete file " (cdr (assq 'file change)) "\n" - "\n") - (insert "--- " (cdr (assq 'path change)) "\n" - "Delete directory " (cdr (assq 'path change)) "\n" - "\n")))))))) - -(defvar elpy-refactor-mode-map - (let ((map (make-sparse-keymap))) - (define-key map (kbd "C-c C-c") 'elpy-refactor-commit) - (define-key map (kbd "q") 'bury-buffer) - (define-key map (kbd "h") 'describe-mode) - (define-key map (kbd "?") 'describe-mode) - map) - "The key map for `elpy-refactor-mode'.") - -(define-derived-mode elpy-refactor-mode diff-mode "Elpy Refactor" - "Mode to display refactoring actions and ask confirmation from the user. - -\\{elpy-refactor-mode-map}" - :group 'elpy - (view-mode 1)) - -(defun elpy-refactor-commit () - "Commit the changes in the current buffer." - (interactive) - (when (not elpy-refactor-changes) - (error "No changes to commit.")) - ;; Restore the window configuration as the first thing so that - ;; changes below are visible to the user. Especially the point - ;; change in possible buffer changes. - (set-window-configuration elpy-refactor-window-configuration) - (dolist (change elpy-refactor-changes) - (let ((action (cdr (assq 'action change)))) - (cond - ((equal action "change") - (with-current-buffer (find-file-noselect (cdr (assq 'file change))) - ;; This would break for save-excursion as the buffer is - ;; truncated, so all markets now point to position 1. - (let ((old-point (point))) - (undo-boundary) - (erase-buffer) - (insert (cdr (assq 'contents change))) - (undo-boundary) - (goto-char old-point)))) - ((equal action "create") - (if (equal (cdr (assq 'type change)) - "file") - (find-file-noselect (cdr (assq 'file change))) - (make-directory (cdr (assq 'path change))))) - ((equal action "move") - (let* ((source (cdr (assq 'source change))) - (dest (cdr (assq 'destination change))) - (buf (get-file-buffer source))) - (when buf - (with-current-buffer buf - (setq buffer-file-name dest) - (rename-buffer (file-name-nondirectory dest) t))) - (rename-file source dest))) - ((equal action "delete") - (if (equal (cdr (assq 'type change)) "file") - (let ((name (cdr (assq 'file change)))) - (when (y-or-n-p (format "Really delete %s? " name)) - (delete-file name t))) - (let ((name (cdr (assq 'directory change)))) - (when (y-or-n-p (format "Really delete %s? " name)) - (delete-directory name nil t)))))))) - (kill-buffer (current-buffer))) - -(defun elpy-refactor-rpc-get-options () - "Get a list of refactoring options from the Elpy RPC." - (if (use-region-p) - (elpy-rpc "get_refactor_options" - (list (elpy-project-root) - (buffer-file-name) - (1- (region-beginning)) - (1- (region-end)))) - (elpy-rpc "get_refactor_options" - (list (elpy-project-root) - (buffer-file-name) - (1- (point)))))) - -(defun elpy-refactor-rpc-get-changes (method args) - "Get a list of changes from the Elpy RPC after applying METHOD with ARGS." - (elpy-rpc "refactor" - (list (elpy-project-root) - (buffer-file-name) - method args))) - -(provide 'elpy-refactor) -;;; elpy-refactor.el ends here diff --git a/emacs.d/elpa/elpy-1.2.1/elpy-refactor.elc b/emacs.d/elpa/elpy-1.2.1/elpy-refactor.elc deleted file mode 100644 index 28b1176..0000000 Binary files a/emacs.d/elpa/elpy-1.2.1/elpy-refactor.elc and /dev/null differ diff --git a/emacs.d/elpa/elpy-1.2.1/elpy.el b/emacs.d/elpa/elpy-1.2.1/elpy.el deleted file mode 100644 index ca17843..0000000 --- a/emacs.d/elpa/elpy-1.2.1/elpy.el +++ /dev/null @@ -1,1601 +0,0 @@ -;;; elpy.el --- Emacs Lisp Python Environment -*- lexical-binding: t -*- - -;; Copyright (C) 2012, 2013 Jorgen Schaefer - -;; Author: Jorgen Schaefer -;; URL: https://github.com/jorgenschaefer/elpy -;; Version: 1.2.1 - -;; This program is free software; you can redistribute it and/or -;; modify it under the terms of the GNU General Public License -;; as published by the Free Software Foundation; either version 3 -;; of the License, or (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: - -;; The Emacs Lisp Python Environment in Emacs - -;; Elpy is an Emacs package to bring powerful Python editing to Emacs. -;; It combines a number of existing Emacs packages, and uses one of a -;; selection of Python packages for code introspection. - -;; To use, you need to install not only this package, but a few Python -;; packages as well. See the installation instructions on the wiki. - -;; Documentation is available there as well. - -;; https://github.com/jorgenschaefer/elpy/wiki - -;;; Code: - -(require 'auto-complete-config) -(require 'elpy-refactor) -(require 'etags) -(require 'find-file-in-project) -(require 'flymake) -(require 'highlight-indentation) -(require 'idomenu) -(require 'json) -(require 'nose) -(require 'python) -(require 'grep) -(require 'thingatpt) -(require 'virtualenv) -(require 'yasnippet) - - -;;;;;;;;;;;;;;; -;;; Elpy itself - -(defgroup elpy nil - "The Emacs Lisp Python Environment." - :prefix "elpy-" - :group 'languages) - -(defcustom elpy-rpc-python-command "python" - "The command to be used for the RPC backend." - :type 'string - :group 'elpy) - -(defcustom elpy-rpc-project-specific nil - "Whether Elpy should use a separate process for each project." - :type 'boolean - :group 'elpy) - -(defcustom elpy-rpc-backend nil - "Your preferred backend. - -Either nil, or a string. - -nil - Select a backend automatically. -rope - Use the Rope refactoring library. This will create - .ropeproject directories in your project roots. -jedi - Use the Jedi completion library. -native - Do not use any backend, use native Python methods only." - :type '(choice (const "rope") - (const "jedi") - (const "native") - (const nil)) - :group 'elpy) - -(defcustom elpy-default-minor-modes '(eldoc-mode - flymake-mode - highlight-indentation-mode - yas-minor-mode - auto-complete-mode) - "Minor modes enabled when `elpy-mode' is enabled." - :group 'elpy) - -(defcustom elpy-rgrep-ignored-directories '(".tox" "build" "dist") - "Directories ignored by `elpy-rgrep-symbol'. - -These are prepended to `grep-find-ignored-directories'." - :group 'elpy) - -(defcustom elpy-mode-hook nil - "Hook run when `elpy-mode' is enabled." - :group 'elpy) - -(defconst elpy-version "1.2.1" - "The version of the Elpy lisp code.") - -(defun elpy-version () - "Echo the version of Elpy." - (interactive) - (let ((version elpy-version) - (rpc-version (when elpy-rpc--buffer - (or (ignore-errors - (elpy-rpc "version" nil)) - "1.1")))) - (if (equal version "devel") - (setq version "development version") - (setq version (format "version %s" version))) - (when rpc-version - (if (equal rpc-version "devel") - (setq rpc-version "development version") - (setq rpc-version (format "version %s" rpc-version)))) - (if rpc-version - (message "Elpy %s using the Python backend %s" - version rpc-version) - (message "Elpy %s" version)))) - -(defvar elpy-mode-map - (let ((map (make-sparse-keymap))) - ;; Alphabetical order to make it easier to find free C-c C-X - ;; bindings in the future. Heh. - - ;; (define-key map (kbd "") 'python-indent-dedent-line-backspace) - ;; (define-key map (kbd "") 'python-indent-dedent-line) - ;; (define-key map (kbd "") 'ac-trigger-key) - - ;; (define-key map (kbd "C-M-x") 'python-shell-send-defun) - ;; (define-key map (kbd "C-c <") 'python-indent-shift-left) - ;; (define-key map (kbd "C-c >") 'python-indent-shift-right) - (define-key map (kbd "C-c C-c") 'elpy-shell-send-region-or-buffer) - (define-key map (kbd "C-c C-z") 'elpy-shell-switch-to-shell) - (define-key map (kbd "C-c C-d") 'elpy-doc) - (define-key map (kbd "C-c C-f") 'find-file-in-project) - ;; (define-key map (kbd "C-c C-i") 'yasnippet-expand) - (define-key map (kbd "C-c C-j") 'idomenu) - (define-key map (kbd "C-c C-n") 'elpy-flymake-forward-error) - (define-key map (kbd "C-c C-o") 'elpy-occur-definitions) - (define-key map (kbd "C-c C-p") 'elpy-flymake-backward-error) - (define-key map (kbd "C-c C-q") 'elpy-show-defun) - (define-key map (kbd "C-c C-r") 'elpy-refactor) - (define-key map (kbd "C-c C-s") 'elpy-rgrep-symbol) - (define-key map (kbd "C-c C-t") 'elpy-test) - (define-key map (kbd "C-c C-v") 'elpy-check) - (define-key map (kbd "C-c C-w") 'elpy-doc-websearch) - ;; (define-key map (kbd "C-c C-z") 'python-shell-switch-to-shell) - - (define-key map (kbd "") 'elpy-nav-forward-definition) - (define-key map (kbd "") 'elpy-nav-backward-definition) - ;; (define-key map (kbd "M-,") 'iedit-mode - (define-key map (kbd "M-.") 'elpy-goto-definition) - (define-key map (kbd "M-a") 'elpy-nav-backward-statement) - (define-key map (kbd "M-e") 'elpy-nav-forward-statement) - (define-key map (kbd "M-n") 'elpy-nav-forward-definition) - (define-key map (kbd "M-p") 'elpy-nav-backward-definition) - - map) - "Key map for the Emacs Lisp Python Environment.") - -;;;###autoload -(defun elpy-enable (&optional skip-initialize-variables) - "Enable Elpy in all future Python buffers. - -When SKIP-INITIALIZE-VARIABLES is non-nil, this will NOT call -`elpy-initialize-variables' to configure various modes in a way -that the Elpy author considers sensible. If you'd rather -configure those modes yourself, pass t here." - (interactive) - (when (< emacs-major-version 24) - (error "Elpy requires Emacs 24 or newer")) - (let ((filename (find-lisp-object-file-name 'python-mode - 'symbol-function))) - (when (and filename - (string-match "/python-mode\\.el\\'" - filename)) - (error (concat "You are using python-mode.el. " - "Elpy only works with python.el from " - "Emacs 24 and above")))) - (add-hook 'python-mode-hook 'elpy-mode) - (when (not skip-initialize-variables) - (elpy-initialize-variables))) - -;;;###autoload -(defun elpy-disable () - "Disable Elpy in all future Python buffers." - (interactive) - (remove-hook 'python-mode-hook 'elpy-mode)) - -;;;###autoload -(define-minor-mode elpy-mode - "Minor mode in Python buffers for the Emacs Lisp Python Environment. - -This mode fully supports virtualenvs. Once you switch a -virtualenv using \\[virtualenv-workon], you can use -\\[elpy-rpc-restart] to make the elpy Python process use your -virtualenv. - -See https://github.com/jorgenschaefer/elpy/wiki/Keybindings for a -more structured list. - -\\{elpy-mode-map}" - :lighter " Elpy" - (when (not (eq major-mode 'python-mode)) - (error "Elpy only works with `python-mode'")) - (cond - (elpy-mode - (when buffer-file-name - (set (make-local-variable 'ffip-project-root) (elpy-project-root))) - (set (make-local-variable 'eldoc-documentation-function) - 'elpy-eldoc-documentation) - (add-to-list 'ac-sources 'ac-source-elpy) - (add-to-list 'ac-sources 'ac-source-elpy-dot) - ;; Enable modes, hence the 1. - (run-hook-with-args 'elpy-default-minor-modes 1)) - (t - (kill-local-variable 'ffip-project-root) - (kill-local-variable 'eldoc-documentation-function) - (setq ac-sources - (delq 'ac-source-elpy - (delq 'ac-source-elpy-dot - ac-sources)))))) - -(defun elpy-installation-instructions (message &optional show-elpy-module) - "Display a window with installation instructions for the Python -side of elpy. - -MESSAGE is shown as the first paragraph. - -If SHOW-ELPY-MODULE is non-nil, the help buffer will first -explain how to install the elpy module." - (with-help-window "*Elpy Installation*" - (with-current-buffer "*Elpy Installation*" - (let ((inhibit-read-only t)) - (erase-buffer) - (insert "Elpy Installation Instructions\n") - (insert "\n") - (insert message) - (when (not (bolp)) - (insert "\n")) - (insert "\n") - (when show-elpy-module - (insert "Elpy requires the Python module \"elpy\". The module " - "is available from pypi, so you can install it using " - "the following command:\n") - (insert "\n") - (elpy-installation-command "elpy") - (insert "\n")) - (insert "To find possible completions, Elpy uses one of two " - "Python modules. Either \"rope\" or \"jedi\". To use " - "Elpy to its fullest potential, you should install " - "either one of them. Which one is a matter of taste. " - "You can try both and even switch at runtime using " - "M-x elpy-set-backend.\n") - (insert "\n") - (insert "Elpy also uses the Rope module for refactoring options, " - "so you likely want to install it even if you use jedi " - "for completion.\n") - (insert "\n") - (if (string-match "Python 3" (shell-command-to-string - "python --version")) - (elpy-installation-command "rope_py3k") - (elpy-installation-command "rope")) - (insert "\n") - (elpy-installation-command "jedi") - (insert "\n") - (insert "If you are using virtualenvs, you can use the " - "M-x virtualenv-workon command to switch to a virtualenv " - "of your choice. Afterwards, running the command " - "M-x elpy-rpc-restart will use the packages in " - "that virtualenv.") - (fill-region (point-min) (point-max)))))) - -(defun elpy-installation-command (python-module) - "Insert an installation command description for PYTHON-MODULE." - (let* ((do-user-install (not (or (getenv "VIRTUAL_ENV") - virtualenv-workon-session))) - (user-option (if do-user-install - "--user " - "")) - (command (cond - ((executable-find "pip") - (format "pip install %s%s" user-option python-module)) - ((executable-find "easy_install") - (format "easy_install %s%s" user-option python-module)) - (t - nil)))) - (if (not command) - (insert "... hm. It appears you have neither pip nor easy_install " - "available. You might want to get the python-pip or " - "or python-setuptools package.\n") - (insert-text-button "[run]" - 'action (lambda (button) - (async-shell-command - (button-get button 'command))) - 'command command) - (insert " " command "\n")))) - -(defun elpy-initialize-variables () - "This sets some variables in other modes we like to set. - -If you want to configure your own keys, do so after this function -is called (usually from `elpy-enable'), or override this function -using (defalias 'elpy-initialize-variables 'identity)" - ;; Local variables in `python-mode'. This is not removed when Elpy - ;; is disabled, which can cause some confusion. - (add-hook 'python-mode-hook 'elpy-initialize-local-variables) - - ;; Flymake support using flake8, including warning faces. - (when (or (executable-find "flake8") - (not (executable-find python-check-command))) - (setq python-check-command "flake8")) - - ;; `flymake-no-changes-timeout': The original value of 0.5 is too - ;; short for Python code, as that will result in the current line to - ;; be highlighted most of the time, and that's annoying. This value - ;; might be on the long side, but at least it does not, in general, - ;; interfere with normal interaction. - (setq flymake-no-changes-timeout 60) - - ;; `flymake-start-syntax-check-on-newline': This should be nil for - ;; Python, as;; most lines with a colon at the end will mean the next - ;; line is always highlighted as error, which is not helpful and - ;; mostly annoying. - (setq flymake-start-syntax-check-on-newline nil) - - ;; `ac-trigger-key': TAB is a great trigger key. We also need to - ;; tell auto-complete about the new trigger key. This is a bad - ;; interface to set the trigger key. Don't do this. Just let the - ;; user set the key in the keymap. Stop second-guessing the user, or - ;; Emacs. - (setq ac-trigger-key "TAB") - (when (fboundp 'ac-set-trigger-key) - (ac-set-trigger-key ac-trigger-key)) - - ;; `ac-auto-show-menu': Short timeout because the menu is great. - (setq ac-auto-show-menu 0.4) - - ;; `ac-quick-help-delay': I'd like to show the menu right with the - ;; completions, but this value should be greater than - ;; `ac-auto-show-menu' to show help for the first entry as well. - (setq ac-quick-help-delay 0.5) - - ;; Fix some key bindings in ac completions. Using RET when a - ;; completion is offered is not usually intended to complete (use - ;; TAB for that), but done while typing and the inputer is considere - ;; complete, with the intent to simply leave it as is and go to the - ;; next line. Much like space will not complete, but leave it as is - ;; and insert a space. - (define-key ac-completing-map (kbd "RET") nil) - (define-key ac-completing-map (kbd "") nil) - - ;; `yas-trigger-key': TAB, as is the default, conflicts with the - ;; autocompletion. We also need to tell yasnippet about the new - ;; binding. This is a bad interface to set the trigger key. Stop - ;; doing this. - (let ((old (when (boundp 'yas-trigger-key) - yas-trigger-key))) - (setq yas-trigger-key "C-c C-i") - (when (fboundp 'yas--trigger-key-reload) - (yas--trigger-key-reload old))) - - ;; We provide some YASnippet snippets. Add them. - (add-to-list - 'yas-snippet-dirs - (concat (file-name-directory (locate-library "elpy")) "snippets/") - t) - - ;; Now load yasnippets. - (yas-reload-all)) - -(defun elpy-initialize-local-variables () - "Initialize local variables in python-mode. - -This should be run from `python-mode-hook'." - ;; Set `forward-sexp-function' to nil in python-mode. See - ;; http://debbugs.gnu.org/db/13/13642.html - (setq forward-sexp-function nil) - ;; Enable warning faces for flake8 output. - (when (string-match "flake8" python-check-command) - ;; COMPAT: Obsolete variable as of 24.4 - (if (boundp 'flymake-warning-predicate) - (set (make-local-variable 'flymake-warning-predicate) "^W[0-9]") - (set (make-local-variable 'flymake-warning-re) "^W[0-9]")))) - -(defvar elpy-project-root nil - "The root of the project the current buffer is in.") -(make-variable-buffer-local 'elpy-project-root) -(put 'elpy-project-root 'safe-local-variable 'file-directory-p) - -(defun elpy-project-root () - "Return the root of the current buffer's project. - -You can set the variable `elpy-project-root' in, for example, -.dir-locals.el to configure this." - (when (not elpy-project-root) - (setq elpy-project-root (elpy-project--find-root)) - (when (equal (directory-file-name (expand-file-name default-directory)) - (directory-file-name (expand-file-name "~"))) - (display-warning 'elpy - (concat "Project root set to your home directory; " - "this can slow down operation considerably") - :warning))) - elpy-project-root) - -(defun elpy-project--find-root () - "Find the first directory in the tree not containing an __init__.py - -If there is no __init__.py in the current directory, return the -current directory." - (if (file-exists-p (format "%s/__init__.py" default-directory)) - (locate-dominating-file default-directory - (lambda (dir) - (not (file-exists-p - (format "%s/__init__.py" dir))))) - default-directory)) - -(defun elpy-set-project-root (new-root) - "Set the Elpy project root to NEW-ROOT." - (interactive "DNew project root: ") - (setq elpy-project-root new-root)) - -(defun elpy-use-ipython (&optional ipython) - "Set defaults to use IPython instead of the standard interpreter. - -With prefix arg, prompt for the command to use." - (interactive (list (when current-prefix-arg - (read-file-name "IPython command: ")))) - (when (not ipython) - (setq ipython "ipython")) - (if (boundp 'python-python-command) - ;; Emacs 24 until 24.3 - (setq python-python-command ipython) - ;; Emacs 24.3 and onwards. - - ;; This is from the python.el commentary. - ;; Settings for IPython 0.11: - (setq python-shell-interpreter ipython - python-shell-interpreter-args "" - python-shell-prompt-regexp "In \\[[0-9]+\\]: " - python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: " - python-shell-completion-setup-code - "from IPython.core.completerlib import module_completion" - python-shell-completion-module-string-code - "';'.join(module_completion('''%s'''))\n" - python-shell-completion-string-code - "';'.join(get_ipython().Completer.all_completions('''%s'''))\n"))) - -(defun elpy-use-cpython (&optional cpython) - "Set defaults to use the standard interpreter instead of IPython. - -With prefix arg, prompt for the command to use." - (interactive (list (when current-prefix-arg - (read-file-name "Python command: ")))) - (when (not cpython) - (setq cpython "python")) - (if (boundp 'python-python-command) - ;; Emacs 24 until 24.3 - (setq python-python-command cpython) - ;; Emacs 24.3 and onwards. - (setq python-shell-interpreter cpython - python-shell-interpreter-args "-i" - python-shell-prompt-regexp ">>> " - python-shell-prompt-output-regexp "" - python-shell-completion-setup-code -"try: - import readline -except ImportError: - def __COMPLETER_all_completions(text): [] -else: - import rlcompleter - readline.set_completer(rlcompleter.Completer().complete) - def __COMPLETER_all_completions(text): - import sys - completions = [] - try: - i = 0 - while True: - res = readline.get_completer()(text, i) - if not res: break - i += 1 - completions.append(res) - except NameError: - pass - return completions" - python-shell-completion-module-string-code "" - python-shell-completion-string-code - "';'.join(__COMPLETER_all_completions('''%s'''))\n"))) - -(defun elpy-clean-modeline () - "Clean up the mode line by removing some lighters. - -It's not necessary to see (Python Elpy yas AC ElDoc) all the -time. Honestly." - (interactive) - (setq eldoc-minor-mode-string nil) - (dolist (mode '(elpy-mode yas-minor-mode auto-complete-mode - flymake-mode)) - (setcdr (assq mode minor-mode-alist) - (list "")))) - -(defun elpy-shell-send-region-or-buffer (&optional arg) - "Send the active region or the buffer to the Python shell. - -If there is an active region, send that. Otherwise, send the -whole buffer. - -Without prefix argument, this will escape the Python idiom of -if __name__ == '__main__' to be false to avoid accidental -execution of code. With prefix argument, this code is executed." - (interactive "P") - ;; Ensure process exists - (elpy-shell-get-or-create-process) - (if (region-active-p) - (python-shell-send-string (elpy--region-without-indentation - (region-beginning) (region-end)) - nil t) - (python-shell-send-buffer arg)) - (elpy-shell-switch-to-shell)) - -(defun elpy--region-without-indentation (beg end) - "Return the current region as a string, but without indentation." - (let ((region (buffer-substring beg end)) - (indent-level nil)) - (catch 'return - (with-temp-buffer - (insert region) - (goto-char (point-min)) - (while (< (point) (point-max)) - (cond - ((and (not indent-level) - (not (looking-at "[ \t]*$"))) - (setq indent-level (current-indentation))) - ((and indent-level - (not (looking-at "[ \t]*$")) - (< (current-indentation) - indent-level)) - (error "Can't adjust indentation, consecutive lines indented less than starting line"))) - (forward-line)) - (indent-rigidly (point-min) - (point-max) - (- indent-level)) - (buffer-string))))) - -(defun elpy-shell-switch-to-shell () - "Switch to inferior Python process buffer." - (interactive) - (pop-to-buffer (process-buffer (elpy-shell-get-or-create-process)) t)) - -(defun elpy-shell-get-or-create-process () - "Get or create an inferior Python process for current buffer and return it." - (let* ((bufname (format "*%s*" (python-shell-get-process-name nil))) - (proc (get-buffer-process bufname))) - (if proc - proc - (run-python (python-shell-parse-command)) - (get-buffer-process bufname)))) - -(defun elpy-check (&optional whole-project-p) - "Run `python-check-command' on the current buffer's file, - -or the project root if WHOLE-PROJECT-P is non-nil (interactively, -with a prefix argument)." - (interactive "P") - (when (not (buffer-file-name)) - (error "Can't check a buffer without a file.")) - (save-some-buffers (not compilation-ask-about-save) nil) - (let ((process-environment (python-shell-calculate-process-environment)) - (exec-path (python-shell-calculate-exec-path)) - (file-name-or-directory (expand-file-name - (if whole-project-p - (elpy-project-root) - (buffer-file-name)))) - (extra-args (if whole-project-p - " --exclude=.svn,CVS,.bzr,.hg,.git,.tox,build,dist" - ""))) - (compilation-start (concat python-check-command - " " - (shell-quote-argument file-name-or-directory) - extra-args) - nil - (lambda (mode-name) - "*Python Check*")))) - -(defun elpy-show-defun () - "Show the current class and method, in case they are not on -screen." - (interactive) - (let ((function (python-info-current-defun))) - (if function - (message "%s()" function) - (message "Not in a function")))) - -(defun elpy-goto-definition () - "Go to the definition of the symbol at point, if found." - (interactive) - (let ((location (elpy-rpc-get-definition))) - (if location - (elpy-goto-location (car location) (cadr location)) - (error "No definition found")))) - -(defun elpy-goto-location (filename offset) - "Show FILENAME at OFFSET to the user." - (ring-insert find-tag-marker-ring (point-marker)) - (let ((buffer (find-file filename))) - (with-current-buffer buffer - (with-selected-window (get-buffer-window buffer) - (goto-char (1+ offset)))))) - -(defun elpy-nav-forward-statement () - "Move forward one statement. - -This will go to the end of the current statement, or the end of -the next one if already at the end." - (interactive) - (let ((old (point))) - (python-nav-end-of-statement) - (when (= old (point)) - (python-nav-forward-statement) - (python-nav-end-of-statement)))) - -(defun elpy-nav-backward-statement () - "Move backward one statement. - -This will go to the beginning of the current statement, or the -beginning of the previous one if already at the beginning." - (interactive) - (let ((old (point))) - (python-nav-beginning-of-statement) - (when (= old (point)) - (python-nav-backward-statement)))) - -(defun elpy-nav-forward-definition () - "Move forward to the next definition (class or function)." - (interactive) - (if (save-excursion - (forward-char 1) - (re-search-forward "^ *\\(def\\|class\\) " nil t)) - (goto-char (match-beginning 1)) - (goto-char (point-max)))) - -(defun elpy-nav-backward-definition () - "Move backward to the previous definition (class or function)." - (interactive) - (if (save-excursion - (forward-char -1) - (re-search-backward "^ *\\(def\\|class\\) " nil t)) - (goto-char (match-beginning 1)) - (goto-char (point-min)))) - -(defun elpy-occur-definitions () - "Display an occur buffer of all definitions in the current buffer. - -Also, switch to that buffer." - (interactive) - (let ((list-matching-lines-face nil)) - (occur "^ *\\(def\\|class\\) ")) - (let ((window (get-buffer-window "*Occur*"))) - (if window - (select-window window) - (switch-to-buffer "*Occur*")))) - -(defun elpy-rgrep-symbol (symbol) - "Search for SYMBOL in the current project. - -SYMBOL defaults to the symbol at point, or the current region if -active. - -With a prefix argument, prompt for a string to search for." - (interactive - (list - (cond - (current-prefix-arg - (read-from-minibuffer "Search for symbol: ")) - ((use-region-p) - (buffer-substring-no-properties (region-beginning) - (region-end))) - (t - (or (thing-at-point 'symbol) - (read-from-minibuffer "Search for symbol: ")))))) - (grep-compute-defaults) - (let ((grep-find-ignored-directories (append elpy-rgrep-ignored-directories - grep-find-ignored-directories))) - (rgrep (format "\\b%s\\b" symbol) - "*.py" - (elpy-project-root))) - (with-current-buffer next-error-last-buffer - (let ((inhibit-read-only t)) - (save-excursion - (goto-char (point-min)) - (when (re-search-forward "^find .*" nil t) - (replace-match (format "\\1\nSearching for symbol %s\n" - symbol))))))) - -(defun elpy-test (&optional arg) - "Run nosetests on the current project. - -With no prefix arg, all tests are run. -With one prefix arg, only the current test is run. -With two prefix args, only the current module is run." - (interactive "p") - (save-some-buffers) - (cond - ((>= arg 16) (nosetests-module)) - ((>= arg 4) (nosetests-one)) - (t (nosetests-all)))) - - -;;;;;;;;;;;;;;;;; -;;; Documentation - -(defvar elpy-doc-history nil - "History for the `elpy-doc' command.") - -(defun elpy-doc-websearch (what) - "Search the Python web documentation for the string WHAT." - (interactive - (list (read-from-minibuffer "Search Python.org for: " - (symbol-name (symbol-at-point))))) - (browse-url - (format "https://www.google.com/search?q=site:docs.python.org%%20%s" - what))) - -(defun elpy-doc (&optional use-pydoc-p symbol) - "Show documentation on the thing at point. - -If USE-PYDOC is non-nil (interactively, when a prefix argument is -given), use pydoc on the symbol SYMBOL (interactively, the symbol -at point). With a single prefix argument, the user gets a -completion interface for possible symbols. With two prefix -arguments, the interface simply asks for a string." - (interactive - (list current-prefix-arg - (let ((initial (with-syntax-table python-dotty-syntax-table - (let ((symbol (symbol-at-point))) - (if symbol - (symbol-name symbol) - nil))))) - (cond - ((and initial (not current-prefix-arg)) - initial) - ((equal current-prefix-arg '(16)) - ;; C-u C-u - (read-from-minibuffer "Pydoc: " initial nil nil - 'elpy-doc-history)) - (t - (elpy-ido-recursive-completing-read "Pydoc: " - 'elpy-pydoc--completions - "." - t - initial - 'elpy-doc-history)))))) - (let ((doc (if use-pydoc-p - (elpy-rpc-get-pydoc-documentation symbol) - (or (elpy-rpc-get-docstring) - ;; This will get the right position for - ;; multiprocessing.Queue(quxqux_|_) - (ignore-errors - (save-excursion - (elpy-nav-backward-statement) - (with-syntax-table python-dotty-syntax-table - (forward-symbol 1) - (backward-char 1)) - (elpy-rpc-get-docstring))))))) - (if doc - (with-help-window "*Python Doc*" - (with-current-buffer "*Python Doc*" - (erase-buffer) - (insert doc) - (goto-char (point-min)) - (while (re-search-forward "\\(.\\)\\1" nil t) - (replace-match (propertize (match-string 1) - 'face 'bold) - t t)))) - (message "No documentation available.")))) - -(defun elpy-pydoc--completions (rcr-prefix) - "Return a list of modules available in pydoc starting with RCR-PREFIX." - (sort (if (or (not rcr-prefix) - (equal rcr-prefix "")) - (elpy-rpc "get_pydoc_completions" nil) - (elpy-rpc "get_pydoc_completions" (list rcr-prefix))) - (lambda (a b) - (if (and (string-prefix-p "_" b) - (not (string-prefix-p "_" a))) - t - (string< (downcase a) - (downcase b)))))) - - -;;;;;;;;;;;; -;;; elpy-ido - -;; This is a wrapper around ido-completing-read, which does not -;; provide for recursive reads by default. - -(defvar elpy-ido-rcr-choice-function nil - "Internal variable for `elpy-ido-recursive-completing-read'. - -Don't touch. Won't help.") - -(defvar elpy-ido-rcr-selection nil - "Internal variable for `elpy-ido-recursive-completing-read'. - -Don't touch. Won't help.") - -(defvar elpy-ido-rcr-separator nil - "Internal variable for `elpy-ido-recursive-completing-read'. - -Don't touch. Won't help.") - -(defvar elpy-ido-rcr-choices nil - "Internal variable for `elpy-ido-recursive-completing-read'. - -Don't touch. Won't help.") - -(defun elpy-ido--rcr-selected () - "Return the currently selected compound." - (mapconcat #'identity - (reverse elpy-ido-rcr-selection) - elpy-ido-rcr-separator)) - -(defun elpy-ido--rcr-setup-keymap () - "Set up the ido keymap for `elpy-ido-recursive-completing-read'." - (define-key ido-completion-map (read-kbd-macro elpy-ido-rcr-separator) - 'elpy-ido-rcr-complete) - (define-key ido-completion-map (kbd "DEL") 'elpy-ido-rcr-backspace)) - -(defun elpy-ido-rcr-complete () - "Complete the current ido completion and attempt an extension." - (interactive) - (let* ((new (car ido-matches)) - (full (concat (elpy-ido--rcr-selected) - elpy-ido-rcr-separator - new)) - (choices (funcall elpy-ido-rcr-choice-function full))) - (when choices - (setq elpy-ido-rcr-choices choices - elpy-ido-rcr-selection (cons new elpy-ido-rcr-selection)) - (throw 'continue t)))) - -(defun elpy-ido-rcr-backspace (&optional n) - "Delete the last character in the minibuffer. - -If the minibuffer is empty, recurse to the last completion." - (interactive "p") - (if (= (minibuffer-prompt-end) (point)) - (progn - (setq elpy-ido-rcr-selection (cdr elpy-ido-rcr-selection) - elpy-ido-rcr-choices (funcall elpy-ido-rcr-choice-function - (elpy-ido--rcr-selected))) - (throw 'continue t)) - (delete-char (- n)))) - -(defun elpy-ido-recursive-completing-read (prompt choice-function - separator - &optional - require-match - initial-input - hist def) - "An alternative to `ido-completing-read' supporting recursive selection. - -The CHOICE-FUNCTION is called with a prefix string and should -find all possible selections with this prefix. The user is then -prompted with those options. When the user hits RET, the -currently selected option is returned. When the user hits the -SEPARATOR key, though, the currently selected option is appended, -with the separator, to the selected prefix, and the user is -prompted for further completions returned by CHOICE-FUNCTION. - -For REQUIRE-MATCH, INITIAL-INPUT, HIST and DEF, see -`completing-read'." - (let ((ido-setup-hook (cons 'elpy-ido--rcr-setup-keymap - ido-setup-hook)) - (elpy-ido-rcr-choice-function choice-function) - (elpy-ido-rcr-separator separator) - elpy-ido-rcr-choices - elpy-ido-rcr-selection) - (when initial-input - (let ((parts (reverse (split-string initial-input - (regexp-quote separator))))) - (setq initial-input (car parts) - elpy-ido-rcr-selection (cdr parts)))) - (setq elpy-ido-rcr-choices (funcall choice-function - (elpy-ido--rcr-selected))) - (catch 'return - (while t - (catch 'continue - (throw 'return - (let ((completion (ido-completing-read - (concat prompt - (elpy-ido--rcr-selected) - (if elpy-ido-rcr-selection - elpy-ido-rcr-separator - "")) - elpy-ido-rcr-choices - nil require-match - initial-input hist def))) - (concat - (mapconcat (lambda (element) - (concat element elpy-ido-rcr-separator)) - (reverse elpy-ido-rcr-selection) - "") - completion)))) - ;; after the first run, we don't want initial and default - ;; anymore. - (setq initial-input nil - def nil))))) - - -;;;;;;;;;;;;;;;;;;;;; -;;; elpy-rpc backends - -;; elpy-rpc is a simple JSON-based RPC protocol. It's mostly JSON-RPC -;; 1.0, except we do not implement the full protocol as we do not need -;; all the features. Emacs starts a Python subprocess which runs a -;; special module. The module reads JSON-RPC requests and responds -;; with JSON-RPC responses. - -(defvar elpy-rpc--call-id 0 - "Call id of the last elpy-rpc call. - -Used to associate responses to callbacks.") -(make-variable-buffer-local 'elpy-rpc--call-id) - -(defvar elpy-rpc--buffer-p nil - "True iff the current buffer is an elpy-rpc buffer.") -(make-variable-buffer-local 'elpy-rpc--buffer-p) - -(defvar elpy-rpc--buffer nil - "The elpy-rpc buffer associated with this buffer.") -(make-variable-buffer-local 'elpy-rpc--buffer) - -(defvar elpy-rpc--backend-project-root nil - "The project root used by this backend.") -(make-variable-buffer-local 'elpy-rpc--backend-project-root) - -(defvar elpy-rpc--backend-python-command nil - "The Python interpreter used by this backend.") -(make-variable-buffer-local 'elpy-rpc--backend-python-command) - -(defvar elpy-rpc--backend-callbacks nil - "The callbacks registered for calls to the current backend. - -This maps call IDs to functions.") -(make-variable-buffer-local 'elpy-rpc--backend-callbacks) - -(defvar elpy-rpc--timeout 1 - "Number of seconds to wait for a response. - -You can dynamically bind this to a higher value if you want to -wait longer.") - -(defun elpy-rpc--process-buffer-p (buffer) - "Return non-nil when BUFFER is an elpy-rpc buffer." - (buffer-local-value 'elpy-rpc--buffer-p buffer)) - -(defun elpy-rpc--live-p (buffer) - "Return non-nil when BUFFER is a live elpy-rpc process." - (and buffer - (get-buffer-process buffer) - (process-live-p (get-buffer-process buffer)))) - -(defun elpy-rpc--get-rpc-buffer () - "Return the RPC buffer associated with the current buffer, -creating one if necessary." - (cond - (elpy-rpc--buffer-p - (current-buffer)) - ((not elpy-mode) - (error "Not an Elpy buffer")) - ((elpy-rpc--live-p elpy-rpc--buffer) - elpy-rpc--buffer) - (t - (when elpy-rpc--buffer - (kill-buffer elpy-rpc--buffer)) - (setq elpy-rpc--buffer - (or (elpy-rpc--find-buffer (elpy-project-root) - elpy-rpc-python-command) - (elpy-rpc--open (elpy-project-root) - elpy-rpc-python-command))) - elpy-rpc--buffer))) - -(defun elpy-rpc--get-rpc-process () - "Return the RPC process associated with the current buffer, -creating one if necessary." - (get-buffer-process (elpy-rpc--get-rpc-buffer))) - -(defun elpy-rpc--find-buffer (project-root python-command) - "Return an existing RPC buffer for this project root and command." - (let ((result nil)) - (dolist (buf (buffer-list)) - (when (elpy-rpc--process-buffer-p buf) - (if (not (elpy-rpc--live-p buf)) - (kill-buffer buf) - (with-current-buffer buf - (when (and (equal elpy-rpc--backend-project-root - project-root) - (equal elpy-rpc--backend-python-command - python-command)) - (when result - (kill-buffer result)) - (setq result buf)))))) - result)) - -(defun elpy-rpc--open (project-root python-command) - "Start a new RPC process and return the associated buffer." - (when (and elpy-rpc-backend - (not (stringp elpy-rpc-backend))) - (error "`elpy-rpc-backend' should be nil or a string.")) - (with-current-buffer (generate-new-buffer "*elpy-rpc*") - (setq elpy-rpc--buffer-p t - elpy-rpc--backend-project-root project-root - elpy-rpc--backend-python-command python-command - default-directory project-root) - (let ((proc (condition-case err - (let ((process-connection-type nil)) - (start-process "elpy-rpc" - (current-buffer) - python-command - "-W" "ignore" - "-m" "elpy.__main__")) - (error - (elpy-installation-instructions - (format "Could not start the Python subprocess: %s" - (cadr err)) - t) - (error (cadr err)))))) - (set-process-query-on-exit-flag proc nil) - (set-process-sentinel proc #'elpy-rpc--sentinel) - (set-process-filter proc #'elpy-rpc--filter)) - (cond - ;; User requested a specific backend - (elpy-rpc-backend - (elpy-rpc-set-backend - elpy-rpc-backend - (lambda (result) - ;; Requested backend successfully set - t) - (lambda (err) - (elpy-installation-instructions - (format (concat "The %s backend is unavailable. " - "Please install appropriate Python library,\n" - "or change the value of `elpy-rpc-backend'") - elpy-rpc-backend))))) - ;; User did not specify a backend, make sure we are not using the - ;; native one. - (t - (elpy-rpc-get-backend - (lambda (current-backend) - (when (equal current-backend "native") - (elpy-installation-instructions - (concat "Only the basic native backend is available. " - "You might want to install an appropriate " - "Python library. If you are happy with the native " - "backend, please add the following to your .emacs:" - "\n\n(setq elpy-rpc-backend \"native\")"))))))) - (current-buffer))) - -(defun elpy-rpc--sentinel (process event) - "The sentinel for the RPC process." - (when event - ;; Process sentinels are only ever called when the process - ;; finishes. - (when elpy-rpc--backend-callbacks - (maphash (lambda (call-id callbacks) - (ignore-errors - (funcall (nth 1 callbacks) - (substring event 0 -1)))) - elpy-rpc--backend-callbacks) - (setq elpy-rpc--backend-callbacks nil)))) - -(defun elpy-rpc--filter (process output) - "The filter for the RPC process." - (with-current-buffer (process-buffer process) - (goto-char (point-max)) - (insert output) - (catch 'return - (while (progn - (goto-char (point-min)) - (search-forward "\n" nil t)) - (goto-char (point-min)) - (let (json did-read-json) - (condition-case err - (setq json (let ((json-array-type 'list)) - (json-read)) - did-read-json t) - (error - (goto-char (point-min)) - (cond - ((looking-at "elpy-rpc ready\n") - (replace-match "") - (elpy-rpc--backend-version "1.1")) - ((looking-at "elpy-rpc ready (\\([^ ]*\\))\n") - (let ((rpc-version (match-string 1))) - (replace-match "") - (elpy-rpc--backend-version rpc-version))) - (t - (elpy-rpc--handle-unexpected-line) - (throw 'return nil))))) - (when did-read-json - (delete-region (point-min) (1+ (point))) - (elpy-rpc--handle-json json))))))) - -(defun elpy-rpc--backend-version (rpc-version) - "Check that we are using the right version." - (when (not (equal rpc-version elpy-version)) - (with-help-window "*Elpy Version Mismatch*" - (with-current-buffer "*Elpy Version Mismatch*" - (insert - "You are not using the same version of Elpy in Emacs Lisp\n" - "compared to Python. This can cause random problems. Please\n" - "do make sure to use compatible versions.\n" - "\n" - "Elpy Emacs Lisp version: " elpy-version "\n" - "Elpy Python version....: " rpc-version "\n"))))) - -(defun elpy-rpc--handle-json (json) - "Handle a single JSON object from the RPC backend." - (let ((call-id (cdr (assq 'id json))) - (error-string (cdr (assq 'error json))) - (result (cdr (assq 'result json))) - success-callback error-callback) - (let ((callbacks (gethash call-id elpy-rpc--backend-callbacks))) - (when (not callbacks) - (error "Received a response for unknown call-id %s" call-id)) - (setq success-callback (nth 0 callbacks) - error-callback (nth 1 callbacks) - orig-buf (nth 2 callbacks)) - (remhash call-id elpy-rpc--backend-callbacks) - (with-current-buffer orig-buf - (if error-string - (if error-callback - (funcall error-callback error-string) - (error "Error from RPC: %S" error-string)) - (funcall success-callback result)))))) - -(defun elpy-rpc--handle-unexpected-line () - "Handle an unexpected line from the backend. - -This is usually an error or backtrace." - (let ((missing-module (when (re-search-forward "No module named \\(.*\\)" - nil t) - (match-string 1)))) - (cond - ((member missing-module '("elpy" "rope" "jedi")) - (elpy-installation-instructions - (format "The %s Python module was not found." missing-module) - (equal missing-module "elpy"))) - (missing-module - (with-help-window "*Elpy Error*" - (with-current-buffer "*Elpy Error*" - (view-mode 1) - (let ((inhibit-read-only t)) - (erase-buffer) - (insert "There was an error initializing the Elpy backend,\n" - "as the " missing-module " Python module was not found.\n" - "\n" - "Please install this module to use elpy.\n")) - (pop-to-buffer (current-buffer))))) - (t - (let ((data (buffer-string))) - (with-help-window "*Elpy Error*" - (with-current-buffer "*Elpy Error*" - (view-mode 1) - (let ((inhibit-read-only t)) - (erase-buffer) - (insert "There was an error in the Elpy backend.\n" - "The following lines were received from Python, and " - "might help identifying\n" - "the problem.\n" - "\n" - data)) - (pop-to-buffer (current-buffer))))))))) - -(defun elpy-rpc--call (method-name params success &optional error) - "Call METHOD-NAME with PARAMS in the current RPC backend. - -Returns immediately. When a result is available, SUCCESS will be -called with that value as its sole argument. If an error occurs, -ERROR is called, if set." - (let ((orig-buf (current-buffer))) - (with-current-buffer (elpy-rpc--get-rpc-buffer) - (setq elpy-rpc--call-id (1+ elpy-rpc--call-id)) - (elpy-rpc--register-callback elpy-rpc--call-id success error orig-buf) - (process-send-string - (get-buffer-process (current-buffer)) - (concat (json-encode `((id . ,elpy-rpc--call-id) - (method . ,method-name) - (params . ,params))) - "\n"))))) - -(defun elpy-rpc--register-callback (call-id success error buffer) - "Register for SUCCESS and ERROR to be called when CALL-ID returns. - -Must be called in an elpy-rpc buffer." - (assert elpy-rpc--buffer-p) - (when (not elpy-rpc--backend-callbacks) - (setq elpy-rpc--backend-callbacks (make-hash-table :test #'equal))) - (puthash call-id (list success error buffer) elpy-rpc--backend-callbacks)) - -(defun elpy-rpc--call-blocking (method-name params) - "Call METHOD-NAME with PARAMS in the current RPC backend. - -Returns the result, blocking until this arrived." - (let ((result-arrived nil) - (error-occured nil) - (result-value nil) - (error-string nil)) - (elpy-rpc--call method-name params - (lambda (result) - (setq result-value result - result-arrived t)) - (lambda (err) - (setq error-string err - error-occured t))) - (let ((end-time (time-add (current-time) - (seconds-to-time elpy-rpc--timeout)))) - (while (and (time-less-p (current-time) - end-time) - (not (or result-arrived - error-occured))) - (accept-process-output (elpy-rpc--get-rpc-process) - elpy-rpc--timeout))) - (cond - (error-occured - (error error-string)) - (result-arrived - result-value) - (t - (error "Timeout in RPC call from backend"))))) - -(defun elpy-rpc (method params &optional success error) - "Call METHOD with PARAMS in the backend. - -If SUCCESS and optionally ERROR is given, return immediately and -call those when a result is available. Otherwise, wait for a -result and return that." - (if success - (elpy-rpc--call method params success error) - (elpy-rpc--call-blocking method params))) - -(defun elpy-rpc-restart () - "Restart the current RPC process." - (interactive) - (when (elpy-rpc--live-p elpy-rpc--buffer) - (kill-buffer elpy-rpc--buffer) - (setq elpy-rpc--buffer nil)) - (elpy-rpc--get-rpc-buffer)) - -(defun elpy-rpc-get-completions (&optional success error) - "Call the find_completions API function. - -Returns a list of possible completions for the Python symbol at -point." - (elpy-rpc "get_completions" - (list (expand-file-name (elpy-project-root)) - buffer-file-name - (buffer-string) - (- (point) - (point-min))) - success error)) - -(defun elpy-rpc-get-calltip (&optional success error) - "Call the get_calltip API function. - -Returns a calltip string for the function call at point." - (elpy-rpc "get_calltip" - (list (expand-file-name (elpy-project-root)) - buffer-file-name - (buffer-string) - (- (point) - (point-min))) - success error)) - -(defun elpy-rpc-get-docstring (&optional success error) - "Call the get_docstring API function. - -Returns a possible multi-line docstring for the symbol at point." - (elpy-rpc "get_docstring" - (list (expand-file-name (elpy-project-root)) - buffer-file-name - (buffer-string) - (- (point) - (point-min))) - success error)) - -(defun elpy-rpc-get-pydoc-documentation (symbol &optional success error) - "Get the Pydoc documentation for SYMBOL. - -Returns a possible multi-line docstring." - (elpy-rpc "get_pydoc_documentation" (list symbol) - success error)) - -(defun elpy-rpc-get-definition (&optional success error) - "Call the find_definition API function. - -Returns nil or a list of (filename, point)." - (elpy-rpc "get_definition" - (list (expand-file-name (elpy-project-root)) - buffer-file-name - (buffer-string) - (- (point) - (point-min))) - success error)) - -(defun elpy-rpc-get-backend (&optional success error) - "Call the get_backend API function. - -Returns the name of the backend currently in use." - (elpy-rpc "get_backend" nil success error)) - -(defun elpy-rpc-get-available-backends (&optional success error) - "Call the get_available_backends API function. - -Returns a list of names of available backends, depending on which -Python libraries are installed." - (elpy-rpc "get_available_backends" nil success error)) - -(defun elpy-rpc-set-backend (backend &optional success error) - "Call the set_backend API function. - -This changes the current backend to the named backend. Raises an -error if the backend is not supported." - (interactive - (list (completing-read - (format "Switch elpy backend (currently %s): " - (elpy-rpc-get-backend)) - (elpy-rpc-get-available-backends) - nil t))) - (elpy-rpc "set_backend" (list backend) success error)) - -(defalias 'elpy-set-backend 'elpy-rpc-set-backend) - - -;;;;;;;;; -;;; Eldoc - -(defun elpy-eldoc-documentation () - "Return a call tip for the python call at point." - (elpy-rpc-get-calltip - (lambda (calltip) - (eldoc-message - (when calltip - (with-temp-buffer - ;; multiprocessing.queues.Queue.cancel_join_thread(self) - (insert calltip) - (goto-char (point-min)) - ;; First, remove the whole path up to the second-to-last dot. We - ;; retain the class just to make it nicer. - (while (search-forward "." nil t) - nil) - (when (search-backward "." nil t 2) - (delete-region (point-min) (1+ (point)))) - ;; Then remove the occurrence of "self", that's not passed by - ;; the user. - (when (re-search-forward "(self\\(, \\)?" nil t) - (replace-match "(")) - (goto-char (point-min)) - ;; Lastly, we'd like to highlight the argument are on. - - ;; This is tricky with keyword vs. positions arguments, and - ;; possibly quite complex argument values. - - ;; Hence, we don't do anything for now. - (buffer-string)))))) - ;; Return the last message until we're done - eldoc-last-message) - - -;;;;;;;;;;; -;;; Flymake - -(eval-after-load "flymake" - '(add-to-list 'flymake-allowed-file-name-masks - '("\\.py\\'" elpy-flymake-python-init))) - -(defun elpy-flymake-python-init () - ;; Make sure it's not a remote buffer as flymake would not work - (when (not (file-remote-p buffer-file-name)) - (let* ((temp-file (flymake-init-create-temp-buffer-copy - 'flymake-create-temp-inplace))) - (list python-check-command (list temp-file))))) - -(defun elpy-flymake-forward-error () - "Move forward to the next Flymake error and show a -description." - (interactive) - (flymake-goto-next-error) - (elpy-flymake-show-error)) - -(defun elpy-flymake-backward-error () - "Move backward to the previous Flymake error and show a -description." - (interactive) - (flymake-goto-prev-error) - (elpy-flymake-show-error)) - -(defun elpy-flymake-show-error () - "Show the flymake error message at point." - (let* ((lineno (flymake-current-line-no)) - (err-info (car (flymake-find-err-info flymake-err-info - lineno))) - (text (mapconcat #'flymake-ler-text - err-info - ", "))) - (message "%s" text))) - - -;;;;;;;;;;;;; -;;; Yasnippet - -;; No added configuration needed. Nice mode. :o) - - -;;;;;;;;;;;;;;;;; -;;; Auto-Complete - -(defvar elpy--ac-cache nil - "List of current expansions and docstrings.") - -(defun elpy--ac-init () - "Initialize a completion. - -This will call Python in the background and initialize -`elpy--ac-cache' when it returns." - (elpy-rpc-get-completions - (lambda (result) - (setq elpy--ac-cache nil) - (dolist (completion result) - (let ((name (car completion)) - (doc (cadr completion))) - (when (not (string-prefix-p "_" name)) - (push (cons (concat ac-prefix name) - doc) - elpy--ac-cache)))) - (ac-start)) - (lambda (err) - (message "Can't get completions: %s" err)))) - -(defun elpy--ac-candidates () - "Return a list of possible expansions at points. - -This uses `elpy--ac-cache'." - (mapcar (lambda (info) - (popup-make-item - (car info) - :symbol "p" - :summary (when (and (cdr info) - (not (equal (cdr info) ""))) - "->"))) - elpy--ac-cache)) - -(defun elpy--ac-document (name) - "Return the documentation for the symbol NAME." - (assoc-default name elpy--ac-cache)) - -(ac-define-source elpy - '((init . elpy--ac-init) - (candidates . elpy--ac-candidates) - (document . elpy--ac-document) - (symbol . "p"))) - -(ac-define-source elpy-dot - '((init . elpy--ac-init) - (candidates . elpy--ac-candidates) - (document . elpy--ac-document) - (symbol . "p") - (prefix . c-dot) - (requires . 0))) - - -;;;;;;;;;;;;;; -;;; Virtualenv - -(defadvice virtualenv-workon (around ad-elpy-virtualenv-workon activate) - "Restart the elpy-rpc backend on virtualenv change." - (let ((old-env virtualenv-workon-session)) - ad-do-it - (when (and virtualenv-workon-starts-python - (elpy-rpc--get-rpc-buffer) - (not (equal old-env virtualenv-workon-session)) - (y-or-n-p "Virtualenv changed, restart Elpy-RPC? ")) - (elpy-rpc-restart)))) - -(defadvice virtualenv-deactivate (after ad-elpy-virtualenv-deactivate activate) - "Restart the elpy-rpc backend on virtualenv change." - (when (and virtualenv-workon-starts-python - (elpy-rpc--get-rpc-buffer) - (y-or-n-p "Virtualenv deactivated, restart Elpy-RPC? ")) - (elpy-rpc-restart))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Backwards compatibility - -;; Functions for Emacs 24 before 24.3 -(when (not (fboundp 'python-shell-send-region)) - (defalias 'python-shell-send-region 'python-send-region)) -(when (not (fboundp 'python-shell-send-buffer)) - (defalias 'python-shell-send-buffer 'python-send-buffer)) -(when (not (fboundp 'python-info-current-defun)) - (defalias 'python-info-current-defun 'python-current-defun)) -(when (not (fboundp 'python-nav-end-of-statement)) - (defalias 'python-nav-end-of-statement 'python-end-of-statement)) -(when (not (fboundp 'python-nav-beginning-of-statement)) - (require 'thingatpt) - (defalias 'python-nav-beginning-of-statement 'beginning-of-sexp)) -(when (not (fboundp 'python-nav-forward-statement)) - (defalias 'python-nav-forward-statement 'forward-sexp)) -(when (not (fboundp 'python-nav-backward-statement)) - (defalias 'python-nav-backward-statement 'backward-sexp)) - -(when (not (fboundp 'python-shell-get-process-name)) - (defun python-shell-get-process-name (dedicated) - "Compatibility function for older Emacsen." - "Python")) -(when (not (fboundp 'python-shell-parse-command)) - (defun python-shell-parse-command () - "Compatibility function for older Emacsen." - python-python-command)) -(when (not (fboundp 'python-shell-calculate-process-environment)) - (defun python-shell-calculate-process-environment () - "Compatibility function for older Emacsen." - process-environment)) -(when (not (fboundp 'python-shell-calculate-exec-path)) - (defun python-shell-calculate-exec-path () - "Compatibility function for older Emacsen." - exec-path)) - -;; Emacs 24.2 made `locate-dominating-file' accept a predicate instead -;; of a string. Simply overwrite the current one, it's -;; backwards-compatible. The code below is taken from Emacs 24.3. -(when (or (< emacs-major-version 24) - (and (= emacs-major-version 24) - (<= emacs-minor-version 2))) - (defun locate-dominating-file (file name) - "Look up the directory hierarchy from FILE for a directory containing NAME. -Stop at the first parent directory containing a file NAME, -and return the directory. Return nil if not found. -Instead of a string, NAME can also be a predicate taking one argument -\(a directory) and returning a non-nil value if that directory is the one for -which we're looking." - ;; We used to use the above locate-dominating-files code, but the - ;; directory-files call is very costly, so we're much better off doing - ;; multiple calls using the code in here. - ;; - ;; Represent /home/luser/foo as ~/foo so that we don't try to look for - ;; `name' in /home or in /. - (setq file (abbreviate-file-name file)) - (let ((root nil) - ;; `user' is not initialized outside the loop because - ;; `file' may not exist, so we may have to walk up part of the - ;; hierarchy before we find the "initial UID". Note: currently unused - ;; (user nil) - try) - (while (not (or root - (null file) - ;; FIXME: Disabled this heuristic because it is sometimes - ;; inappropriate. - ;; As a heuristic, we stop looking up the hierarchy of - ;; directories as soon as we find a directory belonging - ;; to another user. This should save us from looking in - ;; things like /net and /afs. This assumes that all the - ;; files inside a project belong to the same user. - ;; (let ((prev-user user)) - ;; (setq user (nth 2 (file-attributes file))) - ;; (and prev-user (not (equal user prev-user)))) - (string-match locate-dominating-stop-dir-regexp file))) - (setq try (if (stringp name) - (file-exists-p (expand-file-name name file)) - (funcall name file))) - (cond (try (setq root file)) - ((equal file (setq file (file-name-directory - (directory-file-name file)))) - (setq file nil)))) - (if root (file-name-as-directory root)))) - ) - -;; highlight-indentation 0.5 does not use modes yet -(when (not (fboundp 'highlight-indentation-mode)) - (defun highlight-indentation-mode (on-or-off) - (cond - ((and (= on-or-off 1) - (not highlight-indent-active)) - (highlight-indentation)) - ((and (= on-or-off 0) - highlight-indent-active) - (highlight-indentation))))) - -(provide 'elpy) -;;; elpy.el ends here diff --git a/emacs.d/elpa/elpy-1.2.1/elpy.elc b/emacs.d/elpa/elpy-1.2.1/elpy.elc deleted file mode 100644 index e685ab1..0000000 Binary files a/emacs.d/elpa/elpy-1.2.1/elpy.elc and /dev/null differ diff --git a/emacs.d/elpa/elpy-1.2.1/snippets/python-mode/__enter__ b/emacs.d/elpa/elpy-1.2.1/snippets/python-mode/__enter__ deleted file mode 100644 index 4c74b66..0000000 --- a/emacs.d/elpa/elpy-1.2.1/snippets/python-mode/__enter__ +++ /dev/null @@ -1,10 +0,0 @@ -# -*- mode: snippet -*- -# name: __enter__ -# key: __enter__ -# expand-env: ((yas-indent-line nil)) -# -- -__enter__(self): - $1 - - def __exit__(self, exc_type, exc_value, traceback): - $2 diff --git a/emacs.d/elpa/elpy-1.2.1/snippets/python-mode/__exit__ b/emacs.d/elpa/elpy-1.2.1/snippets/python-mode/__exit__ deleted file mode 100644 index e04a433..0000000 --- a/emacs.d/elpa/elpy-1.2.1/snippets/python-mode/__exit__ +++ /dev/null @@ -1,6 +0,0 @@ -# -*- mode: snippet -*- -# name: __exit__ -# key: __exit__ -# -- -__exit__(self, exc_type, exc_value, traceback): - $0 diff --git a/emacs.d/elpa/elpy-1.2.1/snippets/python-mode/super b/emacs.d/elpa/elpy-1.2.1/snippets/python-mode/super deleted file mode 100644 index 6361b45..0000000 --- a/emacs.d/elpa/elpy-1.2.1/snippets/python-mode/super +++ /dev/null @@ -1,7 +0,0 @@ -# -*- mode: snippet -*- -# name: super -# key: super -# expand-env: ((class (lambda () (let ((info (python-info-current-defun))) (if info (car (split-string info "\\.")) "class")))) (method (lambda () (let ((info (python-info-current-defun))) (if info (cadr (split-string info "\\.")) "method")))) (object (lambda () (if (and (python-nav-beginning-of-defun) (re-search-forward "(\\([^),=]*\\)" nil t)) (match-string-no-properties 1) "self")))) -# -- -super(`(funcall class)`, `(funcall object)`).`(funcall method)`($1) - $0 \ No newline at end of file diff --git a/emacs.d/elpa/erlang-2.4.1/erlang-autoloads.el b/emacs.d/elpa/erlang-2.4.1/erlang-autoloads.el deleted file mode 100644 index 6e67393..0000000 --- a/emacs.d/elpa/erlang-2.4.1/erlang-autoloads.el +++ /dev/null @@ -1,131 +0,0 @@ -;;; erlang-autoloads.el --- automatically extracted autoloads -;; -;;; Code: - - -;;;### (autoloads (inferior-erlang erlang-compile erlang-shell erlang-find-tag-other-window -;;;;;; erlang-find-tag erlang-mode) "erlang" "erlang.el" (20941 -;;;;;; 53852 0 0)) -;;; Generated autoloads from erlang.el - -(autoload 'erlang-mode "erlang" "\ -Major mode for editing Erlang source files in Emacs. -It knows about syntax and comment, it can indent code, it is capable -of fontifying the source file, the TAGS commands are aware of Erlang -modules, and the Erlang man pages can be accessed. - -Should this module, \"erlang.el\", be installed properly, Erlang mode -is activated whenever an Erlang source or header file is loaded into -Emacs. To indicate this, the mode line should contain the word -\"Erlang\". - -The main feature of Erlang mode is indentation, press TAB and the -current line will be indented correctly. - -Comments starting with only one `%' are indented to the column stored -in the variable `comment-column'. Comments starting with two `%':s -are indented with the same indentation as code. Comments starting -with at least three `%':s are indented to the first column. - -However, Erlang mode contains much more, this is a list of the most -useful commands: - TAB - Indent the line. - C-c C-q - Indent current function. - M-; - Create a comment at the end of the line. - M-q - Fill a comment, i.e. wrap lines so that they (hopefully) - will look better. - M-a - Goto the beginning of an Erlang clause. - M-C-a - Ditto for function. - M-e - Goto the end of an Erlang clause. - M-C-e - Ditto for function. - M-h - Mark current Erlang clause. - M-C-h - Ditto for function. - C-c C-z - Start, or switch to, an inferior Erlang shell. - C-c C-k - Compile current file. - C-x ` - Next error. - , - Electric comma. - ; - Electric semicolon. - -Erlang mode check the name of the file against the module name when -saving, whenever a mismatch occurs Erlang mode offers to modify the -source. - -The variable `erlang-electric-commands' controls the electric -commands. To deactivate all of them, set it to nil. - -There exists a large number of commands and variables in the Erlang -module. Please press `M-x apropos RET erlang RET' to see a complete -list. Press `C-h f name-of-function RET' and `C-h v name-of-variable -RET'to see the full description of functions and variables, -respectively. - -On entry to this mode the contents of the hook `erlang-mode-hook' is -executed. - -Please see the beginning of the file `erlang.el' for more information -and examples of hooks. - -Other commands: -\\{erlang-mode-map} - -\(fn)" t nil) - -(autoload 'erlang-find-tag "erlang" "\ -Like `find-tag'. Capable of retreiving Erlang modules. - -Tags can be given on the forms `tag', `module:', `module:tag'. - -\(fn MODTAGNAME &optional NEXT-P REGEXP-P)" t nil) - -(autoload 'erlang-find-tag-other-window "erlang" "\ -Like `find-tag-other-window' but aware of Erlang modules. - -\(fn TAGNAME &optional NEXT-P REGEXP-P)" t nil) - -(autoload 'erlang-shell "erlang" "\ -Start a new Erlang shell. - -The variable `erlang-shell-function' decides which method to use, -default is to start a new Erlang host. It is possible that, in the -future, a new shell on an already running host will be started. - -\(fn)" t nil) - (autoload 'run-erlang "erlang" "Start a new Erlang shell." t) - -(autoload 'erlang-compile "erlang" "\ -Compile Erlang module in current buffer. - -\(fn)" t nil) - -(autoload 'inferior-erlang "erlang" "\ -Run an inferior Erlang. - -This is just like running Erlang in a normal shell, except that -an Emacs buffer is used for input and output. - -The command line history can be accessed with M-p and M-n. -The history is saved between sessions. - -Entry to this mode calls the functions in the variables -`comint-mode-hook' and `erlang-shell-mode-hook' with no arguments. - -The following commands imitate the usual Unix interrupt and -editing control characters: -\\{erlang-shell-mode-map} - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil nil ("erlang-pkg.el") (20941 53852 201917 0)) - -;;;*** - -(provide 'erlang-autoloads) -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; coding: utf-8 -;; End: -;;; erlang-autoloads.el ends here diff --git a/emacs.d/elpa/erlang-2.4.1/erlang-pkg.el b/emacs.d/elpa/erlang-2.4.1/erlang-pkg.el deleted file mode 100644 index 1ba978c..0000000 --- a/emacs.d/elpa/erlang-2.4.1/erlang-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "erlang" "2.4.1" "Major modes for editing and running Erlang" (quote nil)) diff --git a/emacs.d/elpa/erlang-2.4.1/erlang-pkg.elc b/emacs.d/elpa/erlang-2.4.1/erlang-pkg.elc deleted file mode 100644 index 620df07..0000000 Binary files a/emacs.d/elpa/erlang-2.4.1/erlang-pkg.elc and /dev/null differ diff --git a/emacs.d/elpa/erlang-2.4.1/erlang.el b/emacs.d/elpa/erlang-2.4.1/erlang.el deleted file mode 100644 index 54e9540..0000000 --- a/emacs.d/elpa/erlang-2.4.1/erlang.el +++ /dev/null @@ -1,5449 +0,0 @@ -;;; erlang.el --- Major modes for editing and running Erlang - -;; Copyright (C) 1995-1998,2000 Ericsson Telecom AB - -;; Author: Anders Lindgren -;; Version: 2.4.1 -;; Keywords: erlang, languages, processes -;; Date: 2000-09-11 - -;; Lars Thorsýn's modifications of 2000-06-07 included. - -;; The original version of this package was written by Robert Virding. -;; -;; Most skeletons has been written at Ericsson Telecom by -;; magnus@erix.ericsson.se and janne@erix.ericsson.se - -;;; Commentary: - -;; Introduction: -;; ------------ -;; -;; This package provides support for the programming language Erlang. -;; The package provides an editing mode with lots of bells and -;; whistles, compilation support, and it makes it possible for the -;; user to start Erlang shells that run inside Emacs. -;; -;; See the Erlang distribution for full documentation of this package. - -;; Installation: -;; ------------ -;; -;; Place this file in Emacs load path, byte-compile it, and add the -;; following line to the appropriate init file: -;; -;; (require 'erlang-start) -;; -;; The full documentation contains much more extensive description of -;; the installation procedure. - -;; Reporting Bugs: -;; -------------- -;; -;; Please send bug reports to the following email address: -;; support@erlang.ericsson.se -;; -;; Please state as exactly as possible: -;; - Version number of Erlang Mode (see the menu), Emacs, Erlang, -;; and of any other relevant software. -;; - What the expected result was. -;; - What you did, preferably in a repeatable step-by-step form. -;; - A description of the unexpected result. -;; - Relevant pieces of Erlang code causing the problem. -;; - Personal Emacs customisations, if any. -;; -;; Should the Emacs generate an error, please set the emacs variable -;; `debug-on-error' to `t'. Repeat the error and enclose the debug -;; information in your bug-report. -;; -;; To set the variable you can use the following command: -;; M-x set-variable RET debug-on-error RET t RET - -;;; Code: - -;; Variables: - -(defconst erlang-version "2.4.1" - "The version number of Erlang mode.") - -(defvar erlang-root-dir nil - "The directory where the Erlang system is installed. -The name should not contain the ending slash. - -Should this variable be nil, no manual pages will show up in the -Erlang mode menu.") - -(defvar erlang-menu-items '(erlang-menu-base-items - erlang-menu-skel-items - erlang-menu-shell-items - erlang-menu-compile-items - erlang-menu-man-items - erlang-menu-personal-items - erlang-menu-version-items) - "*List of menu item list to combine to create Erland mode menu. - -External programs which temporary adds menu items to the Erland mode -menu use this variable. Please use the function `add-hook' to add -items. - -Please call the function `erlang-menu-init' after every change to this -variable.") - -(defvar erlang-menu-base-items - '(("Indent" - (("Indent Line" erlang-indent-command) - ("Indent Region " erlang-indent-region - (if erlang-xemacs-p (mark) mark-active)) - ("Indent Clause" erlang-indent-clause) - ("Indent Function" erlang-indent-function) - ("Indent Buffer" erlang-indent-current-buffer))) - ("Edit" - (("Fill Comment" erlang-fill-paragraph) - ("Comment Region" comment-region - (if erlang-xemacs-p (mark) mark-active)) - ("Uncomment Region" erlang-uncomment-region - (if erlang-xemacs-p (mark) mark-active)) - nil - ("Beginning of Function" erlang-beginning-of-function) - ("End of Function" erlang-end-of-function) - ("Mark Function" erlang-mark-function) - nil - ("Beginning of Clause" erlang-beginning-of-clause) - ("End of Clause" erlang-end-of-clause) - ("Mark Clause" erlang-mark-clause) - nil - ("New Clause" erlang-generate-new-clause) - ("Clone Arguments" erlang-clone-arguments))) - ("Syntax Highlighting" - (("Level 3" erlang-font-lock-level-3) - ("Level 2" erlang-font-lock-level-2) - ("Level 1" erlang-font-lock-level-1) - ("Off" erlang-font-lock-level-0))) - ("TAGS" - (("Find Tag" find-tag) - ("Find Next Tag" erlang-find-next-tag) - ;("Find Regexp" find-tag-regexp) - ("Complete Word" erlang-complete-tag) - ("Tags Apropos" tags-apropos) - ("Search Files" tags-search)))) - "*Description of menu used in Erlang mode. - -This variable must be a list. The elements are either nil representing -a horisontal line or a list with two or three elements. The first is -the name of the menu item, the second is the function to call, or a -submenu, on the same same form as ITEMS. The third optional argument -is an expression which is evaluated every time the menu is displayed. -Should the expression evaluate to nil the menu item is ghosted. - -Example: - '((\"Func1\" function-one) - (\"SubItem\" - ((\"Yellow\" function-yellow) - (\"Blue\" function-blue))) - nil - (\"Region Funtion\" spook-function midnight-variable)) - -Call the function `erlang-menu-init' after modifying this variable.") - -(defvar erlang-menu-shell-items - '(nil - ("Shell" - (("Start New Shell" erlang-shell) - ("Display Shell" erlang-shell-display)))) - "*Description of the Shell menu used by Erlang mode. - -Please see the documentation of `erlang-menu-base-items'.") - -(defvar erlang-menu-compile-items - '(("Compile" - (("Compile Buffer" erlang-compile) - ("Display Result" erlang-compile-display) - ("Next Error" erlang-next-error)))) - "*Description of the Compile menu used by Erlang mode. - -Please see the documentation of `erlang-menu-base-items'.") - -(defvar erlang-menu-version-items - '(nil - ("Version" erlang-version)) - "*Description of the version menu used in Erlang mode.") - -(defvar erlang-menu-personal-items nil - "*Description of personal menu items used in Erlang mode. - -Please see the variable `erlang-menu-base-items' for a description -of the format.") - -(defvar erlang-menu-man-items nil - "The menu containing man pages. - -The format of the menu should be compatible with `erlang-menu-base-items'. -This variable is added to the list of Erlang menus stored in -`erlang-menu-items'.") - -(defvar erlang-menu-skel-items '() - "Description of the menu containing the skeleton entries. -The menu is in the form described by the variable `erlang-menu-base-items'.") - -(defvar erlang-mode-hook nil - "*Functions to run when Erlang mode is activated. - -This hook is used to change the behaviour of Erlang mode. It is -normally used by the user to personalise the programming environment. -When used in a site init file, it could be used to customise Erlang -mode for all users on the system. - -The functions added to this hook is runed every time Erlang mode is -started. See also `erlang-load-hook', a hook which is runed once, -when Erlang mode is loaded into Emacs, and `erlang-shell-mode-hook' -which is run every time a new inferior Erlang shell is started. - -To use a hook, create an Emacs lisp function to perform your actions -and add the function to the hook by calling `add-hook'. - -The following example binds the key sequence C-c C-c to the command -`erlang-compile' (normally bound to C-c C-k). The example also -activates Font Lock mode to fontify the buffer and adds a menu -containing all functions defined in the current buffer. - -To use the example, copy the following lines to your `~/.emacs' file: - - (add-hook 'erlang-mode-hook 'my-erlang-mode-hook) - - (defun my-erlang-mode-hook () - (local-set-key \"\\C-c\\C-c\" 'erlang-compile) - (if window-system - (progn - (setq font-lock-maximum-decoration t) - (font-lock-mode 1))) - (if (and window-system (fboundp 'imenu-add-to-menubar)) - (imenu-add-to-menubar \"Imenu\")))") - -(defvar erlang-load-hook nil - "*Functions to run when Erlang mode is loaded. - -This hook is used to change the behaviour of Erlang mode. It is -normally used by the user to personalise the programming environment. -When used in a site init file, it could be used to customize Erlang -mode for all users on the system. - -The difference between this hook and `erlang-mode-hook' and -`erlang-shell-mode-hook' is that the functions in this hook -is only called once, when the Erlang mode is loaded into Emacs -the first time. - -Natural actions for the functions added to this hook are actions which -only should be performed once, and actions which should be performed -before starting Erlang mode. For example, a number of variables are -used by Erlang mode before `erlang-mode-hook' is runed. - -The following example sets the variable `erlang-root-dir' so that the -manual pages can be retrieved (note that you must set the value of -`erlang-root-dir' to match the loation of Erlang on your system): - - (add-hook 'erlang-load-hook 'my-erlang-load-hook) - - (defun my-erlang-load-hook () - (setq erlang-root-dir \"/usr/local/erlang\"))") - -(defvar erlang-new-file-hook nil - "Functions to run when a new Erlang source file is being edited. - -A useful function is `tempo-template-erlang-normal-header'. -\(This function only exists when the `tempo' packags is available.)") - -(defvar erlang-check-module-name 'ask - "*Non-nil means check that module name and file name agrees when saving. - -If the value of this variable is the atom `ask', the user is -prompted. If the value is t the source is silently changed.") - -(defvar erlang-electric-commands - '(erlang-electric-comma - erlang-electric-semicolon - erlang-electric-gt) - "*List of activated electric commands. - -The list should contain the electric commands which should be active. -Currently, the available electric commands are: - erlang-electric-comma - erlang-electric-semicolon - erlang-electric-gt - erlang-electric-newline - -Should the variable be bound to t, all electric commands -are activated. - -To deactivate all electric commands, set this variable to nil.") - -(defvar erlang-electric-newline-inhibit t - "*Set to non-nil to inhibit newline after electric command. - -This is useful since a lot of people press return after executing an -electric command. - -In order to work, the command must also be in the -list `erlang-electric-newline-inhibit-list'. - -Note that commands in this list are required to set the variable -`erlang-electric-newline-inhibit' to nil when the newline shouldn't be -inhibited.") - -(defvar erlang-electric-newline-inhibit-list - '(erlang-electric-semicolon - erlang-electric-comma - erlang-electric-gt) - "*Command which can inhibit the next newline.") - -(defvar erlang-electric-semicolon-insert-blank-lines nil - "*Number of blank lines inserted before header, or nil. - -This variable controls the behaviour of `erlang-electric-semicolon' -when a new function header is generated. When nil, no blank line is -inserted between the current line and the new header. When bound to a -number it represents the number of blank lines which should be -inserted.") - -(defvar erlang-electric-semicolon-criteria - '(erlang-next-lines-empty-p - erlang-at-keyword-end-p - erlang-at-end-of-function-p) - "*List of functions controlling `erlang-electric-semicolon'. -The functions in this list are called, in order, whenever a semicolon -is typed. Each function in the list is called with no arguments, -and should return one of the following values: - - nil -- no determination made, continue checking - 'stop -- do not create prototype for next line - (anything else) -- insert prototype, and stop checking - -If every function in the list is called with no determination made, -then no prototype is inserted. - -The test is performed by the function `erlang-test-criteria-list'.") - -(defvar erlang-electric-comma-criteria - '(erlang-stop-when-inside-argument-list - erlang-stop-when-at-guard - erlang-next-lines-empty-p - erlang-at-keyword-end-p - erlang-at-end-of-function-p) - "*List of functions controlling `erlang-electric-comma'. -The functions in this list are called, in order, whenever a comma -is typed. Each function in the list is called with no arguments, -and should return one of the following values: - - nil -- no determination made, continue checking - 'stop -- do not create prototype for next line - (anything else) -- insert prototype, and stop checking - -If every function in the list is called with no determination made, -then no prototype is inserted. - -The test is performed by the function `erlang-test-criteria-list'.") - -(defvar erlang-electric-arrow-criteria - '(erlang-next-lines-empty-p - erlang-at-end-of-function-p) - "*List of functions controlling the arrow aspect of `erlang-electric-gt'. -The functions in this list are called, in order, whenever a `>' -is typed. Each function in the list is called with no arguments, -and should return one of the following values: - - nil -- no determination made, continue checking - 'stop -- do not create prototype for next line - (anything else) -- insert prototype, and stop checking - -If every function in the list is called with no determination made, -then no prototype is inserted. - -The test is performed by the function `erlang-test-criteria-list'.") - -(defvar erlang-electric-newline-criteria - '(t) - "*List of functions controlling `erlang-electric-newline'. - -The electric newline commands indents the next line. Should the -current line begin with a comment the comment start is copied to -the newly created line. - -The functions in this list are called, in order, whenever a comma -is typed. Each function in the list is called with no arguments, -and should return one of the following values: - - nil -- no determination made, continue checking - 'stop -- do not create prototype for next line - (anything else) -- trigger the electric command. - -If every function in the list is called with no determination made, -then no prototype is inserted. Should the atom t be a member of the -list, it is treated as a function triggering the electric command. - -The test is performed by the function `erlang-test-criteria-list'.") - -(defvar erlang-next-lines-empty-threshold 2 - "*Number of blank lines required to activate an electric command. - -Actually, this value controls the behaviour of the function -`erlang-next-lines-empty-p' which normally is a member of the -criteria lists controlling the electric commands. (Please see -the variables `erlang-electric-semicolon-criteria' and -`erlang-electric-comma-criteria'.) - -The variable is bound to a threshold value, a number, representing the -number of lines which must be empty. - -Setting this variable to zero, electric commands will always be -triggered by `erlang-next-lines-empty-p', unless inhibited by other -rules. - -Should this variable be `nil', `erlang-next-lines-empty-p' will never -trigger an electric command. The same effect would be reached if the -function `erlang-next-lines-empty-p' would be removed from the criteria -lists. - -Note that even if `erlang-next-lines-empty-p' should not trigger an -electric command, other functions in the criteria list could.") - -(defvar erlang-new-clause-with-arguments nil - "*Non-nil means that the arguments are cloned when a clause is generated. - -A new function header can be generated by calls to the function -`erlang-generate-new-clause' and by use of the electric semicolon.") - -(defvar erlang-compile-use-outdir t - "*When nil, go to the directory containing source file when compiling. - -This is a workaround for a bug in the `outdir' option of compile. If the -outdir is not in the current load path, Erlang doesn't load the object -module after it has been compiled. - -To activate the workaround, place the following in your `~/.emacs' file: - (setq erlang-compile-use-outdir nil)") - -(defvar erlang-indent-level 4 - "*Indentation of Erlang calls/clauses within blocks.") - -(defvar erlang-indent-guard 2 - "*Indentation of Erlang guards.") - -(defvar erlang-argument-indent 2 - "*Indentation of the first argument in a function call. -When nil, indent to the column after the `(' of the -function.") - -(defvar erlang-tab-always-indent t - "*Non-nil means TAB in Erlang mode should always reindent the current line, -regardless of where in the line point is when the TAB command is used.") - -(defvar erlang-error-regexp-alist - '(("^\\([^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)[:) \t]" . (1 2))) - "*Patterns for matching Erlang errors.") - -(defvar erlang-man-inhibit (eq system-type 'windows-nt) - "Inhibit the creation of the Erlang Manual Pages menu. - -The Windows distribution of Erlang does not include man pages, hence -there is no idea to create the menu.") - -(defvar erlang-man-dirs - '(("Man - Commands" "/man/man1" t) - ("Man - Modules" "/man/man3" t) - ("Man - Unsupported" "/uc/man/man3" t)) - "*The man directories displayed in the Erlang menu. - -Each item in the list should be a list with three elements, the first -the name of the menu, the second the directory, and the last a flag. -Should the flag the nil, the directory is absolute, should it be non-nil -the directory is relative to the variable `erlang-root-dir'.") - -(defvar erlang-man-max-menu-size 20 - "*The maximum number of menu items in one menu allowed.") - -(defvar erlang-man-display-function 'erlang-man-display - "*Function used to display man page. - -The function is called with one argument, the name of the file -containing the man page. Use this variable when the default -function, erlang-man-display, does not work on your system.") - -(defconst erlang-atom-regexp "\\([a-z][a-zA-Z0-9_]*\\|'[^\n']*[^\\]'\\)" - "Regexp which should match an Erlang atom. - -The regexp must be surrounded with a pair of regexp parentheses.") -(defconst erlang-atom-regexp-matches 1 - "Number of regexp parenthesis pairs in `erlang-atom-regexp'. - -This is used to determine parenthesis matches in complex regexps which -contains `erlang-atom-regexp'.") - -(defconst erlang-variable-regexp "\\([A-Z_][a-zA-Z0-9_]*\\)" - "Regexp which should match an Erlang variable. - -The regexp must be surrounded with a pair of regexp parenthesis.") -(defconst erlang-variable-regexp-matches 1 - "Number of regexp parenthesis pairs in `erlang-variable-regexp'. - -This is used to determine matches in complex rexeps which contains -`erlang-variable-regexp'.") - -(defvar erlang-defun-prompt-regexp (concat "^" erlang-atom-regexp "\\s *(") - "*Regexp which should match beginning of a clause.") - -(defvar erlang-file-name-extension-regexp "\\.[eh]rl$" - "*Regexp which should match an erlang file name. - -This regexp is used when an Erlang module name is extracted from the -name of an Erlang source file. - -The regexp should only match the section of the file name which should -be excluded from the module name. - -To match all files set this variable to \"\\\\(\\\\..*\\\\|\\\\)$\". -The matches all except the extension. This is useful if the Erlang -tags system should interpretate tags on the form `module:tag' for -files written in other languages than Erlang.") - -(defvar erlang-mode-map nil - "*Keymap used in Erlang mode.") -(defvar erlang-mode-abbrev-table nil - "Abbrev table in use in Erlang-mode buffers.") -(defvar erlang-mode-syntax-table nil - "Syntax table in use in Erlang-mode buffers.") - -(defconst erlang-emacs-major-version - (if (boundp 'emacs-major-version) - emacs-major-version - (string-match "\\([0-9]+\\)\\.\\([0-9]+\\)" emacs-version) - (string-to-int (substring emacs-version - (match-beginning 1) (match-end 1)))) - "Major version number of Emacs.") - -(defconst erlang-emacs-minor-version - (if (boundp 'emacs-minor-version) - emacs-minor-version - (string-match "\\([0-9]+\\)\\.\\([0-9]+\\)" emacs-version) - (string-to-int (substring emacs-version - (match-beginning 2) (match-end 2)))) - "Minor version number of Emacs.") - -(defconst erlang-xemacs-p (string-match "Lucid\\|XEmacs" emacs-version) - "Non-nil when running under XEmacs or Lucid Emacs.") - -(defvar erlang-xemacs-popup-menu '("Erlang Mode Commands" . nil) - "Common popup menu for all buffers in Erlang mode. - -This variable is destructively modified every time the Erlang menu -is modified. The effect is that all changes take effekt in all -buffers in Erlang mode, just like under GNU Emacs. - -Never EVER set this variable!") - - -;; Tempo skeleton templates: - -(defvar erlang-skel - '(("If" "if" erlang-skel-if) - ("Case" "case" erlang-skel-case) - ("Receive" "receive" erlang-skel-receive) - ("Receive After" "after" erlang-skel-receive-after) - ("Receive Loop" "loop" erlang-skel-receive-loop) - ("Module" "module" erlang-skel-module) - ("Author" "author" erlang-skel-author) - () - ("Small Header" "small-header" - erlang-skel-small-header erlang-skel-header) - ("Normal Header" "normal-header" - erlang-skel-normal-header erlang-skel-header) - ("Large Header" "large-header" - erlang-skel-large-header erlang-skel-header) - () - ("Small Server" "small-server" - erlang-skel-small-server erlang-skel-header) - () - ("Application" "application" - erlang-skel-application erlang-skel-header) - ("Supervisor" "supervisor" - erlang-skel-supervisor erlang-skel-header) - ("supervisor_bridge" "supervisor-bridge" - erlang-skel-supervisor-bridge erlang-skel-header) - ("gen_server" "generic-server" - erlang-skel-generic-server erlang-skel-header) - ("gen_event" "gen-event" - erlang-skel-gen-event erlang-skel-header) - ("gen_fsm" "gen-fsm" - erlang-skel-gen-fsm erlang-skel-header) - ("Library module" "gen-lib" - erlang-skel-lib erlang-skel-header) - ("Corba callback" "gen-corba-cb" - erlang-skel-corba-callback erlang-skel-header)) - "*Description of all skeletons templates. -Both functions and menu entries will be created. - -Each entry in `erlang-skel' should be a list with three or four -elements, or the empty list. - -The first element is the name which shows up in the menu. The second -is the `tempo' identfier (The string \"erlang-\" will be added in -front of it). The third is the skeleton descriptor, a variable -containing `tempo' attributes as described in the function -`tempo-define-template'. The optional fourth elements denotes a -function which should be called when the menu is selected. - -Functions corresponding to every template will be created. The name -of the function will be `tempo-template-erlang-X' where `X' is the -tempo identifier as specified in the second argument of the elements -in this list. - -A list with zero elements means that the a horisontal line should -be placed in the menu.") - -;; In XEmacs `user-mail-address' returns "x@y.z (Foo Bar)" ARGH! -;; What's wrong with that? RFC 822 says it's legal. [sverkerw] -(defvar erlang-skel-mail-address - (concat (user-login-name) "@" - (or (and (boundp 'mail-host-address) - (symbol-value 'mail-host-address)) - (system-name))) - "Mail address of the user.") - -;; Expression templates: -(defvar erlang-skel-case - '((erlang-skel-skip-blank) o > - "case " p " of" n> p "_ ->" n> p "ok" n> "end" p) - "*The skeleton of a `case' expression. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-if - '((erlang-skel-skip-blank) o > - "if" n> p " ->" n> p "ok" n> "end" p) - "The skeleton of an `if' expression. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-receive - '((erlang-skel-skip-blank) o > - "receive" n> p "_ ->" n> p "ok" n> "end" p) - "*The skeleton of a `receive' expression. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-receive-after - '((erlang-skel-skip-blank) o > - "receive" n> p "_ ->" n> p "ok" n> "after " p "T ->" n> - p "ok" n> "end" p) - "*The skeleton of a `receive' expression with an `after' clause. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-receive-loop - '(& o "loop(" p ") ->" n> "receive" n> p "_ ->" n> - "loop(" p ")" n> "end.") - "*The skeleton of a simple `recieve' loop. -Please see the function `tempo-define-template'.") - - -;; Attribute templates - -(defvar erlang-skel-module - '(& "-module(" - (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) - ")." n) - "*The skeleton of a `module' attribute. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-author - '(& "-author('" erlang-skel-mail-address "')." n) - "*The skeleton of a `author' attribute. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-vc nil - "*The skeleton template to generate a version control attribute. -The default is to insert nothing. Example of usage: - - (setq erlang-skel-vc '(& \"-rcs(\\\"$\Id: $ \\\").\") n) - -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-export - '(& "-export([" n> "])." n) - "*The skeleton of an `export' attribute. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-import - '(& "%%-import(Module, [Function/Arity, ...])." n) - "*The skeleton of an `import' attribute. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-compile nil - ;; '(& "%%-compile(export_all)." n) - "*The skeleton of a `compile' attribute. -Please see the function `tempo-define-template'.") - - -;; Comment templates. - -(defvar erlang-skel-date-function 'erlang-skel-dd-mmm-yyyy - "*Function which returns date string. -Look in the module `time-stamp' for a battery of functions.") - -(defvar erlang-skel-copyright-comment '() - "*The template for a copyright line in the header, normally empty. -This variable should be bound to a `tempo' template, for example: - '(& \"%%% Copyright (C) 2000, Yoyodyne, Inc.\" n) - -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-created-comment - '(& "%%% Created : " (funcall erlang-skel-date-function) " by " - (user-full-name) " <" erlang-skel-mail-address ">" n) - "*The template for the \"Created:\" comment line.") - -(defvar erlang-skel-author-comment - '(& "%%% Author : " (user-full-name) " <" erlang-skel-mail-address ">" n) - "*The template for creating the \"Author:\" line in the header. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-file-comment - '(& "%%% File : " (file-name-nondirectory buffer-file-name) n) - "*The template for creating the \"Module:\" line in the header. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-small-header - '(o (erlang-skel-include erlang-skel-module) - ;; erlang-skel-author) - n - (erlang-skel-include erlang-skel-compile - ;; erlang-skel-export - erlang-skel-vc)) - "*The template of a small header without any comments. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-normal-header - '(o (erlang-skel-include erlang-skel-copyright-comment - erlang-skel-file-comment - erlang-skel-author-comment) - "%%% Description : " p n - (erlang-skel-include erlang-skel-created-comment) n - (erlang-skel-include erlang-skel-small-header) n) - "*The template of a normal header. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-large-header - '(o (erlang-skel-separator) - (erlang-skel-include erlang-skel-copyright-comment - erlang-skel-file-comment - erlang-skel-author-comment) - "%%% Description : " p n - "%%%" n - (erlang-skel-include erlang-skel-created-comment) - (erlang-skel-separator) - (erlang-skel-include erlang-skel-small-header) ) - "*The template of a large header. -Please see the function `tempo-define-template'.") - - -;; Server templates. - -(defvar erlang-skel-small-server - '((erlang-skel-include erlang-skel-large-header) - "-export([start/0,init/1])." n n n - "start() ->" n> "spawn(" (erlang-get-module-from-file-name) - ", init, [self()])." n n - "init(From) ->" n> - "loop(From)." n n - "loop(From) ->" n> - "receive" n> - p "_ ->" n> - "loop(From)" n> - "end." - ) - "*Template of a small server. -Please see the function `tempo-define-template'.") - -;; Behaviour templates. - -(defvar erlang-skel-application - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(application)." n - (erlang-skel-separator 2) - "%% Include files" n - (erlang-skel-separator 2) - n - (erlang-skel-separator 2) - "%% External exports" n - (erlang-skel-separator 2) - "-export([" n> "start/2," n> - "stop/1" n - " ])." n - n - (erlang-skel-separator 2) - "%% Internal exports" n - (erlang-skel-separator 2) - "-export([" n - " ])." n - n - (erlang-skel-separator 2) - "%% Macros" n - (erlang-skel-separator 2) - n - (erlang-skel-separator 2) - "%% Records" n - (erlang-skel-separator 2) - n - (erlang-skel-double-separator 2) - "%% External functions" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Func: start/2" n - "%% Returns: {ok, Pid} |" n - "%% {ok, Pid, State} |" n - "%% {error, Reason} " n - (erlang-skel-separator 2) - "start(Type, StartArgs) ->" n> - "case 'TopSupervisor':start_link(StartArgs) of" n> - "{ok, Pid} -> " n> - "{ok, Pid};" n> - "Error ->" n> - "Error" n> - "end." n - n - (erlang-skel-separator 2) - "%% Func: stop/1" n - "%% Returns: any "n - (erlang-skel-separator 2) - "stop(State) ->" n> - "ok." n - n - (erlang-skel-double-separator 2) - "%% Internal functions" n - (erlang-skel-double-separator 2) - ) - "*The template of an application behaviour. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-supervisor - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(supervisor)." n - (erlang-skel-separator 2) - "%% Include files" n - (erlang-skel-separator 2) - n - (erlang-skel-separator 2) - "%% External exports" n - (erlang-skel-separator 2) - "-export([" n> "start_link/0" n - " ])." n - n - (erlang-skel-separator 2) - "%% Internal exports" n - (erlang-skel-separator 2) - "-export([" n> "init/1" n - " ])." n - n - (erlang-skel-separator 2) - "%% Macros" n - (erlang-skel-separator 2) - "-define(SERVER, ?MODULE)." n - n - (erlang-skel-separator 2) - "%% Records" n - (erlang-skel-separator 2) - n - (erlang-skel-double-separator 2) - "%% External functions" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: start_link/0" n - "%% Description: Starts the supervisor" n - (erlang-skel-separator 2) - "start_link() ->" n> - "supervisor:start_link({local, ?SERVER}, ?MODULE, [])." n - n - (erlang-skel-double-separator 2) - "%% Server functions" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Func: init/1" n - "%% Returns: {ok, {SupFlags, [ChildSpec]}} |" n - "%% ignore |" n - "%% {error, Reason} " n - (erlang-skel-separator 2) - "init([]) ->" n> - "AChild = {'AName',{'AModule',start_link,[]}," n> - "permanent,2000,worker,['AModule']}," n> - "{ok,{{one_for_all,0,1}, [AChild]}}." n - n - (erlang-skel-double-separator 2) - "%% Internal functions" n - (erlang-skel-double-separator 2) - ) - "*The template of an supervisor behaviour. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-supervisor-bridge - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(supervisor_bridge)." n - (erlang-skel-separator 2) - "%% Include files" n - (erlang-skel-separator 2) - n - (erlang-skel-separator 2) - "%% External exports" n - (erlang-skel-separator 2) - "-export([" n> "start_link/0" n - " ])." n - n - (erlang-skel-separator 2) - "%% Internal exports" n - (erlang-skel-separator 2) - "-export([" n> "init/1, " n> "terminate/2" n - " ])." n - n - (erlang-skel-separator 2) - "%% Macros" n - (erlang-skel-separator 2) - "-define(SERVER, ?MODULE)." n - n - (erlang-skel-separator 2) - "%% Records" n - (erlang-skel-separator 2) - "-record(state, {})." n - n - (erlang-skel-double-separator 2) - "%% External functions" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: start_link/0" n - "%% Description: Starts the supervisor bridge" n - (erlang-skel-separator 2) - "start_link() ->" n> - "supervisor_bridge:start_link({local, ?SERVER}, ?MODULE, [])." n - n - (erlang-skel-double-separator 2) - "%% Server functions" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Func: init/1" n - "%% Returns: {ok, Pid, State} |" n - "%% ignore |" n - "%% {error, Reason} " n - (erlang-skel-separator 2) - "init([]) ->" n> - "case 'AModule':start_link() of" n> - "{ok, Pid} ->" n> - "{ok, Pid, #state{}};" n> - "Error ->" n> - "Error" n> - "end." n - n - (erlang-skel-separator 2) - "%% Func: terminate/2" n - "%% Purpose: Synchronized shutdown of the underlying sub system." n - "%% Returns: any" n - (erlang-skel-separator 2) - "terminate(Reason, State) ->" n> - "'AModule':stop()," n> - "ok." n - n - (erlang-skel-double-separator 2) - "%% Internal functions" n - (erlang-skel-double-separator 2) - ) - "*The template of an supervisor_bridge behaviour. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-generic-server - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(gen_server)." n - (erlang-skel-separator 2) - "%% Include files" n - (erlang-skel-separator 2) - n - (erlang-skel-separator 2) - "%% External exports" n - "-export([start_link/0])." n - n - "%% gen_server callbacks" n - "-export([init/1, handle_call/3, handle_cast/2, " - "handle_info/2, terminate/2, code_change/3])." n n - "-record(state, {})." n - n - (erlang-skel-double-separator 2) - "%% External functions" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: start_link/0" n - "%% Description: Starts the server" n - (erlang-skel-separator 2) - "start_link() ->" n> - "gen_server:start_link({local, ?SERVER}, ?MODULE, [], [])." n - n - (erlang-skel-double-separator 2) - "%% Server functions" n - (erlang-skel-double-separator 2) - n - (erlang-skel-separator 2) - "%% Function: init/1" n - "%% Description: Initiates the server" n - "%% Returns: {ok, State} |" n - "%% {ok, State, Timeout} |" n - "%% ignore |" n - "%% {stop, Reason}" n - (erlang-skel-separator 2) - "init([]) ->" n> - "{ok, #state{}}." n - n - (erlang-skel-separator 2) - "%% Function: handle_call/3" n - "%% Description: Handling call messages" n - "%% Returns: {reply, Reply, State} |" n - "%% {reply, Reply, State, Timeout} |" n - "%% {noreply, State} |" n - "%% {noreply, State, Timeout} |" n - "%% {stop, Reason, Reply, State} | (terminate/2 is called)" n - "%% {stop, Reason, State} (terminate/2 is called)" n - (erlang-skel-separator 2) - "handle_call(Request, From, State) ->" n> - "Reply = ok," n> - "{reply, Reply, State}." n - n - (erlang-skel-separator 2) - "%% Function: handle_cast/2" n - "%% Description: Handling cast messages" n - "%% Returns: {noreply, State} |" n - "%% {noreply, State, Timeout} |" n - "%% {stop, Reason, State} (terminate/2 is called)" n - (erlang-skel-separator 2) - "handle_cast(Msg, State) ->" n> - "{noreply, State}." n - n - (erlang-skel-separator 2) - "%% Function: handle_info/2" n - "%% Description: Handling all non call/cast messages" n - "%% Returns: {noreply, State} |" n - "%% {noreply, State, Timeout} |" n - "%% {stop, Reason, State} (terminate/2 is called)" n - (erlang-skel-separator 2) - "handle_info(Info, State) ->" n> - "{noreply, State}." n - n - (erlang-skel-separator 2) - "%% Function: terminate/2" n - "%% Description: Shutdown the server" n - "%% Returns: any (ignored by gen_server)" n - (erlang-skel-separator 2) - "terminate(Reason, State) ->" n> - "ok." n - n - (erlang-skel-separator 2) - "%% Func: code_change/3" n - "%% Purpose: Convert process state when code is changed" n - "%% Returns: {ok, NewState}" n - (erlang-skel-separator 2) - "code_change(OldVsn, State, Extra) ->" n> - "{ok, State}." n - n - (erlang-skel-separator 2) - "%%% Internal functions" n - (erlang-skel-separator 2) - ) - "*The template of a generic server. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-gen-event - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(gen_event)." n - (erlang-skel-separator 2) - "%% Include files" n - (erlang-skel-separator 2) - n - (erlang-skel-separator 2) - "%% External exports" n - "-export([start_link/0, add_handler/0])." n - n - "%% gen_event callbacks" n - "-export([init/1, handle_event/2, handle_call/2, " - "handle_info/2, terminate/2, code_change/3])." n n - "-record(state, {})." n - n - (erlang-skel-double-separator 2) - "%% External functions" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: start_link/0" n - "%% Description: Starts the server" n - (erlang-skel-separator 2) - "start_link() ->" n> - "gen_event:start_link({local, ?SERVER}). " n - n - (erlang-skel-separator 2) - "%% Function: add_handler/0" n - "%% Description: Adds an event handler" n - (erlang-skel-separator 2) - "add_handler() ->" n> - "gen_event:add_handler(?SERVER, ?MODULE, [])." n - n - (erlang-skel-double-separator 2) - "%% Server functions" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Func: init/1" n - "%% Returns: {ok, State} |" n - "%% Other" n - (erlang-skel-separator 2) - "init([]) ->" n> - "{ok, #state{}}." n - n - (erlang-skel-separator 2) - "%% Func: handle_event/2" n - "%% Returns: {ok, State} |" n - "%% {swap_handler, Args1, State1, Mod2, Args2} |" n - "%% remove_handler " n - (erlang-skel-separator 2) - "handle_event(Event, State) ->" n> - "{ok, State}." n - n - (erlang-skel-separator 2) - "%% Func: handle_call/2" n - "%% Returns: {ok, Reply, State} |" n - "%% {swap_handler, Reply, Args1, State1, Mod2, Args2} |" n - "%% {remove_handler, Reply} " n - (erlang-skel-separator 2) - "handle_call(Request, State) ->" n> - "Reply = ok," n> - "{ok, Reply, State}." n - n - (erlang-skel-separator 2) - "%% Func: handle_info/2" n - "%% Returns: {ok, State} |" n - "%% {swap_handler, Args1, State1, Mod2, Args2} |" n - "%% remove_handler " n - (erlang-skel-separator 2) - "handle_info(Info, State) ->" n> - "{ok, State}." n - n - (erlang-skel-separator 2) - "%% Func: terminate/2" n - "%% Purpose: Shutdown the server" n - "%% Returns: any" n - (erlang-skel-separator 2) - "terminate(Reason, State) ->" n> - "ok." n - n - (erlang-skel-separator 2) - "%% Func: code_change/3" n - "%% Purpose: Convert process state when code is changed" n - "%% Returns: {ok, NewState}" n - (erlang-skel-separator 2) - "code_change(OldVsn, State, Extra) ->" n> - "{ok, State}." n - n - (erlang-skel-separator 2) - "%%% Internal functions" n - (erlang-skel-separator 2) - ) - "*The template of a gen_event. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-gen-fsm - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(gen_fsm)." n - (erlang-skel-separator 2) - "%% Include files" n - (erlang-skel-separator 2) - n - (erlang-skel-separator 2) - "%% External exports" n - "-export([start_link/0])." n - n - "%% gen_fsm callbacks" n - "-export([init/1, state_name/2, state_name/3, handle_event/3," n> - "handle_sync_event/4, handle_info/3, terminate/3, code_change/4])." n n - "-record(state, {})." n - n - (erlang-skel-double-separator 2) - "%% External functions" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: start_link/0" n - "%% Description: Starts the server" n - (erlang-skel-separator 2) - "start_link() ->" n> - "gen_fsm:start_link({local, ?SERVER}, ?MODULE, [], [])." n - n - (erlang-skel-double-separator 2) - "%% Server functions" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Func: init/1" n - "%% Returns: {ok, StateName, StateData} |" n - "%% {ok, StateName, StateData, Timeout} |" n - "%% ignore |" n - "%% {stop, StopReason} " n - (erlang-skel-separator 2) - "init([]) ->" n> - "{ok, state_name, #state{}}." n - n - (erlang-skel-separator 2) - "%% Func: StateName/2" n - "%% Returns: {next_state, NextStateName, NextStateData} |" n - "%% {next_state, NextStateName, NextStateData, Timeout} |" n - "%% {stop, Reason, NewStateData} " n - (erlang-skel-separator 2) - "state_name(Event, StateData) ->" n> - "{next_state, state_name, StateData}." n - n - (erlang-skel-separator 2) - "%% Func: StateName/3" n - "%% Returns: {next_state, NextStateName, NextStateData} |" n - "%% {next_state, NextStateName, NextStateData, Timeout} |" n - "%% {reply, Reply, NextStateName, NextStateData} |" n - "%% {reply, Reply, NextStateName, NextStateData, Timeout} |" n - "%% {stop, Reason, NewStateData} |" n - "%% {stop, Reason, Reply, NewStateData} " n - (erlang-skel-separator 2) - "state_name(Event, From, StateData) ->" n> - "Reply = ok," n> - "{reply, Reply, state_name, StateData}." n - n - (erlang-skel-separator 2) - "%% Func: handle_event/3" n - "%% Returns: {next_state, NextStateName, NextStateData} |" n - "%% {next_state, NextStateName, NextStateData, Timeout} |" n - "%% {stop, Reason, NewStateData} " n - (erlang-skel-separator 2) - "handle_event(Event, StateName, StateData) ->" n> - "{next_state, StateName, StateData}." n - n - (erlang-skel-separator 2) - "%% Func: handle_sync_event/4" n - "%% Returns: {next_state, NextStateName, NextStateData} |" n - "%% {next_state, NextStateName, NextStateData, Timeout} |" n - "%% {reply, Reply, NextStateName, NextStateData} |" n - "%% {reply, Reply, NextStateName, NextStateData, Timeout} |" n - "%% {stop, Reason, NewStateData} |" n - "%% {stop, Reason, Reply, NewStateData} " n - (erlang-skel-separator 2) - "handle_sync_event(Event, From, StateName, StateData) ->" n> - "Reply = ok," n> - "{reply, Reply, StateName, StateData}." n - n - (erlang-skel-separator 2) - "%% Func: handle_info/3" n - "%% Returns: {next_state, NextStateName, NextStateData} |" n - "%% {next_state, NextStateName, NextStateData, Timeout} |" n - "%% {stop, Reason, NewStateData} " n - (erlang-skel-separator 2) - "handle_info(Info, StateName, StateData) ->" n> - "{next_state, StateName, StateData}." n - n - (erlang-skel-separator 2) - "%% Func: terminate/3" n - "%% Purpose: Shutdown the fsm" n - "%% Returns: any" n - (erlang-skel-separator 2) - "terminate(Reason, StateName, StatData) ->" n> - "ok." n - n - (erlang-skel-separator 2) - "%% Func: code_change/4" n - "%% Purpose: Convert process state when code is changed" n - "%% Returns: {ok, NewState, NewStateData}" n - (erlang-skel-separator 2) - "code_change(OldVsn, StateName, StateData, Extra) ->" n> - "{ok, StateName, StateData}." n - n - (erlang-skel-separator 2) - "%%% Internal functions" n - (erlang-skel-separator 2) - ) - "*The template of a gen_fsm. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-lib - '((erlang-skel-include erlang-skel-large-header) - (erlang-skel-separator 2) - "%% Include files" n - (erlang-skel-separator 2) - n - (erlang-skel-separator 2) - "%% External exports" n - (erlang-skel-separator 2) - "-export([" n - " ])." n - n - (erlang-skel-separator 2) - "%% Internal exports" n - (erlang-skel-separator 2) - "-export([" n - " ])." n - n - (erlang-skel-separator 2) - "%% Macros" n - (erlang-skel-separator 2) - n - (erlang-skel-separator 2) - "%% Records" n - (erlang-skel-separator 2) - n - (erlang-skel-double-separator 2) - "%% External functions" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: " n - "%% Description:" n - (erlang-skel-separator 2) - n - (erlang-skel-double-separator 2) - "%% Internal functions" n - (erlang-skel-double-separator 2) - ) - "*The template of a library module. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-corba-callback - '((erlang-skel-include erlang-skel-large-header) - (erlang-skel-separator 2) - "%% Include files" n - (erlang-skel-separator 2) - n - (erlang-skel-separator 2) - "%% External exports" n - (erlang-skel-separator 2) - "-export([" n> "init/1, " n> "terminate/2," n> "code_change/3" n - " ])." n - n - (erlang-skel-separator 2) - "%% Internal exports" n - (erlang-skel-separator 2) - "-export([" n - " ])." n - n - (erlang-skel-separator 2) - "%% Macros" n - (erlang-skel-separator 2) - n - (erlang-skel-separator 2) - "%% Records" n - (erlang-skel-separator 2) - "-record(state, {})." n - n - (erlang-skel-double-separator 2) - "%% External functions" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: init/1" n - "%% Description: Initiates the server" n - "%% Returns: {ok, State} |" n - "%% {ok, State, Timeout} |" n - "%% ignore |" n - "%% {stop, Reason}" n - (erlang-skel-separator 2) - "init([]) ->" n> - "{ok, #state{}}." n - n - (erlang-skel-separator 2) - "%% Function: terminate/2" n - "%% Description: Shutdown the server" n - "%% Returns: any (ignored by gen_server)" n - (erlang-skel-separator 2) - "terminate(Reason, State) ->" n> - "ok." n - n - (erlang-skel-separator 2) - "%% Function: code_change/3" n - "%% Description: Convert process state when code is changed" n - "%% Returns: {ok, NewState}" n - (erlang-skel-separator 2) - "code_change(OldVsn, State, Extra) ->" n> - "{ok, State}." n - n - (erlang-skel-double-separator 2) - "%% Internal functions" n - (erlang-skel-double-separator 2) - ) - "*The template of a library module. -Please see the function `tempo-define-template'.") - - - -;; Font-lock variables - -(defvar erlang-font-lock-modern-p - (cond ((>= erlang-emacs-major-version 20) t) - (erlang-xemacs-p (>= erlang-emacs-minor-version 14)) - ((= erlang-emacs-major-version 19) (>= erlang-emacs-minor-version 29)) - (t nil)) - "Non-nil when this version of Emacs uses a modern version of Font Lock. - -This is determinated by checking the version of Emacs used, the actual -font-lock code is not loaded.") - - -;; The next few variables define different Erlang font-lock patterns. -;; They could be appended to form a custom font-lock appearence. -;; -;; The function `erlang-font-lock-set-face' could be used to change -;; the face of a pattern. -;; -;; Note that Erlang strings and atoms are hightlighted with using -;; syntactix analysis. - -(defvar erlang-font-lock-keywords-func - (list - (list (concat "^" erlang-atom-regexp "\\s *(") - 1 'font-lock-function-name-face t)) - "Font lock keyword highlighting a function header.") - -(defvar erlang-font-lock-keywords-dollar - (list - (list "\\(\\$\\([^\\]\\|\\\\\\([^0-7^\n]\\|[0-7]+\\|\\^[a-zA-Z]\\)\\)\\)" - 1 'font-lock-string-face)) - "Font lock keyword highlighting numbers in ascii-form (e.g. $A).") - -(defvar erlang-font-lock-keywords-arrow - (list - (list "\\(->\\|:-\\)\\(\\s \\|$\\)" 2 'font-lock-function-name-face)) - "Font lock keyword highlighting clause arrow.") - -(defvar erlang-font-lock-keywords-lc - (list - (list "\\(<-\\)\\(\\s \\|$\\)" 1 'font-lock-keyword-face) - (list "\\(||\\)\\(\\s \\|$\\)" 1 'font-lock-keyword-face)) - "Font lock keyword highlighting list comprehension operators.") - -(defvar erlang-font-lock-keywords-keywords - (list - (list (concat "\\<\\(after\\|begin\\|c\\(atch\\|ase\\)\\|end\\|fun\\|if" - "\\|of\\|receive\\|when\\|andalso\\|orelse\\|query\\)\\([^a-zA-Z0-9_]\\|$\\)") - 1 'font-lock-keyword-face)) - "Font lock keyword highlighting Erlang keywords.") - -(defvar erlang-font-lock-keywords-attr - (list - (list (concat "^\\(-" erlang-atom-regexp "\\)\\s *\\(\\.\\|(\\)") - 1 'font-lock-function-name-face)) - "Font lock keyword highlighting attribues.") - -(defvar erlang-font-lock-keywords-quotes - (list - (list "`\\([-+a-zA-Z0-9_:*][-+a-zA-Z0-9_:*]+\\)'" - 1 - (if erlang-font-lock-modern-p - 'font-lock-reference-face - 'font-lock-keyword-face) - t)) - "Font lock keyword highlighting words in single quotes in comments. - -This is not the keyword hightlighting Erlang strings and atoms, they -are highlighted by syntactic analysis.") - -;; Note: The guard `float' collides with the bif `float'. -(defvar erlang-font-lock-keywords-guards - (list - (list - (concat "\\<\\(" - "\\(is_\\)*\\(atom\\|function\\|binary\\|constant\\|float" - "\\|integer\\|list\\|number\\|p\\(id\\|ort\\)\\|" - "re\\(ference\\|cord\\)\\|tuple" - "\\)\\)\\s *(") - - 1 - (if erlang-font-lock-modern-p - 'font-lock-reference-face - 'font-lock-keyword-face))) - "Font lock keyword highlighting guards.") - -(defvar erlang-font-lock-keywords-bifs - (list - (list - (concat - "\\<\\(" - "a\\(bs\\|live\\|pply\\|tom_to_list\\)\\|" - "binary_to_\\(list\\|term\\)\\|" - "concat_binary\\|d\\(ate\\|isconnect_node\\)\\|" - "e\\(lement\\|rase\\|xit\\)\\|" - "float\\(\\|_to_list\\)\\|" - "g\\(arbage_collect\\|et\\(\\|_keys\\)\\|roup_leader\\)\\|" - "h\\(alt\\|d\\)\\|" - "i\\(nte\\(ger_to_list\\|rnal_bif\\)\\|s_alive\\)\\|" - "l\\(ength\\|i\\(nk\\|st_to_\\(atom\\|binary\\|float\\|integer" - "\\|pid\\|tuple\\)\\)\\)\\|" - "make_ref\\|no\\(de\\(\\|_\\(link\\|unlink\\)\\|s\\)\\|talive\\)\\|" - "open_port\\|" - "p\\(id_to_list\\|rocess\\(_\\(flag\\|info\\)\\|es\\)\\|ut\\)\\|" - "r\\(egister\\(\\|ed\\)\\|ound\\)\\|" - "s\\(e\\(lf\\|telement\\)\\|ize\\|" - "p\\(awn\\(\\|_link\\)\\|lit_binary\\)\\|tatistics\\)\\|" - "t\\(erm_to_binary\\|hrow\\|ime\\|l\\|" - "r\\(ace\\|unc\\)\\|uple_to_list\\)\\|" - "un\\(link\\|register\\)\\|whereis" - "\\)\\s *(") - 1 - 'font-lock-keyword-face)) - "Font lock keyword highlighting built in functions.") - -(defvar erlang-font-lock-keywords-macros - (list - (list (concat "?\\s *\\(" erlang-atom-regexp - "\\|" erlang-variable-regexp "\\)\\>") - 1 (if erlang-font-lock-modern-p - 'font-lock-reference-face - 'font-lock-type-face)) - (list (concat "^-\\(define\\|ifn?def\\)\\s *(\\s *\\(" erlang-atom-regexp - "\\|" erlang-variable-regexp "\\)\\>") - 2 (if erlang-font-lock-modern-p - 'font-lock-reference-face - 'font-lock-type-face))) - "Font lock keyword highlighting macros. -This must be placed in front of `erlang-font-lock-keywords-vars'.") - -(defvar erlang-font-lock-keywords-records - (list - (list (concat "#\\s *" erlang-atom-regexp "\\>") - 1 'font-lock-type-face) - ;; Don't highlight numerical constants. - (list "\\<[0-9][0-9]?#\\([0-9a-fA_F]+\\)\\>" - 1 nil t) - (list (concat "^-record(\\s *" erlang-atom-regexp "\\>") - 1 'font-lock-type-face)) - "Font lock keyword highlighting Erlang records. -This must be placed in front of `erlang-font-lock-keywords-vars'.") - -(defvar erlang-font-lock-keywords-vars - (list - (list (concat "\\<" erlang-variable-regexp "\\>") - 1 (if erlang-font-lock-modern-p - 'font-lock-variable-name-face - 'font-lock-type-face))) - "Font lock keyword highlighting Erlang variables. -Must be preceded by `erlang-font-lock-keywords-macros' and `-records' -to work properly.") - - -(defvar erlang-font-lock-keywords-1 - (append erlang-font-lock-keywords-func - erlang-font-lock-keywords-dollar - erlang-font-lock-keywords-arrow - erlang-font-lock-keywords-keywords) - ;; DocStringOrig: erlang-font-lock-keywords - "Font-lock keywords used by Erlang Mode. - -There exists three levels of Font Lock keywords for Erlang: - `erlang-font-lock-keywords-1' - Function headers and reserved keywords. - `erlang-font-lock-keywords-2' - Bifs, guards and `singel quotes'. - `erlang-font-lock-keywords-3' - Variables, macros and records. - -To use a specific level, please set the variable -`font-lock-maximum-decoration' to the appropriate level. Note that the -variable must be set before Erlang mode is activated. - -Example: - (setq font-lock-maximum-decoration 2)") - - -(defvar erlang-font-lock-keywords-2 - (append erlang-font-lock-keywords-1 - erlang-font-lock-keywords-attr - erlang-font-lock-keywords-quotes - erlang-font-lock-keywords-guards - erlang-font-lock-keywords-bifs) - ;; DocStringCopy: erlang-font-lock-keywords - "Font-lock keywords used by Erlang Mode. - -There exists three levels of Font Lock keywords for Erlang: - `erlang-font-lock-keywords-1' - Function headers and reserved keywords. - `erlang-font-lock-keywords-2' - Bifs, guards and `single quotes'. - `erlang-font-lock-keywords-3' - Variables, macros and records. - -To use a specific level, please set the variable -`font-lock-maximum-decoration' to the appropriate level. Note that the -variable must be set before Erlang mode is activated. - -Example: - (setq font-lock-maximum-decoration 2)") - - -(defvar erlang-font-lock-keywords-3 - (append erlang-font-lock-keywords-2 - erlang-font-lock-keywords-macros - erlang-font-lock-keywords-records - erlang-font-lock-keywords-vars) - ;; DocStringCopy: erlang-font-lock-keywords - "Font-lock keywords used by Erlang Mode. - -There exists three levels of Font Lock keywords for Erlang: - `erlang-font-lock-keywords-1' - Function headers and reserved keywords. - `erlang-font-lock-keywords-2' - Bifs, guards and `single quotes'. - `erlang-font-lock-keywords-3' - Variables, macros and records. - -To use a specific level, please set the variable -`font-lock-maximum-decoration' to the appropriate level. Note that the -variable must be set before Erlang mode is activated. - -Example: - (setq font-lock-maximum-decoration 2)") - - -(defvar erlang-font-lock-keywords erlang-font-lock-keywords-3 - ;; DocStringCopy: erlang-font-lock-keywords - "Font-lock keywords used by Erlang Mode. - -There exists three levels of Font Lock keywords for Erlang: - `erlang-font-lock-keywords-1' - Function headers and reserved keywords. - `erlang-font-lock-keywords-2' - Bifs, guards and `single quotes'. - `erlang-font-lock-keywords-3' - Variables, macros and records. - -To use a specific level, please set the variable -`font-lock-maximum-decoration' to the appropriate level. Note that the -variable must be set before Erlang mode is activated. - -Example: - (setq font-lock-maximum-decoration 2)") - - -(defvar erlang-font-lock-syntax-table nil - "Syntax table used by Font Lock mode. - -The difference between this and the standard Erlang Mode -syntax table is that `_' is treated as part of words by -this syntax table. - -Unfortuantely, XEmacs hasn't got support for a special Font -Lock syntax table. The effect is that `apply' in the atom -`foo_apply' will be highlighted as a bif.") - - -;;; Avoid errors while compiling this file. - -;; `eval-when-compile' is not defined in Emacs 18. We define it as a -;; no-op. -(or (fboundp 'eval-when-compile) - (defmacro eval-when-compile (&rest rest) nil)) - -;; These umm...functions are new in Emacs 20. And, yes, until version -;; 19.27 Emacs backquotes were this ugly. - -(or (fboundp 'unless) - (defmacro unless (condition &rest body) - "(unless CONDITION BODY...): If CONDITION is false, do BODY, else return nil." - (` (if (, condition) - nil - (,@ body))))) - -(or (fboundp 'when) - (defmacro when (condition &rest body) - "(when CONDITION BODY...): If CONDITION is true, do BODY, else return nil." - (` (if (, condition) - (progn (,@ body)) - nil)))) - -(or (fboundp 'char-before) - (defmacro char-before (&optional pos) - "Return the character in the current buffer just before POS." - (` (char-after (1- (or (, pos) (point))))))) - -(or (fboundp 'regexp-opt) - (defun regexp-opt (strings &optional paren) - "Return a regular expression that matches any string in -STRINGS. If PAREN is true, it will always enclose the regular -expression in parentheses. - -Unlike its Emacs-20 namesake, it will not optimize the generated -expression." - ;; This stop-gap definition is taken from - ;; _GNU_Emacs_Lisp_Reference_Manual_, ed 2.5, for Emacs 20.3. - (let ((open (if paren "\\(" "")) - (close (if paren "\\)" ""))) - (concat open - (mapconcat 'regexp-quote strings "\\|") - close)))) - -(eval-when-compile - (if (or (featurep 'bytecomp) - (featurep 'byte-compile)) - (progn - (cond ((string-match "Lucid\\|XEmacs" emacs-version) - (put 'comment-indent-hook 'byte-obsolete-variable nil) - ;; Do not warn for unused variables - ;; when compiling under XEmacs. - (setq byte-compile-warnings - '(free-vars unresolved callargs redefine)))) - (require 'comint) - (require 'compile)))) - - -(defun erlang-version () - "Return the current version of Erlang mode." - (interactive) - (if (interactive-p) - (message "Erlang mode version %s, written by Anders Lindgren" - erlang-version)) - erlang-version) - - -;;;###autoload -(defun erlang-mode () - "Major mode for editing Erlang source files in Emacs. -It knows about syntax and comment, it can indent code, it is capable -of fontifying the source file, the TAGS commands are aware of Erlang -modules, and the Erlang man pages can be accessed. - -Should this module, \"erlang.el\", be installed properly, Erlang mode -is activated whenever an Erlang source or header file is loaded into -Emacs. To indicate this, the mode line should contain the word -\"Erlang\". - -The main feature of Erlang mode is indentation, press TAB and the -current line will be indented correctly. - -Comments starting with only one `%' are indented to the column stored -in the variable `comment-column'. Comments starting with two `%':s -are indented with the same indentation as code. Comments starting -with at least three `%':s are indented to the first column. - -However, Erlang mode contains much more, this is a list of the most -useful commands: - TAB - Indent the line. - C-c C-q - Indent current function. - M-; - Create a comment at the end of the line. - M-q - Fill a comment, i.e. wrap lines so that they (hopefully) - will look better. - M-a - Goto the beginning of an Erlang clause. - M-C-a - Ditto for function. - M-e - Goto the end of an Erlang clause. - M-C-e - Ditto for function. - M-h - Mark current Erlang clause. - M-C-h - Ditto for function. - C-c C-z - Start, or switch to, an inferior Erlang shell. - C-c C-k - Compile current file. - C-x ` - Next error. - , - Electric comma. - ; - Electric semicolon. - -Erlang mode check the name of the file against the module name when -saving, whenever a mismatch occurs Erlang mode offers to modify the -source. - -The variable `erlang-electric-commands' controls the electric -commands. To deactivate all of them, set it to nil. - -There exists a large number of commands and variables in the Erlang -module. Please press `M-x apropos RET erlang RET' to see a complete -list. Press `C-h f name-of-function RET' and `C-h v name-of-variable -RET'to see the full description of functions and variables, -respectively. - -On entry to this mode the contents of the hook `erlang-mode-hook' is -executed. - -Please see the beginning of the file `erlang.el' for more information -and examples of hooks. - -Other commands: -\\{erlang-mode-map}" - (interactive) - (kill-all-local-variables) - (setq major-mode 'erlang-mode) - (setq mode-name "Erlang") - (erlang-syntax-table-init) - (erlang-keymap-init) - (erlang-electric-init) - (erlang-menu-init) - (erlang-mode-variables) - (erlang-check-module-name-init) - (erlang-add-compilation-alist erlang-error-regexp-alist) - (erlang-man-init) - (erlang-tags-init) - (erlang-font-lock-init) - (erlang-skel-init) - (run-hooks 'erlang-mode-hook) - (if (zerop (buffer-size)) - (run-hooks 'erlang-new-file-hook))) - - -(defun erlang-syntax-table-init () - (if (null erlang-mode-syntax-table) - (let ((table (make-syntax-table))) - (modify-syntax-entry ?\n ">" table) - (modify-syntax-entry ?\" "\"" table) - (modify-syntax-entry ?# "." table) - (modify-syntax-entry ?$ "/" table) - (modify-syntax-entry ?% "<" table) - (modify-syntax-entry ?& "." table) - (modify-syntax-entry ?\' "\"" table) - (modify-syntax-entry ?* "." table) - (modify-syntax-entry ?+ "." table) - (modify-syntax-entry ?- "." table) - (modify-syntax-entry ?/ "." table) - (modify-syntax-entry ?: "." table) - (modify-syntax-entry ?< "." table) - (modify-syntax-entry ?= "." table) - (modify-syntax-entry ?> "." table) - (modify-syntax-entry ?\\ "\\" table) - (modify-syntax-entry ?_ "_" table) - (modify-syntax-entry ?| "." table) - (modify-syntax-entry ?^ "/" table) - - ;; Pseudo bit-syntax: Latin1 double angle quotes as parens. - ;;(modify-syntax-entry ?\253 "(?\273" table) - ;;(modify-syntax-entry ?\273 ")?\253" table) - - (setq erlang-mode-syntax-table table))) - - (set-syntax-table erlang-mode-syntax-table)) - - -(defun erlang-keymap-init () - (if erlang-mode-map - nil - (setq erlang-mode-map (make-sparse-keymap)) - (erlang-mode-commands erlang-mode-map)) - (use-local-map erlang-mode-map)) - - -(defun erlang-mode-commands (map) - (define-key map "\t" 'erlang-indent-command) - (define-key map ";" 'erlang-electric-semicolon) - (define-key map "," 'erlang-electric-comma) - (define-key map "<" 'erlang-electric-lt) - (define-key map ">" 'erlang-electric-gt) - (define-key map "\C-m" 'erlang-electric-newline) - (define-key map "\177" 'backward-delete-char-untabify) - (define-key map "\M-q" 'erlang-fill-paragraph) - (define-key map "\M-\C-a" 'erlang-beginning-of-function) - (define-key map "\M-\C-e" 'erlang-end-of-function) - (define-key map "\M-\C-h" 'erlang-mark-function) - (define-key map "\M-\t" 'erlang-complete-tag) - (define-key map "\C-c\M-\t" 'tempo-complete-tag) - (define-key map "\C-c\M-a" 'erlang-beginning-of-clause) - (define-key map "\C-c\M-b" 'tempo-backward-mark) - (define-key map "\C-c\M-e" 'erlang-end-of-clause) - (define-key map "\C-c\M-f" 'tempo-forward-mark) - (define-key map "\C-c\M-h" 'erlang-mark-clause) - (define-key map "\C-c\C-c" 'comment-region) - (define-key map "\C-c\C-j" 'erlang-generate-new-clause) - (define-key map "\C-c\C-k" 'erlang-compile) - (define-key map "\C-c\C-l" 'erlang-compile-display) - (define-key map "\C-c\C-s" 'erlang-show-syntactic-information) - (define-key map "\C-c\C-q" 'erlang-indent-function) - (define-key map "\C-c\C-u" 'erlang-uncomment-region) - (define-key map "\C-c\C-y" 'erlang-clone-arguments) - (define-key map "\C-c\C-z" 'erlang-shell-display) - (define-key map "\C-x`" 'erlang-next-error)) - - -(defun erlang-electric-init () - ;; Set up electric character functions to work with - ;; delsel/pending-del mode. Also, set up text properties for bit - ;; syntax handling. - (mapcar #'(lambda (cmd) - (put cmd 'delete-selection t) ;for delsel (Emacs) - (put cmd 'pending-delete t)) ;for pending-del (XEmacs) - '(erlang-electric-semicolon - erlang-electric-comma - erlang-electric-gt)) - - (put 'bitsyntax-open-outer 'syntax-table '(4 . ?>)) - (put 'bitsyntax-open-outer 'rear-nonsticky '(category)) - (put 'bitsyntax-open-inner 'rear-nonsticky '(category)) - (put 'bitsyntax-close-inner 'rear-nonsticky '(category)) - (put 'bitsyntax-close-outer 'syntax-table '(5 . ?<)) - (put 'bitsyntax-close-outer 'rear-nonsticky '(category)) - (setq parse-sexp-lookup-properties 't)) - - - -(defun erlang-mode-variables () - (or erlang-mode-abbrev-table - (define-abbrev-table 'erlang-mode-abbrev-table ())) - (setq local-abbrev-table erlang-mode-abbrev-table) - (make-local-variable 'paragraph-start) - (setq paragraph-start (concat "^$\\|" page-delimiter)) - (make-local-variable 'paragraph-separate) - (setq paragraph-separate paragraph-start) - (make-local-variable 'paragraph-ignore-fill-prefix) - (setq paragraph-ignore-fill-prefix t) - (make-local-variable 'require-final-newline) - (setq require-final-newline t) - (make-local-variable 'defun-prompt-regexp) - (setq defun-prompt-regexp erlang-defun-prompt-regexp) - (make-local-variable 'comment-start) - (setq comment-start "%") - (make-local-variable 'comment-start-skip) - (setq comment-start-skip "%+\\s *") - (make-local-variable 'comment-column) - (setq comment-column 48) - (make-local-variable 'indent-line-function) - (setq indent-line-function 'erlang-indent-command) - (make-local-variable 'indent-region-function) - (setq indent-region-function 'erlang-indent-region) - (set (make-local-variable 'comment-indent-function) 'erlang-comment-indent) - (if (<= erlang-emacs-major-version 18) - (set (make-local-variable 'comment-indent-hook) 'erlang-comment-indent)) - (set (make-local-variable 'parse-sexp-ignore-comments) t) - (set (make-local-variable 'dabbrev-case-fold-search) nil) - (set (make-local-variable 'imenu-prev-index-position-function) - 'erlang-beginning-of-function) - (set (make-local-variable 'imenu-extract-index-name-function) - 'erlang-get-function-name) - (set (make-local-variable 'tempo-match-finder) - "[^-a-zA-Z0-9_]\\([-a-zA-Z0-9_]*\\)\\=")) - - -;; Compilation. -;; -;; The following code is compatible with the standard package `compilation', -;; making it possible to go to errors using `erlang-next-error'. -;; -;; The normal `compile' command works ofcourse. For best result, please -;; execute `make' with the `-w' flag. -;; -;; Please see the variables named `compiling-..' above. - -(defun erlang-add-compilation-alist (alist) - (require 'compile) - (cond ((boundp 'compilation-error-regexp-alist) ; Emacs 19 - (while alist - (or (assoc (car (car alist)) compilation-error-regexp-alist) - (setq compilation-error-regexp-alist - (cons (car alist) compilation-error-regexp-alist))) - (setq alist (cdr alist)))) - ((boundp 'compilation-error-regexp) - ;; Emacs 18, Only one regexp is allowed. - (funcall (symbol-function 'set) - 'compilation-error-regexp (car (car alist)))))) - -(defun erlang-font-lock-init () - "Initialize Font Lock for Erlang mode." - (or erlang-font-lock-syntax-table - (setq erlang-font-lock-syntax-table - (let ((table (copy-syntax-table erlang-mode-syntax-table))) - (modify-syntax-entry ?_ "w" table) - table))) - (set (make-local-variable 'font-lock-syntax-table) - erlang-font-lock-syntax-table) - (set (make-local-variable 'font-lock-beginning-of-syntax-function) - 'erlang-beginning-of-clause) - (make-local-variable 'font-lock-keywords) - (let ((level (cond ((boundp 'font-lock-maximum-decoration) - (symbol-value 'font-lock-maximum-decoration)) - ((boundp 'font-lock-use-maximal-decoration) - (symbol-value 'font-lock-use-maximal-decoration)) - (t nil)))) - (if (consp level) - (setq level (cdr-safe (or (assq 'erlang-mode level) - (assq t level))))) - ;; `level' can here be: - ;; A number - The fontification level - ;; nil - Use the default - ;; t - Use maximum - (cond ((eq level nil) - (set 'font-lock-keywords erlang-font-lock-keywords)) - ((eq level 1) - (set 'font-lock-keywords erlang-font-lock-keywords-1)) - ((eq level 2) - (set 'font-lock-keywords erlang-font-lock-keywords-2)) - (t - (set 'font-lock-keywords erlang-font-lock-keywords-3)))) - - ;; Modern font-locks can handle the above much more elegant: - (set (make-local-variable 'font-lock-defaults) - '((erlang-font-lock-keywords erlang-font-lock-keywords-1 - erlang-font-lock-keywords-2 erlang-font-lock-keywords-3) - nil nil ((?_ . "w")) erlang-beginning-of-clause - (font-lock-mark-block-function . erlang-mark-clause)))) - - - -;; Useful when definig yout own keywords. -(defun erlang-font-lock-set-face (ks &rest faces) - "Replace the face components in a list of keywords. - -The first argument, KS, is a list of keywords. The rest of the -arguments are expressions to replace the face information with. The -first expression replaces the face of the first keyword, the second -expression the second keyword etc. - -Should an expression be nil, the face of the corresponding keyword is -not changed. - -Should fewer expressions than keywords be given, the last expression -is used for all remaining keywords. - -Normally, the expressions are just atoms representing the new face. -They could however be more complex, returning different faces in -different situations. - -This function does only handle keywords with elements on the forms: - (REGEXP NUMBER FACE) - (REGEXP NUMBER FACE OVERWRITE) - -This could be used when defining your own special font-lock setup, e.g: - -\(setq my-font-lock-keywords - (append erlang-font-lock-keywords-func - erlang-font-lock-keywords-dollar - (erlang-font-lock-set-face - erlang-font-lock-keywords-macros 'my-neon-green-face) - (erlang-font-lock-set-face - erlang-font-lock-keywords-lc 'my-deep-red 'my-light-red) - erlang-font-lock-keywords-attr)) - -For a more elaborate example, please see the beginning of the file -`erlang.el'." - (let ((res '())) - (while ks - (let* ((regexp (car (car ks))) - (number (car (cdr (car ks)))) - (new-face (if (and faces (car faces)) - (car faces) - (car (cdr (cdr (car ks)))))) - (overwrite (car (cdr (cdr (cdr (car ks)))))) - (new-keyword (list regexp number new-face))) - (if overwrite (nconc new-keyword (list overwrite))) - (setq res (cons new-keyword res)) - (setq ks (cdr ks)) - (if (and faces (cdr faces)) - (setq faces (cdr faces))))) - (nreverse res))) - - -(defun erlang-font-lock-level-0 () - ;; DocStringOrig: font-cmd - "Fontify current buffer. Level ranges from 0 (off) to 3 (Christmas Tree). - -The following fontification level exists: - 0 - No fontification - 1 - Function headers, reserved keywords, strings and comments. - 2 - Bifs, guards and `single quotes'. - 3 - Variables, macros and records. - -To automatically activate font lock mode, place the following lines -in your ~/.emacs file: - -\(defun my-erlang-mode-hook () - (cond (window-system - (font-lock-mode 1)))) -\(add-hook 'erlang-mode-hook 'my-erlang-mode-hook) -\(setq font-lock-maximum-decoration t)" - (interactive) - (font-lock-mode 0)) - - -(defun erlang-font-lock-level-1 () - ;; DocStringCopy: font-cmd - "Fontify current buffer. Level ranges from 0 (off) to 3 (Christmas Tree). - -The following fontification level exists: - 0 - No fontification - 1 - Function headers, reserved keywords, strings and comments. - 2 - Bifs, guards and `single quotes'. - 3 - Variables, macros and records. - -To automatically activate font lock mode, place the following lines -in your ~/.emacs file: - -\(defun my-erlang-mode-hook () - (cond (window-system - (font-lock-mode 1)))) -\(add-hook 'erlang-mode-hook 'my-erlang-mode-hook) -\(setq font-lock-maximum-decoration t)" - (interactive) - (require 'font-lock) - (set 'font-lock-keywords erlang-font-lock-keywords-1) - (font-lock-mode 1) - (funcall (symbol-function 'font-lock-fontify-buffer))) - - -(defun erlang-font-lock-level-2 () - ;; DocStringCopy: font-cmd - "Fontify current buffer. Level ranges from 0 (off) to 3 (Christmas Tree). - -The following fontification level exists: - 0 - No fontification - 1 - Function headers, reserved keywords, strings and comments. - 2 - Bifs, guards and `single quotes'. - 3 - Variables, macros and records. - -To automatically activate font lock mode, place the following lines -in your ~/.emacs file: - -\(defun my-erlang-mode-hook () - (cond (window-system - (font-lock-mode 1)))) -\(add-hook 'erlang-mode-hook 'my-erlang-mode-hook) -\(setq font-lock-maximum-decoration t)" - (interactive) - (require 'font-lock) - (set 'font-lock-keywords erlang-font-lock-keywords-2) - (font-lock-mode 1) - (funcall (symbol-function 'font-lock-fontify-buffer))) - - -(defun erlang-font-lock-level-3 () - ;; DocStringCopy: font-cmd - "Fontify current buffer. Level ranges from 0 (off) to 3 (Christmas Tree). - -The following fontification level exists: - 0 - No fontification - 1 - Function headers, reserved keywords, strings and comments. - 2 - Bifs, guards and `single quotes'. - 3 - Variables, macros and records. - -To automatically activate font lock mode, place the following lines -in your ~/.emacs file: - -\(defun my-erlang-mode-hook () - (cond (window-system - (font-lock-mode 1)))) -\(add-hook 'erlang-mode-hook 'my-erlang-mode-hook) -\(setq font-lock-maximum-decoration t)" - (interactive) - (require 'font-lock) - (set 'font-lock-keywords erlang-font-lock-keywords-3) - (font-lock-mode 1) - (funcall (symbol-function 'font-lock-fontify-buffer))) - - -(defun erlang-menu-init () - "Init menus for Erlang mode. - -The variable `erlang-menu-items' contain a description of the Erlang -mode menu. Normally, the list contains atoms, representing variables -bound to pieces of the menu. - -Personal extentions could be added to `erlang-menu-personal-items'. - -Should any variable describing the menu configuration, this function -should be called." - (erlang-menu-install "Erlang" erlang-menu-items erlang-mode-map t)) - - -(defun erlang-menu-install (name items keymap &optional popup) - "Install a menu on Emacs 19 or XEmacs based on an abstract description. - -NAME is the name of the menu. - -ITEMS is a list. The elements are either nil representing a horisontal -line or a list with two or three elements. The first is the name of -the menu item, the second the function to call, or a submenu, on the -same same form as ITEMS. The third optional element is an expression -which is evaluated every time the menu is displayed. Should the -expression evaluate to nil the menu item is ghosted. - -KEYMAP is the keymap to add to menu to. (When using XEmacs, the menu -will only be visible when this meny is the global, the local, or an -activated minor mode keymap.) - -If POPUP is non-nil, the menu is bound to the XEmacs `mode-popup-menu' -variable, i.e. it will popup when pressing the right mouse button. - -Please see the variable `erlang-menu-base-items'." - (cond (erlang-xemacs-p - (let ((menu (erlang-menu-xemacs name items keymap))) - ;; We add the menu to the global menubar. - ;;(funcall (symbol-function 'set-buffer-menubar) - ;; (symbol-value 'current-menubar)) - (funcall (symbol-function 'add-submenu) nil menu) - (setcdr erlang-xemacs-popup-menu (cdr menu)) - (if (and popup (boundp 'mode-popup-menu)) - (funcall (symbol-function 'set) - 'mode-popup-menu erlang-xemacs-popup-menu)))) - ((>= erlang-emacs-major-version 19) - (define-key keymap (vector 'menu-bar (intern name)) - (erlang-menu-make-keymap name items))) - (t nil))) - - -(defun erlang-menu-make-keymap (name items) - "Build a menu for Emacs 19." - (let ((menumap (funcall (symbol-function 'make-sparse-keymap) - name)) - (count 0) - id def first second third) - (setq items (reverse items)) - (while items - ;; Replace any occurence of atoms by their value. - (while (and items (atom (car items)) (not (null (car items)))) - (if (and (boundp (car items)) - (listp (symbol-value (car items)))) - (setq items (append (reverse (symbol-value (car items))) - (cdr items))) - (setq items (cdr items)))) - (setq first (car-safe (car items))) - (setq second (car-safe (cdr-safe (car items)))) - (setq third (car-safe (cdr-safe (cdr-safe (car items))))) - (cond ((null first) - (setq count (+ count 1)) - (setq id (intern (format "separator-%d" count))) - (setq def '("--" . nil))) - ((and (consp second) (eq (car second) 'lambda)) - (setq count (+ count 1)) - (setq id (intern (format "lambda-%d" count))) - (setq def (cons first second))) - ((symbolp second) - (setq id second) - (setq def (cons first second))) - (t - (setq count (+ count 1)) - (setq id (intern (format "submenu-%d" count))) - (setq def (erlang-menu-make-keymap first second)))) - (define-key menumap (vector id) def) - (if third - (put id 'menu-enable third)) - (setq items (cdr items))) - (cons name menumap))) - - -(defun erlang-menu-xemacs (name items &optional keymap) - "Build a menu for XEmacs." - (let ((res '()) - first second third entry) - (while items - ;; Replace any occurence of atoms by their value. - (while (and items (atom (car items)) (not (null (car items)))) - (if (and (boundp (car items)) - (listp (symbol-value (car items)))) - (setq items (append (reverse (symbol-value (car items))) - (cdr items))) - (setq items (cdr items)))) - (setq first (car-safe (car items))) - (setq second (car-safe (cdr-safe (car items)))) - (setq third (car-safe (cdr-safe (cdr-safe (car items))))) - (cond ((null first) - (setq res (cons "------" res))) - ((symbolp second) - (setq res (cons (vector first second (or third t)) res))) - ((and (consp second) (eq (car second) 'lambda)) - (setq res (cons (vector first (list 'call-interactively second) - (or third t)) res))) - (t - (setq res (cons (cons first - (cdr (erlang-menu-xemacs - first second))) - res)))) - (setq items (cdr items))) - (setq res (reverse res)) - ;; When adding a menu to a minor-mode keymap under Emacs 19, - ;; it disappears when the mode is disabled. The expression - ;; generated below imitates this behaviour. - ;; (This could be expressed much clearer using backquotes, - ;; but I don't want to pull in every package.) - (if keymap - (let ((expr (list 'or - (list 'eq keymap 'global-map) - (list 'eq keymap (list 'current-local-map)) - (list 'symbol-value - (list 'car-safe - (list 'rassq - keymap - 'minor-mode-map-alist)))))) - (setq res (cons ':included (cons expr res))))) - (cons name res))) - - -(defun erlang-menu-substitute (items alist) - "Substitute functions in menu described by ITEMS. - -The menu ITEMS is updated destructively. - -ALIST is list of pairs where the car is the old function and cdr the new." - (let (first second pair) - (while items - (setq first (car-safe (car items))) - (setq second (car-safe (cdr-safe (car items)))) - (cond ((null first)) - ((symbolp second) - (setq pair (and second (assq second alist))) - (if pair - (setcar (cdr (car items)) (cdr pair)))) - ((and (consp second) (eq (car second) 'lambda))) - (t - (erlang-menu-substitute second alist))) - (setq items (cdr items))))) - - -(defun erlang-menu-add-above (entry above items) - "Add menu ENTRY above menu entry ABOVE in menu ITEMS. -Do nothing if the items already should be in the menu. -Should ABOVE not be in the list, the entry is added at -the bottom of the menu. - -The new menu is returned. No guarantee is given that the original -menu is left unchanged. - -The equality test is performed by `eq'. - -Example: (erlang-menu-add-above 'my-erlang-menu-items - 'erlang-menu-man-items)" - (erlang-menu-add-below entry above items t)) - - -(defun erlang-menu-add-below (entry below items &optional above-p) - "Add menu ENTRY below menu items BELOW in the Erlang menu. -Do nothing if the items already should be in the menu. -Should BELOW not be in the list, items is added at the bottom -of the menu. - -The new menu is returned. No guarantee is given that the original -menu is left unchanged. - -The equality test is performed by `eq'. - -Example: - -\(setq erlang-menu-items - (erlang-menu-add-below 'my-erlang-menu-items - 'erlang-menu-base-items - erlang-menu-items))" - (if (memq entry items) - items ; Return the original menu. - (let ((head '()) - (done nil) - res) - (while (not done) - (cond ((null items) - (setq res (append head (list entry))) - (setq done t)) - ((eq below (car items)) - (setq res - (if above-p - (append head (cons entry items)) - (append head (cons (car items) - (cons entry (cdr items)))))) - (setq done t)) - (t - (setq head (append head (list (car items)))) - (setq items (cdr items))))) - res))) - -(defun erlang-menu-delete (entry items) - "Delete ENTRY from menu ITEMS. - -The new menu is returned. No guarantee is given that the original -menu is left unchanged." - (delq entry items)) - -;; Man code: - -(defun erlang-man-init () - "Add menus containing the manual pages of the Erlang. - -The variable `erlang-man-dirs' contains entries describing -the location of the manual pages." - (interactive) - (if erlang-man-inhibit - () - (setq erlang-menu-man-items - '(nil - ("Man - Function" erlang-man-function))) - (if erlang-man-dirs - (setq erlang-menu-man-items - (append erlang-menu-man-items - (erlang-man-make-top-menu erlang-man-dirs)))) - (setq erlang-menu-items - (erlang-menu-add-above 'erlang-menu-man-items - 'erlang-menu-version-items - erlang-menu-items)) - (erlang-menu-init))) - - -(defun erlang-man-uninstall () - "Remove the man pages from the Erlang mode." - (interactive) - (setq erlang-menu-items - (erlang-menu-delete 'erlang-menu-man-items erlang-menu-items)) - (erlang-menu-init)) - - -;; The man menu is a hierarchal structure, with the manual sections -;; at the top, described by `erlang-man-dirs'. The next level could -;; either be the manual pages if not to many, otherwise it is an index -;; menu whose submenus will contain up to `erlang-man-max-menu-size' -;; manual pages. - -(defun erlang-man-make-top-menu (dir-list) - "Create one menu entry per element of DIR-LIST. -The format is described in the documentation of `erlang-man-dirs'." - (let ((menu '()) - dir) - (while dir-list - (setq dir (cond ((nth 2 (car dir-list)) - ;; Relative to `erlang-root-dir'. - (and (stringp erlang-root-dir) - (concat erlang-root-dir (nth 1 (car dir-list))))) - (t - ;; Absolute - (nth 1 (car dir-list))))) - (if (and dir - (file-readable-p dir)) - (setq menu (cons (list (car (car dir-list)) - (erlang-man-make-middle-menu - (erlang-man-get-files dir))) - menu))) - (setq dir-list (cdr dir-list))) - ;; Should no menus be found, generate a menu item which - ;; will display a help text, when selected. - (if menu - (nreverse menu) - '(("Man Pages" - (("Error! Why?" erlang-man-describe-error))))))) - - -;; Should the menu be to long, let's split it into a number of -;; smaller menus. Warning, this code contains beatiful -;; destructive operations! -(defun erlang-man-make-middle-menu (filelist) - "Create the second level menu from FILELIST. - -Should the list be longer than `erlang-man-max-menu-size', a tree of -menus is created." - (if (<= (length filelist) erlang-man-max-menu-size) - (erlang-man-make-menu filelist) - (let ((menu '()) - (filelist (copy-sequence filelist)) - segment submenu pair) - (while filelist - (setq pair (nthcdr (- erlang-man-max-menu-size 1) filelist)) - (setq segment filelist) - (if (null pair) - (setq filelist nil) - (setq filelist (cdr pair)) - (setcdr pair nil)) - (setq submenu (erlang-man-make-menu segment)) - (setq menu (cons (list (concat (car (car submenu)) - " -- " - (car (car (reverse submenu)))) - submenu) - menu))) - (nreverse menu)))) - - -(defun erlang-man-make-menu (filelist) - "Make a leaf menu based on FILELIST." - (let ((menu '()) - item) - (while filelist - (setq item (erlang-man-make-menu-item (car filelist))) - (if item - (setq menu (cons item menu))) - (setq filelist (cdr filelist))) - (nreverse menu))) - - -(defun erlang-man-make-menu-item (file) - "Create a menu item containing the name of the man page." - (and (string-match ".*/\\([^/]+\\)\\.[^.]$" file) - (let ((page (substring file (match-beginning 1) (match-end 1)))) - (list (capitalize page) - (list 'lambda '() - '(interactive) - (list 'funcall 'erlang-man-display-function - file)))))) - - -(defun erlang-man-get-files (dir) - "Return files in directory DIR." - (directory-files dir t ".*\\.[0-9]\\'")) - - -(defun erlang-man-module (&optional module) - "Find manual page for MODULE, defaults to module of function under point. -This function is aware of imported functions." - (interactive - (list (let* ((mod (car-safe (erlang-get-function-under-point))) - (input (read-string - (format "Manual entry for module%s: " - (if (or (null mod) (string= mod "")) - "" - (format " (default %s)" mod)))))) - (if (string= input "") - mod - input)))) - (or module (setq module (car (erlang-get-function-under-point)))) - (if (or (null module) (string= module "")) - (error "No Erlang module name given")) - (let ((dir-list erlang-man-dirs) - (pat (concat "\\b" (regexp-quote module) "\\.[^.]$")) - (file nil) - file-list) - (while (and dir-list (null file)) - (setq file-list (erlang-man-get-files - (if (nth 2 (car dir-list)) - (concat erlang-root-dir (nth 1 (car dir-list))) - (nth 1 (car dir-list))))) - (while (and file-list (null file)) - (if (string-match pat (car file-list)) - (setq file (car file-list))) - (setq file-list (cdr file-list))) - (setq dir-list (cdr dir-list))) - (if file - (funcall erlang-man-display-function file) - (error "No manual page for module %s found." module)))) - - -;; Warning, the function `erlang-man-function' is a hack! -;; It links itself into the man code in a non-clean way. I have -;; choosed to keep it since it provides a very useful functionality -;; which is not possible to achive using a clean approach. -;; / AndersL - -(defvar erlang-man-function-name nil - "Name of function for last `erlang-man-function' call. -Used for commnication between `erlang-man-function' and the -patch to `Man-notify-when-ready'.") - -(defun erlang-man-function (&optional name) - "Find manual page for NAME, where NAME is module:function. -The entry for `function' is displayed. - -This function is aware of imported functions." - (interactive - (list (let* ((mod-func (erlang-get-function-under-point)) - (mod (car-safe mod-func)) - (func (nth 1 mod-func)) - (input (read-string - (format - "Manual entry for `module:func' or `module'%s: " - (if (or (null mod) (string= mod "")) - "" - (format " (default %s:%s)" mod func)))))) - (if (string= input "") - (if (and mod func) - (concat mod ":" func) - mod) - input)))) - ;; Emacs 18 doesn't provide `man'... - (condition-case nil - (require 'man) - (error nil)) - (let ((modname nil) - (funcname nil)) - (cond ((null name) - (let ((mod-func (erlang-get-function-under-point))) - (setq modname (car-safe mod-func)) - (setq funcname (nth 1 mod-func)))) - ((string-match ":" name) - (setq modname (substring name 0 (match-beginning 0))) - (setq funcname (substring name (match-end 0) nil))) - ((stringp name) - (setq modname name))) - (if (or (null modname) (string= modname "")) - (error "No Erlang module name given")) - (cond ((fboundp 'Man-notify-when-ready) - ;; Emacs 19: The man command could possibly start an - ;; asyncronous process, i.e. we must hook ourselves into - ;; the system to be activated when the man-process - ;; terminates. - (if (null funcname) - () - (erlang-man-patch-notify) - (setq erlang-man-function-name funcname)) - (condition-case nil - (erlang-man-module modname) - (error (setq erlang-man-function-name nil)))) - (t - (erlang-man-module modname) - (if funcname - (erlang-man-find-function - (or (get-buffer "*Manual Entry*") ; Emacs 18 - (current-buffer)) ; XEmacs - funcname)))))) - - -;; Should the defadvice be at the top level, the package `advice' would -;; be required. Now it is only required when this functionality -;; is used. (Emacs 19 specific.) -(defun erlang-man-patch-notify () - "Patch the function `Man-notify-when-ready' to search for function. -The variable `erlang-man-function-name' is assumed to be bound to -the function name, or to nil. - -The reason for patching a function is that under Emacs 19, the man -command is executed asynchronously." - (condition-case nil - (require 'advice) - ;; This should never happend since this is only called when - ;; running under Emacs 19. - (error (error (concat "This commands needs the package `advice', " - "please upgrade your Emacs.")))) - (require 'man) - (defadvice Man-notify-when-ready - (after erlang-Man-notify-when-ready activate) - "Sets point at the documentation of the function name in -erlang-man-function-name when the man-page is displayed." - (if erlang-man-function-name - (erlang-man-find-function (ad-get-arg 0) erlang-man-function-name)) - (setq erlang-man-function-name nil))) - - -(defun erlang-man-find-function (buf func) - "Find manual page for function in `erlang-man-function-name' in buffer BUF." - (if func - (let ((win (get-buffer-window buf))) - (if win - (progn - (set-buffer buf) - (goto-char (point-min)) - (if (re-search-forward - (concat "^[ \t]+" func " ?(") - (point-max) t) - (progn - (forward-word -1) - (set-window-point win (point))) - (message "Could not find function `%s'" func))))))) - - -(defun erlang-man-display (file) - "Display FILE as a `man' file. -This is de default manual page display function. -The variables `erlang-man-display-function' contains the function -to be used." - ;; Emacs 18 doesn't `provide' man. - (condition-case nil - (require 'man) - (error nil)) - (if file - (let ((process-environment (copy-sequence process-environment))) - (if (string-match "\\(.*\\)/man[^/]*/\\([^/]+\\)\\.[^.]$" file) - (let ((dir (substring file (match-beginning 1) (match-end 1))) - (page (substring file (match-beginning 2) (match-end 2)))) - (if (fboundp 'setenv) - (setenv "MANPATH" dir) - ;; Emacs 18 - (setq process-environment (cons (concat "MANPATH=" dir) - process-environment))) - (cond ((not (and (not erlang-xemacs-p) - (= erlang-emacs-major-version 19) - (< erlang-emacs-minor-version 29))) - (manual-entry page)) - (t - ;; Emacs 19.28 and earlier versions of 19: - ;; The manual-entry command unconditionally prompts - ;; the user :-( - (funcall (symbol-function 'Man-getpage-in-background) - page)))) - (error "Can't find man page for %s\n" file))))) - - -(defun erlang-man-describe-error () - "Describe why the manual pages weren't found." - (interactive) - (with-output-to-temp-buffer "*Erlang Man Error*" - (princ "Normally, this menu should contain Erlang manual pages. - -In order to find the manual pages, the variable `erlang-root-dir' -should be bound to the name of the directory containing the Erlang -installation. The name should not include the final slash. - -Practically, you should add a line on the following form to -your ~/.emacs, or ask your system administrator to add it to -the site init file: - (setq erlang-root-dir \"/the/erlang/root/dir/goes/here\") - -For example: - (setq erlang-root-dir \"/usr/local/erlang\") - -After installing the line, kill and restart Emacs, or restart Erlang -mode with the command `M-x erlang-mode RET'."))) - -;; Skeleton code: - -;; This code is based on the package `tempo' which is part of modern -;; Emacsen. (GNU Emacs 19.25 (?) and XEmacs 19.14.) - -(defun erlang-skel-init () - "Generate the skeleton functions and menu items. -The variable `erlang-skel' contains the name and descriptions of -all skeletons. - -The skeleton routines are based on the `tempo' package. Should this -package not be present, this function does nothing." - (interactive) - (condition-case nil - (require 'tempo) - (error t)) - (if (featurep 'tempo) - (let ((skel erlang-skel) - (menu '())) - (while skel - (cond ((null (car skel)) - (setq menu (cons nil menu))) - (t - (funcall (symbol-function 'tempo-define-template) - (concat "erlang-" (nth 1 (car skel))) - ;; The tempo template used contains an `include' - ;; function call only, hence changes to the - ;; variables describing the templates take effect - ;; immdiately. - (list (list 'erlang-skel-include (nth 2 (car skel)))) - (nth 1 (car skel))) - (setq menu (cons (erlang-skel-make-menu-item - (car skel)) menu)))) - (setq skel (cdr skel))) - (setq erlang-menu-skel-items - (list nil (list "Skeletons" (nreverse menu)))) - (setq erlang-menu-items - (erlang-menu-add-above 'erlang-menu-skel-items - 'erlang-menu-version-items - erlang-menu-items)) - (erlang-menu-init)))) - -(defun erlang-skel-make-menu-item (skel) - (let ((func (intern (concat "tempo-template-erlang-" (nth 1 skel))))) - (cond ((null (nth 3 skel)) - (list (car skel) func)) - (t - (list (car skel) - (list 'lambda '() - '(interactive) - (list 'funcall - (list 'quote (nth 3 skel)) - (list 'quote func)))))))) - -;; Functions designed to be added to the skeleton menu. -;; (Not normally used) -(defun erlang-skel-insert (func) - "Insert skeleton generated by FUNC and goto first tempo mark." - (save-excursion (funcall func)) - (funcall (symbol-function 'tempo-forward-mark))) - -(defun erlang-skel-header (func) - "Insert the header generated by FUNC at the beginning of the buffer." - (goto-char (point-min)) - (save-excursion (funcall func)) - (funcall (symbol-function 'tempo-forward-mark))) - - -;; Functions used inside the skeleton descriptions. -(defun erlang-skel-skip-blank () - (skip-chars-backward " \t") - nil) - -(defun erlang-skel-include (&rest args) - "Include a template inside another template. - -Example of use, assuming that `erlang-skel-func' is defined: - - (defvar foo-skeleton '(\"%%% New function:\" - (erlang-skel-include erlang-skel-func))) - -Techically, this function returns the `tempo' attribute`(l ...)' which -can contain other `tempo' attributes. Please see the function -`tempo-define-template' for a description of the `(l ...)' attribute." - (let ((res '()) - entry) - (while args - (setq entry (car args)) - (while entry - (setq res (cons (car entry) res)) - (setq entry (cdr entry))) - (setq args (cdr args))) - (cons 'l (nreverse res)))) - -(defun erlang-skel-separator (&optional percent) - "Return a comment separator." - (let ((percent (or percent 3))) - (concat (make-string percent ?%) - (make-string (- 70 percent) ?-) - "\n"))) - -(defun erlang-skel-double-separator (&optional percent) - "Return a comment separator." - (let ((percent (or percent 3))) - (concat (make-string percent ?%) - (make-string (- 70 percent) ?=) - "\n"))) - -(defun erlang-skel-dd-mmm-yyyy () - "Return the current date as a string in \"DD Mon YYYY\" form. -The first character of DD is space if the value is less than 10." - (let ((date (current-time-string))) - (format "%2d %s %s" - (string-to-int (substring date 8 10)) - (substring date 4 7) - (substring date -4)))) - -;; Indentation code: - -(defun erlang-indent-command (&optional whole-exp) - "Indent current line as Erlang code. -With argument, indent any additional lines of the same clause -rigidly along with this one." - (interactive "P") - (if whole-exp - ;; If arg, always indent this line as Erlang - ;; and shift remaining lines of clause the same amount. - (let ((shift-amt (erlang-indent-line)) - beg end) - (save-excursion - (if erlang-tab-always-indent - (beginning-of-line)) - (setq beg (point)) - (erlang-end-of-clause 1) - (setq end (point)) - (goto-char beg) - (forward-line 1) - (setq beg (point))) - (if (> end beg) - (indent-code-rigidly beg end shift-amt "\n"))) - (if (and (not erlang-tab-always-indent) - (save-excursion - (skip-chars-backward " \t") - (not (bolp)))) - (insert-tab) - (erlang-indent-line)))) - - -(defun erlang-indent-line () - "Indent current line as Erlang code. -Return the amount the indentation changed by." - (let ((pos (- (point-max) (point))) - indent beg - shift-amt) - (beginning-of-line 1) - (setq beg (point)) - (skip-chars-forward " \t") - (cond ((looking-at "%") - (setq indent (funcall comment-indent-function)) - (setq shift-amt (- indent (current-column)))) - (t - (setq indent (erlang-calculate-indent)) - (cond ((null indent) - (setq indent (current-indentation))) - ((eq indent t) - ;; This should never occur here. - (error "Erlang mode error")) - ((= (char-syntax (following-char)) ?\)) - (setq indent (1- indent)))) - (setq shift-amt (- indent (current-column))))) - (if (zerop shift-amt) - nil - (delete-region beg (point)) - (indent-to indent)) - ;; If initial point was within line's indentation, position - ;; after the indentation. Else stay at same point in text. - (if (> (- (point-max) pos) (point)) - (goto-char (- (point-max) pos))) - shift-amt)) - - -(defun erlang-indent-region (beg end) - "Indent region of erlang code. - -This is automagically called by the user level function `indent-region'." - (interactive "r") - (save-excursion - (let ((case-fold-search nil) - (continue t) - (from-end (- (point-max) end)) - indent-point;; The beginning of the current line - indent;; The indent amount - state) - (goto-char beg) - (beginning-of-line) - (setq indent-point (point)) - (erlang-beginning-of-clause) - ;; Parse the Erlang code from the beginning of the clause to - ;; the beginning of the region. - (while (< (point) indent-point) - (setq state (erlang-partial-parse (point) indent-point state))) - ;; Indent every line in the region - (while continue - (goto-char indent-point) - (skip-chars-forward " \t") - (cond ((looking-at "%") - ;; Do not use our stack to help the user to customize - ;; comment indentation. - (setq indent (funcall comment-indent-function))) - ((looking-at "$") - ;; Don't indent empty lines. - (setq indent 0)) - (t - (setq indent - (save-excursion - (erlang-calculate-stack-indent (point) state))) - (cond ((null indent) - (setq indent (current-indentation))) - ((eq indent t) - ;; This should never occur here. - (error "Erlang mode error")) - ((= (char-syntax (following-char)) ?\)) - (setq indent (1- indent)))))) - (if (zerop (- indent (current-column))) - nil - (delete-region indent-point (point)) - (indent-to indent)) - ;; Find the next line in the region - (goto-char indent-point) - (save-excursion - (forward-line 1) - (setq indent-point (point))) - (if (>= from-end (- (point-max) indent-point)) - (setq continue nil) - (while (< (point) indent-point) - (setq state (erlang-partial-parse - (point) indent-point state)))))))) - - -(defun erlang-indent-current-buffer () - "Indent current buffer as Erlang code." - (interactive) - (save-excursion - (save-restriction - (widen) - (erlang-indent-region (point-min) (point-max))))) - - -(defun erlang-indent-function () - "Indent current Erlang function." - (interactive) - (save-excursion - (let ((end (progn (erlang-end-of-function 1) (point))) - (beg (progn (erlang-beginning-of-function 1) (point)))) - (erlang-indent-region beg end)))) - - -(defun erlang-indent-clause () - "Indent current Erlang clause." - (interactive) - (save-excursion - (let ((end (progn (erlang-end-of-clause 1) (point))) - (beg (progn (erlang-beginning-of-clause 1) (point)))) - (erlang-indent-region beg end)))) - - -(defmacro erlang-push (x stack) (list 'setq stack (list 'cons x stack))) -(defmacro erlang-pop (stack) (list 'setq stack (list 'cdr stack))) -;; Would much prefer to make caddr a macro but this clashes. -(defun erlang-caddr (x) (car (cdr (cdr x)))) - - -(defun erlang-calculate-indent (&optional parse-start) - "Compute appropriate indentation for current line as Erlang code. -Return nil if line starts inside string, t if in a comment." - (save-excursion - (let ((indent-point (point)) - (case-fold-search nil) - (state nil)) - (if parse-start - (goto-char parse-start) - (erlang-beginning-of-clause)) - (while (< (point) indent-point) - (setq state (erlang-partial-parse (point) indent-point state))) - (erlang-calculate-stack-indent indent-point state)))) - -(defun erlang-show-syntactic-information () - "Show syntactic information for current line." - - (interactive) - - (save-excursion - (let ((starting-point (point)) - (case-fold-search nil) - (state nil)) - (erlang-beginning-of-clause) - (while (< (point) starting-point) - (setq state (erlang-partial-parse (point) starting-point state))) - (message "%S" state)))) - - -(defun erlang-partial-parse (from to &optional state) - "Parse Erlang syntax starting at FROM until TO, with an optional STATE. -Value is list (stack token-start token-type in-what)." - (goto-char from) ; Start at the beginning - (erlang-skip-blank to) - (let ((cs (char-syntax (following-char))) - (stack (car state)) - (token (point)) - in-what) - (cond - - ;; Done: Return previous state. - ((>= token to) - (setq token (nth 1 state)) - (setq cs (nth 2 state)) - (setq in-what (nth 3 state))) - - ;; Word constituent: check and handle keywords. - ((= cs ?w) - (if (looking-at "\\(end\\|after\\)[^_a-zA-Z0-9]") - ;; Must pop top icr layer, `after' will push a new - ;; layer next. - (progn - (while (and stack (eq (car (car stack)) '->)) - (erlang-pop stack)) - (if (and stack (memq (car (car stack)) '(icr begin))) - (erlang-pop stack)))) - (cond ((looking-at - "\\(if\\|case\\|receive\\|after\\)[^_a-zA-Z0-9]") - ;; Must push a new icr (if/case/receive) layer. - (erlang-push (list 'icr token (current-column)) stack)) - ((looking-at "\\(fun\\)[^_a-zA-Z0-9]") - ;; Puch a new icr layer if we are defining a `fun' - ;; expression, not when we are refering an existing - ;; function. - (if (save-excursion - (goto-char (match-end 1)) - (erlang-skip-blank to) - (eq (following-char) ?\()) - (erlang-push (list 'icr token (current-column)) stack))) - ((looking-at "\\(begin\\|query\\)[^_a-zA-Z0-9]") - (erlang-push (list 'begin token (current-column)) stack)) - ((looking-at "when[^_a-zA-Z0-9][^->\.]*->") - (erlang-push (list 'when token (current-column)) stack))) - (forward-sexp 1)) - - ;; String: Try to skip over it. (Catch error if not complete.) - ((= cs ?\") - (condition-case nil - (progn - (forward-sexp 1) - (if (> (point) to) - (progn - (setq in-what 'string) - (goto-char to)))) - (error - (setq in-what 'string) - (goto-char to)))) - - ;; Symbol constituent, punctuation, or expression prefix? - ((memq cs '(?. ?_ ?')) - (cond - - ;; Clause end - ((= (following-char) ?\;) - (if (and stack (eq (car (car stack)) '->)) - (erlang-pop stack)) - (forward-char 1)) - - ;; Function end - ((looking-at "\\.\\(\\s \\|\n\\|\\s<\\)") - (setq stack nil) - (forward-char 1)) - - ;; Function head - ((looking-at "->\\|:-") - (if (and stack (eq (car (car stack)) 'when)) - (erlang-pop stack)) - (erlang-push (list '-> token (current-column)) stack) - (forward-char 2)) - - ;; List-comprehension divider - ((looking-at "||") - (erlang-push (list '|| token (current-column)) stack) - (forward-char 2)) - - ;; Parameter separator - ((looking-at ",") - (forward-char 1)) - - ;; Bit-syntax open paren - ((looking-at "<<") - (erlang-push (list '\( token (current-column)) stack) - (forward-char 2)) - - ;; Bbit-syntax close paren - ((looking-at ">>") - (while (memq (car (car stack)) '(|| ->)) - (erlang-pop stack)) - (cond ((eq (car (car stack)) '\() - (erlang-pop stack)) - ((memq (car (car stack)) '(icr begin)) - (error "Missing `end'")) - (t - (error "Unbalanced parentheses"))) - (forward-char 2)) - - ;; Macro - ((= (following-char) ??) - ;; Skip over macro name and any following whitespace. - (forward-word 1) - (skip-syntax-forward "-" to) - ;; Macro might have an argument list. Should be handled like - ;; an ordinary function argument list in consecutive calls - ;; to erlang-partial-parse. - ) - - ;; Other punctuation: Skip over it and any following punctuation - ((= cs ?.) - ;; Skip over all characters in the operand. - (skip-syntax-forward ".")) - - ;; Other char: Skip over it. - (t - (forward-char 1)))) - - ;; Open parenthesis - ((= cs ?\() - (erlang-push (list '\( token (current-column)) stack) - (forward-char 1)) - - ;; Close parenthesis - ((= cs ?\)) - (while (memq (car (car stack)) '(|| ->)) - (erlang-pop stack)) - (cond ((eq (car (car stack)) '\() - (erlang-pop stack)) - ((memq (car (car stack)) '(icr begin)) - (error "Missing `end'")) - (t - (error "Unbalanced parenthesis"))) - (forward-char 1)) - - ;; Character quote: Skip it and the quoted char. - ((= cs ?/) - (forward-char 2)) - - ;; Character escape: Skip it and the escape sequence. - ((= cs ?\\) - (forward-char 1) - (skip-syntax-forward "w")) - - ;; Everything else - (t - (forward-char 1))) - (list stack token cs in-what))) - -(defun erlang-calculate-stack-indent (indent-point state) - "From the given last position and state (stack) calculate indentation. -Return nil if inside string, t if in a comment." - (let* ((stack (and state (car state))) - (token (nth 1 state)) - (stack-top (and stack (car stack)))) - (cond ((null state) ;No state - 0) - ((nth 3 state) - ;; Return nil or t. - (eq (nth 3 state) 'comment)) - ((null stack) - (if (looking-at "when[^_a-zA-Z0-9]") - erlang-indent-guard - 0)) - ((eq (car stack-top) '\() - ;; Element of list, tuple or part of an expression, - (if (null erlang-argument-indent) - ;; indent to next column. - (1+ (nth 2 stack-top)) - (goto-char (nth 1 stack-top)) - (cond ((looking-at "[({]\\s *\\($\\|%\\)") - ;; Line ends with parenthesis. - (+ (erlang-indent-find-preceding-expr) - erlang-argument-indent)) - (t - ;; Indent to the same column as the first - ;; argument. - (goto-char (1+ (nth 1 stack-top))) - (skip-chars-forward " \t") - (current-column))))) - ((eq (car stack-top) 'icr) - ;; The default indentation is the column of the option - ;; directly following the keyword. (This does not apply to - ;; `case'.) Should no option be on the same line, the - ;; indentation is the indentation of the keyword + - ;; `erlang-indent-level'. - ;; - ;; `after' should be indentated to the save level as the - ;; corresponding receive. - (if (looking-at "after[^_a-zA-Z0-9]") - (nth 2 stack-top) - (save-excursion - (goto-char (nth 1 stack-top)) - (if (looking-at "case[^_a-zA-Z0-9]") - (+ (nth 2 stack-top) erlang-indent-level) - (skip-chars-forward "a-z") - (skip-chars-forward " \t") - (if (memq (following-char) '(?% ?\n)) - (+ (nth 2 stack-top) erlang-indent-level) - (current-column)))))) - ;; Real indentation, where operators create extra indentation etc. - ((memq (car stack-top) '(-> || begin)) - (goto-char (nth 1 stack-top)) - ;; Check if there is more code after the '->' on the - ;; same line. If so use this indentation as base, else - ;; use parent indentation + 2 * level as base. - (let ((off erlang-indent-level) - (skip 2)) - (cond ((null (cdr stack))) ; Top level in function. - ((eq (car stack-top) 'begin) - (setq skip 5)) - ((eq (car stack-top) '->) - (setq off (* 2 erlang-indent-level)))) - (let ((base (erlang-indent-find-base stack indent-point off skip))) - ;; Look at last thing to see how we are to move relative - ;; to the base. - (goto-char token) - (cond ((looking-at "||\\|,\\|->\\|:-") - base) - ((erlang-at-keyword) - (+ (current-column) erlang-indent-level)) - ((or (= (char-syntax (following-char)) ?.) - (erlang-at-operator)) - (+ base erlang-indent-level)) - (t - (goto-char indent-point) - (cond ((memq (following-char) '(?\( ?{)) - ;; Function application or record. - (+ (erlang-indent-find-preceding-expr) - erlang-argument-indent)) - ;; Empty line, or end; treat it as the end of - ;; the block. (Here we have a choice: should - ;; the user be forced to reindent continued - ;; lines, or should the "end" be reindented?) - ((looking-at "\\(end\\|after\\)[^_a-zA-Z0-9]\\|$") - (if (eq (car (car stack)) '->) - (erlang-pop stack)) - (if stack - (erlang-caddr (car stack)) - 0)) - ;; Avoid trating comments a continued line. - ((= (following-char) ?%) - base) - ;; Continued line (e.g. line beginning - ;; with an operator.) - (t (+ base erlang-indent-level)))))))) - ((eq (car stack-top) 'when) - (goto-char (nth 1 stack-top)) - (if (looking-at "when\\s *\\($\\|%\\)") - (progn - (erlang-pop stack) - (if (and stack (eq (nth 0 (car stack)) 'icr)) - (progn - (goto-char (nth 1 (car stack))) - (+ (nth 2 (car stack)) erlang-indent-guard - ;; receive XYZ or receive - ;; XYZ - (if (looking-at "[a-z]+\\s *\\($\\|%\\)") - erlang-indent-level - (* 2 erlang-indent-level)))) - erlang-indent-guard)) - ;; "when" is followed by code, let's indent to the same - ;; column. - (forward-char 4) ; Skip "when" - (skip-chars-forward " \t") - (current-column)))))) - - -(defun erlang-indent-find-base (stack indent-point &optional offset skip) - "Find the base column for current stack." - (or skip (setq skip 2)) - (or offset (setq offset erlang-indent-level)) - (save-excursion - (let* ((stack-top (car stack))) - (goto-char (nth 1 stack-top)) - (forward-char skip) - (if (looking-at "\\s *\\($\\|%\\)") - (progn - (if (memq (car stack-top) '(-> ||)) - (erlang-pop stack)) - ;; Take parent identation + offset, - ;; else just erlang-indent-level if no parent - (if stack - (+ (erlang-caddr (car stack)) - offset) - erlang-indent-level)) - (erlang-skip-blank indent-point) - (current-column))))) - - -;; Does not handle `begin' .. `end'. -(defun erlang-indent-find-preceding-expr () - "Return the first column of the preceding expression. -This assumes that the preceding expression is either simple -\(i.e. an atom) or parenthesized." - (save-excursion - (forward-sexp -1) - (let ((col (current-column))) - (skip-chars-backward " \t") - ;; Needed to match the colon in "'foo':'bar'". - (if (not (memq (preceding-char) '(?# ?:))) - col - (backward-char 1) - (forward-sexp -1) - (current-column))))) - - -(defun erlang-skip-blank (&optional lim) - "Skip over whitespace and comments until limit reached." - (or lim (setq lim (point-max))) - (let (stop) - (while (and (not stop) (< (point) lim)) - (cond ((= (following-char) ?%) - (skip-chars-forward "^\n" lim)) - ((= (following-char) ?\n) - (skip-chars-forward "\n" lim)) - ((looking-at "\\s ") - (if (re-search-forward "\\S " lim 'move) - (forward-char -1))) - (t - (setq stop t)))) - stop)) - -(defun erlang-at-keyword () - "Are we looking at an Erlang keyword which will increase indentation?" - (looking-at (concat "\\(when\\|if\\|fun\\|case\\|begin\\|query\\|" - "of\\|receive\\|after\\|catch\\)[^_a-zA-Z0-9]"))) - -(defun erlang-at-operator () - "Are we looking at an Erlang operator?" - (looking-at - "\\(bnot\\|div\\|mod\\|band\\|bor\\|bxor\\|bsl\\|bsr\\)[^_a-zA-Z0-9]")) - -(defun erlang-comment-indent () - "Compute erlang comment indentation. - -Used both by `indent-for-comment' and the erlang specific indentation -commands." - (cond ((looking-at "%%%") 0) - ((looking-at "%%") - (or (erlang-calculate-indent) - (current-indentation))) - (t - (save-excursion - (skip-chars-backward " \t") - (max (if (bolp) 0 (1+ (current-column))) - comment-column))))) - -;;; Erlang movement commands - -;; All commands below work as movement commands. I.e. if the point is -;; at the end of the clause, and the command `erlang-end-of-clause' is -;; executed, the point is moved to the end of the NEXT clause. (This -;; mimics the behaviour of `end-of-defun'.) -;; -;; Personally I would like to rewrite them to be "pure", and add a set -;; of movement functions, like `erlang-next-clause', -;; `erlang-previous-clause', and the same for functions. -;; -;; The current implementation makes it hopeless to use the functions as -;; subroutines in more complex commands. /andersl - -(defun erlang-beginning-of-clause (&optional arg) - "Move backward to previous start of clause. -With argument, do this that many times. -Return t unless search stops due to end of buffer." - (interactive "p") - (or arg (setq arg 1)) - (if (< arg 0) - ;; Step back to the end of the previous line, unless we are at - ;; the beginning of the buffer. The reason for this move is - ;; that the regexp below includes the last character of the - ;; previous line. - (if (bobp) - (or (looking-at "\n") - (forward-char 1)) - (forward-char -1) - (if (looking-at "\\`\n") - (forward-char 1)))) - ;; The regexp matches a function header that isn't - ;; included in a string. - (and (re-search-forward "\\(\\`\\|\\`\n\\|[^\\]\n\\)\\([a-z]\\|'\\|-\\)" - nil 'move (- arg)) - (let ((beg (match-beginning 2))) - (and beg (goto-char beg)) - t))) - -(defun erlang-end-of-clause (&optional arg) - "Move to the end of the current clause. -With argument, do this that many times." - (interactive "p") - (or arg (setq arg 1)) - (while (and (looking-at "[ \t]*[%\n]") - (zerop (forward-line 1)))) - ;; Move to the next clause. - (erlang-beginning-of-clause (- arg)) - (beginning-of-line);; Just to be sure... - (let ((continue t)) - (while (and (not (bobp)) continue) - (forward-line -1) - (skip-chars-forward " \t") - (if (looking-at "[%\n]") - nil - (end-of-line) - (setq continue nil))))) - -(defun erlang-mark-clause () - "Put mark at end of clause, point at beginning." - (interactive) - (push-mark (point)) - (erlang-end-of-clause 1) - ;; Sets the region. In Emacs 19 and XEmacs, we wants to activate - ;; the region. - (condition-case nil - (push-mark (point) nil t) - (error (push-mark (point)))) - (erlang-beginning-of-clause 1) - ;; The above function deactivates the mark. - (if (boundp 'deactivate-mark) - (funcall (symbol-function 'set) 'deactivate-mark nil))) - -(defun erlang-beginning-of-function (&optional arg) - "Move backward to previous start of function. -With positive argument, do this that many times. -With negative argument, search forward. - -Return t unless search stops due to end of buffer." - (interactive "p") - (or arg (setq arg 1)) - (cond - ;; Search backward - ((> arg 0) - (while (and (> arg 0) - (and (erlang-beginning-of-clause 1) - (let ((start (point)) - (name (erlang-name-of-function)) - (arity (erlang-get-function-arity))) - ;; Note: "arity" is nil for e.g. "-import", hence - ;; two "-import" clauses are not considered to - ;; be part of the same function. - (while (and (erlang-beginning-of-clause 1) - (string-equal name - (erlang-name-of-function)) - arity - (equal arity - (erlang-get-function-arity))) - (setq start (point))) - (goto-char start) - t))) - (setq arg (1- arg)))) - ;; Search forward - ((< arg 0) - (end-of-line) - (erlang-beginning-of-clause 1) - ;; Step -arg functions forward. - (while (and (< arg 0) - ;; Step one function forward, or stop if the end of - ;; the buffer was reached. Return t if we found the - ;; function. - (let ((name (erlang-name-of-function)) - (arity (erlang-get-function-arity)) - (found (erlang-beginning-of-clause -1))) - (while (and found - (string-equal name (erlang-name-of-function)) - arity - (equal arity - (erlang-get-function-arity))) - (setq found (erlang-beginning-of-clause -1))) - found)) - (setq arg (1+ arg))))) - (zerop arg)) - - -(defun erlang-end-of-function (&optional arg) - "Move forward to next end of function. - -With argument, do this that many times. -With negative argument go towards the beginning of the buffer." - (interactive "p") - (or arg (setq arg 1)) - (let ((first t)) - ;; Forward - (while (and (> arg 0) (< (point) (point-max))) - (let ((pos (point))) - (while (progn - (if (and first - (progn - (forward-char 1) - (erlang-beginning-of-clause 1))) - nil - (or (bobp) (forward-char -1)) - (erlang-beginning-of-clause -1)) - (setq first nil) - (erlang-pass-over-function) - (skip-chars-forward " \t") - (if (looking-at "[%\n]") - (forward-line 1)) - (<= (point) pos)))) - (setq arg (1- arg))) - ;; Backward - (while (< arg 0) - (let ((pos (point))) - (erlang-beginning-of-clause 1) - (erlang-pass-over-function) - (forward-line 1) - (if (>= (point) pos) - (if (erlang-beginning-of-function 2) - (progn - (erlang-pass-over-function) - (skip-chars-forward " \t") - (if (looking-at "[%\n]") - (forward-line 1))) - (goto-char (point-min))))) - (setq arg (1+ arg))))) - -(defun erlang-mark-function () - "Put mark at end of function, point at beginning." - (interactive) - (push-mark (point)) - (erlang-end-of-function 1) - ;; Sets the region. In Emacs 19 and XEmacs, we wants to activate - ;; the region. - (condition-case nil - (push-mark (point) nil t) - (error (push-mark (point)))) - (erlang-beginning-of-function 1) - ;; The above function deactivates the mark. - (if (boundp 'deactivate-mark) - (funcall (symbol-function 'set) 'deactivate-mark nil))) - -(defun erlang-pass-over-function () - (while (progn - (erlang-skip-blank) - (and (not (looking-at "\\.\\(\\s \\|\n\\|\\s<\\)")) - (not (eobp)))) - (forward-sexp 1)) - (if (not (eobp)) - (forward-char 1))) - -(defun erlang-name-of-function () - (save-excursion - ;; Skip over attribute leader. - (if (looking-at "-[ \t]*") - (re-search-forward "-[ \t]*" nil 'move)) - (let ((start (point))) - (forward-sexp 1) - (buffer-substring start (point))))) - - -;;; Miscellaneous - -(defun erlang-fill-paragraph (&optional justify) - "Like \\[fill-paragraph], but handle Erlang comments. -If any of the current line is a comment, fill the comment or the -paragraph of it that point is in, preserving the comment's indentation -and initial `%':s." - (interactive "P") - (let ((has-comment nil) - ;; If has-comment, the appropriate fill-prefix for the comment. - comment-fill-prefix) - ;; Figure out what kind of comment we are looking at. - (save-excursion - (beginning-of-line) - (cond - ;; Find the command prefix. - ((looking-at (concat "\\s *" comment-start-skip)) - (setq has-comment t) - (setq comment-fill-prefix (buffer-substring (match-beginning 0) - (match-end 0)))) - ;; A line with some code, followed by a comment? Remember that the - ;; % which starts the comment shouldn't be part of a string or - ;; character. - ((progn - (while (not (looking-at "%\\|$")) - (skip-chars-forward "^%\n\"\\\\") - (cond - ((eq (char-after (point)) ?\\) (forward-char 2)) - ((eq (char-after (point)) ?\") (forward-sexp 1)))) - (looking-at comment-start-skip)) - (setq has-comment t) - (setq comment-fill-prefix - (concat (make-string (current-column) ? ) - (buffer-substring (match-beginning 0) (match-end 0))))))) - (if (not has-comment) - (fill-paragraph justify) - ;; Narrow to include only the comment, and then fill the region. - (save-restriction - (narrow-to-region - ;; Find the first line we should include in the region to fill. - (save-excursion - (while (and (zerop (forward-line -1)) - (looking-at "^\\s *%"))) - ;; We may have gone to far. Go forward again. - (or (looking-at "^\\s *%") - (forward-line 1)) - (point)) - ;; Find the beginning of the first line past the region to fill. - (save-excursion - (while (progn (forward-line 1) - (looking-at "^\\s *%"))) - (point))) - ;; Lines with only % on them can be paragraph boundaries. - (let ((paragraph-start (concat paragraph-start "\\|^[ \t%]*$")) - (paragraph-separate (concat paragraph-start "\\|^[ \t%]*$")) - (fill-prefix comment-fill-prefix)) - (fill-paragraph justify)))))) - - -(defun erlang-uncomment-region (beg end) - "Uncomment all commented lines in the region." - (interactive "r") - (comment-region beg end -1)) - - -(defun erlang-generate-new-clause () - "Create additional Erlang clause header. - -Parses the source file for the name of the current Erlang function. -Create the header containing the name, A pair of parentheses, -and an arrow. The space between the function name and the -first parenthesis is preserved. The point is placed between -the parentheses." - (interactive) - (let ((name (save-excursion - (and (erlang-beginning-of-clause) - (erlang-get-function-name t)))) - (arrow (save-excursion - (and (erlang-beginning-of-clause) - (erlang-get-function-arrow))))) - (if (or (null arrow) (null name)) - (error "Can't find name of current Erlang function.")) - (if (and (bolp) (eolp)) - nil - (end-of-line) - (newline)) - (insert name) - (save-excursion - (insert (concat ") " arrow))) - (if erlang-new-clause-with-arguments - (erlang-clone-arguments)))) - - -(defun erlang-clone-arguments () - "Insert, at the point, the argument list of the previous clause. - -The mark is set at the beginning of the inserted text, the point -at the end." - (interactive) - (let ((args (save-excursion - (beginning-of-line) - (and (erlang-beginning-of-clause) - (erlang-get-function-arguments)))) - (p (point))) - (if (null args) - (error "Can't clone argument list.")) - (insert args) - (set-mark p))) - -;;; Information retreival functions. - -(defun erlang-buffer-substring (beg end) - "Like `buffer-substring-no-properties'. -Although, this function works on all versions of Emacs." - (if (fboundp 'buffer-substring-no-properties) - (funcall (symbol-function 'buffer-substring-no-properties) beg end) - (buffer-substring beg end))) - - -(defun erlang-get-module () - "Return the name of the module as specified by `-module'. - -Return nil if file contains no `-module' attribute." - (save-excursion - (save-restriction - (widen) - (goto-char (point-min)) - (let ((md (match-data))) - (unwind-protect - (if (re-search-forward - (concat "^-module\\s *(\\s *\\(\\(" - erlang-atom-regexp - "\\)?\\)\\s *)\\s *\\.") - (point-max) t) - (erlang-remove-quotes - (erlang-buffer-substring (match-beginning 1) - (match-end 1))) - nil) - (store-match-data md)))))) - - -(defun erlang-get-module-from-file-name (&optional file) - "Extract the module name from a file name. - -First, the directory part is removed. Second, the part of the file name -matching `erlang-file-name-extension-regexp' is removed. - -Should the match fail, nil is returned. - -By modifying `erlang-file-name-extension-regexp' to match files other -than Erlang source files, Erlang specific functions could be applied on -non-Erlang files. Most notably; the support for Erlang modules in the -tags system could be used by files written in other languages." - (or file (setq file buffer-file-name)) - (if (null file) - nil - (setq file (file-name-nondirectory file)) - (if (string-match erlang-file-name-extension-regexp file) - (substring file 0 (match-beginning 0)) - nil))) - - -;; Used by `erlang-get-export' and `erlang-get-import'. - -(defun erlang-get-function-arity-list () - "Parses list of `function/arity' as used by `-import' and `-export'. - -The point must be placed at before the opening bracket. When the -function returns the point will be placed after the closing bracket. - -The function does not return an error if the list is incorrectly -formatted. - -Return list of (function . arity). The order of the returned list -corresponds to the order of the parsed Erlang list." - (let ((res '())) - (erlang-skip-blank) - (forward-char 1) - (if (not (eq (preceding-char) ?\[)) - '() ; Not looking at an Erlang list. - (while ; Note: `while' has no body. - (progn - (erlang-skip-blank) - (and (looking-at (concat erlang-atom-regexp - "/\\([0-9]+\\)\\>")) - (progn - (setq res (cons - (cons - (erlang-remove-quotes - (erlang-buffer-substring - (match-beginning 1) (match-end 1))) - (string-to-int - (erlang-buffer-substring - (match-beginning - (+ 1 erlang-atom-regexp-matches)) - (match-end - (+ 1 erlang-atom-regexp-matches))))) - res)) - (goto-char (match-end 0)) - (erlang-skip-blank) - (forward-char 1) - ;; Test if there are more exported functions. - (eq (preceding-char) ?,)))))) - (nreverse res))) - - -;;; Note that `-export' and the open parenthesis must be written on -;;; the same line. - -(defun erlang-get-export () - "Return a list of `(function . arity)' as specified by `-export'." - (save-excursion - (goto-char (point-min)) - (let ((md (match-data)) - (res '())) - (unwind-protect - (progn - (while (re-search-forward "^-export\\s *(" (point-max) t) - (erlang-skip-blank) - (setq res (nconc res (erlang-get-function-arity-list)))) - res) - (store-match-data md))))) - - -(defun erlang-get-import () - "Parse an Erlang source file for imported functions. - -Return an alist with module name as car part and list of conses containing -function and arity as cdr part." - (save-excursion - (goto-char (point-min)) - (let ((md (match-data)) - (res '())) - (unwind-protect - (progn - (while (re-search-forward "^-import\\s *(" (point-max) t) - (erlang-skip-blank) - (if (looking-at erlang-atom-regexp) - (let ((module (erlang-remove-quotes - (erlang-buffer-substring - (match-beginning 0) - (match-end 0))))) - (goto-char (match-end 0)) - (erlang-skip-blank) - (if (eq (following-char) ?,) - (progn - (forward-char 1) - (erlang-skip-blank) - (let ((funcs (erlang-get-function-arity-list)) - (pair (assoc module res))) - (if pair - (setcdr pair (nconc (cdr pair) funcs)) - (setq res (cons (cons module funcs) - res))))))))) - (nreverse res)) - (store-match-data md))))) - - -(defun erlang-get-function-name (&optional arg) - "Return name of current function, or nil. - -If optional argument is non-nil, everything up to and including -the first `(' is returned. - -Normally used in conjuction with `erlang-beginning-of-clause', e.g.: - (save-excursion - (if (not (eobp)) (forward-char 1)) - (and (erlang-beginning-of-clause) - (erlang-get-function-name t)))" - (let ((n (if arg 0 1))) - (and (looking-at (concat "^" erlang-atom-regexp "\\s *(")) - (erlang-buffer-substring (match-beginning n) (match-end n))))) - - -(defun erlang-get-function-arrow () - "Return arrow of current function, could be \"->\", \":-\" or nil. - -The \":-\" arrow is used by mnesia queries. - -Normally used in conjuction with `erlang-beginning-of-clause', e.g.: - (save-excursion - (if (not (eobp)) (forward-char 1)) - (and (erlang-beginning-of-clause) - (erlang-get-function-arrow)))" - (and - (save-excursion - (re-search-forward "[^-:]*-\\|:" (point-max) t) - (erlang-buffer-substring (- (point) 1) (+ (point) 1))))) - -(defun erlang-get-function-arity () - "Return the number of arguments of function at point, or nil." - (and (looking-at (concat "^" erlang-atom-regexp "\\s *(")) - (save-excursion - (goto-char (match-end 0)) - (condition-case nil - (let ((res 0) - (cont t)) - (while cont - (cond ((eobp) - (setq res nil) - (setq cont nil)) - ((looking-at "\\s *)") - (setq cont nil)) - ((looking-at "\\s *\\($\\|%\\)") - (forward-line 1)) - ((looking-at "\\s *,") - (setq res (+ 1 res)) - (goto-char (match-end 0))) - (t - (when (zerop res) - (setq res (+ 1 res))) - (forward-sexp 1)))) - res) - (error nil))))) - -(defun erlang-get-function-arguments () - "Return arguments of current function, or nil." - (if (not (looking-at (concat "^" erlang-atom-regexp "\\s *("))) - nil - (save-excursion - (condition-case nil - (let ((start (match-end 0))) - (goto-char (- start 1)) - (forward-sexp) - (erlang-buffer-substring start (- (point) 1))) - (error nil))))) - - -(defun erlang-get-function-under-point () - "Return the module and function under the point, or nil. - -Should no explicit module name be present at the point, the -list of imported functions is searched. - -The following could be retured: - (\"module\" \"function\") -- Both module and function name found. - (nil \"function\") -- No module name was found. - nil -- No function name found - -In the future the list may contain more elements." - (save-excursion - (let ((md (match-data)) - (res nil)) - (if (eq (char-syntax (following-char)) ? ) - (skip-chars-backward " \t")) - (skip-chars-backward "a-zA-Z0-9_:'") - (cond ((looking-at (concat erlang-atom-regexp ":" erlang-atom-regexp)) - (setq res (list - (erlang-remove-quotes - (erlang-buffer-substring - (match-beginning 1) (match-end 1))) - (erlang-remove-quotes - (erlang-buffer-substring - (match-beginning (1+ erlang-atom-regexp-matches)) - (match-end (1+ erlang-atom-regexp-matches))))))) - ((looking-at erlang-atom-regexp) - (let ((fk (erlang-remove-quotes - (erlang-buffer-substring - (match-beginning 0) (match-end 0)))) - (mod nil) - (imports (erlang-get-import))) - (while (and imports (null mod)) - (if (assoc fk (cdr (car imports))) - (setq mod (car (car imports))) - (setq imports (cdr imports)))) - (setq res (list mod fk))))) - (store-match-data md) - res))) - - -;; TODO: Escape single quotes inside the string. -(defun erlang-add-quotes-if-needed (str) - "Return STR, possibly with quotes." - (if (and (stringp str) - (not (string-match (concat "\\`" erlang-atom-regexp "\\'") str))) - (concat "'" str "'") - str)) - - -(defun erlang-remove-quotes (str) - "Return STR without quotes, if present." - (let ((md (match-data))) - (prog1 - (if (string-match "\\`'\\(.*\\)'\\'" str) - (substring str (match-beginning 1) (match-end 1)) - str) - (store-match-data md)))) - - -;;; Check module name - -;; I don't want to use `advice' since it is not part of Emacs 18. -;; -;; The function `write-file', bound to C-x C-w, calls -;; `set-visited-file-name' which clears the hook. :-( -;; To make sure that the hook always is present, we add a piece of -;; code to the function `set-visited-file-name'. -(defun erlang-check-module-name-init () - "Initialize the functionality to compare file and module names. - -We redefines the function `set-visited-file-name' since it clears -the variable `local-write-file-hooks'. The original function definition -is stored in `erlang-orig-set-visited-file-name'." - (if (fboundp 'erlang-orig-set-visited-file-name) - () - (fset 'erlang-orig-set-visited-file-name - (symbol-function 'set-visited-file-name)) - (defun set-visited-file-name (&rest args) - "Please see the function `erlang-orig-set-visited-file-name'." - (interactive "FSet visited file name: ") - (apply (symbol-function 'erlang-orig-set-visited-file-name) args) - (if (eq major-mode 'erlang-mode) - (add-hook 'local-write-file-hooks 'erlang-check-module-name)))) - (add-hook 'local-write-file-hooks 'erlang-check-module-name)) - - -(defun erlang-check-module-name () - "If the module name doesn't match file name, ask for permission to change. - -The variable `erlang-check-module-name' controls the behaviour of this -function. It it is nil, this function does nothing. If it is t, the -source is silently changed. If it is set to the atom `ask', the user -is prompted. - -This function is normally placed in the hook `local-write-file-hook'." - (if erlang-check-module-name - (let ((mn (erlang-get-module)) - (fn (erlang-get-module-from-file-name (buffer-file-name)))) - (if (and (stringp mn) (stringp fn)) - (or (string-equal mn fn) - (if (or (eq erlang-check-module-name t) - (y-or-n-p - "Module does not match file name. Modify source? ")) - (save-excursion - (save-restriction - (widen) - (goto-char (point-min)) - (if (re-search-forward - (concat "^-module\\s *(\\s *\\(\\(" - erlang-atom-regexp - "\\)?\\)\\s *)\\s *\\.") - (point-max) t) - (progn - (goto-char (match-beginning 1)) - (delete-region (match-beginning 1) - (match-end 1)) - (insert fn)))))))))) - ;; Must return nil since it is added to `local-write-file-hook'. - nil) - - -;;; Electric functions. - -(defun erlang-electric-semicolon (&optional arg) - "Insert a semicolon character and possibly a prototype for the next line. - -The variable `erlang-electric-semicolon-criteria' states a critera, -when fulfilled a newline is inserted, the next line is indented and a -prototype for the next line is inserted. Normally the prototype -consists of \" ->\". Should the semicolon end the clause a new clause -header is generated. - -The variable `erlang-electric-semicolon-insert-blank-lines' controls -the number of blank lines inserted between the current line and new -function header. - -Behaves just like the normal semicolon when supplied with a -numerical arg, point is inside string or comment, or when there are -non-whitespace characters following the point on the current line." - (interactive "P") - (self-insert-command (prefix-numeric-value arg)) - (if (or arg - (and (listp erlang-electric-commands) - (not (memq 'erlang-electric-semicolon - erlang-electric-commands))) - (erlang-in-literal) - (not (looking-at "\\s *\\(%.*\\)?$")) - (null (erlang-test-criteria-list - erlang-electric-semicolon-criteria))) - (setq erlang-electric-newline-inhibit nil) - (setq erlang-electric-newline-inhibit t) - (undo-boundary) - (end-of-line) - (newline) - (if (condition-case nil - (progn (erlang-indent-line) t) - (error (if (bolp) (delete-backward-char 1)))) - (if (not (bolp)) - (save-excursion - (insert " ->")) - (condition-case nil - (progn - (erlang-generate-new-clause) - (if erlang-electric-semicolon-insert-blank-lines - (save-excursion - (beginning-of-line) - (newline - erlang-electric-semicolon-insert-blank-lines)))) - (error (if (bolp) (delete-backward-char 1)))))))) - - -(defun erlang-electric-comma (&optional arg) - "Insert a comma character and possibly a new indented line. -The variable `erlang-electric-comma-criteria' states a critera, -when fulfilled a newline is inserted and the next line is indeted. - -Behaves just like the normal comma when supplied with a -numerical arg, point is inside string or comment, or when there are -non-whitespace characters following the point on the current line." - (interactive "P") - - (self-insert-command (prefix-numeric-value arg)) - - (if (or arg - (and (listp erlang-electric-commands) - (not (memq 'erlang-electric-comma erlang-electric-commands))) - (erlang-in-literal) - (not (looking-at "\\s *\\(%.*\\)?$")) - (null (erlang-test-criteria-list - erlang-electric-comma-criteria))) - (setq erlang-electric-newline-inhibit nil) - (setq erlang-electric-newline-inhibit t) - (undo-boundary) - (end-of-line) - (newline) - (condition-case nil - (erlang-indent-line) - (error (if (bolp) (delete-backward-char 1)))))) - -(defun erlang-electric-lt (&optional arg) - "Insert a less-than sign, and optionally mark it as an open paren." - - (interactive "p") - - (self-insert-command arg) - - ;; Was this the second char in bit-syntax open (`<<')? - (unless (< (point) 2) - (save-excursion - (backward-char 2) - (when (and (eq (char-after (point)) ?<) - (not (eq (get-text-property (point) 'category) - 'bitsyntax-open-inner))) - ;; Then mark the two chars... - (put-text-property (point) (1+ (point)) - 'category 'bitsyntax-open-outer) - (forward-char 1) - (put-text-property (point) (1+ (point)) - 'category 'bitsyntax-open-inner) - ;;...and unmark any subsequent less-than chars. - (forward-char 1) - (while (eq (char-after (point)) ?<) - (remove-text-properties (point) (1+ (point)) - '(category nil)) - (forward-char 1)))))) - -(defun erlang-after-bitsyntax-close () - "Returns true if point is placed immediately after a bit-syntax close parenthesis (`>>')." - (and (>= (point) 2) - (save-excursion - (backward-char 2) - (and (eq (char-after (point)) ?>) - (not (eq (get-text-property (point) 'category) - 'bitsyntax-close-outer)))))) - -(defun erlang-after-arrow () - "Returns true if point is placed immediately after a function arrow (`->')." - (and (>= (point) 2) - (and - (save-excursion - (backward-char) - (eq (char-before (point)) ?-)) - (or (not (listp erlang-electric-commands)) - (memq 'erlang-electric-gt - erlang-electric-commands)) - (not (erlang-in-literal)) - (looking-at "\\s *\\(%.*\\)?$") - (erlang-test-criteria-list erlang-electric-arrow-criteria)))) - - -(defun erlang-electric-gt (&optional arg) - "Insert a greater-than sign, and optionally mark it as a close paren." - - (interactive "p") - - (self-insert-command arg) - - (cond - ;; Did we just write a bit-syntax close (`>>')? - ((erlang-after-bitsyntax-close) - (save-excursion - ;; Then mark the two chars... - (backward-char 2) - (put-text-property (point) (1+ (point)) - 'category 'bitsyntax-close-inner) - (forward-char) - (put-text-property (point) (1+ (point)) - 'category 'bitsyntax-close-outer) - ;;...and unmark any subsequent greater-than chars. - (forward-char) - (while (eq (char-after (point)) ?>) - (remove-text-properties (point) (1+ (point)) - '(category nil)) - (forward-char)))) - - ;; Did we just write a function arrow (`->')? - ((erlang-after-arrow) - (let ((erlang-electric-newline-inhibit t)) - (undo-boundary) - (end-of-line) - (newline) - (condition-case nil - (erlang-indent-line) - (error (if (bolp) (delete-backward-char 1)))))) - - ;; Then it's just a plain greater-than. - (t - nil))) - - -(defun erlang-electric-arrow\ off (&optional arg) - "Insert a '>'-sign and possible a new indented line. - -This command is only `electric' when the `>' is part of an `->' arrow. -The variable `erlang-electric-arrow-criteria' states a sequence of -criteria, which decides when a newline should be inserted and the next -line indented. - -It behaves just like the normal greater than sign when supplied with a -numerical arg, point is inside string or comment, or when there are -non-whitespace characters following the point on the current line. - -After being split/merged into erlang-after-arrow and -erlang-electric-gt, it is now unused and disabled." - (interactive "P") - (let ((prec (preceding-char))) - (self-insert-command (prefix-numeric-value arg)) - (if (or arg - (and (listp erlang-electric-commands) - (not (memq 'erlang-electric-arrow - erlang-electric-commands))) - (not (eq prec ?-)) - (erlang-in-literal) - (not (looking-at "\\s *\\(%.*\\)?$")) - (null (erlang-test-criteria-list - erlang-electric-arrow-criteria))) - (setq erlang-electric-newline-inhibit nil) - (setq erlang-electric-newline-inhibit t) - (undo-boundary) - (end-of-line) - (newline) - (condition-case nil - (erlang-indent-line) - (error (if (bolp) (delete-backward-char 1))))))) - - -(defun erlang-electric-newline (&optional arg) - "Break line at point and indent, continuing comment if within one. -The variable `erlang-electric-newline-criteria' states a critera, -when fulfilled a newline is inserted and the next line is indeted. - -Should the current line begin with a comment, and the variable -`comment-multi-line' be non-nil, a new comment start is inserted. - -Should the previous command be another electric command we assume that -the user pressed newline out of old habit, hence we will do nothing." - (interactive "P") - (cond ((and (not arg) - erlang-electric-newline-inhibit - (memq last-command erlang-electric-newline-inhibit-list)) - ()) ; Do nothing! - ((or arg - (and (listp erlang-electric-commands) - (not (memq 'erlang-electric-newline - erlang-electric-commands))) - (null (erlang-test-criteria-list - erlang-electric-newline-criteria))) - (newline (prefix-numeric-value arg))) - (t - (if (and comment-multi-line - (save-excursion - (beginning-of-line) - (looking-at (concat "\\s *" comment-start-skip)))) - (let ((str (buffer-substring - (or (match-end 1) (match-beginning 0)) - (min (match-end 0) (point))))) - (newline) - (undo-boundary) - (insert str)) - (newline) - (undo-boundary) - (indent-according-to-mode))))) - - -(defun erlang-test-criteria-list (criteria) - "Given a list of criteria functions, test if criteria is fulfilled. - -Each element in the criteria list can a function returning nil, t or -the atom `stop'. t means that the criteria is fulfilled, `stop' means -that it the criteria isn't fulfilled and that the search should stop, -and nil means continue searching. - -Should the list contain the atom t the criteria is assumed to be -fulfilled, unless preceded by a function returning `stop', of course. - -Should the argument be the atom t instead of a list, the criteria is -assumed to be trivially true. - -Should all function return nil, the criteria is assumed not to be -fulfilled. - -Return t if criteria fulfilled, nil otherwise." - (if (eq criteria t) - t - (save-excursion - (let ((answer nil)) - (while (and criteria (null answer)) - (if (eq (car criteria) t) - (setq answer t) - (setq answer (funcall (car criteria)))) - (setq criteria (cdr criteria))) - (if (and answer (not (eq answer 'stop))) - t - nil))))) - - -(defun erlang-in-literal (&optional lim) - "Test if point is in string, quoted atom or comment. - -Return one of the three atoms `atom', `string', and `comment'. -Should the point be inside none of the above mentioned types of -context, nil is returned." - (save-excursion - (let* ((lim (or lim (save-excursion - (erlang-beginning-of-clause) - (point)))) - (state (parse-partial-sexp lim (point)))) - (cond - ((eq (nth 3 state) ?') 'atom) - ((nth 3 state) 'string) - ((nth 4 state) 'comment) - (t nil))))) - - -(defun erlang-at-end-of-function-p () - "Test if point is at end of an Erlang function. - -This function is designed to be a member of a criteria list." - (eq (save-excursion (erlang-skip-blank) (point)) - (save-excursion - (erlang-beginning-of-function -1) (point)))) - - -(defun erlang-stop-when-inside-argument-list () - "Return `stop' if inside parenthesis list, nil otherwise. - -Knows about the list comprehension syntax. When the point is -after `||', `stop' is not returned. - -This function is designed to be a member of a criteria list." - (save-excursion - (condition-case nil - (let ((orig-point (point)) - (state nil)) - (up-list -1) - (if (not (eq (following-char) ?\[)) - 'stop - ;; Do not return `stop' when inside a list comprehension - ;; construnction. (The point must be after `||'). - (while (< (point) orig-point) - (setq state (erlang-partial-parse (point) orig-point state))) - (if (and (car state) (eq (car (car (car state))) '||)) - nil - 'stop))) - (error - nil)))) - - -(defun erlang-stop-when-at-guard () - "Return `stop' when at function guards. - -This function is designed to be a member of a criteria list." - (save-excursion - (beginning-of-line) - (if (and (looking-at (concat "^" erlang-atom-regexp "\\s *(")) - (not (looking-at - (concat "^" erlang-atom-regexp ".*\\(->\\|:-\\)")))) - 'stop - nil))) - - -(defun erlang-next-lines-empty-p () - "Return non-nil if next lines are empty. - -The variable `erlang-next-lines-empty-threshold' contains the number -of lines required to be empty. - -A line containing only spaces and tabs is considered empty. - -This function is designed to be a member of a criteria list." - (and erlang-next-lines-empty-threshold - (save-excursion - (let ((left erlang-next-lines-empty-threshold) - (cont t)) - (while (and cont (> left 0)) - (forward-line 1) - (setq cont (looking-at "\\s *$")) - (setq left (- left 1))) - cont)))) - - -(defun erlang-at-keyword-end-p () - "Test if next readable token is the keyword end. - -This function is designed to be a member of a criteria list." - (save-excursion - (erlang-skip-blank) - (looking-at "end[^_a-zA-Z0-9]"))) - - -;; Erlang tags support which is aware of erlang modules. -;; -;; Not yet implemented under XEmacs. (Hint: The Emacs 19 etags -;; package work under XEmacs.) - -(eval-when-compile - (if (or (featurep 'bytecomp) - (featurep 'byte-compile)) - (progn - (require 'etags)))) - - -;; Variables: - -(defvar erlang-tags-function-alist - '((find-tag . erlang-find-tag) - (find-tag-other-window . erlang-find-tag-other-window) - (find-tag-regexp . erlang-find-tag-regexp) - (find-tag-other-frame . erlang-find-tag-other-frame)) - "Alist of old tags commands and the replacement functions.") - -(defvar erlang-tags-installed nil - "Non-nil when the Erlang tags system is installed.") -(defvar erlang-tags-file-list '() - "List of files in tag list. Used when finding tag on form `module:'.") -(defvar erlang-tags-completion-table nil - "Like `tags-completion-table', this table contains `tag' and `module:tag'.") -(defvar erlang-tags-buffer-installed-p nil - "Non-nil when erlang module recognising functions installed.") -(defvar erlang-tags-buffer-list '() - "Temporary list of buffers.") -(defvar erlang-tags-orig-completion-table nil - "Temporary storage for `tags-completion-table'.") -(defvar erlang-tags-orig-tag-order nil - "Temporary storage for `find-tag-tag-order'.") -(defvar erlang-tags-orig-regexp-tag-order nil - "Temporary storage for `find-tag-regexp-tag-order'.") -(defvar erlang-tags-orig-search-function nil - "Temporary storage for `find-tag-search-function'.") -(defvar erlang-tags-orig-regexp-search-function nil - "Temporary storage for `find-tag-regexp-search-function'.") -(defvar erlang-tags-orig-format-hooks nil - "Temporary storage for `tags-table-format-hooks'.") - -(defun erlang-tags-init () - "Install an alternate version of tags, aware of Erlang modules. - -After calling this function, the tags functions are aware of -Erlang modules. Tags can be entered on the for `module:tag' aswell -as on the old form `tag'. - -In the completion list, `module:tag' and `module:' shows up. - -Call this function from an appropriate init file, or add it to -Erlang mode hook with the commands: - (add-hook 'erlang-mode-hook 'erlang-tags-init) - (add-hook 'erlang-shell-mode-hook 'erlang-tags-init) - -This function only works under Emacs 18 and Emacs 19. Currently, It -is not implemented under XEmacs. (Hint: The Emacs 19 etags module -works under XEmacs.)" - (interactive) - (cond ((= erlang-emacs-major-version 18) - (require 'tags) - (erlang-tags-define-keys (current-local-map)) - (setq erlang-tags-installed t)) - (t - (require 'etags) - ;; Test on a function available in the Emacs 19 version - ;; of tags but not in the XEmacs version. - (if (not (fboundp 'find-tag-noselect)) - () - (erlang-tags-define-keys (current-local-map)) - (setq erlang-tags-installed t))))) - - -;; Set all keys bound to `find-tag' et.al. in the global map and the -;; menu to `erlang-find-tag' et.al. in `map'. -;; -;; The function `substitute-key-definition' does not work properly -;; in all version of Emacs. - -(defun erlang-tags-define-keys (map) - "Bind tags commands to keymap MAP aware of Erlang modules." - (let ((alist erlang-tags-function-alist)) - (while alist - (let* ((old (car (car alist))) - (new (cdr (car alist))) - (keys (append (where-is-internal old global-map)))) - (while keys - (define-key map (car keys) new) - (setq keys (cdr keys)))) - (setq alist (cdr alist)))) - ;; Update the menu. - (erlang-menu-substitute erlang-menu-base-items erlang-tags-function-alist) - (erlang-menu-init)) - - -;; There exists a variable `find-tag-default-function'. It is not used -;; since `complete-tag' uses it to get current word under point. In that -;; situation we doesn't want the module to be prepended. - -(defun erlang-find-tag-default () - "Return the default tag, searches `-import' list of imported functions. -Single quotes has been stripped away." - (let ((mod-func (erlang-get-function-under-point))) - (cond ((null mod-func) - nil) - ((null (car mod-func)) - (nth 1 mod-func)) - (t - (concat (car mod-func) ":" (nth 1 mod-func)))))) - - -;; Return `t' since it is used inside `tags-loop-form'. -;;;###autoload -(defun erlang-find-tag (modtagname &optional next-p regexp-p) - "Like `find-tag'. Capable of retreiving Erlang modules. - -Tags can be given on the forms `tag', `module:', `module:tag'." - (interactive (erlang-tag-interactive "Find `module:tag' or `tag': ")) - (switch-to-buffer (erlang-find-tag-noselect modtagname next-p regexp-p)) - t) - - -;; Code mainly from `find-tag-other-window' in `etags.el'. -;;;###autoload -(defun erlang-find-tag-other-window (tagname &optional next-p regexp-p) - "Like `find-tag-other-window' but aware of Erlang modules." - (interactive (erlang-tag-interactive - "Find `module:tag' or `tag' other window: ")) - - ;; This is to deal with the case where the tag is found in the - ;; selected window's buffer; without this, point is moved in both - ;; windows. To prevent this, we save the selected window's point - ;; before doing find-tag-noselect, and restore it afterwards. - (let* ((window-point (window-point (selected-window))) - (tagbuf (erlang-find-tag-noselect tagname next-p regexp-p)) - (tagpoint (progn (set-buffer tagbuf) (point)))) - (set-window-point (prog1 - (selected-window) - (switch-to-buffer-other-window tagbuf) - ;; We have to set this new window's point; it - ;; might already have been displaying a - ;; different portion of tagbuf, in which case - ;; switch-to-buffer-other-window doesn't set - ;; the window's point from the buffer. - (set-window-point (selected-window) tagpoint)) - window-point))) - - -(defun erlang-find-tag-other-frame (tagname &optional next-p) - "Like `find-tag-other-frame' but aware of Erlang modules." - (interactive (erlang-tag-interactive - "Find `module:tag' or `tag' other frame: ")) - (let ((pop-up-frames t)) - (erlang-find-tag-other-window tagname next-p))) - - -(defun erlang-find-tag-regexp (regexp &optional next-p other-window) - "Like `find-tag-regexp' but aware of Erlang modules." - (interactive (if (fboundp 'find-tag-regexp) - (erlang-tag-interactive - "Find `module:regexp' or `regexp': ") - (error "This version of Emacs can't find tags by regexps."))) - (funcall (if other-window - 'erlang-find-tag-other-window - 'erlang-find-tag) - regexp next-p t)) - - -;; Just like C-u M-. This could be added to the menu. -(defun erlang-find-next-tag () - (interactive) - (let ((current-prefix-arg '(4))) - (if erlang-tags-installed - (call-interactively 'erlang-find-tag) - (call-interactively 'find-tag)))) - - -;; Mimics `find-tag-noselect' found in `etags.el', but uses `find-tag' to -;; be compatible with `tags.el'. -;; -;; Handles three cases: -;; * `module:' Loop over all possible filen-ames. Stop if a file-name -;; without extension and directory matches the module. -;; -;; * `module:tag' -;; Emacs 19: Replace testfunctions with functions aware of -;; Erlang modules. Tricky because the etags system wasn't -;; built for these kind of operations... -;; -;; Emacs 18: We loop over `find-tag' until we find a file -;; whose module matches the requested module. The -;; drawback is that a lot of files could be loaded into -;; Emacs. -;; -;; * `tag' Just give it to `find-tag'. - -(defun erlang-find-tag-noselect (modtagname &optional next-p regexp-p) - "Like `find-tag-noselect' but aware of Erlang modules." - (interactive (erlang-tag-interactive "Find `module:tag' or `tag': ")) - (or modtagname - (setq modtagname (symbol-value 'last-tag))) - (funcall (symbol-function 'set) 'last-tag modtagname) - ;; `tags.el' uses this variable to record how M-, would - ;; know where to restart a tags command. - (if (boundp 'tags-loop-form) - (funcall (symbol-function 'set) - 'tags-loop-form '(erlang-find-tag nil t))) - (save-window-excursion - (cond - ((string-match ":$" modtagname) - ;; Only the module name was given. Read all files whose file name - ;; match. - (let ((modname (substring modtagname 0 (match-beginning 0))) - (file nil)) - (if (not next-p) - (save-excursion - (visit-tags-table-buffer) - (setq erlang-tags-file-list - (funcall (symbol-function 'tags-table-files))))) - (while (null file) - (or erlang-tags-file-list - (save-excursion - (if (and (featurep 'etags) - (funcall - (symbol-function 'visit-tags-table-buffer) 'same) - (funcall - (symbol-function 'visit-tags-table-buffer) t)) - (setq erlang-tags-file-list - (funcall (symbol-function 'tags-table-files))) - (error "No %stags containing %s" (if next-p "more " "") - modtagname)))) - (if erlang-tags-file-list - (let ((this-module (erlang-get-module-from-file-name - (car erlang-tags-file-list)))) - (if (and (stringp this-module) - (string= modname this-module)) - (setq file (car erlang-tags-file-list))) - (setq erlang-tags-file-list (cdr erlang-tags-file-list))))) - (set-buffer (or (get-file-buffer file) - (find-file-noselect file))))) - - ((string-match ":" modtagname) - (if (boundp 'find-tag-tag-order) - ;; Method one: Add module-recognising functions to the - ;; list of order functions. However, the tags system - ;; from Emacs 18, and derives thereof (read: XEmacs) - ;; hasn't got this feature. - (progn - (erlang-tags-install-module-check) - (unwind-protect - (funcall (symbol-function 'find-tag) - modtagname next-p regexp-p) - (erlang-tags-remove-module-check))) - ;; Method two: Call the tags system until a file matching - ;; the module is found. This could result in that many - ;; files are read. (e.g. The tag "foo:file" will take a - ;; while to process.) - (let* ((modname (substring modtagname 0 (match-beginning 0))) - (tagname (substring modtagname (match-end 0) nil)) - (last-tag tagname) - file) - (while - (progn - (funcall (symbol-function 'find-tag) tagname next-p regexp-p) - (setq next-p t) - ;; Determine the module form the file name. (The - ;; alternative, to check `-module', would make this - ;; code useless for non-Erlang programs.) - (setq file (erlang-get-module-from-file-name buffer-file-name)) - (not (and (stringp file) - (string= modname file)))))))) - (t - (funcall (symbol-function 'find-tag) modtagname next-p regexp-p))) - (current-buffer))) ; Return the new buffer. - - -;; Process interactive arguments for erlang-find-tag-*. -;; -;; Negative arguments work only for `etags', not `tags'. This is not -;; a problem since negative arguments means step back into the -;; history list, a feature not implemented in `tags'. - -(defun erlang-tag-interactive (prompt) - (condition-case nil - (require 'etags) - (error - (require 'tags))) - (if current-prefix-arg - (list nil (if (< (prefix-numeric-value current-prefix-arg) 0) - '- - t)) - (let* ((default (erlang-find-tag-default)) - (prompt (if default - (format "%s(default %s) " prompt default) - prompt)) - (spec (if (featurep 'etags) - (completing-read prompt 'erlang-tags-complete-tag) - (read-string prompt)))) - (list (if (equal spec "") - (or default (error "There is no default tag")) - spec))))) - - -;; Search tag functions which are aware of Erlang modules. The tactic -;; is to store new search functions into the local variabels of the -;; TAGS buffers. The variables are restored directly after the -;; search. The situation is complicated by the fact that new TAGS -;; files can be loaded during the search. -;; -;; This code is Emacs 19 `etags' specific. - -(defun erlang-tags-install-module-check () - "Install our own tag search functions." - ;; Make sure our functions are installed in TAGS files loaded - ;; into Emacs while searching. - (setq erlang-tags-orig-format-hooks - (symbol-value 'tags-table-format-hooks)) - (funcall (symbol-function 'set) 'tags-table-format-hooks - (cons 'erlang-tags-recognize-tags-table - erlang-tags-orig-format-hooks)) - (setq erlang-tags-buffer-list '()) - ;; Install our functions in the TAGS files already resident. - (save-excursion - (let ((files (symbol-value 'tags-table-computed-list))) - (while files - (if (stringp (car files)) - (if (get-file-buffer (car files)) - (progn - (set-buffer (get-file-buffer (car files))) - (erlang-tags-install-local)))) - (setq files (cdr files)))))) - - -(defun erlang-tags-install-local () - "Install our tag search functions in current buffer." - (if erlang-tags-buffer-installed-p - () - ;; Mark this buffer as "installed" and record. - (set (make-local-variable 'erlang-tags-buffer-installed-p) t) - (setq erlang-tags-buffer-list - (cons (current-buffer) erlang-tags-buffer-list)) - - ;; Save the original values. - (set (make-local-variable 'erlang-tags-orig-tag-order) - (symbol-value 'find-tag-tag-order)) - (set (make-local-variable 'erlang-tags-orig-regexp-tag-order) - (symbol-value 'find-tag-regexp-tag-order)) - (set (make-local-variable 'erlang-tags-orig-search-function) - (symbol-value 'find-tag-search-function)) - (set (make-local-variable 'erlang-tags-orig-regexp-search-function) - (symbol-value 'find-tag-regexp-search-function)) - - ;; Install our own functions. - (set (make-local-variable 'find-tag-search-function) - 'erlang-tags-search-forward) - (set (make-local-variable 'find-tag-regexp-search-function) - 'erlang-tags-regexp-search-forward) - (set (make-local-variable 'find-tag-tag-order) - '(erlang-tag-match-module-p)) - (set (make-local-variable 'find-tag-regexp-tag-order) - '(erlang-tag-match-module-regexp-p)))) - - -(defun erlang-tags-remove-module-check () - "Remove our own tags search functions." - (funcall (symbol-function 'set) - 'tags-table-format-hooks - erlang-tags-orig-format-hooks) - ;; Remove our functions from the TAGS files. (Note that - ;; `tags-table-computed-list' need not be the same list as when - ;; the search was started.) - (save-excursion - (let ((buffers erlang-tags-buffer-list)) - (while buffers - (if (buffer-name (car buffers)) - (progn - (set-buffer (car buffers)) - (erlang-tags-remove-local))) - (setq buffers (cdr buffers)))))) - - -(defun erlang-tags-remove-local () - "Remove our tag search functions from current buffer." - (if (null erlang-tags-buffer-installed-p) - () - (funcall (symbol-function 'set) 'erlang-tags-buffer-installed-p nil) - (funcall (symbol-function 'set) - 'find-tag-tag-order erlang-tags-orig-tag-order) - (funcall (symbol-function 'set) - 'find-tag-regexp-tag-order erlang-tags-orig-regexp-tag-order) - (funcall (symbol-function 'set) - 'find-tag-search-function erlang-tags-orig-search-function) - (funcall (symbol-function 'set) - 'find-tag-regexp-search-function - erlang-tags-orig-regexp-search-function))) - - -(defun erlang-tags-recognize-tags-table () - "Install our functions in all loaded TAGS files. - -This function is added to `tags-table-format-hooks' when searching -for a tag on the form `module:tag'." - (if (null (funcall (symbol-function 'etags-recognize-tags-table))) - nil - (erlang-tags-install-local) - t)) - - -(defun erlang-tags-search-forward (tag &optional bound noerror count) - "Forward search function, aware of Erlang module prefix." - (if (string-match ":" tag) - (setq tag (substring tag (match-end 0) nil))) - ;; Avoid uninteded recursion. - (if (eq erlang-tags-orig-search-function 'erlang-tags-search-forward) - (search-forward tag bound noerror count) - (funcall erlang-tags-orig-search-function tag bound noerror count))) - - -(defun erlang-tags-regexp-search-forward (tag &optional bound noerror count) - "Forward regexp search function, aware of Erlang module prefix." - (if (string-match ":" tag) - (setq tag (substring tag (match-end 0) nil))) - (if (eq erlang-tags-orig-regexp-search-function - 'erlang-tags-regexp-search-forward) - (re-search-forward tag bound noerror count) - (funcall erlang-tags-orig-regexp-search-function - tag bound noerror count))) - - -;; t if point is at a tag line that matches TAG, containing -;; module information. Assumes that all other order functions -;; are stored in `erlang-tags-orig-[regex]-tag-order'. - -(defun erlang-tag-match-module-p (tag) - (erlang-tag-match-module-common-p tag erlang-tags-orig-tag-order)) - -(defun erlang-tag-match-module-regexp-p (tag) - (erlang-tag-match-module-common-p tag erlang-tags-orig-regexp-tag-order)) - -(defun erlang-tag-match-module-common-p (tag order) - (let ((mod nil) - (found nil)) - (if (string-match ":" tag) - (progn - (setq mod (substring tag 0 (match-beginning 0))) - (setq tag (substring tag (match-end 0) nil)))) - (while (and order (not found)) - (setq found - (and (not (memq (car order) - '(erlang-tag-match-module-p - erlang-tag-match-module-regexp-p))) - (funcall (car order) tag))) - (setq order (cdr order))) - (and found - (or (null mod) - (string= mod (erlang-get-module-from-file-name - (file-of-tag))))))) - - -;;; Tags completion, Emacs 19 `etags' specific. -;;; -;;; The basic idea is to create a second completion table `erlang-tags- -;;; completion-table' containing all normal tags plus tags on the form -;;; `module:tag'. - - -(defun erlang-complete-tag () - "Perform tags completion on the text around point. -Completes to the set of names listed in the current tags table. - -Should the Erlang tags system be installed this command knows -about Erlang modules." - (interactive) - (condition-case nil - (require 'etags) - (error nil)) - (cond ((and erlang-tags-installed - (fboundp 'complete-tag)) ; Emacs 19 - (let ((orig-tags-complete-tag (symbol-function 'tags-complete-tag))) - (fset 'tags-complete-tag - (symbol-function 'erlang-tags-complete-tag)) - (unwind-protect - (funcall (symbol-function 'complete-tag)) - (fset 'tags-complete-tag orig-tags-complete-tag)))) - ((fboundp 'complete-tag) ; Emacs 19 - (funcall (symbol-function 'complete-tag))) - ((fboundp 'tag-complete-symbol) ; XEmacs - (funcall (symbol-function 'tag-complete-symbol))) - (t - (error "This version of Emacs can't complete tags.")))) - - -;; Based on `tags-complete-tag', but this one uses -;; `erlang-tag-completion-table' instead of `tag-completion-table'. -;; -;; This is the entry-point called by system function `completing-read'. -(defun erlang-tags-complete-tag (string predicate what) - (save-excursion - ;; If we need to ask for the tag table, allow that. - (let ((enable-recursive-minibuffers t)) - (visit-tags-table-buffer)) - (if (eq what t) - (all-completions string (erlang-tags-completion-table) predicate) - (try-completion string (erlang-tags-completion-table) predicate)))) - - -;; `tags-completion-table' calls itself recursively, make it -;; call our own wedge instead. Note that the recursive call -;; is very rare; it only occurs when a tags-file contains -;; `include'-statements. -(defun erlang-tags-completion-table () - "Build completion table. Tags on the form `tag' or `module:tag'." - (setq erlang-tags-orig-completion-table - (symbol-function 'tags-completion-table)) - (fset 'tags-completion-table - (symbol-function 'erlang-tags-completion-table-1)) - (unwind-protect - (erlang-tags-completion-table-1) - (fset 'tags-completion-table - erlang-tags-orig-completion-table))) - - -(defun erlang-tags-completion-table-1 () - (make-local-variable 'erlang-tags-completion-table) - (or erlang-tags-completion-table - (let ((tags-completion-table nil) - (tags-completion-table-function - 'erlang-etags-tags-completion-table)) - (funcall erlang-tags-orig-completion-table) - (setq erlang-tags-completion-table tags-completion-table)))) - - -;; Based on `etags-tags-completion-table'. The difference is that we -;; adds three symbols to the vector, the tag, module: and module:tag. -;; The module is extracted from the file name of a tag. (This one -;; only works if we are looking at an `etags' file. However, this is -;; the only format supported by Emacs, so far.) -(defun erlang-etags-tags-completion-table () - (let ((table (make-vector 511 0)) - (file nil)) - (save-excursion - (goto-char (point-min)) - ;; This monster regexp matches an etags tag line. - ;; \1 is the string to match; - ;; \2 is not interesting; - ;; \3 is the guessed tag name; XXX guess should be better eg DEFUN - ;; \4 is not interesting; - ;; \5 is the explicitly-specified tag name. - ;; \6 is the line to start searching at; - ;; \7 is the char to start searching at. - (while (progn - (while (and - (eq (following-char) ?\f) - (looking-at "\f\n\\([^,\n]*\\),.*\n")) - (setq file (buffer-substring - (match-beginning 1) (match-end 1))) - (goto-char (match-end 0))) - (re-search-forward - "\ -^\\(\\([^\177]+[^-a-zA-Z0-9_$\177]+\\)?\\([-a-zA-Z0-9_$?:]+\\)\ -\[^-a-zA-Z0-9_$?:\177]*\\)\177\\(\\([^\n\001]+\\)\001\\)?\ -\\([0-9]+\\)?,\\([0-9]+\\)?\n" - nil t)) - (let ((tag (if (match-beginning 5) - ;; There is an explicit tag name. - (buffer-substring (match-beginning 5) (match-end 5)) - ;; No explicit tag name. Best guess. - (buffer-substring (match-beginning 3) (match-end 3)))) - (module (and file - (erlang-get-module-from-file-name file)))) - (intern tag table) - (if (stringp module) - (progn - (intern (concat module ":" tag) table) - ;; Only the first one will be stored in the table. - (intern (concat module ":") table)))))) - table)) - -;;; -;;; Prepare for other methods to run an Erlang slave process. -;;; - -(defvar erlang-shell-function 'inferior-erlang - "Command to execute start a new Erlang shell. - -Change this variable to use your favorite -Erlang compilation package.") - -(defvar erlang-shell-display-function 'inferior-erlang-run-or-select - "Command to execute to display Erlang shell. - -Change this variable to use your favorite -Erlang compilation package.") - -(defvar erlang-compile-function 'inferior-erlang-compile - "Command to execute to compile current buffer. - -Change this variable to use your favorite -Erlang compilation package.") - -(defvar erlang-compile-display-function 'inferior-erlang-run-or-select - "Command to execute to view last compilation. - -Change this variable to use your favorite -Erlang compilation package.") - -(defvar erlang-next-error-function 'inferior-erlang-next-error - "Command to execute to go to the next error. - -Change this variable to use your favorite -Erlang compilation package.") - - -;;;###autoload -(defun erlang-shell () - "Start a new Erlang shell. - -The variable `erlang-shell-function' decides which method to use, -default is to start a new Erlang host. It is possible that, in the -future, a new shell on an already running host will be started." - (interactive) - (call-interactively erlang-shell-function)) - - -;;;###autoload (autoload 'run-erlang "erlang" "Start a new Erlang shell." t) - -;; It is customary for Emacs packages to supply a function on this -;; form, even though it violates the `erlang-*' name convention. -(fset 'run-erlang 'erlang-shell) - - -(defun erlang-shell-display () - "Display an Erlang shell, or start a new." - (interactive) - (call-interactively erlang-shell-display-function)) - - -;;;###autoload -(defun erlang-compile () - "Compile Erlang module in current buffer." - (interactive) - (call-interactively erlang-compile-function)) - - -(defun erlang-compile-display () - "Display compilation output." - (interactive) - (call-interactively erlang-compile-display-function)) - - -(defun erlang-next-error () - "Display next error message from the latest compilation." - (interactive) - (call-interactively erlang-next-error-function)) - - - -;;; -;;; Erlang Shell Mode -- Major mode used for Erlang shells. -;;; - -;; This mode is designed to be implementation independent, -;; e.g. it does not assume that we are running an inferior -;; Erlang, there exists a lot of other possibilities. - - -(defvar erlang-shell-buffer-name "*erlang*" - "*The name of the Erlang link shell buffer.") - - -(defvar erlang-shell-mode-map nil - "*Keymap used by Erlang shells.") - - -(defvar erlang-shell-mode-hook nil - "*User functions to run when an Erlang shell is started. - -This hook is used to change the behaviour of Erlang mode. It is -normally used by the user to personalise the programming environment. -When used in a site init file, it could be used to customise Erlang -mode for all users on the system. - -The functioned added to this hook is runed every time a new Erlang -shell is started. - -See also `erlang-load-hook', a hook which is runed once, when Erlang -mode is loaded, and `erlang-mode-hook' which is runed every time a new -Erlang source file is loaded into Emacs.") - - -(defvar erlang-input-ring-file-name "~/.erlang_history" - "*When non-nil, file name used to store erlang shell history information.") - - -(defun erlang-shell-mode () - "Major mode for interacting with an Erlang shell. - -We assume that we already are in comint-mode. - -The following special commands are available: -\\{erlang-shell-mode-map}" - (interactive) - (setq major-mode 'erlang-shell-mode) - (setq mode-name "Erlang Shell") - (erlang-mode-variables) - (if erlang-shell-mode-map - nil - (setq erlang-shell-mode-map (copy-keymap comint-mode-map)) - (erlang-shell-mode-commands erlang-shell-mode-map)) - (use-local-map erlang-shell-mode-map) - (set (make-local-variable 'compilation-parsing-end) 1) - (set (make-local-variable 'compilation-error-list) nil) - (set (make-local-variable 'compilation-old-error-list) nil) - ;; Needed when compiling directly from the Erlang shell. - (setq compilation-last-buffer (current-buffer)) - (erlang-add-compilation-alist erlang-error-regexp-alist) - (setq comint-prompt-regexp "^[^>=]*> *") - (setq comint-eol-on-send t) - (setq comint-input-ignoredups t) - (setq comint-scroll-show-maximum-output t) - (setq comint-scroll-to-bottom-on-output t) - ;; In Emacs 19.30, `add-hook' has got a `local' flag, use it. If - ;; the call fails, just call the normal `add-hook'. - (condition-case nil - (progn - (funcall (symbol-function 'add-hook) 'comint-output-filter-functions - 'inferior-erlang-strip-delete nil t) - (funcall (symbol-function 'add-hook) 'comint-output-filter-functions - 'inferior-erlang-strip-ctrl-m nil t)) - (error - (add-hook 'comint-output-filter-functions 'inferior-erlang-strip-delete) - (add-hook 'comint-output-filter-functions 'inferior-erlang-strip-ctrl-m))) - ;; Some older versions of comint doesn't have an input ring. - (if (fboundp 'comint-read-input-ring) - (progn - (setq comint-input-ring-file-name erlang-input-ring-file-name) - (comint-read-input-ring t) - (make-local-variable 'kill-buffer-hook) - (add-hook 'kill-buffer-hook 'comint-write-input-ring))) - (run-hooks 'erlang-shell-mode-hook)) - - -(defun erlang-shell-mode-commands (map) - (define-key map "\M-\t" 'erlang-complete-tag) - (define-key map "\C-a" 'comint-bol) ; Normally the other way around. - (define-key map "\C-c\C-a" 'beginning-of-line) - (define-key map "\C-d" nil) ; Was `comint-delchar-or-maybe-eof' - (define-key map "\C-x`" 'erlang-next-error)) - -;;; -;;; Inferior Erlang -- Run an Erlang shell as a subprocess. -;;; - -(defvar inferior-erlang-display-buffer-any-frame nil - "*When nil, `inferior-erlang-display-buffer' use only selected frame. -When t, all frames are searched. When 'raise, the frame is raised.") - -(defvar inferior-erlang-shell-type 'newshell - "The type of Erlang shell to use. - -When this variable is set to the atom `oldshell', the old shell is used. -When set to `newshell' the new shell is used. Should the variable be -nil, the default shell is used. - -This variable influence the setting of other variables.") - -(defvar inferior-erlang-machine "erl" - "*The name of the Erlang shell.") - -(defvar inferior-erlang-machine-options '() - "*The options used when activating the Erlang shell. - -This must be a list of strings.") - -(defvar inferior-erlang-process-name "inferior-erlang" - "*The name of the inferior Erlang process.") - -(defvar inferior-erlang-buffer-name erlang-shell-buffer-name - "*The name of the inferior erlang buffer.") - -(defvar inferior-erlang-prompt-timeout 60 - "*Number of seconds before `inferior-erlang-wait-prompt' timeouts. - -The time specified is waited after every output made by the inferior -Erlang shell. When this variable is t, we assume that we always have -a prompt. When nil, we will wait forever, or until C-g.") - -(defvar inferior-erlang-process nil - "Process of last invoked inferior Erlang, or nil.") - -(defvar inferior-erlang-buffer nil - "Buffer of last invoked inferior Erlang, or nil.") - -;;;###autoload -(defun inferior-erlang () - "Run an inferior Erlang. - -This is just like running Erlang in a normal shell, except that -an Emacs buffer is used for input and output. - -The command line history can be accessed with M-p and M-n. -The history is saved between sessions. - -Entry to this mode calls the functions in the variables -`comint-mode-hook' and `erlang-shell-mode-hook' with no arguments. - -The following commands imitate the usual Unix interrupt and -editing control characters: -\\{erlang-shell-mode-map}" - (interactive) - (require 'comint) - (let ((opts inferior-erlang-machine-options)) - (cond ((eq inferior-erlang-shell-type 'oldshell) - (setq opts (cons "-oldshell" opts))) - ((eq inferior-erlang-shell-type 'newshell) - (setq opts (append '("-newshell" "-env" "TERM" "vt100") opts)))) - (setq inferior-erlang-buffer - (apply 'make-comint - inferior-erlang-process-name inferior-erlang-machine - nil opts))) - (setq inferior-erlang-process - (get-buffer-process inferior-erlang-buffer)) - (process-kill-without-query inferior-erlang-process) - (switch-to-buffer inferior-erlang-buffer) - (if (and (not (eq system-type 'windows-nt)) - (eq inferior-erlang-shell-type 'newshell)) - (setq comint-process-echoes t)) - ;; `rename-buffer' takes only one argument in Emacs 18. - (condition-case nil - (rename-buffer inferior-erlang-buffer-name t) - (error (rename-buffer inferior-erlang-buffer-name))) - (erlang-shell-mode)) - - -(defun inferior-erlang-run-or-select () - "Switch to an inferior Erlang buffer, possibly starting new process." - (interactive) - (if (null (inferior-erlang-running-p)) - (inferior-erlang) - (inferior-erlang-display-buffer t))) - - -(defun inferior-erlang-display-buffer (&optional select) - "Make the inferior Erlang process visible. -The window is returned. - -Should `inferior-erlang-display-buffer-any-frame' be nil the buffer is -displayed in the current frame. Should it be non-nil, and the buffer -already is visible in any other frame, no new window will be created. -Should it be the atom 'raise, the frame containing the window will -be raised. - -Should the optional argument SELECT be non-nil, the window is -selected. Should the window be in another frame, that frame is raised. - -Note, should the mouse pointer be places outside the raised frame, that -frame will become deselected before the next command." - (interactive) - (or (inferior-erlang-running-p) - (error "No inferior Erlang process is running.")) - (let ((win (inferior-erlang-window - inferior-erlang-display-buffer-any-frame)) - (frames-p (fboundp 'selected-frame))) - (if (null win) - (let ((old-win (selected-window))) - (save-excursion - (switch-to-buffer-other-window inferior-erlang-buffer) - (setq win (selected-window))) - (select-window old-win)) - (if (and window-system - frames-p - (or select - (eq inferior-erlang-display-buffer-any-frame 'raise)) - (not (eq (selected-frame) (window-frame win)))) - (raise-frame (window-frame win)))) - (if select - (select-window win)) - (sit-for 0) - win)) - - -(defun inferior-erlang-running-p () - "Non-nil when an inferior Erlang is running." - (and inferior-erlang-process - (memq (process-status inferior-erlang-process) '(run open)) - inferior-erlang-buffer - (buffer-name inferior-erlang-buffer))) - - -(defun inferior-erlang-window (&optional all-frames) - "Return the window containing the inferior Erlang, or nil." - (and (inferior-erlang-running-p) - (if (and all-frames (>= erlang-emacs-major-version 19)) - (get-buffer-window inferior-erlang-buffer t) - (get-buffer-window inferior-erlang-buffer)))) - - -(defun inferior-erlang-wait-prompt () - "Wait until the inferior Erlang shell prompt appear." - (if (eq inferior-erlang-prompt-timeout t) - () - (or (inferior-erlang-running-p) - (error "No inferior Erlang shell is running.")) - (save-excursion - (set-buffer inferior-erlang-buffer) - (let ((msg nil)) - (while (save-excursion - (goto-char (process-mark inferior-erlang-process)) - (forward-line 0) - (not (looking-at comint-prompt-regexp))) - (if msg - () - (setq msg t) - (message "Waiting for Erlang shell prompt (press C-g to abort).")) - (or (accept-process-output inferior-erlang-process - inferior-erlang-prompt-timeout) - (error "No Erlang shell prompt before timeout."))) - (if msg (message "")))))) - - -(defun inferior-erlang-send-command (cmd &optional hist) - "Send command CMD to the inferior Erlang. - -The contents of the current command line (if any) will -be placed at the next prompt. - -If optional second argument is non-nil the command is inserted into -the history list. - -Return the position after the newly inserted command." - (or (inferior-erlang-running-p) - (error "No inferior Erlang process is running.")) - (let ((old-buffer (current-buffer)) - (insert-point (marker-position - (process-mark inferior-erlang-process))) - (insert-length (if comint-process-echoes - 0 - (1+ (length cmd))))) - (set-buffer inferior-erlang-buffer) - (goto-char insert-point) - (insert cmd) - ;; Strange things happend if `comint-eol-on-send' is declared - ;; in the `let' expression above, but setq:d here. The - ;; `set-buffer' statement obviously makes the buffer local - ;; instance of `comint-eol-on-send' shadow this one. - ;; I'm considering this a bug in Elisp. - (let ((comint-eol-on-send nil) - (comint-input-filter (if hist comint-input-filter 'ignore))) - (comint-send-input)) - ;; Adjust all windows whose points are incorrect. - (if (null comint-process-echoes) - (walk-windows - (function - (lambda (window) - (if (and (eq (window-buffer window) inferior-erlang-buffer) - (eq (window-point window) insert-point)) - (set-window-point window - (+ insert-point insert-length))))) - nil t)) - (set-buffer old-buffer) - (+ insert-point insert-length))) - - -(defun inferior-erlang-strip-delete (&optional s) - "Remove `^H' (delete) and the characters it was supposed to remove." - (interactive) - (if (and (boundp 'comint-last-input-end) - (boundp 'comint-last-output-start)) - (save-excursion - (goto-char - (if (interactive-p) - (symbol-value 'comint-last-input-end) - (symbol-value 'comint-last-output-start))) - (while (progn (skip-chars-forward "^\C-h") - (not (eq (point) (point-max)))) - (delete-char 1) - (or (bolp) - (backward-delete-char 1)))))) - - -;; Basically `comint-strip-ctrl-m', with a few extra checks. -(defun inferior-erlang-strip-ctrl-m (&optional string) - "Strip trailing `^M' characters from the current output group." - (interactive) - (if (and (boundp 'comint-last-input-end) - (boundp 'comint-last-output-start)) - (let ((pmark (process-mark (get-buffer-process (current-buffer))))) - (save-excursion - (goto-char - (if (interactive-p) - (symbol-value 'comint-last-input-end) - (symbol-value 'comint-last-output-start))) - (while (re-search-forward "\r+$" pmark t) - (replace-match "" t t)))))) - - -(defun inferior-erlang-compile () - "Compile the file in the current buffer. - -Should Erlang return `{error, nofile}' it could not load the object -module after completing the compilation. This is due to a bug in the -compile command `c' when using the option `outdir'. - -There exists two workarounds for this bug: - - 1) Place the directory in the Erlang load path. - - 2) Set the Emacs variable `erlang-compile-use-outdir' to nil. - To do so, place the following line in your `~/.emacs'-file: - (setq erlang-compile-use-outdir nil)" - (interactive) - (save-some-buffers) - (or (inferior-erlang-running-p) - (save-excursion - (inferior-erlang))) - (or (inferior-erlang-running-p) - (error "Error starting inferior Erlang shell.")) - (let ((dir (file-name-directory (buffer-file-name))) - ;;; (file (file-name-nondirectory (buffer-file-name))) - (noext (substring (buffer-file-name) 0 -4)) - ;; Hopefully, noone else will ever use these... - (tmpvar "Tmp7236") - (tmpvar2 "Tmp8742") - end) - (inferior-erlang-display-buffer) - (inferior-erlang-wait-prompt) - (setq end (inferior-erlang-send-command - (if erlang-compile-use-outdir - (format "c(\"%s\", [{outdir, \"%s\"}])." noext dir) - (format - (concat - "f(%s), {ok, %s} = file:get_cwd(), " - "file:set_cwd(\"%s\"), " - "%s = c(\"%s\"), file:set_cwd(%s), f(%s), %s.") - tmpvar2 tmpvar - dir - tmpvar2 noext tmpvar tmpvar tmpvar2)) - nil)) - (save-excursion - (set-buffer inferior-erlang-buffer) - (setq compilation-error-list nil) - (setq compilation-parsing-end end)) - (setq compilation-last-buffer inferior-erlang-buffer))) - - -;; `next-error' only accepts buffers with major mode `compilation-mode' -;; or with the minor mode `compilation-minor-mode' activated. -;; (To activate the minor mode is out of the question, since it will -;; ruin the inferior Erlang keymap.) -(defun inferior-erlang-next-error (&optional argp) - "Just like `next-error'. -Capable of finding error messages in an inferior Erlang buffer." - (interactive "P") - (let ((done nil) - (buf (and (boundp 'compilation-last-buffer) - compilation-last-buffer))) - (if (and (bufferp buf) - (save-excursion - (set-buffer buf) - (and (eq major-mode 'erlang-shell-mode) - (setq major-mode 'compilation-mode)))) - (unwind-protect - (progn - (setq done t) - (next-error argp)) - (save-excursion - (set-buffer buf) - (setq major-mode 'erlang-shell-mode)))) - (or done - (next-error argp)))) - - -(defun inferior-erlang-change-directory (&optional dir) - "Make the inferior erlang change directory. -The default is to go to the directory of the current buffer." - (interactive) - (or dir (setq dir (file-name-directory (buffer-file-name)))) - (or (inferior-erlang-running-p) - (error "No inferior Erlang is running.")) - (inferior-erlang-display-buffer) - (inferior-erlang-wait-prompt) - (inferior-erlang-send-command (format "cd('%s')." dir) nil)) - -;; Aliases for backward compatibility with older versions of Erlang Mode. -;; -;; Unfortuantely, older versions of Emacs doesn't have `defalias' and -;; `make-obsolete' so we have to define our own `obsolete' function. - -(defun erlang-obsolete (sym newdef) - "Make the obsolete function SYM refer to the defined function NEWDEF. - -Simplified version of a combination `defalias' and `make-obsolete', -it assumes that NEWDEF is loaded." - (fset sym (symbol-function newdef)) - (if (fboundp 'make-obsolete) - (make-obsolete sym newdef))) - - -(erlang-obsolete 'calculate-erlang-indent 'erlang-calculate-indent) -(erlang-obsolete 'calculate-erlang-stack-indent - 'erlang-calculate-stack-indent) -(erlang-obsolete 'at-erlang-keyword 'erlang-at-keyword) -(erlang-obsolete 'at-erlang-operator 'erlang-at-operator) -(erlang-obsolete 'beginning-of-erlang-clause 'erlang-beginning-of-clause) -(erlang-obsolete 'end-of-erlang-clause 'erlang-end-of-clause) -(erlang-obsolete 'mark-erlang-clause 'erlang-mark-clause) -(erlang-obsolete 'beginning-of-erlang-function 'erlang-beginning-of-function) -(erlang-obsolete 'end-of-erlang-function 'erlang-end-of-function) -(erlang-obsolete 'mark-erlang-function 'erlang-mark-function) -(erlang-obsolete 'pass-over-erlang-clause 'erlang-pass-over-function) -(erlang-obsolete 'name-of-erlang-function 'erlang-name-of-function) - - -;; The end... - -(provide 'erlang) - -(run-hooks 'erlang-load-hook) - -;;; erlang.el ends here diff --git a/emacs.d/elpa/erlang-2.4.1/erlang.elc b/emacs.d/elpa/erlang-2.4.1/erlang.elc deleted file mode 100644 index bfc4ae9..0000000 Binary files a/emacs.d/elpa/erlang-2.4.1/erlang.elc and /dev/null differ diff --git a/emacs.d/elpa/go-mode-20130809.1442/go-mode-autoloads.el b/emacs.d/elpa/go-mode-20130809.1442/go-mode-autoloads.el deleted file mode 100644 index 0d859b9..0000000 --- a/emacs.d/elpa/go-mode-20130809.1442/go-mode-autoloads.el +++ /dev/null @@ -1,101 +0,0 @@ -;;; go-mode-autoloads.el --- automatically extracted autoloads -;; -;;; Code: - - -;;;### (autoloads (go-download-play godoc gofmt-before-save go-mode) -;;;;;; "go-mode" "go-mode.el" (20999 39437 0 0)) -;;; Generated autoloads from go-mode.el - -(autoload 'go-mode "go-mode" "\ -Major mode for editing Go source text. - -This mode provides (not just) basic editing capabilities for -working with Go code. It offers almost complete syntax -highlighting, indentation that is almost identical to gofmt and -proper parsing of the buffer content to allow features such as -navigation by function, manipulation of comments or detection of -strings. - -In addition to these core features, it offers various features to -help with writing Go code. You can directly run buffer content -through gofmt, read godoc documentation from within Emacs, modify -and clean up the list of package imports or interact with the -Playground (uploading and downloading pastes). - -The following extra functions are defined: - -- `gofmt' -- `godoc' -- `go-import-add' -- `go-remove-unused-imports' -- `go-goto-imports' -- `go-play-buffer' and `go-play-region' -- `go-download-play' -- `godef-describe' and `godef-jump' -- `go-coverage' - -If you want to automatically run `gofmt' before saving a file, -add the following hook to your emacs configuration: - -\(add-hook 'before-save-hook 'gofmt-before-save) - -If you want to use `godef-jump' instead of etags (or similar), -consider binding godef-jump to `M-.', which is the default key -for `find-tag': - -\(add-hook 'go-mode-hook (lambda () - (local-set-key (kbd \"M-.\") 'godef-jump))) - -Please note that godef is an external dependency. You can install -it with - -go get code.google.com/p/rog-go/exp/cmd/godef - - -If you're looking for even more integration with Go, namely -on-the-fly syntax checking, auto-completion and snippets, it is -recommended that you look at goflymake -\(https://github.com/dougm/goflymake), gocode -\(https://github.com/nsf/gocode) and yasnippet-go -\(https://github.com/dominikh/yasnippet-go) - -\(fn)" t nil) - -(add-to-list 'auto-mode-alist (cons "\\.go\\'" 'go-mode)) - -(autoload 'gofmt-before-save "go-mode" "\ -Add this to .emacs to run gofmt on the current buffer when saving: - (add-hook 'before-save-hook 'gofmt-before-save). - -Note that this will cause go-mode to get loaded the first time -you save any file, kind of defeating the point of autoloading. - -\(fn)" t nil) - -(autoload 'godoc "go-mode" "\ -Show go documentation for a query, much like M-x man. - -\(fn QUERY)" t nil) - -(autoload 'go-download-play "go-mode" "\ -Downloads a paste from the playground and inserts it in a Go -buffer. Tries to look for a URL at point. - -\(fn URL)" t nil) - -;;;*** - -;;;### (autoloads nil nil ("go-mode-load.el" "go-mode-pkg.el") (20999 -;;;;;; 39437 769035 0)) - -;;;*** - -(provide 'go-mode-autoloads) -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; coding: utf-8 -;; End: -;;; go-mode-autoloads.el ends here diff --git a/emacs.d/elpa/go-mode-20130809.1442/go-mode-load.el b/emacs.d/elpa/go-mode-20130809.1442/go-mode-load.el deleted file mode 100644 index 3fc35c1..0000000 --- a/emacs.d/elpa/go-mode-20130809.1442/go-mode-load.el +++ /dev/null @@ -1,96 +0,0 @@ -;;; go-mode-load.el --- automatically extracted autoloads -;;; Commentary: - -;; To install go-mode, add the following lines to your .emacs file: -;; (add-to-list 'load-path "PATH CONTAINING go-mode-load.el" t) -;; (require 'go-mode-load) -;; -;; After this, go-mode will be used for files ending in '.go'. -;; -;; To compile go-mode from the command line, run the following -;; emacs -batch -f batch-byte-compile go-mode.el -;; -;; See go-mode.el for documentation. -;; -;; To update this file, evaluate the following form -;; (let ((generated-autoload-file buffer-file-name)) (update-file-autoloads "go-mode.el")) - -;;; Code: - - -;;;### (autoloads (go-download-play godoc gofmt-before-save go-mode) -;;;;;; "go-mode" "go-mode.el" (20767 50749)) -;;; Generated autoloads from go-mode.el - -(autoload 'go-mode "go-mode" "\ -Major mode for editing Go source text. - -This mode provides (not just) basic editing capabilities for -working with Go code. It offers almost complete syntax -highlighting, indentation that is almost identical to gofmt, -proper parsing of the buffer content to allow features such as -navigation by function, manipulation of comments or detection of -strings. - -Additionally to these core features, it offers various features to -help with writing Go code. You can directly run buffer content -through gofmt, read godoc documentation from within Emacs, modify -and clean up the list of package imports or interact with the -Playground (uploading and downloading pastes). - -The following extra functions are defined: - -- `gofmt' -- `godoc' -- `go-import-add' -- `go-remove-unused-imports' -- `go-goto-imports' -- `go-play-buffer' and `go-play-region' -- `go-download-play' - -If you want to automatically run `gofmt' before saving a file, -add the following hook to your emacs configuration: - -\(add-hook 'before-save-hook 'gofmt-before-save) - -If you're looking for even more integration with Go, namely -on-the-fly syntax checking, auto-completion and snippets, it is -recommended to look at goflymake -\(https://github.com/dougm/goflymake), gocode -\(https://github.com/nsf/gocode) and yasnippet-go -\(https://github.com/dominikh/yasnippet-go) - -\(fn)" t nil) - -(add-to-list 'auto-mode-alist (cons "\\.go\\'" 'go-mode)) - -(autoload 'gofmt-before-save "go-mode" "\ -Add this to .emacs to run gofmt on the current buffer when saving: - (add-hook 'before-save-hook 'gofmt-before-save). - -Note that this will cause go-mode to get loaded the first time -you save any file, kind of defeating the point of autoloading. - -\(fn)" t nil) - -(autoload 'godoc "go-mode" "\ -Show go documentation for a query, much like M-x man. - -\(fn QUERY)" t nil) - -(autoload 'go-download-play "go-mode" "\ -Downloads a paste from the playground and inserts it in a Go -buffer. Tries to look for a URL at point. - -\(fn URL)" t nil) - -;;;*** - -(provide 'go-mode-load) -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; coding: utf-8 -;; End: -;;; go-mode-load.el ends here diff --git a/emacs.d/elpa/go-mode-20130809.1442/go-mode-pkg.el b/emacs.d/elpa/go-mode-20130809.1442/go-mode-pkg.el deleted file mode 100644 index 26938a1..0000000 --- a/emacs.d/elpa/go-mode-20130809.1442/go-mode-pkg.el +++ /dev/null @@ -1,2 +0,0 @@ -(define-package "go-mode" "20130809.1442" "Major mode for the Go programming language [hg]" 'nil) - diff --git a/emacs.d/elpa/go-mode-20130809.1442/go-mode-pkg.elc b/emacs.d/elpa/go-mode-20130809.1442/go-mode-pkg.elc deleted file mode 100644 index 972b045..0000000 Binary files a/emacs.d/elpa/go-mode-20130809.1442/go-mode-pkg.elc and /dev/null differ diff --git a/emacs.d/elpa/go-mode-20130809.1442/go-mode.el b/emacs.d/elpa/go-mode-20130809.1442/go-mode.el deleted file mode 100644 index faa316a..0000000 --- a/emacs.d/elpa/go-mode-20130809.1442/go-mode.el +++ /dev/null @@ -1,1080 +0,0 @@ -;;; go-mode.el --- Major mode for the Go programming language - -;; Copyright 2013 The Go Authors. All rights reserved. -;; Use of this source code is governed by a BSD-style -;; license that can be found in the LICENSE file. - -(require 'cl) -(require 'etags) -(require 'ffap) -(require 'ring) -(require 'url) - -;; XEmacs compatibility guidelines -;; - Minimum required version of XEmacs: 21.5.32 -;; - Feature that cannot be backported: POSIX character classes in -;; regular expressions -;; - Functions that could be backported but won't because 21.5.32 -;; covers them: plenty. -;; - Features that are still partly broken: -;; - godef will not work correctly if multibyte characters are -;; being used -;; - Fontification will not handle unicode correctly -;; -;; - Do not use \_< and \_> regexp delimiters directly; use -;; go--regexp-enclose-in-symbol -;; -;; - The character `_` must not be a symbol constituent but a -;; character constituent -;; -;; - Do not use process-lines -;; -;; - Use go--old-completion-list-style when using a plain list as the -;; collection for completing-read -;; -;; - Use go--kill-whole-line instead of kill-whole-line (called -;; kill-entire-line in XEmacs) -;; -;; - Use go--position-bytes instead of position-bytes -(defmacro go--xemacs-p () - `(featurep 'xemacs)) - -(defalias 'go--kill-whole-line - (if (fboundp 'kill-whole-line) - 'kill-whole-line - 'kill-entire-line)) - -;; Delete the current line without putting it in the kill-ring. -(defun go--delete-whole-line (&optional arg) - ;; Emacs uses both kill-region and kill-new, Xemacs only uses - ;; kill-region. In both cases we turn them into operations that do - ;; not modify the kill ring. This solution does depend on the - ;; implementation of kill-line, but it's the only viable solution - ;; that does not require to write kill-line from scratch. - (flet ((kill-region (beg end) - (delete-region beg end)) - (kill-new (s) ())) - (go--kill-whole-line arg))) - - -;; XEmacs unfortunately does not offer position-bytes. We can fall -;; back to just using (point), but it will be incorrect as soon as -;; multibyte characters are being used. -(if (fboundp 'position-bytes) - (defalias 'go--position-bytes 'position-bytes) - (defun go--position-bytes (point) point)) - -(defun go--old-completion-list-style (list) - (mapcar (lambda (x) (cons x nil)) list)) - -;; GNU Emacs 24 has prog-mode, older GNU Emacs and XEmacs do not. -;; Ideally we'd use defalias instead, but that breaks in XEmacs. -;; -;; TODO: If XEmacs decides to add prog-mode, change this to use -;; defalias to alias prog-mode or fundamental-mode to go--prog-mode -;; and use that in define-derived-mode. -(if (not (fboundp 'prog-mode)) - (define-derived-mode prog-mode fundamental-mode "" "")) - -(defun go--regexp-enclose-in-symbol (s) - ;; XEmacs does not support \_<, GNU Emacs does. In GNU Emacs we make - ;; extensive use of \_< to support unicode in identifiers. Until we - ;; come up with a better solution for XEmacs, this solution will - ;; break fontification in XEmacs for identifiers such as "typeµ". - ;; XEmacs will consider "type" a keyword, GNU Emacs won't. - - (if (go--xemacs-p) - (concat "\\<" s "\\>") - (concat "\\_<" s "\\_>"))) - -;; Move up one level of parentheses. -(defun go-goto-opening-parenthesis (&optional legacy-unused) - ;; The old implementation of go-goto-opening-parenthesis had an - ;; optional argument to speed up the function. It didn't change the - ;; function's outcome. - - ;; Silently fail if there's no matching opening parenthesis. - (condition-case nil - (backward-up-list) - (scan-error nil))) - - -(defconst go-dangling-operators-regexp "[^-]-\\|[^+]\\+\\|[/*&><.=|^]") -(defconst go-identifier-regexp "[[:word:][:multibyte:]]+") -(defconst go-label-regexp go-identifier-regexp) -(defconst go-type-regexp "[[:word:][:multibyte:]*]+") -(defconst go-func-regexp (concat (go--regexp-enclose-in-symbol "func") "\\s *\\(" go-identifier-regexp "\\)")) -(defconst go-func-meth-regexp (concat - (go--regexp-enclose-in-symbol "func") "\\s *\\(?:(\\s *" - "\\(" go-identifier-regexp "\\s +\\)?" go-type-regexp - "\\s *)\\s *\\)?\\(" - go-identifier-regexp - "\\)(")) -(defconst go-builtins - '("append" "cap" "close" "complex" "copy" - "delete" "imag" "len" "make" "new" - "panic" "print" "println" "real" "recover") - "All built-in functions in the Go language. Used for font locking.") - -(defconst go-mode-keywords - '("break" "default" "func" "interface" "select" - "case" "defer" "go" "map" "struct" - "chan" "else" "goto" "package" "switch" - "const" "fallthrough" "if" "range" "type" - "continue" "for" "import" "return" "var") - "All keywords in the Go language. Used for font locking.") - -(defconst go-constants '("nil" "true" "false" "iota")) -(defconst go-type-name-regexp (concat "\\(?:[*(]\\)*\\(?:" go-identifier-regexp "\\.\\)?\\(" go-identifier-regexp "\\)")) - -(defvar go-dangling-cache) -(defvar go-godoc-history nil) - -(defgroup go nil - "Major mode for editing Go code" - :group 'languages) - -(defgroup go-cover nil - "Options specific to `cover`" - :group 'go) - -(defcustom go-fontify-function-calls t - "Fontify function and method calls if this is non-nil." - :type 'boolean - :group 'go) - -(defcustom go-mode-hook nil - "Hook called by `go-mode'." - :type 'hook - :group 'go) - -(defface go-coverage-untracked - '((t (:foreground "#505050"))) - "Coverage color of untracked code." - :group 'go-cover) - -(defface go-coverage-0 - '((t (:foreground "#c00000"))) - "Coverage color for uncovered code." - :group 'go-cover) -(defface go-coverage-1 - '((t (:foreground "#808080"))) - "Coverage color for covered code with weight 1." - :group 'go-cover) -(defface go-coverage-2 - '((t (:foreground "#748c83"))) - "Coverage color for covered code with weight 2." - :group 'go-cover) -(defface go-coverage-3 - '((t (:foreground "#689886"))) - "Coverage color for covered code with weight 3." - :group 'go-cover) -(defface go-coverage-4 - '((t (:foreground "#5ca489"))) - "Coverage color for covered code with weight 4." - :group 'go-cover) -(defface go-coverage-5 - '((t (:foreground "#50b08c"))) - "Coverage color for covered code with weight 5." - :group 'go-cover) -(defface go-coverage-6 - '((t (:foreground "#44bc8f"))) - "Coverage color for covered code with weight 6." - :group 'go-cover) -(defface go-coverage-7 - '((t (:foreground "#38c892"))) - "Coverage color for covered code with weight 7." - :group 'go-cover) -(defface go-coverage-8 - '((t (:foreground "#2cd495"))) - "Coverage color for covered code with weight 8. -For mode=set, all covered lines will have this weight." - :group 'go-cover) -(defface go-coverage-9 - '((t (:foreground "#20e098"))) - "Coverage color for covered code with weight 9." - :group 'go-cover) -(defface go-coverage-10 - '((t (:foreground "#14ec9b"))) - "Coverage color for covered code with weight 10." - :group 'go-cover) -(defface go-coverage-covered - '((t (:foreground "#2cd495"))) - "Coverage color of covered code." - :group 'go-cover) - -(defvar go-mode-syntax-table - (let ((st (make-syntax-table))) - (modify-syntax-entry ?+ "." st) - (modify-syntax-entry ?- "." st) - (modify-syntax-entry ?% "." st) - (modify-syntax-entry ?& "." st) - (modify-syntax-entry ?| "." st) - (modify-syntax-entry ?^ "." st) - (modify-syntax-entry ?! "." st) - (modify-syntax-entry ?= "." st) - (modify-syntax-entry ?< "." st) - (modify-syntax-entry ?> "." st) - (modify-syntax-entry ?/ (if (go--xemacs-p) ". 1456" ". 124b") st) - (modify-syntax-entry ?* ". 23" st) - (modify-syntax-entry ?\n "> b" st) - (modify-syntax-entry ?\" "\"" st) - (modify-syntax-entry ?\' "\"" st) - (modify-syntax-entry ?` "\"" st) - (modify-syntax-entry ?\\ "\\" st) - ;; It would be nicer to have _ as a symbol constituent, but that - ;; would trip up XEmacs, which does not support the \_< anchor - (modify-syntax-entry ?_ "w" st) - - st) - "Syntax table for Go mode.") - -(defun go--build-font-lock-keywords () - ;; we cannot use 'symbols in regexp-opt because emacs <24 doesn't - ;; understand that - (append - `((,(go--regexp-enclose-in-symbol (regexp-opt go-mode-keywords t)) . font-lock-keyword-face) - (,(go--regexp-enclose-in-symbol (regexp-opt go-builtins t)) . font-lock-builtin-face) - (,(go--regexp-enclose-in-symbol (regexp-opt go-constants t)) . font-lock-constant-face) - (,go-func-regexp 1 font-lock-function-name-face)) ;; function (not method) name - - (if go-fontify-function-calls - `((,(concat "\\(" go-identifier-regexp "\\)[[:space:]]*(") 1 font-lock-function-name-face) ;; function call/method name - (,(concat "(\\(" go-identifier-regexp "\\))[[:space:]]*(") 1 font-lock-function-name-face)) ;; bracketed function call - `((,go-func-meth-regexp 1 font-lock-function-name-face))) ;; method name - - `( - (,(concat (go--regexp-enclose-in-symbol "type") "[[:space:]]*\\([^[:space:]]+\\)") 1 font-lock-type-face) ;; types - (,(concat (go--regexp-enclose-in-symbol "type") "[[:space:]]*" go-identifier-regexp "[[:space:]]*" go-type-name-regexp) 1 font-lock-type-face) ;; types - (,(concat "[^[:word:][:multibyte:]]\\[\\([[:digit:]]+\\|\\.\\.\\.\\)?\\]" go-type-name-regexp) 2 font-lock-type-face) ;; Arrays/slices - (,(concat "\\(" go-identifier-regexp "\\)" "{") 1 font-lock-type-face) - (,(concat (go--regexp-enclose-in-symbol "map") "\\[[^]]+\\]" go-type-name-regexp) 1 font-lock-type-face) ;; map value type - (,(concat (go--regexp-enclose-in-symbol "map") "\\[" go-type-name-regexp) 1 font-lock-type-face) ;; map key type - (,(concat (go--regexp-enclose-in-symbol "chan") "[[:space:]]*\\(?:<-\\)?" go-type-name-regexp) 1 font-lock-type-face) ;; channel type - (,(concat (go--regexp-enclose-in-symbol "\\(?:new\\|make\\)") "\\(?:[[:space:]]\\|)\\)*(" go-type-name-regexp) 1 font-lock-type-face) ;; new/make type - ;; TODO do we actually need this one or isn't it just a function call? - (,(concat "\\.\\s *(" go-type-name-regexp) 1 font-lock-type-face) ;; Type conversion - (,(concat (go--regexp-enclose-in-symbol "func") "[[:space:]]+(" go-identifier-regexp "[[:space:]]+" go-type-name-regexp ")") 1 font-lock-type-face) ;; Method receiver - (,(concat (go--regexp-enclose-in-symbol "func") "[[:space:]]+(" go-type-name-regexp ")") 1 font-lock-type-face) ;; Method receiver without variable name - ;; Like the original go-mode this also marks compound literal - ;; fields. There, it was marked as to fix, but I grew quite - ;; accustomed to it, so it'll stay for now. - (,(concat "^[[:space:]]*\\(" go-label-regexp "\\)[[:space:]]*:\\(\\S.\\|$\\)") 1 font-lock-constant-face) ;; Labels and compound literal fields - (,(concat (go--regexp-enclose-in-symbol "\\(goto\\|break\\|continue\\)") "[[:space:]]*\\(" go-label-regexp "\\)") 2 font-lock-constant-face)))) ;; labels in goto/break/continue - -(defvar go-mode-map - (let ((m (make-sparse-keymap))) - (define-key m "}" 'go-mode-insert-and-indent) - (define-key m ")" 'go-mode-insert-and-indent) - (define-key m "," 'go-mode-insert-and-indent) - (define-key m ":" 'go-mode-insert-and-indent) - (define-key m "=" 'go-mode-insert-and-indent) - (define-key m (kbd "C-c C-a") 'go-import-add) - (define-key m (kbd "C-c C-j") 'godef-jump) - (define-key m (kbd "C-x 4 C-c C-j") 'godef-jump-other-window) - (define-key m (kbd "C-c C-d") 'godef-describe) - m) - "Keymap used by Go mode to implement electric keys.") - -(defun go-mode-insert-and-indent (key) - "Invoke the global binding of KEY, then reindent the line." - - (interactive (list (this-command-keys))) - (call-interactively (lookup-key (current-global-map) key)) - (indent-according-to-mode)) - -(defmacro go-paren-level () - `(car (syntax-ppss))) - -(defmacro go-in-string-or-comment-p () - `(nth 8 (syntax-ppss))) - -(defmacro go-in-string-p () - `(nth 3 (syntax-ppss))) - -(defmacro go-in-comment-p () - `(nth 4 (syntax-ppss))) - -(defmacro go-goto-beginning-of-string-or-comment () - `(goto-char (nth 8 (syntax-ppss)))) - -(defun go--backward-irrelevant (&optional stop-at-string) - "Skips backwards over any characters that are irrelevant for -indentation and related tasks. - -It skips over whitespace, comments, cases and labels and, if -STOP-AT-STRING is not true, over strings." - - (let (pos (start-pos (point))) - (skip-chars-backward "\n\s\t") - (if (and (save-excursion (beginning-of-line) (go-in-string-p)) (looking-back "`") (not stop-at-string)) - (backward-char)) - (if (and (go-in-string-p) (not stop-at-string)) - (go-goto-beginning-of-string-or-comment)) - (if (looking-back "\\*/") - (backward-char)) - (if (go-in-comment-p) - (go-goto-beginning-of-string-or-comment)) - (setq pos (point)) - (beginning-of-line) - (if (or (looking-at (concat "^" go-label-regexp ":")) (looking-at "^[[:space:]]*\\(case .+\\|default\\):")) - (end-of-line 0) - (goto-char pos)) - (if (/= start-pos (point)) - (go--backward-irrelevant stop-at-string)) - (/= start-pos (point)))) - -(defun go--buffer-narrowed-p () - "Return non-nil if the current buffer is narrowed." - (/= (buffer-size) - (- (point-max) - (point-min)))) - -(defun go-previous-line-has-dangling-op-p () - "Returns non-nil if the current line is a continuation line." - (let* ((cur-line (line-number-at-pos)) - (val (gethash cur-line go-dangling-cache 'nope))) - (if (or (go--buffer-narrowed-p) (equal val 'nope)) - (save-excursion - (beginning-of-line) - (go--backward-irrelevant t) - (setq val (looking-back go-dangling-operators-regexp)) - (if (not (go--buffer-narrowed-p)) - (puthash cur-line val go-dangling-cache)))) - val)) - -(defun go--at-function-definition () - "Return non-nil if point is on the opening curly brace of a -function definition. - -We do this by first calling (beginning-of-defun), which will take -us to the start of *some* function. We then look for the opening -curly brace of that function and compare its position against the -curly brace we are checking. If they match, we return non-nil." - (if (= (char-after) ?\{) - (save-excursion - (let ((old-point (point)) - start-nesting) - (beginning-of-defun) - (when (looking-at "func ") - (setq start-nesting (go-paren-level)) - (skip-chars-forward "^{") - (while (> (go-paren-level) start-nesting) - (forward-char) - (skip-chars-forward "^{") 0) - (if (and (= (go-paren-level) start-nesting) (= old-point (point))) - t)))))) - -(defun go--indentation-for-opening-parenthesis () - "Return the semantic indentation for the current opening parenthesis. - -If point is on an opening curly brace and said curly brace -belongs to a function declaration, the indentation of the func -keyword will be returned. Otherwise the indentation of the -current line will be returned." - (save-excursion - (if (go--at-function-definition) - (progn - (beginning-of-defun) - (current-indentation)) - (current-indentation)))) - -(defun go-indentation-at-point () - (save-excursion - (let (start-nesting (outindent 0)) - (back-to-indentation) - (setq start-nesting (go-paren-level)) - - (cond - ((go-in-string-p) - (current-indentation)) - ((looking-at "[])}]") - (go-goto-opening-parenthesis) - (if (go-previous-line-has-dangling-op-p) - (- (current-indentation) tab-width) - (go--indentation-for-opening-parenthesis))) - ((progn (go--backward-irrelevant t) (looking-back go-dangling-operators-regexp)) - ;; only one nesting for all dangling operators in one operation - (if (go-previous-line-has-dangling-op-p) - (current-indentation) - (+ (current-indentation) tab-width))) - ((zerop (go-paren-level)) - 0) - ((progn (go-goto-opening-parenthesis) (< (go-paren-level) start-nesting)) - (if (go-previous-line-has-dangling-op-p) - (current-indentation) - (+ (go--indentation-for-opening-parenthesis) tab-width))) - (t - (current-indentation)))))) - -(defun go-mode-indent-line () - (interactive) - (let (indent - shift-amt - end - (pos (- (point-max) (point))) - (point (point)) - (beg (line-beginning-position))) - (back-to-indentation) - (if (go-in-string-or-comment-p) - (goto-char point) - (setq indent (go-indentation-at-point)) - (if (looking-at (concat go-label-regexp ":\\([[:space:]]*/.+\\)?$\\|case .+:\\|default:")) - (decf indent tab-width)) - (setq shift-amt (- indent (current-column))) - (if (zerop shift-amt) - nil - (delete-region beg (point)) - (indent-to indent)) - ;; If initial point was within line's indentation, - ;; position after the indentation. Else stay at same point in text. - (if (> (- (point-max) pos) (point)) - (goto-char (- (point-max) pos)))))) - -(defun go-beginning-of-defun (&optional count) - (unless count (setq count 1)) - (let ((first t) failure) - (dotimes (i (abs count)) - (while (and (not failure) - (or first (go-in-string-or-comment-p))) - (if (>= count 0) - (progn - (go--backward-irrelevant) - (if (not (re-search-backward go-func-meth-regexp nil t)) - (setq failure t))) - (if (looking-at go-func-meth-regexp) - (forward-char)) - (if (not (re-search-forward go-func-meth-regexp nil t)) - (setq failure t))) - (setq first nil))) - (if (< count 0) - (beginning-of-line)) - (not failure))) - -(defun go-end-of-defun () - (let (orig-level) - ;; It can happen that we're not placed before a function by emacs - (if (not (looking-at "func")) - (go-beginning-of-defun -1)) - (skip-chars-forward "^{") - (forward-char) - (setq orig-level (go-paren-level)) - (while (>= (go-paren-level) orig-level) - (skip-chars-forward "^}") - (forward-char)))) - -;;;###autoload -(define-derived-mode go-mode prog-mode "Go" - "Major mode for editing Go source text. - -This mode provides (not just) basic editing capabilities for -working with Go code. It offers almost complete syntax -highlighting, indentation that is almost identical to gofmt and -proper parsing of the buffer content to allow features such as -navigation by function, manipulation of comments or detection of -strings. - -In addition to these core features, it offers various features to -help with writing Go code. You can directly run buffer content -through gofmt, read godoc documentation from within Emacs, modify -and clean up the list of package imports or interact with the -Playground (uploading and downloading pastes). - -The following extra functions are defined: - -- `gofmt' -- `godoc' -- `go-import-add' -- `go-remove-unused-imports' -- `go-goto-imports' -- `go-play-buffer' and `go-play-region' -- `go-download-play' -- `godef-describe' and `godef-jump' -- `go-coverage' - -If you want to automatically run `gofmt' before saving a file, -add the following hook to your emacs configuration: - -\(add-hook 'before-save-hook 'gofmt-before-save) - -If you want to use `godef-jump' instead of etags (or similar), -consider binding godef-jump to `M-.', which is the default key -for `find-tag': - -\(add-hook 'go-mode-hook (lambda () - (local-set-key (kbd \"M-.\") 'godef-jump))) - -Please note that godef is an external dependency. You can install -it with - -go get code.google.com/p/rog-go/exp/cmd/godef - - -If you're looking for even more integration with Go, namely -on-the-fly syntax checking, auto-completion and snippets, it is -recommended that you look at goflymake -\(https://github.com/dougm/goflymake), gocode -\(https://github.com/nsf/gocode) and yasnippet-go -\(https://github.com/dominikh/yasnippet-go)" - - ;; Font lock - (set (make-local-variable 'font-lock-defaults) - '(go--build-font-lock-keywords)) - - ;; Indentation - (set (make-local-variable 'indent-line-function) 'go-mode-indent-line) - - ;; Comments - (set (make-local-variable 'comment-start) "// ") - (set (make-local-variable 'comment-end) "") - (set (make-local-variable 'comment-use-syntax) t) - (set (make-local-variable 'comment-start-skip) "\\(//+\\|/\\*+\\)\\s *") - - (set (make-local-variable 'beginning-of-defun-function) 'go-beginning-of-defun) - (set (make-local-variable 'end-of-defun-function) 'go-end-of-defun) - - (set (make-local-variable 'parse-sexp-lookup-properties) t) - (if (boundp 'syntax-propertize-function) - (set (make-local-variable 'syntax-propertize-function) 'go-propertize-syntax)) - - (set (make-local-variable 'go-dangling-cache) (make-hash-table :test 'eql)) - (add-hook 'before-change-functions (lambda (x y) (setq go-dangling-cache (make-hash-table :test 'eql))) t t) - - - (setq imenu-generic-expression - '(("type" "^type *\\([^ \t\n\r\f]*\\)" 1) - ("func" "^func *\\(.*\\) {" 1))) - (imenu-add-to-menubar "Index") - - ;; Go style - (setq indent-tabs-mode t) - - ;; Handle unit test failure output in compilation-mode - ;; - ;; Note the final t argument to add-to-list for append, ie put these at the - ;; *ends* of compilation-error-regexp-alist[-alist]. We want go-test to be - ;; handled first, otherwise other elements will match that don't work, and - ;; those alists are traversed in *reverse* order: - ;; http://lists.gnu.org/archive/html/bug-gnu-emacs/2001-12/msg00674.html - (when (and (boundp 'compilation-error-regexp-alist) - (boundp 'compilation-error-regexp-alist-alist)) - (add-to-list 'compilation-error-regexp-alist 'go-test t) - (add-to-list 'compilation-error-regexp-alist-alist - '(go-test . ("^\t+\\([^()\t\n]+\\):\\([0-9]+\\):? .*$" 1 2)) t))) - -;;;###autoload -(add-to-list 'auto-mode-alist (cons "\\.go\\'" 'go-mode)) - -(defun go--apply-rcs-patch (patch-buffer) - "Apply an RCS-formatted diff from PATCH-BUFFER to the current -buffer." - (let ((target-buffer (current-buffer)) - ;; Relative offset between buffer line numbers and line numbers - ;; in patch. - ;; - ;; Line numbers in the patch are based on the source file, so - ;; we have to keep an offset when making changes to the - ;; buffer. - ;; - ;; Appending lines decrements the offset (possibly making it - ;; negative), deleting lines increments it. This order - ;; simplifies the forward-line invocations. - (line-offset 0)) - (save-excursion - (with-current-buffer patch-buffer - (goto-char (point-min)) - (while (not (eobp)) - (unless (looking-at "^\\([ad]\\)\\([0-9]+\\) \\([0-9]+\\)") - (error "invalid rcs patch or internal error in go--apply-rcs-patch")) - (forward-line) - (let ((action (match-string 1)) - (from (string-to-number (match-string 2))) - (len (string-to-number (match-string 3)))) - (cond - ((equal action "a") - (let ((start (point))) - (forward-line len) - (let ((text (buffer-substring start (point)))) - (with-current-buffer target-buffer - (decf line-offset len) - (goto-char (point-min)) - (forward-line (- from len line-offset)) - (insert text))))) - ((equal action "d") - (with-current-buffer target-buffer - (go--goto-line (- from line-offset)) - (incf line-offset len) - (go--delete-whole-line len))) - (t - (error "invalid rcs patch or internal error in go--apply-rcs-patch"))))))))) - -(defun gofmt () - "Formats the current buffer according to the gofmt tool." - - (interactive) - (let ((tmpfile (make-temp-file "gofmt" nil ".go")) - (patchbuf (get-buffer-create "*Gofmt patch*")) - (errbuf (get-buffer-create "*Gofmt Errors*")) - (coding-system-for-read 'utf-8) - (coding-system-for-write 'utf-8)) - - (with-current-buffer errbuf - (setq buffer-read-only nil) - (erase-buffer)) - (with-current-buffer patchbuf - (erase-buffer)) - - (write-region nil nil tmpfile) - - ;; We're using errbuf for the mixed stdout and stderr output. This - ;; is not an issue because gofmt -w does not produce any stdout - ;; output in case of success. - (if (zerop (call-process "gofmt" nil errbuf nil "-w" tmpfile)) - (if (zerop (call-process-region (point-min) (point-max) "diff" nil patchbuf nil "-n" "-" tmpfile)) - (progn - (kill-buffer errbuf) - (message "Buffer is already gofmted")) - (go--apply-rcs-patch patchbuf) - (kill-buffer errbuf) - (message "Applied gofmt")) - (message "Could not apply gofmt. Check errors for details") - (gofmt--process-errors (buffer-file-name) tmpfile errbuf)) - - (kill-buffer patchbuf) - (delete-file tmpfile))) - - -(defun gofmt--process-errors (filename tmpfile errbuf) - ;; Convert the gofmt stderr to something understood by the compilation mode. - (with-current-buffer errbuf - (goto-char (point-min)) - (insert "gofmt errors:\n") - (while (search-forward-regexp (concat "^\\(" (regexp-quote tmpfile) "\\):") nil t) - (replace-match (file-name-nondirectory filename) t t nil 1)) - (compilation-mode) - (display-buffer errbuf))) - -;;;###autoload -(defun gofmt-before-save () - "Add this to .emacs to run gofmt on the current buffer when saving: - (add-hook 'before-save-hook 'gofmt-before-save). - -Note that this will cause go-mode to get loaded the first time -you save any file, kind of defeating the point of autoloading." - - (interactive) - (when (eq major-mode 'go-mode) (gofmt))) - -(defun godoc--read-query () - "Read a godoc query from the minibuffer." - ;; Compute the default query as the symbol under the cursor. - ;; TODO: This does the wrong thing for e.g. multipart.NewReader (it only grabs - ;; half) but I see no way to disambiguate that from e.g. foobar.SomeMethod. - (let* ((bounds (bounds-of-thing-at-point 'symbol)) - (symbol (if bounds - (buffer-substring-no-properties (car bounds) - (cdr bounds))))) - (completing-read (if symbol - (format "godoc (default %s): " symbol) - "godoc: ") - (go--old-completion-list-style (go-packages)) nil nil nil 'go-godoc-history symbol))) - -(defun godoc--get-buffer (query) - "Get an empty buffer for a godoc query." - (let* ((buffer-name (concat "*godoc " query "*")) - (buffer (get-buffer buffer-name))) - ;; Kill the existing buffer if it already exists. - (when buffer (kill-buffer buffer)) - (get-buffer-create buffer-name))) - -(defun godoc--buffer-sentinel (proc event) - "Sentinel function run when godoc command completes." - (with-current-buffer (process-buffer proc) - (cond ((string= event "finished\n") ;; Successful exit. - (goto-char (point-min)) - (view-mode 1) - (display-buffer (current-buffer) t)) - ((/= (process-exit-status proc) 0) ;; Error exit. - (let ((output (buffer-string))) - (kill-buffer (current-buffer)) - (message (concat "godoc: " output))))))) - -;;;###autoload -(defun godoc (query) - "Show go documentation for a query, much like M-x man." - (interactive (list (godoc--read-query))) - (unless (string= query "") - (set-process-sentinel - (start-process-shell-command "godoc" (godoc--get-buffer query) - (concat "godoc " query)) - 'godoc--buffer-sentinel) - nil)) - -(defun go-goto-imports () - "Move point to the block of imports. - -If using - - import ( - \"foo\" - \"bar\" - ) - -it will move point directly behind the last import. - -If using - - import \"foo\" - import \"bar\" - -it will move point to the next line after the last import. - -If no imports can be found, point will be moved after the package -declaration." - (interactive) - ;; FIXME if there's a block-commented import before the real - ;; imports, we'll jump to that one. - - ;; Generally, this function isn't very forgiving. it'll bark on - ;; extra whitespace. It works well for clean code. - (let ((old-point (point))) - (goto-char (point-min)) - (cond - ((re-search-forward "^import ([^)]+)" nil t) - (backward-char 2) - 'block) - ((re-search-forward "\\(^import \\([^\"]+ \\)?\"[^\"]+\"\n?\\)+" nil t) - 'single) - ((re-search-forward "^[[:space:]\n]*package .+?\n" nil t) - (message "No imports found, moving point after package declaration") - 'none) - (t - (goto-char old-point) - (message "No imports or package declaration found. Is this really a Go file?") - 'fail)))) - -(defun go-play-buffer () - "Like `go-play-region', but acts on the entire buffer." - (interactive) - (go-play-region (point-min) (point-max))) - -(defun go-play-region (start end) - "Send the region to the Playground and stores the resulting -link in the kill ring." - (interactive "r") - (let* ((url-request-method "POST") - (url-request-extra-headers - '(("Content-Type" . "application/x-www-form-urlencoded"))) - (url-request-data (buffer-substring-no-properties start end)) - (content-buf (url-retrieve - "http://play.golang.org/share" - (lambda (arg) - (cond - ((equal :error (car arg)) - (signal 'go-play-error (cdr arg))) - (t - (re-search-forward "\n\n") - (kill-new (format "http://play.golang.org/p/%s" (buffer-substring (point) (point-max)))) - (message "http://play.golang.org/p/%s" (buffer-substring (point) (point-max))))))))))) - -;;;###autoload -(defun go-download-play (url) - "Downloads a paste from the playground and inserts it in a Go -buffer. Tries to look for a URL at point." - (interactive (list (read-from-minibuffer "Playground URL: " (ffap-url-p (ffap-string-at-point 'url))))) - (with-current-buffer - (let ((url-request-method "GET") url-request-data url-request-extra-headers) - (url-retrieve-synchronously (concat url ".go"))) - (let ((buffer (generate-new-buffer (concat (car (last (split-string url "/"))) ".go")))) - (goto-char (point-min)) - (re-search-forward "\n\n") - (copy-to-buffer buffer (point) (point-max)) - (kill-buffer) - (with-current-buffer buffer - (go-mode) - (switch-to-buffer buffer))))) - -(defun go-propertize-syntax (start end) - (save-excursion - (goto-char start) - (while (search-forward "\\" end t) - (put-text-property (1- (point)) (point) 'syntax-table (if (= (char-after) ?`) '(1) '(9)))))) - -(defun go-import-add (arg import) - "Add a new import to the list of imports. - -When called with a prefix argument asks for an alternative name -to import the package as. - -If no list exists yet, one will be created if possible. - -If an identical import has been commented, it will be -uncommented, otherwise a new import will be added." - - ;; - If there's a matching `// import "foo"`, uncomment it - ;; - If we're in an import() block and there's a matching `"foo"`, uncomment it - ;; - Otherwise add a new import, with the appropriate syntax - (interactive - (list - current-prefix-arg - (replace-regexp-in-string "^[\"']\\|[\"']$" "" (completing-read "Package: " (go--old-completion-list-style (go-packages)))))) - (save-excursion - (let (as line import-start) - (if arg - (setq as (read-from-minibuffer "Import as: "))) - (if as - (setq line (format "%s \"%s\"" as import)) - (setq line (format "\"%s\"" import))) - - (goto-char (point-min)) - (if (re-search-forward (concat "^[[:space:]]*//[[:space:]]*import " line "$") nil t) - (uncomment-region (line-beginning-position) (line-end-position)) - (case (go-goto-imports) - ('fail (message "Could not find a place to add import.")) - ('block - (save-excursion - (re-search-backward "^import (") - (setq import-start (point))) - (if (re-search-backward (concat "^[[:space:]]*//[[:space:]]*" line "$") import-start t) - (uncomment-region (line-beginning-position) (line-end-position)) - (insert "\n\t" line))) - ('single (insert "import " line "\n")) - ('none (insert "\nimport (\n\t" line "\n)\n"))))))) - -(defun go-root-and-paths () - (let* ((output (split-string (shell-command-to-string "go env GOROOT GOPATH") "\n")) - (root (car output)) - (paths (split-string (cadr output) ":"))) - (append (list root) paths))) - -(defun go--string-prefix-p (s1 s2 &optional ignore-case) - "Return non-nil if S1 is a prefix of S2. -If IGNORE-CASE is non-nil, the comparison is case-insensitive." - (eq t (compare-strings s1 nil nil - s2 0 (length s1) ignore-case))) - -(defun go--directory-dirs (dir) - "Recursively return all subdirectories in DIR." - (if (file-directory-p dir) - (let ((dir (directory-file-name dir)) - (dirs '()) - (files (directory-files dir nil nil t))) - (dolist (file files) - (unless (member file '("." "..")) - (let ((file (concat dir "/" file))) - (if (file-directory-p file) - (setq dirs (append (cons file - (go--directory-dirs file)) - dirs)))))) - dirs) - '())) - - -(defun go-packages () - (sort - (delete-dups - (mapcan - (lambda (topdir) - (let ((pkgdir (concat topdir "/pkg/"))) - (mapcan (lambda (dir) - (mapcar (lambda (file) - (let ((sub (substring file (length pkgdir) -2))) - (unless (or (go--string-prefix-p "obj/" sub) (go--string-prefix-p "tool/" sub)) - (mapconcat 'identity (cdr (split-string sub "/")) "/")))) - (if (file-directory-p dir) - (directory-files dir t "\\.a$")))) - (if (file-directory-p pkgdir) - (go--directory-dirs pkgdir))))) - (go-root-and-paths))) - 'string<)) - -(defun go-unused-imports-lines () - ;; FIXME Technically, -o /dev/null fails in quite some cases (on - ;; Windows, when compiling from within GOPATH). Practically, - ;; however, it has the same end result: There won't be a - ;; compiled binary/archive, and we'll get our import errors when - ;; there are any. - (reverse (remove nil - (mapcar - (lambda (line) - (if (string-match "^\\(.+\\):\\([[:digit:]]+\\): imported and not used: \".+\"$" line) - (if (string= (file-truename (match-string 1 line)) (file-truename buffer-file-name)) - (string-to-number (match-string 2 line))))) - (split-string (shell-command-to-string - (if (string-match "_test\.go$" buffer-file-truename) - "go test -c" - "go build -o /dev/null")) "\n"))))) - -(defun go-remove-unused-imports (arg) - "Removes all unused imports. If ARG is non-nil, unused imports -will be commented, otherwise they will be removed completely." - (interactive "P") - (save-excursion - (let ((cur-buffer (current-buffer)) flymake-state lines) - (when (boundp 'flymake-mode) - (setq flymake-state flymake-mode) - (flymake-mode-off)) - (save-some-buffers nil (lambda () (equal cur-buffer (current-buffer)))) - (if (buffer-modified-p) - (message "Cannot operate on unsaved buffer") - (setq lines (go-unused-imports-lines)) - (dolist (import lines) - (go--goto-line import) - (beginning-of-line) - (if arg - (comment-region (line-beginning-position) (line-end-position)) - (go--delete-whole-line))) - (message "Removed %d imports" (length lines))) - (if flymake-state (flymake-mode-on))))) - -(defun godef--find-file-line-column (specifier other-window) - "Given a file name in the format of `filename:line:column', -visit FILENAME and go to line LINE and column COLUMN." - (if (not (string-match "\\(.+\\):\\([0-9]+\\):\\([0-9]+\\)" specifier)) - (error "Unexpected godef output: %s" specifier) - (let ((filename (match-string 1 specifier)) - (line (string-to-number (match-string 2 specifier))) - (column (string-to-number (match-string 3 specifier)))) - (with-current-buffer (funcall (if other-window 'find-file-other-window 'find-file) filename) - (go--goto-line line) - (beginning-of-line) - (forward-char (1- column)) - (if (buffer-modified-p) - (message "Buffer is modified, file position might not have been correct")))))) - -(defun godef--call (point) - "Call godef, acquiring definition position and expression -description at POINT." - (if (go--xemacs-p) - (message "godef does not reliably work in XEmacs, expect bad results")) - (if (not buffer-file-name) - (message "Cannot use godef on a buffer without a file name") - (let ((outbuf (get-buffer-create "*godef*"))) - (with-current-buffer outbuf - (erase-buffer)) - (call-process-region (point-min) (point-max) "godef" nil outbuf nil "-i" "-t" "-f" (file-truename buffer-file-name) "-o" (number-to-string (go--position-bytes (point)))) - (with-current-buffer outbuf - (split-string (buffer-substring-no-properties (point-min) (point-max)) "\n"))))) - -(defun godef-describe (point) - "Describe the expression at POINT." - (interactive "d") - (condition-case nil - (let ((description (nth 1 (godef--call point)))) - (if (string= "" description) - (message "No description found for expression at point") - (message "%s" description))) - (file-error (message "Could not run godef binary")))) - -(defun godef-jump (point &optional other-window) - "Jump to the definition of the expression at POINT." - (interactive "d") - (condition-case nil - (let ((file (car (godef--call point)))) - (cond - ((string= "-" file) - (message "godef: expression is not defined anywhere")) - ((string= "godef: no identifier found" file) - (message "%s" file)) - ((go--string-prefix-p "godef: no declaration found for " file) - (message "%s" file)) - (t - (push-mark) - (ring-insert find-tag-marker-ring (point-marker)) - (godef--find-file-line-column file other-window)))) - (file-error (message "Could not run godef binary")))) - -(defun godef-jump-other-window (point) - (interactive "d") - (godef-jump point t)) - -(defun go--goto-line (line) - (goto-char (point-min)) - (forward-line (1- line))) - -(defun go--line-column-to-point (line column) - (save-excursion - (go--goto-line line) - (forward-char (1- column)) - (point))) - -(defstruct go--covered - start-line start-column end-line end-column covered count) - -(defun go-coverage (input) - "Open a clone of the current buffer and overlay it with -coverage information gathered via go test -coverprofile=INPUT." - (interactive "fCoverage file: ") - (let ((ranges '()) - (file-name (file-name-nondirectory (buffer-file-name))) - (gocov-buffer-name (concat (buffer-name) "")) - (max-count 0) - divisor) - - (with-temp-buffer - (insert-file-contents input) - (go--goto-line 2) ;; Skip over mode - (while (not (eobp)) - (let* ((parts (split-string (buffer-substring (point-at-bol) (point-at-eol)) ":")) - (file (car parts)) - (rest (split-string (nth 1 parts) "[., ]"))) - - (destructuring-bind - (start-line start-column end-line end-column num count) - (mapcar 'string-to-number rest) - - (if (> count max-count) - (setq max-count count)) - - (if (and (string= (file-name-nondirectory file) file-name)) - (push - (make-go--covered - :start-line start-line - :start-column start-column - :end-line end-line - :end-column end-column - :covered (/= count 0) - :count count) - ranges))) - - (forward-line))) - - (if (> max-count 0) - (setq divisor (log max-count)))) - - (with-current-buffer (or - (get-buffer gocov-buffer-name) - (clone-indirect-buffer gocov-buffer-name nil)) - (save-excursion - (remove-overlays) - (overlay-put - (make-overlay - (point-min) - (point-max)) - 'face 'go-coverage-untracked) - - (dolist (range ranges) - (let* ((count (go--covered-count range)) - (norm (cond - ((= count 0) - -0.1) - ((= max-count 1) - 0.8) - (t - (/ (log count) divisor)))) - (n (1+ (floor (* norm 9)))) - (face (concat "go-coverage-" (number-to-string n))) - (ov (make-overlay - (go--line-column-to-point - (go--covered-start-line range) - (go--covered-start-column range)) - (go--line-column-to-point - (go--covered-end-line range) - (go--covered-end-column range))))) - - (overlay-put ov 'face face) - (overlay-put ov 'help-echo (format "Count: %d" count))))) - - (display-buffer (current-buffer) 'display-buffer-reuse-window)))) - -(provide 'go-mode) diff --git a/emacs.d/elpa/go-mode-20130809.1442/go-mode.elc b/emacs.d/elpa/go-mode-20130809.1442/go-mode.elc deleted file mode 100644 index 224b5fb..0000000 Binary files a/emacs.d/elpa/go-mode-20130809.1442/go-mode.elc and /dev/null differ diff --git a/emacs.d/elpa/nose-0.1.1/nose-autoloads.el b/emacs.d/elpa/nose-0.1.1/nose-autoloads.el deleted file mode 100644 index 4429541..0000000 --- a/emacs.d/elpa/nose-0.1.1/nose-autoloads.el +++ /dev/null @@ -1,17 +0,0 @@ -;;; nose-autoloads.el --- automatically extracted autoloads -;; -;;; Code: - - -;;;### (autoloads nil nil ("nose-pkg.el" "nose.el") (20848 3769 807343)) - -;;;*** - -(provide 'nose-autoloads) -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; coding: utf-8 -;; End: -;;; nose-autoloads.el ends here diff --git a/emacs.d/elpa/nose-0.1.1/nose-pkg.el b/emacs.d/elpa/nose-0.1.1/nose-pkg.el deleted file mode 100644 index 7678683..0000000 --- a/emacs.d/elpa/nose-0.1.1/nose-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "nose" "0.1.1" "Easy Python test running in Emacs" (quote nil)) diff --git a/emacs.d/elpa/nose-0.1.1/nose-pkg.elc b/emacs.d/elpa/nose-0.1.1/nose-pkg.elc deleted file mode 100644 index 7798f8a..0000000 Binary files a/emacs.d/elpa/nose-0.1.1/nose-pkg.elc and /dev/null differ diff --git a/emacs.d/elpa/nose-0.1.1/nose.el b/emacs.d/elpa/nose-0.1.1/nose.el deleted file mode 100644 index 5ed8086..0000000 --- a/emacs.d/elpa/nose-0.1.1/nose.el +++ /dev/null @@ -1,185 +0,0 @@ -;;; nose.el --- Easy Python test running in Emacs - -;; Copyright (C) 2009 Jason Pellerin, Augie Fackler - -;; Licensed under the same terms as Emacs. - -;; Version: 0.1.1 -;; Keywords: nose python testing -;; Created: 04 Apr 2009 - -;; This file is NOT part of GNU Emacs. - -;; Licensed under the same terms as Emacs. - -;;; Commentary: -;; This gives a bunch of functions that handle running nosetests on a -;; particular buffer or part of a buffer. - -;;; Installation - -;; In your emacs config: -;; -;; (require 'nose) -;; ; next line only for people with non-eco non-global test runners -;; ; (add-to-list 'nose-project-names "my/crazy/runner") - -;; Note that if your global nose isn't called "nosetests", then you'll want to -;; redefine nose-global-name to be the command that should be used. - -;; By default, the root of a project is found by looking for any of the files -;; 'setup.py', '.hg' and '.git'. You can add files to check for to the file -;; list: -;; -;; ; (add-to-list 'nose-project-root-files "something") - -;; or you can change the project root test to detect in some other way -;; whether a directory is the project root: -;; -;; ; (setq nose-project-root-test (lambda (dirname) (equal dirname "foo"))) - -;; If you want dots as output, rather than the verbose output: -;; (defvar nose-use-verbose nil) ; default is t - -;; Probably also want some keybindings: -;; (add-hook 'python-mode-hook -;; (lambda () -;; (local-set-key "\C-ca" 'nosetests-all) -;; (local-set-key "\C-cm" 'nosetests-module) -;; (local-set-key "\C-c." 'nosetests-one) -;; (local-set-key "\C-cpa" 'nosetests-pdb-all) -;; (local-set-key "\C-cpm" 'nosetests-pdb-module) -;; (local-set-key "\C-cp." 'nosetests-pdb-one))) - -(require 'cl) ;; for "reduce" - -(defvar nose-project-names '("eco/bin/test")) -(defvar nose-project-root-files '("setup.py" ".hg" ".git")) -(defvar nose-project-root-test 'nose-project-root) -(defvar nose-global-name "nosetests") -(defvar nose-use-verbose t) - -(defun run-nose (&optional tests debug failed) - "run nosetests" - (let* ((nose (nose-find-test-runner)) - (where (nose-find-project-root)) - (args (concat (if debug "--pdb" "") - " " - (if failed "--failed" ""))) - (tnames (if tests tests ""))) - (if (not where) - (error - (format (concat "abort: nosemacs couldn't find a project root, " - "looked for any of %S") nose-project-root-files))) - (funcall (if debug - 'pdb - '(lambda (command) - (compilation-start command - nil - (lambda (mode) (concat "*nosetests*"))))) - (format - (concat "%s " - (if nose-use-verbose "-v " "") - "%s -w %s -c %ssetup.cfg %s") - (nose-find-test-runner) args where where tnames))) - ) - -(defun nosetests-all (&optional debug failed) - "run all tests" - (interactive) - (run-nose nil debug failed)) - -(defun nosetests-failed (&optional debug) - (interactive) - (nosetests-all debug t)) - -(defun nosetests-pdb-all () - (interactive) - (nosetests-all t)) - -(defun nosetests-module (&optional debug) - "run nosetests (via eggs/bin/test) on current buffer" - (interactive) - (run-nose buffer-file-name debug)) - -(defun nosetests-pdb-module () - (interactive) - (nosetests-module t)) - -(defun nosetests-one (&optional debug) - "run nosetests (via eggs/bin/test) on testable thing - at point in current buffer" - (interactive) - (run-nose (format "%s:%s" buffer-file-name (nose-py-testable)) debug)) - -(defun nosetests-pdb-one () - (interactive) - (nosetests-one t)) - -(defun nose-find-test-runner () - (message - (let ((result - (reduce '(lambda (x y) (or x y)) - (mapcar 'nose-find-test-runner-names nose-project-names)))) - (if result - result - nose-global-name)))) - -(defun nose-find-test-runner-names (runner) - "find eggs/bin/test in a parent dir of current buffer's file" - (nose-find-test-runner-in-dir-named - (file-name-directory buffer-file-name) runner)) - -(defun nose-find-test-runner-in-dir-named (dn runner) - (let ((fn (expand-file-name runner dn))) - (cond ((file-regular-p fn) fn) - ((equal dn "/") nil) - (t (nose-find-test-runner-in-dir-named - (file-name-directory (directory-file-name dn)) - runner))))) - -(defun nose-py-testable () - (let* ((inner-obj (inner-testable)) - (outer (outer-testable)) - ;; elisp can't return multiple values - (outer-def (car outer)) - (outer-obj (cdr outer))) - (cond ((equal outer-def "def") outer-obj) - ((equal inner-obj outer-obj) outer-obj) - (t (format "%s.%s" outer-obj inner-obj))))) - -(defun inner-testable () - (save-excursion - (re-search-backward - "^ \\{0,4\\}\\(class\\|def\\)[ \t]+\\([a-zA-Z0-9_]+\\)" nil t) - (buffer-substring-no-properties (match-beginning 2) (match-end 2)))) - -(defun outer-testable () - (save-excursion - (re-search-backward - "^\\(class\\|def\\)[ \t]+\\([a-zA-Z0-9_]+\\)" nil t) - (let ((result - (buffer-substring-no-properties (match-beginning 2) (match-end 2)))) - - (cons - (buffer-substring-no-properties (match-beginning 1) (match-end 1)) - result)))) - -(defun nose-find-project-root (&optional dirname) - (let ((dn - (if dirname - dirname - (file-name-directory buffer-file-name)))) - (cond ((funcall nose-project-root-test dn) (expand-file-name dn)) - ((equal (expand-file-name dn) "/") nil) - (t (nose-find-project-root - (file-name-directory (directory-file-name dn))))))) - -(defun nose-project-root (dirname) - (reduce '(lambda (x y) (or x y)) - (mapcar (lambda (d) (member d (directory-files dirname))) - nose-project-root-files))) - -(provide 'nose) - -;;; nose.el ends here diff --git a/emacs.d/elpa/nose-0.1.1/nose.elc b/emacs.d/elpa/nose-0.1.1/nose.elc deleted file mode 100644 index 7a31ebe..0000000 Binary files a/emacs.d/elpa/nose-0.1.1/nose.elc and /dev/null differ diff --git a/emacs.d/elpa/virtualenv-1.2/virtualenv-autoloads.el b/emacs.d/elpa/virtualenv-1.2/virtualenv-autoloads.el deleted file mode 100644 index 0d85e1e..0000000 --- a/emacs.d/elpa/virtualenv-1.2/virtualenv-autoloads.el +++ /dev/null @@ -1,44 +0,0 @@ -;;; virtualenv-autoloads.el --- automatically extracted autoloads -;; -;;; Code: - - -;;;### (autoloads (virtualenv-minor-mode virtualenv-deactivate virtualenv-workon) -;;;;;; "virtualenv" "virtualenv.el" (20848 3772)) -;;; Generated autoloads from virtualenv.el - -(autoload 'virtualenv-workon "virtualenv" "\ -Activate a virtual environment for python. -Optional argument ENV if non-nil, either use the string given as -the virtual environment or if not a string then query the user. - -\(fn &optional ENV)" t nil) - -(autoload 'virtualenv-deactivate "virtualenv" "\ - - -\(fn)" t nil) - -(autoload 'virtualenv-minor-mode "virtualenv" "\ -Toggle Virtualenv minor mode on or off. -With a prefix argument ARG, enable Virtualenv minor mode if ARG is -positive, and disable it otherwise. If called from Lisp, enable -the mode if ARG is omitted or nil, and toggle it if ARG is `toggle'. -\\{virtualenv-minor-mode-map} - -\(fn &optional ARG)" t nil) - -;;;*** - -;;;### (autoloads nil nil ("virtualenv-pkg.el") (20848 3772 415174)) - -;;;*** - -(provide 'virtualenv-autoloads) -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; coding: utf-8 -;; End: -;;; virtualenv-autoloads.el ends here diff --git a/emacs.d/elpa/virtualenv-1.2/virtualenv-pkg.el b/emacs.d/elpa/virtualenv-1.2/virtualenv-pkg.el deleted file mode 100644 index e27b96d..0000000 --- a/emacs.d/elpa/virtualenv-1.2/virtualenv-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "virtualenv" "1.2" "Virtualenv for Python -*- coding: utf-8 -*-" (quote nil)) diff --git a/emacs.d/elpa/virtualenv-1.2/virtualenv-pkg.elc b/emacs.d/elpa/virtualenv-1.2/virtualenv-pkg.elc deleted file mode 100644 index 9806f2e..0000000 Binary files a/emacs.d/elpa/virtualenv-1.2/virtualenv-pkg.elc and /dev/null differ diff --git a/emacs.d/elpa/virtualenv-1.2/virtualenv.el b/emacs.d/elpa/virtualenv-1.2/virtualenv.el deleted file mode 100644 index fc5e5b3..0000000 --- a/emacs.d/elpa/virtualenv-1.2/virtualenv.el +++ /dev/null @@ -1,429 +0,0 @@ -;;; virtualenv.el --- Virtualenv for Python -*- coding: utf-8 -*- - -;; Copyright (c) 2010-2012 Aaron Culich - -;; Author: Aaron Culich -;; Maintainer: Aaron Culich -;; Version: 1.2 -;; Created: September 2010 -;; Updated: September 2012 -;; Keywords: python virtualenv -;; Vcs-git: git://github.com/aculich/virtualenv.git -;; Vcs-Browser: http://github.com/aculich/virtualenv - -;; virtualenv.el is free software: you can redistribute it and/or modify it -;; under the terms of the GNU General Public License as published by the Free -;; Software Foundation, either version 3 of the License, or (at your option) -;; any later version. -;; -;; virtualenv.el 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 virtualenv.el. If not, see . - -;;; Commentary: - -;; This is a minor mode for setting the virtual environment for the -;; Python shell using virtualenv and supports both python-mode.el and -;; python.el. This minor mode was inspired by an earlier -;; implementation by Jesse Legg and Jeremiah Dodds, however this code -;; is a complete re-write with a GPLv3 license consistent with -;; GNU Emacs and python-mode.el. - -;; There are two ways to use virtualenv. - -;; 1) The quickest way to get started is to simply type: -;; M-x virtualenv-workon -;; Which will prompt you to enter the name of a directory in -;; ~/.virtualenvs that contains your chosen environment. You can -;; hit tab to show the available completions. - -;; You'll know that you're in virtualenv mode now when you see the -;; name of the virtualenv you selected in brackets. So if I were to -;; select my turbogears environment that I call tg2.1 then I would -;; see [tg2.1] appear in the mode line. To make sure you're new -;; python shell is set up correctly you can try running this little -;; snippet of python code: - -;; import os, sys -;; print os.environ -;; print sys.path - -;; 2) The recommended way to use virtualenv minor mode is to use a -;; .dir-locals.el file in the root of your project directory, however that -;; requires Emacs 23.1 or higher. There are two buffer-local variables that you -;; can set for virtualenv as shown in this example: - -;; in file /path/to/project/.dir-locals.el: -;; ((nil . ((virtualenv-workon . "tg2.1") -;; (virtualenv-default-directory . "/path/to/project/subdir")))) - -;; The .dir-locals.el is new in Emacs23 and is useful for other -;; things, too. You should read the dir-locals docs to understand the -;; format. The variable virtualenv-workon should just be a string the -;; same as you'd give to the interactive function. The variable -;; virtualenv-default-directory is useful when you want to have your -;; python process rooted in a particular directory when it starts, so -;; that no matter where you are in your project's hierarchy, if you -;; launch a python shell. This method is recommended because it is -;; more flexible and will allow multiple virtualenvs running at once -;; in future versions. - -;;; Bugs: - -;; All bug reports can be filed by opening a new issue on github at: -;; http://github.com/aculich/virtualenv/issues - -;;; TODO: - -;; * support for multiple python processes in different virtualenvs - -;; * add "paster shell" features - -;; * add support for shell-command - -;;; Code: - -(defgroup virtualenv nil - "Emacs support for python virtualenv." - :group 'python) - -(defcustom virtualenv-root - (or (getenv "WORKON_HOME") "~/.virtualenvs") - "Default location for user's virtual environments" - :group 'virtualenv - :type 'directory) - -(defcustom virtualenv-mode-string-format " [%s]" - "Format for the mode string. It should start with a space." - :group 'virtualenv - :type 'string) - -(defcustom virtualenv-workon-starts-python t - "If non-nil the `virtualenv-workon' will also start python." - :group 'virtualenv - :type 'boolean) - -(defvar virtualenv-mode-name-default " Virtualenv" - "The default name in the mode line in case `virtualenv-workon' is not set. -In practice you should never see this in the mode line, but it is -better to use this than for it to appear blank.") - -(defvar virtualenv-mode-name virtualenv-mode-name-default) - -(defvar virtualenv-executables-dir - (if (eq system-type 'windows-nt) "/Scripts" "/bin") - "The name of the directory containing executables. It is system -dependent.") - -(defvar virtualenv-default-directory nil - "Buffer-local variable that should be set in your project's -top-level .dir-locals.el file as the place you want to start the python shell. -When using paster set this to where your .ini files live, e.g.: \ -((nil . ((virtualenv-default-directory . \"/projects/foo\"))))") -(put 'virtualenv-default-directory 'safe-local-variable 'stringp) - -(defvar virtualenv-workon nil - "Buffer-local variable that should be set in your project's -top-level .dir-locals.el file, e.g.: \ -((nil . ((virtualenv-workon . \"tg2.1\"))))") -(put 'virtualenv-workon 'safe-local-variable 'stringp) - -(defvar virtualenv-workon-session nil - "The virtualenv that this emacs session will workon.") -(put 'virtualenv-default-directory 'risky-local-variable 'stringp) - -(defvar virtualenv-workon-history nil - "History list of virtual environments used.") - -(defvar virtualenv-saved-path nil - "Saves `exec-path' and the `PATH' environment variable when - invoking `virtualenv-workon'.") - -(defun virtualenv-formatted-mode-string (&optional name) - "Format the `virtualenv-mode-name' string. -Optional argument NAME is a string that will appear as [NAME] in -the mode line, however if NAME begins with a space the string -will be used verbatim. If NAME is nil and `virtualenv-workon' is -not set, then use `virtualenv-mode-name-default'." - (let* ((name (or name - virtualenv-workon-session - virtualenv-workon - virtualenv-mode-name-default))) - (if (string= " " (substring name 0 1)) - name - (format virtualenv-mode-string-format name)))) - -(defun virtualenv-update-mode-name (&optional name) - "Update the mode line with a string formatted for virtualenv. -Optional argument NAME is a string that will appear as [NAME] in -the mode line, however if NAME begins with a space the string -will be used verbatim. If NAME is nil and `virtualenv-workon' is -not set, then use `virtualenv-mode-name-default'." - (let ((string (virtualenv-formatted-mode-string name))) - (make-local-variable 'virtualenv-mode-name) - (setq virtualenv-mode-name string))) - -(defalias 'virtualenv-old-hack-dir-local-variables (symbol-function 'hack-dir-local-variables)) - -;;;###autoload -(defun virtualenv-workon (&optional env) - "Activate a virtual environment for python. -Optional argument ENV if non-nil, either use the string given as -the virtual environment or if not a string then query the user." - (interactive "P") - - ;; reset virtualenv-workon-session if env is non-nil and also not a - ;; string (e.g. invoked interactively with C-u prefix arg) - (when (and env (not (stringp env))) - (setq virtualenv-workon-session nil)) - - (defalias 'hack-dir-local-variables 'virtualenv-hack-dir-local-variables) - - ;; if env is a string, then just use it, otherwise check to see if - ;; we have already queried the user the session, at last querying - ;; the user if all else fails. - (let ((env - (cond - ((stringp env) env) - ((stringp virtualenv-workon-session) - virtualenv-workon-session) - (t - (let* ((default (car virtualenv-workon-history)) - (root (or (unless (file-directory-p virtualenv-root) - (let ((dir (read-directory-name - "Virtualenv Directory: " - (expand-file-name "~")))) - (funcall - (if (y-or-n-p - (format - "Save %s as virtualenv-root for future sessions?" - dir)) - 'customize-save-variable - 'customize-set-variable) - 'virtualenv-root - dir))) - virtualenv-root)) - (prompt (concat - "Virtualenv to activate" - (when default - (format " (default %s)" default)) - ": ")) - ;; look for directories in virtualenv-root that - ;; contain a bin directory for tab-completion - (dirs (remove - nil - (mapcar - (lambda (d) - (when (file-exists-p - (expand-file-name - (concat d virtualenv-executables-dir) - root)) - d)) - (directory-files root nil "^[^.]")))) - (result (completing-read prompt dirs nil t nil - 'virtualenv-workon-history - default))) - - ;; if the user entered nothing, then return the default - ;; if there is one - (if (not (string= result "")) - result - default)))))) - - (let* ((buffer (get-buffer "*Python*")) - (kill (or (when buffer - (yes-or-no-p - "Python process already running. Kill? "))))) - - (if (or (not buffer) kill) - (progn - (when buffer - (kill-buffer buffer)) - (setq virtualenv-workon-session env) - (let* ((bin (expand-file-name - (concat env virtualenv-executables-dir) - virtualenv-root)) - (oldpath (or (car virtualenv-saved-path) - (getenv "PATH"))) - (oldexec (or (cdr virtualenv-saved-path) - exec-path))) - (setq virtualenv-saved-path (cons oldpath oldexec)) - (add-to-list 'exec-path bin) - (setenv "PATH" - (if (eq system-type 'windows-nt) - (concat bin path-separator - (replace-regexp-in-string - (regexp-quote "/") "\\" oldpath)) - (concat bin path-separator oldpath)))) - (when virtualenv-workon-starts-python - (cond ((fboundp 'python-shell-switch-to-shell) - (python-shell-switch-to-shell)) - ((fboundp 'py-shell) - (py-shell)) - ((fboundp 'python-shell) - (python-shell)) - ((fboundp 'run-python) - (run-python)) - (t (error "Could not start a python shell!")))) - (message (format "Now using virtualenv: %s" env))) - (message "Not changing virtualenv"))))) - -;;;###autoload -(defun virtualenv-deactivate () - (interactive) - - (defalias 'hack-dir-local-variables (symbol-function 'virtualenv-old-hack-dir-local-variables)) - - (when virtualenv-saved-path - (setenv "PATH" (car virtualenv-saved-path)) - (setq exec-path (cdr virtualenv-saved-path))) - - (setq virtualenv-workon-session nil - virtualenv-saved-path nil) - (virtualenv-minor-mode 0)) - -;;;###autoload -(define-minor-mode virtualenv-minor-mode - nil ; use default docstring - nil ; the initial value - virtualenv-mode-name ; mode line indicator - nil ; keymap - :group 'virtualenv) ; group - -(defun virtualenv-minor-mode-on () - (interactive) - (when (or virtualenv-workon-session - virtualenv-workon) - (virtualenv-minor-mode t))) - -(add-hook 'virtualenv-minor-mode-hook 'virtualenv-update-mode-name) -(add-hook 'find-file-hook 'virtualenv-minor-mode-on t) - -;; This provides support for both python-mode.el and python.el by -;; adding defadvice to py-shell and python-shell. -(dolist (list '((python-shell-switch-to-shell . "python") - (py-shell . "python-mode") - (python-shell . "python") - (run-python . "python"))) - (let* ((func (car list)) - (file (cdr list)) - (doc (format "Set the environment with virtualenv before running %s." func))) - - (eval-after-load file -`(progn - -(defadvice ,func (around virtualenv activate) - ,doc - (let ((workon (or virtualenv-workon-session - virtualenv-workon))) - (if workon - (progn - (when (stringp virtualenv-default-directory) - (cd virtualenv-default-directory)) - (let* ((activate (expand-file-name - "activate" - (expand-file-name - (concat workon virtualenv-executables-dir) - virtualenv-root))) - (process-environment - (when (file-exists-p activate) - (split-string - (shell-command-to-string - (if (eq system-type 'windows-nt) - (format "call %s & cd %s && set" - activate default-directory) - (format "source %s; (cd %s && env)" - activate default-directory))) - "\n"))) - (exec-path (split-string (getenv "PATH") path-separator))) - ad-do-it - (hack-local-variables) - (virtualenv-minor-mode-on) - )) - ad-do-it))) - - -)))) - - -;; This is a hack on top of a hack, but it's the way I think dir-local -;; variables should work. The original implementation only loads -;; dir-locals if the buffer has a filename associated with it, however -;; for a python comint buffer or for dired, a call to -;; (buffer-file-name) returns nil. In that case we should use the -;; value of default-directory to check for the presence of -;; .dir-locals.el. This should actually have no effect on any existing -;; code because this hack-local-variables is only added to the -;; find-file-hook, so we can selectively enable this for other buffers -;; that we create, like python shells or dired. - -(defcustom virtualenv-enable-local-variables :all - "Defaults to :all and allows `virtualenv-hack-dir-local-variables' -to override the value of `enable-local-variables' for convenience when -`virtualenv-workon' is enabled." - :risky t - :type '(choice (const :tag "Query Unsafe" t) - (const :tag "Safe Only" :safe) - (const :tag "Do all" :all) - (const :tag "Use value of `enable-local-variables'" nil) - (other :tag "Query" other)) - :group 'virtualenv) - -(defun virtualenv-hack-dir-local-variables () - "Read per-directory local variables for the current buffer. -Store the directory-local variables in `dir-local-variables-alist' -and `file-local-variables-alist', without applying them." - (let ((path (or (buffer-file-name) - default-directory))) - (when (and (or virtualenv-enable-local-variables - enable-local-variables) - path - (not (file-remote-p path))) - ;; Find the variables file. - (let ((variables-file (dir-locals-find-file path)) - (class nil) - (dir-name nil)) - (cond - ((stringp variables-file) - (setq dir-name (file-name-directory path)) - (setq class (dir-locals-read-from-file variables-file))) - ((consp variables-file) - (setq dir-name (nth 0 variables-file)) - (setq class (nth 1 variables-file)))) - (when class - (let ((variables - (dir-locals-collect-variables - (dir-locals-get-class-variables class) dir-name nil))) - (when variables - (dolist (elt variables) - (unless (memq (car elt) '(eval mode)) - (setq dir-local-variables-alist - (assq-delete-all (car elt) dir-local-variables-alist))) - (push elt dir-local-variables-alist)) - ;; override enable-local-variables with - ;; virtualenv-enable-local-variables if set - (let ((enable-local-variables - (or virtualenv-enable-local-variables - enable-local-variables))) - (hack-local-variables-filter variables dir-name))))))))) - -(defvar virtualenv-dir-local-not-supported - (cond ((featurep 'xemacs) - "XEmacs is not officially supported.") - ((not (and (>= emacs-major-version 23) - (>= emacs-minor-version 1))) - "Emacs 23.1 is required for .dir-locals.el support."))) - -(eval-after-load "dired" - '(progn - (unless virtualenv-dir-local-not-supported - (add-hook 'dired-mode-hook 'hack-local-variables)) - (add-hook 'dired-mode-hook 'virtualenv-minor-mode-on t))) - -(provide 'virtualenv) - -;;; virtualenv.el ends here diff --git a/emacs.d/elpa/virtualenv-1.2/virtualenv.elc b/emacs.d/elpa/virtualenv-1.2/virtualenv.elc deleted file mode 100644 index 4967ca4..0000000 Binary files a/emacs.d/elpa/virtualenv-1.2/virtualenv.elc and /dev/null differ diff --git a/gitconfig b/gitconfig index 83dcebd..76b8090 100644 --- a/gitconfig +++ b/gitconfig @@ -2,7 +2,7 @@ name = brettlangdon email = brett@blangdon.com [credential] - helper = osxkeychain + helper = store [core] excludesfile = /Users/brettlangdon/.gitignore_global editor = emacs diff --git a/postactivate b/postactivate deleted file mode 100755 index dfff46f..0000000 --- a/postactivate +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/zsh -# This hook is run after every virtualenv is activated. - -proj_name=$(echo $VIRTUAL_ENV|awk -F'/' '{print $NF}') -if [ -d ~/Magnetic/$proj_name ] -then - cd ~/Magnetic/$proj_name -elif [ -d ~/src/$proj_name ] -then - cd ~/src/$proj_name -fi diff --git a/setup.sh b/setup.sh index be68b57..aaa8a19 100755 --- a/setup.sh +++ b/setup.sh @@ -34,29 +34,5 @@ for file in $files; do fi done -echo "Installing Elpy" -sudo pip install elpy jedi - -echo "Installing Virtualenvwrapper" -sudo pip install virtualenvwrapper - -echo "Setting up $WORKON_HOME" -WORKON_HOME=~/environments -mkdir -p $WORKON_HOME -file="postactivate" -if [ -e $file ] -then - echo "Moving $WORKON_HOME/$file to $olddir/$file" - mv $WORKON_HOME/$file $olddir - echo "Creating symlink to $file in $WORKON_HOME directory." - ln -s $dir/$file $WORKON_HOME/$file -fi - -echo "Setting up GOPATH" -mkdir -p $GOPATH - -echo "Setting up CHEF_PATH" -mkdir -p $CHEF_PATH - echo "Source ~/.zshrc" . ~/.zshrc diff --git a/zshrc b/zshrc index f619b7b..15f9953 100644 --- a/zshrc +++ b/zshrc @@ -2,21 +2,11 @@ ZSH=$HOME/.oh-my-zsh ZSH_THEME="bira" DISABLE_AUTO_UPDATE="true" COMPLETION_WAITING_DOTS="true" -plugins=(git brew pip python node npm urltools golang knife) +plugins=(git pip python node npm) source $ZSH/oh-my-zsh.sh -export PATH=/usr/local/Cellar/ruby/1.9.3-p374/bin:/usr/local/bin:/usr/local/sbin:$PATH -export WORKON_HOME=~/environments -alias up="vagrant up && vagrant ssh" -source /usr/local/bin/virtualenvwrapper.sh +export PATH=/usr/local/bin:/usr/local/sbin:$PATH export NODE_PATH=/usr/local/lib/node_modules -export GOPATH=$HOME/go -export PATH=$PATH:$GOPATH/bin -export CHEF_PATH=~/Magnetic/chef-repo unsetopt inc_append_history unsetopt share_history # share command history data -alias cr="codereivew" -alias crr="codereview --reviewers" -alias cri="codereview --issue" -alias vagrant_restart="sudo /Library/StartupItems/VirtualBox/VirtualBox restart"