This commit is contained in:
Raymundo Vasquez Ruiz
2019-10-09 20:36:55 +02:00
commit 87240f58db
223 changed files with 100952 additions and 0 deletions

18
elpa/0blayout-readme.txt Normal file
View File

@@ -0,0 +1,18 @@
This global minor mode provides a simple way to switch between layouts and
the buffers you left open before you switched (unless you closed it).
It doesn't require any setup at all more than:
(0blayout-mode)
When you start Emacs with 0blayout loaded, you will have a default layout
named "default", and then you can create new layouts (<prefix> C-c), switch
layouts (<prefix> C-b), and kill the current layout (<prefix> C-k).
The default <prefix> is (C-c C-l), but you can change it using:
(0blayout-add-keybindings-with-prefix "<your prefix>")
You can also customize-variable to change the name of the default session.
The project is hosted at https://github.com/etu/0blayout
There you can leave bug-reports and suggestions.
Another comparable mode is eyebrowse which have been developed for longer.

View File

@@ -0,0 +1,62 @@
;;; ac-js2-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (directory-file-name
(or (file-name-directory #$) (car load-path))))
;;;### (autoloads nil "ac-js2" "ac-js2.el" (0 0 0 0))
;;; Generated autoloads from ac-js2.el
(autoload 'ac-js2-expand-function "ac-js2" "\
Expand the function definition left of point.
Expansion will only occur for candidates whose documentation
string contain a function prototype.
\(fn)" t nil)
(autoload 'ac-js2-completion-function "ac-js2" "\
Function for `completions-at-point'.
\(fn)" nil nil)
(autoload 'ac-js2-company "ac-js2" "\
\(fn COMMAND &optional ARG &rest IGNORED)" t nil)
(autoload 'ac-js2-jump-to-definition "ac-js2" "\
Jump to the definition of an object's property, variable or function.
Navigation to a property definend in an Object literal isn't
implemented.
\(fn)" t nil)
(autoload 'ac-js2-mode "ac-js2" "\
A minor mode that provides auto-completion and navigation for Js2-mode.
\(fn &optional ARG)" t nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ac-js2" '("ac-js2-")))
;;;***
;;;### (autoloads nil "ac-js2-tests" "ac-js2-tests.el" (0 0 0 0))
;;; Generated autoloads from ac-js2-tests.el
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ac-js2-tests" '("completion-frontend-test")))
;;;***
;;;### (autoloads nil nil ("ac-js2-pkg.el") (0 0 0 0))
;;;***
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; ac-js2-autoloads.el ends here

View File

@@ -0,0 +1,11 @@
(define-package "ac-js2" "20190101.933" "Auto-complete source for Js2-mode, with navigation"
'((js2-mode "20090723")
(skewer-mode "1.4"))
:authors
'(("Scott Barnett" . "scott.n.barnett@gmail.com"))
:maintainer
'("Scott Barnett" . "scott.n.barnett@gmail.com")
:url "https://github.com/ScottyB/ac-js2")
;; Local Variables:
;; no-byte-compile: t
;; End:

View File

@@ -0,0 +1,76 @@
;;; Tests for ac-js2
(require 'ert)
(require 'skewer-mode)
(require 'js2-mode)
(require 'ac-js2)
;;; Must have a skewer client connected before running the tests
;; Need to call httpd-stop from main Emacs if running tests in batch mode
(unless skewer-clients
(run-skewer))
(ert-deftest ac-js2-candidates-test ()
"Test the major function that returns candidates for all frontends."
(let (property
property-dot
func-call
var)
(with-temp-buffer
(insert "
var temp = function(param1, param2) {
var localParam = 15;
return param1 + param2;
};
var look;
temp.aFun = function(lolParam) {};
temp.anotherFunction = function() { return {about: 3};}")
(setq ac-js2-evaluate-calls t)
(setq ac-js2-external-libraries nil)
(js2-mode)
(ac-js2-mode t)
(js2-parse)
(insert "tem")
(ac-js2-candidates)
(setq var ac-js2-skewer-candidates)
(delete-char -3)
(insert "temp.")
(js2-parse)
(ac-js2-candidates)
(setq property-dot ac-js2-skewer-candidates)
(delete-char -5)
(insert "temp.aF")
(js2-parse)
(ac-js2-candidates)
(setq property ac-js2-skewer-candidates))
(should (assoc 'anotherFunction property-dot))
(print property)
(should (assoc 'aFun property))
(should (assoc 'temp var))))
(defmacro completion-frontend-test (test-name completion-function)
"Utility for testing completion front ends.
TODO: cover more cases"
`(ert-deftest ,test-name ()
(let (var)
(with-temp-buffer
(insert "var testComplete = function(param1, param2) {};")
(js2-mode)
(ac-js2-mode t)
(js2-parse)
(insert "testComplet")
(funcall ',completion-function)
(setq var (thing-at-point 'word)))
(should (string= var "testComplete")))))
(completion-frontend-test auto-complete-test auto-complete)
(completion-frontend-test completion-at-point-test completion-at-point)

Binary file not shown.

View File

@@ -0,0 +1,608 @@
;;; ac-js2.el --- Auto-complete source for Js2-mode, with navigation
;; Copyright (C) 2013 Scott Barnett
;; Author: Scott Barnett <scott.n.barnett@gmail.com>
;; URL: https://github.com/ScottyB/ac-js2
;; Version: 1.0
;; Package-Requires: ((js2-mode "20090723")(skewer-mode "1.4"))
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; An attempt to get context sensitive Javascript completion in Emacs.
;; Basic completions are obtained by parsing Javascript code with
;; Js2-mode's parser.
;;
;; Installation
;;
;; Easiest way to get ac-js2 is to install it from MELPA. You may need
;; this snippet
;;
;; `(add-to-list 'package-archives
;; '("melpa" . "http://melpa.milkbox.net/packages/") t)'
;;
;; if you don't have it already to fetch packages from MELPA.
;;
;; Enable ac-js2 in js2-mode as follows:
;;
;; (add-hook 'js2-mode-hook 'ac-js2-mode)
;;
;; Ac-js2 does not require auto-complete mode but I suggest you grab
;; it anyway as ac-js2 is designed to work with a completion frontend.
;; Support for Company mode is on its way.
;;
;; For more comprehensive completions you can opt to evaluate the code
;; for candidates. A browser needs to be connected to Emacs for the
;; evaluation completions to work. Put this in your init.el file.
;;
;; `(setq ac-js2-evaluate-calls t)'
;;
;; To add completions for external libraries add something like this:
;;
;; (add-to-list 'ac-js2-external-libraries "path/to/lib/library.js")
;;
;; Then connect a browser to Emacs by calling `(run-skewer)'. You may
;; need to save the buffer for completions to start.
;;
;; If auto-complete mode is installed on your system then completions
;; should start showing up otherwise use `completion-at-point'.
;;
;; Note: library completions will only work if `ac-js2-evaluate-calls'
;; is set and a browser is connected to Emacs.
;;
;; Bonus: M-. is bound to `ac-js2-jump-to-definition' which will jump
;; to Javascript definitions found in the same buffer. Given the
;; following proprety reference:
;;
;; foo.bar.baz();
;;
;; placing the cursor on `foo', `bar' or `baz' and executing M-. will
;; take you straight to their respective definitions. Use M-, to jump
;; back to where you were. Also works for object literals.
;;
;; Recently added `ac-js2-expand-function' that will expand a function's
;; parameters bound to `C-c C-c`. Expansion will only work if the cursor
;; is after the function.
;;
;; If you have any issues or suggestions please create an issue on Github:
;; https://github.com/ScottyB/ac-js2
;;; History:
;; Version 1.0
;; * Navigation within current buffer
;; * Completion and docstring for objects via Skewer
;; * External library support
;; * Basic completions of objects in current buffer
;;; Code:
(require 'js2-mode)
(require 'skewer-mode)
(require 'cl-lib)
(require 'etags)
(defgroup ac-js2 nil
"Auto-completion for js2-mode."
:group 'completion
:prefix "ac-js2-")
;;; Configuration variables
(defcustom ac-js2-add-ecma-262-externs t
"If non-nil add `js2-ecma-262-externs' to completion candidates.")
(defcustom ac-js2-add-browser-externs t
"If non-nil add `js2-browser-externs' to completion candidates.")
(defcustom ac-js2-add-keywords t
"If non-nil add `js2-keywords' to completion candidates.")
(defcustom ac-js2-add-prototype-completions t
"When non-nil traverse the prototype chain adding to completion candidates.")
(defcustom ac-js2-external-libraries '()
"List of absolute paths to external Javascript libraries.")
(defcustom ac-js2-evaluate-calls nil
"Warning. When true function calls will be evaluated in the browser.
This may cause undesired side effects however it will
provide better completions. Use at your own risk.")
(defcustom ac-js2-force-reparse t
"Force Js2-mode to reparse buffer before fetching completion candidates.")
;;; Internal variables
(defvar ac-js2-keywords '()
"Cached string version of `js2-keywords'.")
(defvar ac-js2-candidates '())
;; Types of skewer completion methods available
(defconst ac-js2-method-eval 0)
(defconst ac-js2-method-global 1
"Return candidates for the global object.
Only keys of the object are returned as the other properties come
from js2-mode's externs.")
(defvar ac-js2-data-root (file-name-directory load-file-name)
"Location of data files needed for `ac-js2-on-skewer-load'.")
;;; Skewer integration
(defvar ac-js2-skewer-candidates '()
"Cadidates obtained from skewering.")
(defun ac-js2-on-skewer-load ()
"Inject skewer addon and evaluate external libraries in browser."
(insert-file-contents (expand-file-name "skewer-addon.js" ac-js2-data-root))
(and ac-js2-evaluate-calls
(mapcar (lambda (library)
(with-temp-buffer
(insert-file-contents (expand-file-name library))
(skewer-eval (buffer-string)
nil
:type "complete"))) ac-js2-external-libraries)))
(defun ac-js2-skewer-completion-candidates ()
"Get completions returned from skewer."
(mapcar (lambda (candidate) (symbol-name (car candidate))) ac-js2-skewer-candidates))
(defun ac-js2-skewer-document-candidates (name)
"Return document string for NAME from skewer."
(let ((doc (cdr (assoc-string name ac-js2-skewer-candidates))))
(or (ac-js2-format-function doc) doc)))
(defun ac-js2-get-object-properties (name)
"Find properties of NAME for completion."
(ac-js2-skewer-eval-wrapper name `((prototypes . ,ac-js2-add-prototype-completions))))
(defun ac-js2-skewer-result-callback (result)
"Process the RESULT passed from the browser."
(let ((value (cdr (assoc 'value result))))
(if (and (skewer-success-p result) value)
(setq ac-js2-skewer-candidates (append value nil)))))
(defun ac-js2-skewer-eval-wrapper (str &optional extras)
"Wrap `skewer-eval-synchronously' to check if a skewer-client is avilable.
STR is the text to send to the browser for evaluation. Extra
parameters can be passed to the browser using EXTRAS. EXTRAS must
be of the form (param-string . value) where param-string is the
reference and value is the value that can be retrieved from the
request object in Javacript."
(setq ac-js2-skewer-candidates nil)
(if skewer-clients
(if (or ac-js2-evaluate-calls
(not (ac-js2-has-function-calls str)))
(ac-js2-skewer-result-callback
(skewer-eval-synchronously str
:type "complete"
:extra extras)))
(setq skewer-queue nil)))
;; Generate candidates
(defun ac-js2-candidates ()
"Main function called to gather candidates for auto-completion."
(if ac-js2-force-reparse (js2-reparse))
(let ((node (js2-node-parent (js2-node-at-point (1- (point)))))
beg
(prop-get-regex "[a-zA-Z)]\\.")
name)
(setq ac-js2-candidates nil)
(cond
((looking-back "\\.")
;; TODO: Need to come up with a better way to extract object than this regex!!
(save-excursion
(setq beg (and (skip-chars-backward "[a-zA-Z_$][0-9a-zA-Z_$#\"())]+\\.") (point))))
(setq name (buffer-substring-no-properties beg (1- (point))))
(ac-js2-get-object-properties name)
(setq node (ac-js2-initialized-node (if (string-match prop-get-regex name)
(reverse (split-string name prop-get-regex)) name)))
(if (js2-object-node-p node)
(setq ac-js2-candidates
(mapcar (lambda (elem)
(ac-js2-format-node (js2-node-string (js2-object-prop-node-left elem))
elem))
(js2-object-node-elems node))))
(append (mapcar 'cl-first ac-js2-candidates)
(ac-js2-skewer-completion-candidates)))
((js2-prop-get-node-p node)
(setq node (js2-prop-get-node-left node))
(setq name (js2-node-string node))
(ac-js2-get-object-properties name)
(ac-js2-skewer-completion-candidates))
(t
(ac-js2-skewer-eval-wrapper "" `((method . ,ac-js2-method-global)))
(append (ac-js2-skewer-completion-candidates)
(ac-js2-add-extra-completions
(mapcar 'cl-first (ac-js2-get-names-in-scope))))))))
(defun ac-js2-document (name)
"Show documentation for NAME from local buffer if present
otherwise use documentation obtained from skewer."
(let* ((docs (cdr (assoc name ac-js2-candidates)))
(doc (if (listp docs) (cl-first docs) docs)))
(if doc doc (ac-js2-skewer-document-candidates name))))
;; Auto-complete settings
(defun ac-js2-ac-candidates ()
"Completion candidates for auto-complete mode."
(ac-js2-candidates))
(defun ac-js2-ac-document (name)
"Documentation to be shown for auto-complete mode."
(ac-js2-document name))
(defun ac-js2-ac-prefix()
(or (ac-prefix-default) (ac-prefix-c-dot)))
(defun ac-js2-save ()
"Called on `before-save-hook' to evaluate buffer."
(interactive)
(when (string= major-mode "js2-mode")
(ac-js2-skewer-eval-wrapper (buffer-string)))
t)
;;;###autoload
(defun ac-js2-expand-function()
"Expand the function definition left of point.
Expansion will only occur for candidates whose documentation
string contain a function prototype."
(interactive)
(let* ((word (progn
(if (featurep 'auto-complete) (ac-complete))
(substring-no-properties (or (thing-at-point 'word) ""))))
(candidate (ac-js2-ac-document word)))
(if (and (looking-back word) (stringp candidate))
(when (string-match "^function" candidate)
(cond ((featurep 'yasnippet)
(yas-expand-snippet
(concat "("
(replace-regexp-in-string "\\([a-zA-Z0-9]+\\)"
(lambda (txt) (concat "${" txt "}"))
(cl-second (split-string candidate "[()]")))
")$0"))))))))
(defun ac-js2-setup-auto-complete-mode ()
"Setup ac-js2 to be used with auto-complete-mode."
(add-to-list 'ac-sources 'ac-source-js2)
(auto-complete-mode)
(ac-define-source "js2"
'((candidates . ac-js2-ac-candidates)
(document . ac-js2-ac-document)
(prefix . ac-js2-ac-prefix)
(requires . -1))))
;;; Completion at point function
;;;###autoload
(defun ac-js2-completion-function ()
"Function for `completions-at-point'."
(save-excursion
(let ((bounds (if (looking-back "\\.")
(cons (point) (point))
(bounds-of-thing-at-point 'word))))
(list (car bounds) (cdr bounds) (ac-js2-candidates)))))
;;; Company
;;;###autoload
(defun ac-js2-company (command &optional arg &rest ignored)
(interactive (list 'interactive))
(if (not (featurep 'company))
(message "Company is not installed")
(cl-case command
(interactive (company-begin-backend 'ac-js2-company))
(prefix (when ac-js2-mode
(or (company-grab-symbol)
'stop)))
(candidates (all-completions arg (ac-js2-candidates)))
(duplicates t)
(meta (let ((doc (ac-js2-document arg)))
(when doc
(with-temp-buffer
(insert doc)
(js-mode)
(if (fboundp 'font-lock-ensure)
(font-lock-ensure)
(with-no-warnings
(font-lock-fontify-buffer)))
(buffer-string))))))))
;;; Helper functions
(defun ac-js2-build-prop-name-list (prop-node)
"Build a list of names from a PROP-NODE."
(let* (names
left
left-node)
(unless (js2-prop-get-node-p prop-node)
(error "Node is not a property prop-node"))
(while (js2-prop-get-node-p prop-node)
(push (js2-name-node-name (js2-prop-get-node-right prop-node)) names)
(setq left-node (js2-prop-get-node-left prop-node))
(when (js2-name-node-p left-node)
(setq left (js2-name-node-name left-node)))
(setq prop-node (js2-node-parent prop-node)))
(append names `(,left))))
(defun ac-js2-prop-names-left (name-node)
"Create a list of all of the names in the property NAME-NODE.
NAME-NODE must have a js2-prop-get-node as parent. Only adds
properties to the left of point. This is so individual jump
points can be found for each property in the chain."
(let* (name
(parent (js2-node-parent name-node))
left
names)
(unless (or (js2-prop-get-node-p parent) (js2-name-node-p name-node))
(error "Not a name node or doesn't have a prop-get-node as parent"))
(setq name (js2-name-node-name name-node)
left (js2-prop-get-node-left parent))
(if (and (js2-name-node-p left)
(string= name (js2-name-node-name left)))
(setq names name)
(js2-visit-ast
parent
(lambda (node endp)
(unless endp
(if (js2-name-node-p node)
(push (js2-name-node-name node) names)
t))))
names)))
(defun ac-js2-has-function-calls (string)
"Check if the Javascript code in STRING has a Js2-call-node."
(with-temp-buffer
(insert string)
(let* ((ast (js2-parse)))
(catch 'call-node
(js2-visit-ast-root
ast
(lambda (node end-p)
(unless end-p
(if (js2-call-node-p node)
(throw 'call-node t)
t))))))))
(defun ac-js2-add-extra-completions (completions)
"Add extra candidates to COMPLETIONS."
(append completions
(if ac-js2-add-keywords (or ac-js2-keywords (setq ac-js2-keywords (mapcar 'symbol-name js2-keywords))))
(if ac-js2-add-ecma-262-externs js2-ecma-262-externs)
(if ac-js2-add-browser-externs js2-browser-externs)))
(defun ac-js2-root-or-node ()
"Return the current node or js2-ast-root node."
(let ((node (js2-node-at-point)))
(if (js2-ast-root-p node)
node
(js2-node-get-enclosing-scope node))))
(defun ac-js2-get-names-in-scope ()
"Fetches all symbols in scope and formats them for completion."
(let* ((scope (ac-js2-root-or-node))
result)
(while scope
(setq result (append result
(cl-loop for item in (js2-scope-symbol-table scope)
if (not (assoc (car item) result))
collect item)))
(setq scope (js2-scope-parent-scope scope)))
(setq ac-js2-candidates
(mapcar #'(lambda (x)
(let* ((name (symbol-name (car x)))
(init (ac-js2-initialized-node name)))
(ac-js2-format-node name init)))
result))))
(defun ac-js2-initialized-node (name)
"Return initial value assigned to NAME.
NAME may be either a variable, a function or a variable that
holds a function. NAME may also be a list of names that make up a
object property. Returns nil if no initial value can be found."
(let* ((node (if (listp name) (ac-js2-find-property name)
(ac-js2-name-declaration name)))
(parent (if node (js2-node-parent node)))
(init (cond
((js2-function-node-p parent)
parent)
((js2-function-node-p node)
node)
((js2-var-init-node-p parent)
(js2-var-init-node-initializer parent))
((js2-assign-node-p parent)
(js2-assign-node-right parent))
(t
nil))))
init))
(defun ac-js2-name-declaration (name)
"Return the declaration node for node named NAME."
(let* ((node (ac-js2-root-or-node))
(scope-def (js2-get-defining-scope node name))
(scope (if scope-def (js2-scope-get-symbol scope-def name) nil))
(symbol (if scope (js2-symbol-ast-node scope) nil)))
(if (not symbol)
(ac-js2-get-function-node name scope-def)
symbol)))
;;; Completion candidate formatting
(defun ac-js2-format-node (name node)
"Format NAME and NODE for completion.
Returned format is a list where the first element is the NAME of
the node (shown in completion candidate list) and the last
element is the text to show as documentation."
(let ((node (if (js2-object-prop-node-p node) (js2-object-prop-node-right node) node))
(name-format (replace-regexp-in-string "\"" "" name))
(doc (if (and (js2-function-node-p node)
(cl-find name (js2-function-node-params node)
:test '(lambda (name param) (string= name (js2-name-node-name param)))))
"Function parameter"
(ac-js2-format-node-doc node))))
`(,name-format . ,doc)))
(defun ac-js2-format-object-node-doc (obj-node)
"Format OBJ-NODE to display as documentation."
(let (elems)
(unless (js2-object-node-p obj-node)
(error "Node is not an object node"))
(setq elems (js2-object-node-elems obj-node))
(if (not elems)
"{}"
(mapconcat #'(lambda (x) (ac-js2-format-js2-object-prop-doc x)) elems "\n"))))
(defun ac-js2-format-node-doc (node)
"Format NODE for displaying in a document string."
(let* ((node-above (and node (js2-node-at-point
(save-excursion
(goto-char (js2-node-abs-pos node))
(forward-line -1)
(point)))))
(comment (if (js2-comment-node-p node-above)
(ac-js2-format-comment (js2-node-string node-above))))
(doc (cond
((js2-function-node-p node)
(ac-js2-format-function node))
((js2-object-node-p node)
(ac-js2-format-object-node-doc node))
((js2-object-prop-node-p node)
(ac-js2-format-node-doc (js2-object-prop-node-right node)))
(t
(if (js2-node-p node) (js2-node-string node) "")))))
(if comment (concat comment "\n" doc) doc)))
(defun ac-js2-format-js2-object-prop-doc (obj-prop)
"Format an OBJ-PROP for displaying as a document string."
(unless (js2-object-prop-node-p obj-prop)
(error "Node is not an object property node"))
(let* ((left (js2-object-prop-node-left obj-prop))
(right (js2-object-prop-node-right obj-prop)))
(concat (js2-node-string left) " : "
(ac-js2-format-node-doc right))))
(defun ac-js2-format-function (func)
"Formats a function for a document string.
FUNC can be either a function node or a string starting with
'function'. Returns nil if neither."
(let ((str (or (and (js2-function-node-p func) (js2-node-string func))
(and (stringp func) (eq 0 (string-match "function" func)) func))))
(if str (substring str 0 (1+ (string-match ")" str))))))
(defun ac-js2-format-comment (comment)
"Prepare a COMMENT node for displaying in a popup."
(let* ((node-string (if (js2-comment-node-p comment)
(js2-node-string comment)
comment))
(string (replace-regexp-in-string "[ \t]$" ""
(replace-regexp-in-string "^[ \t\n*/*]+" "" node-string))))
string))
;;; Navigation commands for js2-mode
(defun ac-js2-find-property (list-names)
"Find the property definition that consists of LIST-NAMES.
Supports navigation to 'foo.bar = 3' and 'foo = {bar: 3}'."
(catch 'prop-found
(js2-visit-ast-root
js2-mode-ast
(lambda (node endp)
(let ((parent (js2-node-parent node)))
(unless endp
(if (or (and (js2-prop-get-node-p node)
(not (or (js2-elem-get-node-p parent) (js2-call-node-p parent)))
(equal list-names (ac-js2-build-prop-name-list node)))
(and (js2-name-node-p node)
(js2-object-prop-node-p parent)
(string= (js2-name-node-name node)
(cl-first list-names))))
(throw 'prop-found node))
t))))))
(defun ac-js2-get-function-node (name scope)
"Return node of function named NAME in SCOPE."
(catch 'function-found
(js2-visit-ast
scope
(lambda (node end-p)
(when (and (not end-p)
(string= name (ac-js2-get-function-name node)))
(throw 'function-found node))
t))
nil))
;;;###autoload
(defun ac-js2-jump-to-definition ()
"Jump to the definition of an object's property, variable or function.
Navigation to a property definend in an Object literal isn't
implemented."
(interactive)
(ring-insert find-tag-marker-ring (point-marker))
(let* ((node (js2-node-at-point))
(parent (js2-node-parent node))
(prop-names (if (js2-prop-get-node-p parent)
(ac-js2-prop-names-left node)))
(name (if (and (js2-name-node-p node)
(not (js2-object-prop-node-p parent)))
(js2-name-node-name node)
(error "Node is not a supported jump node")))
(node-init (if (and prop-names (listp prop-names))
(ac-js2-find-property prop-names)
(ac-js2-name-declaration name))))
(unless node-init
(pop-tag-mark)
(error "No jump location found"))
(goto-char (js2-node-abs-pos node-init))))
(defun ac-js2-get-function-name (fn-node)
"Return the name of the function FN-NODE.
Value may be either function name or the variable name that holds
the function."
(let ((parent (js2-node-parent fn-node)))
(if (js2-function-node-p fn-node)
(or (js2-function-name fn-node)
(if (js2-var-init-node-p parent)
(js2-name-node-name (js2-var-init-node-target parent)))))))
(defvar ac-js2-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "M-.") 'ac-js2-jump-to-definition)
(define-key map (kbd "M-,") 'pop-tag-mark)
(define-key map (kbd "C-c C-c") 'ac-js2-expand-function)
map)
"Keymap for `ac-js2-mode'.")
;;; Minor mode
;;;###autoload
(define-minor-mode ac-js2-mode
"A minor mode that provides auto-completion and navigation for Js2-mode."
:keymap ac-js2-mode-map
(if (featurep 'auto-complete)
(ac-js2-setup-auto-complete-mode))
(set (make-local-variable 'completion-at-point-functions)
(cons 'ac-js2-completion-function completion-at-point-functions))
(ac-js2-skewer-eval-wrapper (buffer-string))
(add-hook 'before-save-hook 'ac-js2-save nil t)
(add-hook 'skewer-js-hook 'ac-js2-on-skewer-load))
(provide 'ac-js2)
;;; ac-js2.el ends here

Binary file not shown.

View File

@@ -0,0 +1,116 @@
/**
* @fileOverview Completion request handler for skewer.js
* @requires skewer
* @version 1.0
*/
/**
* Handles a completion request from Emacs.
* @param request The request object sent by Emacs
* @returns The completions and init values to be returned to Emacs
*/
skewer.fn.complete = function(request) {
var result = {
type : request.type,
id : request.id,
strict : request.strict,
status : "success"
},
/**
* Methods for generating candidates
*/
METHOD = {
EVAL : 0,
GLOBAL : 1
},
/**
* Add the properties from object to extendObject. Properties
* may be from the prototype but we still want to add them.
*/
extend = function(extendObject, object) {
for(var key in object) {
extendObject[key] = object[key];
}
},
globalCompletion = function() {
var global = Function('return this')(),
keys = Object.keys(global);
candidates = buildCandidates(global, keys);
},
evalCompletion = function(evalObject) {
var obj = (eval, eval)(evalObject);
if (typeof obj === "object") {
candidates = buildCandidates(obj) || {};
while (request.prototypes && (obj = Object.getPrototypeOf(obj)) !== null) {
extend(candidates, buildCandidates(obj));
}
} else if (typeof obj === "function"){
candidates = buildCandidates(obj) || {};
extend(candidates, buildCandidates(Object.getPrototypeOf(obj)));
if (request.prototypes) {
var protoObject = Object.getPrototypeOf(obj.prototype);
if (protoObject !== null) {
extend(candidates, buildCandidates(protoObject));
} else {
extend(candidates, buildCandidates(obj.prototype));
}
}
}
},
/**
* Completion candidates sent back to Emacs. Keys are
* completion candidates the values are the inital items or
* function interfaces.
*/
candidates = {},
/**
* Build the candiates to return to Emacs.
* @param obj The object to get candidates from
* @param items The selected keys from obj to create candidates for
* @return object containing completion candidates and documentation strings
*/
buildCandidates = function(obj, items) {
var keys = items || Object.getOwnPropertyNames(obj), values = {};
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (key === "callee" || key === "caller" || key === "arguments") continue;
if (Object.prototype.toString.call(obj[key]) === "[object Function]") {
values[key] = obj[key].toString();
} else if (typeof obj[key] === "object"){
values[key] = "[object Object]";
} else if (typeof obj[key] === "number") {
if (!(obj instanceof Array)) {
values[key] = obj[key].toString();
}
} else if (typeof obj[key] === "string") {
values[key] = obj[key].toString();
} else if(obj[key] === true) {
values[key] = "true";
} else if (obj[key] === false) {
values[key] = "false";
} else {
values[key] = "";
}
}
return values;
};
try {
switch (request.method) {
case METHOD.GLOBAL:
globalCompletion();
break;
default:
evalCompletion(request.eval);
}
result.value = candidates;
} catch (error){
skewer.errorResult(error, result, request);
}
return result;
};

View File

@@ -0,0 +1,35 @@
The core library of the `ac-php' package. Acts like a backend for the
following components:
- `ac-php'
- `company-php'
- `helm-ac-php-apropros'
Can be used as an API to build your own components. This engine currently
provides:
- Support of PHP code completion
- Support of jumping to definition/declaration/inclusion-file
When creating this package, the ideas of the following packages were used:
- auto-java-complete
- `ac-php-remove-unnecessary-items-4-complete-method'
- `ac-php-split-string-with-separator'
- auto-complete-clang
- rtags
- `ac-php-location-stack-index'
Many options available under Help:Customize
Options specific to ac-php-core are in
Convenience/Completion/Auto Complete
Known to work with Linux and macOS. Windows support is in beta stage.
For more info and examples see URL `https://github.com/xcwen/ac-php' .
Bugs: Bug tracking is currently handled using the GitHub issue tracker
(see URL `https://github.com/xcwen/ac-php/issues')

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,174 @@
;;; async-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (directory-file-name
(or (file-name-directory #$) (car load-path))))
;;;### (autoloads nil "async" "async.el" (0 0 0 0))
;;; Generated autoloads from async.el
(autoload 'async-start-process "async" "\
Start the executable PROGRAM asynchronously. See `async-start'.
PROGRAM is passed PROGRAM-ARGS, calling FINISH-FUNC with the
process object when done. If FINISH-FUNC is nil, the future
object will return the process object when the program is
finished. Set DEFAULT-DIRECTORY to change PROGRAM's current
working directory.
\(fn NAME PROGRAM FINISH-FUNC &rest PROGRAM-ARGS)" nil nil)
(autoload 'async-start "async" "\
Execute START-FUNC (often a lambda) in a subordinate Emacs process.
When done, the return value is passed to FINISH-FUNC. Example:
(async-start
;; What to do in the child process
(lambda ()
(message \"This is a test\")
(sleep-for 3)
222)
;; What to do when it finishes
(lambda (result)
(message \"Async process done, result should be 222: %s\"
result)))
If FINISH-FUNC is nil or missing, a future is returned that can
be inspected using `async-get', blocking until the value is
ready. Example:
(let ((proc (async-start
;; What to do in the child process
(lambda ()
(message \"This is a test\")
(sleep-for 3)
222))))
(message \"I'm going to do some work here\") ;; ....
(message \"Waiting on async process, result should be 222: %s\"
(async-get proc)))
If you don't want to use a callback, and you don't care about any
return value from the child process, pass the `ignore' symbol as
the second argument (if you don't, and never call `async-get', it
will leave *emacs* process buffers hanging around):
(async-start
(lambda ()
(delete-file \"a remote file on a slow link\" nil))
'ignore)
Note: Even when FINISH-FUNC is present, a future is still
returned except that it yields no value (since the value is
passed to FINISH-FUNC). Call `async-get' on such a future always
returns nil. It can still be useful, however, as an argument to
`async-ready' or `async-wait'.
\(fn START-FUNC &optional FINISH-FUNC)" nil nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "async" '("async-")))
;;;***
;;;### (autoloads nil "async-bytecomp" "async-bytecomp.el" (0 0 0
;;;;;; 0))
;;; Generated autoloads from async-bytecomp.el
(autoload 'async-byte-recompile-directory "async-bytecomp" "\
Compile all *.el files in DIRECTORY asynchronously.
All *.elc files are systematically deleted before proceeding.
\(fn DIRECTORY &optional QUIET)" nil nil)
(defvar async-bytecomp-package-mode nil "\
Non-nil if Async-Bytecomp-Package mode is enabled.
See the `async-bytecomp-package-mode' command
for a description of this minor mode.
Setting this variable directly does not take effect;
either customize it (see the info node `Easy Customization')
or call the function `async-bytecomp-package-mode'.")
(custom-autoload 'async-bytecomp-package-mode "async-bytecomp" nil)
(autoload 'async-bytecomp-package-mode "async-bytecomp" "\
Byte compile asynchronously packages installed with package.el.
Async compilation of packages can be controlled by
`async-bytecomp-allowed-packages'.
\(fn &optional ARG)" t nil)
(autoload 'async-byte-compile-file "async-bytecomp" "\
Byte compile Lisp code FILE asynchronously.
Same as `byte-compile-file' but asynchronous.
\(fn FILE)" t nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "async-bytecomp" '("async-byte")))
;;;***
;;;### (autoloads nil "dired-async" "dired-async.el" (0 0 0 0))
;;; Generated autoloads from dired-async.el
(defvar dired-async-mode nil "\
Non-nil if Dired-Async mode is enabled.
See the `dired-async-mode' command
for a description of this minor mode.
Setting this variable directly does not take effect;
either customize it (see the info node `Easy Customization')
or call the function `dired-async-mode'.")
(custom-autoload 'dired-async-mode "dired-async" nil)
(autoload 'dired-async-mode "dired-async" "\
Do dired actions asynchronously.
\(fn &optional ARG)" t nil)
(autoload 'dired-async-do-copy "dired-async" "\
Run dired-do-copy asynchronously.
\(fn &optional ARG)" t nil)
(autoload 'dired-async-do-symlink "dired-async" "\
Run dired-do-symlink asynchronously.
\(fn &optional ARG)" t nil)
(autoload 'dired-async-do-hardlink "dired-async" "\
Run dired-do-hardlink asynchronously.
\(fn &optional ARG)" t nil)
(autoload 'dired-async-do-rename "dired-async" "\
Run dired-do-rename asynchronously.
\(fn &optional ARG)" t nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "dired-async" '("dired-async-")))
;;;***
;;;### (autoloads nil "smtpmail-async" "smtpmail-async.el" (0 0 0
;;;;;; 0))
;;; Generated autoloads from smtpmail-async.el
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "smtpmail-async" '("async-smtpmail-")))
;;;***
;;;### (autoloads nil nil ("async-pkg.el") (0 0 0 0))
;;;***
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; async-autoloads.el ends here

View File

@@ -0,0 +1,219 @@
;;; async-bytecomp.el --- Compile elisp files asynchronously -*- lexical-binding: t -*-
;; Copyright (C) 2014-2016 Free Software Foundation, Inc.
;; Authors: John Wiegley <jwiegley@gmail.com>
;; Thierry Volpiatto <thierry.volpiatto@gmail.com>
;; Keywords: dired async byte-compile
;; X-URL: https://github.com/jwiegley/dired-async
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or (at
;; your option) any later version.
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;;
;; This package provide the `async-byte-recompile-directory' function
;; which allows, as the name says to recompile a directory outside of
;; your running emacs.
;; The benefit is your files will be compiled in a clean environment without
;; the old *.el files loaded.
;; Among other things, this fix a bug in package.el which recompile
;; the new files in the current environment with the old files loaded, creating
;; errors in most packages after upgrades.
;;
;; NB: This package is advicing the function `package--compile'.
;;; Code:
(require 'cl-lib)
(require 'async)
(defcustom async-bytecomp-allowed-packages
'(async helm helm-core helm-ls-git helm-ls-hg magit)
"Packages in this list will be compiled asynchronously by `package--compile'.
All the dependencies of these packages will be compiled async too,
so no need to add dependencies to this list.
The value of this variable can also be a list with a single element,
the symbol `all', in this case packages are always compiled asynchronously."
:group 'async
:type '(repeat (choice symbol)))
(defvar async-byte-compile-log-file
(concat user-emacs-directory "async-bytecomp.log"))
;;;###autoload
(defun async-byte-recompile-directory (directory &optional quiet)
"Compile all *.el files in DIRECTORY asynchronously.
All *.elc files are systematically deleted before proceeding."
(cl-loop with dir = (directory-files directory t "\\.elc\\'")
unless dir return nil
for f in dir
when (file-exists-p f) do (delete-file f))
;; Ensure async is reloaded when async.elc is deleted.
;; This happen when recompiling its own directory.
(load "async")
(let ((call-back
(lambda (&optional _ignore)
(if (file-exists-p async-byte-compile-log-file)
(let ((buf (get-buffer-create byte-compile-log-buffer))
(n 0))
(with-current-buffer buf
(goto-char (point-max))
(let ((inhibit-read-only t))
(insert-file-contents async-byte-compile-log-file)
(compilation-mode))
(display-buffer buf)
(delete-file async-byte-compile-log-file)
(unless quiet
(save-excursion
(goto-char (point-min))
(while (re-search-forward "^.*:Error:" nil t)
(cl-incf n)))
(if (> n 0)
(message "Failed to compile %d files in directory `%s'" n directory)
(message "Directory `%s' compiled asynchronously with warnings" directory)))))
(unless quiet
(message "Directory `%s' compiled asynchronously with success" directory))))))
(async-start
`(lambda ()
(require 'bytecomp)
,(async-inject-variables "\\`\\(load-path\\)\\|byte\\'")
(let ((default-directory (file-name-as-directory ,directory))
error-data)
(add-to-list 'load-path default-directory)
(byte-recompile-directory ,directory 0 t)
(when (get-buffer byte-compile-log-buffer)
(setq error-data (with-current-buffer byte-compile-log-buffer
(buffer-substring-no-properties (point-min) (point-max))))
(unless (string= error-data "")
(with-temp-file ,async-byte-compile-log-file
(erase-buffer)
(insert error-data))))))
call-back)
(unless quiet (message "Started compiling asynchronously directory %s" directory))))
(defvar package-archive-contents)
(defvar package-alist)
(declare-function package-desc-reqs "package.el" (cl-x))
(defun async-bytecomp--get-package-deps (pkg &optional only)
;; Same as `package--get-deps' but parse instead `package-archive-contents'
;; because PKG is not already installed and not present in `package-alist'.
;; However fallback to `package-alist' in case PKG no more present
;; in `package-archive-contents' due to modification to `package-archives'.
;; See issue #58.
(let* ((pkg-desc (cadr (or (assq pkg package-archive-contents)
(assq pkg package-alist))))
(direct-deps (cl-loop for p in (package-desc-reqs pkg-desc)
for name = (car p)
when (or (assq name package-archive-contents)
(assq name package-alist))
collect name))
(indirect-deps (unless (eq only 'direct)
(delete-dups
(cl-loop for p in direct-deps append
(async-bytecomp--get-package-deps p))))))
(cl-case only
(direct direct-deps)
(separate (list direct-deps indirect-deps))
(indirect indirect-deps)
(t (delete-dups (append direct-deps indirect-deps))))))
(defun async-bytecomp-get-allowed-pkgs ()
(when (and async-bytecomp-allowed-packages
(listp async-bytecomp-allowed-packages))
(if package-archive-contents
(cl-loop for p in async-bytecomp-allowed-packages
when (assq p package-archive-contents)
append (async-bytecomp--get-package-deps p) into reqs
finally return
(delete-dups
(append async-bytecomp-allowed-packages reqs)))
async-bytecomp-allowed-packages)))
(defadvice package--compile (around byte-compile-async)
(let ((cur-package (package-desc-name pkg-desc))
(pkg-dir (package-desc-dir pkg-desc)))
(if (or (equal async-bytecomp-allowed-packages '(all))
(memq cur-package (async-bytecomp-get-allowed-pkgs)))
(progn
(when (eq cur-package 'async)
(fmakunbound 'async-byte-recompile-directory))
;; Add to `load-path' the latest version of async and
;; reload it when reinstalling async.
(when (string= cur-package "async")
(cl-pushnew pkg-dir load-path)
(load "async-bytecomp"))
;; `async-byte-recompile-directory' will add directory
;; as needed to `load-path'.
(async-byte-recompile-directory (package-desc-dir pkg-desc) t))
ad-do-it)))
;;;###autoload
(define-minor-mode async-bytecomp-package-mode
"Byte compile asynchronously packages installed with package.el.
Async compilation of packages can be controlled by
`async-bytecomp-allowed-packages'."
:group 'async
:global t
(if async-bytecomp-package-mode
(ad-activate 'package--compile)
(ad-deactivate 'package--compile)))
;;;###autoload
(defun async-byte-compile-file (file)
"Byte compile Lisp code FILE asynchronously.
Same as `byte-compile-file' but asynchronous."
(interactive "fFile: ")
(let ((call-back
(lambda (&optional _ignore)
(let ((bn (file-name-nondirectory file)))
(if (file-exists-p async-byte-compile-log-file)
(let ((buf (get-buffer-create byte-compile-log-buffer))
start)
(with-current-buffer buf
(goto-char (setq start (point-max)))
(let ((inhibit-read-only t))
(insert-file-contents async-byte-compile-log-file)
(compilation-mode))
(display-buffer buf)
(delete-file async-byte-compile-log-file)
(save-excursion
(goto-char start)
(if (re-search-forward "^.*:Error:" nil t)
(message "Failed to compile `%s'" bn)
(message "`%s' compiled asynchronously with warnings" bn)))))
(message "`%s' compiled asynchronously with success" bn))))))
(async-start
`(lambda ()
(require 'bytecomp)
,(async-inject-variables "\\`load-path\\'")
(let ((default-directory ,(file-name-directory file)))
(add-to-list 'load-path default-directory)
(byte-compile-file ,file)
(when (get-buffer byte-compile-log-buffer)
(setq error-data (with-current-buffer byte-compile-log-buffer
(buffer-substring-no-properties (point-min) (point-max))))
(unless (string= error-data "")
(with-temp-file ,async-byte-compile-log-file
(erase-buffer)
(insert error-data))))))
call-back)))
(provide 'async-bytecomp)
;;; async-bytecomp.el ends here

Binary file not shown.

View File

@@ -0,0 +1,6 @@
(define-package "async" "20190503.656" "Asynchronous processing in Emacs" 'nil :keywords
'("async")
:url "https://github.com/jwiegley/emacs-async")
;; Local Variables:
;; no-byte-compile: t
;; End:

View File

@@ -0,0 +1,408 @@
;;; async.el --- Asynchronous processing in Emacs -*- lexical-binding: t -*-
;; Copyright (C) 2012-2016 Free Software Foundation, Inc.
;; Author: John Wiegley <jwiegley@gmail.com>
;; Created: 18 Jun 2012
;; Version: 1.9.3
;; Keywords: async
;; X-URL: https://github.com/jwiegley/emacs-async
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or (at
;; your option) any later version.
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; Adds the ability to call asynchronous functions and process with ease. See
;; the documentation for `async-start' and `async-start-process'.
;;; Code:
(eval-when-compile (require 'cl-lib))
(defgroup async nil
"Simple asynchronous processing in Emacs"
:group 'emacs)
(defcustom async-variables-noprops-function #'async--purecopy
"Default function to remove text properties in variables."
:group 'async
:type 'function)
(defvar async-debug nil)
(defvar async-send-over-pipe t)
(defvar async-in-child-emacs nil)
(defvar async-callback nil)
(defvar async-callback-for-process nil)
(defvar async-callback-value nil)
(defvar async-callback-value-set nil)
(defvar async-current-process nil)
(defvar async--procvar nil)
(defun async--purecopy (object)
"Remove text properties in OBJECT.
Argument OBJECT may be a list or a string, if anything else it
is returned unmodified."
(cond ((stringp object)
(substring-no-properties object))
((consp object)
(cl-loop for elm in object
;; A string.
if (stringp elm)
collect (substring-no-properties elm)
else
;; Proper lists.
if (and (consp elm) (null (cdr (last elm))))
collect (async--purecopy elm)
else
;; Dotted lists.
;; We handle here only dotted list where car and cdr
;; are atoms i.e. (x . y) and not (x . (x . y)) or
;; (x . (x y)) which should fit most cases.
if (and (consp elm) (cdr (last elm)))
collect (let ((key (car elm))
(val (cdr elm)))
(cons (if (stringp key)
(substring-no-properties key)
key)
(if (stringp val)
(substring-no-properties val)
val)))
else
collect elm))
(t object)))
(defun async-inject-variables
(include-regexp &optional predicate exclude-regexp noprops)
"Return a `setq' form that replicates part of the calling environment.
It sets the value for every variable matching INCLUDE-REGEXP and
also PREDICATE. It will not perform injection for any variable
matching EXCLUDE-REGEXP (if present) or representing a syntax-table
i.e. ending by \"-syntax-table\".
When NOPROPS is non nil it tries to strip out text properties of each
variable's value with `async-variables-noprops-function'.
It is intended to be used as follows:
(async-start
`(lambda ()
(require 'smtpmail)
(with-temp-buffer
(insert ,(buffer-substring-no-properties (point-min) (point-max)))
;; Pass in the variable environment for smtpmail
,(async-inject-variables \"\\`\\(smtpmail\\|\\(user-\\)?mail\\)-\")
(smtpmail-send-it)))
'ignore)"
`(setq
,@(let (bindings)
(mapatoms
(lambda (sym)
(let* ((sname (and (boundp sym) (symbol-name sym)))
(value (and sname (symbol-value sym))))
(when (and sname
(or (null include-regexp)
(string-match include-regexp sname))
(or (null exclude-regexp)
(not (string-match exclude-regexp sname)))
(not (string-match "-syntax-table\\'" sname)))
(unless (or (stringp value)
(memq value '(nil t))
(numberp value)
(vectorp value))
(setq value `(quote ,value)))
(when noprops
(setq value (funcall async-variables-noprops-function
value)))
(when (or (null predicate)
(funcall predicate sym))
(setq bindings (cons value bindings)
bindings (cons sym bindings)))))))
bindings)))
(defalias 'async-inject-environment 'async-inject-variables)
(defun async-handle-result (func result buf)
(if (null func)
(progn
(set (make-local-variable 'async-callback-value) result)
(set (make-local-variable 'async-callback-value-set) t))
(unwind-protect
(if (and (listp result)
(eq 'async-signal (nth 0 result)))
(signal (car (nth 1 result))
(cdr (nth 1 result)))
(funcall func result))
(unless async-debug
(kill-buffer buf)))))
(defun async-when-done (proc &optional _change)
"Process sentinel used to retrieve the value from the child process."
(when (eq 'exit (process-status proc))
(with-current-buffer (process-buffer proc)
(let ((async-current-process proc))
(if (= 0 (process-exit-status proc))
(if async-callback-for-process
(if async-callback
(prog1
(funcall async-callback proc)
(unless async-debug
(kill-buffer (current-buffer))))
(set (make-local-variable 'async-callback-value) proc)
(set (make-local-variable 'async-callback-value-set) t))
(goto-char (point-max))
(backward-sexp)
(async-handle-result async-callback (read (current-buffer))
(current-buffer)))
(set (make-local-variable 'async-callback-value)
(list 'error
(format "Async process '%s' failed with exit code %d"
(process-name proc) (process-exit-status proc))))
(set (make-local-variable 'async-callback-value-set) t))))))
(defun async--receive-sexp (&optional stream)
(let ((sexp (decode-coding-string (base64-decode-string
(read stream)) 'utf-8-auto))
;; Parent expects UTF-8 encoded text.
(coding-system-for-write 'utf-8-auto))
(if async-debug
(message "Received sexp {{{%s}}}" (pp-to-string sexp)))
(setq sexp (read sexp))
(if async-debug
(message "Read sexp {{{%s}}}" (pp-to-string sexp)))
(eval sexp)))
(defun async--insert-sexp (sexp)
(let (print-level
print-length
(print-escape-nonascii t)
(print-circle t))
(prin1 sexp (current-buffer))
;; Just in case the string we're sending might contain EOF
(encode-coding-region (point-min) (point-max) 'utf-8-auto)
(base64-encode-region (point-min) (point-max) t)
(goto-char (point-min)) (insert ?\")
(goto-char (point-max)) (insert ?\" ?\n)))
(defun async--transmit-sexp (process sexp)
(with-temp-buffer
(if async-debug
(message "Transmitting sexp {{{%s}}}" (pp-to-string sexp)))
(async--insert-sexp sexp)
(process-send-region process (point-min) (point-max))))
(defun async-batch-invoke ()
"Called from the child Emacs process' command-line."
;; Make sure 'message' and 'prin1' encode stuff in UTF-8, as parent
;; process expects.
(let ((coding-system-for-write 'utf-8-auto))
(setq async-in-child-emacs t
debug-on-error async-debug)
(if debug-on-error
(prin1 (funcall
(async--receive-sexp (unless async-send-over-pipe
command-line-args-left))))
(condition-case err
(prin1 (funcall
(async--receive-sexp (unless async-send-over-pipe
command-line-args-left))))
(error
(prin1 (list 'async-signal err)))))))
(defun async-ready (future)
"Query a FUTURE to see if it is ready.
I.e., if no blocking
would result from a call to `async-get' on that FUTURE."
(and (memq (process-status future) '(exit signal))
(let ((buf (process-buffer future)))
(if (buffer-live-p buf)
(with-current-buffer buf
async-callback-value-set)
t))))
(defun async-wait (future)
"Wait for FUTURE to become ready."
(while (not (async-ready future))
(sleep-for 0.05)))
(defun async-get (future)
"Get the value from process FUTURE when it is ready.
FUTURE is returned by `async-start' or `async-start-process' when
its FINISH-FUNC is nil."
(and future (async-wait future))
(let ((buf (process-buffer future)))
(when (buffer-live-p buf)
(with-current-buffer buf
(async-handle-result
#'identity async-callback-value (current-buffer))))))
(defun async-message-p (value)
"Return true of VALUE is an async.el message packet."
(and (listp value)
(plist-get value :async-message)))
(defun async-send (&rest args)
"Send the given messages to the asychronous Emacs PROCESS."
(let ((args (append args '(:async-message t))))
(if async-in-child-emacs
(if async-callback
(funcall async-callback args))
(async--transmit-sexp (car args) (list 'quote (cdr args))))))
(defun async-receive ()
"Send the given messages to the asychronous Emacs PROCESS."
(async--receive-sexp))
;;;###autoload
(defun async-start-process (name program finish-func &rest program-args)
"Start the executable PROGRAM asynchronously. See `async-start'.
PROGRAM is passed PROGRAM-ARGS, calling FINISH-FUNC with the
process object when done. If FINISH-FUNC is nil, the future
object will return the process object when the program is
finished. Set DEFAULT-DIRECTORY to change PROGRAM's current
working directory."
(let* ((buf (generate-new-buffer (concat "*" name "*")))
(proc (let ((process-connection-type nil))
(apply #'start-process name buf program program-args))))
(with-current-buffer buf
(set (make-local-variable 'async-callback) finish-func)
(set-process-sentinel proc #'async-when-done)
(unless (string= name "emacs")
(set (make-local-variable 'async-callback-for-process) t))
proc)))
(defvar async-quiet-switch "-Q"
"The Emacs parameter to use to call emacs without config.
Can be one of \"-Q\" or \"-q\".
Default is \"-Q\" but it is sometimes useful to use \"-q\" to have a
enhanced config or some more variables loaded.")
;;;###autoload
(defun async-start (start-func &optional finish-func)
"Execute START-FUNC (often a lambda) in a subordinate Emacs process.
When done, the return value is passed to FINISH-FUNC. Example:
(async-start
;; What to do in the child process
(lambda ()
(message \"This is a test\")
(sleep-for 3)
222)
;; What to do when it finishes
(lambda (result)
(message \"Async process done, result should be 222: %s\"
result)))
If FINISH-FUNC is nil or missing, a future is returned that can
be inspected using `async-get', blocking until the value is
ready. Example:
(let ((proc (async-start
;; What to do in the child process
(lambda ()
(message \"This is a test\")
(sleep-for 3)
222))))
(message \"I'm going to do some work here\") ;; ....
(message \"Waiting on async process, result should be 222: %s\"
(async-get proc)))
If you don't want to use a callback, and you don't care about any
return value from the child process, pass the `ignore' symbol as
the second argument (if you don't, and never call `async-get', it
will leave *emacs* process buffers hanging around):
(async-start
(lambda ()
(delete-file \"a remote file on a slow link\" nil))
'ignore)
Note: Even when FINISH-FUNC is present, a future is still
returned except that it yields no value (since the value is
passed to FINISH-FUNC). Call `async-get' on such a future always
returns nil. It can still be useful, however, as an argument to
`async-ready' or `async-wait'."
(let ((sexp start-func)
;; Subordinate Emacs will send text encoded in UTF-8.
(coding-system-for-read 'utf-8-auto))
(setq async--procvar
(async-start-process
"emacs" (file-truename
(expand-file-name invocation-name
invocation-directory))
finish-func
async-quiet-switch "-l"
;; Using `locate-library' ensure we use the right file
;; when the .elc have been deleted.
(locate-library "async")
"-batch" "-f" "async-batch-invoke"
(if async-send-over-pipe
"<none>"
(with-temp-buffer
(async--insert-sexp (list 'quote sexp))
(buffer-string)))))
(if async-send-over-pipe
(async--transmit-sexp async--procvar (list 'quote sexp)))
async--procvar))
(defmacro async-sandbox(func)
"Evaluate FUNC in a separate Emacs process, synchronously."
`(async-get (async-start ,func)))
(defun async--fold-left (fn forms bindings)
(let ((res forms))
(dolist (binding bindings)
(setq res (funcall fn res
(if (listp binding)
binding
(list binding)))))
res))
(defmacro async-let (bindings &rest forms)
"Implements `let', but each binding is established asynchronously.
For example:
(async-let ((x (foo))
(y (bar)))
(message \"%s %s\" x y))
expands to ==>
(async-start (foo)
(lambda (x)
(async-start (bar)
(lambda (y)
(message \"%s %s\" x y)))))"
(declare (indent 1))
(async--fold-left
(lambda (acc binding)
(let ((fun (pcase (cadr binding)
((and (pred functionp) f) f)
(f `(lambda () ,f)))))
`(async-start ,fun
(lambda (,(car binding))
,acc))))
`(progn ,@forms)
(reverse bindings)))
(provide 'async)
;;; async.el ends here

Binary file not shown.

View File

@@ -0,0 +1,408 @@
;;; dired-async.el --- Asynchronous dired actions -*- lexical-binding: t -*-
;; Copyright (C) 2012-2016 Free Software Foundation, Inc.
;; Authors: John Wiegley <jwiegley@gmail.com>
;; Thierry Volpiatto <thierry.volpiatto@gmail.com>
;; Keywords: dired async network
;; X-URL: https://github.com/jwiegley/dired-async
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or (at
;; your option) any later version.
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; This file provide a redefinition of `dired-create-file' function,
;; performs copies, moves and all what is handled by `dired-create-file'
;; in the background using a slave Emacs process,
;; by means of the async.el module.
;; To use it, put this in your .emacs:
;; (dired-async-mode 1)
;; This will enable async copy/rename etc...
;; in dired and helm.
;;; Code:
(require 'cl-lib)
(require 'dired-aux)
(require 'async)
(eval-when-compile
(defvar async-callback))
(defgroup dired-async nil
"Copy rename files asynchronously from dired."
:group 'dired)
(defcustom dired-async-env-variables-regexp
"\\`\\(tramp-\\(default\\|connection\\|remote\\)\\|ange-ftp\\)-.*"
"Variables matching this regexp will be loaded on Child Emacs."
:type 'regexp
:group 'dired-async)
(defcustom dired-async-message-function 'dired-async-mode-line-message
"Function to use to notify result when operation finish.
Should take same args as `message'."
:group 'dired-async
:type 'function)
(defcustom dired-async-log-file "/tmp/dired-async.log"
"File use to communicate errors from Child Emacs to host Emacs."
:group 'dired-async
:type 'string)
(defcustom dired-async-mode-lighter '(:eval
(when (eq major-mode 'dired-mode)
" Async"))
"Mode line lighter used for `dired-async-mode'."
:group 'dired-async
:risky t
:type 'sexp)
(defface dired-async-message
'((t (:foreground "yellow")))
"Face used for mode-line message."
:group 'dired-async)
(defface dired-async-failures
'((t (:foreground "red")))
"Face used for mode-line message."
:group 'dired-async)
(defface dired-async-mode-message
'((t (:foreground "Gold")))
"Face used for `dired-async--modeline-mode' lighter."
:group 'dired-async)
(define-minor-mode dired-async--modeline-mode
"Notify mode-line that an async process run."
:group 'dired-async
:global t
:lighter (:eval (propertize (format " [%s Async job(s) running]"
(length (dired-async-processes)))
'face 'dired-async-mode-message))
(unless dired-async--modeline-mode
(let ((visible-bell t)) (ding))))
(defun dired-async-mode-line-message (text face &rest args)
"Notify end of operation in `mode-line'."
(message nil)
(let ((mode-line-format (concat
" " (propertize
(if args
(apply #'format text args)
text)
'face face))))
(force-mode-line-update)
(sit-for 3)
(force-mode-line-update)))
(defun dired-async-processes ()
(cl-loop for p in (process-list)
when (cl-loop for c in (process-command p) thereis
(string= "async-batch-invoke" c))
collect p))
(defun dired-async-kill-process ()
(interactive)
(let* ((processes (dired-async-processes))
(proc (car (last processes))))
(and proc (delete-process proc))
(unless (> (length processes) 1)
(dired-async--modeline-mode -1))))
(defun dired-async-after-file-create (total operation failures skipped)
"Callback function used for operation handled by `dired-create-file'."
(unless (dired-async-processes)
;; Turn off mode-line notification
;; only when last process end.
(dired-async--modeline-mode -1))
(when operation
(if (file-exists-p dired-async-log-file)
(progn
(pop-to-buffer (get-buffer-create dired-log-buffer))
(goto-char (point-max))
(setq inhibit-read-only t)
(insert "Error: ")
(insert-file-contents dired-async-log-file)
(special-mode)
(shrink-window-if-larger-than-buffer)
(delete-file dired-async-log-file))
(run-with-timer
0.1 nil
(lambda ()
;; First send error messages.
(cond (failures
(funcall dired-async-message-function
"%s failed for %d of %d file%s -- See *Dired log* buffer"
'dired-async-failures
(car operation) (length failures)
total (dired-plural-s total)))
(skipped
(funcall dired-async-message-function
"%s: %d of %d file%s skipped -- See *Dired log* buffer"
'dired-async-failures
(car operation) (length skipped) total
(dired-plural-s total))))
(when dired-buffers
(cl-loop for (_f . b) in dired-buffers
when (buffer-live-p b)
do (with-current-buffer b
(when (and (not (file-remote-p default-directory nil t))
(file-exists-p default-directory))
(revert-buffer nil t)))))
;; Finally send the success message.
(funcall dired-async-message-function
"Asynchronous %s of %s on %s file%s done"
'dired-async-message
(car operation) (cadr operation)
total (dired-plural-s total)))))))
(defun dired-async-maybe-kill-ftp ()
"Return a form to kill ftp process in child emacs."
(quote
(progn
(require 'cl-lib)
(let ((buf (cl-loop for b in (buffer-list)
thereis (and (string-match
"\\`\\*ftp.*"
(buffer-name b)) b))))
(when buf (kill-buffer buf))))))
(defvar overwrite-query)
(defun dired-async-create-files (file-creator operation fn-list name-constructor
&optional _marker-char)
"Same as `dired-create-files' but asynchronous.
See `dired-create-files' for the behavior of arguments."
(setq overwrite-query nil)
(let ((total (length fn-list))
failures async-fn-list skipped callback
async-quiet-switch)
(let (to)
(dolist (from fn-list)
(setq to (funcall name-constructor from))
(if (and (equal to from)
(null (eq file-creator 'backup-file)))
(progn
(setq to nil)
(dired-log "Cannot %s to same file: %s\n"
(downcase operation) from)))
(if (not to)
(setq skipped (cons (dired-make-relative from) skipped))
(let* ((overwrite (and (null (eq file-creator 'backup-file))
(file-exists-p to)))
(dired-overwrite-confirmed ; for dired-handle-overwrite
(and overwrite
(let ((help-form `(format "\
Type SPC or `y' to overwrite file `%s',
DEL or `n' to skip to next,
ESC or `q' to not overwrite any of the remaining files,
`!' to overwrite all remaining files with no more questions." ,to)))
(dired-query 'overwrite-query "Overwrite `%s'?" to)))))
;; Handle the `dired-copy-file' file-creator specially
;; When copying a directory to another directory or
;; possibly to itself or one of its subdirectories.
;; e.g "~/foo/" => "~/test/"
;; or "~/foo/" =>"~/foo/"
;; or "~/foo/ => ~/foo/bar/")
;; In this case the 'name-constructor' have set the destination
;; TO to "~/test/foo" because the old emacs23 behavior
;; of `copy-directory' was to not create the subdirectory
;; and instead copy the contents.
;; With the new behavior of `copy-directory'
;; (similar to the `cp' shell command) we don't
;; need such a construction of the target directory,
;; so modify the destination TO to "~/test/" instead of "~/test/foo/".
(let ((destname (file-name-directory to)))
(when (and (file-directory-p from)
(file-directory-p to)
(eq file-creator 'dired-copy-file))
(setq to destname))
;; If DESTNAME is a subdirectory of FROM, not a symlink,
;; and the method in use is copying, signal an error.
(and (eq t (car (file-attributes destname)))
(eq file-creator 'dired-copy-file)
(file-in-directory-p destname from)
(error "Cannot copy `%s' into its subdirectory `%s'"
from to)))
(if overwrite
(or (and dired-overwrite-confirmed
(push (cons from to) async-fn-list))
(progn
(push (dired-make-relative from) failures)
(dired-log "%s `%s' to `%s' failed\n"
operation from to)))
(push (cons from to) async-fn-list)))))
;; Fix tramp issue #80 with emacs-26, use "-q" only when needed.
(setq async-quiet-switch
(if (and (boundp 'tramp-cache-read-persistent-data)
async-fn-list
(cl-loop for (_from . to) in async-fn-list
thereis (file-remote-p to)))
"-q" "-Q"))
;; When failures have been printed to dired log add the date at bob.
(when (or failures skipped) (dired-log t))
;; When async-fn-list is empty that's mean only one file
;; had to be copied and user finally answer NO.
;; In this case async process will never start and callback
;; will have no chance to run, so notify failures here.
(unless async-fn-list
(cond (failures
(funcall dired-async-message-function
"%s failed for %d of %d file%s -- See *Dired log* buffer"
'dired-async-failures
operation (length failures)
total (dired-plural-s total)))
(skipped
(funcall dired-async-message-function
"%s: %d of %d file%s skipped -- See *Dired log* buffer"
'dired-async-failures
operation (length skipped) total
(dired-plural-s total)))))
;; Setup callback.
(setq callback
(lambda (&optional _ignore)
(dired-async-after-file-create
total (list operation (length async-fn-list)) failures skipped)
(when (string= (downcase operation) "rename")
(cl-loop for (file . to) in async-fn-list
for bf = (get-file-buffer file)
for destp = (file-exists-p to)
do (and bf destp
(with-current-buffer bf
(set-visited-file-name to t t))))))))
;; Start async process.
(when async-fn-list
(async-start `(lambda ()
(require 'cl-lib) (require 'dired-aux) (require 'dired-x)
,(async-inject-variables dired-async-env-variables-regexp)
(let ((dired-recursive-copies (quote always))
(dired-copy-preserve-time
,dired-copy-preserve-time))
(setq overwrite-backup-query nil)
;; Inline `backup-file' as long as it is not
;; available in emacs.
(defalias 'backup-file
;; Same feature as "cp -f --backup=numbered from to"
;; Symlinks are copied as file from source unlike
;; `dired-copy-file' which is same as cp -d.
;; Directories are omitted.
(lambda (from to ok)
(cond ((file-directory-p from) (ignore))
(t (let ((count 0))
(while (let ((attrs (file-attributes to)))
(and attrs (null (nth 0 attrs))))
(cl-incf count)
(setq to (concat (file-name-sans-versions to)
(format ".~%s~" count)))))
(condition-case err
(copy-file from to ok dired-copy-preserve-time)
(file-date-error
(dired-log "Can't set date on %s:\n%s\n" from err)))))))
;; Now run the FILE-CREATOR function on files.
(cl-loop with fn = (quote ,file-creator)
for (from . dest) in (quote ,async-fn-list)
do (condition-case err
(funcall fn from dest t)
(file-error
(dired-log "%s: %s\n" (car err) (cdr err)))
nil))
(when (get-buffer dired-log-buffer)
(dired-log t)
(with-current-buffer dired-log-buffer
(write-region (point-min) (point-max)
,dired-async-log-file))))
,(dired-async-maybe-kill-ftp))
callback)
;; Run mode-line notifications while process running.
(dired-async--modeline-mode 1)
(message "%s proceeding asynchronously..." operation))))
(defvar wdired-use-interactive-rename)
(defun dired-async-wdired-do-renames (old-fn &rest args)
;; Perhaps a better fix would be to ask for renaming BEFORE starting
;; OLD-FN when `wdired-use-interactive-rename' is non-nil. For now
;; just bind it to nil to ensure no questions will be asked between
;; each rename.
(let (wdired-use-interactive-rename)
(apply old-fn args)))
(defadvice wdired-do-renames (around wdired-async)
(let (wdired-use-interactive-rename)
ad-do-it))
(defadvice dired-create-files (around dired-async)
(dired-async-create-files file-creator operation fn-list
name-constructor marker-char))
;;;###autoload
(define-minor-mode dired-async-mode
"Do dired actions asynchronously."
:group 'dired-async
:lighter dired-async-mode-lighter
:global t
(if dired-async-mode
(if (fboundp 'advice-add)
(progn (advice-add 'dired-create-files :override #'dired-async-create-files)
(advice-add 'wdired-do-renames :around #'dired-async-wdired-do-renames))
(ad-activate 'dired-create-files)
(ad-activate 'wdired-do-renames))
(if (fboundp 'advice-remove)
(progn (advice-remove 'dired-create-files #'dired-async-create-files)
(advice-remove 'wdired-do-renames #'dired-async-wdired-do-renames))
(ad-deactivate 'dired-create-files)
(ad-deactivate 'wdired-do-renames))))
(defmacro dired-async--with-async-create-files (&rest body)
"Evaluate BODY with dired-create-files set to dired-async-create-files."
(declare (indent 0))
`(cl-letf (((symbol-function 'dired-create-files) #'dired-async-create-files))
,@body))
;;;###autoload
(defun dired-async-do-copy (&optional arg)
"Run dired-do-copy asynchronously."
(interactive "P")
(dired-async--with-async-create-files
(dired-do-copy arg)))
;;;###autoload
(defun dired-async-do-symlink (&optional arg)
"Run dired-do-symlink asynchronously."
(interactive "P")
(dired-async--with-async-create-files
(dired-do-symlink arg)))
;;;###autoload
(defun dired-async-do-hardlink (&optional arg)
"Run dired-do-hardlink asynchronously."
(interactive "P")
(dired-async--with-async-create-files
(dired-do-hardlink arg)))
;;;###autoload
(defun dired-async-do-rename (&optional arg)
"Run dired-do-rename asynchronously."
(interactive "P")
(dired-async--with-async-create-files
(dired-do-rename arg)))
(provide 'dired-async)
;;; dired-async.el ends here

Binary file not shown.

View File

@@ -0,0 +1,73 @@
;;; smtpmail-async.el --- Send e-mail with smtpmail.el asynchronously -*- lexical-binding: t -*-
;; Copyright (C) 2012-2016 Free Software Foundation, Inc.
;; Author: John Wiegley <jwiegley@gmail.com>
;; Created: 18 Jun 2012
;; Keywords: email async
;; X-URL: https://github.com/jwiegley/emacs-async
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or (at
;; your option) any later version.
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; Send e-mail with smtpmail.el asynchronously. To use:
;;
;; (require 'smtpmail-async)
;;
;; (setq send-mail-function 'async-smtpmail-send-it
;; message-send-mail-function 'async-smtpmail-send-it)
;;
;; This assumes you already have smtpmail.el working.
;;; Code:
(defgroup smtpmail-async nil
"Send e-mail with smtpmail.el asynchronously"
:group 'smptmail)
(require 'async)
(require 'smtpmail)
(require 'message)
(defvar async-smtpmail-before-send-hook nil
"Hook running in the child emacs in `async-smtpmail-send-it'.
It is called just before calling `smtpmail-send-it'.")
(defun async-smtpmail-send-it ()
(let ((to (message-field-value "To"))
(buf-content (buffer-substring-no-properties
(point-min) (point-max))))
(message "Delivering message to %s..." to)
(async-start
`(lambda ()
(require 'smtpmail)
(with-temp-buffer
(insert ,buf-content)
(set-buffer-multibyte nil)
;; Pass in the variable environment for smtpmail
,(async-inject-variables
"\\`\\(smtpmail\\|async-smtpmail\\|\\(user-\\)?mail\\)-\\|auth-sources\\|epg\\|nsm"
nil "\\`\\(mail-header-format-function\\|smtpmail-address-buffer\\|mail-mode-abbrev-table\\)")
(run-hooks 'async-smtpmail-before-send-hook)
(smtpmail-send-it)))
(lambda (&optional _ignore)
(message "Delivering message to %s...done" to)))))
(provide 'smtpmail-async)
;;; smtpmail-async.el ends here

Binary file not shown.

View File

@@ -0,0 +1,71 @@
;;; auto-complete-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (directory-file-name
(or (file-name-directory #$) (car load-path))))
;;;### (autoloads nil "auto-complete" "auto-complete.el" (0 0 0 0))
;;; Generated autoloads from auto-complete.el
(autoload 'auto-complete "auto-complete" "\
Start auto-completion at current point.
\(fn &optional SOURCES)" t nil)
(autoload 'auto-complete-mode "auto-complete" "\
AutoComplete mode
\(fn &optional ARG)" t nil)
(defvar global-auto-complete-mode nil "\
Non-nil if Global Auto-Complete mode is enabled.
See the `global-auto-complete-mode' command
for a description of this minor mode.
Setting this variable directly does not take effect;
either customize it (see the info node `Easy Customization')
or call the function `global-auto-complete-mode'.")
(custom-autoload 'global-auto-complete-mode "auto-complete" nil)
(autoload 'global-auto-complete-mode "auto-complete" "\
Toggle Auto-Complete mode in all buffers.
With prefix ARG, enable Global Auto-Complete mode if ARG is positive;
otherwise, disable it. If called from Lisp, enable the mode if
ARG is omitted or nil.
Auto-Complete mode is enabled in all buffers where
`auto-complete-mode-maybe' would do it.
See `auto-complete-mode' for more information on Auto-Complete mode.
\(fn &optional ARG)" t nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "auto-complete" '("auto-complete-mode" "ac-")))
;;;***
;;;### (autoloads nil "auto-complete-config" "auto-complete-config.el"
;;;;;; (0 0 0 0))
;;; Generated autoloads from auto-complete-config.el
(autoload 'ac-config-default "auto-complete-config" "\
\(fn)" nil nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "auto-complete-config" '("ac-")))
;;;***
;;;### (autoloads nil nil ("auto-complete-pkg.el") (0 0 0 0))
;;;***
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; auto-complete-autoloads.el ends here

View File

@@ -0,0 +1,551 @@
;;; auto-complete-config.el --- auto-complete additional configuations
;; Copyright (C) 2009, 2010 Tomohiro Matsuyama
;; Author: Tomohiro Matsuyama <m2ym.pub@gmail.com>
;; Keywords: convenience
;; Version: 1.5.0
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;;; Code:
(require 'cl-lib)
(require 'auto-complete)
(declare-function semantic-analyze-current-context "semantic/analyze")
(declare-function semantic-tag-class "semantic/tag")
(declare-function semantic-tag-function-arguments "semantic/tag")
(declare-function semantic-format-tag-type "semantic/format")
(declare-function semantic-format-tag-name "semantic/format")
(declare-function yas-expand-snippet "yasnippet")
(declare-function oref "eieio" (obj slot))
;;;; Additional sources
;; imenu
(defvar ac-imenu-index nil)
(ac-clear-variable-every-10-minutes 'ac-imenu-index)
(defun ac-imenu-candidates ()
(cl-loop with i = 0
with stack = (progn
(unless (local-variable-p 'ac-imenu-index)
(make-local-variable 'ac-imenu-index))
(or ac-imenu-index
(setq ac-imenu-index
(ignore-errors
(with-no-warnings
(imenu--make-index-alist))))))
with result
while (and stack (or (not (integerp ac-limit))
(< i ac-limit)))
for node = (pop stack)
if (consp node)
do
(let ((car (car node))
(cdr (cdr node)))
(if (consp cdr)
(mapc (lambda (child)
(push child stack))
cdr)
(when (and (stringp car)
(string-match (concat "^" (regexp-quote ac-prefix)) car))
;; Remove extra characters
(if (string-match "^.*\\(()\\|=\\|<>\\)$" car)
(setq car (substring car 0 (match-beginning 1))))
(push car result)
(cl-incf i))))
finally return (nreverse result)))
(ac-define-source imenu
'((depends imenu)
(candidates . ac-imenu-candidates)
(symbol . "s")))
;; gtags
(defface ac-gtags-candidate-face
'((t (:inherit ac-candidate-face :foreground "navy")))
"Face for gtags candidate"
:group 'auto-complete)
(defface ac-gtags-selection-face
'((t (:inherit ac-selection-face :background "navy")))
"Face for the gtags selected candidate."
:group 'auto-complete)
(defun ac-gtags-candidate ()
(ignore-errors
(split-string (shell-command-to-string (format "global -ciq %s" ac-prefix)) "\n")))
(ac-define-source gtags
'((candidates . ac-gtags-candidate)
(candidate-face . ac-gtags-candidate-face)
(selection-face . ac-gtags-selection-face)
(requires . 3)
(symbol . "s")))
;; yasnippet
(defface ac-yasnippet-candidate-face
'((t (:inherit ac-candidate-face
:background "sandybrown" :foreground "black")))
"Face for yasnippet candidate."
:group 'auto-complete)
(defface ac-yasnippet-selection-face
'((t (:inherit ac-selection-face :background "coral3")))
"Face for the yasnippet selected candidate."
:group 'auto-complete)
(defun ac-yasnippet-table-hash (table)
(cond
((fboundp 'yas/snippet-table-hash)
(yas/snippet-table-hash table))
((fboundp 'yas/table-hash)
(yas/table-hash table))))
(defun ac-yasnippet-table-parent (table)
(cond
((fboundp 'yas/snippet-table-parent)
(yas/snippet-table-parent table))
((fboundp 'yas/table-parent)
(yas/table-parent table))))
(defun ac-yasnippet-candidate-1 (table)
(with-no-warnings
(let ((hashtab (ac-yasnippet-table-hash table))
(parent (ac-yasnippet-table-parent table))
candidates)
(maphash (lambda (key value)
(push key candidates))
hashtab)
(setq candidates (all-completions ac-prefix (nreverse candidates)))
(if parent
(setq candidates
(append candidates (ac-yasnippet-candidate-1 parent))))
candidates)))
(defun ac-yasnippet-candidates ()
(with-no-warnings
(cond (;; 0.8 onwards
(fboundp 'yas-active-keys)
(all-completions ac-prefix (yas-active-keys)))
(;; >0.6.0
(fboundp 'yas/get-snippet-tables)
(apply 'append (mapcar 'ac-yasnippet-candidate-1
(condition-case nil
(yas/get-snippet-tables major-mode)
(wrong-number-of-arguments
(yas/get-snippet-tables)))))
)
(t
(let ((table
(if (fboundp 'yas/snippet-table)
;; <0.6.0
(yas/snippet-table major-mode)
;; 0.6.0
(yas/current-snippet-table))))
(if table
(ac-yasnippet-candidate-1 table)))))))
(ac-define-source yasnippet
'((depends yasnippet)
(candidates . ac-yasnippet-candidates)
(action . yas/expand)
(candidate-face . ac-yasnippet-candidate-face)
(selection-face . ac-yasnippet-selection-face)
(symbol . "a")))
;; semantic
(defun ac-semantic-candidates (prefix)
(with-no-warnings
(delete "" ; semantic sometimes returns an empty string
(mapcar (lambda (elem)
(cons (semantic-tag-name elem)
(semantic-tag-clone elem)))
(ignore-errors
(or (semantic-analyze-possible-completions
(semantic-analyze-current-context))
(senator-find-tag-for-completion prefix)))))))
(defun ac-semantic-doc (symbol)
(with-no-warnings
(let* ((proto (semantic-format-tag-summarize-with-file symbol nil t))
(doc (semantic-documentation-for-tag symbol))
(res proto))
(when doc
(setq res (concat res "\n\n" doc)))
res)))
(defun ac-semantic-action ()
(when (and (boundp 'yas-minor-mode) yas-minor-mode)
(let* ((tag (car (last (oref (semantic-analyze-current-context) prefix))))
(class (semantic-tag-class tag))
(args))
(when (eq class 'function)
(setq args (semantic-tag-function-arguments tag))
(yas-expand-snippet
(concat "("
(mapconcat
(lambda (arg)
(let ((arg-type (semantic-format-tag-type arg nil))
(arg-name (semantic-format-tag-name arg nil)))
(concat "${"
(if (string= arg-name "")
arg-type
(concat arg-type " " arg-name))
"}")))
args
", ")
")$0"))))))
(ac-define-source semantic
'((available . (or (require 'semantic-ia nil t)
(require 'semantic/ia nil t)))
(candidates . (ac-semantic-candidates ac-prefix))
(document . ac-semantic-doc)
(action . ac-semantic-action)
(prefix . cc-member)
(requires . 0)
(symbol . "m")))
(ac-define-source semantic-raw
'((available . (or (require 'semantic-ia nil t)
(require 'semantic/ia nil t)))
(candidates . (ac-semantic-candidates ac-prefix))
(document . ac-semantic-doc)
(action . ac-semantic-action)
(symbol . "s")))
;; eclim
(defun ac-eclim-candidates ()
(with-no-warnings
(cl-loop for c in (eclim/java-complete)
collect (nth 1 c))))
(ac-define-source eclim
'((candidates . ac-eclim-candidates)
(prefix . c-dot)
(requires . 0)
(symbol . "f")))
;; css
;; Copied from company-css.el
(defconst ac-css-property-alist
;; see http://www.w3.org/TR/CSS21/propidx.html
'(("azimuth" angle "left-side" "far-left" "left" "center-left" "center"
"center-right" "right" "far-right" "right-side" "behind" "leftwards"
"rightwards")
("background" background-color background-image background-repeat
background-attachment background-position)
("background-attachment" "scroll" "fixed")
("background-color" color "transparent")
("background-image" uri "none")
("background-position" percentage length "left" "center" "right" percentage
length "top" "center" "bottom" "left" "center" "right" "top" "center"
"bottom")
("background-repeat" "repeat" "repeat-x" "repeat-y" "no-repeat")
("border" border-width border-style border-color)
("border-bottom" border)
("border-bottom-color" border-color)
("border-bottom-style" border-style)
("border-bottom-width" border-width)
("border-collapse" "collapse" "separate")
("border-color" color "transparent")
("border-left" border)
("border-left-color" border-color)
("border-left-style" border-style)
("border-left-width" border-width)
("border-right" border)
("border-right-color" border-color)
("border-right-style" border-style)
("border-right-width" border-width)
("border-spacing" length length)
("border-style" border-style)
("border-top" border)
("border-top-color" border-color)
("border-top-style" border-style)
("border-top-width" border-width)
("border-width" border-width)
("bottom" length percentage "auto")
("caption-side" "top" "bottom")
("clear" "none" "left" "right" "both")
("clip" shape "auto")
("color" color)
("content" "normal" "none" string uri counter "attr()" "open-quote"
"close-quote" "no-open-quote" "no-close-quote")
("counter-increment" identifier integer "none")
("counter-reset" identifier integer "none")
("cue" cue-before cue-after)
("cue-after" uri "none")
("cue-before" uri "none")
("cursor" uri "*" "auto" "crosshair" "default" "pointer" "move" "e-resize"
"ne-resize" "nw-resize" "n-resize" "se-resize" "sw-resize" "s-resize"
"w-resize" "text" "wait" "help" "progress")
("direction" "ltr" "rtl")
("display" "inline" "block" "list-item" "run-in" "inline-block" "table"
"inline-table" "table-row-group" "table-header-group" "table-footer-group"
"table-row" "table-column-group" "table-column" "table-cell"
"table-caption" "none")
("elevation" angle "below" "level" "above" "higher" "lower")
("empty-cells" "show" "hide")
("float" "left" "right" "none")
("font" font-style font-variant font-weight font-size "/" line-height
font-family "caption" "icon" "menu" "message-box" "small-caption"
"status-bar")
("font-family" family-name generic-family)
("font-size" absolute-size relative-size length percentage)
("font-style" "normal" "italic" "oblique")
("font-variant" "normal" "small-caps")
("font-weight" "normal" "bold" "bolder" "lighter" "100" "200" "300" "400"
"500" "600" "700" "800" "900")
("height" length percentage "auto")
("left" length percentage "auto")
("letter-spacing" "normal" length)
("line-height" "normal" number length percentage)
("list-style" list-style-type list-style-position list-style-image)
("list-style-image" uri "none")
("list-style-position" "inside" "outside")
("list-style-type" "disc" "circle" "square" "decimal" "decimal-leading-zero"
"lower-roman" "upper-roman" "lower-greek" "lower-latin" "upper-latin"
"armenian" "georgian" "lower-alpha" "upper-alpha" "none")
("margin" margin-width)
("margin-bottom" margin-width)
("margin-left" margin-width)
("margin-right" margin-width)
("margin-top" margin-width)
("max-height" length percentage "none")
("max-width" length percentage "none")
("min-height" length percentage)
("min-width" length percentage)
("orphans" integer)
("outline" outline-color outline-style outline-width)
("outline-color" color "invert")
("outline-style" border-style)
("outline-width" border-width)
("overflow" "visible" "hidden" "scroll" "auto")
("padding" padding-width)
("padding-bottom" padding-width)
("padding-left" padding-width)
("padding-right" padding-width)
("padding-top" padding-width)
("page-break-after" "auto" "always" "avoid" "left" "right")
("page-break-before" "auto" "always" "avoid" "left" "right")
("page-break-inside" "avoid" "auto")
("pause" time percentage)
("pause-after" time percentage)
("pause-before" time percentage)
("pitch" frequency "x-low" "low" "medium" "high" "x-high")
("pitch-range" number)
("play-during" uri "mix" "repeat" "auto" "none")
("position" "static" "relative" "absolute" "fixed")
("quotes" string string "none")
("richness" number)
("right" length percentage "auto")
("speak" "normal" "none" "spell-out")
("speak-header" "once" "always")
("speak-numeral" "digits" "continuous")
("speak-punctuation" "code" "none")
("speech-rate" number "x-slow" "slow" "medium" "fast" "x-fast" "faster"
"slower")
("stress" number)
("table-layout" "auto" "fixed")
("text-align" "left" "right" "center" "justify")
("text-decoration" "none" "underline" "overline" "line-through" "blink")
("text-indent" length percentage)
("text-transform" "capitalize" "uppercase" "lowercase" "none")
("top" length percentage "auto")
("unicode-bidi" "normal" "embed" "bidi-override")
("vertical-align" "baseline" "sub" "super" "top" "text-top" "middle"
"bottom" "text-bottom" percentage length)
("visibility" "visible" "hidden" "collapse")
("voice-family" specific-voice generic-voice "*" specific-voice
generic-voice)
("volume" number percentage "silent" "x-soft" "soft" "medium" "loud"
"x-loud")
("white-space" "normal" "pre" "nowrap" "pre-wrap" "pre-line")
("widows" integer)
("width" length percentage "auto")
("word-spacing" "normal" length)
("z-index" "auto" integer))
"A list of CSS properties and their possible values.")
(defconst ac-css-value-classes
'((absolute-size "xx-small" "x-small" "small" "medium" "large" "x-large"
"xx-large")
(border-style "none" "hidden" "dotted" "dashed" "solid" "double" "groove"
"ridge" "inset" "outset")
(color "aqua" "black" "blue" "fuchsia" "gray" "green" "lime" "maroon" "navy"
"olive" "orange" "purple" "red" "silver" "teal" "white" "yellow"
"rgb")
(counter "counter")
(family-name "Courier" "Helvetica" "Times")
(generic-family "serif" "sans-serif" "cursive" "fantasy" "monospace")
(generic-voice "male" "female" "child")
(margin-width "auto") ;; length percentage
(relative-size "larger" "smaller")
(shape "rect")
(uri "url"))
"A list of CSS property value classes and their contents.")
(defconst ac-css-pseudo-classes
'("active" "after" "before" "first" "first-child" "first-letter" "first-line"
"focus" "hover" "lang" "left" "link" "right" "visited")
"Identifiers for CSS pseudo-elements and pseudo-classes.")
(defvar ac-css-property nil
"Current editing property.")
(defun ac-css-prefix ()
(when (save-excursion (re-search-backward "\\_<\\(.+?\\)\\_>\\s *:[^;]*\\=" nil t))
(setq ac-css-property (match-string 1))
(or (ac-prefix-symbol) (point))))
(defun ac-css-property-candidates ()
(let ((list (assoc-default ac-css-property ac-css-property-alist)))
(if list
(cl-loop with seen
with value
while (setq value (pop list))
if (symbolp value)
do (unless (memq value seen)
(push value seen)
(setq list
(append list
(or (assoc-default value ac-css-value-classes)
(assoc-default (symbol-name value) ac-css-property-alist)))))
else collect value)
ac-css-pseudo-classes)))
(ac-define-source css-property
'((candidates . ac-css-property-candidates)
(prefix . ac-css-prefix)
(requires . 0)))
;; slime
(ac-define-source slime
'((depends slime)
(candidates . (car (slime-simple-completions ac-prefix)))
(symbol . "s")
(cache)))
;; ghc-mod
(ac-define-source ghc-mod
'((depends ghc)
(candidates . (ghc-select-completion-symbol))
(symbol . "s")
(cache)))
;;;; Not maintained sources
;; ropemacs
(defvar ac-ropemacs-loaded nil)
(defun ac-ropemacs-require ()
(with-no-warnings
(unless ac-ropemacs-loaded
(pymacs-load "ropemacs" "rope-")
(if (boundp 'ropemacs-enable-autoimport)
(setq ropemacs-enable-autoimport t))
(setq ac-ropemacs-loaded t))))
(defun ac-ropemacs-setup ()
(ac-ropemacs-require)
;(setq ac-sources (append (list 'ac-source-ropemacs) ac-sources))
(setq ac-omni-completion-sources '(("\\." ac-source-ropemacs))))
(defun ac-ropemacs-initialize ()
(autoload 'pymacs-apply "pymacs")
(autoload 'pymacs-call "pymacs")
(autoload 'pymacs-eval "pymacs" nil t)
(autoload 'pymacs-exec "pymacs" nil t)
(autoload 'pymacs-load "pymacs" nil t)
(add-hook 'python-mode-hook 'ac-ropemacs-setup)
t)
(defvar ac-ropemacs-completions-cache nil)
(defvar ac-source-ropemacs
'((init
. (lambda ()
(setq ac-ropemacs-completions-cache
(mapcar
(lambda (completion)
(concat ac-prefix completion))
(ignore-errors
(rope-completions))))))
(candidates . ac-ropemacs-completions-cache)))
;; rcodetools
(defvar ac-source-rcodetools
'((init . (lambda ()
(require 'rcodetools)
(condition-case x
(save-excursion
(rct-exec-and-eval rct-complete-command-name "--completion-emacs-icicles"))
(error) (setq rct-method-completion-table nil))))
(candidates . (lambda ()
(all-completions
ac-prefix
(mapcar
(lambda (completion)
(replace-regexp-in-string "\t.*$" "" (car completion)))
rct-method-completion-table))))))
;;;; Default settings
(defun ac-common-setup ()
;(add-to-list 'ac-sources 'ac-source-filename)
)
(defun ac-emacs-lisp-mode-setup ()
(setq ac-sources (append '(ac-source-features ac-source-functions ac-source-yasnippet ac-source-variables ac-source-symbols) ac-sources)))
(defun ac-cc-mode-setup ()
(setq ac-sources (append '(ac-source-yasnippet ac-source-gtags) ac-sources)))
(defun ac-ruby-mode-setup ())
(defun ac-css-mode-setup ()
(setq ac-sources (append '(ac-source-css-property) ac-sources)))
;;;###autoload
(defun ac-config-default ()
(setq-default ac-sources '(ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers))
(add-hook 'emacs-lisp-mode-hook 'ac-emacs-lisp-mode-setup)
(add-hook 'c-mode-common-hook 'ac-cc-mode-setup)
(add-hook 'ruby-mode-hook 'ac-ruby-mode-setup)
(add-hook 'css-mode-hook 'ac-css-mode-setup)
(add-hook 'auto-complete-mode-hook 'ac-common-setup)
(global-auto-complete-mode t))
(provide 'auto-complete-config)
;;; auto-complete-config.el ends here

View File

@@ -0,0 +1,6 @@
(define-package "auto-complete" "20170125.245" "Auto Completion for GNU Emacs"
'((popup "0.5.0")
(cl-lib "0.5")))
;; Local Variables:
;; no-byte-compile: t
;; End:

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -0,0 +1,72 @@
abort
abs
abstract
accept
access
aliased
all
and
array
at
begin
body
case
constant
declare
delay
delta
digits
do
else
elsif
end
entry
exception
exit
for
function
generic
goto
if
in
interface
is
limited
loop
mod
new
not
null
of
or
others
out
overriding
package
pragma
private
procedure
protected
raise
range
record
rem
renames
requeue
return
reverse
select
separate
subtype
synchronized
tagged
task
terminate
then
type
until
use
when
while
with
xor

View File

@@ -0,0 +1,99 @@
alignas
alignof
and
and_eq
asm
auto
bitand
bitor
bool
break
case
catch
char
char16_t
char32_t
class
compl
concept
const
const_cast
constexpr
continue
decltype
default
define
defined
delete
do
double
dynamic_cast
elif
else
endif
enum
error
explicit
export
extern
false
final
float
for
friend
goto
if
ifdef
ifndef
include
inline
int
line
long
mutable
namespace
new
noexcept
not
not_eq
nullptr
operator
or
or_eq
override
pragma
_Pragma
private
protected
public
register
reinterpret_cast
requires
return
short
signed
sizeof
static
static_assert
static_cast
struct
switch
template
this
thread_local
throw
true
try
typedef
typeid
typename
union
unsigned
using
virtual
void
volatile
wchar_t
while
xor
xor_eq

View File

@@ -0,0 +1,55 @@
auto
_Alignas
_Alignof
_Atomic
_Bool
break
case
char
_Complex
const
continue
default
define
defined
do
double
elif
else
endif
enum
error
extern
float
for
goto
_Generic
if
ifdef
ifndef
_Imaginary
include
inline
int
line
long
_Noreturn
pragma
register
restrict
return
short
signed
sizeof
static
struct
switch
_Static_assert
typedef
_Thread_local
undef
union
unsigned
void
volatile
while

View File

@@ -0,0 +1,231 @@
# OCaml 3.12.1
# Keywords
and
as
assert
begin
class
constraint
do
done
downto
else
end
exception
external
false
for
fun
function
functor
if
in
include
inherit
initializer
lazy
let
match
method
module
mutable
new
object
of
open
or
private
rec
sig
struct
then
to
true
try
type
val
virtual
when
while
with
# Pervasives
!
!=
&
&&
*
**
*.
+
+.
-
-.
/
/.
:=
<
<=
<>
=
==
>
>=
@
FP_infinite
FP_nan
FP_normal
FP_subnormal
FP_zero
LargeFile
Open_append
Open_binary
Open_creat
Open_nonblock
Open_rdonly
Open_text
Open_trunc
Open_wronly
Oupen_excl
^
^^
abs
abs_float
acos
asin
asr
at_exit
atan
atan2
bool_of_string
ceil
char_of_int
classify_float
close_in
close_in_noerr
close_out
close_out_noerr
compare
cos
cosh
decr
do_at_exit
epsilon_float
exit
exp
expm1
failwith
float
float_of_int
float_of_string
floor
flush
flush_all
format
format4
format_of_string
fpclass
frexp
fst
ignore
in_channel
in_channel_length
incr
infinity
input
input_binary_int
input_byte
input_char
input_line
input_value
int_of_char
int_of_float
int_of_string
invalid_arg
land
ldexp
lnot
log
log10
log1p
lor
lsl
lsr
lxor
max
max_float
max_int
min
min_float
min_int
mod
mod_float
modf
nan
neg_infinity
not
open_flag
open_in
open_in_bin
open_in_gen
open_out
open_out_bin
open_out_gen
or
out_channel
out_channel_length
output
output_binary_int
output_byte
output_char
output_string
output_value
pos_in
pos_out
pred
prerr_char
prerr_endline
prerr_float
prerr_int
prerr_newline
prerr_string
print_char
print_endline
print_float
print_int
print_newline
print_string
raise
read_float
read_int
read_line
really_input
ref
seek_in
seek_out
set_binary_mode_in
set_binary_mode_out
sin
sinh
snd
sqrt
stderr
stdin
stdout
string_of_bool
string_of_float
string_of_format
string_of_int
succ
tan
tanh
truncate
unsafe_really_input
valid_float_lexem
||
~
~+
~+.
~-
~-.

View File

@@ -0,0 +1,580 @@
*agent*
*allow-unresolved-vars*
*assert*
*clojure-version*
*command-line-args*
*compile-files*
*compile-path*
*compiler-options*
*data-readers*
*default-data-reader-fn*
*err*
*file*
*flush-on-newline*
*fn-loader*
*in*
*math-context*
*ns*
*out*
*print-dup*
*print-length*
*print-level*
*print-meta*
*print-readably*
*read-eval*
*source-path*
*unchecked-math*
*use-context-classloader*
*verbose-defrecords*
*warn-on-reflection*
->ArrayChunk
->Vec
->VecNode
->VecSeq
-cache-protocol-fn
-reset-methods
accessor
aclone
add-classpath
add-watch
agent
agent-error
agent-errors
aget
alength
alias
all-ns
alter
alter-meta!
alter-var-root
amap
ancestors
and
apply
areduce
array-map
as->
aset
aset-boolean
aset-byte
aset-char
aset-double
aset-float
aset-int
aset-long
aset-short
assert
assoc
assoc!
assoc-in
associative?
atom
await
await-for
await1
bases
bean
bigdec
bigint
biginteger
binding
bit-and
bit-and-not
bit-clear
bit-flip
bit-not
bit-or
bit-set
bit-shift-left
bit-shift-right
bit-test
bit-xor
boolean
boolean-array
booleans
bound-fn
bound-fn*
bound?
butlast
byte
byte-array
bytes
case
cast
char
char-array
char-escape-string
char-name-string
char?
chars
chunk
chunk-append
chunk-buffer
chunk-cons
chunk-first
chunk-next
chunk-rest
chunked-seq?
class
class?
clear-agent-errors
clojure-version
coll?
comment
commute
comp
comparator
compare
compare-and-set!
compile
complement
concat
cond
cond->
cond->>
condp
conj
conj!
cons
constantly
construct-proxy
contains?
count
counted?
create-ns
create-struct
cycle
dec
dec'
decimal?
declare
default-data-readers
definline
definterface
defmacro
defmethod
defmulti
defn
defn-
defonce
defprotocol
defrecord
defstruct
deftype
delay
delay?
deliver
denominator
deref
derive
descendants
destructure
disj
disj!
dissoc
dissoc!
distinct
distinct?
doall
doc
dorun
doseq
dosync
dotimes
doto
double
double-array
doubles
drop
drop-last
drop-while
dtype
empty
empty?
ensure
enumeration-seq
error-handler
error-mode
eval
even?
every-pred
every?
ex-data
ex-info
extend
extend-class
extend-protocol
extend-type
extenders
extends?
false?
ffirst
file-seq
filter
filterv
find
find-doc
find-keyword
find-ns
find-protocol-impl
find-protocol-method
find-var
first
flatten
float
float-array
float?
floats
flush
fn
fn?
fnext
fnil
for
force
format
frequencies
future
future-call
future-cancel
future-cancelled?
future-done?
future?
gen-class
gen-interface
gensym
get
get-in
get-method
get-proxy-class
get-thread-bindings
get-validator
group-by
hash
hash-combine
hash-map
hash-set
identical?
identity
if-let
if-not
ifn?
import
in-ns
inc
inc'
init-proxy
instance?
int
int-array
integer?
interleave
intern
interpose
into
into-array
ints
io!
isa?
iterate
iterator-seq
juxt
keep
keep-indexed
key
keys
keyword
keyword?
last
lazy-cat
lazy-seq
let
letfn
line-seq
list
list*
list?
load
load-file
load-reader
load-string
loaded-libs
locking
long
long-array
longs
loop
macroexpand
macroexpand-1
make-array
make-hierarchy
map
map-indexed
map?
mapcat
mapv
max
max-key
memfn
memoize
merge
merge-with
meta
method-sig
methods
min
min-key
mod
munge
name
namespace
namespace-munge
neg?
newline
next
nfirst
nil?
nnext
not
not-any?
not-empty
not-every?
not=
ns
ns-aliases
ns-imports
ns-interns
ns-map
ns-name
ns-publics
ns-refers
ns-resolve
ns-unalias
ns-unmap
nth
nthnext
nthrest
num
number?
numerator
object-array
odd?
or
parents
partial
partition
partition-all
partition-by
pcalls
peek
persistent!
pmap
pop
pop!
pop-thread-bindings
pos?
pr
pr-str
prefer-method
prefers
primitives-classnames
print
print-ctor
print-dup
print-method
print-namespace-doc
print-simple
print-str
printf
println
println-str
prn
prn-str
promise
proxy
proxy-call-with-super
proxy-mappings
proxy-name
proxy-super
push-thread-bindings
pvalues
quot
rand
rand-int
rand-nth
range
ratio?
rational?
rationalize
re-find
re-groups
re-matcher
re-matches
re-pattern
re-seq
read
read-line
read-string
realized?
reduce
reduce-kv
reduced
reduced?
reductions
ref
ref-history-count
ref-max-history
ref-min-history
ref-set
refer
refer-clojure
reify
release-pending-sends
rem
remove
remove-all-methods
remove-method
remove-ns
remove-watch
repeat
repeatedly
replace
replicate
require
reset!
reset-meta!
resolve
rest
restart-agent
resultset-seq
reverse
reversible?
rseq
rsubseq
satisfies?
second
select-keys
send
send-off
send-via
seq
seq?
seque
sequence
sequential?
set
set-agent-send-executor!
set-agent-send-off-executor!
set-error-handler!
set-error-mode!
set-validator!
set?
short
short-array
shorts
shuffle
shutdown-agents
slurp
some
some->
some->>
some-fn
sort
sort-by
sorted-map
sorted-map-by
sorted-set
sorted-set-by
sorted?
special-form-anchor
special-symbol?
spit
split-at
split-with
str
stream?
string?
struct
struct-map
subs
subseq
subvec
supers
swap!
symbol
symbol?
sync
syntax-symbol-anchor
take
take-last
take-nth
take-while
test
the-ns
thread-bound?
time
to-array
to-array-2d
trampoline
transient
tree-seq
true?
type
unchecked-add
unchecked-add-int
unchecked-byte
unchecked-char
unchecked-dec
unchecked-dec-int
unchecked-divide
unchecked-divide-int
unchecked-double
unchecked-float
unchecked-inc
unchecked-inc-int
unchecked-int
unchecked-long
unchecked-multiply
unchecked-multiply-int
unchecked-negate
unchecked-negate-int
unchecked-remainder
unchecked-remainder-int
unchecked-short
unchecked-subtract
unchecked-subtract-int
underive
unquote
unquote-splicing
update-in
update-proxy
use
val
vals
var-get
var-set
var?
vary-meta
vec
vector
vector-of
vector?
when
when-first
when-let
when-not
while
with-bindings
with-bindings*
with-in-str
with-loading-context
with-local-vars
with-meta
with-open
with-out-str
with-precision
with-redefs
with-redefs-fn
xml-seq
zero?
zipmap

View File

@@ -0,0 +1,475 @@
*agent*
*clojure-version*
*command-line-args*
*compile-files*
*compile-path*
*err*
*file*
*flush-on-newline*
*in*
*ns*
*out*
*print-dup*
*print-length*
*print-level*
*print-meta*
*print-readably*
*read-eval*
*warn-on-reflection*
accessor
aclone
add-classpath
add-watch
agent
agent-error
agent-errors
aget
alength
alias
all-ns
alter
alter-meta!
alter-var-root
amap
ancestors
and
apply
areduce
array-map
aset
aset-boolean
aset-byte
aset-char
aset-double
aset-float
aset-int
aset-long
aset-short
assert
assoc
assoc!
assoc-in
associative?
atom
await
await-for
bases
bean
bigdec
bigint
binding
bit-and
bit-and-not
bit-clear
bit-flip
bit-not
bit-or
bit-set
bit-shift-left
bit-shift-right
bit-test
bit-xor
boolean
boolean-array
booleans
bound-fn
bound-fn*
butlast
byte
byte-array
bytes
case
cast
char
char-array
char-escape-string
char-name-string
char?
chars
class
class?
clear-agent-errors
clojure-version
coll?
comment
commute
comp
comparator
compare
compare-and-set!
compile
complement
concat
cond
condp
conj
conj!
cons
constantly
construct-proxy
contains?
count
counted?
create-ns
create-struct
cycle
dec
decimal?
declare
definline
defmacro
defmethod
defmulti
defn
defn-
defonce
defprotocol
defstruct
deftype
delay
delay?
deliver
deref
derive
descendants
disj
disj!
dissoc
dissoc!
distinct
distinct?
doall
doc
dorun
doseq
dosync
dotimes
doto
double
double-array
doubles
drop
drop-last
drop-while
dtype
empty
empty?
ensure
enumeration-seq
error-handler
error-mode
eval
even?
every?
extend
extend-class
extend-protocol
extend-type
extenders
extends?
false?
ffirst
file-seq
filter
find
find-doc
find-ns
find-var
first
float
float-array
float?
floats
flush
fn
fn?
fnext
for
force
format
future
future-call
future-cancel
future-cancelled?
future-done?
future?
gen-class
gen-interface
gensym
get
get-in
get-method
get-proxy-class
get-thread-bindings
get-validator
hash
hash-map
hash-set
identical?
identity
if-let
if-not
ifn?
import
in-ns
inc
init-proxy
instance?
int
int-array
integer?
interleave
intern
interpose
into
into-array
ints
io!
isa?
iterate
iterator-seq
juxt
key
keys
keyword
keyword?
last
lazy-cat
lazy-seq
let
letfn
line-seq
list
list*
list?
load
load-file
load-reader
load-string
loaded-libs
locking
long
long-array
longs
loop
macroexpand
macroexpand-1
make-array
make-hierarchy
map
map?
mapcat
max
max-key
memfn
memoize
merge
merge-with
meta
methods
min
min-key
mod
name
namespace
neg?
newline
next
nfirst
nil?
nnext
not
not-any?
not-empty
not-every?
not=
ns
ns-aliases
ns-imports
ns-interns
ns-map
ns-name
ns-publics
ns-refers
ns-resolve
ns-unalias
ns-unmap
nth
nthnext
num
number?
object-array
odd?
or
parents
partial
partition
pcalls
peek
persistent!
pmap
pop
pop!
pop-thread-bindings
pos?
pr
pr-str
prefer-method
prefers
print
print-namespace-doc
print-str
printf
println
println-str
prn
prn-str
promise
proxy
proxy-mappings
proxy-super
push-thread-bindings
pvalues
quot
rand
rand-int
range
ratio?
rationalize
re-find
re-groups
re-matcher
re-matches
re-pattern
re-seq
read
read-line
read-string
reduce
ref
ref-history-count
ref-max-history
ref-min-history
ref-set
refer
refer-clojure
reify
release-pending-sends
rem
remove
remove-method
remove-ns
remove-watch
repeat
repeatedly
replace
replicate
require
reset!
reset-meta!
resolve
rest
restart-agent
resultset-seq
reverse
reversible?
rseq
rsubseq
satisfies?
second
select-keys
send
send-off
seq
seq?
seque
sequence
sequential?
set
set-error-handler!
set-error-mode!
set-validator!
set?
short
short-array
shorts
shutdown-agents
slurp
some
sort
sort-by
sorted-map
sorted-map-by
sorted-set
sorted-set-by
sorted?
special-form-anchor
special-symbol?
split-at
split-with
str
stream?
string?
struct
struct-map
subs
subseq
subvec
supers
swap!
symbol
symbol?
sync
syntax-symbol-anchor
take
take-last
take-nth
take-while
test
the-ns
time
to-array
to-array-2d
trampoline
transient
tree-seq
true?
type
unchecked-add
unchecked-dec
unchecked-divide
unchecked-inc
unchecked-multiply
unchecked-negate
unchecked-remainder
unchecked-subtract
underive
update-in
update-proxy
use
val
vals
var-get
var-set
var?
vary-meta
vec
vector
vector-of
vector?
when
when-first
when-let
when-not
while
with-bindings
with-bindings*
with-in-str
with-local-vars
with-meta
with-open
with-out-str
with-precision
xml-seq
zero?
zipmap

View File

@@ -0,0 +1,278 @@
# Generated by the following form.
# (loop for regexp in (append
# coq-solve-tactics
# coq-keywords
# coq-reserved
# coq-tactics
# coq-tacticals
# (list "Set" "Type" "Prop"))
# append (split-string regexp (regexp-quote "\\s-+")) into words
# finally (loop initially (goto-char (point-max))
# for word in (delete-dups (sort words 'string<))
# do (insert word) (newline)))
Abort
About
Abstract
Add
Admit
Admitted
All
Arguments
AutoInline
Axiom
Bind
Canonical
Cd
Chapter
Check
Close
CoFixpoint
CoInductive
Coercion
Coercions
Comments
Conjecture
Constant
Constructors
Corollary
Declare
Defined
Definition
Delimit
Dependent
Depth
Derive
End
Eval
Export
Extern
Extract
Extraction
Fact
False
Field
File
Fixpoint
Focus
Function
Functional
Goal
Hint
Hypotheses
Hypothesis
Hyps
Identity
If
Immediate
Implicit
Import
Inductive
Infix
Inline
Inlined
Inspect
Inversion
Language
Lemma
Let
Library
Limit
LoadPath
Local
Locate
Ltac
ML
Module
Morphism
Next Obligation
NoInline
Notation
Notations
Obligation
Obligations
Off
On
Opaque
Open
Optimize
Parameter
Parameters
Path
Print
Printing
Program
Proof
Prop
Pwd
Qed
Rec
Record
Recursive
Remark
Remove
Require
Reserved
Reset
Resolve
Rewrite
Ring
Save
Scheme
Scope
Search
SearchAbout
SearchPattern
SearchRewrite
Section
Semi
Set
Setoid
Show
Solve
Sort
Strict
Structure
Synth
Tactic
Test
Theorem
Time
Transparent
True
Type
Undo
Unfocus
Unfold
Unset
Variable
Variables
Width
Wildcard
abstract
absurd
after
apply
as
assert
assumption
at
auto
autorewrite
beta
by
case
cbv
change
clear
clearbody
cofix
coinduction
compare
compute
congruence
constructor
contradiction
cut
cutrewrite
decide
decompose
delta
dependent
dest
destruct
discrR
discriminate
do
double
eapply
eauto
econstructor
eexists
eleft
elim
else
end
equality
esplit
exact
exists
fail
field
first
firstorder
fix
fold
forall
fourier
fun
functional
generalize
hnf
idtac
if
in
induction
info
injection
instantiate
into
intro
intros
intuition
inversion
inversion_clear
iota
lapply
lazy
left
let
linear
load
match
move
omega
pattern
pose
progress
prolog
quote
record
red
refine
reflexivity
rename
repeat
replace
return
rewrite
right
ring
set
setoid
setoid_replace
setoid_rewrite
simpl
simple
simplify_eq
solve
specialize
split
split_Rabs
split_Rmult
stepl
stepr
struct
subst
sum
symmetry
tauto
then
transitivity
trivial
try
unfold
until
using
with
zeta

View File

@@ -0,0 +1,874 @@
!important
@font-face
@font-feature-values
@keyframes
ActiveBorder
ActiveCaption
Alpha
AppWorkspace
Background
Barn
BasicImage
Blinds
Blur
ButtonFace
ButtonHighlight
ButtonShadow
ButtonText
CaptionText
CheckerBoard
Chroma
Compositor
CradientWipe
DXImageTransform
DropShadow
Emboss
Engrave
Fade
FlipH
FlipV
Glow
Gray
GrayText
Highlight
HighlightText
Hz
ICMFilter
InactiveBorder
InactiveCaption
InactiveCaptionText
InfoBackground
InfoText
Inset
Invert
Iris
Light
MaskFilter
Matrix
Menu
MenuText
Microsoft
MotionBlur
Pixelate
RadialWipe
RandomBars
RandomDissolve
RevealTrans
Scrollbar
Shadow
Slide
Spiral
Stretch
Strips
ThreeDDarkShadow
ThreeDFace
ThreeDHighlight
ThreeDLightShadow
ThreeDShadow
Wave
Wheel
Window
WindowFrame
WindowText
Xray
Zigzag
_azimuth
_background
_background-position-x
_background-position-y
_border
_bottom
_caption
_clear
_clip
_color
_content
_counter
_cue
_cursor
_direction
_display
_elevation
_empty
_filter
_filter:progid:DXImageTransform.Microsoft
_float
_font
_height
_ime
_ime-mode
_layout
_layout-flow
_layout-grid
_layout-grid-char
_layout-grid-line
_layout-grid-mode
_layout-grid-type
_left
_letter
_line
_line-break
_list
_margin
_orphans
_outline
_overflow
_overflow-x
_overflow-y
_padding
_page
_pause
_pitch
_play
_position
_quotes
_richness
_right
_ruby
_ruby-align
_ruby-overhang
_ruby-position
_scrollbar
_scrollbar-3dlight-color
_scrollbar-arrow-color
_scrollbar-base-color
_scrollbar-darkshadow-color
_scrollbar-face-color
_scrollbar-highlight-color
_scrollbar-track-color
_speak
_speech
_stress
_table
_text
_text-align-last
_text-autospace
_text-justify
_text-kashida-space
_text-overflow
_text-underline-position
_top
_unicode
_vertical
_visibility
_voice
_volume
_white
_widows
_width
_word
_word-break
_word-wrap
_writing
_writing-mode
_z
_zoom
above
active
adjust
after
aliceblue
align
align-content
align-items
align-self
always
animation
animation-delay
animation-direction
animation-duration
animation-fill-mode
animation-iteration-count
animation-name
animation-play-state
animation-timing-function
antiquewhite
aqua
aquamarine
armenian
arrow
attachment
auto
autospace
avoid
azimuth
azure
backface-visibility
background
background-attachment
background-clip
background-color
background-image
background-origin
background-position
background-repeat
background-size
bar
base
baseline
before
behind
beige
below
bidi
bidi-override
bisque
black
blanchedalmond
blink
block
blue
blueviolet
bold
bolder
border
border-bottom
border-bottom-color
border-bottom-left-radius
border-bottom-right-radius
border-bottom-style
border-bottom-width
border-collapse
border-color
border-image
border-image-outset
border-image-repeat
border-image-slice
border-image-source
border-image-width
border-left
border-left-color
border-left-style
border-left-width
border-radius
border-right
border-right-color
border-right-style
border-right-width
border-spacing
border-style
border-top
border-top-color
border-top-left-radius
border-top-right-radius
border-top-style
border-top-width
border-width
both
bottom
box
box-decoration-break
box-shadow
box-sizing
break
break-after
break-before
break-inside
brown
burlwood
cadetblue
capitalize
caps
caption
caption-side
cell
cells
center
center-left
center-right
char
chartreuse
chocolate
circle
cjk
cjk-ideographic
clear
clip
close
close-quote
cm
code
collapse
color
column
column-count
column-fill
column-gap
column-rule
column-rule-color
column-rule-style
column-rule-width
column-span
column-width
columns
compact
condensed
content
continuous
coral
cornflowerblue
cornsilk
counter
counter-increment
counter-reset
crimson
crop
cross
crosshair
cue
cue-after
cue-before
cursive
cursor
cyan
darkblue
darkcyan
darkgoldenrod
darkgray
darkgreen
darkkhaki
darkmagenta
darkolivegreen
darkorange
darkorchid
darkred
darksalmon
darkseagreen
darkshadow
darkslateblue
darkslategray
darkturquoise
darkviolet
dashed
decimal
decimal-leading-zero
decoration
deeppink
deepskyblue
default
deg
digits
dimgray
direction
disc
display
dodgerblue
dotted
double
during
e
e-resize
elevation
em
embed
empty
empty-cells
ex
expanded
extra
extra-condensed
extra-expanded
face
family
fantasy
far
far-left
far-right
fast
faster
filter
firebrick
first
first-child
first-letter
first-line
fixed
flex
flex-basis
flex-direction
flex-flow
flex-grow
flex-shrink
flex-wrap
float
floralwhite
flow
focus
font
font-family
font-feature-setting
font-kerning
font-language-override
font-size
font-size-adjust
font-stretch
font-style
font-synthesis
font-variant
font-variant-alternates
font-variant-caps
font-variant-east-asian
font-variant-ligatures
font-variant-numeric
font-variant-position
font-weight
footer
forestgreen
fuchsia
gainsboro
georgian
ghostwhite
gold
goldenrod
gray
greek
green
greenyellow
grid
groove
group
hanging-punctuation
header
hebrew
height
help
hidden
hide
high
higher
hiragana
hiragana-iroha
honeydew
hotpink
hover
hyphens
icon
ideographic
image
image-orientation
image-rendering
image-resolution
ime-mode
in
increment
indent
index
indianred
indigo
inherit
inline
inline-block
inline-table
inset
inside
iroha
italic
item
ivory
justify
justify-content
kHz
kashida
katakana
katakana-iroha
khaki
landscape
lang()
large
larger
last
latin
lavender
lavenderblush
lawngreen
layout
leading
left
left-side
leftwards
lenonchiffon
letter
letter-spacing
level
lightblue
lightcoral
lightcyan
lighter
lightgoldenrodyellow
lightgray
lightgreen
lightgrey
lightpink
lightsalmon
lightseagreen
lightskyblue
lightslategray
lightsteelblue
lightyellow
lime
limegreen
line
line-break
line-height
line-through
linen
link
list
list-item
list-style
list-style-image
list-style-position
list-style-type
loud
low
lower
lower-alpha
lower-greek
lower-latin
lower-roman
lowercase
ltr
magenta
margin
margin-bottom
margin-left
margin-right
margin-top
mark
mark-after
mark-before
marker
marker-offset
marks
maroon
marquee-direction
marquee-play-count
marquee-speed
marquee-style
mask
mask-type
max
max-height
max-width
medium
mediumaquamarine
mediumblue
mediumorchid
mediumpurple
mediumseagreen
mediumslateblue
mediumspringgreen
mediumturquoise
mediumvioletred
menu
message
message-box
middle
midnightblue
min
min-height
min-width
mintcream
mistyrose
mix
mm
moccasin
mode
monospace
move
ms
n
n-resize
naby
narrower
nav-down
nav-index
nav-left
nav-right
nav-up
navajowhite
ne
ne-resize
no
no-close-quote
no-open-quote
no-repeat
none
normal
nowrap
number
numeral
nw
nw-resize
object-fit
object-position
oblique
offset
oldlace
olive
olivedrab
once
opacity
open
open-quote
orange
orangered
orchid
order
orphans
out
outline
outline-color
outline-offset
outline-style
outline-width
outset
outside
overflow
overflow-wrap
overflow-x
overflow-y
overhang
overline
override
padding
padding-bottom
padding-left
padding-right
padding-top
page
page-break-after
page-break-before
page-break-inside
palegoldenrod
palegreen
paleturquoise
palevioletred
papayawhip
pause
pause-after
pause-before
pc
peachpuff
perspective
perspective-origin
peru
phonemes
pink
pitch
pitch-range
play
play-during
plum
pointer
portrait
position
powderblue
pre
pre-line
pre-wrap
progid
progress
pt
punctuation
purple
px
quote
quotes
rad
range
rate
red
relative
repeat
repeat-x
repeat-y
reset
resize
rest
rest-after
rest-before
richness
ridge
right
right-side
rightwards
roman
rosybrown
row
royalblue
rtl
run
run-in
s
s-resize
saddlebrown
salmon
sandybrown
sans-serif
scroll
se
se-resize
seagreen
seashell
semi
semi-condensed
semi-expanded
separate
serif
shadow
show
side
sienna
silent
silever
silver
size
skyblue
slateblue
slategray
slow
slower
small
small-caps
small-caption
smaller
snow
soft
solid
space
spacing
speak
speak-header
speak-numeral
speak-punctuation
specific
specific-voice
speech
speech-rate
spell
spell-out
springgreen
square
static
status
status-bar
steelblue
stress
stretch
style
sub
super
sw
sw-resize
tab-size
table
table-caption
table-cell
table-column
table-column-group
table-footer-group
table-header-group
table-layout
table-row
table-row-group
tan
teal
text
text-align
text-align-last
text-bottom
text-combine-horizontal
text-decoration
text-decoration-color
text-decoration-line
text-decoration-style
text-indent
text-justify
text-orientation
text-overflow
text-shadow
text-top
text-transform
text-underline-position
thick
thin
thistle
through
tomato
top
track
transform
transform-origin
transform-style
transition
transition-delay
transition-duration
transition-property
transition-timing-function
transparent
turquoise
type
ultra
ultra-condensed
ultra-expanded
underline
unicode
unicode-bidi
upper
upper-alpha
upper-latin
upper-roman
uppercase
variant
vertical
vertical-align
violet
visibility
visible
visited
voice
voice-balance
voice-duration
voice-family
voice-pitch
voice-pitch-range
voice-rate
voice-stress
voice-volume
volume
w
w-resize
wait
weight
wheat
white
white-space
whitesmoke
wider
widows
width
word
word-break
word-spacing
word-wrap
wrap
writing-mode
x
x-fast
x-high
x-large
x-loud
x-low
x-slow
x-small
x-soft
xx
xx-large
xx-small
y
yellow
yellowgreen
z
z-index
zero

View File

@@ -0,0 +1,216 @@
after
begin
catch
case
cond
end
fun
if
let
of
query
receive
try
when
and
andalso
band
bnot
bor
bsl
bsr
bxor
div
not
or
orelse
rem
xor
is_atom
is_binary
is_bitstring
is_boolean
is_float
is_function
is_integer
is_list
is_number
is_pid
is_port
is_record
is_reference
is_tuple
atom
binary
bitstring
boolean
function
integer
list
number
pid
port
record
reference
tuple
abs
adler32
adler32_combine
alive
apply
atom_to_binary
atom_to_list
binary_to_atom
binary_to_existing_atom
binary_to_list
binary_to_term
bit_size
bitstring_to_list
byte_size
check_process_code
contact_binary
crc32
crc32_combine
date
decode_packet
delete_module
disconnect_node
element
erase
exit
float
float_to_list
garbage_collect
get
get_keys
group_leader
halt
hd
integer_to_list
internal_bif
iolist_size
iolist_to_binary
is_alive
is_atom
is_binary
is_bitstring
is_boolean
is_float
is_function
is_integer
is_list
is_number
is_pid
is_port
is_process_alive
is_record
is_reference
is_tuple
length
link
list_to_atom
list_to_binary
list_to_bitstring
list_to_existing_atom
list_to_float
list_to_integer
list_to_pid
list_to_tuple
load_module
make_ref
module_loaded
monitor_node
node
node_link
node_unlink
nodes
notalive
now
open_port
pid_to_list
port_close
port_command
port_connect
port_control
pre_loaded
process_flag
process_info
processes
purge_module
put
register
registered
round
self
setelement
size
spawn
spawn_link
spawn_monitor
spawn_opt
split_binary
statistics
term_to_binary
time
throw
tl
trunc
tuple_size
tuple_to_list
unlink
unregister
whereis
append_element
bump_reductions
cancel_timer
demonitor
display
fun_info
fun_to_list
function_exported
get_cookie
get_stacktrace
hash
integer_to_list
is_builtin
list_to_integer
loaded
localtime
localtime_to_universaltime
make_tuple
max
md5
md5_final
md5_init
md5_update
memory
min
monitor
monitor_node
phash
phash2
port_call
port_info
port_to_list
ports
process_display
read_timer
ref_to_list
resume_process
send
send_after
send_nosuspend
set_cookie
start_timer
suspend_process
system_flag
system_info
system_monitor
system_profile
trace
trace_delivered
trace_info
trace_pattern
universaltime
universaltime_to_localtime
yield

View File

@@ -0,0 +1,37 @@
abstract
break
case
catch
const
continue
do
else
elseif
end
eval
export
false
finally
for
function
global
if
ifelse
immutable
import
importall
in
let
macro
module
otherwise
quote
return
switch
throw
true
try
type
typealias
using
while

View File

@@ -0,0 +1,25 @@
break
case
chan
const
continue
default
defer
else
fallthrough
for
func
go
goto
if
import
interface
map
package
range
return
select
struct
switch
type
var

View File

@@ -0,0 +1,679 @@
Arrows
BangPatterns
Bool
Bounded
CPP
Char
Complex
ConstrainedClassMethods
Control.Applicative
Control.Arrow
Control.Category
Control.Concurrent
Control.Concurrent.MVar
Control.Concurrent.QSem
Control.Concurrent.QSemN
Control.Concurrent.STM
Control.Concurrent.STM.TArray
Control.Concurrent.STM.TChan
Control.Concurrent.STM.TMVar
Control.Concurrent.STM.TVar
Control.Concurrent.SampleVar
Control.Exception
Control.Exception.Base
Control.Monad
Control.Monad.Cont
Control.Monad.Cont.Class
Control.Monad.Error
Control.Monad.Error.Class
Control.Monad.Fix
Control.Monad.Identity
Control.Monad.Instances
Control.Monad.List
Control.Monad.RWS
Control.Monad.RWS.Class
Control.Monad.RWS.Lazy
Control.Monad.RWS.Strict
Control.Monad.Reader
Control.Monad.Reader.Class
Control.Monad.ST
Control.Monad.ST.Lazy
Control.Monad.ST.Strict
Control.Monad.STM
Control.Monad.State
Control.Monad.State.Class
Control.Monad.State.Lazy
Control.Monad.State.Strict
Control.Monad.Trans
Control.Monad.Writer
Control.Monad.Writer.Class
Control.Monad.Writer.Lazy
Control.Monad.Writer.Strict
Control.OldException
Control.Parallel
Control.Parallel.Strategies
DEPRECATED
Data.Array
Data.Array.Diff
Data.Array.IArray
Data.Array.IO
Data.Array.IO.Internals
Data.Array.MArray
Data.Array.Paralell
Data.Array.Paralell.Arr
Data.Array.Paralell.Base
Data.Array.Paralell.Int
Data.Array.Paralell.Lifted
Data.Array.Paralell.PArray
Data.Array.Paralell.Prelude
Data.Array.Paralell.Prelude.Double
Data.Array.Paralell.Stream
Data.Array.Paralell.Unlifted
Data.Array.Paralell.Unlifted.Distributed
Data.Array.Paralell.Unlifted.Paralell
Data.Array.Paralell.Unlifted.Sqeuential
Data.Array.Paralell.Word8
Data.Array.ST
Data.Array.Storable
Data.Array.Unboxed
Data.Bits
Data.Bool
Data.ByteString
Data.ByteString.Char8
Data.ByteString.Fusion
Data.ByteString.Internal
Data.ByteString.Lazy
Data.ByteString.Lazy.Char8
Data.ByteString.Lazy.Fusion
Data.ByteString.Lazy.Internal
Data.ByteString.Unsafe
Data.Char
Data.Complex
Data.Data
Data.Dynamic
Data.Either
Data.Eq
Data.Fixed
Data.Foldable
Data.Function
Data.Generics
Data.Generics.Aliases
Data.Generics.Basics
Data.Generics.Instances
Data.Generics.Schemes
Data.Generics.Text
Data.Generics.Twins
Data.Graph
Data.HashTable
Data.IORef
Data.Int
Data.IntMap
Data.IntSet
Data.Ix
Data.List
Data.Map
Data.Maybe
Data.Monoid
Data.Ord
Data.Ratio
Data.STRef
Data.STRef.Lazy
Data.STRef.Strict
Data.Sequence
Data.Set
Data.String
Data.Time
Data.Time.Calendar
Data.Time.Calendar.Easter
Data.Time.Calendar.Julian
Data.Time.Calendar.MonthDay
Data.Time.Calendar.OrdinalDate
Data.Time.Calendar.WeekDate
Data.Time.Clock
Data.Time.Clock.POSIX
Data.Time.Clock.TAI
Data.Time.Format
Data.Time.LocalTime
Data.Traversable
Data.Tree
Data.Tuple
Data.Typeable
Data.Unique
Data.Version
Data.Word
Debug.Trace
DeriveDataTypeable
DisambiguateRecordFields
Distribution.Compat.ReadP
Distribution.Compiler
Distribution.InstalledPackageInfo
Distribution.License
Distribution.Make
Distribution.ModuleName
Distribution.Package
Distribution.PackageDescription
Distribution.PackageDescription.Check
Distribution.PackageDescription.Configuration
Distribution.PackageDescription.Parse
Distribution.ParseUtils
Distribution.ReadE
Distribution.Simple
Distribution.Simple.Build
Distribution.Simple.Build.Macros
Distribution.Simple.Build.PathsModule
Distribution.Simple.BuildPaths
Distribution.Simple.Command
Distribution.Simple.Compiler
Distribution.Simple.Configure
Distribution.Simple.GHC
Distribution.Simple.Haddock
Distribution.Simple.Hugs
Distribution.Simple.Install
Distribution.Simple.InstallDirs
Distribution.Simple.JHC
Distribution.Simple.LocalBuildInfo
Distribution.Simple.NHC
Distribution.Simple.PackageIndex
Distribution.Simple.PreProcess
Distribution.Simple.PreProcess.Unlit
Distribution.Simple.Program
Distribution.Simple.Register
Distribution.Simple.Setup
Distribution.Simple.SrcDist
Distribution.Simple.UserHooks
Distribution.Simple.Utils
Distribution.System
Distribution.Text
Distribution.Verbosity
Distribution.Version
Double
EQ
Either
EmptyDataDecls
Enum
Eq
ExistentialQuantification
ExtendedDefaultRules
False
FilePath
FlexibleContexts
FlexibleInstances
Float
Floating
Foreign
Foreign.C
Foreign.C.Error
Foreign.C.String
Foreign.C.Types
Foreign.Concurrent
Foreign.ForeignPtr
Foreign.Marshal
Foreign.Marshal.Alloc
Foreign.Marshal.Array
Foreign.Marshal.Error
Foreign.Marshal.Pool
Foreign.Marshal.Utils
Foreign.Ptr
Foreign.StablePtr
Foreign.Storable
ForeignFunctionInterface
Fractional
FunctionnalDependencies
Functor
GADTs
GHC.Arr
GHC.Bool
GHC.Conc
GHC.ConsoleHandler
GHC.Desugar
GHC.Environment
GHC.Err
GHC.Exts
GHC.Generics
GHC.Handle
GHC.Ordering
GHC.PArr
GHC.Prim
GHC.PrimopWrappers
GHC.Tuple
GHC.Types
GHC.Unicode
GHC.Unit
GT
GeneralizedNewtypeDeriving
Generics
INCLUDE
INLINE
IO
IOError
IOException
ImplicitParams
ImplicitPrelude
ImpredicativeTypes
IncoherentInstances
Int
Integer
Integral
Just
KindSignatures
LANGUAGE
LINE
LT
Language.Haskell.Extension
Language.Haskell.Lexer
Language.Haskell.ParseMonad
Language.Haskell.ParseUtils
Language.Haskell.Parser
Language.Haskell.Pretty
Language.Haskell.Syntax
Language.Haskell.TH
Language.Haskell.TH.Lib
Language.Haskell.TH.Ppr
Language.Haskell.TH.PprLib
Language.Haskell.TH.Quote
Language.Haskell.TH.Syntax
Left
LiberalTypeSynonyms
MagicHash
Maybe
Monad
MonoPatBinds
MonomorphismRestriction
MultiParamTypeClasses
NOINLINE
NamedFieldPuns
Network
Network.BSD
Network.Socket
Network.URI
NewQualifiedOperators
NoArrows
NoBangPatterns
NoCPP
NoConstrainedClassMethods
NoDeriveDataTypeable
NoDisambiguateRecordFields
NoEmptyDataDecls
NoExistentialQuantification
NoExtendedDefaultRules
NoFlexibleContexts
NoFlexibleInstances
NoForeignFunctionInterface
NoFunctionnalDependencies
NoGADTs
NoGeneralizedNewtypeDeriving
NoGenerics
NoImplicitParams
NoImplicitPrelude
NoImpredicativeTypes
NoIncoherentInstances
NoKindSignatures
NoLiberalTypeSynonyms
NoMagicHash
NoMonoPatBinds
NoMonomorphismRestriction
NoMultiParamTypeClasses
NoNamedFieldPuns
NoNewQualifiedOperators
NoOverlappingInstances
NoOverloadedStrings
NoPArr
NoPackageImports
NoParallelListComp
NoPatternGuards
NoPolymorphicComponents
NoQuasiQuotes
NoRank2Types
NoRankNTypes
NoRecordWildCards
NoRecursiveDo
NoRelaxedPolyRec
NoScopedTypeVariables
NoStandaloneDeriving
NoTemplateHaskell
NoTransformListComp
NoTypeFamilies
NoTypeOperators
NoTypeSynonymInstances
NoUnboxedTuples
NoUndecidableInstances
NoUnicodeSyntax
NoUnliftedFFITypes
NoViewPatterns
Nothing
Num
Numeric
OPTIONS_GHC
Ord
Ordering
OverlappingInstances
OverloadedStrings
PArr
PackageImports
ParallelListComp
PatternGuards
PolymorphicComponents
Prelude
QuasiQuotes
RULES
Rank2Types
RankNTypes
Ratio
Read
ReadS
Real
RealFloat
RealFrac
RecordWildCards
RecursiveDo
RelaxedPolyRec
Right
SOURCE
SPECIALIZE
ScopedTypeVariables
ShowS
StandaloneDeriving
String
System.CPUTime
System.Cmd
System.Console.Editline
System.Console.GetOpt
System.Console.Readline
System.Directory
System.Environment
System.Exit
System.FilePath
System.FilePath.Posix
System.FilePath.Windows
System.IO
System.IO.Error
System.IO.Unsafe
System.Info
System.Locale
System.Mem
System.Mem.StableName
System.Mem.Weak
System.Posix
System.Posix.Directory
System.Posix.DynamicLinker
System.Posix.DynamicLinker.Module
System.Posix.DynamicLinker.Prim
System.Posix.Env
System.Posix.Error
System.Posix.Files
System.Posix.IO
System.Posix.Process
System.Posix.Process.Internals
System.Posix.Resource
System.Posix.Semaphore
System.Posix.SharedMem
System.Posix.Signals
System.Posix.Signals.Exts
System.Posix.Temp
System.Posix.Terminal
System.Posix.Time
System.Posix.Types
System.Posix.Unistd
System.Posix.User
System.Process
System.Random
System.Time
System.Timeout
TemplateHaskell
Test.HUnit
Test.HUnit.Base
Test.HUnit.Lang
Test.HUnit.Terminal
Test.HUnit.Text
Test.QuickCheck
Test.QuickCheck.Batch
Test.QuickCheck.Poly
Test.QuickCheck.Utils
Text.Html
Text.Html.BlockTable
Text.ParserCombinators.Parsec
Text.ParserCombinators.Parsec.Char
Text.ParserCombinators.Parsec.Combinator
Text.ParserCombinators.Parsec.Error
Text.ParserCombinators.Parsec.Expr
Text.ParserCombinators.Parsec.Language
Text.ParserCombinators.Parsec.Perm
Text.ParserCombinators.Parsec.Pos
Text.ParserCombinators.Parsec.Prim
Text.ParserCombinators.Parsec.Token
Text.ParserCombinators.ReadP
Text.ParserCombinators.ReadPrec
Text.PrettyPrint
Text.PrettyPrint.HughesPJ
Text.Printf
Text.Read
Text.Read.Lex
Text.Regex.Base
Text.Regex.Base.Context
Text.Regex.Base.Impl
Text.Regex.Base.RegexLike
Text.Regex.Posix
Text.Regex.Posix.ByteString
Text.Regex.Posix.String
Text.Regex.Posix.Wrap
Text.Show
Text.Show.Functions
Text.XHtml
Text.XHtml.Debug
Text.XHtml.Frameset
Text.XHtml.Strict
Text.XHtml.Table
Text.XHtml.Transitional
Trace.Hpc.Mix
Trace.Hpc.Reflect
Trace.Hpc.Tix
Trace.Hpc.Util
TransformListComp
True
TypeFamilies
TypeOperators
TypeSynonymInstances
UNPACK
UnboxedTuples
UndecidableInstances
UnicodeSyntax
UnliftedFFITypes
Unsafe.Coerce
ViewPatterns
WARNING
abs
acos
acosh
all
and
any
appendFile
as
asTypeOf
asin
asinh
atan
atan2
atanh
break
case
catch
ceiling
class
compare
concat
concatMap
const
cos
cosh
curry
cycle
data
decodeFloat
default
deriving
div
divMod
do
drop
dropWhile
either
elem
else
encodeFloat
enumFrom
enumFromThen
enumFromThenTo
enumFromTo
error
exp
exponent
fail
filter
flip
floatDigits
floatRadix
floatRange
floor
fmap
fold
fold1
foldr
foldr1
fromEnum
fromInteger
fromIntegral
fromRational
fst
gcd
getChar
getContents
getLine
head
hiding
id
if
import
in
infix
infixl
infixr
init
instance
intract
ioError
isDenormalized
isIEEE
isInfinite
isNan
isNegativeZero
iterate
last
lcm
length
let
lex
lines
log
logBase
lookup
map
mapM
mapM_
max
maxBound
maximum
maybe
min
minBound
minimum
mod
module
negate
newtype
not
notElem
null
odd
of
or
otherwise
pi
pred
print
product
properFraction
putChar
putStr
putStrLn
qualified
quot
quotRem
read
readFile
readIO
readList
readLn
readParen
reads
readsPrec
realtoFrac
recip
rem
repeat
replicate
return
reverse
round
scaleFloat
scanl
scanl1
scanr
scanr1
seq
sequence
sequence_
show
showChar
showList
showParen
showString
shows
showsPrec
significand
signum
sin
sinh
snd
span
splitAt
sqrt
subtract
succ
sum
tail
take
takeWhile
tan
tanh
then
toEnum
toInteger
toRational
truncate
type
uncurry
undefined
unlines
until
unwords
unzip
unzip3
userError
where
words
writeFile
zip
zip3
zipWith
zipWith3

View File

@@ -0,0 +1,53 @@
abstract
assert
boolean
break
byte
case
catch
char
class
const
continue
default
do
double
else
enum
extends
final
finally
float
for
goto
if
implements
import
instanceof
int
interface
long
native
new
package
private
protected
public
return
short
static
strictfp
super
switch
synchronized
this
throw
throws
transient
try
void
volatile
while
@Override
@Deprecated
@SuppressWarnings

View File

@@ -0,0 +1,148 @@
Anchor
Area
Array
Boolean
Button
Checkbox
Date
Document
Element
FileUpload
Form
Frame
Function
Hidden
History
Image
Infinity
JavaArray
JavaClass
JavaObject
JavaPackage
Link
Location
Math
MimeType
NaN
Navigator
Number
Object
Option
Packages
Password
Plugin
Radio
RegExp
Reset
Select
String
Submit
Text
Textarea
Window
alert
arguments
assign
blur
break
callee
caller
captureEvents
case
clearInterval
clearTimeout
close
closed
comment
confirm
constructor
continue
default
defaultStatus
delete
do
document
else
escape
eval
export
find
focus
for
frames
function
getClass
history
home
if
import
in
innerHeight
innerWidth
isFinite
isNan
java
label
length
location
locationbar
menubar
moveBy
moveTo
name
navigate
navigator
netscape
new
onBlur
onError
onFocus
onLoad
onUnload
open
opener
outerHeight
outerWidth
pageXoffset
pageYoffset
parent
parseFloat
parseInt
personalbar
print
prompt
prototype
ref
releaseEvents
resizeBy
resizeTo
return
routeEvent
scroll
scrollBy
scrollTo
scrollbars
self
setInterval
setTimeout
status
statusbar
stop
sun
switch
taint
this
toString
toolbar
top
typeof
unescape
untaint
unwatch
valueOf
var
void
watch
while
window
with

View File

@@ -0,0 +1,37 @@
abstract
break
case
catch
const
continue
do
else
elseif
end
eval
export
false
finally
for
function
global
if
ifelse
immutable
import
importall
in
let
macro
module
otherwise
quote
return
switch
throw
true
try
type
typealias
using
while

View File

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

View File

@@ -0,0 +1,70 @@
addr
and
as
asm
atomic
bind
block
break
case
cast
concept
const
continue
converter
defer
discard
distinct
div
do
elif
else
end
enum
except
export
finally
for
from
func
generic
if
import
in
include
interface
is
isnot
iterator
let
macro
method
mixin
mod
nil
not
notin
object
of
or
out
proc
ptr
raise
ref
return
shl
shr
static
template
try
tuple
type
using
var
when
while
with
without
xor
yield

View File

@@ -0,0 +1,161 @@
auto
break
case
char
const
continue
default
do
double
else
enum
extern
float
for
goto
if
inline
int
long
register
restrict
return
short
signed
sizeof
static
struct
switch
typedef
union
unsigned
void
volatile
while
_Alignas
_Alignof
_Atomic
_Bool
_Complex
_Generic
_Imaginary
_Noreturn
_Static_assert
_Thread_local
alignas
alignof
atomic_
bool
complex
imaginary
noreturn
static_assert
thread_local
#if
#elif
#else
#endif
defined
#ifdef
#ifndef
#define
#undef
#include
#line
#error
#pragma
_Pragma
asm
fortran
#import
self
_cmd
instancetype
__bridge
__bridge_transfer
__bridge_retained
__bridge_retain
@not_keyword
@class
@compatibility_alias
@defs
@encode
@end
@implementation
@interface
@private
@protected
@protocol
@public
@selector
@throw
@try
@catch
@finally
@synchronized
@autoreleasepool
@property
@package
@required
@optional
@synthesize
@dynamic
@import
@available
__attribute__((visibility("default")))
__attribute__((visibility("hidden")))
__attribute__((deprecated))
__attribute__((unavailable))
__attribute__((objc_exception))
__attribute__((objc_root_class))
__covariant
__contravariant
__kindof
getter=
setter=
readonly
readwrite
assign
retain
copy
nonatomic
atomic
strong
weak
unsafe_unretained
nonnull
nullable
null_unspecified
null_resettable
class
__attribute__((deprecated))
in
out
inout
oneway
bycopy
byref
nonnull
nullable
null_unspecified
__attribute__((unused))
super
true
false
__objc_yes
__objc_no
Class
id
SEL
IMP
BOOL
STR
NSInteger
NSUInteger
YES
NO
Nil
nil
__strong
__unsafe_unretained
__autoreleasing

View File

@@ -0,0 +1,46 @@
# GNU Octave, and probably proprietary MATLAB
# https://www.gnu.org/software/octave/doc/interpreter/Keywords.html
__FILE__
__LINE__
break
case
catch
classdef
continue
do
else
elseif
end
end_try_catch
end_unwind_protect
endclassdef
endenumeration
endevents
endfor
endfunction
endif
endmethods
endparfor
endproperties
endswitch
endwhile
enumeration
events
for
function
global
if
methods
otherwise
parfor
persistent
properties
return
static
switch
try
unitl
unwind_protect
unwind_protect_cleanup
while

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,379 @@
ArithmeticError
AssertionError
AttributeError
BaseException
BufferError
BytesWarning
DeprecationWarning
EOFError
Ellipsis
EnvironmentError
Exception
False
FloatingPointError
FutureWarning
GeneratorExit
IOError
ImportError
ImportWarning
IndentationError
IndexError
KeyError
KeyboardInterrupt
LookupError
MemoryError
NameError
None
NotImplemented
NotImplementedError
OSError
OverflowError
PendingDeprecationWarning
ReferenceError
RuntimeError
RuntimeWarning
StandardError
StopIteration
SyntaxError
SyntaxWarning
SystemError
SystemExit
TabError
True
TypeError
UnboundLocalError
UnicodeDecodeError
UnicodeEncodeError
UnicodeError
UnicodeTranslateError
UnicodeWarning
UserWarning
ValueError
Warning
ZeroDivisionError
__builtins__
__debug__
__doc__
__file__
__future__
__import__
__init__
__main__
__name__
__package__
_dummy_thread
_thread
abc
abs
aifc
all
and
any
apply
argparse
array
as
assert
ast
asynchat
asyncio
asyncore
atexit
audioop
base64
basestring
bdb
bin
binascii
binhex
bisect
bool
break
buffer
builtins
bytearray
bytes
bz2
calendar
callable
cgi
cgitb
chr
chuck
class
classmethod
cmath
cmd
cmp
code
codecs
codeop
coerce
collections
colorsys
compile
compileall
complex
concurrent
configparser
contextlib
continue
copy
copyreg
copyright
credits
crypt
csv
ctypes
curses
datetime
dbm
decimal
def
del
delattr
dict
difflib
dir
dis
distutils
divmod
doctest
dummy_threading
elif
else
email
enumerate
ensurepip
enum
errno
eval
except
exec
execfile
exit
faulthandler
fcntl
file
filecmp
fileinput
filter
finally
float
fnmatch
for
format
formatter
fpectl
fractions
from
frozenset
ftplib
functools
gc
getattr
getopt
getpass
gettext
glob
global
globals
grp
gzip
hasattr
hash
hashlib
heapq
help
hex
hmac
html
http
id
if
imghdr
imp
impalib
import
importlib
in
input
inspect
int
intern
io
ipaddress
is
isinstance
issubclass
iter
itertools
json
keyword
lambda
len
license
linecache
list
locale
locals
logging
long
lzma
macpath
mailbox
mailcap
map
marshal
math
max
memoryview
mimetypes
min
mmap
modulefinder
msilib
msvcrt
multiprocessing
netrc
next
nis
nntplib
not
numbers
object
oct
open
operator
optparse
or
ord
os
ossaudiodev
parser
pass
pathlib
pdb
pickle
pickletools
pipes
pkgutil
platform
plistlib
poplib
posix
pow
pprint
print
profile
property
pty
pwd
py_compiler
pyclbr
pydoc
queue
quit
quopri
raise
random
range
raw_input
re
readline
reduce
reload
repr
reprlib
resource
return
reversed
rlcompleter
round
runpy
sched
select
selectors
self
set
setattr
shelve
shlex
shutil
signal
site
slice
smtpd
smtplib
sndhdr
socket
socketserver
sorted
spwd
sqlite3
ssl
stat
staticmethod
statistics
str
string
stringprep
struct
subprocess
sum
sunau
super
symbol
symtable
sys
sysconfig
syslog
tabnanny
tarfile
telnetlib
tempfile
termios
test
textwrap
threading
time
timeit
tkinter
token
tokenize
trace
traceback
tracemalloc
try
tty
tuple
turtle
type
types
unichr
unicode
unicodedata
unittest
urllib
uu
uuid
vars
venv
warnings
wave
weakref
webbrowser
while
winsound
winreg
with
wsgiref
xdrlib
xml
xmlrpc
xrange
yield
zip
zipfile
zipimport
zlib

View File

@@ -0,0 +1,183 @@
AlignBottom
AlignCenter
AlignHCenter
AlignLeft
AlignRight
AlignTop
AlignVCenter
AnchorAnimation
AnchorChanges
Audio
Behavior
Binding
BorderImage
ColorAnimation
Column
Component
Connections
Easing
Flickable
Flipable
Flow
FocusScope
GestureArea
Grid
GridView
Horizontal
Image
InBack
InBounce
InCirc
InCubic
InElastic
InExpo
InOutBack
InOutBounce
InOutCirc
InOutCubic
InOutElastic
InOutExpo
InOutQuad
InOutQuart
InOutQuint
InQuad
InQuart
InQuint
InQuint
InSine
Item
LayoutItem
LeftButton
Linear
ListElement
ListModel
ListView
Loader
MidButton
MiddleButton
MouseArea
NoButton
NumberAnimation
OutBack
OutBounce
OutCirc
OutCubic
OutElastic
OutExpo
OutInBack
OutInBounce
OutInCirc
OutInCubic
OutInElastic
OutInExpo
OutInQuad
OutInQuart
OutInQuint
OutQuad
OutQuart
OutQuint
OutSine
Package
ParallelAnimation
ParentAnimation
ParentChange
ParticleMotionGravity
ParticleMotionLinear
ParticleMotionWander
Particles
Path
PathAttribute
PathCubic
PathLine
PathPercent
PathQuad
PathView
PauseAnimation
PropertyAction
PropertyAnimation
PropertyChanges
Qt
QtObject
Rectangle
Repeater
RightButton
Rotation
RotationAnimation
Row
Scale
ScriptAction
SequentialAnimation
SmoothedAnimation
SoundEffect
SpringFollow
State
StateChangeScript
StateGroup
SystemPalette
Text
TextEdit
TextInput
Timer
Transition
Translate
Vertical
Video
ViewsPositionersMediaEffects
VisualDataModel
VisualItemModel
WebView
WorkerScript
XmlListModel
XmlRole
alias
as
bool
break
case
catch
color
const
continue
date
debugger
default
delete
do
double
else
enum
false
false
finally
for
function
if
import
import
in
instanceof
int
let
new
null
on
parent
property
real
return
signal
string
switch
this
throw
true
try
typeof
undefined
url
var
variant
void
while
with
yield

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,216 @@
case-lambda
call/cc
class
define-class
exit-handler
field
import
inherit
init-field
interface
let*-values
let-values
let/ec
mixin
opt-lambda
override
protect
provide
public
rename
require
require-for-syntax
syntax
syntax-case
syntax-error
unit/sig
unless
when
with-syntax
and
begin
call-with-current-continuation
call-with-input-file
call-with-output-file
case
cond
define
define-syntax
delay
do
dynamic-wind
else
for-each
if
lambda
let
let*
let-syntax
letrec
letrec-syntax
map
or
syntax-rules
abs
acos
angle
append
apply
asin
assoc
assq
assv
atan
boolean?
caar
cadr
call-with-input-file
call-with-output-file
call-with-values
car
cdddar
cddddr
cdr
ceiling
char->integer
char-alphabetic?
char-ci<=?
char-ci<?
char-ci=?
char-ci>=?
char-ci>?
char-downcase
char-lower-case?
char-numeric?
char-ready?
char-upcase
char-upper-case?
char-whitespace?
char<=?
char<?
char=?
char>=?
char>?
char?
close-input-port
close-output-port
complex?
cons
cos
current-input-port
current-output-port
denominator
display
eof-object?
eq?
equal?
eqv?
eval
even?
exact->inexact
exact?
exp
expt
#f
floor
force
gcd
imag-part
inexact->exact
inexact?
input-port?
integer->char
integer?
interaction-environment
lcm
length
list
list->string
list->vector
list-ref
list-tail
list?
load
log
magnitude
make-polar
make-rectangular
make-string
make-vector
max
member
memq
memv
min
modulo
negative?
newline
not
null-environment
null?
number->string
number?
numerator
odd?
open-input-file
open-output-file
output-port?
pair?
peek-char
port?
positive?
procedure?
quasiquote
quote
quotient
rational?
rationalize
read
read-char
real-part
real?
remainder
reverse
round
scheme-report-environment
set!
set-car!
set-cdr!
sin
sqrt
string
string->list
string->number
string->symbol
string-append
string-ci<=?
string-ci<?
string-ci=?
string-ci>=?
string-ci>?
string-copy
string-fill!
string-length
string-ref
string-set!
string<=?
string<?
string=?
string>=?
string>?
string?
substring
symbol->string
symbol?
#t
tan
transcript-off
transcript-on
truncate
values
vector
vector->list
vector-fill!
vector-length
vector-ref
vector-set!

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -0,0 +1,87 @@
associatedtype
class
deinit
enum
extension
func
import
init
inout
let
operator
precedencegroup
protocol
struct
subscript
typealias
var
fileprivate
internal
private
public
static
undef
sil
sil_stage
sil_vtable
sil_global
sil_witness_table
sil_default_witness_table
sil_coverage_map
sil_scope
defer
if
guard
do
repeat
else
for
in
while
return
break
continue
fallthrough
switch
case
default
where
catch
as
Any
false
is
nil
rethrows
super
self
Self
throw
true
try
throws
__FILE__
__LINE__
__COLUMN__
__FUNCTION__
__DSO_HANDLE__
_
#if
#else
#elseif
#endif
#keyPath
#line
#sourceLocation
#selector
#available
#fileLiteral
#imageLiteral
#colorLiteral
#FileReference
#Image
#Color
#file
#column
#function
#dsohandle

View File

@@ -0,0 +1,172 @@
after
append
apply
array
auto_execok
auto_import
auto_load
auto_load_index
auto_mkindex
auto_mkindex_old
auto_qualify
auto_reset
bell
binary
bind
bindtags
break
button
canvas
case
catch
cd
chan
checkbutton
clipboard
clock
close
concat
continue
destroy
dict
encoding
entry
eof
error
eval
event
exec
exit
expr
fblocked
fconfigure
fcopy
file
fileevent
flush
focus
font
for
foreach
format
frame
gets
glob
global
grab
grid
if
image
incr
info
interp
join
label
labelframe
lappend
lassign
lindex
linsert
list
listbox
llength
load
lower
lrange
lrepeat
lreplace
lreverse
lsearch
lset
lsort
menu
menubutton
message
namespace
open
option
pack
package
panedwindow
pid
pkg_mkIndex
place
proc
puts
pwd
radiobutton
raise
read
regexp
registry
regsub
rename
return
scale
scan
scrollbar
seek
selection
set
socket
source
spinbox
split
string
subst
switch
tclLog
tclPkgSetup
tclPkgUnknown
tcl_findLibrary
tell
text
time
tk
tk_chooseColor
tk_chooseDirectory
tk_getOpenFile
tk_getSaveFile
tk_menuSetFocus
tk_messageBox
tk_popup
tk_textCopy
tk_textCut
tk_textPaste
tkwait
toplevel
ttk::button
ttk::checkbutton
ttk::combobox
ttk::entry
ttk::focusFirst
ttk::frame
ttk::label
ttk::labelframe
ttk::menubutton
ttk::notebook
ttk::paned
ttk::panedwindow
ttk::progressbar
ttk::radiobutton
ttk::scale
ttk::scrollbar
ttk::separator
ttk::setTheme
ttk::sizegrip
ttk::style
ttk::takefocus
ttk::themes
ttk::treeview
trace
unknown
unload
unset
update
uplevel
upvar
variable
vwait
while
winfo
wm

View File

@@ -0,0 +1,797 @@
absRefPrefix
accessibility
accessibilityWrap
accessKey
ACT
ACTIFSUB
ACTIVSUBRO
ACTRO
addAttributes
addExtUrlsAndShortCuts
additionalHeaders
additionalParams
addParams
addQueryString
addQueryString
adjustItemsH
adjustSubItemsH
adminPanelStyles
after
age
align
align.field
all
allowedAttribs
allowedGroups
allowEdit
allowNew
allowTags
allStdWrap
allWrap
alternativeSortingField
alternativeTempPath
altImgResource
altTarget
altText
alwaysActivePIDlist
alwaysLink
andWhere
angle
antiAlias
append
applyTotalH
applyTotalW
arrayReturnMode
arrowACT
arrowImgParams
arrowNO
ATagBeforeWrap
ATagParams
ATagTitle
atLeast
atMost
authcodeFields
autoInsertPID
autostart
backColor
badMess
base64
baseURL
beforeImg
beforeImgLink
beforeImgTagParams
beforeROImg
beforeWrap
begin
begin
beginAtLevel
beLoginLinkIPList
beLoginLinkIPList_login
beLoginLinkIPList_logout
beUserLogin
bgImg
blankStrEqFalse
blur
bm
bodyTag
bodyTag
bodyTagAdd
bodyTagCObject
bodyTagMargins
border
border
borderCol
bordersWithin
borderThick
bottomContent
bottomHeight
br
breakSpace
breakWidth
brTag
bytes
c
cache_clearAtMidnight
cached
cache_period
caption
captionAlign
captionSplit
case
case
CASE
casesensitiveComp
cellpadding
cellspacing
char
charcoal
clearCacheOfPages
cMargins
COA
COA_INT
cObject
cObjNum
code
collapse
color
color1
color2
color3
color.default
color.field
colRelations
cols
cols
colSpace
COLUMNS
COMMENT
commentWrap
compensateFieldWidth
compX
compY
concatenateJsAndCss
conf
config
config
CONFIG
constants
CONTENT
content_fallback
content_from_pid_allowOutsideDomain
controllerActionName
controllerExtensionName
controllerName
crop
cropHTML
csConv
cssInline
CSS_inlineStyle
CTABLE
CUR
CURIFSUB
CURIFSUBRO
current
CURRO
cWidth
data
dataArray
dataWrap
date
debug
debugData
debugFunc
debugItemConf
debugRenumberedObject
decimals
dec_point
default
defaultAlign
defaultCmd
defaultCode
defaultGetVars
delete
denyTags
depth
dimensions
directImageLink
directionLeft
directionUp
directReturn
disableAllHeaderCode
disableAltText
disableCharsetHeader
disableImgBorderAttr
disablePageExternalUrl
disablePrefixComment
disablePreviewNotification
displayActiveOnLoad
displayActiveOnLoad
displayrecord
distributeX
distributeY
doctype
doctypeSwitch
doNotLinkIt
doNotShowLink
doNotStripHTML
dontCheckPid
dontFollowMouse
dontHideOnMouseUp
dontLinkIfSubmenu
dontMd5FieldNames
dontWrapInTable
doubleBrTag
doublePostCheck
dWorkArea
edge
edit
editIcons
editIcons
editPanel
EDITPANEL
EDITPANEL
effects
email
emailMess
emboss
emptyTitleHandling
emptyTitleHandling
emptyTitleHandling
enable
enableContentLengthHeader
encapsLines
encapsLinesStdWrap
encapsTagList
entryLevel
equalH
equals
evalErrors
evalFunc
excludeDoktypes
excludeNoSearchPages
excludeUidList
expAll
explode
ext
extbase
externalBlocks
extOnReady
extTarget
face.default
face.field
FEData
fe_userEditSelf
fe_userOwnSelf
field
fieldPrefix
fieldRequired
fieldWrap
file
FILE
filelink
fileList
fileTarget
firstLabel
firstLabelGeneral
flip
flop
foldSpeed
foldTimer
fontFile
fontSize
fontSizeMultiplicator
fontTag
footerData
forceAbsoluteUrl
forceTypeValue
FORM
format
formName
formurl
frame
frameReloadIfNotInFrameset
frameSet
freezeMouseover
ftu
gamma
gapBgCol
gapLineCol
gapLineThickness
gapWidth
gif
GIFBUILDER
globalNesting
GMENU
goodMess
gray
gr_list
groupBy
headerComment
headerData
headTag
height
hiddenFields
hide
hideButCreateMap
hideMenuTimer
hideMenuWhenNotOver
hideNonTranslated
highColor
HMENU
hover
hoverStyle
HRULER
HTML
html5
htmlmail
HTMLparser
htmlSpecialChars
htmlTag_dir
htmlTag_langKey
htmlTag_setParams
http
icon
iconCObject
icon_image_ext_list
icon_link
icon_thumbSize
if
ifBlank
ifEmpty
IFSUB
IFSUBRO
ignore
IMAGE
image_compression
image_effects
image_frames
imgList
imgMap
imgMapExtras
imgMax
imgNameNotRandom
imgNamePrefix
imgObjNum
imgParams
imgPath
imgStart
IMGTEXT
import
inBranch
includeCSS
includeJS
includeJSFooter
includeJSFooterlibs
includeJSlibs
includeLibrary
includeLibs
includeNotInMenu
incT3Lib_htmlmail
index_descrLgd
index_enable
index_externals
index_metatags
infomail
inlineJS
inlineLanguageLabel
inlineSettings
inlineStyle2TempFile
innerStdWrap_all
innerWrap
innerWrap2
inputLevels
insertClassesFromRTE
insertData
intensity
intTarget
intval
invert
IProcFunc
isFalse
isGreaterThan
isInList
isLessThan
isPositive
isTrue
itemArrayProcFunc
items
iterations
javascriptLibs
join
jpg
jsFooterInline
jsInline
JSMENU
JSwindow
JSwindow.altUrl
JSwindow.altUrl_noDefaultParams
JSwindow.expand
JSwindow.newWindow
JSwindow_params
jumpurl
jumpurl_enable
jumpurl_mailto_disable
keep
keepNonMatchedTags
keywords
keywordsField
labelStdWrap
labelWrap
lang
language
language_alt
languageField
layer_menu_id
layerStyle
layout
layoutRootPath
leftjoin
leftOffset
levels
limit
lineColor
lineThickness
linkAccessRestrictedPages
linkParams
linkVars
linkWrap
list
listNum
lm
LOAD_REGISTER
locale_all
localNesting
locationData
lockFilePath
lockPosition
lockPosition_addSelf
lockPosition_adjust
loginUser
longdescURL
loop
lowColor
lower
mailto
main
mainScript
makelinks
markers
markerWrap
mask
max
maxAge
maxH
maxHeight
maxItems
maxW
maxWidth
maxWInText
m.bgImg
m.bottomImg
m.bottomImg_mask
md5
meaningfulTempFilePrefix
menuBackColor
menuHeight
menuOffset
menuWidth
message_page_is_being_generated
message_preview
message_preview_workspace
meta
metaCharset
method
minH
minifyCSS
minifyJS
minItems
minItems
minW
m.mask
moveJsFromHeaderToFooter
MP_defaults
MP_disableTypolinkClosestMPvalue
MP_mapRootPoints
MULTIMEDIA
name
namespaces
negate
newRecordFromTable
newRecordInPid
next
niceText
NO
noAttrib
noBlur
no_cache
noCols
noLink
noLinkUnderline
nonCachedSubst
none
nonTypoTagStdWrap
nonTypoTagUserFunc
nonWrappedTag
noOrderBy
noPageTitle
noResultObj
normalWhenNoLanguage
noRows
noScale
noScaleUp
noscript
noStretchAndMarginCells
notification_email_charset
notification_email_encoding
notification_email_urlmode
noTrimWrap
noValueInsert
noWrapAttr
numberFormat
numRows
obj
offset
offset
_offset
offsetWrap
onlyCurrentPid
opacity
options
orderBy
OTABLE
outerWrap
outline
output
outputLevels
override
overrideAttribs
overrideEdit
overrideId
PAGE
pageGenScript
pageRendererTemplateFile
pageTitleFirst
parameter
params
parseFunc
parseFunc
parseValues
partialRootPath
path
pidInList
pixelSpaceFontSizeRef
plainTextStdWrap
pluginNames
png
postCObject
postUserFunc
postUserFunkInt
preCObject
prefixComment
prefixLocalAnchors
prefixLocalAnchors
prefixRelPathWith
preIfEmptyListNum
prepend
preUserFunc
prev
previewBorder
printBeforeContent
prioriCalc
processScript
properties
protect
protectLvar
quality
quality
radioInputWrap
radioWrap
range
range
rawUrlEncode
recipient
RECORDS
recursive
redirect
reduceColors
relativeToParentLayer
relativeToTriggerItem
relPathPrefix
remap
remapTag
removeBadHTML
removeDefaultJS
removeIfEquals
removeIfFalse
removeObjectsOfDummy
removePrependedNumbers
removeTags
removeWrapping
renderCharset
renderObj
renderWrap
REQ
required
required
resources
resultObj
returnKey
returnLast
reverseOrder
rightjoin
rm
rmTagIfNoAttrib
RO_chBgColor
rootline
rotate
rows
rowSpace
sample
sample
section
sectionIndex
select
sendCacheHeaders
sendCacheHeaders_onlyWhenLoginDeniedInBranch
separator
setContentToCurrent
setCurrent
setfixed
setFixedHeight
setFixedWidth
setJS_mouseOver
setJS_openPic
setKeywords
shadow
sharpen
shear
short
shortcutIcon
showAccessRestrictedPages
showActive
showFirst
simulateStaticDocuments
simulateStaticDocuments_addTitle
simulateStaticDocuments_dontRedirectPathInfoError
simulateStaticDocuments_noTypeIfNoTitle
simulateStaticDocuments_pEnc
simulateStaticDocuments_pEnc_onlyP
simulateStaticDocuments_replacementChar
sitetitle
size
size.default
size.field
slide
smallFormFields
solarize
source
space
spaceAfter
spaceBefore
spaceBelowAbove
spaceLeft
spaceRight
spacing
spamProtectEmailAddresses
spamProtectEmailAddresses_atSubst
spamProtectEmailAddresses_lastDotSubst
SPC
special
split
splitRendering
src
stat
stat_apache
stat_apache_logfile
stat_apache_niceTitle
stat_apache_noHost
stat_apache_noRoot
stat_apache_notExtended
stat_apache_pagenames
stat_excludeBEuserHits
stat_excludeIPList
stat_mysql
stat_pageLen
stat_titleLen
stat_typeNumList
stayFolded
stdWrap
stdWrap2
strftime
stripHtml
stripProfile
stylesheet
submenuObjSuffixes
subMenuOffset
subparts
subst_elementUid
subst_elementUid
substMarksSeparately
substring
swirl
sword
sword_noMixedCase
sword_standAlone
sys_language_mode
sys_language_overlay
sys_language_softExclude
sys_language_softMergeIfNotBlank
sys_language_uid
sys_page
table
tableParams
tables
tableStdWrap
tableStyle
tags
target
TCAselectItem
TDparams
template
TEMPLATE
templateFile
text
TEXT
textMargin
textMargin_outOfText
textMaxLength
textObjNum
textPos
textStyle
thickness
thousands_sep
title
titleTagFunction
titleText
titleText
tm
TMENU
token
topOffset
totalWidth
transparentBackground
transparentColor
trim
twice
typeNum
types
typolink
typolinkCheckRootline
typolinkEnableLinksAcrossDomains
typolinkLinkAccessRestrictedPages
typolinkLinkAccessRestrictedPages_addParams
uid
uidInList
uniqueGlobal
uniqueLinkVars
uniqueLocal
unset
unsetEmpty
upper
url
useCacheHash
useLargestItemX
useLargestItemY
USER
USERDEF1
USERDEF1RO
USERDEF2RO
USERFEF2
userFunc
userFunc_updateArray
userIdColumn
USER_INT
USERNAME_substToken
USERUID_substToken
USR
USRRO
value
variables
wave
where
width
wordSpacing
workArea
workOnSubpart
wrap
wrap2
wrap3
wrapAlign
wrapFieldName
wrapItemAndSub
wrapNoWrappedLines
wraps
xhtml_11
xhtml_2
xhtml_basic
xhtml_cleaning
xhtmlDoctype
xhtml_frames
xhtml+rdfa_10
xhtml_strict
xhtml_trans
xml_10
xml_11
xmlprologue
xPosOffset
yPosOffset

View File

@@ -0,0 +1,231 @@
# OCaml 3.12.1
# Keywords
and
as
assert
begin
class
constraint
do
done
downto
else
end
exception
external
false
for
fun
function
functor
if
in
include
inherit
initializer
lazy
let
match
method
module
mutable
new
object
of
open
or
private
rec
sig
struct
then
to
true
try
type
val
virtual
when
while
with
# Pervasives
!
!=
&
&&
*
**
*.
+
+.
-
-.
/
/.
:=
<
<=
<>
=
==
>
>=
@
FP_infinite
FP_nan
FP_normal
FP_subnormal
FP_zero
LargeFile
Open_append
Open_binary
Open_creat
Open_nonblock
Open_rdonly
Open_text
Open_trunc
Open_wronly
Oupen_excl
^
^^
abs
abs_float
acos
asin
asr
at_exit
atan
atan2
bool_of_string
ceil
char_of_int
classify_float
close_in
close_in_noerr
close_out
close_out_noerr
compare
cos
cosh
decr
do_at_exit
epsilon_float
exit
exp
expm1
failwith
float
float_of_int
float_of_string
floor
flush
flush_all
format
format4
format_of_string
fpclass
frexp
fst
ignore
in_channel
in_channel_length
incr
infinity
input
input_binary_int
input_byte
input_char
input_line
input_value
int_of_char
int_of_float
int_of_string
invalid_arg
land
ldexp
lnot
log
log10
log1p
lor
lsl
lsr
lxor
max
max_float
max_int
min
min_float
min_int
mod
mod_float
modf
nan
neg_infinity
not
open_flag
open_in
open_in_bin
open_in_gen
open_out
open_out_bin
open_out_gen
or
out_channel
out_channel_length
output
output_binary_int
output_byte
output_char
output_string
output_value
pos_in
pos_out
pred
prerr_char
prerr_endline
prerr_float
prerr_int
prerr_newline
prerr_string
print_char
print_endline
print_float
print_int
print_newline
print_string
raise
read_float
read_int
read_line
really_input
ref
seek_in
seek_out
set_binary_mode_in
set_binary_mode_out
sin
sinh
snd
sqrt
stderr
stdin
stdout
string_of_bool
string_of_float
string_of_format
string_of_int
succ
tan
tanh
truncate
unsafe_really_input
valid_float_lexem
||
~
~+
~+.
~-
~-.

View File

@@ -0,0 +1,313 @@
`define
`else
`endif
`ifdef
`ifndef
`macromodule
`module
`primitive
`timescale
above
abs
absdelay
ac_stim
acos
acosh
alias
aliasparam
always
always_comb
always_ff
always_latch
analog
analysis
and
asin
asinh
assert
assign
assume
atan
atan2
atanh
automatic
before
begin
bind
bins
binsof
bit
branch
break
buf
bufif0
bufif1
byte
case
casex
casez
cell
chandle
class
clocking
cmos
config
connectmodule
connectrules
const
constraint
context
continue
cos
cosh
cover
covergroup
coverpoint
cross
ddt
ddx
deassign
default
define
defparam
design
disable
discipline
dist
do
driver_update
edge
else
end
endcase
endclass
endclocking
endconfig
endconnectrules
enddiscipline
endfunction
endgenerate
endgroup
endif
endinterface
endmodule
endnature
endpackage
endparamset
endprimitive
endprogram
endproperty
endsequence
endspecify
endtable
endtask
enum
event
exclude
exp
expect
export
extends
extern
final
final_step
first_match
flicker_noise
floor
flow
for
force
foreach
forever
fork
forkjoin
from
function
generate
genvar
ground
highz0
highz1
hypot
idt
idtmod
if
ifdef
iff
ifndef
ifnone
ignore_bins
illegal_bins
import
incdir
include
inf
initial
initial_step
inout
input
inside
instance
int
integer
interface
intersect
join
join_any
join_none
laplace_nd
laplace_np
laplace_zd
laplace_zp
large
last_crossing
liblist
library
limexp
ln
local
localparam
log
logic
longint
macromodule
mailbox
matches
max
medium
min
modport
module
nand
nand
nature
negedge
net_resolution
new
nmos
nmos
noise_table
nor
noshowcancelled
not
notif0
notif1
null
or
output
package
packed
parameter
paramset
pmos
pmos
posedge
potential
pow
primitive
priority
program
property
protected
pull0
pull1
pullup
pulsestyle_ondetect
pulsestyle_onevent
pure
rand
randc
randcase
randcase
randsequence
rcmos
real
realtime
ref
reg
release
repeat
return
rnmos
rpmos
rtran
rtranif0
rtranif1
scalared
semaphore
sequence
shortint
shortreal
showcancelled
signed
sin
sinh
slew
small
solve
specify
specparam
sqrt
static
string
strong0
strong1
struct
super
supply
supply0
supply1
table
tagged
tan
tanh
task
then
this
throughout
time
timeprecision
timer
timescale
timeunit
tran
tran
tranif0
tranif1
transition
tri
tri
tri0
tri1
triand
trior
trireg
type
typedef
union
unique
unsigned
use
uwire
var
vectored
virtual
void
wait
wait_order
wand
weak0
weak1
while
white_noise
wildcard
wire
with
within
wor
wreal
xnor
xor
zi_nd
zi_np
zi_zd

View File

@@ -0,0 +1,211 @@
;;; cargo-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (directory-file-name
(or (file-name-directory #$) (car load-path))))
;;;### (autoloads nil "cargo" "cargo.el" (0 0 0 0))
;;; Generated autoloads from cargo.el
(autoload 'cargo-minor-mode "cargo" "\
Cargo minor mode. Used to hold keybindings for cargo-mode.
\\{cargo-minor-mode-map}
\(fn &optional ARG)" t nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cargo" '("cargo-minor-mode")))
;;;***
;;;### (autoloads nil "cargo-process" "cargo-process.el" (0 0 0 0))
;;; Generated autoloads from cargo-process.el
(autoload 'cargo-process-bench "cargo-process" "\
Run the Cargo bench command.
With the prefix argument, modify the command's invocation.
Cargo: Run the benchmarks.
\(fn)" t nil)
(autoload 'cargo-process-build "cargo-process" "\
Run the Cargo build command.
With the prefix argument, modify the command's invocation.
Cargo: Compile the current project.
\(fn)" t nil)
(autoload 'cargo-process-clean "cargo-process" "\
Run the Cargo clean command.
With the prefix argument, modify the command's invocation.
Cargo: Remove the target directory.
\(fn)" t nil)
(autoload 'cargo-process-doc "cargo-process" "\
Run the Cargo doc command.
With the prefix argument, modify the command's invocation.
Cargo: Build this project's and its dependencies' documentation.
\(fn)" t nil)
(autoload 'cargo-process-doc-open "cargo-process" "\
Run the Cargo doc command with the --open switch.
With the prefix argument, modify the command's invocation.
Cargo: Open this project's documentation.
\(fn)" t nil)
(autoload 'cargo-process-new "cargo-process" "\
Run the Cargo new command.
With the prefix argument, modify the command's invocation.
NAME is the name of your application.
If BIN is t then create a binary application, otherwise a library.
Cargo: Create a new cargo project.
\(fn NAME &optional BIN)" t nil)
(autoload 'cargo-process-init "cargo-process" "\
Run the Cargo init command.
With the prefix argument, modify the command's invocation.
DIRECTORY is the directory you want to create a cargo project in.
If BIN is t then create a binary application, otherwise a library.
Cargo: Create a new cargo project in current directory.
DIRECTORY is created if necessary.
\(fn DIRECTORY &optional BIN)" t nil)
(autoload 'cargo-process-run "cargo-process" "\
Run the Cargo run command.
With the prefix argument, modify the command's invocation.
Cargo: Build and execute src/main.rs.
\(fn)" t nil)
(autoload 'cargo-process-run-bin "cargo-process" "\
Run the Cargo run command --bin <name>.
With the prefix argument, modify the command's invocation.
Cargo: Build and execute a specific binary
\(fn COMMAND)" t nil)
(autoload 'cargo-process-run-example "cargo-process" "\
Run the Cargo run command --example <name>.
With the prefix argument, modify the command's invocation.
Cargo: Build and execute with --example <name>.
\(fn COMMAND)" t nil)
(autoload 'cargo-process-search "cargo-process" "\
Run the Cargo search command.
With the prefix argument, modify the command's invocation.
SEARCH-TERM is used as the search term for the Cargo registry.
Cargo: Search registry for crates.
\(fn SEARCH-TERM)" t nil)
(autoload 'cargo-process-test "cargo-process" "\
Run the Cargo test command.
With the prefix argument, modify the command's invocation.
Cargo: Run the tests.
\(fn)" t nil)
(autoload 'cargo-process-current-test "cargo-process" "\
Run the Cargo test command for the current test.
With the prefix argument, modify the command's invocation.
Cargo: Run the tests.
\(fn)" t nil)
(autoload 'cargo-process-current-file-tests "cargo-process" "\
Run the Cargo test command for the current file.
With the prefix argument, modify the command's invocation.
Cargo: Run the tests.
\(fn)" t nil)
(autoload 'cargo-process-update "cargo-process" "\
Run the Cargo update command.
With the prefix argument, modify the command's invocation.
Cargo: Update dependencies listed in Cargo.lock.
\(fn)" t nil)
(autoload 'cargo-process-fmt "cargo-process" "\
Run the Cargo fmt command.
With the prefix argument, modify the command's invocation.
Requires Cargo Fmt to be installed.
\(fn)" t nil)
(autoload 'cargo-process-outdated "cargo-process" "\
Run the Cargo outdated command.
With the prefix argument, modify the command's invocation.
Requires Cargo Outdated to be installed.
\(fn)" t nil)
(autoload 'cargo-process-check "cargo-process" "\
Run the Cargo check command.
With the prefix argument, modify the command's invocation.
Cargo: Check compile the current project.
Requires cargo-check to be installed.
\(fn)" t nil)
(autoload 'cargo-process-clippy "cargo-process" "\
Run the Cargo clippy command.
With the prefix argument, modify the command's invocation.
Cargo: Clippy compile the current project.
Requires Cargo clippy to be installed.
\(fn)" t nil)
(autoload 'cargo-process-add "cargo-process" "\
Run the Cargo add command.
With the prefix argument, modify the command's invocation.
CRATES is the name of the crate to add.
Cargo: This command allows you to add a dependency to a Cargo.toml manifest file.
\(fn CRATE)" t nil)
(autoload 'cargo-process-rm "cargo-process" "\
Run the Cargo rm command.
With the prefix argument, modify the command's invocation.
CRATE is the name of the crate to remove.
Cargo: Remove a dependency from a Cargo.toml manifest file.
\(fn CRATE)" t nil)
(autoload 'cargo-process-upgrade "cargo-process" "\
Run the Cargo update command.
With the prefix argument, modify the command's invocation.
If ALL is t then update all crates, otherwise specify CRATES.
Cargo: Upgrade dependencies as specified in the local manifest file
\(fn &optional ALL CRATES)" t nil)
(autoload 'cargo-process-repeat "cargo-process" "\
Run the last cargo-process command.
\(fn)" t nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cargo-process" '("cargo-process-" "manifest-path-argument" "set-rust-backtrace" "rustc-errno")))
;;;***
;;;### (autoloads nil nil ("cargo-pkg.el") (0 0 0 0))
;;;***
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; cargo-autoloads.el ends here

View File

@@ -0,0 +1,13 @@
(define-package "cargo" "20190902.754" "Emacs Minor Mode for Cargo, Rust's Package Manager."
'((emacs "24.3")
(rust-mode "0.2.0")
(markdown-mode "2.4"))
:keywords
'("tools")
:authors
'(("Kevin W. van Rooijen" . "kevin.van.rooijen@attichacker.com"))
:maintainer
'("Kevin W. van Rooijen" . "kevin.van.rooijen@attichacker.com"))
;; Local Variables:
;; no-byte-compile: t
;; End:

View File

@@ -0,0 +1,677 @@
;;; cargo-process.el --- Cargo Process Major Mode -*-lexical-binding: t-*-
;; Copyright (C) 2015 Kevin W. van Rooijen
;; Author: Kevin W. van Rooijen <kevin.van.rooijen@attichacker.com>
;; Keywords: processes, tools
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Cargo Process Major mode.
;; Used to run Cargo background processes.
;; Current supported Cargo functions:
;; * cargo-process-bench - Run the benchmarks.
;; * cargo-process-build - Compile the current project.
;; * cargo-process-clean - Remove the target directory.
;; * cargo-process-doc - Build this project's and its dependencies' documentation.
;; * cargo-process-doc-open - Open this project's documentation.
;; * cargo-process-new - Create a new cargo project.
;; * cargo-process-init - Create a new cargo project inside an existing directory.
;; * cargo-process-run - Build and execute src/main.rs.
;; * cargo-process-run-example - Build and execute with --example <name>.
;; * cargo-process-run-bin - Build and execute a specific binary.
;; * cargo-process-search - Search registry for crates.
;; * cargo-process-test - Run all unit tests.
;; * cargo-process-update - Update dependencies listed in Cargo.lock.
;; * cargo-process-repeat - Run the last cargo-process command.
;; * cargo-process-current-test - Run the current unit test.
;; * cargo-process-current-file-tests - Run the current file unit tests.
;; * cargo-process-fmt - Run the optional cargo command fmt.
;; * cargo-process-check - Run the optional cargo command check.
;; * cargo-process-clippy - Run the optional cargo command clippy.
;; * cargo-process-add - Run the optional cargo command add.
;; * cargo-process-rm - Run the optional cargo command rm.
;; * cargo-process-upgrade - Run the optional cargo command upgrade.
;; * cargo-process-outdated - Run the optional cargo command outdated.
;;
;;; Code:
(require 'compile)
(require 'button)
(require 'rust-mode)
(require 'markdown-mode)
(defgroup cargo-process nil
"Cargo Process group."
:prefix "cargo-process-"
:group 'cargo)
(defcustom cargo-process--custom-path-to-bin
(or (executable-find "cargo")
(expand-file-name "cargo" "~/.cargo/bin")
"/usr/local/bin/cargo")
"Custom path to the cargo executable"
:type 'file
:group 'cargo-process)
(defcustom cargo-process--rustc-cmd
(or (executable-find "rustc")
(expand-file-name "rustc" "~/.cargo/bin")
"/usr/local/bin/rustc")
"Custom path to the rustc executable"
:type 'file
:group 'cargo-process)
(defcustom cargo-process--enable-rust-backtrace nil
"Set RUST_BACKTRACE environment variable to 1 for tasks test and run"
:type 'boolean
:group 'cargo-process)
(defcustom cargo-process--command-flags ""
"Flags to be added to every cargo command when run."
:group 'cargo-process)
(defvar cargo-process-mode-map
(nconc (make-sparse-keymap) compilation-mode-map)
"Keymap for Cargo major mode.")
(defvar cargo-process--no-manifest-commands
'("New" "Init" "Search" "Fmt")
"These commands should not specify a manifest file.")
(defvar cargo-process-last-command nil "Command used last for repeating.")
(make-variable-buffer-local 'cargo-process-last-command)
(defcustom cargo-process--command-bench "bench"
"Subcommand used by `cargo-process-bench'.")
(defcustom cargo-process--command-build "build"
"Subcommand used by `cargo-process-build'.")
(defcustom cargo-process--command-clean "clean"
"Subcommand used by `cargo-process-clean'.")
(defcustom cargo-process--command-doc "doc"
"Subcommand used by `cargo-process-doc'.")
(defcustom cargo-process--command-doc-open "doc --open"
"Subcommand used by `cargo-process-doc'.")
(defcustom cargo-process--command-new "new"
"Subcommand used by `cargo-process-new'.")
(defcustom cargo-process--command-init "init"
"Subcommand used by `cargo-process-init'.")
(defcustom cargo-process--command-run "run"
"Subcommand used by `cargo-process-run'.")
(defcustom cargo-process--command-run-bin "run --bin"
"Subcommand used by `cargo-process-run-bin'.")
(defcustom cargo-process--command-run-example "run --example"
"Subcommand used by `cargo-process-run-example'.")
(defcustom cargo-process--command-search "search"
"Subcommand used by `cargo-process-search'.")
(defcustom cargo-process--command-test "test"
"Subcommand used by `cargo-process-test'.")
(defcustom cargo-process--command-current-test "test"
"Subcommand used by `cargo-process-current-test'.")
(defcustom cargo-process--command-current-file-tests "test"
"Subcommand used by `cargo-process-current-file-tests'.")
(defcustom cargo-process--command-update "update"
"Subcommand used by `cargo-process-update'.")
(defcustom cargo-process--command-fmt "fmt"
"Subcommand used by `cargo-process-fmt'.")
(defcustom cargo-process--command-outdated "outdated -R"
"Subcommand used by `cargo-process-outdated'.")
(defcustom cargo-process--command-check "check"
"Subcommand used by `cargo-process-check'.")
(defcustom cargo-process--command-clippy "clippy"
"Subcommand used by `cargo-process-clippy'.")
(defcustom cargo-process--command-add "add"
"Subcommand used by `cargo-process-add'.")
(defcustom cargo-process--command-rm "rm"
"Subcommand used by `cargo-process-rm'.")
(defcustom cargo-process--command-upgrade "upgrade"
"Subcommand used by `cargo-process-upgrade'.")
(defvar cargo-process-favorite-crates nil)
(defface cargo-process--ok-face
'((t (:inherit success)))
"Ok face"
:group 'cargo-process)
(defface cargo-process--error-face
'((t (:inherit error)))
"Error face"
:group 'cargo-process)
(defface cargo-process--warning-face
'((t (:inherit warning)))
"Warning face"
:group 'cargo-process)
(defface cargo-process--pointer-face
'((t (:inherit font-lock-negation-char-face)))
"Pointer face"
:group 'cargo-process)
(defface cargo-process--standard-face
'((t (:inherit font-lock-comment-face)))
"Standard face"
:group 'cargo-process)
(defface cargo-process--errno-face
'((t (:inherit link)))
"Error number face"
:group 'cargo-process)
(defconst cargo-process--rust-backtrace "RUST_BACKTRACE")
(defconst cargo-process-test-regexp "^[[:space:]]*fn[[:space:]]*"
"Regex to find Rust unit test function.")
(defconst cargo-process-test-mod-regexp "^[[:space:]]*mod[[:space:]]+[[:word:][:multibyte:]_][[:word:][:multibyte:]_[:digit:]]*[[:space:]]*{")
(defconst cargo-process-font-lock-keywords
'(("^error\\:?" . 'cargo-process--error-face)
("^warning\\:?" . 'cargo-process--warning-face)
("^\s*\\^\\~*\s*$" . 'cargo-process--pointer-face)
("^\s*Compiling.*" . 'cargo-process--standard-face)
("^\s*Running.*" . 'cargo-process--standard-face)
("^\s*Updating.*" . 'cargo-process--standard-face)
("test result: FAILED." . 'cargo-process--error-face)
("test result: ok." . 'cargo-process--ok-face)
("test\s.*\sFAILED" . 'cargo-process--error-face)
("test\s.*\sok" . 'cargo-process--ok-face))
"Minimal highlighting expressions for cargo-process mode.")
;; Bind `case-fold-search' to nil before using the regex.
(defconst cargo-process--errno-regex "\\bE[0-9]\\{4\\}\\b"
"A regular expression to match Rust error number.")
(define-button-type 'rustc-errno
'follow-link t
'face 'cargo-process--errno-face
'action #'cargo-process--explain-action)
(defun cargo-process--defun-at-point-p ()
(string-match cargo-process-test-regexp
(buffer-substring-no-properties (line-beginning-position)
(line-end-position))))
(defun cargo-process--project-root (&optional extra)
"Find the root of the current Cargo project."
(let ((root (locate-dominating-file (or buffer-file-name default-directory) "Cargo.toml")))
(when root
(file-truename (concat root extra)))))
(define-derived-mode cargo-process-mode compilation-mode "Cargo-Process."
"Major mode for the Cargo process buffer."
(use-local-map cargo-process-mode-map)
(setq major-mode 'cargo-process-mode)
(setq mode-name "Cargo-Process")
(setq-local truncate-lines t)
(run-hooks 'cargo-process-mode-hook)
(add-hook 'compilation-filter-hook #'cargo-process--add-errno-buttons)
(font-lock-add-keywords nil cargo-process-font-lock-keywords))
(defun cargo-process--finished-sentinel (process event)
"Execute after PROCESS return and EVENT is 'finished'."
(compilation-sentinel process event)
(when (equal event "finished\n")
(message "Cargo Process finished.")))
(defun cargo-process--activate-mode (buffer)
"Execute commands BUFFER at process start."
(with-current-buffer buffer
(funcall 'cargo-process-mode)
(setq-local window-point-insertion-type t)))
(defun set-rust-backtrace (command)
"Set RUST_BACKTRACE variable depending on the COMMAND used.
Always set to nil if cargo-process--enable-rust-backtrace is nil"
(if (and cargo-process--enable-rust-backtrace
(string-match "\\(test\\|run\\)" command))
(setenv cargo-process--rust-backtrace "1")
(setenv cargo-process--rust-backtrace nil)))
(defun cargo-process--workspace-root ()
"Find the workspace root using `cargo metadata`."
(when (cargo-process--project-root)
(let* ((metadata-text (shell-command-to-string
(concat (shell-quote-argument cargo-process--custom-path-to-bin)
" metadata --format-version 1 --no-deps")))
(metadata-json (json-read-from-string metadata-text))
(workspace-root (cdr (assoc 'workspace_root metadata-json))))
workspace-root)))
(defun manifest-path-argument (name)
(let ((manifest-filename (cargo-process--project-root "Cargo.toml")))
(when (and manifest-filename
(not (member name cargo-process--no-manifest-commands)))
(concat "--manifest-path " (shell-quote-argument manifest-filename)))))
(defun cargo-process--start (name command &optional last-cmd opens-external)
"Start the Cargo process NAME with the cargo command COMMAND.
OPENS-EXTERNAL is non-nil if the COMMAND is expected to open an external application.
Returns the created process."
(set-rust-backtrace command)
(let* ((buffer (concat "*Cargo " name "*"))
(project-root (cargo-process--project-root))
(cmd
(or last-cmd
(cargo-process--maybe-read-command
(cargo-process--augment-cmd-for-os opens-external
(mapconcat #'identity (list (shell-quote-argument cargo-process--custom-path-to-bin)
command
(manifest-path-argument name)
cargo-process--command-flags)
" ")))))
(default-directory (or project-root default-directory)))
(save-some-buffers (not compilation-ask-about-save)
(lambda ()
(and project-root
buffer-file-name
(string-prefix-p project-root (file-truename buffer-file-name)))))
(setq cargo-process-last-command (list name command cmd))
(let ((default-directory (or (cargo-process--workspace-root)
default-directory)))
(compilation-start cmd 'cargo-process-mode (lambda(_) buffer)))
(let ((process (get-buffer-process buffer)))
(set-process-sentinel process 'cargo-process--finished-sentinel)
process)))
(defun cargo-process--explain-action (button)
"Action called when the user activates Rust errno BUTTON."
(cargo-process--explain-help (button-label button)))
(defun cargo-process--explain-help (errno)
"Display a detailed explaination of ERRNO in a markdown buffer."
(pop-to-buffer
(let ((current-window (selected-window))
(inhibit-message t))
(with-current-buffer (get-buffer-create "*rust errno*")
(let ((buffer-read-only nil))
(erase-buffer)
(insert (shell-command-to-string
(concat cargo-process--rustc-cmd " --explain=" errno))))
(markdown-view-mode)
(setq-local markdown-fontify-code-blocks-natively t)
(setq-local markdown-fontify-code-block-default-mode 'rust-mode)
(setq-local kill-buffer-hook (lambda ()
(when (window-live-p current-window)
(select-window current-window))))
(setq
header-line-format
(concat (propertize " " 'display
`(space :align-to (- right-fringe ,(1+ (length errno)))))
(propertize errno 'face 'error)))
(markdown-toggle-markup-hiding 1)
(goto-char 1)
(current-buffer)))))
(defun cargo-process--add-errno-buttons ()
"Turn error numbers into clickable links in Cargo process output.
Meant to be run as a `compilation-filter-hook'."
(save-excursion
(let ((start compilation-filter-start)
(end (point))
(case-fold-search nil))
(goto-char start)
(while (re-search-forward cargo-process--errno-regex end t)
(make-button (match-beginning 0)
(match-end 0)
:type 'rustc-errno)))))
(defun cargo-process--get-current-test ()
"Return the current test."
(save-excursion
(unless (cargo-process--defun-at-point-p)
(rust-beginning-of-defun))
(beginning-of-line)
(search-forward "fn ")
(let* ((line (buffer-substring-no-properties (point)
(line-end-position)))
(lines (split-string line "("))
(function-name (car lines)))
function-name)))
(defun cargo-process--get-current-mod ()
"Return the current mod."
(save-excursion
(when (search-backward-regexp cargo-process-test-mod-regexp nil t)
(let* ((line (buffer-substring-no-properties (line-beginning-position)
(line-end-position)))
(line (string-trim-left line))
(lines (split-string line " \\|{"))
(mod (cadr lines)))
mod))))
(defun cargo-process--get-current-test-fullname ()
(if (cargo-process--get-current-mod)
(concat (cargo-process--get-current-mod)
"::"
(cargo-process--get-current-test))
(cargo-process--get-current-test)))
(defun cargo-process--maybe-read-command (default)
"Prompt to modify the DEFAULT command when the prefix argument is present.
Without the prefix argument, return DEFAULT immediately."
(if current-prefix-arg
(read-shell-command "Cargo command: " default)
default))
(defun cargo-process--get-dependencies (&optional manifest)
"Extract the list of dependencies from the
MANIFEST (i.e. Cargo.toml)."
(with-current-buffer (find-file-noselect (or manifest
(cargo-process--project-root "Cargo.toml")))
(save-excursion
(let ((deps-list))
(widen)
(goto-char (point-min))
(search-forward "[dependencies]" nil t)
(while (re-search-forward "^[a-zA-Z\-\_]* *=" nil t)
(beginning-of-line)
(setq deps-list
(cons (thing-at-point 'sexp t) deps-list))
(end-of-line))
deps-list))))
(defun cargo-process--augment-cmd-for-os (opens-external cmd)
"Augment the cargo CMD according to OS. OPENS-EXTERNAL is non-nil
if the CMD is expected to open and external application."
(if (and opens-external
(not (member system-type '(windows-nt ms-dos)))
(executable-find "setsid"))
(concat "setsid -w " cmd)
cmd))
;;;###autoload
(defun cargo-process-bench ()
"Run the Cargo bench command.
With the prefix argument, modify the command's invocation.
Cargo: Run the benchmarks."
(interactive)
(cargo-process--start "Bench" cargo-process--command-bench))
;;;###autoload
(defun cargo-process-build ()
"Run the Cargo build command.
With the prefix argument, modify the command's invocation.
Cargo: Compile the current project."
(interactive)
(cargo-process--start "Build" cargo-process--command-build))
;;;###autoload
(defun cargo-process-clean ()
"Run the Cargo clean command.
With the prefix argument, modify the command's invocation.
Cargo: Remove the target directory."
(interactive)
(cargo-process--start "Clean" cargo-process--command-clean))
;;;###autoload
(defun cargo-process-doc ()
"Run the Cargo doc command.
With the prefix argument, modify the command's invocation.
Cargo: Build this project's and its dependencies' documentation."
(interactive)
(cargo-process--start "Doc" cargo-process--command-doc))
;;;###autoload
(defun cargo-process-doc-open ()
"Run the Cargo doc command with the --open switch.
With the prefix argument, modify the command's invocation.
Cargo: Open this project's documentation."
(interactive)
(cargo-process--start "Doc" cargo-process--command-doc-open nil t))
;;;###autoload
(defun cargo-process-new (name &optional bin)
"Run the Cargo new command.
With the prefix argument, modify the command's invocation.
NAME is the name of your application.
If BIN is t then create a binary application, otherwise a library.
Cargo: Create a new cargo project."
(interactive "sProject name: ")
(let ((bin (if (or bin
(y-or-n-p "Create Bin Project? "))
" --bin"
" --lib")))
(cargo-process--start "New" (concat cargo-process--command-new
" "
name
bin))))
;;;###autoload
(defun cargo-process-init (directory &optional bin)
"Run the Cargo init command.
With the prefix argument, modify the command's invocation.
DIRECTORY is the directory you want to create a cargo project in.
If BIN is t then create a binary application, otherwise a library.
Cargo: Create a new cargo project in current directory.
DIRECTORY is created if necessary."
(interactive
(list (read-directory-name "Directory: " nil default-directory nil)))
(let* ((bin (if (or bin (y-or-n-p "Create Bin Project? "))
" --bin"
" --lib"))
(process
(cargo-process--start "Init" (concat cargo-process--command-init
" "
directory
bin))))
(set-process-sentinel
process
(lambda (process event)
(cargo-process--open-manifest process
event
(expand-file-name "Cargo.toml" directory))))))
(defun cargo-process--open-manifest (process event manifest-path)
"Open the manifest file when process ends."
(when (equal event "finished\n")
(find-file manifest-path)))
;;;###autoload
(defun cargo-process-run ()
"Run the Cargo run command.
With the prefix argument, modify the command's invocation.
Cargo: Build and execute src/main.rs."
(interactive)
(cargo-process--start "Run" cargo-process--command-run))
;;;###autoload
(defun cargo-process-run-bin (command)
"Run the Cargo run command --bin <name>.
With the prefix argument, modify the command's invocation.
Cargo: Build and execute a specific binary"
(interactive "sBinary name: ")
(cargo-process--start (concat "Run " command)
(concat cargo-process--command-run-bin " " command)))
;;;###autoload
(defun cargo-process-run-example (command)
"Run the Cargo run command --example <name>.
With the prefix argument, modify the command's invocation.
Cargo: Build and execute with --example <name>."
(interactive "sExample name: ")
(cargo-process--start (concat "Example " command)
(concat cargo-process--command-run-example " " command)))
;;;###autoload
(defun cargo-process-search (search-term)
"Run the Cargo search command.
With the prefix argument, modify the command's invocation.
SEARCH-TERM is used as the search term for the Cargo registry.
Cargo: Search registry for crates."
(interactive "sSearch: ")
(cargo-process--start "Search"
(concat cargo-process--command-search " " search-term)))
;;;###autoload
(defun cargo-process-test ()
"Run the Cargo test command.
With the prefix argument, modify the command's invocation.
Cargo: Run the tests."
(interactive)
(cargo-process--start "Test" cargo-process--command-test))
;;;###autoload
(defun cargo-process-current-test ()
"Run the Cargo test command for the current test.
With the prefix argument, modify the command's invocation.
Cargo: Run the tests."
(interactive)
(cargo-process--start "Test"
(concat cargo-process--command-current-test
" "
(cargo-process--get-current-test-fullname))))
;;;###autoload
(defun cargo-process-current-file-tests ()
"Run the Cargo test command for the current file.
With the prefix argument, modify the command's invocation.
Cargo: Run the tests."
(interactive)
(cargo-process--start "Test" (concat cargo-process--command-current-file-tests
" "
(cargo-process--get-current-mod))))
;;;###autoload
(defun cargo-process-update ()
"Run the Cargo update command.
With the prefix argument, modify the command's invocation.
Cargo: Update dependencies listed in Cargo.lock."
(interactive)
(cargo-process--start "Update" cargo-process--command-update))
;;;###autoload
(defun cargo-process-fmt ()
"Run the Cargo fmt command.
With the prefix argument, modify the command's invocation.
Requires Cargo Fmt to be installed."
(interactive)
(cargo-process--start "Fmt" cargo-process--command-fmt))
;;;###autoload
(defun cargo-process-outdated ()
"Run the Cargo outdated command.
With the prefix argument, modify the command's invocation.
Requires Cargo Outdated to be installed."
(interactive)
(cargo-process--start "Outdated" cargo-process--command-outdated))
;;;###autoload
(defun cargo-process-check ()
"Run the Cargo check command.
With the prefix argument, modify the command's invocation.
Cargo: Check compile the current project.
Requires cargo-check to be installed."
(interactive)
(cargo-process--start "Check" cargo-process--command-check))
;;;###autoload
(defun cargo-process-clippy ()
"Run the Cargo clippy command.
With the prefix argument, modify the command's invocation.
Cargo: Clippy compile the current project.
Requires Cargo clippy to be installed."
(interactive)
(cargo-process--start "Clippy" cargo-process--command-clippy))
;;;###autoload
(defun cargo-process-add (crate)
"Run the Cargo add command.
With the prefix argument, modify the command's invocation.
CRATES is the name of the crate to add.
Cargo: This command allows you to add a dependency to a Cargo.toml manifest file."
(interactive (list
(completing-read "Crate(s) to add: " cargo-process-favorite-crates)))
(cargo-process--start "Add" (concat cargo-process--command-add
" "
crate)))
;;;###autoload
(defun cargo-process-rm (crate)
"Run the Cargo rm command.
With the prefix argument, modify the command's invocation.
CRATE is the name of the crate to remove.
Cargo: Remove a dependency from a Cargo.toml manifest file."
(interactive
(list
(let ((deplist (cargo-process--get-dependencies)))
(when deplist
(completing-read "Crate to remove: "
deplist nil t)))))
(if crate (cargo-process--start "Remove" (concat cargo-process--command-rm
" "
crate))
(message "No crates used in current project.")))
;;;###autoload
(defun cargo-process-upgrade (&optional all crates)
"Run the Cargo update command.
With the prefix argument, modify the command's invocation.
If ALL is t then update all crates, otherwise specify CRATES.
Cargo: Upgrade dependencies as specified in the local manifest file"
(interactive)
(let ((deplist (cargo-process--get-dependencies)))
(if deplist
(let* ((all (when (or all
(y-or-n-p "Upgrade all crates? "))
"--all"))
(crates (when (not all)
(completing-read "Crate(s) to upgrade: " deplist nil 'confirm))))
(cargo-process--start "Upgrade" (concat cargo-process--command-upgrade
" "
all
" "
crates)))
(message "No crates used in current project."))))
;;;###autoload
(defun cargo-process-repeat ()
"Run the last cargo-process command."
(interactive)
(if cargo-process-last-command
(apply 'cargo-process--start cargo-process-last-command)
(message "No last Cargo command.")))
(define-key cargo-process-mode-map (kbd "n") 'forward-button)
(define-key cargo-process-mode-map (kbd "p") 'backward-button)
(provide 'cargo-process)
;;; cargo-process.el ends here

Binary file not shown.

View File

@@ -0,0 +1,95 @@
;;; cargo.el --- Emacs Minor Mode for Cargo, Rust's Package Manager.
;; Copyright (C) 2015 Kevin W. van Rooijen
;; Author: Kevin W. van Rooijen <kevin.van.rooijen@attichacker.com>
;; Version : 0.4.0
;; Keywords: tools
;; Package-Requires: ((emacs "24.3") (rust-mode "0.2.0") (markdown-mode "2.4"))
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; Cargo Minor mode.
;; Provides a number of key combinations and functions for managing Cargo.
;; Current supported Cargo Key Combinations:
;; * C-c C-c C-e - cargo-process-bench
;; * C-c C-c C-b - cargo-process-build
;; * C-c C-c C-l - cargo-process-clean
;; * C-c C-c C-d - cargo-process-doc
;; * C-c C-c C-v - cargo-process-doc-open
;; * C-c C-c C-n - cargo-process-new
;; * C-c C-c C-i - cargo-process-init
;; * C-c C-c C-r - cargo-process-run
;; * C-c C-c C-x - cargo-process-run-example
;; * C-c C-c C-s - cargo-process-search
;; * C-c C-c C-t - cargo-process-test
;; * C-c C-c C-u - cargo-process-update
;; * C-c C-c C-c - cargo-process-repeat
;; * C-c C-c C-f - cargo-process-current-test
;; * C-c C-c C-o - cargo-process-current-file-tests
;; * C-c C-c C-O - cargo-process-outdated
;; * C-c C-c C-m - cargo-process-fmt
;; * C-c C-c C-k - cargo-process-check
;; * C-c C-c C-K - cargo-process-clippy
;; * C-c C-c C-a - cargo-process-add
;; * C-c C-c C-D - cargo-process-rm
;; * C-c C-c C-U - cargo-process-upgrade
;;
;;; Code:
(require 'cargo-process)
(defgroup cargo nil
"Cargo group."
:prefix "cargo-"
:group 'tools)
(defvar cargo-minor-mode-map (make-keymap) "Cargo-mode keymap.")
(defvar cargo-minor-mode nil)
;;;###autoload
(define-minor-mode cargo-minor-mode
"Cargo minor mode. Used to hold keybindings for cargo-mode.
\\{cargo-minor-mode-map}"
nil " cargo" cargo-minor-mode-map)
(define-key cargo-minor-mode-map (kbd "C-c C-c C-e") 'cargo-process-bench)
(define-key cargo-minor-mode-map (kbd "C-c C-c C-b") 'cargo-process-build)
(define-key cargo-minor-mode-map (kbd "C-c C-c C-l") 'cargo-process-clean)
(define-key cargo-minor-mode-map (kbd "C-c C-c C-d") 'cargo-process-doc)
(define-key cargo-minor-mode-map (kbd "C-c C-c C-v") 'cargo-process-doc-open)
(define-key cargo-minor-mode-map (kbd "C-c C-c C-n") 'cargo-process-new)
(define-key cargo-minor-mode-map (kbd "C-c C-c C-i") 'cargo-process-init)
(define-key cargo-minor-mode-map (kbd "C-c C-c C-r") 'cargo-process-run)
(define-key cargo-minor-mode-map (kbd "C-c C-c C-x") 'cargo-process-run-example)
(define-key cargo-minor-mode-map (kbd "C-c C-c C-s") 'cargo-process-search)
(define-key cargo-minor-mode-map (kbd "C-c C-c C-t") 'cargo-process-test)
(define-key cargo-minor-mode-map (kbd "C-c C-c C-u") 'cargo-process-update)
(define-key cargo-minor-mode-map (kbd "C-c C-c C-c") 'cargo-process-repeat)
(define-key cargo-minor-mode-map (kbd "C-c C-c C-f") 'cargo-process-current-test)
(define-key cargo-minor-mode-map (kbd "C-c C-c C-o") 'cargo-process-current-file-tests)
(define-key cargo-minor-mode-map (kbd "C-c C-c C-S-o") 'cargo-process-outdated)
(define-key cargo-minor-mode-map (kbd "C-c C-c C-m") 'cargo-process-fmt)
(define-key cargo-minor-mode-map (kbd "C-c C-c C-k") 'cargo-process-check)
(define-key cargo-minor-mode-map (kbd "C-c C-c C-S-k") 'cargo-process-clippy)
(define-key cargo-minor-mode-map (kbd "C-c C-c C-a") 'cargo-process-add)
(define-key cargo-minor-mode-map (kbd "C-c C-c C-S-d") 'cargo-process-rm)
(define-key cargo-minor-mode-map (kbd "C-c C-c C-S-u") 'cargo-process-upgrade)
(provide 'cargo)
;;; cargo.el ends here

Binary file not shown.

View File

@@ -0,0 +1,22 @@
;;; epl-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (directory-file-name
(or (file-name-directory #$) (car load-path))))
;;;### (autoloads nil "epl" "epl.el" (0 0 0 0))
;;; Generated autoloads from epl.el
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "epl" '("epl-")))
;;;***
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; epl-autoloads.el ends here

View File

@@ -0,0 +1,2 @@
;;; -*- no-byte-compile: t -*-
(define-package "epl" "20180205.2049" "Emacs Package Library" '((cl-lib "0.3")) :commit "78ab7a85c08222cd15582a298a364774e3282ce6" :keywords '("convenience") :authors '(("Sebastian Wiesner" . "swiesner@lunaryorn.com")) :maintainer '("Johan Andersson" . "johan.rejeep@gmail.com") :url "http://github.com/cask/epl")

View File

@@ -0,0 +1,711 @@
;;; epl.el --- Emacs Package Library -*- lexical-binding: t; -*-
;; Copyright (C) 2013-2015 Sebastian Wiesner
;; Copyright (C) 1985-1986, 1992, 1994-1995, 1999-2015 Free Software
;; Author: Sebastian Wiesner <swiesner@lunaryorn.com>
;; Maintainer: Johan Andersson <johan.rejeep@gmail.com>
;; Sebastian Wiesner <swiesner@lunaryorn.com>
;; Version: 0.10-cvs
;; Package-Version: 20180205.2049
;; Package-Requires: ((cl-lib "0.3"))
;; Keywords: convenience
;; URL: http://github.com/cask/epl
;; This file is NOT part of GNU Emacs.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; A package management library for Emacs, based on package.el.
;; The purpose of this library is to wrap all the quirks and hassle of
;; package.el into a sane API.
;; The following functions comprise the public interface of this library:
;;; Package directory selection
;; `epl-package-dir' gets the directory of packages.
;; `epl-default-package-dir' gets the default package directory.
;; `epl-change-package-dir' changes the directory of packages.
;;; Package system management
;; `epl-initialize' initializes the package system and activates all
;; packages.
;; `epl-reset' resets the package system.
;; `epl-refresh' refreshes all package archives.
;; `epl-add-archive' adds a new package archive.
;;; Package objects
;; Struct `epl-requirement' describes a requirement of a package with `name' and
;; `version' slots.
;; `epl-requirement-version-string' gets a requirement version as string.
;; Struct `epl-package' describes an installed or installable package with a
;; `name' and some internal `description'.
;; `epl-package-version' gets the version of a package.
;; `epl-package-version-string' gets the version of a package as string.
;; `epl-package-summary' gets the summary of a package.
;; `epl-package-requirements' gets the requirements of a package.
;; `epl-package-directory' gets the installation directory of a package.
;; `epl-package-from-buffer' creates a package object for the package contained
;; in the current buffer.
;; `epl-package-from-file' creates a package object for a package file, either
;; plain lisp or tarball.
;; `epl-package-from-descriptor-file' creates a package object for a package
;; description (i.e. *-pkg.el) file.
;;; Package database access
;; `epl-package-installed-p' determines whether a package is installed, either
;; built-in or explicitly installed.
;; `epl-package-outdated-p' determines whether a package is outdated, that is,
;; whether a package with a higher version number is available.
;; `epl-built-in-packages', `epl-installed-packages', `epl-outdated-packages'
;; and `epl-available-packages' get all packages built-in, installed, outdated,
;; or available for installation respectively.
;; `epl-find-built-in-package', `epl-find-installed-packages' and
;; `epl-find-available-packages' find built-in, installed and available packages
;; by name.
;; `epl-find-upgrades' finds all upgradable packages.
;; `epl-built-in-p' return true if package is built-in to Emacs.
;;; Package operations
;; `epl-install-file' installs a package file.
;; `epl-package-install' installs a package.
;; `epl-package-delete' deletes a package.
;; `epl-upgrade' upgrades packages.
;;; Code:
(require 'cl-lib)
(require 'package)
(unless (fboundp #'define-error)
;; `define-error' for 24.3 and earlier, copied from subr.el
(defun define-error (name message &optional parent)
"Define NAME as a new error signal.
MESSAGE is a string that will be output to the echo area if such an error
is signaled without being caught by a `condition-case'.
PARENT is either a signal or a list of signals from which it inherits.
Defaults to `error'."
(unless parent (setq parent 'error))
(let ((conditions
(if (consp parent)
(apply #'append
(mapcar (lambda (parent)
(cons parent
(or (get parent 'error-conditions)
(error "Unknown signal `%s'" parent))))
parent))
(cons parent (get parent 'error-conditions)))))
(put name 'error-conditions
(delete-dups (copy-sequence (cons name conditions))))
(when message (put name 'error-message message)))))
(defsubst epl--package-desc-p (package)
"Whether PACKAGE is a `package-desc' object.
Like `package-desc-p', but return nil, if `package-desc-p' is not
defined as function."
(and (fboundp 'package-desc-p) (package-desc-p package)))
;;; EPL errors
(define-error 'epl-error "EPL error")
(define-error 'epl-invalid-package "Invalid EPL package" 'epl-error)
(define-error 'epl-invalid-package-file "Invalid EPL package file"
'epl-invalid-package)
;;; Package directory
(defun epl-package-dir ()
"Get the directory of packages."
package-user-dir)
(defun epl-default-package-dir ()
"Get the default directory of packages."
(eval (car (get 'package-user-dir 'standard-value))))
(defun epl-change-package-dir (directory)
"Change the directory of packages to DIRECTORY."
(setq package-user-dir directory)
(epl-initialize))
;;; Package system management
(defvar epl--load-path-before-initialize nil
"Remember the load path for `epl-reset'.")
(defun epl-initialize (&optional no-activate)
"Load Emacs Lisp packages and activate them.
With NO-ACTIVATE non-nil, do not activate packages."
(setq epl--load-path-before-initialize load-path)
(package-initialize no-activate))
(defalias 'epl-refresh 'package-refresh-contents)
(defun epl-add-archive (name url)
"Add a package archive with NAME and URL."
(add-to-list 'package-archives (cons name url)))
(defun epl-reset ()
"Reset the package system.
Clear the list of installed and available packages, the list of
package archives and reset the package directory."
(setq package-alist nil
package-archives nil
package-archive-contents nil
load-path epl--load-path-before-initialize)
(when (boundp 'package-obsolete-alist) ; Legacy package.el
(setq package-obsolete-alist nil))
(epl-change-package-dir (epl-default-package-dir)))
;;; Package structures
(cl-defstruct (epl-requirement
(:constructor epl-requirement-create))
"Structure describing a requirement.
Slots:
`name' The name of the required package, as symbol.
`version' The version of the required package, as version list."
name
version)
(defun epl-requirement-version-string (requirement)
"The version of a REQUIREMENT, as string."
(package-version-join (epl-requirement-version requirement)))
(cl-defstruct (epl-package (:constructor epl-package-create))
"Structure representing a package.
Slots:
`name' The package name, as symbol.
`description' The package description.
The format package description varies between package.el
variants. For `package-desc' variants, it is simply the
corresponding `package-desc' object. For legacy variants, it is
a vector `[VERSION REQS DOCSTRING]'.
Do not access `description' directly, but instead use the
`epl-package' accessors."
name
description)
(defmacro epl-package-as-description (var &rest body)
"Cast VAR to a package description in BODY.
VAR is a symbol, bound to an `epl-package' object. This macro
casts this object to the `description' object, and binds the
description to VAR in BODY."
(declare (indent 1))
(unless (symbolp var)
(signal 'wrong-type-argument (list #'symbolp var)))
`(if (epl-package-p ,var)
(let ((,var (epl-package-description ,var)))
,@body)
(signal 'wrong-type-argument (list #'epl-package-p ,var))))
(defsubst epl-package--package-desc-p (package)
"Whether the description of PACKAGE is a `package-desc'."
(epl--package-desc-p (epl-package-description package)))
(defun epl-package-version (package)
"Get the version of PACKAGE, as version list."
(epl-package-as-description package
(cond
((fboundp 'package-desc-version) (package-desc-version package))
;; Legacy
((fboundp 'package-desc-vers)
(let ((version (package-desc-vers package)))
(if (listp version) version (version-to-list version))))
(:else (error "Cannot get version from %S" package)))))
(defun epl-package-version-string (package)
"Get the version from a PACKAGE, as string."
(package-version-join (epl-package-version package)))
(defun epl-package-summary (package)
"Get the summary of PACKAGE, as string."
(epl-package-as-description package
(cond
((fboundp 'package-desc-summary) (package-desc-summary package))
((fboundp 'package-desc-doc) (package-desc-doc package)) ; Legacy
(:else (error "Cannot get summary from %S" package)))))
(defsubst epl-requirement--from-req (req)
"Create a `epl-requirement' from a `package-desc' REQ."
(let ((version (cadr req)))
(epl-requirement-create :name (car req)
:version (if (listp version) version
(version-to-list version)))))
(defun epl-package-requirements (package)
"Get the requirements of PACKAGE.
The requirements are a list of `epl-requirement' objects."
(epl-package-as-description package
(mapcar #'epl-requirement--from-req (package-desc-reqs package))))
(defun epl-package-directory (package)
"Get the directory PACKAGE is installed to.
Return the absolute path of the installation directory of
PACKAGE, or nil, if PACKAGE is not installed."
(cond
((fboundp 'package-desc-dir)
(package-desc-dir (epl-package-description package)))
((fboundp 'package--dir)
(package--dir (symbol-name (epl-package-name package))
(epl-package-version-string package)))
(:else (error "Cannot get package directory from %S" package))))
(defun epl-package-->= (pkg1 pkg2)
"Determine whether PKG1 is before PKG2 by version."
(not (version-list-< (epl-package-version pkg1)
(epl-package-version pkg2))))
(defun epl-package--from-package-desc (package-desc)
"Create an `epl-package' from a PACKAGE-DESC.
PACKAGE-DESC is a `package-desc' object, from recent package.el
variants."
(if (and (fboundp 'package-desc-name)
(epl--package-desc-p package-desc))
(epl-package-create :name (package-desc-name package-desc)
:description package-desc)
(signal 'wrong-type-argument (list 'epl--package-desc-p package-desc))))
(defun epl-package--parse-info (info)
"Parse a package.el INFO."
(if (epl--package-desc-p info)
(epl-package--from-package-desc info)
;; For legacy package.el, info is a vector [NAME REQUIRES DESCRIPTION
;; VERSION COMMENTARY]. We need to re-shape this vector into the
;; `package-alist' format [VERSION REQUIRES DESCRIPTION] to attach it to the
;; new `epl-package'.
(let ((name (intern (aref info 0)))
(info (vector (aref info 3) (aref info 1) (aref info 2))))
(epl-package-create :name name :description info))))
(defun epl-package-from-buffer (&optional buffer)
"Create an `epl-package' object from BUFFER.
BUFFER defaults to the current buffer.
Signal `epl-invalid-package' if the buffer does not contain a
valid package file."
(let ((info (with-current-buffer (or buffer (current-buffer))
(condition-case err
(package-buffer-info)
(error (signal 'epl-invalid-package (cdr err)))))))
(epl-package--parse-info info)))
(defun epl-package-from-lisp-file (file-name)
"Parse the package headers the file at FILE-NAME.
Return an `epl-package' object with the header metadata."
(with-temp-buffer
(insert-file-contents file-name)
(condition-case err
(epl-package-from-buffer (current-buffer))
;; Attach file names to invalid package errors
(epl-invalid-package
(signal 'epl-invalid-package-file (cons file-name (cdr err))))
;; Forward other errors
(error (signal (car err) (cdr err))))))
(defun epl-package-from-tar-file (file-name)
"Parse the package tarball at FILE-NAME.
Return a `epl-package' object with the meta data of the tarball
package in FILE-NAME."
(condition-case nil
;; In legacy package.el, `package-tar-file-info' takes the name of the tar
;; file to parse as argument. In modern package.el, it has no arguments
;; and works on the current buffer. Hence, we just try to call the legacy
;; version, and if that fails because of a mismatch between formal and
;; actual arguments, we use the modern approach. To avoid spurious
;; signature warnings by the byte compiler, we suppress warnings when
;; calling the function.
(epl-package--parse-info (with-no-warnings
(package-tar-file-info file-name)))
(wrong-number-of-arguments
(with-temp-buffer
(insert-file-contents-literally file-name)
;; Switch to `tar-mode' to enable extraction of the file. Modern
;; `package-tar-file-info' relies on `tar-mode', and signals an error if
;; called in a buffer with a different mode.
(tar-mode)
(epl-package--parse-info (with-no-warnings
(package-tar-file-info)))))))
(defun epl-package-from-file (file-name)
"Parse the package at FILE-NAME.
Return an `epl-package' object with the meta data of the package
at FILE-NAME."
(if (string-match-p (rx ".tar" string-end) file-name)
(epl-package-from-tar-file file-name)
(epl-package-from-lisp-file file-name)))
(defun epl-package--parse-descriptor-requirement (requirement)
"Parse a REQUIREMENT in a package descriptor."
;; This function is only called on legacy package.el. On package-desc
;; package.el, we just let package.el do the work.
(cl-destructuring-bind (name version-string) requirement
(list name (version-to-list version-string))))
(defun epl-package-from-descriptor-file (descriptor-file)
"Load a `epl-package' from a package DESCRIPTOR-FILE.
A package descriptor is a file defining a new package. Its name
typically ends with -pkg.el."
(with-temp-buffer
(insert-file-contents descriptor-file)
(goto-char (point-min))
(let ((sexp (read (current-buffer))))
(unless (eq (car sexp) 'define-package)
(error "%S is no valid package descriptor" descriptor-file))
(if (and (fboundp 'package-desc-from-define)
(fboundp 'package-desc-name))
;; In Emacs snapshot, we can conveniently call a function to parse the
;; descriptor
(let ((desc (apply #'package-desc-from-define (cdr sexp))))
(epl-package-create :name (package-desc-name desc)
:description desc))
;; In legacy package.el, we must manually deconstruct the descriptor,
;; because the load function has eval's the descriptor and has a lot of
;; global side-effects.
(cl-destructuring-bind
(name version-string summary requirements) (cdr sexp)
(epl-package-create
:name (intern name)
:description
(vector (version-to-list version-string)
(mapcar #'epl-package--parse-descriptor-requirement
;; Strip the leading `quote' from the package list
(cadr requirements))
summary)))))))
;;; Package database access
(defun epl-package-installed-p (package &optional min-version)
"Determine whether a PACKAGE, of MIN-VERSION or newer, is installed.
PACKAGE is either a package name as symbol, or a package object.
When a explicit MIN-VERSION is provided it overwrites the version of the PACKAGE object."
(let ((name (if (epl-package-p package)
(epl-package-name package)
package))
(min-version (or min-version (and (epl-package-p package)
(epl-package-version package)))))
(package-installed-p name min-version)))
(defun epl--parse-built-in-entry (entry)
"Parse an ENTRY from the list of built-in packages.
Return the corresponding `epl-package' object."
(if (fboundp 'package--from-builtin)
;; In package-desc package.el, convert the built-in package to a
;; `package-desc' and convert that to an `epl-package'
(epl-package--from-package-desc (package--from-builtin entry))
(epl-package-create :name (car entry) :description (cdr entry))))
(defun epl-built-in-packages ()
"Get all built-in packages.
Return a list of `epl-package' objects."
;; This looks mighty strange, but it's the only way to force package.el to
;; build the list of built-in packages. Without this, `package--builtins'
;; might be empty.
(package-built-in-p 'foo)
(mapcar #'epl--parse-built-in-entry package--builtins))
(defun epl-find-built-in-package (name)
"Find a built-in package with NAME.
NAME is a package name, as symbol.
Return the built-in package as `epl-package' object, or nil if
there is no built-in package with NAME."
(when (package-built-in-p name)
;; We must call `package-built-in-p' *before* inspecting
;; `package--builtins', because otherwise `package--builtins' might be
;; empty.
(epl--parse-built-in-entry (assq name package--builtins))))
(defun epl-package-outdated-p (package)
"Determine whether a PACKAGE is outdated.
A package is outdated, if there is an available package with a
higher version.
PACKAGE is either a package name as symbol, or a package object.
In the former case, test the installed or built-in package with
the highest version number, in the later case, test the package
object itself.
Return t, if the package is outdated, or nil otherwise."
(let* ((package (if (epl-package-p package)
package
(or (car (epl-find-installed-packages package))
(epl-find-built-in-package package))))
(available (car (epl-find-available-packages
(epl-package-name package)))))
(and package available (version-list-< (epl-package-version package)
(epl-package-version available)))))
(defun epl--parse-package-list-entry (entry)
"Parse a list of packages from ENTRY.
ENTRY is a single entry in a package list, e.g. `package-alist',
`package-archive-contents', etc. Typically it is a cons cell,
but the exact format varies between package.el versions. This
function tries to parse all known variants.
Return a list of `epl-package' objects parsed from ENTRY."
(let ((descriptions (cdr entry)))
(cond
((listp descriptions)
(sort (mapcar #'epl-package--from-package-desc descriptions)
#'epl-package-->=))
;; Legacy package.el has just a single package in an entry, which is a
;; standard description vector
((vectorp descriptions)
(list (epl-package-create :name (car entry)
:description descriptions)))
(:else (error "Cannot parse entry %S" entry)))))
(defun epl-installed-packages ()
"Get all installed packages.
Return a list of package objects."
(apply #'append (mapcar #'epl--parse-package-list-entry package-alist)))
(defsubst epl--filter-outdated-packages (packages)
"Filter outdated packages from PACKAGES."
(let (res)
(dolist (package packages)
(when (epl-package-outdated-p package)
(push package res)))
(nreverse res)))
(defun epl-outdated-packages ()
"Get all outdated packages, as in `epl-package-outdated-p'.
Return a list of package objects."
(epl--filter-outdated-packages (epl-installed-packages)))
(defsubst epl--find-package-in-list (name list)
"Find a package by NAME in a package LIST.
Return a list of corresponding `epl-package' objects."
(let ((entry (assq name list)))
(when entry
(epl--parse-package-list-entry entry))))
(defun epl-find-installed-package (name)
"Find the latest installed package by NAME.
NAME is a package name, as symbol.
Return the installed package with the highest version number as
`epl-package' object, or nil, if no package with NAME is
installed."
(car (epl-find-installed-packages name)))
(make-obsolete 'epl-find-installed-package 'epl-find-installed-packages "0.7")
(defun epl-find-installed-packages (name)
"Find all installed packages by NAME.
NAME is a package name, as symbol.
Return a list of all installed packages with NAME, sorted by
version number in descending order. Return nil, if there are no
packages with NAME."
(epl--find-package-in-list name package-alist))
(defun epl-available-packages ()
"Get all packages available for installation.
Return a list of package objects."
(apply #'append (mapcar #'epl--parse-package-list-entry
package-archive-contents)))
(defun epl-find-available-packages (name)
"Find available packages for NAME.
NAME is a package name, as symbol.
Return a list of available packages for NAME, sorted by version
number in descending order. Return nil, if there are no packages
for NAME."
(epl--find-package-in-list name package-archive-contents))
(cl-defstruct (epl-upgrade
(:constructor epl-upgrade-create))
"Structure describing an upgradable package.
Slots:
`installed' The installed package
`available' The package available for installation."
installed
available)
(defun epl-find-upgrades (&optional packages)
"Find all upgradable PACKAGES.
PACKAGES is a list of package objects to upgrade, defaulting to
all installed packages.
Return a list of `epl-upgrade' objects describing all upgradable
packages."
(let ((packages (or packages (epl-installed-packages)))
upgrades)
(dolist (pkg packages)
(let* ((version (epl-package-version pkg))
(name (epl-package-name pkg))
;; Find the latest available package for NAME
(available-pkg (car (epl-find-available-packages name)))
(available-version (when available-pkg
(epl-package-version available-pkg))))
(when (and available-version (version-list-< version available-version))
(push (epl-upgrade-create :installed pkg
:available available-pkg)
upgrades))))
(nreverse upgrades)))
(defalias 'epl-built-in-p 'package-built-in-p)
;;; Package operations
(defun epl-install-file (file)
"Install a package from FILE, like `package-install-file'."
(interactive (advice-eval-interactive-spec
(cadr (interactive-form #'package-install-file))))
(apply #'package-install-file (list file))
(let ((package (epl-package-from-file file)))
(unless (epl-package--package-desc-p package)
(epl--kill-autoload-buffer package))))
(defun epl--kill-autoload-buffer (package)
"Kill the buffer associated with autoloads for PACKAGE."
(let* ((auto-name (format "%s-autoloads.el" (epl-package-name package)))
(generated-autoload-file (expand-file-name auto-name (epl-package-directory package)))
(buf (find-buffer-visiting generated-autoload-file)))
(when buf (kill-buffer buf))))
(defun epl-package-install (package &optional force)
"Install a PACKAGE.
PACKAGE is a `epl-package' object. If FORCE is given and
non-nil, install PACKAGE, even if it is already installed."
(when (or force (not (epl-package-installed-p package)))
(if (epl-package--package-desc-p package)
(package-install (epl-package-description package))
;; The legacy API installs by name. We have no control over versioning,
;; etc.
(package-install (epl-package-name package))
(epl--kill-autoload-buffer package))))
(defun epl-package-delete (package)
"Delete a PACKAGE.
PACKAGE is a `epl-package' object to delete."
;; package-delete allows for packages being trashed instead of fully deleted.
;; Let's prevent his silly behavior
(let ((delete-by-moving-to-trash nil))
;; The byte compiler will warn us that we are calling `package-delete' with
;; the wrong number of arguments, since it can't infer that we guarantee to
;; always call the correct version. Thus we suppress all warnings when
;; calling `package-delete'. I wish there was a more granular way to
;; disable just that specific warning, but it is what it is.
(if (epl-package--package-desc-p package)
(with-no-warnings
(package-delete (epl-package-description package)))
;; The legacy API deletes by name (as string!) and version instead by
;; descriptor. Hence `package-delete' takes two arguments. For some
;; insane reason, the arguments are strings here!
(let ((name (symbol-name (epl-package-name package)))
(version (epl-package-version-string package)))
(with-no-warnings
(package-delete name version))
;; Legacy package.el does not remove the deleted package
;; from the `package-alist', so we do it manually here.
(let ((pkg (assq (epl-package-name package) package-alist)))
(when pkg
(setq package-alist (delq pkg package-alist))))))))
(defun epl-upgrade (&optional packages preserve-obsolete)
"Upgrade PACKAGES.
PACKAGES is a list of package objects to upgrade, defaulting to
all installed packages.
The old versions of the updated packages are deleted, unless
PRESERVE-OBSOLETE is non-nil.
Return a list of all performed upgrades, as a list of
`epl-upgrade' objects."
(let ((upgrades (epl-find-upgrades packages)))
(dolist (upgrade upgrades)
(epl-package-install (epl-upgrade-available upgrade) 'force)
(unless preserve-obsolete
(epl-package-delete (epl-upgrade-installed upgrade))))
upgrades))
(provide 'epl)
;;; epl.el ends here

Binary file not shown.

BIN
elpa/gnupg/pubring.kbx Normal file

Binary file not shown.

BIN
elpa/gnupg/pubring.kbx~ Normal file

Binary file not shown.

BIN
elpa/gnupg/trustdb.gpg Normal file

Binary file not shown.

View File

@@ -0,0 +1,219 @@
#!/usr/bin/env sh
## Copyright (C) 2012 ~ 2019 Thierry Volpiatto <thierry.volpiatto@gmail.com>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
## Commentary:
# Preconfigured `emacs -Q' with a basic Helm configuration.
# If TEMP env var exists, use it, otherwise declare it.
test -z "$TEMP" && TEMP="/tmp"
CONF_FILE="$TEMP/helm-cfg.el"
EMACS=emacs
TOOLBARS=-1
LOAD_PACKAGES=
usage () {
cat >&1 <<EOF
Usage: ${0##*/} [-P PATH] [--toolbars] [--load-packages pkgs] [-h] [EMACS-OPTIONS-OR-FILENAME]
-P --path Specify path to emacs
-B --toolbars Display Menu bar, scroll bar etc...
--load-packages Load specified M/Elpa packages (separate with ",")
-h Display this help and exit
Any other Emacs options or filename must come after.
Emacs options:
Initialization options:
--chdir DIR change to directory DIR
--daemon, --bg-daemon[=NAME] start a (named) server in the background
--fg-daemon[=NAME] start a (named) server in the foreground
--debug-init enable Emacs Lisp debugger for init file
--display, -d DISPLAY use X server DISPLAY
--no-build-details do not add build details such as time stamps
--no-loadup, -nl do not load loadup.el into bare Emacs
--no-site-file do not load site-start.el
--no-x-resources do not load X resources
--no-window-system, -nw do not communicate with X, ignoring $DISPLAY
--script FILE run FILE as an Emacs Lisp script
--terminal, -t DEVICE use DEVICE for terminal I/O
Action options:
FILE visit FILE
+LINE go to line LINE in next FILE
+LINE:COLUMN go to line LINE, column COLUMN, in next FILE
--directory, -L DIR prepend DIR to load-path (with :DIR, append DIR)
--file FILE visit FILE
--find-file FILE visit FILE
--funcall, -f FUNC call Emacs Lisp function FUNC with no arguments
--insert FILE insert contents of FILE into current buffer
--load, -l FILE load Emacs Lisp FILE using the load function
--visit FILE visit FILE
Display options:
--background-color, -bg COLOR window background color
--basic-display, -D disable many display features;
used for debugging Emacs
--border-color, -bd COLOR main border color
--border-width, -bw WIDTH width of main border
--color, --color=MODE override color mode for character terminals;
MODE defaults to \`auto', and
can also be \`never', \`always',
or a mode name like \`ansi8'
--cursor-color, -cr COLOR color of the Emacs cursor indicating point
--font, -fn FONT default font; must be fixed-width
--foreground-color, -fg COLOR window foreground color
--fullheight, -fh make the first frame high as the screen
--fullscreen, -fs make the first frame fullscreen
--fullwidth, -fw make the first frame wide as the screen
--maximized, -mm make the first frame maximized
--geometry, -g GEOMETRY window geometry
--iconic start Emacs in iconified state
--internal-border, -ib WIDTH width between text and main border
--line-spacing, -lsp PIXELS additional space to put between lines
--mouse-color, -ms COLOR mouse cursor color in Emacs window
--name NAME title for initial Emacs frame
--reverse-video, -r, -rv switch foreground and background
--title, -T TITLE title for initial Emacs frame
--vertical-scroll-bars, -vb enable vertical scroll bars
--xrm XRESOURCES set additional X resources
--parent-id XID set parent window
--help display this help and exit
--version output version information and exit
You can generally also specify long option names with a single -; for
example, -batch as well as --batch. You can use any unambiguous
abbreviation for a --option.
Various environment variables and window system resources also affect
the operation of Emacs. See the main documentation.
EOF
}
for a in "$@"; do
case $a in
--path | -P)
shift 1
EMACS="$1"
shift 1
;;
--toolbars | -B)
shift 1
TOOLBARS=1
;;
--load-packages)
shift 1
LOAD_PACKAGES="$1"
shift 1
;;
-h)
usage
exit 1
;;
esac
done
LOAD_PATH=$($EMACS -q -batch --eval "(prin1 load-path)")
cd "${0%/*}" || exit 1
# Check if autoload file exists.
# It may be in a different directory if emacs-helm.sh is a symlink.
TRUENAME=$(find . -samefile "$0" -printf "%l")
if [ ! -z "$TRUENAME" ]; then
AUTO_FILE="${TRUENAME%/*}/helm-autoloads.el"
else
AUTO_FILE="helm-autoloads.el"
fi
if [ ! -e "$AUTO_FILE" ]; then
echo No autoloads found, please run make first to generate autoload file
exit 1
fi
cat > $CONF_FILE <<EOF
(setq initial-scratch-message (concat initial-scratch-message
";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\\n\
;; This Emacs is Powered by \`HELM' using\\n\
;; emacs program \"$EMACS\".\\n\
;; This is a minimal \`helm' configuration to discover \`helm' or debug it.\\n\
;; You can retrieve this minimal configuration in \"$CONF_FILE\".\\n\
;;
;; Some original Emacs commands are replaced by their \`helm' counterparts:\\n\\n\
;; - \`find-file'(C-x C-f) =>\`helm-find-files'\\n\
;; - \`occur'(M-s o) =>\`helm-occur'\\n\
;; - \`list-buffers'(C-x C-b) =>\`helm-buffers-list'\\n\
;; - \`completion-at-point'(M-tab) =>\`helm-lisp-completion-at-point'[1]\\n\
;; - \`apropos-command'(C-h a) =>\`helm-apropos'\\n\
;; - \`dabbrev-expand'(M-/) =>\`helm-dabbrev'\\n\
;; - \`execute-extended-command'(M-x) =>\`helm-M-x'\\n\\n
;; Some other Emacs commands are \"helmized\" by \`helm-mode'.\\n\
;; [1] Coming with emacs-24.4, \`completion-at-point' is \"helmized\" by \`helm-mode'\\n\
;; which provides Helm completion in many places like \`shell-mode'.\\n\
;; Find context help for most Helm commands with \`C-h m'.\\n\
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\\n\\n"))
(setq load-path (quote $LOAD_PATH))
(require 'package)
;; User may be using a non standard \`package-user-dir'.
;; Modify \`package-directory-list' instead of \`package-user-dir'
;; in case the user starts Helm from a non-ELPA installation.
(unless (file-equal-p package-user-dir "~/.emacs.d/elpa")
(add-to-list 'package-directory-list (directory-file-name
(file-name-directory
(directory-file-name default-directory)))))
(let* ((str-lst "$LOAD_PACKAGES")
(load-packages (and str-lst
(not (string= str-lst ""))
(split-string str-lst ","))))
(setq package-load-list
(if (equal load-packages '("all"))
'(all)
(append '((helm-core t) (helm t) (async t) (popup t))
(mapcar (lambda (p) (list (intern p) t)) load-packages)))))
(package-initialize)
(add-to-list 'load-path (file-name-directory (file-truename "$0")))
(unless (> $TOOLBARS 0)
(setq default-frame-alist '((vertical-scroll-bars . nil)
(tool-bar-lines . 0)
(menu-bar-lines . 0)
(fullscreen . nil))))
(blink-cursor-mode -1)
(require 'helm-config)
(helm-mode 1)
(define-key global-map [remap find-file] 'helm-find-files)
(define-key global-map [remap occur] 'helm-occur)
(define-key global-map [remap list-buffers] 'helm-buffers-list)
(define-key global-map [remap dabbrev-expand] 'helm-dabbrev)
(define-key global-map [remap execute-extended-command] 'helm-M-x)
(define-key global-map [remap apropos-command] 'helm-apropos)
(unless (boundp 'completion-in-region-function)
(define-key lisp-interaction-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point)
(define-key emacs-lisp-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point))
(add-hook 'kill-emacs-hook #'(lambda () (and (file-exists-p "$CONF_FILE") (delete-file "$CONF_FILE"))))
EOF
$EMACS -Q -l "$CONF_FILE" "$@"

View File

@@ -0,0 +1,278 @@
;;; helm-adaptive.el --- Adaptive Sorting of Candidates. -*- lexical-binding: t -*-
;; Original Author: Tamas Patrovics
;; Copyright (C) 2007 Tamas Patrovics
;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto <thierry.volpiatto@gmail.com>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'cl-lib)
(require 'helm)
(defgroup helm-adapt nil
"Adaptative sorting of candidates for Helm."
:group 'helm)
(defcustom helm-adaptive-history-file
"~/.emacs.d/helm-adaptive-history"
"Path of file where history information is stored.
When nil history is not saved nor restored after emacs restart unless
you save/restore `helm-adaptive-history' with something else like
psession or desktop."
:type 'string
:group 'helm-adapt)
(defcustom helm-adaptive-history-length 50
"Maximum number of candidates stored for a source."
:type 'number
:group 'helm-adapt)
(defcustom helm-adaptive-sort-by-frequent-recent-usage t
"Try to sort on an average of frequent and recent usage when non-nil.
When nil sort on frequency usage only.
Only frequency:
When candidate have low frequency, you have to hit on it many times to
make it going up on top.
Frequency+recent:
Even with a low frequency, candidate go up on top. If a candidate
have a high frequency but it is not used since some time, it goes
down slowly, but as soon you reuse it it go up on top quickly."
:group 'helm-adapt
:type 'boolean)
;; Internal
(defvar helm-adaptive-done nil
"nil if history information is not yet stored for the current
selection.")
(defvar helm-adaptive-history nil
"Contains the stored history information.
Format: ((SOURCE-NAME (SELECTED-CANDIDATE (PATTERN . NUMBER-OF-USE) ...) ...) ...)")
(defconst helm-adaptive-freq-coefficient 5)
(defconst helm-adaptive-recent-coefficient 2)
(defun helm-adaptive-done-reset ()
(setq helm-adaptive-done nil))
;;;###autoload
(define-minor-mode helm-adaptive-mode
"Toggle adaptive sorting in all sources."
:group 'helm-adapt
:require 'helm-adaptive
:global t
(if helm-adaptive-mode
(progn
(unless helm-adaptive-history
(helm-adaptive-maybe-load-history))
(add-hook 'kill-emacs-hook 'helm-adaptive-save-history)
;; Should run at beginning of `helm-initial-setup'.
(add-hook 'helm-before-initialize-hook 'helm-adaptive-done-reset)
;; Should run at beginning of `helm-exit-minibuffer'.
(add-hook 'helm-before-action-hook 'helm-adaptive-store-selection)
;; Should run at beginning of `helm-select-action'.
(add-hook 'helm-select-action-hook 'helm-adaptive-store-selection))
(helm-adaptive-save-history)
(setq helm-adaptive-history nil)
(remove-hook 'kill-emacs-hook 'helm-adaptive-save-history)
(remove-hook 'helm-before-initialize-hook 'helm-adaptive-done-reset)
(remove-hook 'helm-before-action-hook 'helm-adaptive-store-selection)
(remove-hook 'helm-select-action-hook 'helm-adaptive-store-selection)))
(defun helm-adapt-use-adaptive-p (&optional source-name)
"Return current source only if it use adaptive history, nil otherwise."
(when helm-adaptive-mode
(let* ((source (or source-name (helm-get-current-source)))
(adapt-source (or (assoc-default 'filtered-candidate-transformer source)
(assoc-default 'candidate-transformer source))))
(if (listp adapt-source)
(and (memq 'helm-adaptive-sort adapt-source) source)
(and (eq adapt-source 'helm-adaptive-sort) source)))))
(defun helm-adaptive-store-selection ()
"Store history information for the selected candidate."
(unless helm-adaptive-done
(setq helm-adaptive-done t)
(let ((source (helm-adapt-use-adaptive-p)))
(when source
(let* ((source-name (assoc-default 'name source))
(source-info (or (assoc source-name helm-adaptive-history)
(progn
(push (list source-name) helm-adaptive-history)
(car helm-adaptive-history))))
(selection (helm-get-selection nil t))
(selection-info (progn
(setcdr source-info
(cons
(let ((found (assoc selection (cdr source-info))))
(if (not found)
;; new entry
(list selection)
;; move entry to the beginning of the
;; list, so that it doesn't get
;; trimmed when the history is
;; truncated
(setcdr source-info
(delete found (cdr source-info)))
found))
(cdr source-info)))
(cadr source-info)))
(pattern-info (progn
(setcdr selection-info
(cons
(let ((found (assoc helm-pattern (cdr selection-info))))
(if (not found)
;; new entry
(cons helm-pattern 0)
;; move entry to the beginning of the
;; list, so if two patterns used the
;; same number of times then the one
;; used last appears first in the list
(setcdr selection-info
(delete found (cdr selection-info)))
found))
(cdr selection-info)))
(cadr selection-info)))
(timestamp-info (helm-aif (assq 'timestamp (cdr selection-info))
it
(setcdr selection-info (cons (cons 'timestamp 0) (cdr selection-info)))
(cadr selection-info))))
;; Increase usage count.
(setcdr pattern-info (1+ (cdr pattern-info)))
;; Update timestamp.
(setcdr timestamp-info (float-time))
;; Truncate history if needed.
(if (> (length (cdr selection-info)) helm-adaptive-history-length)
(setcdr selection-info
(cl-subseq (cdr selection-info) 0 helm-adaptive-history-length))))))))
(defun helm-adaptive-maybe-load-history ()
"Load `helm-adaptive-history-file' which contain `helm-adaptive-history'.
Returns nil if `helm-adaptive-history-file' doesn't exist."
(when (and helm-adaptive-history-file
(file-readable-p helm-adaptive-history-file))
(load-file helm-adaptive-history-file)))
(defun helm-adaptive-save-history (&optional arg)
"Save history information to file given by `helm-adaptive-history-file'."
(interactive "p")
(when helm-adaptive-history-file
(with-temp-buffer
(insert
";; -*- mode: emacs-lisp -*-\n"
";; History entries used for helm adaptive display.\n")
(let (print-length print-level)
(prin1 `(setq helm-adaptive-history ',helm-adaptive-history)
(current-buffer)))
(insert ?\n)
(write-region (point-min) (point-max) helm-adaptive-history-file nil
(unless arg 'quiet)))))
(defun helm-adaptive-sort (candidates source)
"Sort the CANDIDATES for SOURCE by usage frequency.
This is a filtered candidate transformer you can use with the
`filtered-candidate-transformer' attribute."
(let* ((source-name (assoc-default 'name source))
(source-info (assoc source-name helm-adaptive-history)))
(if source-info
(let ((usage
;; Loop in the SOURCE entry of `helm-adaptive-history'
;; and assemble a list containing the (CANDIDATE
;; . USAGE-COUNT) pairs.
(cl-loop with cf = (if helm-adaptive-sort-by-frequent-recent-usage
helm-adaptive-freq-coefficient 1)
with cr = helm-adaptive-recent-coefficient
for (src-cand . infos) in (cdr source-info)
for count-freq = 0
for count-rec =
(helm-aif (and helm-adaptive-sort-by-frequent-recent-usage
(assq 'timestamp infos))
(* cr (+ (float-time) (cdr it)))
0)
do (cl-loop for (pattern . score) in
(remove (assq 'timestamp infos) infos)
;; If current pattern is equal to
;; the previously used one then
;; this candidate has priority
;; (that's why its count-freq is
;; boosted by 10000) and it only
;; has to compete with other
;; candidates which were also
;; selected with the same pattern.
if (equal pattern helm-pattern)
return (setq count-freq (+ 10000 score))
else do (cl-incf count-freq score))
and collect (cons src-cand (+ (* count-freq cf) count-rec))
into results
;; Sort the list in descending order, so
;; candidates with highest priority come
;; first.
finally return
(sort results (lambda (first second)
(> (cdr first) (cdr second)))))))
(if (consp usage)
;; Put those candidates first which have the highest usage count.
(cl-loop for (cand . _freq) in usage
for info = (or (and (assq 'multiline source)
(replace-regexp-in-string
"\n\\'" "" cand))
cand)
when (cl-member info candidates
:test 'helm-adaptive-compare)
collect (car it) into sorted
and do (setq candidates
(cl-remove info candidates
:test 'helm-adaptive-compare))
finally return (append sorted candidates))
(message "Your `%s' is maybe corrupted or too old, \
you should reinitialize it with `helm-reset-adaptive-history'"
helm-adaptive-history-file)
(sit-for 1)
candidates))
;; if there is no information stored for this source then do nothing
candidates)))
;;;###autoload
(defun helm-reset-adaptive-history ()
"Delete all `helm-adaptive-history' and his file.
Useful when you have a old or corrupted `helm-adaptive-history-file'."
(interactive)
(when (y-or-n-p "Really delete all your `helm-adaptive-history'? ")
(setq helm-adaptive-history nil)
(delete-file helm-adaptive-history-file)))
(defun helm-adaptive-compare (x y)
"Compare display parts if some of candidates X and Y.
Arguments X and Y are cons cell in (DISPLAY . REAL) format or atoms."
(equal (if (listp x) (car x) x)
(if (listp y) (car y) y)))
(provide 'helm-adaptive)
;; Local Variables:
;; byte-compile-warnings: (not obsolete)
;; coding: utf-8
;; indent-tabs-mode: nil
;; End:
;;; helm-adaptive.el ends here

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,737 @@
;;; helm-bookmark.el --- Helm for Emacs regular Bookmarks. -*- lexical-binding: t -*-
;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto <thierry.volpiatto@gmail.com>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'cl-lib)
(require 'bookmark)
(require 'helm)
(require 'helm-lib)
(require 'helm-help)
(require 'helm-types)
(require 'helm-utils)
(require 'helm-info)
(require 'helm-adaptive)
(require 'helm-net)
(declare-function helm-browse-project "helm-files" (arg))
(declare-function addressbook-bookmark-edit "ext:addressbook-bookmark.el" (bookmark))
(defgroup helm-bookmark nil
"Predefined configurations for `helm.el'."
:group 'helm)
(defcustom helm-bookmark-show-location nil
"Show location of bookmark on display."
:group 'helm-bookmark
:type 'boolean)
(defcustom helm-bookmark-default-filtered-sources
(append '(helm-source-bookmark-org
helm-source-bookmark-files&dirs
helm-source-bookmark-helm-find-files
helm-source-bookmark-info
helm-source-bookmark-gnus
helm-source-bookmark-man
helm-source-bookmark-images
helm-source-bookmark-w3m)
(list 'helm-source-bookmark-uncategorized
'helm-source-bookmark-set))
"List of sources to use in `helm-filtered-bookmarks'."
:group 'helm-bookmark
:type '(repeat (choice symbol)))
(defface helm-bookmark-info
'((t (:foreground "green")))
"Face used for W3m Emacs bookmarks (not w3m bookmarks)."
:group 'helm-bookmark)
(defface helm-bookmark-w3m
'((t (:foreground "yellow")))
"Face used for W3m Emacs bookmarks (not w3m bookmarks)."
:group 'helm-bookmark)
(defface helm-bookmark-gnus
'((t (:foreground "magenta")))
"Face used for Gnus bookmarks."
:group 'helm-bookmark)
(defface helm-bookmark-man
'((t (:foreground "Orange4")))
"Face used for Woman/man bookmarks."
:group 'helm-bookmark)
(defface helm-bookmark-file
'((t (:foreground "Deepskyblue2")))
"Face used for file bookmarks."
:group 'helm-bookmark)
(defface helm-bookmark-file-not-found
'((t (:foreground "Slategray4")))
"Face used for file bookmarks."
:group 'helm-bookmark)
(defface helm-bookmark-directory
'((t (:inherit helm-ff-directory)))
"Face used for file bookmarks."
:group 'helm-bookmark)
(defface helm-bookmark-addressbook
'((t (:foreground "tomato")))
"Face used for addressbook bookmarks."
:group 'helm-bookmark)
(defvar helm-bookmark-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map helm-map)
(define-key map (kbd "C-c o") 'helm-bookmark-run-jump-other-window)
(define-key map (kbd "C-c C-o") 'helm-bookmark-run-jump-other-frame)
(define-key map (kbd "C-d") 'helm-bookmark-run-delete)
(define-key map (kbd "C-]") 'helm-bookmark-toggle-filename)
(define-key map (kbd "M-e") 'helm-bookmark-run-edit)
map)
"Generic Keymap for emacs bookmark sources.")
(defclass helm-source-basic-bookmarks (helm-source-in-buffer helm-type-bookmark)
((init :initform (lambda ()
(bookmark-maybe-load-default-file)
(helm-init-candidates-in-buffer
'global
(bookmark-all-names))))
(filtered-candidate-transformer :initform 'helm-bookmark-transformer)))
(defvar helm-source-bookmarks
(helm-make-source "Bookmarks" 'helm-source-basic-bookmarks)
"See (info \"(emacs)Bookmarks\").")
(defun helm-bookmark-transformer (candidates _source)
(cl-loop for i in candidates
for loc = (bookmark-location i)
for len = (string-width i)
for trunc = (if (> len bookmark-bmenu-file-column)
(helm-substring i bookmark-bmenu-file-column)
i)
for sep = (make-string (- (+ bookmark-bmenu-file-column 2)
(length trunc))
? )
if helm-bookmark-show-location
collect (cons (concat trunc sep (if (listp loc) (car loc) loc)) i)
else collect i))
(defun helm-bookmark-toggle-filename-1 (_candidate)
(let* ((real (helm-get-selection helm-buffer))
(trunc (if (> (string-width real) bookmark-bmenu-file-column)
(helm-substring real bookmark-bmenu-file-column)
real))
(loc (bookmark-location real)))
(setq helm-bookmark-show-location (not helm-bookmark-show-location))
(helm-update (if helm-bookmark-show-location
(concat (regexp-quote trunc)
" +"
(regexp-quote
(if (listp loc) (car loc) loc)))
(regexp-quote real)))))
(defun helm-bookmark-toggle-filename ()
"Toggle bookmark location visibility."
(interactive)
(with-helm-alive-p
(helm-attrset 'toggle-filename
'(helm-bookmark-toggle-filename-1 . never-split))
(helm-execute-persistent-action 'toggle-filename)))
(put 'helm-bookmark-toggle-filename 'helm-only t)
(defun helm-bookmark-jump (candidate)
"Jump to bookmark action."
(let ((current-prefix-arg helm-current-prefix-arg)
non-essential)
(bookmark-jump candidate)))
(defun helm-bookmark-jump-other-frame (candidate)
"Jump to bookmark in other frame action."
(let ((current-prefix-arg helm-current-prefix-arg)
non-essential)
(bookmark-jump candidate 'switch-to-buffer-other-frame)))
(defun helm-bookmark-jump-other-window (candidate)
"Jump to bookmark in other window action."
(let (non-essential)
(bookmark-jump-other-window candidate)))
;;; bookmark-set
;;
(defvar helm-source-bookmark-set
(helm-build-dummy-source "Set Bookmark"
:filtered-candidate-transformer
(lambda (_candidates _source)
(list (or (and (not (string= helm-pattern ""))
helm-pattern)
"Enter a bookmark name to record")))
:action '(("Set bookmark" . (lambda (candidate)
(if (string= helm-pattern "")
(message "No bookmark name given for record")
(bookmark-set candidate))))))
"See (info \"(emacs)Bookmarks\").")
;;; Predicates
;;
(defconst helm-bookmark--non-file-filename " - no file -"
"Name to use for `filename' entry, for non-file bookmarks.")
(defun helm-bookmark-gnus-bookmark-p (bookmark)
"Return non-nil if BOOKMARK is a Gnus bookmark.
BOOKMARK is a bookmark name or a bookmark record."
(or (eq (bookmark-get-handler bookmark) 'bmkext-jump-gnus)
(eq (bookmark-get-handler bookmark) 'gnus-summary-bookmark-jump)
(eq (bookmark-get-handler bookmark) 'bookmarkp-jump-gnus)))
(defun helm-bookmark-w3m-bookmark-p (bookmark)
"Return non-nil if BOOKMARK is a W3m bookmark.
BOOKMARK is a bookmark name or a bookmark record."
(or (eq (bookmark-get-handler bookmark) 'bmkext-jump-w3m)
(eq (bookmark-get-handler bookmark) 'bookmark-w3m-bookmark-jump)
(eq (bookmark-get-handler bookmark) 'bookmarkp-jump-w3m)))
(defun helm-bookmark-woman-bookmark-p (bookmark)
"Return non-nil if BOOKMARK is a Woman bookmark.
BOOKMARK is a bookmark name or a bookmark record."
(or (eq (bookmark-get-handler bookmark) 'bmkext-jump-woman)
(eq (bookmark-get-handler bookmark) 'woman-bookmark-jump)
(eq (bookmark-get-handler bookmark) 'bookmarkp-jump-woman)))
(defun helm-bookmark-man-bookmark-p (bookmark)
"Return non-nil if BOOKMARK is a Man bookmark.
BOOKMARK is a bookmark name or a bookmark record."
(or (eq (bookmark-get-handler bookmark) 'bmkext-jump-man)
(eq (bookmark-get-handler bookmark) 'Man-bookmark-jump)
(eq (bookmark-get-handler bookmark) 'bookmarkp-jump-man)))
(defun helm-bookmark-woman-man-bookmark-p (bookmark)
"Return non-nil if BOOKMARK is a Man or Woman bookmark.
BOOKMARK is a bookmark name or a bookmark record."
(or (helm-bookmark-man-bookmark-p bookmark)
(helm-bookmark-woman-bookmark-p bookmark)))
(defun helm-bookmark-info-bookmark-p (bookmark)
"Return non-nil if BOOKMARK is an Info bookmark.
BOOKMARK is a bookmark name or a bookmark record."
(eq (bookmark-get-handler bookmark) 'Info-bookmark-jump))
(defun helm-bookmark-image-bookmark-p (bookmark)
"Return non-nil if BOOKMARK bookmarks an image file."
(if (stringp bookmark)
(assq 'image-type (assq bookmark bookmark-alist))
(assq 'image-type bookmark)))
(defun helm-bookmark-file-p (bookmark)
"Return non-nil if BOOKMARK bookmarks a file or directory.
BOOKMARK is a bookmark name or a bookmark record.
This excludes bookmarks of a more specific kind (Info, Gnus, and W3m)."
(let* ((filename (bookmark-get-filename bookmark))
(isnonfile (equal filename helm-bookmark--non-file-filename)))
(and filename (not isnonfile) (not (bookmark-get-handler bookmark)))))
(defun helm-bookmark-org-file-p (bookmark)
(let* ((filename (bookmark-get-filename bookmark)))
(or (string-suffix-p ".org" filename t)
(string-suffix-p ".org_archive" filename t))))
(defun helm-bookmark-helm-find-files-p (bookmark)
"Return non-nil if BOOKMARK bookmarks a `helm-find-files' session.
BOOKMARK is a bookmark name or a bookmark record."
(eq (bookmark-get-handler bookmark) 'helm-ff-bookmark-jump))
(defun helm-bookmark-addressbook-p (bookmark)
"Return non--nil if BOOKMARK is a contact recorded with addressbook-bookmark.
BOOKMARK is a bookmark name or a bookmark record."
(if (listp bookmark)
(string= (assoc-default 'type bookmark) "addressbook")
(string= (assoc-default
'type (assoc bookmark bookmark-alist)) "addressbook")))
(defun helm-bookmark-uncategorized-bookmark-p (bookmark)
"Return non--nil if BOOKMARK match no known category."
(cl-loop for pred in '(helm-bookmark-org-file-p
helm-bookmark-addressbook-p
helm-bookmark-gnus-bookmark-p
helm-bookmark-w3m-bookmark-p
helm-bookmark-woman-man-bookmark-p
helm-bookmark-info-bookmark-p
helm-bookmark-image-bookmark-p
helm-bookmark-file-p
helm-bookmark-helm-find-files-p
helm-bookmark-addressbook-p)
never (funcall pred bookmark)))
(defun helm-bookmark-filter-setup-alist (fn)
"Return a filtered `bookmark-alist' sorted alphabetically."
(cl-loop for b in bookmark-alist
for name = (car b)
when (funcall fn b) collect
(propertize name 'location (bookmark-location name))))
;;; Bookmark handlers
;;
(defvar w3m-async-exec)
(defun helm-bookmark-jump-w3m (bookmark)
"Jump to W3m bookmark BOOKMARK, setting a new tab.
If `browse-url-browser-function' is set to something else
than `w3m-browse-url' use it."
(require 'helm-net)
(let* ((file (or (bookmark-prop-get bookmark 'filename)
(bookmark-prop-get bookmark 'url)))
(buf (generate-new-buffer-name "*w3m*"))
(w3m-async-exec nil)
;; If user don't have anymore w3m installed let it browse its
;; bookmarks with default browser otherwise assume bookmark
;; have been bookmarked from w3m and use w3m.
(browse-url-browser-function (or (and (fboundp 'w3m-browse-url)
(executable-find "w3m")
'w3m-browse-url)
browse-url-browser-function))
(really-use-w3m (equal browse-url-browser-function 'w3m-browse-url)))
(helm-browse-url file really-use-w3m)
(when really-use-w3m
(bookmark-default-handler
`("" (buffer . ,buf) . ,(bookmark-get-bookmark-record bookmark))))))
;; All bookmarks recorded with the handler provided with w3m
;; (`bookmark-w3m-bookmark-jump') will use our handler which open
;; the bookmark in a new tab or in an external browser depending
;; on `browse-url-browser-function'.
(defalias 'bookmark-w3m-bookmark-jump 'helm-bookmark-jump-w3m)
;; Provide compatibility with old handlers provided in external
;; packages bookmark-extensions.el and bookmark+.
(defalias 'bmkext-jump-woman 'woman-bookmark-jump)
(defalias 'bmkext-jump-man 'Man-bookmark-jump)
(defalias 'bmkext-jump-w3m 'helm-bookmark-jump-w3m)
(defalias 'bmkext-jump-gnus 'gnus-summary-bookmark-jump)
(defalias 'bookmarkp-jump-gnus 'gnus-summary-bookmark-jump)
(defalias 'bookmarkp-jump-w3m 'helm-bookmark-jump-w3m)
(defalias 'bookmarkp-jump-woman 'woman-bookmark-jump)
(defalias 'bookmarkp-jump-man 'Man-bookmark-jump)
;;;; Filtered bookmark sources
;;
;;
(defclass helm-source-filtered-bookmarks (helm-source-in-buffer helm-type-bookmark)
((filtered-candidate-transformer
:initform '(helm-adaptive-sort
helm-highlight-bookmark))))
;;; W3m bookmarks.
;;
(defun helm-bookmark-w3m-setup-alist ()
"Specialized filter function for bookmarks w3m."
(helm-bookmark-filter-setup-alist 'helm-bookmark-w3m-bookmark-p))
(defvar helm-source-bookmark-w3m
(helm-make-source "Bookmark W3m" 'helm-source-filtered-bookmarks
:init (lambda ()
(bookmark-maybe-load-default-file)
(helm-init-candidates-in-buffer
'global (helm-bookmark-w3m-setup-alist)))))
;;; Images
;;
(defun helm-bookmark-images-setup-alist ()
"Specialized filter function for images bookmarks."
(helm-bookmark-filter-setup-alist 'helm-bookmark-image-bookmark-p))
(defvar helm-source-bookmark-images
(helm-make-source "Bookmark Images" 'helm-source-filtered-bookmarks
:init (lambda ()
(bookmark-maybe-load-default-file)
(helm-init-candidates-in-buffer
'global (helm-bookmark-images-setup-alist)))))
;;; Woman Man
;;
(defun helm-bookmark-man-setup-alist ()
"Specialized filter function for bookmarks w3m."
(helm-bookmark-filter-setup-alist 'helm-bookmark-woman-man-bookmark-p))
(defvar helm-source-bookmark-man
(helm-make-source "Bookmark Woman&Man" 'helm-source-filtered-bookmarks
:init (lambda ()
(bookmark-maybe-load-default-file)
(helm-init-candidates-in-buffer
'global (helm-bookmark-man-setup-alist)))))
;;; Org files
;;
(defun helm-bookmark-org-setup-alist ()
"Specialized filter function for Org file bookmarks."
(helm-bookmark-filter-setup-alist 'helm-bookmark-org-file-p))
(defvar helm-source-bookmark-org
(helm-make-source " Bookmarked Org files" 'helm-source-filtered-bookmarks
:init (lambda ()
(bookmark-maybe-load-default-file)
(helm-init-candidates-in-buffer
'global (helm-bookmark-org-setup-alist)))))
;;; Gnus
;;
(defun helm-bookmark-gnus-setup-alist ()
"Specialized filter function for bookmarks gnus."
(helm-bookmark-filter-setup-alist 'helm-bookmark-gnus-bookmark-p))
(defvar helm-source-bookmark-gnus
(helm-make-source "Bookmark Gnus" 'helm-source-filtered-bookmarks
:init (lambda ()
(bookmark-maybe-load-default-file)
(helm-init-candidates-in-buffer
'global (helm-bookmark-gnus-setup-alist)))))
;;; Info
;;
(defun helm-bookmark-info-setup-alist ()
"Specialized filter function for bookmarks info."
(helm-bookmark-filter-setup-alist 'helm-bookmark-info-bookmark-p))
(defvar helm-source-bookmark-info
(helm-make-source "Bookmark Info" 'helm-source-filtered-bookmarks
:init (lambda ()
(bookmark-maybe-load-default-file)
(helm-init-candidates-in-buffer
'global (helm-bookmark-info-setup-alist)))))
;;; Files and directories
;;
(defun helm-bookmark-local-files-setup-alist ()
"Specialized filter function for bookmarks locals files."
(helm-bookmark-filter-setup-alist 'helm-bookmark-file-p))
(defvar helm-source-bookmark-files&dirs
(helm-make-source "Bookmark Files&Directories" 'helm-source-filtered-bookmarks
:init (lambda ()
(bookmark-maybe-load-default-file)
(helm-init-candidates-in-buffer
'global (helm-bookmark-local-files-setup-alist)))))
;;; Helm find files sessions.
;;
(defun helm-bookmark-helm-find-files-setup-alist ()
"Specialized filter function for `helm-find-files' bookmarks."
(helm-bookmark-filter-setup-alist 'helm-bookmark-helm-find-files-p))
(defun helm-bookmark-browse-project (candidate)
"Run `helm-browse-project' from action."
(with-helm-default-directory
(bookmark-get-filename candidate)
(helm-browse-project nil)))
(defun helm-bookmark-run-browse-project ()
"Run `helm-bookmark-browse-project' from keyboard."
(interactive)
(with-helm-alive-p
(helm-exit-and-execute-action 'helm-bookmark-browse-project)))
(put 'helm-bookmark-run-browse-project 'helm-only t)
(defvar helm-bookmark-find-files-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map helm-bookmark-map)
(define-key map (kbd "C-x C-d") 'helm-bookmark-run-browse-project)
map))
(defclass helm-bookmark-override-inheritor (helm-source) ())
(defmethod helm--setup-source ((source helm-bookmark-override-inheritor))
;; Ensure `helm-source-in-buffer' method is called.
(call-next-method)
(setf (slot-value source 'action)
(helm-append-at-nth
(cl-loop for (name . action) in helm-type-bookmark-actions
unless (memq action '(helm-bookmark-jump-other-frame
helm-bookmark-jump-other-window))
collect (cons name action))
'(("Browse project" . helm-bookmark-browse-project)) 1))
(setf (slot-value source 'keymap) helm-bookmark-find-files-map))
(defclass helm-bookmark-find-files-class (helm-source-filtered-bookmarks
helm-bookmark-override-inheritor)
())
(defvar helm-source-bookmark-helm-find-files
(helm-make-source "Bookmark helm-find-files sessions" 'helm-bookmark-find-files-class
:init (lambda ()
(bookmark-maybe-load-default-file)
(helm-init-candidates-in-buffer
'global (helm-bookmark-helm-find-files-setup-alist)))
:persistent-action (lambda (_candidate) (ignore))
:persistent-help "Do nothing"))
;;; Uncategorized bookmarks
;;
(defun helm-bookmark-uncategorized-setup-alist ()
"Specialized filter function for uncategorized bookmarks."
(helm-bookmark-filter-setup-alist 'helm-bookmark-uncategorized-bookmark-p))
(defvar helm-source-bookmark-uncategorized
(helm-make-source "Bookmark uncategorized" 'helm-source-filtered-bookmarks
:init (lambda ()
(bookmark-maybe-load-default-file)
(helm-init-candidates-in-buffer
'global (helm-bookmark-uncategorized-setup-alist)))))
;;; Transformer
;;
(defun helm-highlight-bookmark (bookmarks _source)
"Used as `filtered-candidate-transformer' to colorize bookmarks."
(let ((non-essential t))
(cl-loop for i in bookmarks
for isfile = (bookmark-get-filename i)
for hff = (helm-bookmark-helm-find-files-p i)
for handlerp = (and (fboundp 'bookmark-get-handler)
(bookmark-get-handler i))
for isw3m = (and (fboundp 'helm-bookmark-w3m-bookmark-p)
(helm-bookmark-w3m-bookmark-p i))
for isgnus = (and (fboundp 'helm-bookmark-gnus-bookmark-p)
(helm-bookmark-gnus-bookmark-p i))
for isman = (and (fboundp 'helm-bookmark-man-bookmark-p) ; Man
(helm-bookmark-man-bookmark-p i))
for iswoman = (and (fboundp 'helm-bookmark-woman-bookmark-p) ; Woman
(helm-bookmark-woman-bookmark-p i))
for isannotation = (bookmark-get-annotation i)
for isabook = (string= (bookmark-prop-get i 'type)
"addressbook")
for isinfo = (eq handlerp 'Info-bookmark-jump)
for loc = (bookmark-location i)
for len = (string-width i)
for trunc = (if (and helm-bookmark-show-location
(> len bookmark-bmenu-file-column))
(helm-substring
i bookmark-bmenu-file-column)
i)
;; Add a * if bookmark have annotation
if (and isannotation (not (string-equal isannotation "")))
do (setq trunc (concat "*" (if helm-bookmark-show-location trunc i)))
for sep = (and helm-bookmark-show-location
(make-string (- (+ bookmark-bmenu-file-column 2)
(string-width trunc))
? ))
for bmk = (cond ( ;; info buffers
isinfo
(propertize trunc 'face 'helm-bookmark-info
'help-echo isfile))
( ;; w3m buffers
isw3m
(propertize trunc 'face 'helm-bookmark-w3m
'help-echo isfile))
( ;; gnus buffers
isgnus
(propertize trunc 'face 'helm-bookmark-gnus
'help-echo isfile))
( ;; Man Woman
(or iswoman isman)
(propertize trunc 'face 'helm-bookmark-man
'help-echo isfile))
( ;; Addressbook
isabook
(propertize trunc 'face 'helm-bookmark-addressbook))
(;; Directories (helm-find-files)
hff
(if (and (file-remote-p isfile)
(not (file-remote-p isfile nil t)))
(propertize trunc 'face 'helm-bookmark-file-not-found
'help-echo isfile)
(propertize trunc 'face 'helm-bookmark-directory
'help-echo isfile)))
( ;; Directories (dired)
(and isfile
;; This is needed because `non-essential'
;; is not working on Emacs-24.2 and the behavior
;; of tramp seems to have changed since previous
;; versions (Need to reenter password even if a
;; first connection have been established,
;; probably when host is named differently
;; i.e machine/localhost)
(and (not (file-remote-p isfile))
(file-directory-p isfile)))
(propertize trunc 'face 'helm-bookmark-directory
'help-echo isfile))
( ;; Non existing files.
(and isfile
;; Be safe and call `file-exists-p'
;; only if file is not remote or
;; remote but connected.
(or (and (file-remote-p isfile)
(not (file-remote-p isfile nil t)))
(not (file-exists-p isfile))))
(propertize trunc 'face 'helm-bookmark-file-not-found
'help-echo isfile))
( ;; regular files
t
(propertize trunc 'face 'helm-bookmark-file
'help-echo isfile)))
collect (if helm-bookmark-show-location
(cons (concat bmk sep (if (listp loc) (car loc) loc))
i)
(cons bmk i)))))
;;; Edit/rename/save bookmarks.
;;
;;
(defun helm-bookmark-edit-bookmark (bookmark-name)
"Edit bookmark's name and file name, and maybe save them.
BOOKMARK-NAME is the current (old) name of the bookmark to be renamed."
(let ((bmk (helm-bookmark-get-bookmark-from-name bookmark-name))
(handler (bookmark-prop-get bookmark-name 'handler)))
(if (eq handler 'addressbook-bookmark-jump)
(addressbook-bookmark-edit
(assoc bmk bookmark-alist))
(helm-bookmark-edit-bookmark-1 bookmark-name handler))))
(defun helm-bookmark-edit-bookmark-1 (bookmark-name handler)
(let* ((helm--reading-passwd-or-string t)
(bookmark-fname (bookmark-get-filename bookmark-name))
(bookmark-loc (bookmark-prop-get bookmark-name 'location))
(new-name (read-from-minibuffer "Name: " bookmark-name))
(new-loc (read-from-minibuffer "FileName or Location: "
(or bookmark-fname
(if (consp bookmark-loc)
(car bookmark-loc)
bookmark-loc))))
(docid (and (eq handler 'mu4e-bookmark-jump)
(read-number "Docid: " (cdr bookmark-loc)))))
(when docid
(setq new-loc (cons new-loc docid)))
(when (and (not (equal new-name "")) (not (equal new-loc ""))
(y-or-n-p "Save changes? "))
(if bookmark-fname
(progn
(helm-bookmark-rename bookmark-name new-name 'batch)
(bookmark-set-filename new-name new-loc))
(bookmark-prop-set
(bookmark-get-bookmark bookmark-name) 'location new-loc)
(helm-bookmark-rename bookmark-name new-name 'batch))
(helm-bookmark-maybe-save-bookmark)
(list new-name new-loc))))
(defun helm-bookmark-maybe-save-bookmark ()
"Increment save counter and maybe save `bookmark-alist'."
(setq bookmark-alist-modification-count (1+ bookmark-alist-modification-count))
(when (bookmark-time-to-save-p) (bookmark-save)))
(defun helm-bookmark-rename (old &optional new batch)
"Change bookmark's name from OLD to NEW.
Interactively:
If called from the keyboard, then prompt for OLD.
If called from the menubar, select OLD from a menu.
If NEW is nil, then prompt for its string value.
If BATCH is non-nil, then do not rebuild the menu list.
While the user enters the new name, repeated `C-w' inserts consecutive
words from the buffer into the new bookmark name."
(interactive (list (bookmark-completing-read "Old bookmark name")))
(bookmark-maybe-historicize-string old)
(bookmark-maybe-load-default-file)
(save-excursion (skip-chars-forward " ") (setq bookmark-yank-point (point)))
(setq bookmark-current-buffer (current-buffer))
(let ((newname (or new (read-from-minibuffer
"New name: " nil
(let ((now-map (copy-keymap minibuffer-local-map)))
(define-key now-map "\C-w" 'bookmark-yank-word)
now-map)
nil 'bookmark-history))))
(bookmark-set-name old newname)
(setq bookmark-current-bookmark newname)
(unless batch (bookmark-bmenu-surreptitiously-rebuild-list))
(helm-bookmark-maybe-save-bookmark) newname))
(defun helm-bookmark-run-edit ()
"Run `helm-bookmark-edit-bookmark' from keyboard."
(interactive)
(with-helm-alive-p
(helm-exit-and-execute-action 'helm-bookmark-edit-bookmark)))
(put 'helm-bookmark-run-edit 'helm-only t)
(defun helm-bookmark-run-jump-other-frame ()
"Jump to bookmark other frame from keyboard."
(interactive)
(with-helm-alive-p
(helm-exit-and-execute-action 'helm-bookmark-jump-other-frame)))
(put 'helm-bookmark-run-jump-other-frame 'helm-only t)
(defun helm-bookmark-run-jump-other-window ()
"Jump to bookmark from keyboard."
(interactive)
(with-helm-alive-p
(helm-exit-and-execute-action 'helm-bookmark-jump-other-window)))
(put 'helm-bookmark-run-jump-other-window 'helm-only t)
(defun helm-bookmark-run-delete ()
"Delete bookmark from keyboard."
(interactive)
(with-helm-alive-p
(when (y-or-n-p "Delete bookmark(s)?")
(helm-exit-and-execute-action 'helm-delete-marked-bookmarks))))
(put 'helm-bookmark-run-delete 'helm-only t)
(defun helm-bookmark-get-bookmark-from-name (bmk)
"Return bookmark name even if it is a bookmark with annotation.
e.g prepended with *."
(let ((bookmark (replace-regexp-in-string "\\`\\*" "" bmk)))
(if (assoc bookmark bookmark-alist) bookmark bmk)))
(defun helm-delete-marked-bookmarks (_ignore)
"Delete this bookmark or all marked bookmarks."
(cl-dolist (i (helm-marked-candidates))
(bookmark-delete (helm-bookmark-get-bookmark-from-name i)
'batch)))
;;;###autoload
(defun helm-bookmarks ()
"Preconfigured `helm' for bookmarks."
(interactive)
(helm :sources '(helm-source-bookmarks
helm-source-bookmark-set)
:buffer "*helm bookmarks*"
:default (buffer-name helm-current-buffer)))
;;;###autoload
(defun helm-filtered-bookmarks ()
"Preconfigured helm for bookmarks (filtered by category).
Optional source `helm-source-bookmark-addressbook' is loaded
only if external addressbook-bookmark package is installed."
(interactive)
(helm :sources helm-bookmark-default-filtered-sources
:prompt "Search Bookmark: "
:buffer "*helm filtered bookmarks*"
:default (list (thing-at-point 'symbol)
(buffer-name helm-current-buffer))))
(provide 'helm-bookmark)
;; Local Variables:
;; byte-compile-warnings: (not obsolete)
;; coding: utf-8
;; indent-tabs-mode: nil
;; End:
;;; helm-bookmark.el ends here

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -0,0 +1,170 @@
;;; helm-color.el --- colors and faces -*- lexical-binding: t -*-
;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto <thierry.volpiatto@gmail.com>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'cl-lib)
(require 'helm)
(require 'helm-help)
(require 'helm-elisp)
;;; Customize Face
;;
;;
(defun helm-custom-faces-init ()
"Initialize buffer for `helm-source-customize-face'."
(unless (helm-candidate-buffer)
(save-selected-window
(list-faces-display)
(message nil))
(helm-init-candidates-in-buffer
'global
(with-current-buffer (get-buffer "*Faces*")
(buffer-substring
(next-single-char-property-change (point-min) 'face)
(point-max))))
(kill-buffer "*Faces*")))
(defvar helm-source-customize-face
(helm-build-in-buffer-source "Customize Face"
:init 'helm-custom-faces-init
:get-line 'buffer-substring
:persistent-action (lambda (candidate)
(helm-elisp--persistent-help
(intern (car (split-string candidate)))
'helm-describe-face))
:persistent-help "Describe face"
:action '(("Customize"
. (lambda (line)
(customize-face (intern (car (split-string line))))))
("Copy name"
. (lambda (line)
(kill-new (car (split-string line " " t)))))))
"See (info \"(emacs)Faces\")")
;;; Colors browser
;;
;;
(defun helm-colors-init ()
(unless (helm-candidate-buffer)
(save-selected-window
(list-colors-display)
(message nil))
(helm-init-candidates-in-buffer
'global
(with-current-buffer (get-buffer "*Colors*")
(buffer-string)))
(kill-buffer "*Colors*")))
(defun helm-color-insert-name (candidate)
(with-helm-current-buffer
(insert (helm-colors-get-name candidate))))
(defun helm-color-kill-name (candidate)
(kill-new (helm-colors-get-name candidate)))
(defun helm-color-insert-rgb (candidate)
(with-helm-current-buffer
(insert (helm-colors-get-rgb candidate))))
(defun helm-color-kill-rgb (candidate)
(kill-new (helm-colors-get-rgb candidate)))
(defun helm-color-run-insert-name ()
"Insert name of color from `helm-source-colors'"
(interactive)
(with-helm-alive-p (helm-exit-and-execute-action 'helm-color-insert-name)))
(put 'helm-color-run-insert-name 'helm-only t)
(defun helm-color-run-kill-name ()
"Kill name of color from `helm-source-colors'"
(interactive)
(with-helm-alive-p (helm-exit-and-execute-action 'helm-color-kill-name)))
(put 'helm-color-run-kill-name 'helm-only t)
(defun helm-color-run-insert-rgb ()
"Insert RGB of color from `helm-source-colors'"
(interactive)
(with-helm-alive-p (helm-exit-and-execute-action 'helm-color-insert-rgb)))
(put 'helm-color-run-insert-rgb 'helm-only t)
(defun helm-color-run-kill-rgb ()
"Kill RGB of color from `helm-source-colors'"
(interactive)
(with-helm-alive-p (helm-exit-and-execute-action 'helm-color-kill-rgb)))
(put 'helm-color-run-kill-rgb 'helm-only t)
(defvar helm-color-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map helm-map)
(define-key map (kbd "C-c n") 'helm-color-run-insert-name)
(define-key map (kbd "C-c N") 'helm-color-run-kill-name)
(define-key map (kbd "C-c r") 'helm-color-run-insert-rgb)
(define-key map (kbd "C-c R") 'helm-color-run-kill-rgb)
map))
(defvar helm-source-colors
(helm-build-in-buffer-source "Colors"
:init 'helm-colors-init
:get-line 'buffer-substring
:keymap helm-color-map
:persistent-help "Kill entry in RGB format."
:persistent-action 'helm-color-kill-rgb
:help-message 'helm-colors-help-message
:action
'(("Copy Name (C-c N)" . helm-color-kill-name)
("Copy RGB (C-c R)" . helm-color-kill-rgb)
("Insert Name (C-c n)" . helm-color-insert-name)
("Insert RGB (C-c r)" . helm-color-insert-rgb))))
(defun helm-colors-get-name (candidate)
"Get color name."
(replace-regexp-in-string
" " ""
(with-temp-buffer
(insert (capitalize candidate))
(goto-char (point-min))
(search-forward-regexp "\\s-\\{2,\\}")
(delete-region (point) (point-max))
(buffer-string))))
(defun helm-colors-get-rgb (candidate)
"Get color RGB."
(replace-regexp-in-string
" " ""
(with-temp-buffer
(insert (capitalize candidate))
(goto-char (point-max))
(search-backward-regexp "\\s-\\{2,\\}")
(delete-region (point) (point-min))
(buffer-string))))
;;;###autoload
(defun helm-colors ()
"Preconfigured `helm' for color."
(interactive)
(helm :sources '(helm-source-colors helm-source-customize-face)
:buffer "*helm colors*"))
(provide 'helm-color)
;; Local Variables:
;; byte-compile-warnings: (not obsolete)
;; coding: utf-8
;; indent-tabs-mode: nil
;; End:
;;; helm-color.el ends here

Binary file not shown.

View File

@@ -0,0 +1,219 @@
;;; helm-comint.el --- Comint prompt navigation for helm. -*- lexical-binding: t -*-
;; Copyright (C) 2019 Pierre Neidhardt <mail@ambrevar.xyz>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; You can bind this as follows in .emacs:
;;
;; (add-hook 'comint-mode-hook
;; (lambda ()
;; (define-key comint-mode-map (kbd "M-s f") 'helm-comint-prompts-all)))
;;; Code:
(require 'cl-lib)
(require 'helm)
(require 'helm-lib)
(require 'helm-help)
(require 'helm-elisp)
;;; Comint prompts
;;
(defface helm-comint-prompts-promptidx
'((t (:foreground "cyan")))
"Face used to highlight comint prompt index."
:group 'helm-comint-faces)
(defface helm-comint-prompts-buffer-name
'((t (:foreground "green")))
"Face used to highlight comint buffer name."
:group 'helm-comint-faces)
(defcustom helm-comint-prompts-promptidx-p t
"Show prompt number."
:group 'helm-comint
:type 'boolean)
(defcustom helm-comint-mode-list '(comint-mode slime-repl-mode)
"Supported modes for prompt navigation.
Derived modes (e.g. Geiser's REPL) are automatically supported."
:group 'helm-comint
:type '(repeat (choice symbol)))
(defcustom helm-comint-max-offset 400
"Max number of chars displayed per candidate in comint-input-ring browser.
When `t', don't truncate candidate, show all.
By default it is approximatively the number of bits contained in five lines
of 80 chars each i.e 80*5.
Note that if you set this to nil multiline will be disabled, i.e you
will not have anymore separators between candidates."
:type '(choice (const :tag "Disabled" t)
(integer :tag "Max candidate offset"))
:group 'helm-misc)
(defvar helm-comint-prompts-keymap
(let ((map (make-sparse-keymap)))
(set-keymap-parent map helm-map)
(define-key map (kbd "C-c o") 'helm-comint-prompts-other-window)
(define-key map (kbd "C-c C-o") 'helm-comint-prompts-other-frame)
map)
"Keymap for `helm-comint-prompt-all'.")
(defun helm-comint-prompts-list (mode &optional buffer)
"List the prompts in BUFFER in mode MODE.
Return a list of (\"prompt\" (point) (buffer-name) prompt-index))
e.g. (\"ls\" 162 \"*shell*\" 3).
If BUFFER is nil, use current buffer."
(with-current-buffer (or buffer (current-buffer))
(when (derived-mode-p mode)
(save-excursion
(goto-char (point-min))
(let (result (count 1))
(save-mark-and-excursion
(helm-awhile (and (not (eobp)) (comint-next-prompt 1))
(push (list (buffer-substring-no-properties
it (point-at-eol))
it (buffer-name) count)
result)
(setq count (1+ count))))
(nreverse result))))))
(defun helm-comint-prompts-list-all (mode)
"List the prompts of all buffers in mode MODE.
See `helm-comint-prompts-list'."
(cl-loop for b in (buffer-list)
append (helm-comint-prompts-list mode b)))
(defun helm-comint-prompts-transformer (candidates &optional all)
;; ("ls" 162 "*shell*" 3) => ("*shell*:3:ls" . ("ls" 162 "*shell*" 3))
(cl-loop for (prt pos buf id) in candidates
collect `(,(concat
(when all
(concat (propertize
buf
'face 'helm-comint-prompts-buffer-name)
":"))
(when helm-comint-prompts-promptidx-p
(concat (propertize
(number-to-string id)
'face 'helm-comint-prompts-promptidx)
":"))
prt)
. ,(list prt pos buf id))))
(defun helm-comint-prompts-all-transformer (candidates)
(helm-comint-prompts-transformer candidates t))
(cl-defun helm-comint-prompts-goto (candidate &optional (action 'switch-to-buffer))
;; Candidate format: ("ls" 162 "*shell*" 3)
(let ((buf (nth 2 candidate)))
(unless (and (string= (buffer-name) buf)
(eq action 'switch-to-buffer))
(funcall action buf))
(goto-char (nth 1 candidate))
(recenter)))
(defun helm-comint-prompts-goto-other-window (candidate)
(helm-comint-prompts-goto candidate 'switch-to-buffer-other-window))
(defun helm-comint-prompts-goto-other-frame (candidate)
(helm-comint-prompts-goto candidate 'switch-to-buffer-other-frame))
(defun helm-comint-prompts-other-window ()
(interactive)
(with-helm-alive-p
(helm-exit-and-execute-action 'helm-comint-prompts-goto-other-window)))
(put 'helm-comint-prompts-other-window 'helm-only t)
(defun helm-comint-prompts-other-frame ()
(interactive)
(with-helm-alive-p
(helm-exit-and-execute-action 'helm-comint-prompts-goto-other-frame)))
(put 'helm-comint-prompts-other-frame 'helm-only t)
;;;###autoload
(defun helm-comint-prompts ()
"Pre-configured `helm' to browse the prompts of the current comint buffer."
(interactive)
(if (apply 'derived-mode-p helm-comint-mode-list)
(helm :sources
(helm-build-sync-source "Comint prompts"
:candidates (helm-comint-prompts-list major-mode)
:candidate-transformer 'helm-comint-prompts-transformer
:action '(("Go to prompt" . helm-comint-prompts-goto)))
:buffer "*helm comint prompts*")
(message "Current buffer is not a comint buffer")))
;;;###autoload
(defun helm-comint-prompts-all ()
"Pre-configured `helm' to browse the prompts of all comint sessions."
(interactive)
(if (apply 'derived-mode-p helm-comint-mode-list)
(helm :sources
(helm-build-sync-source "All comint prompts"
:candidates (helm-comint-prompts-list-all major-mode)
:candidate-transformer 'helm-comint-prompts-all-transformer
:action (quote (("Go to prompt" . helm-comint-prompts-goto)
("Go to prompt in other window `C-c o`" .
helm-comint-prompts-goto-other-window)
("Go to prompt in other frame `C-c C-o`" .
helm-comint-prompts-goto-other-frame)))
:keymap helm-comint-prompts-keymap)
:buffer "*helm comint all prompts*")
(message "Current buffer is not a comint buffer")))
;;; Comint history
;;
;;
(defun helm-comint-input-ring-action (candidate)
"Default action for comint history."
(with-helm-current-buffer
(delete-region (comint-line-beginning-position) (point-max))
(insert candidate)))
(defvar helm-source-comint-input-ring
(helm-build-sync-source "Comint history"
:candidates (lambda ()
(with-helm-current-buffer
(cl-loop for elm in (ring-elements comint-input-ring)
unless (string= elm "")
collect elm)))
:action 'helm-comint-input-ring-action
;; Multiline does not work for `shell' because of an Emacs bug.
;; It works in other REPLs like Geiser.
:multiline 'helm-comint-max-offset)
"Source that provides Helm completion against `comint-input-ring'.")
;;;###autoload
(defun helm-comint-input-ring ()
"Preconfigured `helm' that provide completion of `comint' history."
(interactive)
(when (derived-mode-p 'comint-mode)
(helm :sources 'helm-source-comint-input-ring
:input (buffer-substring-no-properties (comint-line-beginning-position)
(point-at-eol))
:buffer "*helm comint history*")))
(provide 'helm-comint)
;; Local Variables:
;; byte-compile-warnings: (not obsolete)
;; coding: utf-8
;; indent-tabs-mode: nil
;; End:
;;; helm-comint.el ends here

Binary file not shown.

View File

@@ -0,0 +1,308 @@
;;; helm-command.el --- Helm execute-exended-command. -*- lexical-binding: t -*-
;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto <thierry.volpiatto@gmail.com>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'cl-lib)
(require 'helm)
(require 'helm-help)
(require 'helm-mode)
(require 'helm-elisp)
(defgroup helm-command nil
"Emacs command related Applications and libraries for Helm."
:group 'helm)
(defcustom helm-M-x-requires-pattern 0
"Value of requires-pattern for `helm-M-x'.
Show all candidates on startup when 0 (default)."
:group 'helm-command
:type 'boolean)
(defcustom helm-M-x-always-save-history nil
"`helm-M-x' Save command in `extended-command-history' even when it fail."
:group 'helm-command
:type 'boolean)
(defcustom helm-M-x-reverse-history nil
"The history source of `helm-M-x' appear in second position when non--nil."
:group 'helm-command
:type 'boolean)
(defcustom helm-M-x-fuzzy-match nil
"Enable fuzzy matching in `helm-M-x' when non--nil."
:group 'helm-command
:type 'boolean)
(defcustom helm-M-x-default-sort-fn #'helm-M-x-fuzzy-sort-candidates
"Default sort function for `helm-M-x'.
It should sort against REAL value of candidates.
It is used only when `helm-M-x-fuzzy-match' is enabled."
:group 'helm-command
:type 'function)
;;; Faces
;;
;;
(defgroup helm-command-faces nil
"Customize the appearance of helm-command."
:prefix "helm-"
:group 'helm-command
:group 'helm-faces)
(defface helm-M-x-key '((t (:foreground "orange" :underline t)))
"Face used in helm-M-x to show keybinding."
:group 'helm-command-faces)
(defvar helm-M-x-input-history nil)
(defvar helm-M-x-prefix-argument nil
"Prefix argument before calling `helm-M-x'.")
(defun helm-M-x-get-major-mode-command-alist (mode-map)
"Return alist of MODE-MAP."
(when mode-map
(cl-loop for key being the key-seqs of mode-map using (key-bindings com)
for str-key = (key-description key)
for ismenu = (string-match "<menu-bar>" str-key)
unless ismenu collect (cons str-key com))))
(defun helm-get-mode-map-from-mode (mode)
"Guess the mode-map name according to MODE.
Some modes don't use conventional mode-map name
so we need to guess mode-map name. e.g python-mode ==> py-mode-map.
Return nil if no mode-map found."
(cl-loop ;; Start with a conventional mode-map name.
with mode-map = (intern-soft (format "%s-map" mode))
with mode-string = (symbol-name mode)
with mode-name = (replace-regexp-in-string "-mode" "" mode-string)
while (not mode-map)
for count downfrom (length mode-name)
;; Return when no result after parsing entire string.
when (eq count 0) return nil
for sub-name = (substring mode-name 0 count)
do (setq mode-map (intern-soft (format "%s-map" (concat sub-name "-mode"))))
finally return mode-map))
(defun helm-M-x-current-mode-map-alist ()
"Return mode-map alist of current `major-mode'."
(let ((map-sym (helm-get-mode-map-from-mode major-mode)))
(when (and map-sym (boundp map-sym))
(helm-M-x-get-major-mode-command-alist (symbol-value map-sym)))))
(defun helm-M-x-transformer-1 (candidates &optional sort)
"Transformer function to show bindings in emacs commands.
Show global bindings and local bindings according to current `major-mode'.
If SORT is non nil sort list with `helm-generic-sort-fn'.
Note that SORT should not be used when fuzzy matching because
fuzzy matching is running its own sort function with a different algorithm."
(with-helm-current-buffer
(cl-loop with local-map = (helm-M-x-current-mode-map-alist)
for cand in candidates
for local-key = (car (rassq cand local-map))
for key = (substitute-command-keys (format "\\[%s]" cand))
unless (get (intern (if (consp cand) (car cand) cand)) 'helm-only)
collect
(cons (cond ((and (string-match "^M-x" key) local-key)
(format "%s (%s)"
cand (propertize
local-key
'face 'helm-M-x-key)))
((string-match "^M-x" key) cand)
(t (format "%s (%s)"
cand (propertize
key
'face 'helm-M-x-key))))
cand)
into ls
finally return
(if sort (sort ls #'helm-generic-sort-fn) ls))))
(defun helm-M-x-transformer (candidates _source)
"Transformer function for `helm-M-x' candidates."
(helm-M-x-transformer-1 candidates (null helm--in-fuzzy)))
(defun helm-M-x-transformer-hist (candidates _source)
"Transformer function for `helm-M-x' candidates."
(helm-M-x-transformer-1 candidates))
(defun helm-M-x--notify-prefix-arg ()
;; Notify a prefix-arg set AFTER calling M-x.
(when prefix-arg
(with-helm-window
(helm-display-mode-line (helm-get-current-source) 'force))))
(defun helm-cmd--get-current-function-name ()
(save-excursion
(beginning-of-defun)
(cadr (split-string (buffer-substring-no-properties
(point-at-bol) (point-at-eol))))))
(defun helm-cmd--get-preconfigured-commands (&optional dir)
(let* ((helm-dir (or dir (helm-basedir (locate-library "helm"))))
(helm-autoload-file (expand-file-name "helm-autoloads.el" helm-dir))
results)
(when (file-exists-p helm-autoload-file)
(with-temp-buffer
(insert-file-contents helm-autoload-file)
(while (re-search-forward "Preconfigured" nil t)
(push (substring (helm-cmd--get-current-function-name) 1) results))))
results))
(defvar helm-M-x-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map helm-comp-read-map)
(define-key map (kbd "C-u") nil)
(define-key map (kbd "C-u") 'helm-M-x-universal-argument)
map))
(defun helm-M-x-universal-argument ()
"Same as `universal-argument' but for `helm-M-x'."
(interactive)
(if helm-M-x-prefix-argument
(progn (setq helm-M-x-prefix-argument nil)
(let ((inhibit-read-only t))
(with-selected-window (minibuffer-window)
(save-excursion
(goto-char (point-min))
(delete-char (- (minibuffer-prompt-width) (length "M-x "))))))
(message "Initial prefix arg disabled"))
(setq prefix-arg (list 4))
(universal-argument--mode)))
(put 'helm-M-x-universal-argument 'helm-only t)
(defun helm-M-x-fuzzy-sort-candidates (candidates _source)
(helm-fuzzy-matching-default-sort-fn-1 candidates t))
(defun helm-M-x-read-extended-command (&optional collection history)
"Read command name to invoke in `helm-M-x'.
Helm completion is not provided when executing or defining
kbd macros.
Optional arg COLLECTION is to allow using another COLLECTION
than the default which is OBARRAY."
(if (or defining-kbd-macro executing-kbd-macro)
(if helm-mode
(unwind-protect
(progn
(helm-mode -1)
(read-extended-command))
(helm-mode 1))
(read-extended-command))
(let* ((helm-fuzzy-sort-fn helm-M-x-default-sort-fn)
(helm--mode-line-display-prefarg t)
(tm (run-at-time 1 0.1 'helm-M-x--notify-prefix-arg))
(helm-move-selection-after-hook
(cons (lambda () (setq current-prefix-arg nil))
helm-move-selection-after-hook)))
(setq extended-command-history
(cl-loop for c in extended-command-history
when (and c (commandp (intern c)))
do (set-text-properties 0 (length c) nil c)
and collect c))
(unwind-protect
(progn
(setq current-prefix-arg nil)
(helm-comp-read
(concat (cond
((eq helm-M-x-prefix-argument '-) "- ")
((and (consp helm-M-x-prefix-argument)
(eq (car helm-M-x-prefix-argument) 4)) "C-u ")
((and (consp helm-M-x-prefix-argument)
(integerp (car helm-M-x-prefix-argument)))
(format "%d " (car helm-M-x-prefix-argument)))
((integerp helm-M-x-prefix-argument)
(format "%d " helm-M-x-prefix-argument)))
"M-x ")
(or collection obarray)
:test 'commandp
:requires-pattern helm-M-x-requires-pattern
:name "Emacs Commands"
:buffer "*helm M-x*"
:persistent-action (lambda (candidate)
(helm-elisp--persistent-help
candidate 'helm-describe-function))
:persistent-help "Describe this command"
:history (or history extended-command-history)
:reverse-history helm-M-x-reverse-history
:input-history 'helm-M-x-input-history
:del-input nil
:help-message 'helm-M-x-help-message
:group 'helm-command
:keymap helm-M-x-map
:must-match t
:match-part (lambda (c) (car (split-string c)))
:fuzzy helm-M-x-fuzzy-match
:nomark t
:candidates-in-buffer t
:fc-transformer 'helm-M-x-transformer
:hist-fc-transformer 'helm-M-x-transformer-hist))
(cancel-timer tm)
(setq helm--mode-line-display-prefarg nil)))))
;;;###autoload
(defun helm-M-x (_arg &optional command-name)
"Preconfigured `helm' for Emacs commands.
It is `helm' replacement of regular `M-x' `execute-extended-command'.
Unlike regular `M-x' emacs vanilla `execute-extended-command' command,
the prefix args if needed, can be passed AFTER starting `helm-M-x'.
When a prefix arg is passed BEFORE starting `helm-M-x', the first `C-u'
while in `helm-M-x' session will disable it.
You can get help on each command by persistent action."
(interactive
(progn
(setq helm-M-x-prefix-argument current-prefix-arg)
(list current-prefix-arg (helm-M-x-read-extended-command))))
(when (stringp command-name)
(unless (string= command-name "")
(let ((sym-com (and (stringp command-name) (intern-soft command-name))))
(when sym-com
;; Avoid having `this-command' set to *exit-minibuffer.
(setq this-command sym-com
;; Handle C-x z (repeat) Issue #322
real-this-command sym-com)
;; If helm-M-x is called with regular emacs completion (kmacro)
;; use the value of arg otherwise use helm-current-prefix-arg.
(let ((prefix-arg (or helm-current-prefix-arg helm-M-x-prefix-argument)))
(cl-flet ((save-hist (command)
(setq extended-command-history
(cons command (delete command extended-command-history)))))
(condition-case-unless-debug err
(progn
(command-execute sym-com 'record)
(save-hist command-name))
(error
(when helm-M-x-always-save-history
(save-hist command-name))
(signal (car err) (cdr err)))))))))))
(put 'helm-M-x 'interactive-only 'command-execute)
(provide 'helm-command)
;; Local Variables:
;; byte-compile-warnings: (not obsolete)
;; coding: utf-8
;; indent-tabs-mode: nil
;; End:
;;; helm-command.el ends here

Binary file not shown.

View File

@@ -0,0 +1,172 @@
;;; helm-config.el --- Applications library for `helm.el' -*- lexical-binding: t -*-
;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto <thierry.volpiatto@gmail.com>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
;;; Require
;;
;;
(declare-function async-bytecomp-package-mode "ext:async-bytecomp.el")
(when (require 'async-bytecomp nil t)
(and (fboundp 'async-bytecomp-package-mode)
(async-bytecomp-package-mode 1)))
(defgroup helm-config nil
"Various configurations for Helm."
:group 'helm)
(defcustom helm-command-prefix-key "C-x c"
"The key `helm-command-prefix' is bound to in the global map."
:type '(choice (string :tag "Key") (const :tag "no binding"))
:group 'helm-config
:set
(lambda (var key)
(when (and (boundp var) (symbol-value var))
(define-key (current-global-map)
(read-kbd-macro (symbol-value var)) nil))
(when key
(define-key (current-global-map)
(read-kbd-macro key) 'helm-command-prefix))
(set var key)))
(defcustom helm-minibuffer-history-key "C-r"
"The key `helm-minibuffer-history' is bound to in minibuffer local maps."
:type '(choice (string :tag "Key") (const :tag "no binding"))
:group 'helm-config
:set
(lambda (var key)
(cl-dolist (map '(minibuffer-local-completion-map
minibuffer-local-filename-completion-map
minibuffer-local-filename-must-match-map ; Emacs 23.1.+
minibuffer-local-isearch-map
minibuffer-local-map
minibuffer-local-must-match-filename-map ; Older Emacsen
minibuffer-local-must-match-map
minibuffer-local-ns-map))
(when (and (boundp map) (keymapp (symbol-value map)))
(when (and (boundp var) (symbol-value var))
(define-key (symbol-value map)
(read-kbd-macro (symbol-value var)) nil))
(when key
(define-key (symbol-value map)
(read-kbd-macro key) 'helm-minibuffer-history))))
(set var key)))
;;; Command Keymap
;;
;;
(defvar helm-command-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "a") 'helm-apropos)
(define-key map (kbd "e") 'helm-etags-select)
(define-key map (kbd "l") 'helm-locate)
(define-key map (kbd "s") 'helm-surfraw)
(define-key map (kbd "r") 'helm-regexp)
(define-key map (kbd "m") 'helm-man-woman)
(define-key map (kbd "t") 'helm-top)
(define-key map (kbd "/") 'helm-find)
(define-key map (kbd "i") 'helm-semantic-or-imenu)
(define-key map (kbd "I") 'helm-imenu-in-all-buffers)
(define-key map (kbd "<tab>") 'helm-lisp-completion-at-point)
(define-key map (kbd "p") 'helm-list-emacs-process)
(define-key map (kbd "C-x r b") 'helm-filtered-bookmarks)
(define-key map (kbd "M-y") 'helm-show-kill-ring)
(define-key map (kbd "C-c <SPC>") 'helm-all-mark-rings)
(define-key map (kbd "C-x C-f") 'helm-find-files)
(define-key map (kbd "f") 'helm-multi-files)
(define-key map (kbd "C-:") 'helm-eval-expression-with-eldoc)
(define-key map (kbd "C-,") 'helm-calcul-expression)
(define-key map (kbd "M-x") 'helm-M-x)
(define-key map (kbd "M-s o") 'helm-occur)
(define-key map (kbd "M-g a") 'helm-do-grep-ag)
(define-key map (kbd "c") 'helm-colors)
(define-key map (kbd "F") 'helm-select-xfont)
(define-key map (kbd "8") 'helm-ucs)
(define-key map (kbd "C-c f") 'helm-recentf)
(define-key map (kbd "C-c g") 'helm-google-suggest)
(define-key map (kbd "h i") 'helm-info-at-point)
(define-key map (kbd "h r") 'helm-info-emacs)
(define-key map (kbd "h g") 'helm-info-gnus)
(define-key map (kbd "h h") 'helm-documentation)
(define-key map (kbd "C-x C-b") 'helm-buffers-list)
(define-key map (kbd "C-x r i") 'helm-register)
(define-key map (kbd "C-c C-x") 'helm-run-external-command)
(define-key map (kbd "b") 'helm-resume)
(define-key map (kbd "M-g i") 'helm-gid)
(define-key map (kbd "@") 'helm-list-elisp-packages)
map))
;; Don't override the keymap we just defined with an empty
;; keymap. This also protect bindings changed by the user.
(defvar helm-command-prefix)
(define-prefix-command 'helm-command-prefix)
(fset 'helm-command-prefix helm-command-map)
(setq helm-command-prefix helm-command-map)
;;; Menu
(require 'helm-easymenu)
;;;###autoload
(defun helm-configuration ()
"Customize `helm'."
(interactive)
(customize-group "helm"))
;;; Fontlock
(cl-dolist (mode '(emacs-lisp-mode lisp-interaction-mode))
(font-lock-add-keywords
mode
'(("(\\<\\(with-helm-after-update-hook\\)\\>" 1 font-lock-keyword-face)
("(\\<\\(with-helm-temp-hook\\)\\>" 1 font-lock-keyword-face)
("(\\<\\(with-helm-window\\)\\>" 1 font-lock-keyword-face)
("(\\<\\(with-helm-quittable\\)\\>" 1 font-lock-keyword-face)
("(\\<\\(with-helm-current-buffer\\)\\>" 1 font-lock-keyword-face)
("(\\<\\(with-helm-buffer\\)\\>" 1 font-lock-keyword-face)
("(\\<\\(with-helm-show-completion\\)\\>" 1 font-lock-keyword-face)
("(\\<\\(with-helm-default-directory\\)\\>" 1 font-lock-keyword-face)
("(\\<\\(with-helm-restore-variables\\)\\>" 1 font-lock-keyword-face)
("(\\<\\(helm-multi-key-defun\\)\\>" 1 font-lock-keyword-face)
("(\\<\\(helm-while-no-input\\)\\>" 1 font-lock-keyword-face)
("(\\<\\(helm-aif\\)\\>" 1 font-lock-keyword-face)
("(\\<\\(helm-awhile\\)\\>" 1 font-lock-keyword-face)
("(\\<\\(helm-acond\\)\\>" 1 font-lock-keyword-face)
("(\\<\\(helm-aand\\)\\>" 1 font-lock-keyword-face)
("(\\<\\(helm-with-gensyms\\)\\>" 1 font-lock-keyword-face)
("(\\<\\(helm-read-answer\\)\\>" 1 font-lock-keyword-face))))
;;; Load the autoload file
;; It should have been generated either by
;; package.el or the make file.
(load "helm-autoloads" nil t)
(provide 'helm-config)
;; Local Variables:
;; byte-compile-warnings: (not obsolete)
;; coding: utf-8
;; indent-tabs-mode: nil
;; End:
;;; helm-config.el ends here

Binary file not shown.

View File

@@ -0,0 +1,388 @@
;;; helm-dabbrev.el --- Helm implementation of dabbrev. -*- lexical-binding: t -*-
;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto <thierry.volpiatto@gmail.com>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'helm)
(require 'helm-lib)
(require 'helm-help)
(require 'helm-elisp) ; For show-completion.
(defgroup helm-dabbrev nil
"Dabbrev related Applications and libraries for Helm."
:group 'helm)
(defcustom helm-dabbrev-always-search-all t
"Always search in all buffers when non--nil.
Note that even if nil, a search in all buffers
will occur if the length of candidates is <= than
`helm-dabbrev-max-length-result'."
:group 'helm-dabbrev
:type 'boolean)
(defcustom helm-dabbrev-candidates-number-limit 1000
"Maximum number of candidates to collect.
Higher this number is, slower the computation of candidates will be.
You can use safely a higher value with emacs-26+.
Note that this have nothing to do with `helm-candidate-number-limit'."
:group 'helm-dabbrev
:type 'integer)
(defcustom helm-dabbrev-ignored-buffers-regexps
'("\\*helm" "\\*Messages" "\\*Echo Area" "\\*Buffer List")
"List of regexps matching names of buffers that helm-dabbrev should not check."
:group 'helm-dabbrev
:type '(repeat regexp))
(defcustom helm-dabbrev-related-buffer-fn #'helm-dabbrev--same-major-mode-p
"A function that decide if a buffer to search in is related to `current-buffer'.
This is actually determined by comparing `major-mode' of the buffer to search
and the `current-buffer'.
The function take one arg, the buffer which is current, look at
`helm-dabbrev--same-major-mode-p' for example.
When nil all buffers are considered related to `current-buffer'."
:group 'helm-dabbrev
:type 'function)
(defcustom helm-dabbrev-major-mode-assoc nil
"Major mode association alist.
This allow helm-dabbrev searching in buffers with the associated `major-mode'.
e.g \(emacs-lisp-mode . lisp-interaction-mode\)
will allow searching in the lisp-interaction-mode buffer when `current-buffer'
is an `emacs-lisp-mode' buffer and vice versa i.e
no need to provide \(lisp-interaction-mode . emacs-lisp-mode\) association.
When nil check is the searched buffer have same `major-mode'
than the `current-buffer'.
This have no effect when `helm-dabbrev-related-buffer-fn' is nil or of course
bound to a function that doesn't handle this var."
:type '(alist :key-type symbol :value-type symbol)
:group 'helm-dabbrev)
(defcustom helm-dabbrev-lineno-around 30
"Search first in this number of lines before an after point."
:group 'helm-dabbrev
:type 'integer)
(defcustom helm-dabbrev-cycle-threshold 5
"Number of time helm-dabbrev cycle before displaying helm completion.
When nil or 0 disable cycling."
:group 'helm-dabbrev
:type '(choice (const :tag "Cycling disabled" nil) integer))
(defcustom helm-dabbrev-case-fold-search 'smart
"Set `case-fold-search' in `helm-dabbrev'.
Same as `helm-case-fold-search' but for `helm-dabbrev'.
Note that this is not affecting searching in helm buffer,
but the initial search for all candidates in buffer(s)."
:group 'helm-dabbrev
:type '(choice (const :tag "Ignore case" t)
(const :tag "Respect case" nil)
(other :tag "Smart" 'smart)))
(defcustom helm-dabbrev-use-thread nil
"[EXPERIMENTAL] Compute candidates asynchronously (partially) when non nil.
The idea is to compute candidates while cycling the first ones, so
this is available only if `helm-dabbrev-cycle-threshold' is not 0 or
nil, also it is available only on emacs-26+ (needs threads).
This is reasonably working when you don't have to complete a huge list
of candidates, otherwise you will have a small delay after the first cycle
because thread is released unexpectedly when helm-dabbrev exit after
first insertion.
IOW keep `helm-dabbrev-candidates-number-limit' to a reasonable
value (I don't!) and give enough prefix before completing e.g. for
completing \"helm-dabbrev\" use \"helm-d\" and not \"he\" if you want
to use this."
:group 'helm-dabbrev
:type 'boolean)
(defvaralias 'helm-dabbrev--regexp 'helm-dabbrev-separator-regexp)
(make-obsolete-variable 'helm-dabbrev--regexp
'helm-dabbrev-separator-regexp "2.8.3")
;; Check for beginning of line should happen last (^\n\\|^).
(defvar helm-dabbrev-separator-regexp
"\\s-\\|\t\\|[(\\[\\{\"'`=<$;,@.#+]\\|\\s\\\\|^\n\\|^"
"Regexp matching the start of a dabbrev candidate.")
(defvar helm-dabbrev-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map helm-map)
(define-key map (kbd "M-/") 'helm-next-line)
(define-key map (kbd "M-:") 'helm-previous-line)
map))
;; Internal
(defvar helm-dabbrev--cache nil)
(defvar helm-dabbrev--data nil)
(cl-defstruct helm-dabbrev-info dabbrev limits iterator)
(defvar helm-dabbrev--already-tried nil)
(defvar helm-dabbrev--current-thread nil)
(defun helm-dabbrev--buffer-list ()
(cl-loop for buf in (buffer-list)
unless (cl-loop for r in helm-dabbrev-ignored-buffers-regexps
thereis (string-match r (buffer-name buf)))
collect buf))
(defun helm-dabbrev--same-major-mode-p (start-buffer)
"Decide if current-buffer is related to START-BUFFER."
(helm-same-major-mode-p start-buffer helm-dabbrev-major-mode-assoc))
(defun helm-dabbrev--collect (str limit ignore-case all)
(let* ((case-fold-search ignore-case)
(buffer1 (current-buffer)) ; start buffer.
(minibuf (minibufferp buffer1))
result pos-before pos-after
(search-and-store
(lambda (pattern direction)
(while (and (<= (length result) limit)
(cl-case direction
(1 (search-forward pattern nil t))
(-1 (search-backward pattern nil t))
(2 (let ((pos
(save-excursion
(forward-line
helm-dabbrev-lineno-around)
(point))))
(setq pos-after pos)
(search-forward pattern pos t)))
(-2 (let ((pos
(save-excursion
(forward-line
(- helm-dabbrev-lineno-around))
(point))))
(setq pos-before pos)
(search-backward pattern pos t)))))
(let* ((pbeg (match-beginning 0))
(replace-regexp (concat "\\(" helm-dabbrev-separator-regexp
"\\)\\'"))
(match-word (helm-dabbrev--search
pattern pbeg replace-regexp)))
(when (and match-word (not (member match-word result)))
(push match-word result)))))))
(catch 'break
(dolist (buf (if all (helm-dabbrev--buffer-list)
(list (current-buffer))))
(with-current-buffer buf
(when (or minibuf ; check against all buffers when in minibuffer.
(if helm-dabbrev-related-buffer-fn
(funcall helm-dabbrev-related-buffer-fn buffer1)
t))
(save-excursion
;; Start searching before thing before point.
(goto-char (- (point) (length str)))
;; Search the last 30 lines before point.
(funcall search-and-store str -2)) ; store pos [1]
(save-excursion
;; Search the next 30 lines after point.
(funcall search-and-store str 2)) ; store pos [2]
(save-excursion
;; Search all before point.
;; If limit is reached in previous call of
;; search-and-store pos-before is never set and
;; goto-char will fail, so check it.
(when pos-before
(goto-char pos-before) ; start from [1]
(funcall search-and-store str -1)))
(save-excursion
;; Search all after point.
;; Same comment as above for pos-after.
(when pos-after
(goto-char pos-after) ; start from [2]
(funcall search-and-store str 1)))))
(when (>= (length result) limit) (throw 'break nil))))
(nreverse result)))
(defun helm-dabbrev--search (pattern beg sep-regexp)
"Search word or symbol at point matching PATTERN.
Argument BEG is corresponding to the previous match-beginning search.
The search starts at (1- BEG) with a regexp starting with
`helm-dabbrev-separator-regexp' followed by PATTERN followed by a
regexp matching syntactically any word or symbol.
The possible false positives matching SEP-REGEXP at end are finally
removed."
(let ((eol (point-at-eol)))
(save-excursion
(goto-char (1- beg))
(when (re-search-forward
(concat "\\("
helm-dabbrev-separator-regexp
"\\)"
"\\(?99:\\("
(regexp-quote pattern)
"\\(\\sw\\|\\s_\\)+\\)\\)")
eol t)
(replace-regexp-in-string
sep-regexp ""
(match-string-no-properties 99))))))
(defun helm-dabbrev--get-candidates (dabbrev &optional limit)
(cl-assert dabbrev nil "[No Match]")
(helm-dabbrev--collect
dabbrev (or limit helm-dabbrev-candidates-number-limit)
(cl-case helm-dabbrev-case-fold-search
(smart (helm-set-case-fold-search-1 dabbrev))
(t helm-dabbrev-case-fold-search))
helm-dabbrev-always-search-all))
(defun helm-dabbrev-default-action (candidate)
(with-helm-current-buffer
(let* ((limits (helm-bounds-of-thing-before-point
helm-dabbrev-separator-regexp))
(beg (car limits))
(end (point)))
(run-with-timer
0.01 nil
'helm-insert-completion-at-point
beg end candidate))))
;;;###autoload
(cl-defun helm-dabbrev ()
"Preconfigured helm for dynamic abbreviations."
(interactive)
(let ((dabbrev (helm-thing-before-point
nil helm-dabbrev-separator-regexp))
(limits (helm-bounds-of-thing-before-point
helm-dabbrev-separator-regexp))
(enable-recursive-minibuffers t)
(cycling-disabled-p (or (null helm-dabbrev-cycle-threshold)
(zerop helm-dabbrev-cycle-threshold)))
(helm-execute-action-at-once-if-one t)
(helm-quit-if-no-candidate
(lambda ()
(message "[Helm-dabbrev: No expansion found]"))))
(cl-assert (and (stringp dabbrev) (not (string= dabbrev "")))
nil "[Helm-dabbrev: Nothing found before point]")
(when (and
;; have been called at least once.
(helm-dabbrev-info-p helm-dabbrev--data)
;; But user have moved with some other command
;; in the meaning time.
(not (eq last-command 'helm-dabbrev)))
(setq helm-dabbrev--data nil))
;; When candidates are requested in helm directly without cycling,
;; we need them right now before running helm, so no need to use a
;; thread here.
(when cycling-disabled-p
(setq helm-dabbrev--cache (helm-dabbrev--get-candidates dabbrev)))
(unless (or cycling-disabled-p
(helm-dabbrev-info-p helm-dabbrev--data))
(setq helm-dabbrev--data
(make-helm-dabbrev-info
:dabbrev dabbrev
:limits limits
:iterator
(helm-iter-list
(cl-loop for i in (helm-dabbrev--get-candidates
dabbrev helm-dabbrev-cycle-threshold)
when (string-match-p
(concat "^" (regexp-quote dabbrev)) i)
collect i))))
;; Thread is released as soon as helm-dabbrev exits after first
;; insertion so this is unusable for now, keep it like this for
;; now hooping the situation with threads will be improved in
;; emacs. The idea is to compute whole list of candidates in
;; background while cycling with the first
;; helm-dabbrev-cycle-threshold ones.
(when (and (fboundp 'make-thread) helm-dabbrev-use-thread)
(setq helm-dabbrev--current-thread
(make-thread
(lambda ()
(setq helm-dabbrev--cache
(helm-dabbrev--get-candidates dabbrev)))))))
(let ((iter (and (helm-dabbrev-info-p helm-dabbrev--data)
(helm-dabbrev-info-iterator helm-dabbrev--data)))
deactivate-mark)
;; Cycle until iterator is consumed.
(helm-aif (and iter (helm-iter-next iter))
(progn
(helm-insert-completion-at-point
(car (helm-dabbrev-info-limits helm-dabbrev--data))
;; END is the end of the previous inserted string, not
;; the end (apart for first insertion) of the initial string.
(cdr limits) it)
;; Move already tried candidates to end of list.
(push it helm-dabbrev--already-tried))
;; Iterator is now empty, reset dabbrev to initial value
;; and start helm completion.
(let* ((old-dabbrev (if (helm-dabbrev-info-p helm-dabbrev--data)
(helm-dabbrev-info-dabbrev helm-dabbrev--data)
dabbrev))
(only-one (null (cdr (all-completions
old-dabbrev
helm-dabbrev--already-tried)))))
(unless helm-dabbrev-use-thread
(message "Waiting for helm-dabbrev candidates...")
(setq helm-dabbrev--cache
(helm-dabbrev--get-candidates old-dabbrev)))
;; If the length of candidates is only one when computed
;; that's mean the unique matched item have already been
;; inserted by the iterator, so no need to reinsert the old dabbrev,
;; just let helm exiting with "No expansion found".
(unless (or only-one cycling-disabled-p)
(setq dabbrev old-dabbrev
limits (helm-dabbrev-info-limits helm-dabbrev--data))
(setq helm-dabbrev--data nil)
(delete-region (car limits) (point))
(insert dabbrev))
;; Cycling is finished, block until helm-dabbrev--cache have
;; finished to complete.
(when (and (fboundp 'thread-join)
helm-dabbrev-use-thread
(thread-alive-p helm-dabbrev--current-thread))
(thread-join helm-dabbrev--current-thread))
(when (and (null cycling-disabled-p) only-one)
(cl-return-from helm-dabbrev
(message "[Helm-dabbrev: No expansion found]")))
(with-helm-show-completion (car limits) (cdr limits)
(unwind-protect
(helm :sources
(helm-build-in-buffer-source "Dabbrev Expand"
:data
(cl-loop for cand in helm-dabbrev--cache
unless
(member cand helm-dabbrev--already-tried)
collect cand into lst
finally return
(append lst helm-dabbrev--already-tried))
:persistent-action 'ignore
:persistent-help "DoNothing"
:keymap helm-dabbrev-map
:action 'helm-dabbrev-default-action
:group 'helm-dabbrev)
:buffer "*helm dabbrev*"
:input (concat "^" dabbrev " ")
:resume 'noresume
:allow-nest t)
(setq helm-dabbrev--already-tried nil))))))))
(provide 'helm-dabbrev)
;; Local Variables:
;; byte-compile-warnings: (not obsolete)
;; coding: utf-8
;; indent-tabs-mode: nil
;; End:
;;; helm-dabbrev.el ends here

Binary file not shown.

View File

@@ -0,0 +1,87 @@
;;; helm-easymenu.el --- Helm easymenu definitions. -*- lexical-binding: t -*-
;; Copyright (C) 2015 ~ 2019 Thierry Volpiatto <thierry.volpiatto@gmail.com>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'easymenu)
(easy-menu-add-item
nil '("Tools")
'("Helm"
["Find any Files/Buffers" helm-multi-files t]
["Helm Everywhere (Toggle)" helm-mode t]
["Helm resume" helm-resume t]
"----"
("Files"
["Find files" helm-find-files t]
["Recent Files" helm-recentf t]
["Locate" helm-locate t]
["Search Files with find" helm-find t]
["Bookmarks" helm-filtered-bookmarks t])
("Buffers"
["Find buffers" helm-buffers-list t])
("Commands"
["Emacs Commands" helm-M-x t]
["Externals Commands" helm-run-external-command t])
("Help"
["Helm Apropos" helm-apropos t])
("Info"
["Info at point" helm-info-at-point t]
["Emacs Manual index" helm-info-emacs t]
["Gnus Manual index" helm-info-gnus t]
["Helm documentation" helm-documentation t])
("Elpa"
["Elisp packages" helm-list-elisp-packages t]
["Elisp packages no fetch" helm-list-elisp-packages-no-fetch t])
("Tools"
["Occur" helm-occur t]
["Grep current directory with AG" helm-do-grep-ag t]
["Gid" helm-gid t]
["Etags" helm-etags-select t]
["Lisp complete at point" helm-lisp-completion-at-point t]
["Browse Kill ring" helm-show-kill-ring t]
["Browse register" helm-register t]
["Mark Ring" helm-all-mark-rings t]
["Regexp handler" helm-regexp t]
["Colors & Faces" helm-colors t]
["Show xfonts" helm-select-xfont t]
["Ucs Symbols" helm-ucs t]
["Imenu" helm-imenu t]
["Imenu all" helm-imenu-in-all-buffers t]
["Semantic or Imenu" helm-semantic-or-imenu t]
["Google Suggest" helm-google-suggest t]
["Eval expression" helm-eval-expression-with-eldoc t]
["Calcul expression" helm-calcul-expression t]
["Man pages" helm-man-woman t]
["Top externals process" helm-top t]
["Emacs internals process" helm-list-emacs-process t])
"----"
["Preferred Options" helm-configuration t])
"Spell Checking")
(easy-menu-add-item nil '("Tools") '("----") "Spell Checking")
(provide 'helm-easymenu)
;; Local Variables:
;; byte-compile-warnings: (not obsolete)
;; coding: utf-8
;; indent-tabs-mode: nil
;; End:
;;; helm-easymenu.el ends here

Binary file not shown.

View File

@@ -0,0 +1,463 @@
;;; helm-elisp-package.el --- helm interface for package.el -*- lexical-binding: t -*-
;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto <thierry.volpiatto@gmail.com>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'cl-lib)
(require 'helm)
(require 'helm-help)
(require 'package)
(defgroup helm-el-package nil
"helm elisp packages."
:group 'helm)
(defcustom helm-el-package-initial-filter 'all
"Show only installed, upgraded or all packages at startup."
:group 'helm-el-package
:type '(radio :tag "Initial filter for elisp packages"
(const :tag "Show all packages" all)
(const :tag "Show installed packages" installed)
(const :tag "Show not installed packages" uninstalled)
(const :tag "Show upgradable packages" upgrade)))
(defcustom helm-el-truncate-lines t
"Truncate lines in helm-buffer when non--nil."
:group 'helm-el-package
:type 'boolean)
;; internals vars
(defvar helm-el-package--show-only 'all)
(defvar helm-el-package--initialized-p nil)
(defvar helm-el-package--tabulated-list nil)
(defvar helm-el-package--upgrades nil)
(defvar helm-el-package--removable-packages nil)
;; Shutup bytecompiler for emacs-24*
(defvar package-menu-async) ; Only available on emacs-25.
(declare-function async-byte-recompile-directory "ext:async-bytecomp.el")
(defun helm-el-package--init ()
(let (package-menu-async
(inhibit-read-only t))
(when (null package-alist)
(setq helm-el-package--show-only 'all))
(when (setq helm-el-package--removable-packages
(package--removable-packages))
(package-autoremove))
(unwind-protect
(progn
(save-selected-window
(if helm-el-package--initialized-p
;; Use this as `list-packages' doesn't work
;; properly (empty buffer) when called from lisp
;; with 'no-fetch (emacs-25 WA).
(package-show-package-list)
(when helm--force-updating-p (message "Refreshing packages list..."))
(list-packages helm-el-package--initialized-p))
(setq helm-el-package--initialized-p t)
(message nil))
(helm-init-candidates-in-buffer
'global
(with-current-buffer (get-buffer "*Packages*")
(setq helm-el-package--tabulated-list tabulated-list-entries)
(remove-text-properties (point-min) (point-max)
'(read-only button follow-link category))
(goto-char (point-min))
(while (re-search-forward "^[ \t]+" nil t)
(replace-match ""))
(buffer-string)))
(setq helm-el-package--upgrades (helm-el-package-menu--find-upgrades))
(if helm--force-updating-p
(if helm-el-package--upgrades
(message "Refreshing packages list done, [%d] package(s) to upgrade"
(length helm-el-package--upgrades))
(message "Refreshing packages list done, no upgrades available"))
(setq helm-el-package--show-only (if helm-el-package--upgrades
'upgrade
helm-el-package-initial-filter))))
(kill-buffer "*Packages*"))))
(defun helm-el-package-describe (candidate)
(let ((id (get-text-property 0 'tabulated-list-id candidate)))
(describe-package (package-desc-name id))))
(defun helm-el-package-visit-homepage (candidate)
(let* ((id (get-text-property 0 'tabulated-list-id candidate))
(pkg (package-desc-name id))
(desc (cadr (assoc pkg package-archive-contents)))
(extras (package-desc-extras desc))
(url (and (listp extras) (cdr-safe (assoc :url extras)))))
(if (stringp url)
(browse-url url)
(message "Package %s has no homepage"
(propertize (symbol-name pkg)
'face 'font-lock-keyword-face)))))
(defun helm-el-run-visit-homepage ()
(interactive)
(with-helm-alive-p
(helm-exit-and-execute-action 'helm-el-package-visit-homepage)))
(put 'helm-el-run-visit-homepage 'helm-only t)
(defun helm-elisp-package--pkg-name (pkg)
(if (package-desc-p pkg)
(package-desc-name pkg)
pkg))
(defun helm-el-package-install-1 (pkg-list)
(cl-loop with mkd = pkg-list
for p in mkd
for id = (get-text-property 0 'tabulated-list-id p)
for name = (helm-elisp-package--pkg-name id)
do (package-install id t)
when (helm-aand (assq name package-alist)
(package-desc-dir (cadr it))
(file-exists-p it))
collect id into installed-list and
do (unless (package--user-selected-p name)
(package--save-selected-packages
(cons name package-selected-packages)))
finally do (message (format "%d packages installed:\n(%s)"
(length installed-list)
(mapconcat #'package-desc-full-name
installed-list ", ")))))
(defun helm-el-package-install (_candidate)
(helm-el-package-install-1 (helm-marked-candidates)))
(defun helm-el-run-package-install ()
(interactive)
(with-helm-alive-p
(helm-exit-and-execute-action 'helm-el-package-install)))
(put 'helm-el-run-package-install 'helm-only t)
(defun helm-el-package-uninstall-1 (pkg-list &optional force)
(cl-loop with mkd = pkg-list
for p in mkd
for id = (get-text-property 0 'tabulated-list-id p)
do
(condition-case-unless-debug err
(package-delete id force)
(error (message (cadr err))))
;; Seems like package-descs are symbols with props instead of
;; vectors in emacs-27, use package-desc-name to ensure
;; compatibility in all emacs versions.
unless (assoc (package-desc-name id) package-alist)
collect id into delete-list
finally do (if delete-list
(message (format "%d packages deleted:\n(%s)"
(length delete-list)
(mapconcat #'package-desc-full-name
delete-list ", ")))
"No package deleted")))
(defun helm-el-package-uninstall (_candidate)
(helm-el-package-uninstall-1 (helm-marked-candidates) helm-current-prefix-arg))
(defun helm-el-run-package-uninstall ()
(interactive)
(with-helm-alive-p
(helm-exit-and-execute-action 'helm-el-package-uninstall)))
(put 'helm-el-run-package-uninstall 'helm-only t)
(defun helm-el-package-menu--find-upgrades ()
(cl-loop for entry in helm-el-package--tabulated-list
for pkg-desc = (car entry)
for status = (package-desc-status pkg-desc)
;; A dependency.
when (string= status "dependency")
collect pkg-desc into dependencies
;; An installed package used as dependency (user have
;; installed this package explicitely).
when (package--used-elsewhere-p pkg-desc)
collect pkg-desc into installed-as-dep
;; An installed package.
when (member status '("installed" "unsigned"))
collect pkg-desc into installed
when (member status '("available" "new"))
collect (cons (package-desc-name pkg-desc) pkg-desc) into available
finally return
;; Always try to upgrade dependencies before installed.
(cl-loop with all = (append dependencies installed-as-dep installed)
for pkg in all
for name = (package-desc-name pkg)
for avail-pkg = (assq name available)
when (and avail-pkg
(version-list-<
(package-desc-version pkg)
(package-desc-version (cdr avail-pkg))))
collect avail-pkg)))
(defun helm-el-package--user-installed-p (package)
"Return non-nil if PACKAGE is a user-installed package."
(let* ((assoc (assq package package-alist))
(pkg-desc (and assoc (cadr assoc)))
(dir (and pkg-desc (package-desc-dir pkg-desc))))
(when dir
(file-in-directory-p dir package-user-dir))))
(defun helm-el-package-upgrade-1 (pkg-list)
(cl-loop for p in pkg-list
for pkg-desc = (car p)
for pkg-name = (package-desc-name pkg-desc)
for upgrade = (cdr (assq pkg-name
helm-el-package--upgrades))
do
(cond (;; Install.
(equal pkg-desc upgrade)
(message "Installing package `%s'" pkg-name)
(package-install pkg-desc t))
(;; Do nothing.
(or (null upgrade)
;; This may happen when a Elpa version of pkg
;; is installed and need upgrade and pkg is as
;; well a builtin package.
(package-built-in-p pkg-name))
(ignore))
(;; Delete.
t
(message "Deleting package `%s'" pkg-name)
(package-delete pkg-desc t t)))))
(defun helm-el-package-upgrade (_candidate)
(helm-el-package-upgrade-1
(cl-loop with pkgs = (helm-marked-candidates)
for p in helm-el-package--tabulated-list
for pkg = (car p)
if (member (symbol-name (package-desc-name pkg)) pkgs)
collect p)))
(defun helm-el-run-package-upgrade ()
(interactive)
(with-helm-alive-p
(helm-exit-and-execute-action 'helm-el-package-upgrade)))
(put 'helm-el-run-package-upgrade 'helm-only t)
(defun helm-el-package-upgrade-all ()
(if helm-el-package--upgrades
(with-helm-display-marked-candidates
helm-marked-buffer-name (mapcar (lambda (x) (symbol-name (car x)))
helm-el-package--upgrades)
(when (y-or-n-p "Upgrade all packages? ")
(helm-el-package-upgrade-1 helm-el-package--tabulated-list)))
(message "No packages to upgrade actually!")))
(defun helm-el-package-upgrade-all-action (_candidate)
(helm-el-package-upgrade-all))
(defun helm-el-run-package-upgrade-all ()
(interactive)
(with-helm-alive-p
(helm-exit-and-execute-action 'helm-el-package-upgrade-all-action)))
(put 'helm-el-run-package-upgrade-all 'helm-only t)
(defun helm-el-package--transformer (candidates _source)
(cl-loop for c in candidates
for disp = (concat " " c)
for id = (get-text-property 0 'tabulated-list-id c)
for name = (and id (package-desc-name id))
for desc = (package-desc-status id)
for built-in-p = (and (package-built-in-p name)
(not (member desc '("available" "new"
"installed" "dependency"))))
for installed-p = (member desc '("installed" "dependency"))
for upgrade-p = (assq name helm-el-package--upgrades)
for user-installed-p = (memq name package-selected-packages)
do (when (and user-installed-p (not upgrade-p))
(put-text-property 0 2 'display "S " disp))
do (when (or (memq name helm-el-package--removable-packages)
(and upgrade-p installed-p))
(put-text-property 0 2 'display "U " disp)
(put-text-property
2 (+ (length (symbol-name name)) 2)
'face 'font-lock-variable-name-face disp))
do (when (and upgrade-p (not installed-p) (not built-in-p))
(put-text-property 0 2 'display "I " disp))
for cand = (cons disp (car (split-string disp)))
when (or (and built-in-p
(eq helm-el-package--show-only 'built-in))
(and upgrade-p
(eq helm-el-package--show-only 'upgrade))
(and installed-p
(eq helm-el-package--show-only 'installed))
(and (not installed-p)
(not built-in-p)
(eq helm-el-package--show-only 'uninstalled))
(eq helm-el-package--show-only 'all))
collect cand))
(defun helm-el-package-show-built-in ()
(interactive)
(with-helm-alive-p
(setq helm-el-package--show-only 'built-in)
(helm-update)))
(put 'helm-el-package-show-built-in 'helm-only t)
(defun helm-el-package-show-upgrade ()
(interactive)
(with-helm-alive-p
(setq helm-el-package--show-only 'upgrade)
(helm-update)))
(put 'helm-el-package-show-upgrade 'helm-only t)
(defun helm-el-package-show-installed ()
(interactive)
(with-helm-alive-p
(setq helm-el-package--show-only 'installed)
(helm-update)))
(put 'helm-el-package-show-installed 'helm-only t)
(defun helm-el-package-show-all ()
(interactive)
(with-helm-alive-p
(setq helm-el-package--show-only 'all)
(helm-update)))
(put 'helm-el-package-show-all 'helm-only t)
(defun helm-el-package-show-uninstalled ()
(interactive)
(with-helm-alive-p
(setq helm-el-package--show-only 'uninstalled)
(helm-update)))
(put 'helm-el-package-show-uninstalled 'helm-only t)
(defvar helm-el-package-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map helm-map)
(define-key map (kbd "M-I") 'helm-el-package-show-installed)
(define-key map (kbd "M-O") 'helm-el-package-show-uninstalled)
(define-key map (kbd "M-U") 'helm-el-package-show-upgrade)
(define-key map (kbd "M-B") 'helm-el-package-show-built-in)
(define-key map (kbd "M-A") 'helm-el-package-show-all)
(define-key map (kbd "C-c i") 'helm-el-run-package-install)
(define-key map (kbd "C-c r") 'helm-el-run-package-reinstall)
(define-key map (kbd "C-c d") 'helm-el-run-package-uninstall)
(define-key map (kbd "C-c u") 'helm-el-run-package-upgrade)
(define-key map (kbd "C-c U") 'helm-el-run-package-upgrade-all)
(define-key map (kbd "C-c @") 'helm-el-run-visit-homepage)
map))
(defvar helm-source-list-el-package nil)
(defclass helm-list-el-package-source (helm-source-in-buffer)
((init :initform 'helm-el-package--init)
(get-line :initform 'buffer-substring)
(filtered-candidate-transformer :initform 'helm-el-package--transformer)
(action-transformer :initform 'helm-el-package--action-transformer)
(help-message :initform 'helm-el-package-help-message)
(keymap :initform helm-el-package-map)
(update :initform 'helm-el-package--update)
(candidate-number-limit :initform 9999)
(action :initform '(("Describe package" . helm-el-package-describe)
("Visit homepage" . helm-el-package-visit-homepage)))
(group :initform 'helm-el-package)))
(defun helm-el-package--action-transformer (actions candidate)
(let* ((pkg-desc (get-text-property 0 'tabulated-list-id candidate))
(status (package-desc-status pkg-desc))
(pkg-name (package-desc-name pkg-desc))
(built-in (and (package-built-in-p pkg-name)
(not (member status '("available" "new"
"installed" "dependency")))))
(acts (if helm-el-package--upgrades
(append actions '(("Upgrade all packages"
. helm-el-package-upgrade-all-action)))
actions)))
(cond (built-in '(("Describe package" . helm-el-package-describe)))
((and (package-installed-p pkg-name)
(cdr (assq pkg-name helm-el-package--upgrades))
(member status '("installed" "dependency")))
(append '(("Upgrade package(s)" . helm-el-package-upgrade)
("Uninstall package(s)" . helm-el-package-uninstall))
acts))
((and (package-installed-p pkg-name)
(cdr (assq pkg-name helm-el-package--upgrades))
(string= status "available"))
(append '(("Upgrade package(s)" . helm-el-package-upgrade))
acts))
((and (package-installed-p pkg-name)
(or (null (package-built-in-p pkg-name))
(and (package-built-in-p pkg-name)
(assq pkg-name package-alist))))
(append acts '(("Reinstall package(s)" . helm-el-package-reinstall)
("Recompile package(s)" . helm-el-package-recompile)
("Uninstall package(s)" . helm-el-package-uninstall))))
(t (append acts '(("Install packages(s)" . helm-el-package-install)))))))
(defun helm-el-package--update ()
(setq helm-el-package--initialized-p nil))
(defun helm-el-package-recompile (_pkg)
(cl-loop for p in (helm-marked-candidates)
do (helm-el-package-recompile-1 p)))
(defun helm-el-package-recompile-1 (pkg)
(let* ((pkg-desc (get-text-property 0 'tabulated-list-id pkg))
(dir (package-desc-dir pkg-desc)))
(async-byte-recompile-directory dir)))
(defun helm-el-package-reinstall (_pkg)
(cl-loop for p in (helm-marked-candidates)
for pkg-desc = (get-text-property 0 'tabulated-list-id p)
do (helm-el-package-reinstall-1 pkg-desc)))
(defun helm-el-package-reinstall-1 (pkg-desc)
(let ((name (package-desc-name pkg-desc)))
(package-delete pkg-desc 'force 'nosave)
;; pkg-desc contain the description
;; of the installed package just removed
;; and is BTW no more valid.
;; Use the entry in package-archive-content
;; which is the non--installed package entry.
;; For some reason `package-install'
;; need a pkg-desc (package-desc-p) for the build-in
;; packages already installed, the name (as symbol)
;; fails with such packages.
(package-install
(cadr (assq name package-archive-contents)) t)))
(defun helm-el-run-package-reinstall ()
(interactive)
(with-helm-alive-p
(helm-exit-and-execute-action 'helm-el-package-reinstall)))
(put 'helm-el-run-package-reinstall 'helm-only t)
;;;###autoload
(defun helm-list-elisp-packages (arg)
"Preconfigured helm for listing and handling emacs packages."
(interactive "P")
(when arg (setq helm-el-package--initialized-p nil))
(unless helm-source-list-el-package
(setq helm-source-list-el-package
(helm-make-source "list packages" 'helm-list-el-package-source)))
(helm :sources 'helm-source-list-el-package
:truncate-lines helm-el-truncate-lines
:full-frame t
:buffer "*helm list packages*"))
;;;###autoload
(defun helm-list-elisp-packages-no-fetch (arg)
"Preconfigured helm for emacs packages.
Same as `helm-list-elisp-packages' but don't fetch packages on remote.
Called with a prefix ARG always fetch packages on remote."
(interactive "P")
(let ((helm-el-package--initialized-p (null arg)))
(helm-list-elisp-packages nil)))
(provide 'helm-elisp-package)
;;; helm-elisp-package.el ends here

Binary file not shown.

View File

@@ -0,0 +1,984 @@
;;; helm-elisp.el --- Elisp symbols completion for helm. -*- lexical-binding: t -*-
;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto <thierry.volpiatto@gmail.com>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'cl-lib)
(require 'helm)
(require 'helm-lib)
(require 'helm-help)
(require 'helm-types)
(require 'helm-utils)
(require 'helm-info)
(require 'helm-eval)
(require 'helm-files)
(declare-function 'helm-describe-function "helm-lib")
(declare-function 'helm-describe-variable "helm-lib")
(declare-function 'helm-describe-face "helm-lib")
;;; Customizable values
(defgroup helm-elisp nil
"Elisp related Applications and libraries for Helm."
:group 'helm)
(defcustom helm-turn-on-show-completion t
"Display candidate in `current-buffer' while moving selection when non--nil."
:group 'helm-elisp
:type 'boolean)
(defcustom helm-show-completion-min-window-height 7
"Minimum completion window height used in show completion.
This is used in macro `with-helm-show-completion'."
:group 'helm-elisp
:type 'integer)
(defcustom helm-lisp-quoted-function-list
'(funcall apply mapc cl-mapc mapcar cl-mapcar
callf callf2 cl-callf cl-callf2 fset
fboundp fmakunbound symbol-function)
"List of function where quoted function completion happen.
e.g give only function names after \(funcall '."
:group 'helm-elisp
:type '(repeat (choice symbol)))
(defcustom helm-lisp-unquoted-function-list
'(function defadvice)
"List of function where unquoted function completion happen.
e.g give only function names after \(function ."
:group 'helm-elisp
:type '(repeat (choice symbol)))
(defcustom helm-apropos-fuzzy-match nil
"Enable fuzzy matching for `helm-apropos' when non-nil."
:group 'helm-elisp
:type 'boolean)
(defcustom helm-lisp-fuzzy-completion nil
"Enable fuzzy matching in emacs-lisp completion when non-nil.
NOTE: This enable fuzzy matching in helm native implementation of
elisp completion, but not on helmized elisp completion, i.e
fuzzy completion is not available in `completion-at-point'."
:group 'helm-elisp
:type 'boolean)
(defcustom helm-apropos-function-list '(helm-def-source--emacs-commands
helm-def-source--emacs-functions
helm-def-source--eieio-classes
helm-def-source--eieio-generic
helm-def-source--emacs-variables
helm-def-source--emacs-faces)
"A list of functions that build helm sources to use in `helm-apropos'."
:group 'helm-elisp
:type '(repeat (choice symbol)))
(defcustom helm-apropos-defaut-info-lookup-sources '(helm-source-info-elisp
helm-source-info-cl
helm-source-info-eieio)
"A list of sources to look into when searching info page of a symbol."
:group 'helm-elisp
:type '(repeat (choice symbol)))
(defcustom helm-show-completion-display-function
(if (display-graphic-p)
#'helm-display-buffer-in-own-frame
#'helm-show-completion-default-display-function)
"The function used to display helm completion buffer.
This function is used by `with-helm-show-completion', when nil
fallback to `helm-default-display-buffer'.
Default is to use a separate frame on graphic display and
`helm-show-completion-default-display-function' on non graphic
display."
:group 'helm-elisp
:type 'function)
;;; Faces
;;
;;
(defgroup helm-elisp-faces nil
"Customize the appearance of helm-elisp."
:prefix "helm-"
:group 'helm-elisp
:group 'helm-faces)
(defface helm-lisp-show-completion
'((t (:background "DarkSlateGray")))
"Face used for showing candidates in `helm-lisp-completion'."
:group 'helm-elisp-faces)
(defface helm-lisp-completion-info
'((t (:foreground "red")))
"Face used for showing info in `helm-lisp-completion'."
:group 'helm-elisp-faces)
(defcustom helm-elisp-help-function
'helm-elisp-show-help
"Function for displaying help for Lisp symbols."
:group 'helm-elisp
:type '(choice (function :tag "Open help for the symbol."
helm-elisp-show-help)
(function :tag "Show one liner in modeline."
helm-elisp-show-doc-modeline)))
(defcustom helm-locate-library-fuzzy-match t
"Enable fuzzy-matching in `helm-locate-library' when non--nil."
:type 'boolean
:group 'helm-elisp)
;;; Show completion.
;;
;; Provide show completion with macro `with-helm-show-completion'.
(defvar helm-show-completion-overlay nil)
;; Called each time cursor move in helm-buffer.
(defun helm-show-completion ()
(with-helm-current-buffer
(overlay-put helm-show-completion-overlay
'display (substring-no-properties
(helm-get-selection)))))
(defun helm-show-completion-init-overlay (beg end)
(setq helm-show-completion-overlay (make-overlay beg end))
(overlay-put helm-show-completion-overlay
'face 'helm-lisp-show-completion))
(defun helm-show-completion-default-display-function (buffer &rest _args)
"A special resized helm window is used depending on position in BUFFER."
(with-selected-window (selected-window)
(if (window-dedicated-p)
(helm-default-display-buffer buffer)
(let* ((screen-size (+ (count-screen-lines (window-start) (point) t)
1 ; mode-line
(if header-line-format 1 0))) ; header-line
(def-size (- (window-height)
helm-show-completion-min-window-height))
(upper-height (max window-min-height (min screen-size def-size)))
split-window-keep-point)
(recenter -1)
(set-window-buffer (if (active-minibuffer-window)
(minibuffer-selected-window)
(split-window nil upper-height
helm-split-window-default-side))
buffer)))))
(defmacro with-helm-show-completion (beg end &rest body)
"Show helm candidate in an overlay at point.
BEG and END are the beginning and end position of the current completion
in `helm-current-buffer'.
BODY is an helm call where we want to enable show completion.
If `helm-turn-on-show-completion' is nil do nothing."
(declare (indent 2) (debug t))
`(unwind-protect
(if helm-turn-on-show-completion
(let ((helm-move-selection-after-hook
(append (list 'helm-show-completion)
helm-move-selection-after-hook))
(helm-split-window-default-side
(if (eq helm-split-window-default-side 'same)
'below helm-split-window-default-side))
helm-split-window-inside-p
helm-reuse-last-window-split-state)
(helm-set-local-variable
'helm-display-function
(or helm-show-completion-display-function
'helm-default-display-buffer))
(helm-show-completion-init-overlay ,beg ,end)
,@body)
,@body)
(when (and helm-show-completion-overlay
(overlayp helm-show-completion-overlay))
(delete-overlay helm-show-completion-overlay))))
;;; Lisp symbol completion.
;;
;;
(defun helm-lisp-completion--predicate-at-point (beg)
;; Return a predicate for `all-completions'.
(let ((fn-sym-p (lambda ()
(or
(and (eq (char-before) ?\ )
(save-excursion
(skip-syntax-backward " " (point-at-bol))
(memq (symbol-at-point)
helm-lisp-unquoted-function-list)))
(and (eq (char-before) ?\')
(save-excursion
(forward-char -1)
(eq (char-before) ?\#)))))))
(save-excursion
(goto-char beg)
(if (or
;; Complete on all symbols in non--lisp modes (logs mail etc..)
(not (memq major-mode '(emacs-lisp-mode
lisp-interaction-mode
inferior-emacs-lisp-mode)))
(not (or (funcall fn-sym-p)
(and (eq (char-before) ?\')
(save-excursion
(forward-char (if (funcall fn-sym-p) -2 -1))
(skip-syntax-backward " " (point-at-bol))
(memq (symbol-at-point)
helm-lisp-quoted-function-list)))
(eq (char-before) ?\())) ; no paren before str.
;; Looks like we are in a let statement.
(condition-case nil
(progn (up-list -2) (forward-char 1)
(eq (char-after) ?\())
(error nil)))
(lambda (sym)
(or (boundp sym) (fboundp sym) (symbol-plist sym)))
#'fboundp))))
(defun helm-thing-before-point (&optional limits regexp)
"Return symbol name before point.
If REGEXP is specified return what REGEXP find before point.
By default match the beginning of symbol before point.
With LIMITS arg specified return the beginning and end position
of symbol before point."
(save-excursion
(let (beg
(end (point))
(boundary (field-beginning nil nil (point-at-bol))))
(if (re-search-backward (or regexp "\\_<") boundary t)
(setq beg (match-end 0))
(setq beg boundary))
(unless (= beg end)
(if limits
(cons beg end)
(buffer-substring-no-properties beg end))))))
(defun helm-bounds-of-thing-before-point (&optional regexp)
"Get the beginning and end position of `helm-thing-before-point'.
Return a cons \(beg . end\)."
(helm-thing-before-point 'limits regexp))
(defun helm-insert-completion-at-point (beg end str)
;; When there is no space after point
;; we are completing inside a symbol or
;; after a partial symbol with the next arg aside
;; without space, in this case mark the region.
;; deleting it would remove the
;; next arg which is unwanted.
(delete-region beg end)
(insert str)
(let ((pos (cdr (or (bounds-of-thing-at-point 'symbol)
;; needed for helm-dabbrev.
(bounds-of-thing-at-point 'filename)))))
(when (and pos (< (point) pos))
(push-mark pos t t))))
(defvar helm-lisp-completion--cache nil)
(defvar helm-lgst-len nil)
;;;###autoload
(defun helm-lisp-completion-at-point ()
"Preconfigured helm for lisp symbol completion at point."
(interactive)
(setq helm-lgst-len 0)
(let* ((target (helm-thing-before-point))
(beg (car (helm-bounds-of-thing-before-point)))
(end (point))
(pred (and beg (helm-lisp-completion--predicate-at-point beg)))
(loc-vars (and (fboundp 'elisp--local-variables)
(ignore-errors
(mapcar #'symbol-name (elisp--local-variables)))))
(glob-syms (and target pred (all-completions target obarray pred)))
(candidates (append loc-vars glob-syms))
(helm-quit-if-no-candidate t)
(helm-execute-action-at-once-if-one t)
(enable-recursive-minibuffers t))
(setq helm-lisp-completion--cache (cl-loop for sym in candidates
for len = (length sym)
when (> len helm-lgst-len)
do (setq helm-lgst-len len)
collect sym))
(if candidates
(with-helm-show-completion beg end
;; Overlay is initialized now in helm-current-buffer.
(helm
:sources (helm-build-in-buffer-source "Lisp completion"
:data helm-lisp-completion--cache
:persistent-action `(helm-lisp-completion-persistent-action .
,(and (eq helm-elisp-help-function
'helm-elisp-show-doc-modeline)
'never-split))
:nomark t
:match-part (lambda (c) (car (split-string c)))
:fuzzy-match helm-lisp-fuzzy-completion
:persistent-help (helm-lisp-completion-persistent-help)
:filtered-candidate-transformer
'helm-lisp-completion-transformer
:action (lambda (candidate)
(with-helm-current-buffer
(run-with-timer
0.01 nil
'helm-insert-completion-at-point
beg end candidate))))
:input (if helm-lisp-fuzzy-completion
target (concat target " "))
:resume 'noresume
:truncate-lines t
:buffer "*helm lisp completion*"
:allow-nest t))
(message "[No Match]"))))
(defun helm-lisp-completion-persistent-action (candidate &optional name)
"Show documentation for the function.
Documentation is shown briefly in mode-line or completely
in other window according to the value of `helm-elisp-help-function'."
(funcall helm-elisp-help-function candidate name))
(defun helm-lisp-completion-persistent-help ()
"Return persistent-help according to the value of `helm-elisp-help-function'"
(cl-ecase helm-elisp-help-function
(helm-elisp-show-doc-modeline "Show brief doc in mode-line")
(helm-elisp-show-help "Toggle show help for the symbol")))
(defun helm-elisp--show-help-1 (candidate &optional name)
(let ((sym (intern-soft candidate)))
(cl-typecase sym
((and fboundp boundp)
(if (member name `(,helm-describe-function-function ,helm-describe-variable-function))
(funcall (intern (format "helm-%s" name)) sym)
;; When there is no way to know what to describe
;; prefer describe-function.
(helm-describe-function sym)))
(fbound (helm-describe-function sym))
(bound (helm-describe-variable sym))
(face (helm-describe-face sym)))))
(defun helm-elisp-show-help (candidate &optional name)
"Show full help for the function CANDIDATE.
Arg NAME specify the name of the top level function
calling helm generic completion (e.g \"describe-function\")
which allow calling the right function when CANDIDATE symbol
refers at the same time to variable and a function."
(helm-elisp--persistent-help
candidate 'helm-elisp--show-help-1 name))
(defun helm-elisp-show-doc-modeline (candidate &optional name)
"Show brief documentation for the function in modeline."
(let ((cursor-in-echo-area t)
mode-line-in-non-selected-windows)
(helm-show-info-in-mode-line
(propertize
(helm-get-first-line-documentation
(intern candidate) name)
'face 'helm-lisp-completion-info))))
(defun helm-lisp-completion-transformer (candidates _source)
"Helm candidates transformer for lisp completion."
(cl-loop for c in candidates
for sym = (intern c)
for annot = (cl-typecase sym
(command " (Com)")
(class " (Class)")
(generic " (Gen)")
(fbound " (Fun)")
(bound " (Var)")
(face " (Face)"))
for spaces = (make-string (- helm-lgst-len (length c)) ? )
collect (cons (concat c spaces annot) c) into lst
finally return (sort lst #'helm-generic-sort-fn)))
(defun helm-get-first-line-documentation (sym &optional name)
"Return first line documentation of symbol SYM.
If SYM is not documented, return \"Not documented\"."
(let ((doc (cl-typecase sym
((and fboundp boundp)
(cond ((string= name "describe-function")
(documentation sym t))
((string= name "describe-variable")
(documentation-property sym 'variable-documentation t))
(t (documentation sym t))))
(fbound (documentation sym t))
(bound (documentation-property sym 'variable-documentation t))
(face (face-documentation sym)))))
(if (and doc (not (string= doc ""))
;; `documentation' return "\n\n(args...)"
;; for CL-style functions.
(not (string-match-p "^\n\n" doc)))
(car (split-string doc "\n"))
"Not documented")))
;;; File completion.
;;
;; Complete file name at point.
;;;###autoload
(defun helm-complete-file-name-at-point (&optional force)
"Preconfigured helm to complete file name at point."
(interactive)
(require 'helm-mode)
(let* ((tap (thing-at-point 'filename))
beg
(init (and tap
(or force
(save-excursion
(end-of-line)
(search-backward tap (point-at-bol) t)
(setq beg (point))
(looking-back "[^'`( ]" (1- (point)))))
(expand-file-name
(substring-no-properties tap))))
(end (point))
(helm-quit-if-no-candidate t)
(helm-execute-action-at-once-if-one t)
completion)
(with-helm-show-completion beg end
(setq completion (helm-read-file-name "FileName: "
:initial-input init)))
(when (and completion (not (string= completion "")))
(delete-region beg end) (insert (if (string-match "^~" tap)
(abbreviate-file-name completion)
completion)))))
;;;###autoload
(defun helm-lisp-indent ()
;; It is meant to use with `helm-define-multi-key' which
;; does not support args for functions yet, so use `current-prefix-arg'
;; for now instead of (interactive "P").
(interactive)
(let ((tab-always-indent (or (eq tab-always-indent 'complete)
tab-always-indent)))
(indent-for-tab-command current-prefix-arg)))
;;;###autoload
(defun helm-lisp-completion-or-file-name-at-point ()
"Preconfigured helm to complete lisp symbol or filename at point.
Filename completion happen if string start after or between a double quote."
(interactive)
(let* ((tap (thing-at-point 'filename)))
(if (and tap (save-excursion
(end-of-line)
(search-backward tap (point-at-bol) t)
(looking-back "[^'`( ]" (1- (point)))))
(helm-complete-file-name-at-point)
(helm-lisp-completion-at-point))))
;;; Apropos
;;
;;
(defvar helm-apropos-history nil)
(defun helm-apropos-init (test default)
"Init candidates buffer for `helm-apropos' sources."
(require 'helm-help)
(helm-init-candidates-in-buffer 'global
(let ((default-symbol (and (stringp default)
(intern-soft default)))
(symbols (all-completions "" obarray test)))
(if (and default-symbol (funcall test default-symbol))
(cons default-symbol symbols)
symbols))))
(defun helm-apropos-init-faces (default)
"Init candidates buffer for faces for `helm-apropos'."
(require 'helm-help)
(with-current-buffer (helm-candidate-buffer 'global)
(goto-char (point-min))
(let ((default-symbol (and (stringp default)
(intern-soft default)))
(faces (face-list)))
(when (and default-symbol (facep default-symbol))
(insert (concat default "\n")))
(insert
(mapconcat #'prin1-to-string
(if default
(cl-remove-if (lambda (sym) (string= sym default)) faces)
faces)
"\n")))))
(defun helm-apropos-default-sort-fn (candidates _source)
(if (string= helm-pattern "")
candidates
(sort candidates #'helm-generic-sort-fn)))
(defun helm-apropos-clean-history-variable (candidate)
(with-helm-current-buffer ; var is maybe local
(let* ((sym (intern-soft candidate))
(cands (symbol-value sym))
(mkds (and (listp cands)
(helm-comp-read "Delete entry: "
cands :marked-candidates t))))
(cl-assert (listp mkds) nil "Variable value is not a list")
(cl-loop for elm in mkds do
(if (local-variable-p sym)
(set (make-local-variable sym)
(setq cands (delete elm cands)))
(set sym (setq cands (delete elm cands))))))))
(defun helm-apropos-clean-ring (candidate)
(with-helm-current-buffer ; var is maybe local
(let* ((sym (intern-soft candidate))
(val (symbol-value sym))
(cands (and (ring-p val) (ring-elements val)))
(mkds (and cands (helm-comp-read
"Delete entry: "
cands :marked-candidates t))))
(when mkds
(cl-loop for elm in mkds do
(ring-remove
val (helm-position
elm
(ring-elements val)
:test 'equal))
and do (if (local-variable-p sym)
(set (make-local-variable sym) val)
(set sym val)))))))
(defun helm-apropos-action-transformer (actions candidate)
(let* ((sym (helm-symbolify candidate))
(val (with-helm-current-buffer (symbol-value sym))))
(cond ((custom-variable-p sym)
(append
actions
(let ((standard-value (eval (car (get sym 'standard-value)))))
(unless (equal standard-value (symbol-value sym))
`(("Reset Variable to default value"
. ,(lambda (candidate)
(let ((sym (helm-symbolify candidate)))
(set sym standard-value)))))))
'(("Customize variable" .
(lambda (candidate)
(customize-option (helm-symbolify candidate)))))))
((and val (with-helm-current-buffer (ring-p (symbol-value sym))))
(append actions
'(("Clean ring" . helm-apropos-clean-ring))))
((and (string-match-p "history" candidate) (listp val))
(append actions
'(("Clean variable" .
helm-apropos-clean-history-variable))))
(t actions))))
(defun helm-def-source--emacs-variables (&optional default)
(helm-build-in-buffer-source "Variables"
:init (lambda ()
(helm-apropos-init
(lambda (x) (and (boundp x) (not (keywordp x)))) default))
:fuzzy-match helm-apropos-fuzzy-match
:filtered-candidate-transformer (and (null helm-apropos-fuzzy-match)
'helm-apropos-default-sort-fn)
:nomark t
:persistent-action (lambda (candidate)
(helm-elisp--persistent-help
candidate 'helm-describe-variable))
:persistent-help "Toggle describe variable"
:action '(("Describe variable" . helm-describe-variable)
("Find variable" . helm-find-variable)
("Info lookup" . helm-info-lookup-symbol)
("Set variable" . helm-set-variable))
:action-transformer 'helm-apropos-action-transformer))
(defun helm-def-source--emacs-faces (&optional default)
"Create `helm' source for faces to be displayed with
`helm-apropos'."
(helm-build-in-buffer-source "Faces"
:init (lambda () (helm-apropos-init-faces default))
:fuzzy-match helm-apropos-fuzzy-match
:filtered-candidate-transformer
(append (and (null helm-apropos-fuzzy-match)
'(helm-apropos-default-sort-fn))
(list
(lambda (candidates _source)
(cl-loop for c in candidates
collect (propertize c 'face (intern c))))))
:persistent-action (lambda (candidate)
(helm-elisp--persistent-help
candidate 'helm-describe-face))
:persistent-help "Toggle describe face"
:action '(("Describe face" . helm-describe-face)
("Find face" . helm-find-face-definition)
("Customize face" . (lambda (candidate)
(customize-face (helm-symbolify candidate)))))))
(defun helm-def-source--emacs-commands (&optional default)
(helm-build-in-buffer-source "Commands"
:init (lambda ()
(helm-apropos-init 'commandp default))
:fuzzy-match helm-apropos-fuzzy-match
:filtered-candidate-transformer (and (null helm-apropos-fuzzy-match)
'helm-apropos-default-sort-fn)
:nomark t
:persistent-action (lambda (candidate)
(helm-elisp--persistent-help
candidate 'helm-describe-function))
:persistent-help "Toggle describe command"
:action '(("Describe function" . helm-describe-function)
("Find function" . helm-find-function)
("Info lookup" . helm-info-lookup-symbol))))
(defun helm-def-source--emacs-functions (&optional default)
(helm-build-in-buffer-source "Functions"
:init (lambda ()
(helm-apropos-init (lambda (x)
(and (fboundp x)
(not (commandp x))
(not (generic-p x))
(not (class-p x))))
default))
:fuzzy-match helm-apropos-fuzzy-match
:filtered-candidate-transformer (and (null helm-apropos-fuzzy-match)
'helm-apropos-default-sort-fn)
:persistent-action (lambda (candidate)
(helm-elisp--persistent-help
candidate 'helm-describe-function))
:persistent-help "Toggle describe function"
:nomark t
:action '(("Describe function" . helm-describe-function)
("Find function" . helm-find-function)
("Info lookup" . helm-info-lookup-symbol))))
(defun helm-def-source--eieio-classes (&optional default)
(helm-build-in-buffer-source "Classes"
:init (lambda ()
(helm-apropos-init (lambda (x)
(class-p x))
default))
:fuzzy-match helm-apropos-fuzzy-match
:filtered-candidate-transformer (and (null helm-apropos-fuzzy-match)
'helm-apropos-default-sort-fn)
:nomark t
:persistent-action (lambda (candidate)
(helm-elisp--persistent-help
candidate 'helm-describe-class))
:persistent-help "Toggle describe class"
:action '(("Describe Class" . helm-describe-class)
("Find Class" . helm-find-function)
("Info lookup" . helm-info-lookup-symbol))))
(defun helm-def-source--eieio-generic (&optional default)
(helm-build-in-buffer-source "Generic functions"
:init (lambda ()
(helm-apropos-init (lambda (x)
(generic-p x))
default))
:fuzzy-match helm-apropos-fuzzy-match
:filtered-candidate-transformer (and (null helm-apropos-fuzzy-match)
'helm-apropos-default-sort-fn)
:nomark t
:persistent-action (lambda (candidate)
(helm-elisp--persistent-help
candidate 'helm-describe-function))
:persistent-help "Toggle describe generic function"
:action '(("Describe function" . helm-describe-function)
("Find function" . helm-find-function)
("Info lookup" . helm-info-lookup-symbol))))
(defun helm-info-lookup-fallback-source (candidate)
(let ((sym (helm-symbolify candidate))
src-name fn)
(cond ((class-p sym)
(setq fn #'helm-describe-function
src-name "Describe class"))
((generic-p sym)
(setq fn #'helm-describe-function
src-name "Describe generic function"))
((fboundp sym)
(setq fn #'helm-describe-function
src-name "Describe function"))
((facep sym)
(setq fn #'helm-describe-face
src-name "Describe face"))
(t
(setq fn #'helm-describe-variable
src-name "Describe variable")))
(helm-build-sync-source src-name
:candidates (list candidate)
:persistent-action (lambda (candidate)
(helm-elisp--persistent-help
candidate fn))
:persistent-help src-name
:nomark t
:action fn)))
(defun helm-info-lookup-symbol-1 (c)
(let ((helm-execute-action-at-once-if-one 'current-source))
(helm :sources (append helm-apropos-defaut-info-lookup-sources
(list (helm-info-lookup-fallback-source c)))
:resume 'noresume
:buffer "*helm lookup*"
:input c)))
(defun helm-info-lookup-symbol (candidate)
;; ???:Running an idle-timer allows not catching RET when exiting
;; with the fallback source.
;; (run-with-idle-timer 0.01 nil #'helm-info-lookup-symbol-1 candidate)
(helm-info-lookup-symbol-1 candidate))
;;;###autoload
(defun helm-apropos (default)
"Preconfigured helm to describe commands, functions, variables and faces.
In non interactives calls DEFAULT argument should be provided as a string,
i.e the `symbol-name' of any existing symbol."
(interactive (list (thing-at-point 'symbol)))
(helm :sources
(mapcar (lambda (func)
(funcall func default))
helm-apropos-function-list)
:history 'helm-apropos-history
:buffer "*helm apropos*"
:preselect (and default (concat "\\_<" (regexp-quote default) "\\_>"))))
;;; Advices
;;
;;
(defvar helm-source-advice
(helm-build-sync-source "Function Advice"
:init (lambda () (require 'advice))
:candidates 'helm-advice-candidates
:action (helm-make-actions "Toggle Enable/Disable" 'helm-advice-toggle)
:persistent-action 'helm-advice-persistent-action
:nomark t
:multiline t
:persistent-help "Toggle describe function / C-u C-j: Toggle advice"))
(defun helm-advice-candidates ()
(cl-loop for (fname) in ad-advised-functions
for function = (intern fname)
append
(cl-loop for class in ad-advice-classes append
(cl-loop for advice in (ad-get-advice-info-field function class)
for enabled = (ad-advice-enabled advice)
collect
(cons (format
"%s %s %s"
(if enabled "Enabled " "Disabled")
(propertize fname 'face 'font-lock-function-name-face)
(ad-make-single-advice-docstring advice class nil))
(list function class advice))))))
(defun helm-advice-persistent-action (func-class-advice)
(if current-prefix-arg
(helm-advice-toggle func-class-advice)
(describe-function (car func-class-advice))))
(defun helm-advice-toggle (func-class-advice)
(cl-destructuring-bind (function _class advice) func-class-advice
(cond ((ad-advice-enabled advice)
(ad-advice-set-enabled advice nil)
(message "Disabled"))
(t
(ad-advice-set-enabled advice t)
(message "Enabled")))
(ad-activate function)
(and helm-in-persistent-action
(helm-advice-update-current-display-string))))
(defun helm-advice-update-current-display-string ()
(helm-edit-current-selection
(let ((newword (cond ((looking-at "Disabled") "Enabled")
((looking-at "Enabled") "Disabled"))))
(when newword
(delete-region (point) (progn (forward-word 1) (point)))
(insert newword)))))
;;;###autoload
(defun helm-manage-advice ()
"Preconfigured `helm' to disable/enable function advices."
(interactive)
(helm-other-buffer 'helm-source-advice "*helm advice*"))
;;; Locate elisp library
;;
;;
(defun helm-locate-library-scan-list ()
(cl-loop for dir in load-path
with load-suffixes = '(".el")
when (file-directory-p dir)
append (directory-files
dir t (concat (regexp-opt (get-load-suffixes))
"\\'"))))
;;;###autoload
(defun helm-locate-library ()
"Preconfigured helm to locate elisp libraries."
(interactive)
(helm :sources (helm-build-in-buffer-source "Elisp libraries (Scan)"
:data #'helm-locate-library-scan-list
:fuzzy-match helm-locate-library-fuzzy-match
:keymap helm-generic-files-map
:search (unless helm-locate-library-fuzzy-match
(lambda (regexp)
(re-search-forward
(if helm-ff-transformer-show-only-basename
(replace-regexp-in-string
"\\`\\^" "" regexp)
regexp)
nil t)))
:match-part (lambda (candidate)
(with-helm-buffer
(if helm-ff-transformer-show-only-basename
(helm-basename candidate) candidate)))
:filter-one-by-one (lambda (c)
(with-helm-buffer
(if helm-ff-transformer-show-only-basename
(cons (helm-basename c) c) c)))
:action (helm-actions-from-type-file))
:ff-transformer-show-only-basename nil
:buffer "*helm locate library*"))
(defun helm-set-variable (var)
"Set VAR value interactively."
(let* ((sym (helm-symbolify var))
(val (default-value sym)))
(set-default sym (eval-minibuffer
(format "Set `%s': " var)
(if (or (stringp val)
(memq val '(nil t))
(numberp val))
(prin1-to-string val)
(format "'%s" (prin1-to-string val)))))))
;;; Elisp Timers.
;;
;;
(defclass helm-absolute-time-timers-class (helm-source-sync helm-type-timers)
((candidates :initform timer-list)
(allow-dups :initform t)
(candidate-transformer
:initform
(lambda (candidates)
(cl-loop for timer in candidates
collect (cons (helm-elisp--format-timer timer) timer))))))
(defvar helm-source-absolute-time-timers
(helm-make-source "Absolute Time Timers" 'helm-absolute-time-timers-class))
(defclass helm-idle-time-timers-class (helm-source-sync helm-type-timers)
((candidates :initform timer-idle-list)
(allow-dups :initform t)
(candidate-transformer
:initform
(lambda (candidates)
(cl-loop for timer in candidates
collect (cons (helm-elisp--format-timer timer) timer))))))
(defvar helm-source-idle-time-timers
(helm-make-source "Idle Time Timers" 'helm-idle-time-timers-class))
(defun helm-elisp--format-timer (timer)
(format "%s repeat=%s %s(%s)"
(let ((time (timer--time timer)))
(if (timer--idle-delay timer)
(format-time-string "idle-for=%5s" time)
(format-time-string "%m/%d %T" time)))
(or (timer--repeat-delay timer) "nil")
(mapconcat 'identity (split-string
(prin1-to-string (timer--function timer))
"\n") " ")
(mapconcat 'prin1-to-string (timer--args timer) " ")))
;;;###autoload
(defun helm-timers ()
"Preconfigured `helm' for timers."
(interactive)
(helm :sources '(helm-source-absolute-time-timers
helm-source-idle-time-timers)
:buffer "*helm timers*"))
;;; Complex command history
;;
;;
(defun helm-btf--usable-p ()
"Return t if current version of `backtrace-frame' accept 2 arguments."
(condition-case nil
(progn (backtrace-frame 1 'condition-case) t)
(wrong-number-of-arguments nil)))
(if (helm-btf--usable-p) ; Check if BTF accept more than one arg.
;; Emacs 24.4.
(dont-compile
(defvar helm-sexp--last-sexp nil)
;; This wont work compiled.
(defun helm-sexp-eval-1 ()
(interactive)
(unwind-protect
(progn
;; Trick called-interactively-p into thinking that `cand' is
;; an interactive call, See `repeat-complex-command'.
(add-hook 'called-interactively-p-functions
#'helm-complex-command-history--called-interactively-skip)
(eval (read helm-sexp--last-sexp)))
(remove-hook 'called-interactively-p-functions
#'helm-complex-command-history--called-interactively-skip)))
(defun helm-complex-command-history--called-interactively-skip (i _frame1 frame2)
(and (eq 'eval (cadr frame2))
(eq 'helm-sexp-eval-1
(cadr (backtrace-frame (+ i 2) #'called-interactively-p)))
1))
(defun helm-sexp-eval (_candidate)
(call-interactively #'helm-sexp-eval-1)))
;; Emacs 24.3
(defun helm-sexp-eval (cand)
(let ((sexp (read cand)))
(condition-case err
(if (> (length (remove nil sexp)) 1)
(eval sexp)
(apply 'call-interactively sexp))
(error (message "Evaluating gave an error: %S" err)
nil)))))
(defvar helm-source-complex-command-history
(helm-build-sync-source "Complex Command History"
:candidates (lambda ()
;; Use cdr to avoid adding
;; `helm-complex-command-history' here.
(cl-loop for i in command-history
unless (equal i '(helm-complex-command-history))
collect (prin1-to-string i)))
:action (helm-make-actions
"Eval" (lambda (candidate)
(and (boundp 'helm-sexp--last-sexp)
(setq helm-sexp--last-sexp candidate))
(let ((command (read candidate)))
(unless (equal command (car command-history))
(setq command-history (cons command command-history))))
(run-with-timer 0.1 nil #'helm-sexp-eval candidate))
"Edit and eval" (lambda (candidate)
(edit-and-eval-command "Eval: " (read candidate))))
:persistent-action #'helm-sexp-eval
:multiline t))
;;;###autoload
(defun helm-complex-command-history ()
"Preconfigured helm for complex command history."
(interactive)
(helm :sources 'helm-source-complex-command-history
:buffer "*helm complex commands*"))
(provide 'helm-elisp)
;; Local Variables:
;; byte-compile-warnings: (not obsolete)
;; coding: utf-8
;; indent-tabs-mode: nil
;; End:
;;; helm-elisp.el ends here

Binary file not shown.

View File

@@ -0,0 +1,488 @@
;;; helm-eshell.el --- pcomplete and eshell completion for helm. -*- lexical-binding: t -*-
;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto <thierry.volpiatto@gmail.com>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; Enable like this in .emacs:
;; (add-hook 'eshell-mode-hook
;; (lambda ()
;; (eshell-cmpl-initialize)
;; (define-key eshell-mode-map [remap eshell-pcomplete] 'helm-esh-pcomplete)
;; (define-key eshell-mode-map (kbd "M-s f") 'helm-eshell-prompts-all)))
;; (define-key eshell-mode-map (kbd "M-r") 'helm-eshell-history)))
;;; Code:
(require 'cl-lib)
(require 'helm)
(require 'helm-lib)
(require 'helm-help)
(require 'helm-elisp)
(declare-function eshell-read-aliases-list "em-alias")
(declare-function eshell-send-input "esh-mode" (&optional use-region queue-p no-newline))
(declare-function eshell-bol "esh-mode")
(declare-function eshell-parse-arguments "esh-arg" (beg end))
(declare-function eshell-backward-argument "esh-mode" (&optional arg))
(declare-function helm-quote-whitespace "helm-lib")
(declare-function eshell-skip-prompt "em-prompt")
(defvar eshell-special-chars-outside-quoting)
(defgroup helm-eshell nil
"Helm eshell completion and history."
:group 'helm)
(defcustom helm-eshell-fuzzy-match nil
"Enable fuzzy matching in `helm-esh-pcomplete' when non--nil."
:group 'helm-eshell
:type 'boolean)
(defvar helm-eshell-history-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map helm-map)
(define-key map (kbd "M-p") 'helm-next-line)
map)
"Keymap for `helm-eshell-history'.")
(defvar helm-esh-completion-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map helm-map)
(define-key map (kbd "TAB") 'helm-next-line)
map)
"Keymap for `helm-esh-pcomplete'.")
(defvar helm-eshell--quit-flag nil)
(defclass helm-esh-source (helm-source-sync)
((init :initform (lambda ()
(setq pcomplete-current-completions nil
pcomplete-last-completion-raw nil)
;; Eshell-command add this hook in all minibuffers
;; Remove it for the helm one. (Fixed in Emacs24)
(remove-hook 'minibuffer-setup-hook 'eshell-mode)))
(candidates :initform 'helm-esh-get-candidates)
;(nomark :initform t)
(persistent-action :initform 'ignore)
(nohighlight :initform t)
(filtered-candidate-transformer
:initform
(lambda (candidates _sources)
(cl-loop
for i in candidates
collect
(cond ((string-match "\\`~/?" helm-ec-target)
(abbreviate-file-name i))
((string-match "\\`/" helm-ec-target) i)
(t
(file-relative-name i)))
into lst
finally return (sort lst 'helm-generic-sort-fn))))
(action :initform 'helm-ec-insert))
"Helm class to define source for Eshell completion.")
;; Internal.
(defvar helm-ec-target "")
(defun helm-ec-insert (_candidate)
"Replace text at point with CANDIDATE.
The function that call this should set `helm-ec-target' to thing at point."
(set (make-local-variable 'comint-file-name-quote-list)
eshell-special-chars-outside-quoting)
(let ((pt (point)))
(when (and helm-ec-target
(search-backward helm-ec-target nil t)
(string= (buffer-substring (point) pt) helm-ec-target))
(delete-region (point) pt)))
(when (string-match "\\`\\*" helm-ec-target) (insert "*"))
(let ((marked (helm-marked-candidates)))
(prog1 t ;; Makes helm returns t on action.
(insert
(mapconcat
(lambda (x)
(cond ((string-match "\\`~/" helm-ec-target)
;; Strip out the first escape char added by
;; `comint-quote-filename' before "~" (Issue #1803).
(substring (comint-quote-filename (abbreviate-file-name x)) 1))
((string-match "\\`/" helm-ec-target)
(comint-quote-filename x))
(t
(concat (and (string-match "\\`[.]/" helm-ec-target) "./")
(comint-quote-filename
(file-relative-name x))))))
marked " ")
(or (helm-aand (car (last marked))
(string-match-p "/\\'" it)
"")
" ")))))
(defun helm-esh-get-candidates ()
"Get candidates for eshell completion using `pcomplete'."
(catch 'pcompleted
(with-helm-current-buffer
(let* ((pcomplete-stub)
pcomplete-seen pcomplete-norm-func
pcomplete-args pcomplete-last pcomplete-index
(pcomplete-autolist pcomplete-autolist)
(pcomplete-suffix-list pcomplete-suffix-list)
(table (pcomplete-completions))
(entry (or (try-completion helm-pattern
(pcomplete-entries))
helm-pattern)))
(cl-loop ;; expand entry too to be able to compare it with file-cand.
with exp-entry = (and (stringp entry)
(not (string= entry ""))
(file-name-as-directory
(expand-file-name entry default-directory)))
with comps = (all-completions pcomplete-stub table)
unless comps return (prog1 nil
;; Don't add final space when
;; there is no completion (issue #1990).
(setq helm-eshell--quit-flag t)
(message "No completions of %s" pcomplete-stub))
for i in comps
;; Transform the related names to abs names.
for file-cand = (and exp-entry
(if (file-remote-p i) i
(expand-file-name
i (file-name-directory entry))))
;; Compare them to avoid dups.
for file-entry-p = (and (stringp exp-entry)
(stringp file-cand)
;; Fix :/tmp/foo/ $ cd foo
(not (file-directory-p file-cand))
(file-equal-p exp-entry file-cand))
if (and file-cand (or (file-remote-p file-cand)
(file-exists-p file-cand))
(not file-entry-p))
collect file-cand into ls
else
;; Avoid adding entry here.
unless file-entry-p collect i into ls
finally return
(if (and exp-entry
(file-directory-p exp-entry)
;; If the car of completion list is
;; an executable, probably we are in
;; command completion, so don't add a
;; possible file related entry here.
(and ls (not (executable-find (car ls))))
;; Don't add entry if already in prompt.
(not (file-equal-p exp-entry pcomplete-stub)))
(append (list exp-entry)
;; Entry should not be here now but double check.
(remove entry ls))
ls))))))
;;; Eshell history.
;;
;;
(defclass helm-eshell-history-source (helm-source-sync)
((init :initform
(lambda ()
;; Same comment as in `helm-source-esh'.
(remove-hook 'minibuffer-setup-hook 'eshell-mode)))
(candidates
:initform
(lambda ()
(with-helm-current-buffer
(cl-loop for c from 0 to (ring-length eshell-history-ring)
collect (eshell-get-history c)))))
(nomark :initform t)
(multiline :initform t)
(keymap :initform helm-eshell-history-map)
(candidate-number-limit :initform 9999)
(action :initform (lambda (candidate)
(eshell-kill-input)
(insert candidate))))
"Helm class to define source for Eshell history.")
;;;###autoload
(defun helm-esh-pcomplete ()
"Preconfigured helm to provide helm completion in eshell."
(interactive)
(let* ((helm-quit-if-no-candidate t)
(helm-execute-action-at-once-if-one t)
(end (point-marker))
(beg (save-excursion (eshell-bol) (point)))
(args (catch 'eshell-incomplete
(eshell-parse-arguments beg end)))
(target
(or (and (looking-back " " (1- (point))) " ")
(buffer-substring-no-properties
(save-excursion
(eshell-backward-argument 1) (point))
end)))
(users-comp (string= target "~"))
(first (car args)) ; Maybe lisp delimiter "(".
last ; Will be the last but parsed by pcomplete.
del-space
del-dot)
(setq helm-ec-target (or target " ")
end (point)
;; Reset beg for `with-helm-show-completion'.
beg (or (and target (not (string= target " "))
(- end (length target)))
;; Nothing at point.
(progn (insert " ") (setq del-space t) (point))))
(when (string-match "\\`[~.]*.*/[.]\\'" target)
;; Fix completion on
;; "~/.", "~/[...]/.", and "../."
(delete-char -1) (setq del-dot t)
(setq helm-ec-target (substring helm-ec-target 0 (1- (length helm-ec-target)))))
(cond ((eq first ?\()
(helm-lisp-completion-or-file-name-at-point))
;; In eshell `pcomplete-parse-arguments' is called
;; with `pcomplete-parse-arguments-function'
;; locally bound to `eshell-complete-parse-arguments'
;; which is calling `lisp-complete-symbol',
;; calling it before would popup the
;; *completions* buffer.
(t (setq last (replace-regexp-in-string
"\\`\\*" ""
(car (last (ignore-errors
(pcomplete-parse-arguments))))))
;; Set helm-eshell--quit-flag to non-nil only on
;; quit, this tells to not add final suffix when quitting
;; helm.
(add-hook 'helm-quit-hook 'helm-eshell--quit-hook-fn)
(with-helm-show-completion beg end
(unwind-protect
(or (helm :sources (helm-make-source "Eshell completions" 'helm-esh-source
:fuzzy-match helm-eshell-fuzzy-match)
:buffer "*helm pcomplete*"
:keymap helm-esh-completion-map
:resume 'noresume
:input (if (and (stringp last)
(not (string= last ""))
(not users-comp)
;; Fix completion on
;; "../" see #1832.
(or (file-exists-p last)
(helm-aand
(file-name-directory last)
(file-directory-p it))))
(if (and (file-directory-p last)
(string-match "\\`[~.]*.*/[.]\\'" target))
;; Fix completion on
;; "~/.", "~/[...]/.", and "../."
(expand-file-name
(concat (helm-basedir (file-name-as-directory last))
(regexp-quote (helm-basename target))))
(expand-file-name last))
;; Don't add "~" to input to
;; provide completion on all
;; users instead of only on
;; current $HOME (#1832).
(unless users-comp last)))
;; Delete removed dot on quit
(and del-dot (prog1 t (insert ".")))
;; A space is needed to have completion, remove
;; it when nothing found.
(and del-space (looking-back "\\s-" (1- (point)))
(delete-char -1))
(if (and (null helm-eshell--quit-flag)
(and (stringp last) (file-directory-p last))
(looking-back "\\([.]\\{1,2\\}\\|[^/]\\)\\'"
(1- (point))))
(prog1 t (insert "/"))
;; We need another flag for space here, but
;; global to pass it to `helm-quit-hook', this
;; space is added when point is just after
;; previous completion and there is no
;; more completion, see issue #1832.
(unless (or helm-eshell--quit-flag
(looking-back "/\\'" (1- (point))))
(prog1 t (insert " ")))
(when (and helm-eshell--quit-flag
(string-match-p "[.]\\{2\\}\\'" last))
(insert "/"))))
(remove-hook 'helm-quit-hook 'helm-eshell--quit-hook-fn)
(setq helm-eshell--quit-flag nil)))))))
(defun helm-eshell--quit-hook-fn ()
(setq helm-eshell--quit-flag t))
;;;###autoload
(defun helm-eshell-history ()
"Preconfigured helm for eshell history."
(interactive)
(let* ((end (point))
(beg (save-excursion (eshell-bol) (point)))
(input (buffer-substring beg end))
flag-empty)
(when (eq beg end)
(insert " ")
(setq flag-empty t)
(setq end (point)))
(unwind-protect
(with-helm-show-completion beg end
(helm :sources (helm-make-source "Eshell history"
'helm-eshell-history-source
:fuzzy-match helm-eshell-fuzzy-match)
:buffer "*helm eshell history*"
:resume 'noresume
:input input))
(when (and flag-empty
(looking-back " " (1- (point))))
(delete-char -1)))))
;;; Eshell prompts
;;
(defface helm-eshell-prompts-promptidx
'((t (:foreground "cyan")))
"Face used to highlight Eshell prompt index."
:group 'helm-eshell-faces)
(defface helm-eshell-prompts-buffer-name
'((t (:foreground "green")))
"Face used to highlight Eshell buffer name."
:group 'helm-eshell-faces)
(defcustom helm-eshell-prompts-promptidx-p t
"Show prompt number."
:group 'helm-eshell
:type 'boolean)
(defvar helm-eshell-prompts-keymap
(let ((map (make-sparse-keymap)))
(set-keymap-parent map helm-map)
(define-key map (kbd "C-c o") 'helm-eshell-prompts-other-window)
(define-key map (kbd "C-c C-o") 'helm-eshell-prompts-other-frame)
map)
"Keymap for `helm-eshell-prompt-all'.")
(defvar eshell-prompt-regexp)
(defvar eshell-highlight-prompt)
(defun helm-eshell-prompts-list (&optional buffer)
"List the prompts in Eshell BUFFER.
Return a list of (\"prompt\" (point) (buffer-name) prompt-index))
e.g. (\"ls\" 162 \"*eshell*\" 3).
If BUFFER is nil, use current buffer."
(with-current-buffer (or buffer (current-buffer))
(when (eq major-mode 'eshell-mode)
(save-excursion
(goto-char (point-min))
(let (result (count 1))
(helm-awhile (re-search-forward eshell-prompt-regexp nil t)
(when (or (and eshell-highlight-prompt
(get-text-property (match-beginning 0) 'read-only))
(null eshell-highlight-prompt))
(push (list (buffer-substring-no-properties
it (point-at-eol))
it (buffer-name) count)
result)
(setq count (1+ count))))
(nreverse result))))))
(defun helm-eshell-prompts-list-all ()
"List the prompts of all Eshell buffers.
See `helm-eshell-prompts-list'."
(cl-loop for b in (buffer-list)
append (helm-eshell-prompts-list b)))
(defun helm-eshell-prompts-transformer (candidates &optional all)
;; ("ls" 162 "*eshell*" 3) => ("*eshell*:3:ls" . ("ls" 162 "*eshell*" 3))
(cl-loop for (prt pos buf id) in candidates
collect `(,(concat
(when all
(concat (propertize
buf
'face 'helm-eshell-prompts-buffer-name)
":"))
(when helm-eshell-prompts-promptidx-p
(concat (propertize
(number-to-string id)
'face 'helm-eshell-prompts-promptidx)
":"))
prt)
. ,(list prt pos buf id))))
(defun helm-eshell-prompts-all-transformer (candidates)
(helm-eshell-prompts-transformer candidates t))
(cl-defun helm-eshell-prompts-goto (candidate &optional (action 'switch-to-buffer))
;; Candidate format: ("ls" 162 "*eshell*" 3)
(let ((buf (nth 2 candidate)))
(unless (and (string= (buffer-name) buf)
(eq action 'switch-to-buffer))
(funcall action buf))
(goto-char (nth 1 candidate))
(recenter)))
(defun helm-eshell-prompts-goto-other-window (candidate)
(helm-eshell-prompts-goto candidate 'switch-to-buffer-other-window))
(defun helm-eshell-prompts-goto-other-frame (candidate)
(helm-eshell-prompts-goto candidate 'switch-to-buffer-other-frame))
(defun helm-eshell-prompts-other-window ()
(interactive)
(with-helm-alive-p
(helm-exit-and-execute-action 'helm-eshell-prompts-goto-other-window)))
(put 'helm-eshell-prompts-other-window 'helm-only t)
(defun helm-eshell-prompts-other-frame ()
(interactive)
(with-helm-alive-p
(helm-exit-and-execute-action 'helm-eshell-prompts-goto-other-frame)))
(put 'helm-eshell-prompts-other-frame 'helm-only t)
;;;###autoload
(defun helm-eshell-prompts ()
"Pre-configured `helm' to browse the prompts of the current Eshell."
(interactive)
(if (eq major-mode 'eshell-mode)
(helm :sources
(helm-build-sync-source "Eshell prompts"
:candidates (helm-eshell-prompts-list)
:candidate-transformer 'helm-eshell-prompts-transformer
:action '(("Go to prompt" . helm-eshell-prompts-goto)))
:buffer "*helm Eshell prompts*")
(message "Current buffer is not an Eshell buffer")))
;;;###autoload
(defun helm-eshell-prompts-all ()
"Pre-configured `helm' to browse the prompts of all Eshell sessions."
(interactive)
(helm :sources
(helm-build-sync-source "All Eshell prompts"
:candidates (helm-eshell-prompts-list-all)
:candidate-transformer 'helm-eshell-prompts-all-transformer
:action '(("Go to prompt" . helm-eshell-prompts-goto)
("Go to prompt in other window `C-c o`" .
helm-eshell-prompts-goto-other-window)
("Go to prompt in other frame `C-c C-o`" .
helm-eshell-prompts-goto-other-frame))
:keymap helm-eshell-prompts-keymap)
:buffer "*helm Eshell all prompts*"))
(provide 'helm-eshell)
;; Local Variables:
;; byte-compile-warnings: (not obsolete)
;; coding: utf-8
;; indent-tabs-mode: nil
;; End:
;;; helm-eshell ends here

Binary file not shown.

View File

@@ -0,0 +1,204 @@
;;; helm-eval.el --- eval expressions from helm. -*- lexical-binding: t -*-
;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto <thierry.volpiatto@gmail.com>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'cl-lib)
(require 'helm)
(require 'helm-help)
(require 'eldoc)
(require 'edebug)
(defgroup helm-eval nil
"Eval related Applications and libraries for Helm."
:group 'helm)
(defcustom helm-eldoc-in-minibuffer-show-fn
'helm-show-info-in-mode-line
"A function to display eldoc info.
Should take one arg: the string to display."
:group 'helm-eval
:type 'symbol)
(defcustom helm-show-info-in-mode-line-delay 12
"Eldoc will show info in mode-line during this delay if user is idle."
:type 'integer
:group 'helm-eval)
;;; Eldoc compatibility between emacs-24 and emacs-25
;;
(if (require 'elisp-mode nil t) ; emacs-25
;; Maybe the eldoc functions have been
;; already aliased by eldoc-eval.
(cl-loop for (f . a) in '((eldoc-current-symbol .
elisp--current-symbol)
(eldoc-fnsym-in-current-sexp .
elisp--fnsym-in-current-sexp)
(eldoc-get-fnsym-args-string .
elisp-get-fnsym-args-string)
(eldoc-get-var-docstring .
elisp-get-var-docstring))
unless (fboundp f)
do (defalias f a))
;; Emacs-24.
(declare-function eldoc-current-symbol "eldoc")
(declare-function eldoc-get-fnsym-args-string "eldoc" (sym &optional index))
(declare-function eldoc-get-var-docstring "eldoc" (sym))
(declare-function eldoc-fnsym-in-current-sexp "eldoc"))
;;; Evaluation Result
;;
;;
;; Internal
(defvar helm-eldoc-active-minibuffers-list nil)
(defvar helm-eval-expression-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map helm-map)
(define-key map (kbd "<C-return>") 'helm-eval-new-line-and-indent)
(define-key map (kbd "<M-tab>") 'lisp-indent-line)
(define-key map (kbd "<C-tab>") 'helm-lisp-completion-at-point)
(define-key map (kbd "C-p") 'previous-line)
(define-key map (kbd "C-n") 'next-line)
(define-key map (kbd "<up>") 'previous-line)
(define-key map (kbd "<down>") 'next-line)
(define-key map (kbd "<right>") 'forward-char)
(define-key map (kbd "<left>") 'backward-char)
map))
(defun helm-build-evaluation-result-source ()
(helm-build-dummy-source "Evaluation Result"
:multiline t
:mode-line "C-RET: nl-and-indent, M-tab: reindent, C-tab:complete, C-p/n: next/prec-line."
:filtered-candidate-transformer (lambda (_candidates _source)
(list
(condition-case nil
(with-helm-current-buffer
(pp-to-string
(if edebug-active
(edebug-eval-expression
(read helm-pattern))
(eval (read helm-pattern)))))
(error "Error"))))
:nohighlight t
:keymap helm-eval-expression-map
:action '(("Copy result to kill-ring" . (lambda (candidate)
(kill-new
(replace-regexp-in-string
"\n" "" candidate))
(message "Result copied to kill-ring")))
("copy sexp to kill-ring" . (lambda (_candidate)
(kill-new helm-input)
(message "Sexp copied to kill-ring"))))))
(defun helm-eval-new-line-and-indent ()
(interactive)
(newline) (lisp-indent-line))
(defun helm-eldoc-store-minibuffer ()
"Store minibuffer buffer name in `helm-eldoc-active-minibuffers-list'."
(with-selected-window (minibuffer-window)
(push (current-buffer) helm-eldoc-active-minibuffers-list)))
(defun helm-eldoc-show-in-eval ()
"Return eldoc in mode-line for current minibuffer input."
(let ((buf (window-buffer (active-minibuffer-window))))
(condition-case err
(when (member buf helm-eldoc-active-minibuffers-list)
(with-current-buffer buf
(let* ((sym (save-excursion
(unless (looking-back ")\\|\"" (1- (point)))
(forward-char -1))
(eldoc-current-symbol)))
(info-fn (eldoc-fnsym-in-current-sexp))
(doc (or (eldoc-get-var-docstring sym)
(eldoc-get-fnsym-args-string
(car info-fn) (cadr info-fn)))))
(when doc (funcall helm-eldoc-in-minibuffer-show-fn doc)))))
(error (message "Eldoc in minibuffer error: %S" err) nil))))
(defun helm-show-info-in-mode-line (str)
"Display string STR in mode-line."
(save-selected-window
(with-current-buffer helm-buffer
(let ((mode-line-format (concat " " str)))
(force-mode-line-update)
(sit-for helm-show-info-in-mode-line-delay))
(force-mode-line-update))))
;;; Calculation Result
;;
;;
(defvar helm-source-calculation-result
(helm-build-dummy-source "Calculation Result"
:filtered-candidate-transformer (lambda (_candidates _source)
(list
(condition-case nil
(calc-eval helm-pattern)
(error "error"))))
:nohighlight t
:action '(("Copy result to kill-ring" . (lambda (candidate)
(kill-new candidate)
(message "Result \"%s\" copied to kill-ring"
candidate)))
("Copy operation to kill-ring" . (lambda (_candidate)
(kill-new helm-input)
(message "Calculation copied to kill-ring"))))))
;;;###autoload
(defun helm-eval-expression (arg)
"Preconfigured helm for `helm-source-evaluation-result'."
(interactive "P")
(helm :sources (helm-build-evaluation-result-source)
:input (when arg (thing-at-point 'sexp))
:buffer "*helm eval*"
:echo-input-in-header-line nil
:history 'read-expression-history))
(defvar eldoc-idle-delay)
;;;###autoload
(defun helm-eval-expression-with-eldoc ()
"Preconfigured helm for `helm-source-evaluation-result' with `eldoc' support."
(interactive)
(let ((timer (run-with-idle-timer
eldoc-idle-delay 'repeat
'helm-eldoc-show-in-eval)))
(unwind-protect
(minibuffer-with-setup-hook
'helm-eldoc-store-minibuffer
(call-interactively 'helm-eval-expression))
(and timer (cancel-timer timer))
(setq helm-eldoc-active-minibuffers-list
(cdr helm-eldoc-active-minibuffers-list)))))
;;;###autoload
(defun helm-calcul-expression ()
"Preconfigured helm for `helm-source-calculation-result'."
(interactive)
(helm :sources 'helm-source-calculation-result
:buffer "*helm calcul*"))
(provide 'helm-eval)
;; Local Variables:
;; byte-compile-warnings: (not obsolete)
;; coding: utf-8
;; indent-tabs-mode: nil
;; End:
;;; helm-eval.el ends here

Binary file not shown.

View File

@@ -0,0 +1,213 @@
;;; helm-external.el --- Run Externals commands within Emacs with helm completion. -*- lexical-binding: t -*-
;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto <thierry.volpiatto@gmail.com>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'cl-lib)
(require 'helm)
(require 'helm-help)
(require 'helm-net)
(defgroup helm-external nil
"External related Applications and libraries for Helm."
:group 'helm)
(defcustom helm-raise-command nil
"A shell command to jump to a window running specific program.
Need external program wmctrl.
This will be use with `format', so use something like \"wmctrl -xa %s\"."
:type 'string
:group 'helm-external)
(defcustom helm-external-programs-associations nil
"Alist to store externals programs associated with file extension.
This variable overhide setting in .mailcap file.
e.g : '\(\(\"jpg\" . \"gqview\"\) (\"pdf\" . \"xpdf\"\)\) "
:type '(alist :key-type string :value-type string)
:group 'helm-external)
(defcustom helm-default-external-file-browser "nautilus"
"Default external file browser for your system.
Directories will be opened externally with it when
opening file externally in `helm-find-files'.
Set to nil if you do not have external file browser
or do not want to use it.
Windows users should set that to \"explorer.exe\"."
:group 'helm-external
:type 'string)
;;; Internals
(defvar helm-external-command-history nil)
(defvar helm-external-commands-list nil
"A list of all external commands the user can execute.
If this variable is not set by the user, it will be calculated
automatically.")
(defun helm-external-commands-list-1 (&optional sort)
"Returns a list of all external commands the user can execute.
If `helm-external-commands-list' is non-nil it will
return its contents. Else it calculates all external commands
and sets `helm-external-commands-list'."
(helm-aif helm-external-commands-list
it
(setq helm-external-commands-list
(cl-loop
for dir in (split-string (getenv "PATH") path-separator)
when (and (file-exists-p dir) (file-accessible-directory-p dir))
for lsdir = (cl-loop for i in (directory-files dir t)
for bn = (file-name-nondirectory i)
when (and (not (member bn completions))
(not (file-directory-p i))
(file-executable-p i))
collect bn)
append lsdir into completions
finally return
(if sort (sort completions 'string-lessp) completions)))))
(defun helm-run-or-raise (exe &optional file)
"Run asynchronously EXE or jump to the application window.
If EXE is already running just jump to his window if `helm-raise-command'
is non--nil.
When FILE argument is provided run EXE with FILE."
(let* ((real-com (car (split-string exe)))
(proc (if file (concat real-com " " file) real-com))
process-connection-type)
(if (get-process proc)
(if helm-raise-command
(shell-command (format helm-raise-command real-com))
(error "Error: %s is already running" real-com))
(when (member real-com helm-external-commands-list)
(message "Starting %s..." real-com)
(if file
(start-process-shell-command
proc nil (format "%s %s"
real-com
(shell-quote-argument
(if (eq system-type 'windows-nt)
(helm-w32-prepare-filename file)
(expand-file-name file)))))
(start-process-shell-command proc nil real-com))
(set-process-sentinel
(get-process proc)
(lambda (process event)
(when (and (string= event "finished\n")
helm-raise-command
(not (helm-get-pid-from-process-name real-com)))
(shell-command (format helm-raise-command "emacs")))
(message "%s process...Finished." process))))
(setq helm-external-commands-list
(cons real-com
(delete real-com helm-external-commands-list))))))
(defun helm-get-mailcap-for-file (filename)
"Get the command to use for FILENAME from mailcap files."
(mailcap-parse-mailcaps)
(let* ((ext (file-name-extension filename))
(mime (when ext (mailcap-extension-to-mime ext)))
(result (when mime (mailcap-mime-info mime))))
;; If elisp file have no associations in .mailcap
;; `mailcap-maybe-eval' is returned, in this case just return nil.
(when (stringp result) (helm-basename result))))
(defun helm-get-default-program-for-file (filename)
"Try to find a default program to open FILENAME.
Try first in `helm-external-programs-associations' and then in mailcap file
if nothing found return nil."
(let* ((ext (file-name-extension filename))
(def-prog (assoc-default ext helm-external-programs-associations)))
(cond ((and def-prog (not (string= def-prog ""))) def-prog)
((and helm-default-external-file-browser (file-directory-p filename))
helm-default-external-file-browser)
(t (helm-get-mailcap-for-file filename)))))
(defun helm-open-file-externally (file)
"Open FILE with an external program.
Try to guess which program to use with `helm-get-default-program-for-file'.
If not found or a prefix arg is given query the user which tool to use."
(let* ((fname (expand-file-name file))
(collection (helm-external-commands-list-1 'sort))
(def-prog (helm-get-default-program-for-file fname))
(program (if (or helm-current-prefix-arg (not def-prog))
;; Prefix arg or no default program.
(prog1
(helm-comp-read
"Program: " collection
:must-match t
:name "Open file Externally"
:del-input nil
:history helm-external-command-history)
;; Always prompt to set this program as default.
(setq def-prog nil))
;; No prefix arg or default program exists.
def-prog)))
(unless (or def-prog ; Association exists, no need to record it.
;; Don't try to record non--filenames associations (e.g urls).
(not (file-exists-p fname)))
(when
(y-or-n-p
(format
"Do you want to make `%s' the default program for this kind of files? "
program))
(helm-aif (assoc (file-name-extension fname)
helm-external-programs-associations)
(setq helm-external-programs-associations
(delete it helm-external-programs-associations)))
(push (cons (file-name-extension fname)
(helm-read-string
"Program (Add args maybe and confirm): " program))
helm-external-programs-associations)
(customize-save-variable 'helm-external-programs-associations
helm-external-programs-associations)))
(helm-run-or-raise program file)
(setq helm-external-command-history
(cons program
(delete program
(cl-loop for i in helm-external-command-history
when (executable-find i) collect i))))))
;;;###autoload
(defun helm-run-external-command (program)
"Preconfigured `helm' to run External PROGRAM asyncronously from Emacs.
If program is already running exit with error.
You can set your own list of commands with
`helm-external-commands-list'."
(interactive (list
(helm-comp-read
"RunProgram: "
(helm-external-commands-list-1 'sort)
:must-match t
:del-input nil
:name "External Commands"
:history helm-external-command-history)))
(helm-run-or-raise program)
(setq helm-external-command-history
(cons program (delete program
(cl-loop for i in helm-external-command-history
when (executable-find i) collect i)))))
(provide 'helm-external)
;; Local Variables:
;; byte-compile-warnings: (not obsolete)
;; coding: utf-8
;; indent-tabs-mode: nil
;; End:
;;; helm-external ends here

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