From 1afee9c5e384aadc0980a4f9ea38c2e6b928ebb8 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Fri, 1 Nov 2019 09:51:18 +0100 Subject: [PATCH] adding dependencies and removing old files --- elpa/a-20180907.953/a-autoloads.el | 22 + elpa/a-20180907.953/a-pkg.el | 2 + elpa/a-20180907.953/a.el | 347 +++++++ elpa/biblio-20190624.1408/biblio-arxiv.el | 147 +++ elpa/biblio-20190624.1408/biblio-autoloads.el | 181 ++++ elpa/biblio-20190624.1408/biblio-crossref.el | 113 +++ elpa/biblio-20190624.1408/biblio-dblp.el | 96 ++ elpa/biblio-20190624.1408/biblio-dissemin.el | 157 ++++ elpa/biblio-20190624.1408/biblio-doi.el | 123 +++ elpa/biblio-20190624.1408/biblio-download.el | 58 ++ elpa/biblio-20190624.1408/biblio-hal.el | 106 +++ elpa/biblio-20190624.1408/biblio-ieee.el | 103 +++ elpa/biblio-20190624.1408/biblio-pkg.el | 6 + elpa/biblio-20190624.1408/biblio.el | 97 ++ .../biblio-core-autoloads.el | 31 + .../biblio-core-pkg.el | 2 + elpa/biblio-core-20190624.1408/biblio-core.el | 864 ++++++++++++++++++ elpa/biblio-readme.txt | 58 ++ elpa/centered-cursor-mode-readme.txt | 16 - elpa/dash-readme.txt | 8 - .../ejc-sql-20190121.1043/ejc-autocomplete.el | 203 ---- elpa/ejc-sql-20190121.1043/ejc-direx.el | 196 ---- elpa/ejc-sql-20190121.1043/ejc-doc.el | 75 -- elpa/ejc-sql-20190121.1043/ejc-flx.el | 103 --- elpa/ejc-sql-20190121.1043/ejc-format.el | 276 ------ elpa/ejc-sql-20190121.1043/ejc-interaction.el | 244 ----- elpa/ejc-sql-20190121.1043/ejc-lib.el | 50 - elpa/ejc-sql-20190121.1043/ejc-result-mode.el | 42 - .../ejc-sql-autoloads.el | 151 --- elpa/ejc-sql-20190121.1043/ejc-sql-pkg.el | 17 - elpa/ejc-sql-20190121.1043/ejc-sql.el | 703 -------------- elpa/ejc-sql-20190121.1043/project.clj | 14 - .../snippets/sql-mode/begin.snippet | 7 - .../snippets/sql-mode/delete.yasnippet | 5 - .../snippets/sql-mode/insert.yasnippet | 6 - .../snippets/sql-mode/select.yasnippet | 7 - .../snippets/sql-mode/update.yasnippet | 7 - .../snippets/sql-mode/where.yasnippet | 5 - .../src/ejc_sql/connect.clj | 285 ------ .../ejc-sql-20190121.1043/src/ejc_sql/jpa.clj | 48 - .../ejc-sql-20190121.1043/src/ejc_sql/lib.clj | 91 -- .../src/ejc_sql/output.clj | 170 ---- .../src/ejc_sql/structure.clj | 556 ----------- .../emacs-helm.sh | 0 .../helm-adaptive.el | 0 .../helm-autoloads.el | 197 ++-- .../helm-bookmark.el | 0 .../helm-buffers.el | 0 .../helm-color.el | 0 .../helm-comint.el | 0 .../helm-command.el | 0 .../helm-config.el | 0 .../helm-dabbrev.el | 0 .../helm-easymenu.el | 0 .../helm-elisp-package.el | 0 .../helm-elisp.el | 0 .../helm-eshell.el | 0 .../helm-eval.el | 0 .../helm-external.el | 0 .../helm-files.el | 0 .../helm-find.el | 0 .../helm-font.el | 0 .../helm-for-files.el | 0 .../helm-grep.el | 0 .../helm-help.el | 0 .../helm-id-utils.el | 0 .../helm-imenu.el | 0 .../helm-info.el | 0 .../helm-locate.el | 0 .../helm-man.el | 0 .../helm-misc.el | 0 .../helm-mode.el | 13 +- .../helm-net.el | 0 .../helm-occur.el | 0 .../helm-pkg.el | 2 +- .../helm-regexp.el | 0 .../helm-ring.el | 0 .../helm-semantic.el | 0 .../helm-shell.el | 0 .../helm-sys.el | 0 .../helm-tags.el | 0 .../helm-types.el | 0 .../helm-utils.el | 0 .../helm-x-files.el | 0 .../helm-core-autoloads.el | 35 +- .../helm-core-pkg.el | 2 +- .../helm-lib.el | 0 .../helm-multi-match.el | 0 .../helm-source.el | 2 +- .../helm.el | 1 - elpa/hydra-readme.txt | 51 -- elpa/json-mode-readme.txt | 1 - elpa/lv-20191025.1326/lv-autoloads.el | 22 + elpa/lv-20191025.1326/lv-pkg.el | 2 + elpa/lv-20191025.1326/lv.el | 126 +++ elpa/lv-readme.txt | 9 + elpa/parsebib-readme.txt | 0 elpa/parseclj-20190531.711/parseclj-ast.el | 205 +++++ .../parseclj-autoloads.el | 48 + elpa/parseclj-20190531.711/parseclj-lex.el | 545 +++++++++++ elpa/parseclj-20190531.711/parseclj-parser.el | 278 ++++++ elpa/parseclj-20190531.711/parseclj-pkg.el | 12 + elpa/parseclj-20190531.711/parseclj.el | 93 ++ .../parseedn-autoloads.el | 22 + elpa/parseedn-20190331.1058/parseedn-pkg.el | 2 + elpa/parseedn-20190331.1058/parseedn.el | 202 ++++ elpa/parseedn-readme.txt | 10 + 107 files changed, 4252 insertions(+), 3426 deletions(-) create mode 100644 elpa/a-20180907.953/a-autoloads.el create mode 100644 elpa/a-20180907.953/a-pkg.el create mode 100644 elpa/a-20180907.953/a.el create mode 100644 elpa/biblio-20190624.1408/biblio-arxiv.el create mode 100644 elpa/biblio-20190624.1408/biblio-autoloads.el create mode 100644 elpa/biblio-20190624.1408/biblio-crossref.el create mode 100644 elpa/biblio-20190624.1408/biblio-dblp.el create mode 100644 elpa/biblio-20190624.1408/biblio-dissemin.el create mode 100644 elpa/biblio-20190624.1408/biblio-doi.el create mode 100644 elpa/biblio-20190624.1408/biblio-download.el create mode 100644 elpa/biblio-20190624.1408/biblio-hal.el create mode 100644 elpa/biblio-20190624.1408/biblio-ieee.el create mode 100644 elpa/biblio-20190624.1408/biblio-pkg.el create mode 100644 elpa/biblio-20190624.1408/biblio.el create mode 100644 elpa/biblio-core-20190624.1408/biblio-core-autoloads.el create mode 100644 elpa/biblio-core-20190624.1408/biblio-core-pkg.el create mode 100644 elpa/biblio-core-20190624.1408/biblio-core.el create mode 100644 elpa/biblio-readme.txt delete mode 100644 elpa/centered-cursor-mode-readme.txt delete mode 100644 elpa/dash-readme.txt delete mode 100644 elpa/ejc-sql-20190121.1043/ejc-autocomplete.el delete mode 100644 elpa/ejc-sql-20190121.1043/ejc-direx.el delete mode 100644 elpa/ejc-sql-20190121.1043/ejc-doc.el delete mode 100644 elpa/ejc-sql-20190121.1043/ejc-flx.el delete mode 100644 elpa/ejc-sql-20190121.1043/ejc-format.el delete mode 100644 elpa/ejc-sql-20190121.1043/ejc-interaction.el delete mode 100644 elpa/ejc-sql-20190121.1043/ejc-lib.el delete mode 100644 elpa/ejc-sql-20190121.1043/ejc-result-mode.el delete mode 100644 elpa/ejc-sql-20190121.1043/ejc-sql-autoloads.el delete mode 100644 elpa/ejc-sql-20190121.1043/ejc-sql-pkg.el delete mode 100644 elpa/ejc-sql-20190121.1043/ejc-sql.el delete mode 100644 elpa/ejc-sql-20190121.1043/project.clj delete mode 100644 elpa/ejc-sql-20190121.1043/snippets/sql-mode/begin.snippet delete mode 100644 elpa/ejc-sql-20190121.1043/snippets/sql-mode/delete.yasnippet delete mode 100644 elpa/ejc-sql-20190121.1043/snippets/sql-mode/insert.yasnippet delete mode 100644 elpa/ejc-sql-20190121.1043/snippets/sql-mode/select.yasnippet delete mode 100644 elpa/ejc-sql-20190121.1043/snippets/sql-mode/update.yasnippet delete mode 100644 elpa/ejc-sql-20190121.1043/snippets/sql-mode/where.yasnippet delete mode 100644 elpa/ejc-sql-20190121.1043/src/ejc_sql/connect.clj delete mode 100644 elpa/ejc-sql-20190121.1043/src/ejc_sql/jpa.clj delete mode 100644 elpa/ejc-sql-20190121.1043/src/ejc_sql/lib.clj delete mode 100644 elpa/ejc-sql-20190121.1043/src/ejc_sql/output.clj delete mode 100644 elpa/ejc-sql-20190121.1043/src/ejc_sql/structure.clj rename elpa/{helm-20191031.839 => helm-20191101.641}/emacs-helm.sh (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-adaptive.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-autoloads.el (81%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-bookmark.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-buffers.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-color.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-comint.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-command.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-config.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-dabbrev.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-easymenu.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-elisp-package.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-elisp.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-eshell.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-eval.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-external.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-files.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-find.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-font.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-for-files.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-grep.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-help.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-id-utils.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-imenu.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-info.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-locate.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-man.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-misc.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-mode.el (99%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-net.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-occur.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-pkg.el (76%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-regexp.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-ring.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-semantic.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-shell.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-sys.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-tags.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-types.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-utils.el (100%) rename elpa/{helm-20191031.839 => helm-20191101.641}/helm-x-files.el (100%) rename elpa/{helm-core-20191013.626 => helm-core-20191031.1931}/helm-core-autoloads.el (85%) rename elpa/{helm-core-20191013.626 => helm-core-20191031.1931}/helm-core-pkg.el (64%) rename elpa/{helm-core-20191013.626 => helm-core-20191031.1931}/helm-lib.el (100%) rename elpa/{helm-core-20191013.626 => helm-core-20191031.1931}/helm-multi-match.el (100%) rename elpa/{helm-core-20191013.626 => helm-core-20191031.1931}/helm-source.el (99%) rename elpa/{helm-core-20191013.626 => helm-core-20191031.1931}/helm.el (99%) delete mode 100644 elpa/hydra-readme.txt delete mode 100644 elpa/json-mode-readme.txt create mode 100644 elpa/lv-20191025.1326/lv-autoloads.el create mode 100644 elpa/lv-20191025.1326/lv-pkg.el create mode 100644 elpa/lv-20191025.1326/lv.el create mode 100644 elpa/lv-readme.txt create mode 100644 elpa/parsebib-readme.txt create mode 100644 elpa/parseclj-20190531.711/parseclj-ast.el create mode 100644 elpa/parseclj-20190531.711/parseclj-autoloads.el create mode 100644 elpa/parseclj-20190531.711/parseclj-lex.el create mode 100644 elpa/parseclj-20190531.711/parseclj-parser.el create mode 100644 elpa/parseclj-20190531.711/parseclj-pkg.el create mode 100644 elpa/parseclj-20190531.711/parseclj.el create mode 100644 elpa/parseedn-20190331.1058/parseedn-autoloads.el create mode 100644 elpa/parseedn-20190331.1058/parseedn-pkg.el create mode 100644 elpa/parseedn-20190331.1058/parseedn.el create mode 100644 elpa/parseedn-readme.txt diff --git a/elpa/a-20180907.953/a-autoloads.el b/elpa/a-20180907.953/a-autoloads.el new file mode 100644 index 00000000..c9ec568d --- /dev/null +++ b/elpa/a-20180907.953/a-autoloads.el @@ -0,0 +1,22 @@ +;;; a-autoloads.el --- automatically extracted autoloads +;; +;;; Code: + +(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path)))) + + +;;;### (autoloads nil "a" "a.el" (0 0 0 0)) +;;; Generated autoloads from a.el + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "a" '("a-"))) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; coding: utf-8 +;; End: +;;; a-autoloads.el ends here diff --git a/elpa/a-20180907.953/a-pkg.el b/elpa/a-20180907.953/a-pkg.el new file mode 100644 index 00000000..f07f8644 --- /dev/null +++ b/elpa/a-20180907.953/a-pkg.el @@ -0,0 +1,2 @@ +;;; -*- no-byte-compile: t -*- +(define-package "a" "20180907.953" "Associative data structure functions" '((emacs "25")) :commit "18966975db7110d0aac726be95b593e2fc3d44ed" :keywords '("lisp") :authors '(("Arne Brasseur" . "arne@arnebrasseur.net")) :maintainer '("Arne Brasseur" . "arne@arnebrasseur.net") :url "https://github.com/plexus/a.el") diff --git a/elpa/a-20180907.953/a.el b/elpa/a-20180907.953/a.el new file mode 100644 index 00000000..b699160e --- /dev/null +++ b/elpa/a-20180907.953/a.el @@ -0,0 +1,347 @@ +;;; a.el --- Associative data structure functions -*- lexical-binding: t; -*- + +;; Copyright (C) 2017 Arne Brasseur + +;; Author: Arne Brasseur +;; URL: https://github.com/plexus/a.el +;; Package-Version: 20180907.953 +;; Keywords: lisp +;; Version: 0.1.1 +;; Package-Requires: ((emacs "25")) + +;; This file is not part of GNU Emacs. + +;; This file is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Commentary: + +;; Library for dealing with associative data structures: alists, hash-maps, and +;; vectors (for vectors, the indices are treated as keys). +;; +;; This library is largely inspired by Clojure, it has many of the functions +;; found in clojure.core, prefixed with `a-'. All functions treat their +;; arguments as immutable, so e.g. `a-assoc' will clone the hash-table or alist +;; it is given. Keep this in mind when writing performance sensitive code. + +;;; Code: + +(eval-when-compile (require 'subr-x)) ;; for things like hash-table-keys + +(require 'cl-lib) +(require 'seq) + +(defun a-associative-p (obj) + (or (not obj) + (hash-table-p obj) + (and (consp obj) (consp (car obj))))) + +(defalias 'a-associative? 'a-associative-p) + +(defun a-get (map key &optional not-found) + "Return the value MAP mapped to KEY, NOT-FOUND or nil if key not present." + (cond + ;; own implementation instead of alist-get so keys are checked with equal + ;; instead of eq + ((listp map) + (a--alist-get map key not-found)) + + ((vectorp map) + (if (a-has-key? map key) + (aref map key) + not-found)) + + ((hash-table-p map) + (gethash key map not-found)) + (t (user-error "Not associative: %S" map)))) + +(defun a--alist-get (map key &optional not-found) + "Like alist-get, but uses equal instead of eq to look up in map MAP key KEY. +Returns NOT-FOUND if the key is not present, or `nil' if +NOT-FOUND is not specified." + (cl-block nil + (seq-doseq (pair map) + (when (equal (car pair) key) + (cl-return (cdr pair)))) + not-found)) + +(defun a-get-in (m ks &optional not-found) + "Look up a value in a nested associative structure. + +Given a data structure M, and a sequence of keys KS, find the +value found by using each key in turn to do a lookup in the next +\"layer\". Return `nil' if the key is not present, or the NOT-FOUND +value if supplied." + (let ((result m)) + (cl-block nil + (seq-doseq (k ks) + (if (a-has-key? result k) + (setq result (a-get result k)) + (cl-return not-found))) + result))) + +(defmacro a-get* (&rest keys) + "Look up a value in a nested associative structure. + +Like a-get-in, but takes the key sequence KEYS directly as vararg +arguments, rather than as a single sequence." + (cl-labels ((rec (keys) + `(a-get ,(if (and (consp (cdr keys)) + (cddr keys)) + (rec (cdr keys)) + (cadr keys)) + ,(car keys)))) + (rec (nreverse keys)))) + +(defun a-has-key (coll k) + "Check if the given associative collection COLL has a certain key K." + (cond + ((listp coll) (not (eq (a--alist-get coll k :not-found) :not-found))) + ((vectorp coll) (and (integerp k) (< -1 k (length coll)))) + ((hash-table-p coll) (not (eq (gethash k coll :not-found) :not-found))) + (t (user-error "Not associative: %S" coll)))) + +(defalias 'a-has-key? 'a-has-key) + +(defun a-assoc-1 (coll k v) + "Like `a-assoc', (in COLL assoc K with V) but only takes a single k-v pair. +Internal helper function." + (cond + ((listp coll) + (if (a-has-key? coll k) + (mapcar (lambda (entry) + (if (equal (car entry) k) + (cons k v) + entry)) + coll) + (cons (cons k v) coll))) + + ((vectorp coll) + (if (and (integerp k) (> k 0)) + (if (< k (length coll)) + (let ((copy (copy-sequence coll))) + (aset copy k v) + copy) + (vconcat coll (make-list (- k (length coll)) nil) (list v))))) + + ((hash-table-p coll) + (let ((copy (copy-hash-table coll))) + (puthash k v copy) + copy)))) + +(defun a-assoc (coll &rest kvs) + "Return an updated collection COLL, associating values with keys KVS." + (when (not (cl-evenp (a-count kvs))) + (user-error "a-assoc requires an even number of arguments!")) + (seq-reduce (lambda (coll kv) + (seq-let [k v] kv + (a-assoc-1 coll k v))) + (seq-partition kvs 2) + coll)) + +(defun a-keys (coll) + "Return the keys in the collection COLL." + (cond + ((listp coll) + (mapcar #'car coll)) + + ((hash-table-p coll) + (hash-table-keys coll)))) + +(defun a-vals (coll) + "Return the values in the collection COLL." + (cond + ((listp coll) + (mapcar #'cdr coll)) + + ((hash-table-p coll) + (hash-table-values coll)))) + +(defun a-reduce-kv (fn from coll) + "Reduce with FN starting from FROM the collection COLL. +Reduce an associative collection COLL, starting with an initial +value of FROM. The reducing function FN receives the intermediate +value, key, and value." + (seq-reduce (lambda (acc key) + (funcall fn acc key (a-get coll key))) + (a-keys coll) + from)) + +(defun a-count (coll) + "Count the number of key-value pairs in COLL. +Like length, but can also return the length of hash tables." + (cond + ((seqp coll) + (length coll)) + + ((hash-table-p coll) + (hash-table-count coll)))) + +(defun a-equal (a b) + "Compare collections A, B for value equality. + +Associative collections (hash tables and a-lists) are considered +equal if they contain equal key-value pairs, regardless of order. + +Sequences (lists or vectors) are considered equal if they contain +the same elements in the same order. + +Collection elements are compared using `a-equal'. In other words, +the equality check is recursive, resulting in a \"deep\" equality +check. + +Anything that isn't associative or a sequence is compared with +`equal'." + (cond + ((and (a-associative? a) (a-associative? b)) + (or (equal a b) + (when (eq (a-count a) (a-count b)) + (cl-block nil + (seq-doseq (k (a-keys a)) + (when (not (a-equal (a-get a k) (a-get b k))) + (cl-return nil))) + t)))) + ((and (sequencep a) (sequencep b)) + (and (eq (length a) (length b)) + (or (and (seq-empty-p a) (seq-empty-p b)) + (and (a-equal (elt a 0) (elt b 0)) + (a-equal (seq-drop a 1) (seq-drop b 1)))))) + (t + (equal a b)))) + +(defalias 'a-equal? 'a-equal) + +(defun a-merge (&rest colls) + "Merge multiple associative collections. +Return the type of the first collection COLLS." + (seq-reduce (lambda (this that) + (a-reduce-kv (lambda (coll k v) + (a-assoc coll k v)) + this + that)) + (cdr colls) + (car colls))) + +(defun a-merge-with (f &rest colls) + "Merge multiple associative collections. +Return the type of the first collection COLLS. If a key exists in +both, then combine the associated values by calling f on them." + (seq-reduce (lambda (this that) + (a-reduce-kv (lambda (coll k v) + (a-assoc coll k (if (a-has-key coll k) + (funcall f v (a-get coll k)) + v))) + this + that)) + (cdr colls) + (car colls))) + +(defun a-alist (&rest kvs) + "Create an association list from the given keys and values KVS. +Arguments are simply provided in sequence, rather than as lists or cons cells. +For example: (a-alist :foo 123 :bar 456)" + (mapcar (lambda (kv) (cons (car kv) (cadr kv))) (seq-partition kvs 2))) + +(defalias 'a-list 'a-alist) + +(defun a-hash-table (&rest kvs) + "Create a hash table from the given keys and values KVS. +Arguments are simply provided in sequence, rather than as lists +or cons cells. As \"test\" for the hash table, equal is used. The +hash table is created without extra storage space, so with a size +equal to amount of key-value pairs, since it is assumed to be +treated as immutable. +For example: (a-hash-table :foo 123 :bar 456)" + (let* ((kv-pairs (seq-partition kvs 2)) + (hash-map (make-hash-table :test 'equal :size (length kv-pairs)))) + (seq-do (lambda (pair) + (puthash (car pair) (cadr pair) hash-map)) + kv-pairs) + hash-map)) + +(defun a-assoc-in (coll keys value) + "In collection COLL, at location KEYS, associate value VALUE. +Associates a value in a nested associative collection COLL, where +KEYS is a sequence of keys and VALUE is the new value and returns +a new nested structure. If any levels do not exist, association +lists will be created." + (cl-case (length keys) + (0 coll) + (1 (a-assoc-1 coll (elt keys 0) value)) + (t (a-assoc-1 coll + (elt keys 0) + (a-assoc-in (a-get coll (elt keys 0)) + (seq-drop keys 1) + value))))) + +(defun a-dissoc--list (list keys) + "Return updated LIST with KEYS removed. +Internal helper. Use `a-dissoc' instead." + (a-reduce-kv (lambda (res k v) + (if (member k keys) + res + (cons (cons k v) res))) + nil + list)) + +(defun a-dissoc--hash-table (table keys) + "Return updated TABLE with KEYS removed. +Internal helper. Use `a-dissoc' instead." + (let ((new-table (make-hash-table :size (hash-table-count table) + :test (hash-table-test table))) + (rest-keys (seq-remove (lambda (k) + (member k keys)) + (a-keys table)))) + (seq-doseq (k rest-keys) + (puthash k (gethash k table) new-table)) + new-table)) + +(defun a-dissoc (coll &rest keys) + "Return an updated version of collection COLL with the KEY removed." + (cond + ((listp coll) (a-dissoc--list coll keys)) + ((hash-table-p coll) (a-dissoc--hash-table coll keys)))) + +(defun a-update (coll key fn &rest args) + "In collection COLL, at location KEY, apply FN with extra args ARGS. +'Updates' a value in an associative collection COLL, where KEY is +a key and FN is a function that will take the old value and any +supplied args and return the new value, and returns a new +structure. If the key does not exist, nil is passed as the old +value." + (a-assoc-1 coll + key + (apply #'funcall fn (a-get coll key) args))) + +(defun a-update-in (coll keys fn &rest args) + "In collection COLL, at location KEYS, apply FN with extra args ARGS. +'Updates' a value in a nested associative collection COLL, where +KEYS is a sequence of keys and FN is a function that will take +the old value and any supplied ARGS and return the new value, and +returns a new nested structure. If any levels do not exist, +association lists will be created." + (cl-case (length keys) + (0 coll) + (1 (apply #'a-update coll (elt keys 0) fn args)) + (t (a-assoc-1 coll + (elt keys 0) + (apply #'a-update-in + (a-get coll (elt keys 0)) + (seq-drop keys 1) + fn + args))))) + +(provide 'a) +;;; a.el ends here diff --git a/elpa/biblio-20190624.1408/biblio-arxiv.el b/elpa/biblio-20190624.1408/biblio-arxiv.el new file mode 100644 index 00000000..e5498a26 --- /dev/null +++ b/elpa/biblio-20190624.1408/biblio-arxiv.el @@ -0,0 +1,147 @@ +;;; biblio-arxiv.el --- Lookup and import bibliographic entries from arXiv -*- lexical-binding: t -*- + +;; Copyright (C) 2016 Clément Pit-Claudel + +;; Author: Clément Pit-Claudel +;; URL: http://github.com/cpitclaudel/biblio.el + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: +;; +;; Lookup and download bibliographic records from arXiv using `arxiv-lookup'. +;; When a DOI is available, the metadata is fetched from the DOI's issuer; +;; otherwise, this package uses arXiv's metadata to generate an entry. +;; +;; This file implements a backend for the for the `biblio' package (which see for more +;; documentation). + +;;; Code: + +(require 'biblio-core) +(require 'biblio-doi) +(require 'timezone) + +(defgroup biblio-arxiv nil + "arXiv support in biblio.el" + :group 'biblio) + +(defcustom biblio-arxiv-bibtex-header "online" + "Which header to use for BibTeX entries generated from arXiv metadata." + :group 'biblio + :type 'string) + +(defun biblio-arxiv--build-bibtex-1 (metadata) + "Create an unformated BibTeX record for METADATA." + (let-alist metadata + (format "@%s{NO_KEY, +author = {%s}, +title = {{%s}}, +year = {%s}, +archivePrefix = {arXiv}, +eprint = {%s}, +primaryClass = {%s}}" + biblio-arxiv-bibtex-header + (biblio-join-1 " AND " .authors) + .title .year .identifier .category))) + +(defun biblio-arxiv--build-bibtex (metadata) + "Create a BibTeX record for METADATA." + (let-alist metadata + (message "Auto-generating a BibTeX entry for %S." .id) + (biblio-format-bibtex (biblio-arxiv--build-bibtex-1 metadata) t))) + +(defun biblio-arxiv--forward-bibtex (metadata forward-to) + "Forward BibTeX for arXiv entry METADATA to FORWARD-TO." + (let-alist metadata + (if (seq-empty-p .doi) + (funcall forward-to (biblio-arxiv--build-bibtex metadata)) + (biblio-doi-forward-bibtex .doi forward-to)))) + +(defun biblio-arxiv--format-author (author) + "Format AUTHOR for arXiv search results." + (when (eq (car-safe author) 'author) + (let-alist (cdr author) + (biblio-join " " + (cadr .name) + (biblio-parenthesize (cadr .arxiv:affiliation)))))) + +(defun biblio-arxiv--extract-id (id) + "Extract identifier from ID, the URL of an arXiv abstract." + (replace-regexp-in-string "https?://arxiv.org/abs/" "" id)) + +(defun biblio-arxiv--pdf-url (id) + "Extract PDF url from ID of an arXiv entry." + (when id + (concat "http://arxiv.org/pdf/" id))) + +(defun biblio-arxiv--extract-interesting-fields (entry) + "Prepare an arXiv search result ENTRY for display." + (let-alist entry + (let ((id (biblio-arxiv--extract-id (cadr .id)))) + (list (cons 'doi (cadr .arxiv:doi)) + (cons 'identifier id) + (cons 'year (aref (timezone-parse-date (cadr .published)) 0)) + (cons 'title (cadr .title)) + (cons 'authors (seq-map #'biblio-arxiv--format-author entry)) + (cons 'container (cadr .arxiv:journal_ref)) + (cons 'category + (biblio-alist-get 'term (car .arxiv:primary_category))) + (cons 'references (list (cadr .arxiv:doi) id)) + (cons 'type "eprint") + (cons 'url (biblio-alist-get 'href (car .link))) + (cons 'direct-url (biblio-arxiv--pdf-url id)))))) + +(defun biblio-arxiv--entryp (entry) + "Check if ENTRY is an arXiv entry." + (eq (car-safe entry) 'entry)) + +(defun biblio-arxiv--parse-search-results () + "Extract search results from arXiv response." + (biblio-decode-url-buffer 'utf-8) + (let-alist (xml-parse-region (point-min) (point-max)) + (seq-map #'biblio-arxiv--extract-interesting-fields + (seq-filter #'biblio-arxiv--entryp .feed)))) + +(defun biblio-arxiv--url (query) + "Create an arXiv url to look up QUERY." + (format "http://export.arxiv.org/api/query?search_query=%s" + (url-encode-url query))) + +;;;###autoload +(defun biblio-arxiv-backend (command &optional arg &rest more) + "A arXiv backend for biblio.el. +COMMAND, ARG, MORE: See `biblio-backends'." + (pcase command + (`name "arXiv") + (`prompt "arXiv query: ") + (`url (biblio-arxiv--url arg)) + (`parse-buffer (biblio-arxiv--parse-search-results)) + (`forward-bibtex (biblio-arxiv--forward-bibtex arg (car more))) + (`register (add-to-list 'biblio-backends #'biblio-arxiv-backend)))) + +;;;###autoload +(add-hook 'biblio-init-hook #'biblio-arxiv-backend) + +;;;###autoload +(defun biblio-arxiv-lookup (&optional query) + "Start an arXiv search for QUERY, prompting if needed." + (interactive) + (biblio-lookup #'biblio-arxiv-backend query)) + +;;;###autoload +(defalias 'arxiv-lookup 'biblio-arxiv-lookup) + +(provide 'biblio-arxiv) +;;; biblio-arxiv.el ends here diff --git a/elpa/biblio-20190624.1408/biblio-autoloads.el b/elpa/biblio-20190624.1408/biblio-autoloads.el new file mode 100644 index 00000000..1ebfebc7 --- /dev/null +++ b/elpa/biblio-20190624.1408/biblio-autoloads.el @@ -0,0 +1,181 @@ +;;; biblio-autoloads.el --- automatically extracted autoloads +;; +;;; Code: + +(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path)))) + + +;;;### (autoloads nil "biblio-arxiv" "biblio-arxiv.el" (0 0 0 0)) +;;; Generated autoloads from biblio-arxiv.el + +(autoload 'biblio-arxiv-backend "biblio-arxiv" "\ +A arXiv backend for biblio.el. +COMMAND, ARG, MORE: See `biblio-backends'. + +\(fn COMMAND &optional ARG &rest MORE)" nil nil) + +(add-hook 'biblio-init-hook #'biblio-arxiv-backend) + +(autoload 'biblio-arxiv-lookup "biblio-arxiv" "\ +Start an arXiv search for QUERY, prompting if needed. + +\(fn &optional QUERY)" t nil) + +(defalias 'arxiv-lookup 'biblio-arxiv-lookup) + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "biblio-arxiv" '("biblio-arxiv-"))) + +;;;*** + +;;;### (autoloads nil "biblio-crossref" "biblio-crossref.el" (0 0 +;;;;;; 0 0)) +;;; Generated autoloads from biblio-crossref.el + +(autoload 'biblio-crossref-backend "biblio-crossref" "\ +A CrossRef backend for biblio.el. +COMMAND, ARG, MORE: See `biblio-backends'. + +\(fn COMMAND &optional ARG &rest MORE)" nil nil) + +(add-hook 'biblio-init-hook #'biblio-crossref-backend) + +(autoload 'biblio-crossref-lookup "biblio-crossref" "\ +Start a CrossRef search for QUERY, prompting if needed. + +\(fn &optional QUERY)" t nil) + +(defalias 'crossref-lookup 'biblio-crossref-lookup) + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "biblio-crossref" '("biblio-crossref-"))) + +;;;*** + +;;;### (autoloads nil "biblio-dblp" "biblio-dblp.el" (0 0 0 0)) +;;; Generated autoloads from biblio-dblp.el + +(autoload 'biblio-dblp-backend "biblio-dblp" "\ +A DBLP backend for biblio.el. +COMMAND, ARG, MORE: See `biblio-backends'. + +\(fn COMMAND &optional ARG &rest MORE)" nil nil) + +(add-hook 'biblio-init-hook #'biblio-dblp-backend) + +(autoload 'biblio-dblp-lookup "biblio-dblp" "\ +Start a DBLP search for QUERY, prompting if needed. + +\(fn &optional QUERY)" t nil) + +(defalias 'dblp-lookup 'biblio-dblp-lookup) + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "biblio-dblp" '("biblio-dblp--"))) + +;;;*** + +;;;### (autoloads nil "biblio-dissemin" "biblio-dissemin.el" (0 0 +;;;;;; 0 0)) +;;; Generated autoloads from biblio-dissemin.el + +(autoload 'biblio-dissemin-lookup "biblio-dissemin" "\ +Retrieve a record by DOI from Dissemin, and display it. +Interactively, or if CLEANUP is non-nil, pass DOI through +`biblio-cleanup-doi'. + +\(fn DOI &optional CLEANUP)" t nil) + +(defalias 'dissemin-lookup 'biblio-dissemin-lookup) + +(autoload 'biblio-dissemin--register-action "biblio-dissemin" "\ +Add Dissemin to list of `biblio-selection-mode' actions. + +\(fn)" nil nil) + +(add-hook 'biblio-selection-mode-hook #'biblio-dissemin--register-action) + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "biblio-dissemin" '("biblio-dissemin--"))) + +;;;*** + +;;;### (autoloads nil "biblio-doi" "biblio-doi.el" (0 0 0 0)) +;;; Generated autoloads from biblio-doi.el + +(autoload 'doi-insert-bibtex "biblio-doi" "\ +Insert BibTeX entry matching DOI. + +\(fn DOI)" t nil) + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "biblio-doi" '("biblio-doi-"))) + +;;;*** + +;;;### (autoloads nil "biblio-download" "biblio-download.el" (0 0 +;;;;;; 0 0)) +;;; Generated autoloads from biblio-download.el + +(autoload 'biblio-download--register-action "biblio-download" "\ +Add download to list of `biblio-selection-mode' actions. + +\(fn)" nil nil) + +(add-hook 'biblio-selection-mode-hook #'biblio-download--register-action) + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "biblio-download" '("biblio-download-"))) + +;;;*** + +;;;### (autoloads nil "biblio-hal" "biblio-hal.el" (0 0 0 0)) +;;; Generated autoloads from biblio-hal.el + +(autoload 'biblio-hal-backend "biblio-hal" "\ +A HAL backend for biblio.el. +COMMAND, ARG, MORE: See `biblio-backends'. + +\(fn COMMAND &optional ARG &rest MORE)" nil nil) + +(add-hook 'biblio-init-hook #'biblio-hal-backend) + +(autoload 'biblio-hal-lookup "biblio-hal" "\ +Start a HAL search for QUERY, prompting if needed. + +\(fn &optional QUERY)" t nil) + +(defalias 'hal-lookup 'biblio-hal-lookup) + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "biblio-hal" '("biblio-hal--"))) + +;;;*** + +;;;### (autoloads nil "biblio-ieee" "biblio-ieee.el" (0 0 0 0)) +;;; Generated autoloads from biblio-ieee.el + +(autoload 'biblio-ieee-backend "biblio-ieee" "\ +A IEEE Xplore backend for biblio.el. +COMMAND, ARG, MORE: See `biblio-backends'. + +\(fn COMMAND &optional ARG &rest MORE)" nil nil) + +(add-hook 'biblio-init-hook #'biblio-ieee-backend) + +(autoload 'biblio-ieee-lookup "biblio-ieee" "\ +Start a IEEE search for QUERY, prompting if needed. + +\(fn &optional QUERY)" t nil) + +(defalias 'ieee-lookup 'biblio-ieee-lookup) + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "biblio-ieee" '("biblio-ieee--"))) + +;;;*** + +;;;### (autoloads nil nil ("biblio-pkg.el" "biblio.el") (0 0 0 0)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; coding: utf-8 +;; End: +;;; biblio-autoloads.el ends here diff --git a/elpa/biblio-20190624.1408/biblio-crossref.el b/elpa/biblio-20190624.1408/biblio-crossref.el new file mode 100644 index 00000000..8ad57784 --- /dev/null +++ b/elpa/biblio-20190624.1408/biblio-crossref.el @@ -0,0 +1,113 @@ +;;; biblio-crossref.el --- Lookup and import bibliographic entries from CrossRef -*- lexical-binding: t -*- + +;; Copyright (C) 2016 Clément Pit-Claudel + +;; Author: Clément Pit-Claudel +;; URL: http://github.com/cpitclaudel/biblio.el + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: +;; +;; Lookup and download bibliographic records from CrossRef (a very nicely +;; curated metadata engine) using `crossref-lookup'. +;; +;; This file implements a backend for the `biblio' package (which see for more +;; documentation). + +;;; Code: + +(require 'biblio-core) +(require 'biblio-doi) + +(defcustom biblio-crossref-user-email-address nil + "Email address to include in CrossRef queries, or nil. +CrossRef gives priority to queries that include an email address. +See URL `https://github.com/CrossRef/rest-api-doc#etiquette' for +more details." + :group 'biblio + :type '(choice (const :tag "Do not include an email address." nil) + (string :tag "Include an email address."))) + +(defun biblio-crossref--forward-bibtex (metadata forward-to) + "Forward BibTeX for CrossRef entry METADATA to FORWARD-TO." + (biblio-doi-forward-bibtex (biblio-alist-get 'doi metadata) forward-to)) + +(defun biblio-crossref--format-affiliation (affiliation) + "Format AFFILIATION for CrossRef search results." + (mapconcat (apply-partially #'biblio-alist-get 'name) affiliation ", ")) + +(defun biblio-crossref--format-author (author) + "Format AUTHOR for CrossRef search results." + (let-alist author + (biblio-join " " + .given .family (biblio-parenthesize (biblio-crossref--format-affiliation .affiliation))))) + +(defun biblio-crossref--extract-interesting-fields (item) + "Prepare a CrossRef search result ITEM for display." + (let-alist item + (list (cons 'doi .DOI) + (cons 'year (let ((year (aref (aref .issued.date-parts 0) 0))) + (and (numberp year) (number-to-string year)))) + (cons 'title (biblio-join " " + (biblio-join-1 ", " .title) + (biblio-parenthesize (biblio-join-1 ", " .subtitle)))) + (cons 'authors (seq-map #'biblio-crossref--format-author .author)) + (cons 'publisher .publisher) + (cons 'container .container-title) + (cons 'references (seq-concatenate 'list (list .DOI) .isbn)) + (cons 'type .type) + (cons 'url .URL)))) + +(defun biblio-crossref--parse-search-results () + "Extract search results from CrossRef response." + (biblio-decode-url-buffer 'utf-8) + (let-alist (json-read) + (unless (string= .status "ok") + (display-warning 'biblio-crossref "CrossRef query failed")) + (seq-map #'biblio-crossref--extract-interesting-fields .message.items))) + +(defun biblio-crossref--url (query) + "Create a CrossRef url to look up QUERY." + (format "http://api.crossref.org/works?query=%s%s" + (url-encode-url query) + (if biblio-crossref-user-email-address + (format "&mailto=%s" (url-encode-url biblio-crossref-user-email-address)) ""))) + +;;;###autoload +(defun biblio-crossref-backend (command &optional arg &rest more) + "A CrossRef backend for biblio.el. +COMMAND, ARG, MORE: See `biblio-backends'." + (pcase command + (`name "CrossRef") + (`prompt "CrossRef query: ") + (`url (biblio-crossref--url arg)) + (`parse-buffer (biblio-crossref--parse-search-results)) + (`forward-bibtex (biblio-crossref--forward-bibtex arg (car more))) + (`register (add-to-list 'biblio-backends #'biblio-crossref-backend)))) + +;;;###autoload +(add-hook 'biblio-init-hook #'biblio-crossref-backend) + +;;;###autoload +(defun biblio-crossref-lookup (&optional query) + "Start a CrossRef search for QUERY, prompting if needed." + (interactive) + (biblio-lookup #'biblio-crossref-backend query)) + +;;;###autoload +(defalias 'crossref-lookup 'biblio-crossref-lookup) + +(provide 'biblio-crossref) +;;; biblio-crossref.el ends here diff --git a/elpa/biblio-20190624.1408/biblio-dblp.el b/elpa/biblio-20190624.1408/biblio-dblp.el new file mode 100644 index 00000000..1e23c076 --- /dev/null +++ b/elpa/biblio-20190624.1408/biblio-dblp.el @@ -0,0 +1,96 @@ +;;; biblio-dblp.el --- Lookup and import bibliographic entries from DBLP -*- lexical-binding: t -*- + +;; Copyright (C) 2016 Clément Pit-Claudel + +;; Author: Clément Pit-Claudel +;; URL: http://github.com/cpitclaudel/biblio.el + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: +;; +;; Lookup and download bibliographic records from DBLP (a great source of +;; references for Computer Science papers) using `dblp-lookup'. +;; +;; This file implements a backend for the for the `biblio' package (which see for more +;; documentation). + +;;; Code: + +(require 'biblio-core) + +(defun biblio-dblp--forward-bibtex (metadata forward-to) + "Forward BibTeX for DBLP entry METADATA to FORWARD-TO." + (let* ((source-url (biblio-alist-get 'url metadata)) + (url (replace-regexp-in-string "/rec/" "/rec/bib2/" source-url t t))) + (biblio-url-retrieve url (biblio-generic-url-callback + (lambda () ;; No allowed errors, so no arguments + "Parse DBLP BibTeX results." + (funcall forward-to + (biblio-format-bibtex + (biblio-response-as-utf-8)))))))) + +(defun biblio-dblp--extract-interesting-fields (item) + "Prepare a DBLP search result ITEM for display." + (let-alist (biblio-alist-get 'info item) + (list (cons 'year (cadr .year)) + (cons 'title (cadr .title)) + (cons 'authors (seq-map #'cl-caddr (cdr .authors))) + (cons 'container (cadr .venue)) + (cons 'references nil) + (cons 'type (cadr .type)) + (cons 'url (cadr .url))))) + +(defun biblio-dblp--hitp (item) + "Check if ITEM is a DBLP hit." + (eq (car-safe item) 'hit)) + +(defun biblio-dblp--parse-search-results () + "Extract search results from DBLP response." + (biblio-decode-url-buffer 'utf-8) + (let-alist (car (xml-parse-region (point-min) (point-max))) + (unless (string= (cadr .status) "OK") + (display-warning 'biblio-dblp "DBLP query failed")) + (seq-map #'biblio-dblp--extract-interesting-fields (seq-filter #'biblio-dblp--hitp .hits)))) + +(defun biblio-dblp--url (query) + "Create a DBLP url to look up QUERY." + (format "http://dblp.uni-trier.de/search/publ/api?q=%s&format=xml" (url-encode-url query))) + +;;;###autoload +(defun biblio-dblp-backend (command &optional arg &rest more) + "A DBLP backend for biblio.el. +COMMAND, ARG, MORE: See `biblio-backends'." + (pcase command + (`name "DBLP") + (`prompt "DBLP query: ") + (`url (biblio-dblp--url arg)) + (`parse-buffer (biblio-dblp--parse-search-results)) + (`forward-bibtex (biblio-dblp--forward-bibtex arg (car more))) + (`register (add-to-list 'biblio-backends #'biblio-dblp-backend)))) + +;;;###autoload +(add-hook 'biblio-init-hook #'biblio-dblp-backend) + +;;;###autoload +(defun biblio-dblp-lookup (&optional query) + "Start a DBLP search for QUERY, prompting if needed." + (interactive) + (biblio-lookup #'biblio-dblp-backend query)) + +;;;###autoload +(defalias 'dblp-lookup 'biblio-dblp-lookup) + +(provide 'biblio-dblp) +;;; biblio-dblp.el ends here diff --git a/elpa/biblio-20190624.1408/biblio-dissemin.el b/elpa/biblio-20190624.1408/biblio-dissemin.el new file mode 100644 index 00000000..7463f7e3 --- /dev/null +++ b/elpa/biblio-20190624.1408/biblio-dissemin.el @@ -0,0 +1,157 @@ +;;; biblio-dissemin.el --- Lookup bibliographic information and open access records from Dissemin -*- lexical-binding: t -*- + +;; Copyright (C) 2016 Clément Pit-Claudel + +;; Author: Clément Pit-Claudel +;; URL: http://github.com/cpitclaudel/biblio.el + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: +;; +;; Lookup publication records on Dissemin by DOI using `dissemin-lookup'. +;; +;; This package also plugs into `biblio-selection-mode' by adding an entry to +;; the extended actions menu (`x') to quickly locate the Dissemin record of +;; e.g. a CrossRef entry. + +;;; Code: + +(require 'biblio-core) + +(defun biblio-dissemin--format-author (author) + "Format a Dissemin AUTHOR entry." + (let-alist author + (format "%s %s" .name.first .name.last))) + +(defun biblio-dissemin--insert-button (url prefix) + "Insert a button pointing to URL, prefixed by PREFIX." + (unless (seq-empty-p url) + (insert "\n" prefix) + (insert (biblio-make-url-button url)))) + +(defun biblio-dissemin--insert-record (record) + "Insert a Dissemin RECORD entry into the current buffer." + (let-alist record + (insert "\n\n") + (biblio-with-fontification 'font-lock-preprocessor-face + (biblio-insert-with-prefix ">> " .identifier)) + (biblio-dissemin--insert-button .pdf_url " ") + (unless (string= .pdf_url .splash_url) + (biblio-dissemin--insert-button .splash_url " ")) + (unless (seq-empty-p .abstract) + (insert "\n") + ;; (biblio-with-fontification 'font-lock-doc-face + (biblio-insert-with-prefix " " .abstract)))) + +(defun biblio-dissemin--translate-classification (classification) + "Translate Dissemin's CLASSIFICATION for display." + (pcase classification + (`"OA" "Available from the publisher") + (`"OK" "Some versions may be shared by the author") + (`"UNK" "Sharing policy is unclear") + (`"CLOSED" "Subject to a restrictive sharing policy") + (_ classification))) + +(defun biblio-dissemin--suggest-upload (doi) + "Insert a link to Dissemin's upload page for DOI." + (insert "\n\nDid you write this paper? ") + (biblio-with-fontification '(:weight bold) + (insert + (biblio-make-url-button (format "http://dissem.in/%s" doi) "upload it"))) + (insert "!\n")) + +(defun biblio-dissemin--pretty-print (paper doi) + "Pretty-print a Dissemin PAPER entry (with DOI) to current buffer." + (let-alist paper + (biblio-insert-result + (list (cons 'title .title) + (cons 'authors (seq-map #'biblio-dissemin--format-author .authors)) + (cons 'open-access-status + (biblio-dissemin--translate-classification .classification))) + t) + (biblio-dissemin--insert-button .pdf_url " ") + (if (seq-empty-p .records) + (progn (insert "\n\n(no records)") + (when (member .classification '("OA" "OK")) + (biblio-dissemin--suggest-upload doi))) + (seq-do #'biblio-dissemin--insert-record .records)) + (goto-char (point-min)))) + +(defun biblio-dissemin--print-results (paper doi) + "Create a buffer for Dissemin, and print PAPER (with DOI) into it." + (with-current-buffer (biblio-dissemin--make-buffer) + (let ((inhibit-read-only t)) + (erase-buffer) + (help-mode) + (visual-line-mode) + (biblio-dissemin--pretty-print paper doi)) + (setq buffer-read-only t) + (pop-to-buffer (current-buffer)))) + +(defun biblio-dissemin--make-buffer () + "Create a buffer to display Dissemin results in." + (get-buffer-create "*Dissemin search results*")) + +(defun biblio-dissemin--parse-buffer () + "Extract search results from DBLP response." + (biblio-decode-url-buffer 'utf-8) + (let-alist (json-read) + (unless (string= .status "ok") + (display-warning 'biblio-dissemin "Dissemin query failed")) + .paper)) + +(defun biblio-dissemin--url (doi) + "Create a DBLP url to look up DOI." + (format "http://dissem.in/api/%s" (url-encode-url doi))) + +(defun biblio-dissemin--callback (doi) + "Generate a callback to parse Dissemin results for DOI." + (lambda () ;; no allowed errors, so no arguments + (biblio-dissemin--print-results (biblio-dissemin--parse-buffer) doi))) + +;;;###autoload +(defun biblio-dissemin-lookup (doi &optional cleanup) + "Retrieve a record by DOI from Dissemin, and display it. +Interactively, or if CLEANUP is non-nil, pass DOI through +`biblio-cleanup-doi'." + (interactive "MDOI: \nd") + (when cleanup + (setq doi (biblio-cleanup-doi doi))) + (let ((buf (biblio-dissemin--make-buffer))) + (biblio-url-retrieve (biblio-dissemin--url doi) + (biblio-generic-url-callback (biblio-dissemin--callback doi))) + buf)) + +;;;###autoload +(defalias 'dissemin-lookup 'biblio-dissemin-lookup) + +(defun biblio-dissemin--lookup-record (record) + "Retrieve a RECORD from Dissemin, and display it. +RECORD is a formatted record as expected by `biblio-insert-result'." + (let-alist record + (if .doi (dissemin-lookup .doi) + (user-error "Dissemin needs a DOI, but this record does not contain one")))) + +;;;###autoload +(defun biblio-dissemin--register-action () + "Add Dissemin to list of `biblio-selection-mode' actions." + (add-to-list 'biblio-selection-mode-actions-alist + '("Dissemin (find open access copies of this article)" . biblio-dissemin--lookup-record))) + +;;;###autoload +(add-hook 'biblio-selection-mode-hook #'biblio-dissemin--register-action) + +(provide 'biblio-dissemin) +;;; biblio-dissemin.el ends here diff --git a/elpa/biblio-20190624.1408/biblio-doi.el b/elpa/biblio-20190624.1408/biblio-doi.el new file mode 100644 index 00000000..e4b1a4e9 --- /dev/null +++ b/elpa/biblio-20190624.1408/biblio-doi.el @@ -0,0 +1,123 @@ +;;; biblio-doi.el --- Retrieve BibTeX entries by DOI -*- lexical-binding: t -*- + +;; Copyright (C) 2016 Clément Pit-Claudel + +;; Author: Clément Pit-Claudel +;; URL: http://github.com/cpitclaudel/biblio.el + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + + +;;; Commentary: +;; +;; Retrieve and insert BibTeX records by DOI using `doi-insert-bibtex'. +;; Information is retrieved from DOI issuing sites of each DOI using the +;; “application/x-bibtex” and “text/bibliography” request types, falling back to +;; CrossCite if unavailable. +;; +;; This package integrates with `biblio-selection-mode', and is part of the more +;; general `biblio' package (which see for more documentation). + +(require 'biblio-core) + +;;; Code: + +(defun biblio-doi--dx-url (doi) + "Create a doi.org url for DOI." + (format "http://doi.org/%s" doi)) + +(defun biblio-doi--crosscite-url (doi) + "Create a crosscite URL to use as a fallback for DOI. +Not all content providers provide BibTeX formatted entries, so +instead of failing reroute the request through crosscite, which +requests a generic format and crates the BibTeX on its own." + (format "http://crosscite.org/citeproc/format?doi=%s&style=bibtex&lang=en-US" doi)) + +(defconst biblio-doi--dx-mime-accept + ;; “Accept:” header; Zenodo recognize x-bibtex but not text/bibliography + "text/bibliography;style=bibtex, application/x-bibtex") + +(defun biblio-doi--set-mime-accept () + "Set `url-mime-accept-string' before contacting the DOI server." + ;; Ugly: let-binding or buffer-locally setting `url-mime-accept-string' does + ;; not work, because `url-http-create-request' can be called from a + ;; sentinel, or from an entirely new buffer (after a redirection). + (setq url-mime-accept-string biblio-doi--dx-mime-accept)) + +(defun biblio-doi--restore-mime-accept () + "Restore `url-mime-accept-string'." + (kill-local-variable 'url-mime-accept-string) + (setq-default url-mime-accept-string nil)) + +(defun biblio-doi--insert (bibtex buffer) + "Insert formatted BIBTEX into BUFFER." + (with-current-buffer buffer + (insert bibtex "\n\n"))) + +(defun biblio-doi--generic-url-callback-1 (errors forward-to) + "Helper function for `biblio-doi--generic-url-callback'. +ERRORS, FORWARD-TO: see there." + (funcall forward-to + (unless errors + (biblio-format-bibtex (biblio-response-as-utf-8))))) + +(defun biblio-doi--generic-url-callback (cleanup-fn forward-to) + "Make an URL-ready callback. +Call CLEANUP-FN in any case, and FORWARD-TO with BibTeX source +or nil depending on whether an error occured. If error 406 +occurs, forward nil; otherwise, signal the error. This is +essentially a thin wrapper around `biblio-generic-url-callback'." + (biblio-generic-url-callback + (lambda (&optional errors) + "Handle response from BibTeX server." + (biblio-doi--generic-url-callback-1 errors forward-to)) + cleanup-fn '(http . 406))) + +(defun biblio-doi--crosscite-callback (forward-to) + "Generate a handler for response of CrossCite server. +FORWARD-TO is the callback to call with the results of the search." + (biblio-doi--generic-url-callback #'ignore forward-to)) + +(defun biblio-doi--forward-bibtex-crosscite (doi forward-to) + "Forward BibTeX entry for DOI from CrossCite to FORWARD-TO." + (biblio-url-retrieve (biblio-doi--crosscite-url doi) (biblio-doi--crosscite-callback forward-to))) + +(defun biblio-doi--dx-callback (forward-to) + "Generate a handler for response of DX server. +FORWARD-TO is the callback to call with the results of the search." + (biblio-doi--generic-url-callback #'biblio-doi--restore-mime-accept forward-to)) + +(defun biblio-doi--forward-bibtex-dx (doi forward-to) + "Forward BibTeX entry for DOI from doi.org to FORWARD-TO." + (biblio-doi--set-mime-accept) + (biblio-url-retrieve (biblio-doi--dx-url doi) (biblio-doi--dx-callback forward-to))) + +(defun biblio-doi-forward-bibtex (doi forward-to) + "Pass BibTeX entry for DOI to FORWARD-TO." + (biblio-doi--forward-bibtex-dx + doi (lambda (result) + (if result (funcall forward-to result) + (biblio-doi--forward-bibtex-crosscite doi forward-to))))) + +;;;###autoload +(defun doi-insert-bibtex (doi) + "Insert BibTeX entry matching DOI." + (interactive "MDOI: ") + (let ((target-buffer (current-buffer))) + (biblio-doi-forward-bibtex + (biblio-cleanup-doi doi) + (lambda (result) (biblio-doi--insert result target-buffer))))) + +(provide 'biblio-doi) +;;; biblio-doi.el ends here diff --git a/elpa/biblio-20190624.1408/biblio-download.el b/elpa/biblio-20190624.1408/biblio-download.el new file mode 100644 index 00000000..ef8acaeb --- /dev/null +++ b/elpa/biblio-20190624.1408/biblio-download.el @@ -0,0 +1,58 @@ +;;; biblio-download.el --- Lookup bibliographic information and open access records from Dissemin -*- lexical-binding: t -*- + +;; Copyright (C) 2016 Clément Pit-Claudel + +;; Author: Clément Pit-Claudel +;; URL: http://github.com/cpitclaudel/biblio.el + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: +;; +;; Download scientific papers directly from Emacs. +;; +;; This package plugs into `biblio-selection-mode' by adding an entry to the +;; extended actions menu (`x'). + +;;; Code: + +(require 'biblio-core) + +(defcustom biblio-download-directory nil + "Where to put downloaded papers." + :group 'biblio + :type 'directory) + +(defun biblio-download--action (record) + "Retrieve a RECORD from Dissemin, and display it. +RECORD is a formatted record as expected by `biblio-insert-result'." + (let-alist record + (if .direct-url + (let* ((fname (concat .identifier ".pdf")) + (target (read-file-name "Save as (see also biblio-download-directory): " + biblio-download-directory fname nil fname))) + (url-copy-file .direct-url (expand-file-name target biblio-download-directory))) + (user-error "This record does not contain a direct URL (try arXiv or HAL)")))) + +;;;###autoload +(defun biblio-download--register-action () + "Add download to list of `biblio-selection-mode' actions." + (add-to-list 'biblio-selection-mode-actions-alist + '("Download this article" . biblio-download--action))) + +;;;###autoload +(add-hook 'biblio-selection-mode-hook #'biblio-download--register-action) + +(provide 'biblio-download) +;;; biblio-download.el ends here diff --git a/elpa/biblio-20190624.1408/biblio-hal.el b/elpa/biblio-20190624.1408/biblio-hal.el new file mode 100644 index 00000000..0d2b0154 --- /dev/null +++ b/elpa/biblio-20190624.1408/biblio-hal.el @@ -0,0 +1,106 @@ +;;; biblio-hal.el --- Lookup and import bibliographic entries from HAL (archives ouvertes) -*- lexical-binding: t -*- + +;; Copyright (C) 2016 Clément Pit-Claudel + +;; Author: Clément Pit-Claudel +;; URL: http://github.com/cpitclaudel/biblio.el + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: +;; +;; Lookup and download bibliographic records from HAL using `hal-lookup'. +;; +;; This file implements a backend for the for the `biblio' package (which see for more +;; documentation). + +;;; Code: + +(require 'biblio-core) + +(defun biblio-hal--forward-bibtex (metadata forward-to) + "Forward BibTeX for HAL entry METADATA to FORWARD-TO." + (funcall forward-to (biblio-alist-get 'bibtex metadata))) + +;; (defun biblio-hal--format-author (author) +;; "Format AUTHOR for HAL search results." +;; (pcase author +;; (`(,author . ,affiliation) +;; (biblio-join " " author (biblio-parenthesize affiliation))))) + +(defun biblio-hal--extract-interesting-fields (item) + "Prepare a HAL search result ITEM for display." + (let-alist item + (list (cons 'doi .doiId_s) + (cons 'year (aref (timezone-parse-date .producedDate_tdate) 0)) + (cons 'bibtex .label_bibtex) + (cons 'title (biblio-join " " + (biblio-join-1 ", " .title_s) + (biblio-parenthesize + (biblio-join-1 ", " .subtitle_s)))) + (cons 'authors .authFullName_s) + ;; Too many institutions? (biblio-parenthesize (biblio-join-1 ", " .structName_s)) + (cons 'publisher .journalPublisher_s) + (cons 'container .journalTitle_s) + (cons 'references (biblio-remove-empty + (list .doiId_s .halId_s .arxivId_s))) + (cons 'type .submitType_s) + (cons 'url .uri_s) + (cons 'direct-url (car (append .files_s nil)))))) + +(defun biblio-hal--parse-search-results () + "Extract search results from HAL response." + (biblio-decode-url-buffer 'utf-8) + (let-alist (json-read) + (unless .response + (display-warning 'biblio-hal "HAL query failed")) + (seq-map #'biblio-hal--extract-interesting-fields .response.docs))) + +(defun biblio-hal--url (query) + "Create a HAL url to look up QUERY." + (format "https://api.archives-ouvertes.fr/search/?q=%s&wt=%s&fl=%s" + (url-encode-url query) "json" + (biblio-join "," ;; Use ‘*’ to show all fields + "arxivId_s" "halId_s" "doiId_s" ;; "journalIssn_s" + "title_s" "subtitle_s" "authFullName_s" "structName_s" + "journalPublisher_s" "submitType_s" ;; "abstract_s" + ;; "journalTitle_s" "volume_s" "issue_s" "page_s" "writingDate_s" + "label_bibtex" "files_s" "uri_s" "producedDate_tdate"))) + +;;;###autoload +(defun biblio-hal-backend (command &optional arg &rest more) + "A HAL backend for biblio.el. +COMMAND, ARG, MORE: See `biblio-backends'." + (pcase command + (`name "HAL") + (`prompt "HAL (archives ouvertes) query: ") + (`url (biblio-hal--url arg)) + (`parse-buffer (biblio-hal--parse-search-results)) + (`forward-bibtex (biblio-hal--forward-bibtex arg (car more))) + (`register (add-to-list 'biblio-backends #'biblio-hal-backend)))) + +;;;###autoload +(add-hook 'biblio-init-hook #'biblio-hal-backend) + +;;;###autoload +(defun biblio-hal-lookup (&optional query) + "Start a HAL search for QUERY, prompting if needed." + (interactive) + (biblio-lookup #'biblio-hal-backend query)) + +;;;###autoload +(defalias 'hal-lookup 'biblio-hal-lookup) + +(provide 'biblio-hal) +;;; biblio-hal.el ends here diff --git a/elpa/biblio-20190624.1408/biblio-ieee.el b/elpa/biblio-20190624.1408/biblio-ieee.el new file mode 100644 index 00000000..39b16f8e --- /dev/null +++ b/elpa/biblio-20190624.1408/biblio-ieee.el @@ -0,0 +1,103 @@ +;;; biblio-ieee.el --- Lookup and import bibliographic entries from IEEE -*- lexical-binding: t -*- + +;; Copyright (C) 2019 Clément Pit-Claudel + +;; Author: Clément Pit-Claudel +;; URL: http://github.com/cpitclaudel/biblio.el + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: +;; +;; Lookup and download bibliographic records from IEEE Xplore using +;; `ieee-lookup'. +;; +;; This package uses `biblio-selection-mode', and plugs into the more general +;; `biblio' package (which see for more documentation). + +;;; Code: + +(require 'biblio-core) +(require 'biblio-doi) + +(defconst biblio-ieee--api-key "rfwzcsz3f9fkhklhii84xdfz" + "API key used to query IEEE; for use only with biblio.el!") + +(defconst biblio-ieee--api-root-url + "http://ieeexploreapi.ieee.org/api/v1/search/articles") + +(defun biblio-ieee--forward-bibtex (metadata forward-to) + "Forward BibTeX for IEEE Xplore entry METADATA to FORWARD-TO." + (biblio-doi-forward-bibtex (biblio-alist-get 'doi metadata) forward-to)) + +(defun biblio-ieee--format-author (author) + "Format AUTHOR for IEEE Xplore search results." + (let-alist author + (biblio-join " " .full_name (biblio-parenthesize .affiliation)))) + +(defun biblio-ieee--extract-interesting-fields (item) + "Prepare a IEEE Xplore search result ITEM for display." + (let-alist item + (list (cons 'doi .doi) + (cons 'year .publication_year) + (cons 'title .title) + (cons 'authors (seq-map #'biblio-ieee--format-author .authors.authors)) + (cons 'publisher .publisher) + (cons 'container .publication_title) + (cons 'references (list .doi .isbn)) + (cons 'type (or .index_terms.author_terms.terms + .index_terms.ieee_terms.terms)) + (cons 'url .abstract_url) + (cons 'direct-url .pdf_url) + (cons 'open-access-status .access_type)))) + +(defun biblio-ieee--parse-search-results () + "Extract search results from IEEE Xplore response." + (biblio-decode-url-buffer 'utf-8) + (let-alist (json-read) + (seq-map #'biblio-ieee--extract-interesting-fields .articles))) + +(defun biblio-ieee--url (query) + "Create an IEEE Xplore url to look up QUERY." + (format "%s?querytext=%s&apikey=%s" + biblio-ieee--api-root-url + (url-encode-url query) + (rot13 biblio-ieee--api-key))) + +;;;###autoload +(defun biblio-ieee-backend (command &optional arg &rest more) + "A IEEE Xplore backend for biblio.el. +COMMAND, ARG, MORE: See `biblio-backends'." + (pcase command + (`name "IEEE Xplore") + (`prompt "IEEE Xplore query: ") + (`url (biblio-ieee--url arg)) + (`parse-buffer (biblio-ieee--parse-search-results)) + (`forward-bibtex (biblio-ieee--forward-bibtex arg (car more))) + (`register (add-to-list 'biblio-backends #'biblio-ieee-backend)))) + +;;;###autoload +(add-hook 'biblio-init-hook #'biblio-ieee-backend) + +;;;###autoload +(defun biblio-ieee-lookup (&optional query) + "Start a IEEE search for QUERY, prompting if needed." + (interactive) + (biblio-lookup #'biblio-ieee-backend query)) + +;;;###autoload +(defalias 'ieee-lookup 'biblio-ieee-lookup) + +(provide 'biblio-ieee) +;;; biblio-ieee.el ends here diff --git a/elpa/biblio-20190624.1408/biblio-pkg.el b/elpa/biblio-20190624.1408/biblio-pkg.el new file mode 100644 index 00000000..ffc6a5fc --- /dev/null +++ b/elpa/biblio-20190624.1408/biblio-pkg.el @@ -0,0 +1,6 @@ +(define-package "biblio" "20190624.1408" "Browse and import bibliographic references from CrossRef, arXiv, DBLP, HAL, Dissemin, and doi.org" + '((emacs "24.3") + (biblio-core "0.2"))) +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/elpa/biblio-20190624.1408/biblio.el b/elpa/biblio-20190624.1408/biblio.el new file mode 100644 index 00000000..cfffbca9 --- /dev/null +++ b/elpa/biblio-20190624.1408/biblio.el @@ -0,0 +1,97 @@ +;;; biblio.el --- Browse and import bibliographic references and BibTeX records from CrossRef, arXiv, DBLP, HAL, IEEE Xplore, Dissemin, and doi.org -*- lexical-binding: t -*- + +;; Copyright (C) 2016 Clément Pit-Claudel + +;; Author: Clément Pit-Claudel +;; Version: 0.2 +;; Package-Requires: ((emacs "24.3") (biblio-core "0.2")) +;; Keywords: bib, tex, convenience, hypermedia +;; URL: http://github.com/cpitclaudel/biblio.el + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: +;; # biblio.el: An extensible Emacs package for browsing and fetching references +;; +;; biblio.el makes it easy to browse and gather bibliographic references and +;; publications from various sources, by keywords or by DOI. References are +;; automatically fetched from well-curated sources, and formatted as BibTeX. +;; +;; ## Supported sources: +;; +;; * ‘CrossRef’, an exhaustive academic search engine (recommended) +;; * ‘arXiv’, an archive of pre-prints in various scientific fields +;; * ‘DBLP’, a database of Computer Science publications +;; * ‘HAL’, a French repository of Open Access publications +;; * ‘doi.org’, a DOI resolver (to retrieve BibTeX records from DOIs) +;; * ‘CrossCite’, an alternative DOI resolver and BibTeX formatting service +;; * ‘Dissemin’, a database tracking the open access status of scholarly articles +;; +;; ## Usage +;; +;; Quick start: ‘M-x biblio-lookup’. Each source can also be accessed independently: +;; +;; * ‘M-x crossref-lookup’ to query CrossRef +;; * ‘M-x arxiv-lookup` to query arXiv +;; * `M-x dblp-lookup’ to query DBLP +;; * ‘M-x doi-insert’ to insert a BibTeX record by DOI +;; * ‘M-x dissemin-lookup’ to show information about the open access status of a +;; particular DOI +;; +;; Most of these commands work together: for example, ‘crossref-lookup’ displays a +;; list of results in ‘biblio-selection-mode’. In that mode, use: +;; +;; * ‘RET’ to visit the corresponding web page +;; * ‘c’ or ‘M-w’ to copy the BibTeX record of the current entry +;; * ‘i’ or ‘C-y’ to insert the BibTeX record of the current entry +;; * ‘x’ to run an extended action, such as fetching a Dissemin record +;; +;; ‘C’ and ‘I’ do the same as ‘c’ and ‘i’, but additionally close the search window. +;; +;; ## Examples +;; +;; * To insert a clean BibTeX entry for http://doi.org/10.1145/2676726.2677006 +;; in the current buffer, use +;; +;; M-x crossref-lookup RET fiat deductive delaware RET i +;; +;; (the last ‘i’ inserts the BibTeX record of the currently selected entry in +;; your buffer). +;; +;; * To find publications by computer scientist Leslie Lamport, use ‘M-x +;; dblp-lookup RET author:Lamport RET’ (see more info about DBLP's syntax at +;; ) +;; +;; * To check whether an article is freely available online, use ‘x’ in the list +;; of results. For example ‘M-x crossref-lookup RET Emacs stallman RET’ +;; followed by ‘x Dissemin RET’ will help you find open access copies of +;; Stallman's paper on EMACS (spoiler: http://hdl.handle.net/1721.1/5736). +;; +;; See http://github.com/cpitclaudel/biblio.el for more information, including +;; documentation on extending this framework. + +;;; Code: + +(require 'biblio-core) +(require 'biblio-doi) +(require 'biblio-arxiv) +(require 'biblio-crossref) +(require 'biblio-dblp) +(require 'biblio-hal) +(require 'biblio-ieee) +(require 'biblio-dissemin) +(require 'biblio-download) + +(provide 'biblio) +;;; biblio.el ends here diff --git a/elpa/biblio-core-20190624.1408/biblio-core-autoloads.el b/elpa/biblio-core-20190624.1408/biblio-core-autoloads.el new file mode 100644 index 00000000..78f53452 --- /dev/null +++ b/elpa/biblio-core-20190624.1408/biblio-core-autoloads.el @@ -0,0 +1,31 @@ +;;; biblio-core-autoloads.el --- automatically extracted autoloads +;; +;;; Code: + +(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path)))) + + +;;;### (autoloads nil "biblio-core" "biblio-core.el" (0 0 0 0)) +;;; Generated autoloads from biblio-core.el + +(autoload 'biblio-lookup "biblio-core" "\ +Perform a search using BACKEND, and QUERY. +Prompt for any missing or nil arguments. BACKEND should be a +function obeying the interface described in the docstring of +`biblio-backends'. Returns the buffer in which results will be +inserted. + +\(fn &optional BACKEND QUERY)" t nil) + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "biblio-core" '("biblio-"))) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; coding: utf-8 +;; End: +;;; biblio-core-autoloads.el ends here diff --git a/elpa/biblio-core-20190624.1408/biblio-core-pkg.el b/elpa/biblio-core-20190624.1408/biblio-core-pkg.el new file mode 100644 index 00000000..afd62697 --- /dev/null +++ b/elpa/biblio-core-20190624.1408/biblio-core-pkg.el @@ -0,0 +1,2 @@ +;;; -*- no-byte-compile: t -*- +(define-package "biblio-core" "20190624.1408" "A framework for looking up and displaying bibliographic entries" '((emacs "24.3") (let-alist "1.0.4") (seq "1.11") (dash "2.12.1")) :commit "efeeab720cb8e3f95ddb4298d0cc62393cf237e9" :keywords '("bib" "tex" "convenience" "hypermedia") :authors '(("Clément Pit-Claudel" . "clement.pitclaudel@live.com")) :maintainer '("Clément Pit-Claudel" . "clement.pitclaudel@live.com") :url "http://github.com/cpitclaudel/biblio.el") diff --git a/elpa/biblio-core-20190624.1408/biblio-core.el b/elpa/biblio-core-20190624.1408/biblio-core.el new file mode 100644 index 00000000..a5a2304d --- /dev/null +++ b/elpa/biblio-core-20190624.1408/biblio-core.el @@ -0,0 +1,864 @@ +;;; biblio-core.el --- A framework for looking up and displaying bibliographic entries -*- lexical-binding: t -*- + +;; Copyright (C) 2016 Clément Pit-Claudel + +;; Author: Clément Pit-Claudel +;; Version: 0.2 +;; Package-Version: 20190624.1408 +;; Package-Requires: ((emacs "24.3") (let-alist "1.0.4") (seq "1.11") (dash "2.12.1")) +;; Keywords: bib, tex, convenience, hypermedia +;; URL: http://github.com/cpitclaudel/biblio.el + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: +;; A framework for browsing bibliographic search results. This is the core +;; package; for user interfaces, see any of `biblio-crossref', `biblio-dblp', `biblio-doi', +;; `biblio-arxiv', `biblio-hal' and `biblio-dissemin', which are part of the `biblio' package. + +;;; Code: + +(require 'bibtex) +(require 'browse-url) +(require 'hl-line) +(require 'ido) +(require 'json) +(require 'url-queue) + +(require 'dash) +(require 'let-alist) +(require 'seq) + +(defvar-local biblio--target-buffer nil + "Buffer into which BibTeX entries should be inserted. +This variable is local to each search results buffer.") + +(defvar-local biblio--search-terms nil + "Keywords that led to a page of bibliographic search results.") + +(defvar-local biblio--backend nil + "Backend that produced a page of bibliographic search results.") + +(defgroup biblio nil + "A browser for bibliographic information." + :group 'communication) + +(defgroup biblio-core nil + "Core of the biblio package." + :group 'biblio) + +(defgroup biblio-faces nil + "Faces of the biblio package." + :group 'biblio) + +(defcustom biblio-synchronous nil + "Whether bibliographic queries should be synchronous." + :group 'biblio-core + :type 'boolean) + +(defcustom biblio-authors-limit 10 + "Maximum number of authors to display per paper." + :group 'biblio-core + :type 'integer) + +;;; Compatibility + +(defun biblio-alist-get (key alist) + "Copy of Emacs 25's `alist-get', minus default. +Get the value associated to KEY in ALIST, or nil." + (cdr (assq key alist))) + +(defun biblio--plist-to-alist (plist) + "Copy of Emacs 25's `json--plist-to-alist'. +Return an alist of the property-value pairs in PLIST." + (let (res) + (while plist + (let ((prop (pop plist)) + (val (pop plist))) + (push (cons prop val) res))) + (nreverse res))) + +;;; Utilities + +(defconst biblio--bibtex-entry-format + (list 'opts-or-alts 'numerical-fields 'page-dashes 'whitespace + 'inherit-booktitle 'realign 'last-comma 'delimiters + 'unify-case 'braces 'strings 'sort-fields) + "Format to use in `biblio-format-bibtex'. +See `bibtex-entry-format' for details; this list is all +transformations, except errors for missing fields. +Also see `biblio-cleanup-bibtex-function'.") + +(defun biblio--cleanup-bibtex-1 (dialect autokey) + "Cleanup BibTeX entry starting at point. +DIALECT is `BibTeX' or `biblatex'. AUTOKEY: see `biblio-format-bibtex'." + (let ((bibtex-entry-format biblio--bibtex-entry-format) + (bibtex-align-at-equal-sign t) + (bibtex-autokey-edit-before-use nil) + (bibtex-autokey-year-title-separator ":")) + ;; Use biblatex to allow for e.g. @Online + ;; Use BibTeX to allow for e.g. @TechReport + (bibtex-set-dialect dialect t) + (bibtex-clean-entry autokey))) + +(defun biblio--cleanup-bibtex (autokey) + "Default value of `biblio-cleanup-bibtex-function'. +AUTOKEY: See biblio-format-bibtex." + (save-excursion + (when (search-forward "@data{" nil t) + (replace-match "@misc{"))) + (ignore-errors ;; See https://github.com/crosscite/citeproc-doi-server/issues/12 + (condition-case _ + (biblio--cleanup-bibtex-1 'biblatex autokey) + (error (biblio--cleanup-bibtex-1 'BibTeX autokey))))) + +(defcustom biblio-cleanup-bibtex-function + #'biblio--cleanup-bibtex + "Function to clean up BibTeX entries. +This function is called in a `bibtex-mode' buffer containing an +unprocessed, potentially invalid BibTeX (or BibLaTeX) entry, and +should clean it up in place. It should take a single argument, +AUTOKEY, indicating whether the entry needs a new key." + :group 'biblio + :type 'function) + +(defun biblio-format-bibtex (bibtex &optional autokey) + "Format BIBTEX entry. +With non-nil AUTOKEY, automatically generate a key for BIBTEX." + (with-temp-buffer + (bibtex-mode) + (save-excursion + (insert (biblio-strip bibtex))) + (when (functionp biblio-cleanup-bibtex-function) + (funcall biblio-cleanup-bibtex-function autokey)) + (if (fboundp 'font-lock-ensure) (font-lock-ensure) + (with-no-warnings (font-lock-fontify-buffer))) + (buffer-substring-no-properties (point-min) (point-max)))) + +(defun biblio--beginning-of-response-body () + "Move point to beginning of response body." + (goto-char (point-min)) + (unless (re-search-forward "^\n" nil t) + (error "Invalid response from server: %S" (buffer-string)))) + +(defun biblio-response-as-utf-8 () + "Extract body of response." + (set-buffer-multibyte t) + (decode-coding-region (point) (point-max) 'utf-8 t)) + +(defun biblio-decode-url-buffer (coding) + "Decode URL buffer with CODING." + (set-buffer-multibyte t) ;; URL buffer is unibyte + (decode-coding-region (point-min) (point-max) coding)) + +(defun biblio--event-error-code (event) + "Extract HTTP error code from EVENT, if any." + (pcase event + (`(:error . (error ,source ,details)) + (cons source details)))) + +(eval-and-compile + (define-error 'biblio--url-error "URL retrieval error.")) + +(defun biblio--throw-on-unexpected-errors (errors allowed-errors) + "Throw an url-error for any error in ERRORS not in ALLOWED-ERRORS." + (dolist (err errors) + (cond ((eq (car err) 'url-queue-timeout) + (signal 'biblio--url-error 'timeout)) + ((not (member err allowed-errors)) + (signal 'biblio--url-error err))))) + +(defun biblio--extract-errors (events) + "Extract errors from EVENTS." + (delq nil (mapcar #'biblio--event-error-code (biblio--plist-to-alist events)))) + +(defun biblio-generic-url-callback (callback &optional cleanup-function &rest allowed-errors) + "Make an `url'-ready callback from CALLBACK. +CALLBACK is called with no arguments; the buffer containing the +server's response is current at the time of the call, and killed +after the call returns. Call CLEANUP-FUNCTION before checking +for errors. If the request returns one of the errors in +ALLOWED-ERRORS, CALLBACK is instead called with one argument, the +list of allowed errors that occurred instead of a buffer. If the +request returns another error, an exception is raised." + (lambda (events) + (let ((target-buffer (current-buffer))) + (unwind-protect + (progn + (funcall (or cleanup-function #'ignore)) + (condition-case err + (-if-let* ((errors (biblio--extract-errors events))) + (progn + (biblio--throw-on-unexpected-errors errors allowed-errors) + (funcall callback errors)) + (biblio--beginning-of-response-body) + (delete-region (point-min) (point)) + (funcall callback)) + (error (message "Error while processing request: %S" err)))) + (kill-buffer target-buffer))))) + +(defun biblio-url-retrieve (url callback) + "Wrapper around `url-queue-retrieve'. +URL and CALLBACK; see `url-queue-retrieve'" + (message "Fetching %s" url) + (if biblio-synchronous + (with-current-buffer (url-retrieve-synchronously url) + (funcall callback nil)) + (setq url-queue-timeout 1) + (url-queue-retrieve url callback))) + +(defun biblio-strip (str) + "Remove spaces surrounding STR." + (when str + (->> str + (replace-regexp-in-string "[ \t\n\r]+\\'" "") + (replace-regexp-in-string "\\`[ \t\n\r]+" "")))) + +(defun biblio-cleanup-doi (doi) + "Cleanup DOI string." + (biblio-strip (replace-regexp-in-string "https?://\\(dx\\.\\)?doi\\.org/" "" doi))) + +(defun biblio-remove-empty (strs) + "Remove empty sequences from STRS." + (seq-remove #'seq-empty-p strs)) + +(defun biblio-join-1 (sep strs) + "Join non-empty elements of STRS with SEP." + (declare (indent 1)) + (let ((strs (biblio-remove-empty strs))) + (mapconcat #'identity strs sep))) + +(defun biblio-join (sep &rest strs) + "Join non-empty elements of STRS with SEP." + (declare (indent 1)) + (biblio-join-1 sep strs)) + +(defmacro biblio--with-text-property (prop value &rest body) + "Set PROP to VALUE on text inserted by BODY." + (declare (indent 2) + (debug t)) + (let ((beg-var (make-symbol "beg"))) + `(let ((,beg-var (point))) + ,@body + (put-text-property ,beg-var (point) ,prop ,value)))) + +(defmacro biblio-with-fontification (face &rest body) + "Apply FACE to text inserted by BODY." + (declare (indent 1) + (debug t)) + (let ((beg-var (make-symbol "beg"))) + `(let ((,beg-var (point))) + ,@body + (font-lock-append-text-property ,beg-var (point) 'face ,face)))) + +;;; Help with major mode + +(defsubst biblio--as-list (x) + "Make X a list, if it isn't." + (if (consp x) x (list x))) + +(defun biblio--map-keymap (func map) + "Call `map-keymap' on FUNC and MAP, and collect the results." + (let ((out)) + (map-keymap (lambda (&rest args) (push (apply func args) out)) map) + out)) + +(defun biblio--flatten-map (keymap &optional prefix) + "Flatten KEYMAP, prefixing its keys with PREFIX. +This should really be in Emacs core (in Elisp), instead of being +implemented in C (at least for sparse keymaps). Don't run this on +non-sparse keymaps." + (nreverse + (cond + ((keymapp keymap) + (seq-map (lambda (key-value) + "Add PREFIX to key in KEY-VALUE." + (cons (append prefix (biblio--as-list (car key-value))) + (cdr key-value))) + (delq nil + (apply + #'seq-concatenate + 'list (biblio--map-keymap + (lambda (k v) + "Return a list of bindings in V, prefixed by K." + (biblio--flatten-map v (biblio--as-list k))) + keymap))))) + ;; This breaks if keymap is a symbol whose function cell is a keymap + ((symbolp keymap) + (list (cons prefix keymap)))))) + +(defun biblio--group-alist (alist) + "Return a copy of ALIST whose keys are lists of keys, grouped by value. +That is, if two key map to `eq' values, they are grouped." + (let ((map (make-hash-table :test 'eq)) + (new-alist nil)) + (pcase-dolist (`(,key . ,value) alist) + (puthash value (cons key (gethash value map)) map)) + (pcase-dolist (`(,_ . ,value) alist) + (-when-let* ((keys (gethash value map))) + (push (cons (nreverse keys) value) new-alist) + (puthash value nil map))) + (nreverse new-alist))) + +(defun biblio--quote (str) + "Quote STR and call `substitute-command-keys' on it." + (if str (substitute-command-keys (concat "`" str "'")) "")) + +(defun biblio--quote-keys (keys) + "Quote and concatenate keybindings in KEYS." + (mapconcat (lambda (keyseq) + (biblio--quote (ignore-errors (help-key-description keyseq nil)))) + keys ", ")) + +(defun biblio--brief-docs (command) + "Return first line of documentation of COMMAND." + (let ((docs (or (ignore-errors (documentation command t)) ""))) + (string-match "\\(.*\\)$" docs) + (match-string-no-properties 1 docs))) + +(defun biblio--help-with-major-mode-1 (keyseqs-command) + "Print help on KEYSEQS-COMMAND to standard output." + ;; (biblio-with-fontification 'font-lock-function-name-face + (insert (format "%s (%S)\n" + (biblio--quote-keys (car keyseqs-command)) + (cdr keyseqs-command))) + (biblio-with-fontification 'font-lock-doc-face + (insert (format " %s\n\n" (biblio--brief-docs (cdr keyseqs-command)))))) + +(defun biblio--help-with-major-mode () + "Display help with current major mode." + (let ((buf (format "*%S help*" major-mode))) + (with-help-window buf + (princ (format "Help with %s\n\n" (biblio--quote (symbol-name major-mode)))) + (let ((bindings (nreverse + (biblio--group-alist + (biblio--flatten-map + (current-local-map)))))) + (with-current-buffer buf + (seq-do #'biblio--help-with-major-mode-1 bindings)))) + buf)) + +;;; Interaction + +(defconst biblio--search-result-marker-regexp "^> " + "Indicator of a search result.") + +(defun biblio--selection-move (move-fn search-fn) + "Move using MOVE-FN, then call SEARCH-FN and go to first match." + (let ((target (point))) + (save-excursion + (funcall move-fn) + (when (funcall search-fn biblio--search-result-marker-regexp nil t) + (setq target (match-end 0)))) + (goto-char target))) + +(defun biblio-get-url (metadata) + "Compute a url from METADATA. +Uses .url, and .doi as a fallback." + (let-alist metadata + (if .url .url + (when .doi + (concat "https://doi.org/" (url-encode-url .doi)))))) + +(defun biblio--selection-browse () + "Open the web page of the current entry in a web browser." + (interactive) + (-if-let* ((url (biblio-get-url (biblio--selection-metadata-at-point)))) + (browse-url url) + (user-error "This record does not contain a URL"))) + +(defun biblio--selection-browse-direct () + "Open the full text of the current entry in a web browser." + (interactive) + (-if-let* ((url (biblio-alist-get 'direct-url (biblio--selection-metadata-at-point)))) + (browse-url url) + (user-error "This record does not contain a direct URL (try arXiv or HAL)"))) + +(defun biblio--selection-next () + "Move to next search result." + (interactive) + (biblio--selection-move #'end-of-line #'re-search-forward)) + +(defun biblio--selection-first () + "Move to first search result." + (goto-char (point-min)) + (biblio--selection-move #'ignore #'re-search-forward)) + +(defun biblio--selection-previous () + "Move to previous search result." + (interactive) + (biblio--selection-move #'beginning-of-line #'re-search-backward)) + +(defun biblio--selection-copy-callback (bibtex entry) + "Add BIBTEX (from ENTRY) to kill ring." + (kill-new bibtex) + (message "Killed bibtex entry for %S." + (biblio--prepare-title (biblio-alist-get 'title entry)))) + +(defun biblio--selection-copy () + "Copy BibTeX of current entry at point." + (interactive) + (biblio--selection-forward-bibtex #'biblio--selection-copy-callback)) + +(defun biblio--selection-copy-quit () + "Copy BibTeX of current entry at point and close results." + (interactive) + (biblio--selection-forward-bibtex #'biblio--selection-copy-callback t)) + +(defun biblio--target-window () + "Get the window of the source buffer." + (get-buffer-window biblio--target-buffer)) + +(defun biblio--selection-insert-callback (bibtex entry) + "Add BIBTEX (from ENTRY) to kill ring." + (let ((target-buffer biblio--target-buffer)) + (with-selected-window (or (biblio--target-window) (selected-window)) + (with-current-buffer target-buffer + (insert bibtex "\n\n")))) + (message "Inserted bibtex entry for %S." + (biblio--prepare-title (biblio-alist-get 'title entry)))) + +(defun biblio--selection-insert () + "Insert BibTeX of current entry into source buffer." + (interactive) + (biblio--selection-forward-bibtex #'biblio--selection-insert-callback)) + +(defun biblio--selection-insert-quit () + "Insert BibTeX of current entry into source buffer and close results." + (interactive) + (biblio--selection-forward-bibtex #'biblio--selection-insert-callback t)) + +(defun biblio--selection-metadata-at-point () + "Return the metadata of the entry at point." + (or (get-text-property (point) 'biblio-metadata) + (user-error "No entry at point"))) + +(defun biblio--selection-forward-bibtex (forward-to &optional quit) + "Retrieve BibTeX for entry at point and pass it to FORWARD-TO. +If QUIT is set, also kill the results buffer." + (let* ((metadata (biblio--selection-metadata-at-point)) + (results-buffer (current-buffer))) + (progn + (funcall (biblio-alist-get 'backend metadata) + 'forward-bibtex metadata + (lambda (bibtex) + (with-current-buffer results-buffer + (funcall forward-to (biblio-format-bibtex bibtex) metadata)))) + (when quit (quit-window))))) + +(defun biblio--selection-change-buffer (buffer-name) + "Change buffer in which BibTeX results will be inserted. +BUFFER-NAME is the name of the new target buffer." + (interactive (list (read-buffer "Buffer to insert entries into: "))) + (let ((buffer (get-buffer buffer-name))) + (if (buffer-local-value 'buffer-read-only buffer) + (user-error "%s is read-only" (buffer-name buffer)) + (setq biblio--target-buffer buffer)))) + +(defvar biblio-selection-mode-actions-alist nil + "An alist of extensions for `biblio-selection-mode'. +Each element should be in the for (LABEL . FUNCTION); FUNCTION +will be called with the metadata of the current item.") + +(defun biblio--completing-read-function () + "Return ido, unless user picked another completion package." + (if (eq completing-read-function #'completing-read-default) + #'ido-completing-read + completing-read-function)) + +(defun biblio-completing-read (prompt collection &optional predicate require-match + initial-input hist def inherit-input-method) + "Complete using `biblio-completing-read-function'. +PROMPT, COLLECTION, PREDICATE, REQUIRE-MATCH, INITIAL-INPUT, +HIST, DEF, INHERIT-INPUT-METHOD: see `completing-read'." + (let ((completing-read-function (biblio--completing-read-function))) + (completing-read prompt collection predicate require-match + initial-input hist def inherit-input-method))) + +(defun biblio-completing-read-alist (prompt collection &optional predicate require-match + initial-input hist def inherit-input-method) + "Same as `biblio-completing-read', when COLLECTION in an alist. +Complete with the `car's, and return the `cdr' of the result. +PROMPT, COLLECTION, PREDICATE, REQUIRE-MATCH, INITIAL-INPUT, +HIST, DEF, INHERIT-INPUT-METHOD: see `completing-read'." + (let ((choices (mapcar #'car collection))) + (cdr (assoc (biblio-completing-read + prompt choices predicate require-match + initial-input hist def inherit-input-method) + collection)))) + +(defun biblio--read-selection-extended-action () + "Read an action from `biblio-selection-mode-actions-alist'." + (biblio-completing-read-alist + "Action: " biblio-selection-mode-actions-alist nil t)) + +(defun biblio--selection-extended-action (action) + "Run an ACTION with metadata of current entry. +Interactively, query for ACTION from +`biblio-selection-mode-actions-alist'." + (interactive (list (biblio--read-selection-extended-action))) + (let* ((metadata (biblio--selection-metadata-at-point))) + (funcall action metadata))) + +(defun biblio--selection-help () + "Show help on local keymap." + (interactive) + (biblio--help-with-major-mode)) + +(defvar biblio-selection-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "") #'biblio--selection-previous) + (define-key map (kbd "C-p") #'biblio--selection-previous) + (define-key map (kbd "") #'biblio--selection-next) + (define-key map (kbd "C-n") #'biblio--selection-next) + (define-key map (kbd "RET") #'biblio--selection-browse) + (define-key map (kbd "") #'biblio--selection-browse-direct) + (define-key map (kbd "C-RET") #'biblio--selection-browse-direct) + (define-key map (kbd "M-w") #'biblio--selection-copy) + (define-key map (kbd "c") #'biblio--selection-copy) + (define-key map (kbd "C-w") #'biblio--selection-copy-quit) + (define-key map (kbd "C") #'biblio--selection-copy-quit) + (define-key map (kbd "i") #'biblio--selection-insert) + (define-key map (kbd "C-y") #'biblio--selection-insert-quit) + (define-key map (kbd "I") #'biblio--selection-insert-quit) + (define-key map (kbd "b") #'biblio--selection-change-buffer) + (define-key map (kbd "x") #'biblio--selection-extended-action) + (define-key map (kbd "?") #'biblio--selection-help) + (define-key map (kbd "h") #'biblio--selection-help) + (define-key map (kbd "q") #'quit-window) + map) + "Keybindings for Bibliographic search results.") + +(defconst biblio--selection-mode-name-base "Bibliographic search results") + +(defun biblio--selection-mode-name () + "Compute a modeline string for `biblio-selection-mode'." + (concat biblio--selection-mode-name-base + (if (bufferp biblio--target-buffer) + (format " (→ %s)" + (buffer-name biblio--target-buffer)) + ""))) + +(define-derived-mode biblio-selection-mode fundamental-mode biblio--selection-mode-name-base + "Browse bibliographic search results. +\\{biblio-selection-mode-map}" + (hl-line-mode) + (visual-line-mode) + (setq-local truncate-lines nil) + (setq-local cursor-type nil) + (setq-local buffer-read-only t) + (setq-local mode-name '(:eval (biblio--selection-mode-name))) + (setq-local + header-line-format + `(:eval + (concat + (ignore-errors + (propertize " " 'display '(space :align-to 0) 'face 'fringe)) + (substitute-command-keys + (biblio-join " " + "\\[biblio--selection-help]: Help" + "\\[biblio--selection-insert],\\[biblio--selection-insert-quit]: Insert BibTex" + "\\[biblio--selection-copy],\\[biblio--selection-copy-quit]: Copy BibTeX" + "\\[biblio--selection-extended-action]: Extended action" + "\\[biblio--selection-browse]: Open in browser" + "\\[biblio--selection-change-buffer]: Change buffer")))))) + +;;; Printing search results + +(defun biblio-parenthesize (str) + "Add parentheses to STR, if not empty." + (if (seq-empty-p str) "" + (concat "(" str ")"))) + +(defun biblio-insert-with-prefix (prefix &rest strs) + "Like INSERT with PREFIX and STRS, but set `wrap-prefix'. +That is, the inserted text gets a `wrap-prefix' made of enough +white space to align with the end of PREFIX." + (declare (indent 1)) + (biblio--with-text-property 'wrap-prefix (make-string (length prefix) ?\s) + (apply #'insert prefix strs))) + +(defface biblio-detail-header-face + '((t :slant normal)) + "Face used for headers of details in `biblio-selection-mode'." + :group 'biblio-faces) + +(defun biblio--insert-detail (prefix items newline) + "Insert PREFIX followed by ITEMS, if ITEMS has non-empty entries. +If ITEMS is a list or vector, join its entries with “, ”. If +NEWLINE is non-nil, add a newline before the main text." + (when (or (vectorp items) (listp items)) + (setq items (biblio-join-1 ", " items))) + (unless (seq-empty-p items) + (when newline (insert "\n")) + (let ((fontified (propertize prefix 'face 'biblio-detail-header-face))) + (biblio-insert-with-prefix fontified items)))) + +(defun biblio--nonempty-string-p (str) + "Return STR if STR is non-empty." + (unless (seq-empty-p str) + str)) + +(defun biblio--cleanup-field (text) + "Cleanup TEXT for presentation to the user." + (when text (biblio-strip (replace-regexp-in-string "[ \r\n\t]+" " " text)))) + +(defun biblio--prepare-authors (authors) + "Cleanup and join list of AUTHORS." + (let* ((authors (biblio-remove-empty (seq-map #'biblio-strip authors))) + (num-authors (length authors))) + ;; Only truncate when significantly above limit + (when (> num-authors (+ 2 biblio-authors-limit)) + (let* ((last (nthcdr biblio-authors-limit authors))) + (setcar last (format "… (%d more)" (- num-authors biblio-authors-limit))) + (setcdr last nil))) + (if authors (biblio-join-1 ", " authors) + "(no authors)"))) + +(defun biblio--prepare-title (title &optional year) + "Cleanup TITLE and add YEAR for presentation to the user." + (concat (or (biblio--nonempty-string-p (biblio--cleanup-field title)) + "(no title)") + (if year (format " [%s]" year) ""))) + +(defun biblio--browse-url (button) + "Open web browser on page pointed to by BUTTON." + (browse-url (button-get button 'target))) + +(defun biblio-make-url-button (url &optional label) + "Make a text button pointing to URL. +With non-nil LABEL, use that instead of URL to label the button." + (unless (seq-empty-p url) + (with-temp-buffer + (insert-text-button (or label url) + 'target url + 'follow-link t + 'action #'biblio--browse-url) + (buffer-string)))) + +(defun biblio-insert-result (item &optional no-sep) + "Print a (prepared) bibliographic search result ITEM. +With NO-SEP, do not add space after the record. + +This command expects ITEM to be a single alist, in the following format: + + ((title . \"Title of entry\") + (authors . (\"Author 1\" \"Author 2\" …)) + (container . \"Where this was published (which journal, conference, …)\") + (type . \"Type of document (journal paper, proceedings, report, …)\") + (category . \"Category of this document (aka primary topic)\") + (publisher . \"Publisher of this document\") + (references . \"Identifier(s) of this document (DOI, DBLP id, Handle, …)\") + (open-access-status . \"Open access status of this document\") + (url . \"Relevant URL\") + (year . \"Publication year as a string, if available\") + (direct-url . \"Direct URL of paper (typically PDF)\")) + +Each of `container', `type', `category', `publisher', +`references', and `open-access-status' may be a list; in that +case, entries of the list are displayed comma-separated. All +entries are optional. + +`crossref--extract-interesting-fields' and `dblp--extract-interesting-fields' +provide examples of how to build such a result." + (biblio--with-text-property 'biblio-metadata item + (let-alist item + (biblio-with-fontification 'font-lock-function-name-face + (biblio-insert-with-prefix "> " (biblio--prepare-title .title .year))) + (insert "\n") + (biblio-with-fontification 'font-lock-doc-face + (biblio-insert-with-prefix " " (biblio--prepare-authors .authors))) + (biblio-with-fontification 'font-lock-comment-face + (biblio--insert-detail " In: " .container t) + (biblio--insert-detail " Type: " .type t) + (biblio--insert-detail " Category: " .category t) + (biblio--insert-detail " Publisher: " .publisher t) + (biblio--insert-detail " References: " .references t) + (biblio--insert-detail " Open Access: " .open-access-status t) + (biblio--insert-detail " URL: " (list (biblio-make-url-button .url) + (biblio-make-url-button .direct-url)) + t)) + (unless no-sep + (insert "\n\n"))))) + +(defface biblio-results-header-face + '((t :height 1.5 :weight bold :inherit font-lock-preprocessor-face)) + "Face used for general search results header in `biblio-selection-mode'." + :group 'biblio-faces) + +(defun biblio--search-results-header (&optional loading-p) + "Compute a header for the current `selection-mode' buffer. +With LOADING-P, mention that results are being loaded." + (format "%s search results for %s%s" + (funcall biblio--backend 'name) + (biblio--quote biblio--search-terms) + (if loading-p " (loading…)" ""))) + +(defun biblio--make-results-buffer (target-buffer search-terms backend) + "Set up the results buffer for TARGET-BUFFER, SEARCH-TERMS and BACKEND." + (with-current-buffer (get-buffer-create + (format "*%s search*" (funcall backend 'name))) + (let ((inhibit-read-only t)) + (erase-buffer) + (biblio-selection-mode) + (setq biblio--target-buffer target-buffer) + (setq biblio--search-terms search-terms) + (setq biblio--backend backend) + (biblio--insert-header (biblio--search-results-header t)) + (setq buffer-read-only t) + (current-buffer)))) + +(defun biblio--insert-header (header) + "Prettify and insert HEADER in current buffer." + (when header + (biblio--with-text-property 'line-spacing 0.5 + (biblio--with-text-property 'line-height 1.75 + (biblio-with-fontification 'biblio-results-header-face + (insert header "\n")))))) + +(defun biblio-insert-results (items &optional header) + "Populate current buffer with ITEMS and HEADER, then display it." + (let ((inhibit-read-only t)) + (erase-buffer) + (biblio--insert-header header) + (seq-do #'biblio-insert-result items)) + (pop-to-buffer (current-buffer)) + (biblio--selection-first) + (hl-line-highlight)) + +(defun biblio--tag-backend (backend items) + "Add (backend . BACKEND) to each alist in ITEMS." + (seq-map (lambda (i) (cons `(backend . ,backend) i)) items)) + +(defun biblio--callback (results-buffer backend) + "Generate a search results callback for RESULTS-BUFFER. +Results are parsed with (BACKEND 'parse-buffer)." + (biblio-generic-url-callback + (lambda () ;; no allowed errors, so no arguments + "Parse results of bibliographic search." + (let ((results (biblio--tag-backend backend (funcall backend 'parse-buffer)))) + (with-current-buffer results-buffer + (biblio-insert-results results (biblio--search-results-header))) + (message "Tip: learn to browse results with `h'"))))) + +;;; Searching + +(defvar biblio--search-history nil) + +(defvar biblio-backends nil + "List of biblio backends. +This list is generally populated through `biblio-init-hook', +which is called by `biblio-collect-backends'. + + +Each backend is a function that take a variable number of +arguments. The first argument is a command; the rest are +arguments to this specific command. The command is one of the +following: + +`name': (no arguments) The name of the backend, displayed when picking a +backend from a list. + +`prompt': (no arguments) The string used when querying the user for a search +term to feed this backend. + +`url': (one argument, QUERY) Create a URL to query the backend's API. + +`parse-buffer': (no arguments) Parse the contents of the current +buffer and return a list of results. At the time of the call, +the current buffer contains the results of querying a url +returned by (THIS-BACKEND `url' QUERY). The format of individual +results is described in the docstring of `biblio-insert-result'). + +`forward-bibtex': (two arguments, METADATA and FORWARD-TO) +Produce a BibTeX record from METADATA (one of the elements of the +list produced by `parse-buffer') and call FORWARD-TO on it. + +For examples of backends, see one of `biblio-crossref-backend', +`biblio-dblp-backend', `biblio-arxiv-backend', etc. + + +To register your backend automatically, you may want to add a +`register' command: + +`register': Add the current backend to `biblio-backends'. +Something like (add-to-list \\='biblio-backends \\='THIS-BACKEND). + +Then it's enough to add your backend to `biblio-init-hook': + +;;;###autoload +\(add-hook \\='biblio-init-hook \\='YOUR-BACKEND-HERE).") + +(defvar biblio-init-hook nil + "Hook run before every search. +Each function is called with one argument, `register'. This +makes it possible to register backends by adding them directly to +this hook, and making them react to `register' by adding +themselves to biblio-backends.") + +(defun biblio-collect-backends () + "Populate `biblio-backends' and return that." + (run-hook-with-args 'biblio-init-hook 'register) + biblio-backends) + +(defun biblio--named-backends () + "Collect an alist of (NAME . BACKEND)." + (seq-map (lambda (b) (cons (funcall b 'name) b)) (biblio-collect-backends))) + +(defun biblio--read-backend () + "Run `biblio-init-hook', then read a backend from `biblio-backend'." + (biblio-completing-read-alist "Backend: " (biblio--named-backends) nil t)) + +(defun biblio--read-query (backend) + "Interactively read a query. +Get prompt string from BACKEND." + (let* ((prompt (funcall backend 'prompt))) + (read-string prompt nil 'biblio--search-history))) + +(defun biblio--lookup-1 (backend query) + "Just like `biblio-lookup' on BACKEND and QUERY, but never prompt." + (let ((results-buffer (biblio--make-results-buffer (current-buffer) query backend))) + (biblio-url-retrieve + (funcall backend 'url query) + (biblio--callback results-buffer backend)) + results-buffer)) + +;;;###autoload +(defun biblio-lookup (&optional backend query) + "Perform a search using BACKEND, and QUERY. +Prompt for any missing or nil arguments. BACKEND should be a +function obeying the interface described in the docstring of +`biblio-backends'. Returns the buffer in which results will be +inserted." + (interactive) + (unless backend (setq backend (biblio--read-backend))) + (unless query (setq query (biblio--read-query backend))) + (biblio--lookup-1 backend query)) + +(defun biblio-kill-buffers () + "Kill all `biblio-selection-mode' buffers." + (interactive) + (dolist (buf (buffer-list)) + (when (and (buffer-live-p buf) + (eq (buffer-local-value 'major-mode buf) + 'biblio-selection-mode)) + (kill-buffer buf)))) + +;; Local Variables: +;; nameless-current-name: "biblio" +;; checkdoc-arguments-in-order-flag: nil +;; End: + +(provide 'biblio-core) +;;; biblio-core.el ends here diff --git a/elpa/biblio-readme.txt b/elpa/biblio-readme.txt new file mode 100644 index 00000000..0bd67028 --- /dev/null +++ b/elpa/biblio-readme.txt @@ -0,0 +1,58 @@ +# biblio.el: An extensible Emacs package for browsing and fetching references + +biblio.el makes it easy to browse and gather bibliographic references and +publications from various sources, by keywords or by DOI. References are +automatically fetched from well-curated sources, and formatted as BibTeX. + +## Supported sources: + +* ‘CrossRef’, an exhaustive academic search engine (recommended) +* ‘arXiv’, an archive of pre-prints in various scientific fields +* ‘DBLP’, a database of Computer Science publications +* ‘HAL’, a French repository of Open Access publications +* ‘doi.org’, a DOI resolver (to retrieve BibTeX records from DOIs) +* ‘CrossCite’, an alternative DOI resolver and BibTeX formatting service +* ‘Dissemin’, a database tracking the open access status of scholarly articles + +## Usage + +Quick start: ‘M-x biblio-lookup’. Each source can also be accessed independently: + +* ‘M-x crossref-lookup’ to query CrossRef +* ‘M-x arxiv-lookup` to query arXiv +* `M-x dblp-lookup’ to query DBLP +* ‘M-x doi-insert’ to insert a BibTeX record by DOI +* ‘M-x dissemin-lookup’ to show information about the open access status of a + particular DOI + +Most of these commands work together: for example, ‘crossref-lookup’ displays a +list of results in ‘biblio-selection-mode’. In that mode, use: + +* ‘RET’ to visit the corresponding web page +* ‘c’ or ‘M-w’ to copy the BibTeX record of the current entry +* ‘i’ or ‘C-y’ to insert the BibTeX record of the current entry +* ‘x’ to run an extended action, such as fetching a Dissemin record + +‘C’ and ‘I’ do the same as ‘c’ and ‘i’, but additionally close the search window. + +## Examples + +* To insert a clean BibTeX entry for http://doi.org/10.1145/2676726.2677006 + in the current buffer, use + + M-x crossref-lookup RET fiat deductive delaware RET i + + (the last ‘i’ inserts the BibTeX record of the currently selected entry in + your buffer). + +* To find publications by computer scientist Leslie Lamport, use ‘M-x + dblp-lookup RET author:Lamport RET’ (see more info about DBLP's syntax at + ) + +* To check whether an article is freely available online, use ‘x’ in the list + of results. For example ‘M-x crossref-lookup RET Emacs stallman RET’ + followed by ‘x Dissemin RET’ will help you find open access copies of + Stallman's paper on EMACS (spoiler: http://hdl.handle.net/1721.1/5736). + +See http://github.com/cpitclaudel/biblio.el for more information, including +documentation on extending this framework. diff --git a/elpa/centered-cursor-mode-readme.txt b/elpa/centered-cursor-mode-readme.txt deleted file mode 100644 index b062660c..00000000 --- a/elpa/centered-cursor-mode-readme.txt +++ /dev/null @@ -1,16 +0,0 @@ -Makes the cursor stay vertically in a defined position (usually -centered). The vertical position can be altered, see key definition -below. - -To load put that in .emacs: - (require 'centered-cursor-mode) -To activate do: - M-x centered-cursor-mode -for buffer local or - M-x global-centered-cursor-mode -for global minor mode. -Also possible: put that in .emacs - (and - (require 'centered-cursor-mode) - (global-centered-cursor-mode +1)) -to always have centered-cursor-mode on in all buffers. diff --git a/elpa/dash-readme.txt b/elpa/dash-readme.txt deleted file mode 100644 index b6baaa2d..00000000 --- a/elpa/dash-readme.txt +++ /dev/null @@ -1,8 +0,0 @@ -A modern list api for Emacs. - -See documentation on https://github.com/magnars/dash.el#functions - -**Please note** The lexical binding in this file is not utilised at the -moment. We will take full advantage of lexical binding in an upcoming 3.0 -release of Dash. In the meantime, we've added the pragma to avoid a bug that -you can read more about in https://github.com/magnars/dash.el/issues/130. diff --git a/elpa/ejc-sql-20190121.1043/ejc-autocomplete.el b/elpa/ejc-sql-20190121.1043/ejc-autocomplete.el deleted file mode 100644 index 6b06177e..00000000 --- a/elpa/ejc-sql-20190121.1043/ejc-autocomplete.el +++ /dev/null @@ -1,203 +0,0 @@ -;;; ejc-autocomplete.el -- SQL completitions at point (the part of ejc-sql). - -;;; Copyright © 2013-2018 - Kostafey - -;;; This program is free software; you can redistribute it and/or modify -;;; it under the terms of the GNU General Public License as published by -;;; the Free Software Foundation; either version 2, or (at your option) -;;; any later version. -;;; -;;; This program is distributed in the hope that it will be useful, -;;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;;; GNU General Public License for more details. -;;; -;;; You should have received a copy of the GNU General Public License -;;; along with this program; if not, write to the Free Software Foundation, -;;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - -;;; Code: - -(require 'dash) -(require 'auto-complete) -(require 'ejc-lib) -(require 'ejc-interaction) -(require 'ejc-doc) -(require 'ejc-format) -(require 'ejc-flx) - -(defcustom ejc-candidates-uppercase t - "Use uppercase candidates or downcase. -Uppercase by default, set to nil to use downcase candidates." - :type 'boolean - :safe #'booleanp - :group 'ejc-sql) - -(defun ejc-get-prefix-word () - "Return the word preceding dot before the typing." - (save-excursion - (let ((space-dist (or (save-excursion - (re-search-backward "[ \n\t\r(]+" nil t)) - 0)) - (dot (search-backward "." nil t)) - (space (re-search-backward "[ \n\t\r(.]+" nil t))) - (if (and dot - space - (> dot space) - (<= space-dist space)) ; is a dot completition - (buffer-substring (1+ space) dot) - nil)))) - -(defvar ejc-ansi-sql-words - '("select" "where" "and" "or" "from" "insert" "update" "delete" "join" - "order" "by" "distinct" "create" "alter" "drop" "like" - "grant" "revoke" "deny" "commit" "rollback" "savepoint")) - -(defvar ejc-auxulary-sql-words - '("show" "errors" "desc" "count" "type" "table" "function" "procedure" - "begin" "end" "for" "return")) - -(defun ejc-not-nil-str (s) - (not (equal s "nil"))) - -(defmacro ejc-candidates (cand-fn) - `(if (ejc-buffer-connected-p) - (let* ((prefix-1 (ejc-get-prefix-word)) - (prefix-2 (save-excursion - (search-backward "." nil t) - (ejc-get-prefix-word))) - (result (funcall ,cand-fn - ejc-db - (apply - 'buffer-substring - (ejc-get-sql-boundaries-at-point)) - prefix-1 - prefix-2)) - (pending (car result)) - (candidates-cache (cdr result))) - (if (ejc-not-nil-str pending) - (progn - (message "Receiving database structure...") - (list)) - candidates-cache)))) - -;;;###autoload -(defun ejc-owners-candidates () - (ejc-candidates 'ejc-get-owners-candidates)) - -;;;###autoload -(defun ejc-tables-candidates () - (ejc-candidates 'ejc-get-tables-candidates)) - -;;;###autoload -(defun ejc-colomns-candidates () - (ejc-candidates 'ejc-get-colomns-candidates)) - -(defun ejc-return-point () - "Return point position if point (cursor) is located next to dot char (.#)" - (let ((curr-char (buffer-substring - (save-excursion - (left-char 1) - (point)) - (point)))) - (if (equal curr-char ".") - (point) - nil))) - -(defun ejc-get-ansi-sql-words () - (unless (or (ejc-return-point) (ejc-get-prefix-word)) - (if ejc-candidates-uppercase - (append (mapcar 'upcase ejc-ansi-sql-words) - (mapcar 'upcase ejc-auxulary-sql-words)) - (append ejc-ansi-sql-words - ejc-auxulary-sql-words)))) - -(defun ac-ejc-documentation (symbol-name) - "Return a documentation string for SYMBOL-NAME." - (if (not ejc-doc-created-p) - (ejc-create-doc)) - (gethash (intern (downcase symbol-name)) ejc-sql-doc)) - -(defvar ac-source-ejc-owners - '((candidates . ejc-owners-candidates) - (symbol . "o") - (requires . 1) - (cache . t))) - -(defvar ac-source-ejc-tables - '((candidates . ejc-tables-candidates) - (symbol . "t") - (requires . 1) - (cache . t))) - -(defvar ac-source-ejc-tables-point - '((candidates . ejc-tables-candidates) - (symbol . "t") - (prefix . ejc-return-point) - (requires . 0) - (cache . t))) - -(defvar ac-source-ejc-colomns - '((candidates . ejc-colomns-candidates) - (symbol . "c") - (requires . 1) - (cache . t))) - -(defvar ac-source-ejc-colomns-point - '((candidates . ejc-colomns-candidates) - (symbol . "c") - (prefix . ejc-return-point) - (requires . 0) - (cache . t))) - -(defvar ac-source-ejc-ansi-sql - '((candidates . ejc-get-ansi-sql-words) - (symbol . "s") - (document . ac-ejc-documentation) - (requires . 1) - (cache . t))) - -;;;###autoload -(defun ejc-ac-setup () - "Add the completion sources to the front of `ac-sources'. -This affects only the current buffer. - -Check against following cases: -prefix-2.prefix-1.# -prefix-1.# -something#" - (interactive) - (add-to-list 'ac-sources 'ac-source-ejc-ansi-sql) - (add-to-list 'ac-sources 'ac-source-ejc-owners) - (add-to-list 'ac-sources 'ac-source-ejc-tables) - (add-to-list 'ac-sources 'ac-source-ejc-tables-point) - (add-to-list 'ac-sources 'ac-source-ejc-colomns) - (add-to-list 'ac-sources 'ac-source-ejc-colomns-point)) - -(defun ejc-ac-hook () - (if ejc-use-flx - (if (require 'flx-ido nil 'noerror) - (setq-local ac-match-function 'ejc-flx-match-internal) - (error (concat "Please install flx.el and flx-ido.el " - "if you use fuzzy completion")))) - (delq 'ac-source-dictionary ac-sources) - (delq 'ac-source-abbrev ac-sources) - (delq 'ac-source-words-in-same-mode-buffers ac-sources)) - -(add-hook 'ejc-sql-minor-mode-hook 'ejc-ac-hook) - -(when (require 'yasnippet nil 'noerror) - (setq yas-snippet-dirs - (nconc yas-snippet-dirs - (list (expand-file-name "snippets" - (file-name-directory - (locate-library "ejc-sql")))))) - (defun ejc-yas-downcase-key (args) - (if ejc-sql-mode - (cl-callf downcase (nth 1 args))) - args) - (advice-add 'yas--fetch :filter-args #'ejc-yas-downcase-key)) - -(provide 'ejc-autocomplete) - -;;; ejc-autocomplete.el ends here diff --git a/elpa/ejc-sql-20190121.1043/ejc-direx.el b/elpa/ejc-sql-20190121.1043/ejc-direx.el deleted file mode 100644 index d59d201f..00000000 --- a/elpa/ejc-sql-20190121.1043/ejc-direx.el +++ /dev/null @@ -1,196 +0,0 @@ -;;; ejc-direx.el - -;;; Copyright © 2017 - Kostafey - -;;; This program is free software; you can redistribute it and/or modify -;;; it under the terms of the GNU General Public License as published by -;;; the Free Software Foundation; either version 2, or (at your option) -;;; any later version. -;;; -;;; This program is distributed in the hope that it will be useful, -;;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;;; GNU General Public License for more details. -;;; -;;; You should have received a copy of the GNU General Public License -;;; along with this program; if not, write to the Free Software Foundation, -;;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - -;;; Code: - - -(require 'dash) -(require 'direx) -(require 'ejc-interaction) - -(defgroup ejc-direx nil - "Database structure visualisation tree." - :group 'ejc - :prefix "ejc-direx") - - -;;; Core - -(defclass ejc-direx:object (direx:tree) ((cache :initarg :cache))) -(defclass ejc-direx:database (ejc-direx:object direx:node) - ((buffer :initarg :buffer) - (file-name :initarg :file-name - :accessor direx:file-full-name))) -(defclass ejc-direx:schema (ejc-direx:object direx:node) ()) -(defclass ejc-direx:table (ejc-direx:object direx:node) ()) -(defclass ejc-direx:colomn (ejc-direx:object direx:leaf) ()) - -(defvar ejc-direx:type-class-map - '(("database" . ejc-direx:database) - ("schema" . ejc-direx:schema) - ("table" . ejc-direx:table) - ("colomn" . ejc-direx:colomn))) - -(defun ejc-direx:node-from-cache (cache) - (let* ((type (plist-get (car cache) :type)) - (class (or (assoc-default type ejc-direx:type-class-map) - 'ejc-direx:colomn))) - (make-instance class - :cache cache - :name (plist-get (car cache) :name)))) - -(defun ejc-direx:-filter-cache (items) - "Filter out cache items according to configuration." - (delq nil items)) - -(defmethod direx:node-children ((node ejc-direx:object)) - (mapcar 'ejc-direx:node-from-cache - (ejc-direx:-filter-cache (cdr (oref node :cache))))) - - -;;; Face -(defface ejc-direx:database - '((t :inherit font-lock-keyword-face)) - "Face for database name in direx tree" - :group 'ejc-direx) - -(defface ejc-direx:schema - '((t :inherit font-lock-type-face)) - "Face for schema name in direx tree" - :group 'ejc-direx) - -(defface ejc-direx:table - '((t :inherit font-lock-function-name-face)) - "Face for table name in direx tree" - :group 'ejc-direx) - -(defface ejc-direx:colomn - '((t :inherit font-lock-variable-name-face)) - "Face for column name in direx tree" - :group 'ejc-direx) - - -;;; View - -(defclass ejc-direx:item (direx:item) ()) - -(defmethod direx:make-item ((tree ejc-direx:object) parent) - (make-instance 'ejc-direx:item :tree tree :parent parent)) - -(defmethod direx:make-item ((tree ejc-direx:colomn) parent) - (let ((item (call-next-method))) - (oset item :face 'ejc-direx:colomn) - item)) - -(defmethod direx:make-item ((tree ejc-direx:table) parent) - (let ((item (call-next-method))) - (oset item :face 'ejc-direx:table) - item)) - -(defmethod direx:make-item ((tree ejc-direx:schema) parent) - (let ((item (call-next-method))) - (oset item :face 'ejc-direx:schema) - item)) - -(defmethod direx:make-item ((tree ejc-direx:database) parent) - (let ((item (call-next-method))) - (oset item :face 'ejc-direx:database) - item)) - -(defun direx-ejc:-goto-item (item) - (destructuring-bind (&key line_nr column &allow-other-keys) - (car (oref (direx:item-tree item) :cache)) - (ejc:goto--line-column line_nr column))) - -(defmethod direx:generic-find-item ((item ejc-direx:item) - not-this-window) - (let* ((root (direx:item-root item)) - (filename (direx:file-full-name (direx:item-tree root)))) - (if not-this-window - (find-file-other-window filename) - (find-file filename)) - (direx-ejc:-goto-item item))) - -(defmethod direx:generic-display-item ((item ejc-direx:item)) - (let* ((root (direx:item-root item)) - (filename (direx:file-full-name (direx:item-tree root)))) - (with-selected-window (display-buffer (find-file-noselect filename)) - (direx-ejc:-goto-item item)))) - -(defvar ejc-direx:item-refresh--recurring nil) - -(defun ejc-direx:get-structure () - "Provide data - database structure for direx tree." - (cl-labels ((column-item (column) - (list :type "column" :name column)) - (table-item (table) - (let ((columns - (ejc-get-cached-colomns-list ejc-db table t))) - (cons (list :type "table" :name table) - (-map 'list - (-map #'column-item columns))))) - (schema-item (schema) - (let ((tables (ejc-get-cached-tables-list - ejc-db schema t))) - (cons (list :type "schema" :name schema) - (-map #'table-item tables))))) - ;; Assume schema == owner (difference depends on exact database type). - (let ((schemas (ejc-get-cached-owners-list ejc-db t))) - (-map #'schema-item schemas)))) - -(defmethod direx:item-refresh ((item ejc-direx:item) &key recursive) - "Currently it always recursively refreshes whole tree." - (if ejc-direx:item-refresh--recurring - (call-next-method) - (let* ((ejc-direx:item-refresh--recurring t) - (root (direx:item-root item)) - (module (direx:item-tree root))) - (if (with-current-buffer (oref module :buffer) - (unless (eq (cdr (oref module :cache)) (ejc-direx:get-structure)) - (oset module :cache (cons nil (ejc-direx:get-structure))))) - (call-next-method root :recursive t) - (message "No need to refresh"))))) - - -;;; Command - -(defun ejc-direx:make-buffer () - (let ((current-ejc-db ejc-db) - (buf (direx:ensure-buffer-for-root - (make-instance 'ejc-direx:database - :name (format "%s" (ejc-get-db-name ejc-db)) - :buffer (current-buffer) - :file-name (buffer-file-name) - :cache (cons nil (ejc-direx:get-structure)))))) - (with-current-buffer buf - (setq-local ejc-db current-ejc-db)) - buf)) - -;;;###autoload -(defun ejc-direx:pop-to-buffer () - (interactive) - (pop-to-buffer (ejc-direx:make-buffer))) - -;;;###autoload -(defun ejc-direx:switch-to-buffer () - (interactive) - (switch-to-buffer (ejc-direx:make-buffer))) - -(provide 'ejc-direx) - -;;; ejc-direx.el ends here diff --git a/elpa/ejc-sql-20190121.1043/ejc-doc.el b/elpa/ejc-sql-20190121.1043/ejc-doc.el deleted file mode 100644 index 7c99ab69..00000000 --- a/elpa/ejc-sql-20190121.1043/ejc-doc.el +++ /dev/null @@ -1,75 +0,0 @@ -;;; ejc-doc.el -- SQL quick hints documentation. - -;; Copyright © wikipedia.org -;; Creative Commons Attribution-ShareAlike license - -;;; Code: - -(require 'dash) - -(defconst ejc-sql-doc (make-hash-table :test 'eq)) - -(defun ejc-fill-doc (&rest args) - (-reduce (lambda (key val) - (puthash key val ejc-sql-doc)) - args)) - -(defvar ejc-doc-created-p nil) - -(defun ejc-create-doc () - (ejc-fill-doc - 'select - "The SQL SELECT statement returns a result -set of records from one or more tables. - -SELECT - [DISTINCT | DISTINCTROW | ALL] - select_expression,... - FROM table_references - [WHERE where_definition] - [GROUP BY {unsigned_integer | col_name | formula}] - [HAVING where_definition] - [ORDER BY {unsigned_integer | col_name | formula} [ASC | DESC], ...]" - - 'insert - "An SQL INSERT statement adds one or more records -to any single table in a relational database. - -INSERT INTO table (column1 [, column2, column3 ... ]) -VALUES (value1 [, value2, value3 ... ])" - - 'update - "An SQL UPDATE statement changes the data of one -or more records in a table. Either all the rows can -be updated, or a subset may be chosen using a condition. - -UPDATE table_name SET column_name = value [, column_name = value ...] -[WHERE condition]" - - 'delete - "The SQL DELETE statement removes one or more records from a table. - -DELETE FROM table_name [WHERE condition]" - - 'alter - "The ALTER TABLE command modifies column definitions and table constraints -'on the fly'. This means existing definitions are extended, changed or -deleted or existing data is casted to a different type or existing data is -evaluated against the new definitions. - --- change column definitions -ALTER TABLE { ADD | ALTER } [ COLUMN ] - ; -ALTER TABLE { DROP } [ COLUMN ] - ; - --- change table constraints -ALTER TABLE { ADD | ALTER } CONSTRAINT - ; -ALTER TABLE { DROP } CONSTRAINT - ;") - (setq ejc-doc-created-p t)) - -(provide 'ejc-doc) - -;;; ejc-doc.el ends here diff --git a/elpa/ejc-sql-20190121.1043/ejc-flx.el b/elpa/ejc-sql-20190121.1043/ejc-flx.el deleted file mode 100644 index 2bb98a38..00000000 --- a/elpa/ejc-sql-20190121.1043/ejc-flx.el +++ /dev/null @@ -1,103 +0,0 @@ -;;; ejc-flx.el -- Customization flx for ejc (the part of ejc-sql). - -;;; Copyright © 2018 - Kostafey - -;;; This program is free software; you can redistribute it and/or modify -;;; it under the terms of the GNU General Public License as published by -;;; the Free Software Foundation; either version 2, or (at your option) -;;; any later version. -;;; -;;; This program is distributed in the hope that it will be useful, -;;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;;; GNU General Public License for more details. -;;; -;;; You should have received a copy of the GNU General Public License -;;; along with this program; if not, write to the Free Software Foundation, -;;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - -;;; Code: - -(defcustom ejc-use-flx nil - "Non-nil enables `flx' fuzzy matching engine autocompletion." - :group 'ejc-sql - :type 'boolean) - -(defcustom ejc-flx-threshold 2 - "The minimum number of typed chars required to use `flx' for autocompletion. -When 1, enables `flx' usage from the first typed char." - :group 'ejc-sql - :type 'integer) - -(defface ejc-flx-highlight-face - '((t :inherit popup-isearch-match)) - "Face used by flx for highlighting flx match characters in `ejc-sql' buffers." - :group 'ejc-sql) - -(defun ejc-flx-propertize (obj score &optional add-score) - "Return propertized copy of obj according to score. - -SCORE of nil means to clear the properties." - (let ((block-started (cadr score)) - (last-char nil) - (str (if (consp obj) - (substring-no-properties (car obj)) - (substring-no-properties obj)))) - - (when score - (dolist (char (cdr score)) - (when (and last-char - (not (= (1+ last-char) char))) - (put-text-property block-started (1+ last-char) 'face 'ejc-flx-highlight-face str) - (setq block-started char)) - (setq last-char char)) - (put-text-property block-started (1+ last-char) 'face 'ejc-flx-highlight-face str) - (when add-score - (setq str (format "%s [%s]" str (car score))))) - (if (consp obj) - (cons str (cdr obj)) - str))) - -(defun ejc-flx-decorate (things &optional clear) - "Add ido text properties to THINGS. -If CLEAR is specified, clear them instead." - (if flx-ido-use-faces - (let ((decorate-count (min ido-max-prospects - (length things)))) - (nconc - (cl-loop for thing in things - for i from 0 below decorate-count - collect (if clear - (ejc-flx-propertize thing nil) - (ejc-flx-propertize (car thing) (cdr thing)))) - (if clear - (nthcdr decorate-count things) - (mapcar 'car (nthcdr decorate-count things))))) - (if clear - things - (mapcar 'car things)))) - -(defun ejc-flx-match-internal (query items) - "Match QUERY against ITEMS using flx scores. - -If filtered item count is still greater than `flx-ido-threshold', then use flex." - (if (< (length query) ejc-flx-threshold) - (all-completions query items) - (let ((flex-result (flx-flex-match query items))) - (if (< (length flex-result) flx-ido-threshold) - (let* ((matches (cl-loop for item in flex-result - for string = (ido-name item) - for score = (flx-score string query flx-file-cache) - if score - collect (cons item score) - into matches - finally return matches))) - (ejc-flx-decorate (delete-consecutive-dups - (sort matches - (lambda (x y) (> (cadr x) (cadr y)))) - t))) - flex-result)))) - -(provide 'ejc-flx) - -;;; ejc-flx.el ends here diff --git a/elpa/ejc-sql-20190121.1043/ejc-format.el b/elpa/ejc-sql-20190121.1043/ejc-format.el deleted file mode 100644 index 70b35c1f..00000000 --- a/elpa/ejc-sql-20190121.1043/ejc-format.el +++ /dev/null @@ -1,276 +0,0 @@ -;;; ejc-format.el -- SQL formatting library (the part of ejc-sql). - -;;; Copyright © 2012-2019 - Kostafey - -;;; This program is free software; you can redistribute it and/or modify -;;; it under the terms of the GNU General Public License as published by -;;; the Free Software Foundation; either version 2, or (at your option) -;;; any later version. -;;; -;;; This program is distributed in the hope that it will be useful, -;;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;;; GNU General Public License for more details. -;;; -;;; You should have received a copy of the GNU General Public License -;;; along with this program; if not, write to the Free Software Foundation, -;;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - -;;; Code: - -(require 'cua-base) -(require 'ejc-lib) -(require 'subr-x) - -(defvar ejc-sql-separator "/" - "The char with purpose to separate the SQL statement both other.") - -(defun ejc-sql-separator-re () - (format "^\\s-*%s\\s-*" ejc-sql-separator)) - -(defun ejc-get-border-top () - "Get top position of batch statement(s) seperator `ejc-sql-separator'. -Upper position of this batch statement(s)." - (save-excursion - (if (re-search-backward (ejc-sql-separator-re) nil t nil) - (forward-char) - (beginning-of-buffer)) - (point))) - -(defun ejc-get-border-bottom () - "Get bottom position of batch statements seperator `ejc-sql-separator' -Bottom position of this batch statement(s)." - (save-excursion - (if (re-search-forward (ejc-sql-separator-re) nil t nil) - (backward-char) - (end-of-buffer)) - (if (equal (string (preceding-char)) "\n") - (backward-char 1)) - (let ((sep-len (length ejc-sql-separator))) - (if (equal (buffer-substring (- (point) sep-len) (point)) - ejc-sql-separator) - (backward-char sep-len))) - (point))) - -(defun ejc-get-org-begin () - "Obtain position for begin of code snippet in `org-mode' buffers." - (save-excursion - (if (and (derived-mode-p 'org-mode) - (re-search-backward "^\\s-*#\\+begin_[(src)(example)].*" - nil t nil)) - (line-end-position) - (point-min)))) - -(defun ejc-get-org-end () - "Obtain position for end of code snippet in `org-mode' buffers." - (save-excursion - (if (and (derived-mode-p 'org-mode) - (re-search-forward "^\\s-*#\\+end_[(src)(example)]" - nil t nil)) - (line-beginning-position) - (point-max)))) - -(cl-defun ejc-get-sql-boundaries-at-point (&optional beg end) - "Returns list of the boundaries of the current SQL expression. -The current SQL expression is the expression under the point. -The boundaries are marked by `ejc-sql-separator's. If the top or -bottom boundary is absent - it returns beginning or end of the -buffer. Set BEG and END parameters to add manual boundaries restrictions." - (let* ((beg (max (or beg (point-min)) - (ejc-get-border-top) - (ejc-get-org-begin))) - (end (min (or end (point-max)) - (ejc-get-border-bottom) - (ejc-get-org-end)))) - (list beg end))) - -(defmacro ejc--in-sql-boundaries (beg end &rest body) - "Inject `beg' and `end' local variables to the `body' scope. -`beg' and `end' are the boundaries of the current sql expression." - `(let* ((boundaries (if (and (boundp ',beg) (boundp ',end)) - (ejc-get-sql-boundaries-at-point ,beg ,end) - (ejc-get-sql-boundaries-at-point))) - (,beg (car boundaries)) - (,end (car (cdr boundaries)))) - ,@body)) - -(defun ejc-mark-this-sql () - "Select (mark) SQL around the point." - (interactive) - (ejc--in-sql-boundaries beg end - (when mark-active - (setq mark-active nil)) - (goto-char beg) - (cua-set-mark) - (goto-char end))) - -(defun ejc-next-sql (&optional mark) - "Goto next SQL statement." - (interactive) - (ejc--in-sql-boundaries - beg end - (if (and mark (not mark-active)) - (cua-set-mark)) - (goto-char end) - (right-char 1))) - -(defun ejc-previous-sql (&optional mark) - "Goto previous SQL statement." - (interactive) - (ejc--in-sql-boundaries - beg end - (if (and mark (not mark-active)) - (cua-set-mark)) - (goto-char beg) - (left-char 1))) - -(defun ejc-apply-in-sql-boundaries (func) - (ejc--in-sql-boundaries beg end - (apply func (list beg end)))) - -(cl-defun ejc-get-sql-at-point (&key beg end) - "Return SQL around the point." - (ejc--in-sql-boundaries - beg end - (let ((sql (ejc-strip-text-properties - (buffer-substring beg end)))) - sql))) - -(defmacro ejc-ensure-sql-mode (&rest body) - `(if (not (equal major-mode 'sql-mode)) - (error "SQL formatting is suitable in sql-mode only.") - (progn ,@body))) - -(defun ejc-format-sql (beg end) - (interactive "r") - (ejc-ensure-sql-mode - (save-excursion - (mapc (lambda (from-to) - (ejc-apply-in-sql-boundaries - (lambda (beg end) - (replace-regexp (car from-to) (cadr from-to) nil beg end)))) - '(("\n" " ") - ("," ", ") - (" +" " ") - ("," ",\n ") - ("select" "select \n ") - (" from " "\nfrom \n ") - (" where " "\nwhere \n ") - (" and " "\n and ") - (" or " "\n or ") - (" order by " "\norder by \n") - (" inner join " "\ninner join ") - (" left join " "\nleft join ") - (" on " "\n on ") - (" group by " "\ngroup by ")))))) - -(defun ejc-format-sql-at-point () - (interactive) - (ejc--in-sql-boundaries - beg end - (ejc-format-sql beg end))) - -(defun ejc-pretty-print-sql-at-point () - "Pretty-print SQL bounded by the `ejc-sql-separator' or/and buffer -boundaries." - (interactive) - (ejc--in-sql-boundaries - beg end - (let ((result (ejc-pretty-print (buffer-substring beg end) :hibernate))) - (delete-region beg end) - (insert result)))) - -(defun ejc-pretty-print-sql-region (beg end) - "Pretty-print SQL bounded by the selection area." - (interactive "r") - (let ((result (ejc-pretty-print (buffer-substring beg end) :hibernate))) - (delete-region beg end) - (insert result))) - -(defun ejc-insert-file-header () - (interactive) - (insert (concat "-- -*- mode: sql; -*-\n" - "-- Local Variables:\n" - "-- eval: (ejc-sql-mode)\n" - "-- End:\n"))) - -(defvar ejc-clear-sql-regexp - (concat "^\\s-*\\t*\"" - "\\|\\\\n\"\s-*\\+$" - "\\|\\\\n\";$")) - -(defun ejc-strinp-sql-at-point () - (interactive) - (ejc--in-sql-boundaries - beg end - (save-excursion - (replace-regexp ejc-clear-sql-regexp "" nil beg end) - (whitespace-cleanup-region beg end)))) - -(defun ejc-longest-line-length (beg-line end-line) - (interactive) - (save-excursion - (let ((curr-line beg-line) - (max-length 0) - (new-length 0)) - (while (<= curr-line end-line) - (goto-line curr-line) - (setq new-length (save-excursion - (end-of-line) - (current-column))) - (if (> new-length max-length) - (setq max-length new-length)) - (setq curr-line (1+ curr-line))) - max-length))) - -(defun ejc-is-separator-string (pos) - (equal (string-trim (buffer-substring - pos - (save-excursion - (end-of-line) - (point)))) - ejc-sql-separator)) - -(defun ejc-dress-sql-at-point () - (interactive) - (ejc-strinp-sql-at-point) - (save-excursion - (ejc--in-sql-boundaries - beg end - (let* ((beg-line (progn (goto-char beg) - (right-char) - (line-number-at-pos))) - (end-line (progn (goto-char end) - (if (ejc-is-separator-string end) - (left-char 1)) - (line-number-at-pos))) - (length-line (ejc-longest-line-length beg-line end-line)) - (curr-line beg-line)) - (while (<= curr-line end-line) - (goto-line curr-line) - (beginning-of-line) - (insert "\"") - (end-of-line) - (dotimes (counter (+ 2 (- length-line (current-column)))) - (insert " ")) - (if (equal curr-line end-line) - (insert "\\n\";") - (insert "\\n\" +")) - (setq curr-line (1+ curr-line))))))) - -(defun ejc-flash-region (start end &optional timeout) - "Temporarily highlight region from START to END." - (let ((overlay (make-overlay start end))) - (overlay-put overlay 'face 'secondary-selection) - (run-with-timer (or timeout 0.2) nil 'delete-overlay overlay))) - -(cl-defun ejc-flash-this-sql (&key beg end) - "Select (mark) SQL around the point." - (interactive) - (ejc--in-sql-boundaries - beg end - (ejc-flash-region beg end))) - -(provide 'ejc-format) - -;;; ejc-format.el ends here diff --git a/elpa/ejc-sql-20190121.1043/ejc-interaction.el b/elpa/ejc-sql-20190121.1043/ejc-interaction.el deleted file mode 100644 index 3f1fb529..00000000 --- a/elpa/ejc-sql-20190121.1043/ejc-interaction.el +++ /dev/null @@ -1,244 +0,0 @@ -;;; ejc-interaction.el -- ejc-sql interact with Clojure. -*- lexical-binding: t -*- - -;;; Copyright © 2013-2018 - Kostafey - -;;; This program is free software; you can redistribute it and/or modify -;;; it under the terms of the GNU General Public License as published by -;;; the Free Software Foundation; either version 2, or (at your option) -;;; any later version. -;;; -;;; This program is distributed in the hope that it will be useful, -;;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;;; GNU General Public License for more details. -;;; -;;; You should have received a copy of the GNU General Public License -;;; along with this program; if not, write to the Free Software Foundation, -;;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - -;;; Code: - -(require 'ejc-lib) -(require 'ejc-format) -(require 'clomacs) - -(clomacs-create-httpd-start ejc-httpd-start - :lib-name "ejc-sql") - -(clomacs-create-httpd-stop ejc-httpd-stop - :lib-name "ejc-sql") - -(clomacs-defun ejc-sql-set-db - set-db - :lib-name "ejc-sql" - :namespace ejc-sql.connect - :doc "Define ejc-sql.connect/db var." - :httpd-starter 'ejc-httpd-start) - -(clomacs-defun ejc-add-classpath - add-classpath - :lib-name "ejc-sql" - :namespace cemerick.pomegranate) - -(clomacs-defun ejc-require - clojure.core/require - :lib-name "ejc-sql") - -(clomacs-defun ejc-import - clojure.core/import - :lib-name "ejc-sql") - -(defun ejc-connect-to-db (conn-struct) - (ejc-require `'cemerick.pomegranate) - (ejc-add-classpath (alist-get :classpath conn-struct)) - (if-let ((classname (alist-get :classname conn-struct))) - (ejc-import (read classname))) - (ejc-sql-set-db conn-struct) - (setq-local ejc-connection-struct conn-struct)) - -(defun ejc-get-sql-from-string (sql) - (let* ((sql (replace-regexp-in-string ejc-clear-sql-regexp "" sql)) - (sql (replace-regexp-in-string "\"" "'" sql))) - sql)) - -(clomacs-defun ejc--eval-sql-and-log-print - eval-sql-and-log-print - :lib-name "ejc-sql" - :namespace ejc-sql.connect - :return-type :string - :doc "Core function to evaluate SQL queries. - Prepare SQL string, evaluate SQL script and write them to log file") - -(clomacs-defun ejc--is-query-running-p - is-query-running? - :lib-name "ejc-sql" - :namespace ejc-sql.connect - :return-type :boolean) - -(clomacs-defun ejc--cancel-query - cancel-query - :lib-name "ejc-sql" - :namespace ejc-sql.connect - :doc "Cancel current query." - :interactive t - :return-type :list) - -(clomacs-defun ejc--eval-sql-get-column - eval-sql-internal-get-column - :lib-name "ejc-sql" - :return-type :list - :namespace ejc-sql.connect - :doc "Get `sql', return list.") - -(defalias 'ejc--eval-get-list 'ejc--eval-sql-get-column) - -(clomacs-defun ejc-get-table-meta - ejc-sql.connect/get-table-meta - :lib-name "ejc-sql" - :namespace ejc-sql.connect) - -(clomacs-defun ejc--get-result-file-path - get-result-file-path - :lib-name "ejc-sql" - :namespace ejc-sql.output) - -(clomacs-defun ejc-print - clojure.core/print - :lib-name "ejc-sql" - :return-type :string - :return-value :stdout) - -(clomacs-defun ejc-write-result-file - write-result-file - :namespace ejc-sql.output - :lib-name "ejc-sql" - :return-type :string) - -(clomacs-defun ejc-clear-result-file - clear-result-file - :namespace ejc-sql.output - :lib-name "ejc-sql" - :return-type :string) - -(clomacs-defun ejc-get-log-file-path - print-log-file-path - :lib-name "ejc-sql" - :namespace ejc-sql.output - :return-value :stdout) - -(clomacs-defun ejc-pretty-print - pretty-print - :lib-name "ejc-sql" - :namespace ejc-sql.output - :return-value :stdout) - -(clomacs-defun ejc-set-rows-limit - set-rows-limit - :lib-name "ejc-sql" - :namespace ejc-sql.output - :doc (concat "Set limit for number of records to output. " - "When nil no limit.")) - -(clomacs-defun ejc-get-stucture - get-stucture - :lib-name "ejc-sql" - :namespace ejc-sql.structure - :return-type :list) - -(clomacs-defun ejc-get-owners-candidates - get-owners-candidates - :lib-name "ejc-sql" - :namespace ejc-sql.structure - :return-type :list) - -(clomacs-defun ejc-get-tables-candidates - get-tables-candidates - :lib-name "ejc-sql" - :namespace ejc-sql.structure - :return-type :list) - -(clomacs-defun ejc-get-colomns-candidates - get-colomns-candidates - :lib-name "ejc-sql" - :namespace ejc-sql.structure - :return-type :list) - -(clomacs-defun ejc-get-cached-owners-list - get-owners - :lib-name "ejc-sql" - :namespace ejc-sql.structure - :return-type :list) - -(clomacs-defun ejc-get-cached-tables-list - get-tables - :lib-name "ejc-sql" - :namespace ejc-sql.structure - :return-type :list - :doc "Return cached tables list. - Requires `ejc-db' buffer local variable as parameter.") - -(clomacs-defun ejc-get-cached-colomns-list - get-colomns - :lib-name "ejc-sql" - :namespace ejc-sql.structure - :return-type :list) - -(clomacs-defun ejc-invalidate-cache-inner - invalidate-cache - :lib-name "ejc-sql" - :namespace ejc-sql.structure - :doc (concat "Clean your current connection cache " - "(database owners and tables list).")) - -(clomacs-defun ejc-validate-connection - validate-connection - :lib-name "ejc-sql" - :namespace ejc-sql.connect - :return-type :boolean) - -(defun ejc-invalidate-cache () - "Clean current connection cache (database owners and tables list)." - (interactive) - (ejc-invalidate-cache-inner ejc-connection-struct)) - -(clomacs-defun ejc-get-cache - get-cache - :lib-name "ejc-sql" - :namespace ejc-sql.structure) - -(clomacs-defun ejc-select-db-meta-script - select-db-meta-script - :lib-name "ejc-sql" - :namespace ejc-sql.structure) - -(clomacs-defun ejc-get-db-name - get-db-name - :lib-name "ejc-sql" - :namespace ejc-sql.structure) - -(defun ejc-quit-connection () - "Stop nREPL process, mark ejc-sql-mode buffers disconnected." - (interactive) - (when (y-or-n-p "Are you sure you want to close all jdbc connections?") - (ejc-httpd-stop) - (cider--close-connection (clomacs-get-connection "ejc-sql")) - ;; Update modeline of ejc-sql-mode buffers - mark as disconnected. - (let ((buffers (buffer-list))) - (while buffers - (with-current-buffer (car buffers) - (when (member 'ejc-sql-mode minor-mode-list) - (sql-highlight-product) - (spinner-stop))) - (setq buffers (cdr buffers))))) - (unless (cider-connected-p) - (cider-close-ancillary-buffers))) - -(defalias 'ejc-close-connection 'ejc-quit-connection) - -(defun ejc-buffer-connected-p () - "Check if current buffer is connected to database." - (and (clomacs-get-connection "ejc-sql") (boundp 'ejc-db) ejc-db)) - -(provide 'ejc-interaction) - -;;; ejc-interaction.el ends here diff --git a/elpa/ejc-sql-20190121.1043/ejc-lib.el b/elpa/ejc-sql-20190121.1043/ejc-lib.el deleted file mode 100644 index 845e66f0..00000000 --- a/elpa/ejc-sql-20190121.1043/ejc-lib.el +++ /dev/null @@ -1,50 +0,0 @@ -;;; ejc-lib.el -- ejc-sql shared objects (the part of ejc-sql). - -;;; Copyright © 2013-2016 - Kostafey - -;;; This program is free software; you can redistribute it and/or modify -;;; it under the terms of the GNU General Public License as published by -;;; the Free Software Foundation; either version 2, or (at your option) -;;; any later version. -;;; -;;; This program is distributed in the hope that it will be useful, -;;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;;; GNU General Public License for more details. -;;; -;;; You should have received a copy of the GNU General Public License -;;; along with this program; if not, write to the Free Software Foundation, -;;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - -;;; Code: - -(defvar-local ejc-connection-name nil - "Buffer-local connection name created with `ejc-create-connection'.") - -(defvar-local ejc-connection-struct nil - "Buffer-local connection structure.") - -(defun ejc-string-endswith-p (s ending) - "Return non-nil if string S ends with ENDING." - (let ((elength (length ending))) - (string= (substring s (- 0 elength)) ending))) - -(defun ejc-find-file-in-load-path (search-file-name &optional fail-on-error) - "Return the full path to `file-name'. -`file-name' is searching in the emacs `load-path'." - (let ((result nil)) - (dolist (path load-path) - (let ((search-file-path (expand-file-name search-file-name path))) - (if (file-exists-p search-file-path) - (setq result search-file-path)))) - (if (and fail-on-error (not result)) - (error (concat "Can't find file " search-file-name)) - result))) - -(defun ejc-strip-text-properties (txt) - (set-text-properties 0 (length txt) nil txt) - txt) - -(provide 'ejc-lib) - -;;; ejc-lib.el ends here diff --git a/elpa/ejc-sql-20190121.1043/ejc-result-mode.el b/elpa/ejc-sql-20190121.1043/ejc-result-mode.el deleted file mode 100644 index 4aa05772..00000000 --- a/elpa/ejc-sql-20190121.1043/ejc-result-mode.el +++ /dev/null @@ -1,42 +0,0 @@ -;;; ejc-result-mode.el - -;;; Copyright © 2017 - Kostafey - -;;; This program is free software; you can redistribute it and/or modify -;;; it under the terms of the GNU General Public License as published by -;;; the Free Software Foundation; either version 2, or (at your option) -;;; any later version. -;;; -;;; This program is distributed in the hope that it will be useful, -;;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;;; GNU General Public License for more details. -;;; -;;; You should have received a copy of the GNU General Public License -;;; along with this program; if not, write to the Free Software Foundation, -;;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - -;;; Code: - -(defface ejc-result-table-borders-face '((t :inherit font-lock-comment-face - :italic nil)) - "Face used to font-lock table borders." - :group 'ejc-sql-faces) - -(defconst ejc-result-font-lock-keywords - '(("|" . 'ejc-result-table-borders-face) - ("-" . 'ejc-result-table-borders-face) - ("+" . 'ejc-result-table-borders-face))) - -(defun ejc-result-mode () - (interactive) - (kill-all-local-variables) - (setq view-read-only t) - (setq truncate-lines t) - (setq major-mode 'ejc-result-mode - mode-name "SQL-Result") - (setq font-lock-defaults '(ejc-result-font-lock-keywords))) - -(provide 'ejc-result-mode) - -;;; ejc-result-mode.el ends here diff --git a/elpa/ejc-sql-20190121.1043/ejc-sql-autoloads.el b/elpa/ejc-sql-20190121.1043/ejc-sql-autoloads.el deleted file mode 100644 index 7bab6a44..00000000 --- a/elpa/ejc-sql-20190121.1043/ejc-sql-autoloads.el +++ /dev/null @@ -1,151 +0,0 @@ -;;; ejc-sql-autoloads.el --- automatically extracted autoloads -;; -;;; Code: - -(add-to-list 'load-path (directory-file-name - (or (file-name-directory #$) (car load-path)))) - - -;;;### (autoloads nil "ejc-autocomplete" "ejc-autocomplete.el" (0 -;;;;;; 0 0 0)) -;;; Generated autoloads from ejc-autocomplete.el - -(autoload 'ejc-owners-candidates "ejc-autocomplete" "\ - - -\(fn)" nil nil) - -(autoload 'ejc-tables-candidates "ejc-autocomplete" "\ - - -\(fn)" nil nil) - -(autoload 'ejc-colomns-candidates "ejc-autocomplete" "\ - - -\(fn)" nil nil) - -(autoload 'ejc-ac-setup "ejc-autocomplete" "\ -Add the completion sources to the front of `ac-sources'. -This affects only the current buffer. - -Check against following cases: -prefix-2.prefix-1.# -prefix-1.# -something# - -\(fn)" t nil) - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ejc-autocomplete" '("ejc-" "ac-"))) - -;;;*** - -;;;### (autoloads nil "ejc-direx" "ejc-direx.el" (0 0 0 0)) -;;; Generated autoloads from ejc-direx.el - -(autoload 'ejc-direx:pop-to-buffer "ejc-direx" "\ - - -\(fn)" t nil) - -(autoload 'ejc-direx:switch-to-buffer "ejc-direx" "\ - - -\(fn)" t nil) - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ejc-direx" '("ejc-direx:" "direx"))) - -;;;*** - -;;;### (autoloads nil "ejc-doc" "ejc-doc.el" (0 0 0 0)) -;;; Generated autoloads from ejc-doc.el - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ejc-doc" '("ejc-"))) - -;;;*** - -;;;### (autoloads nil "ejc-flx" "ejc-flx.el" (0 0 0 0)) -;;; Generated autoloads from ejc-flx.el - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ejc-flx" '("ejc-"))) - -;;;*** - -;;;### (autoloads nil "ejc-format" "ejc-format.el" (0 0 0 0)) -;;; Generated autoloads from ejc-format.el - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ejc-format" '("ejc-"))) - -;;;*** - -;;;### (autoloads nil "ejc-interaction" "ejc-interaction.el" (0 0 -;;;;;; 0 0)) -;;; Generated autoloads from ejc-interaction.el - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ejc-interaction" '("ejc-"))) - -;;;*** - -;;;### (autoloads nil "ejc-lib" "ejc-lib.el" (0 0 0 0)) -;;; Generated autoloads from ejc-lib.el - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ejc-lib" '("ejc-"))) - -;;;*** - -;;;### (autoloads nil "ejc-result-mode" "ejc-result-mode.el" (0 0 -;;;;;; 0 0)) -;;; Generated autoloads from ejc-result-mode.el - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ejc-result-mode" '("ejc-result-"))) - -;;;*** - -;;;### (autoloads nil "ejc-sql" "ejc-sql.el" (0 0 0 0)) -;;; Generated autoloads from ejc-sql.el - -(autoload 'ejc-sql-mode "ejc-sql" "\ -Toggle ejc-sql mode. - -\(fn &optional ARG)" t nil) - -(autoload 'ejc-create-menu "ejc-sql" "\ - - -\(fn)" nil nil) - -(autoload 'ejc-connect "ejc-sql" "\ -Connect to selected db. - -\(fn CONNECTION-NAME)" t nil) - -(autoload 'ejc-connect-existing-repl "ejc-sql" "\ -Connect to existing ejc-sql nREPL running process. -You can `cd` to your ejc-sql project folder (typically -'~/.emacs.d/elpa/ejc-sql-') and launch nREPL via `lein repl`. -Then run in Emacs `ejc-connect-existing-repl', type HOST and PORT -from your `lein run` console output. Finally, use `ejc-connect' from -any SQL buffer to connect to exact database, as always. - -\(fn)" t nil) - -(autoload 'ejc-version "ejc-sql" "\ -Get the ejc-sql version as string. - -\(fn)" t nil) - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ejc-sql" '("ejc-"))) - -;;;*** - -;;;### (autoloads nil nil ("ejc-sql-pkg.el") (0 0 0 0)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; coding: utf-8 -;; End: -;;; ejc-sql-autoloads.el ends here diff --git a/elpa/ejc-sql-20190121.1043/ejc-sql-pkg.el b/elpa/ejc-sql-20190121.1043/ejc-sql-pkg.el deleted file mode 100644 index bc818d77..00000000 --- a/elpa/ejc-sql-20190121.1043/ejc-sql-pkg.el +++ /dev/null @@ -1,17 +0,0 @@ -(define-package "ejc-sql" "20190121.1043" "Emacs SQL client uses Clojure JDBC." - '((emacs "25.1") - (clomacs "0.0.3") - (dash "2.12.1") - (auto-complete "1.5.1") - (spinner "1.7.1") - (direx "1.0.0")) - :keywords - '("sql" "jdbc") - :authors - '(("Kostafey" . "kostafey@gmail.com")) - :maintainer - '("Kostafey" . "kostafey@gmail.com") - :url "https://github.com/kostafey/ejc-sql") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/elpa/ejc-sql-20190121.1043/ejc-sql.el b/elpa/ejc-sql-20190121.1043/ejc-sql.el deleted file mode 100644 index 8b7a9a9c..00000000 --- a/elpa/ejc-sql-20190121.1043/ejc-sql.el +++ /dev/null @@ -1,703 +0,0 @@ -;;; ejc-sql.el --- Emacs SQL client uses Clojure JDBC. -*- lexical-binding: t -*- - -;;; Copyright © 2012-2019 - Kostafey - -;; Author: Kostafey -;; URL: https://github.com/kostafey/ejc-sql -;; Keywords: sql, jdbc -;; Version: 0.0.1 -;; Package-Requires: ((emacs "25.1")(clomacs "0.0.3")(dash "2.12.1")(auto-complete "1.5.1")(spinner "1.7.1")(direx "1.0.0")) - -;; 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 2, or (at your option) -;;; any later version. -;;; -;;; This program is distributed in the hope that it will be useful, -;;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;;; GNU General Public License for more details. -;;; -;;; You should have received a copy of the GNU General Public License -;;; along with this program; if not, write to the Free Software Foundation, -;;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - -;;; Commentary: - -;; ejc-sql turns Emacs into simple SQL client, it uses JDBC connection to -;; databases via clojure/java.jdbc lib. - -;; See README.md for detailed description. - -;;; Code: - -(require 'sql) -(require 'dash) -(require 'cl-lib) -(require 'ejc-lib) -(require 'ejc-direx) -(require 'ejc-format) -(require 'ejc-interaction) -(require 'ejc-result-mode) -(require 'ejc-autocomplete) - -(defvar-local ejc-db nil - "JDBC connection info for current SQL buffer.") - -(defvar ejc-connections nil - "List of existing configured jdbc connections") - -(defvar ejc-results-buffer nil - "The results buffer.") - -(defvar ejc-results-buffer-name "*ejc-sql-output*" - "The results buffer name.") - -(defvar ejc-result-file-path nil - "The results file path. Refreshed by any finished SQL evaluation.") - -(defvar ejc-current-buffer-query nil - "Current SQL edit buffer lanched query.") - -(defvar ejc-temp-editor-buffer-name "*ejc-sql-editor*" - "The buffer for conveniently edit ad-hoc SQL scripts.") - -(defvar ejc-temp-editor-file (expand-file-name "~/tmp/ejc-sql-editor.sql")) - -(defcustom ejc-keymap-prefix (kbd "C-c e") - "ejc-sql keymap prefix." - :group 'ejc-sql - :type 'string) - -(defcustom ejc-date-output-format "%d.%m.%Y %H:%M:%S" - "ejc-sql date output format." - :group 'ejc-sql - :type 'string) - -(defcustom ejc-connection-validate-timeout 5 - "The time in seconds to wait for the database connection validation." - :group 'ejc-sql - :type 'integer) - -(defcustom ejc-org-mode-show-results t - "When t show SQL query results of `org-mode' code snippet in the same buffer. -An expected behaviour for `org-mode' users. Disable popup window with SQL -results. When nil, otherwise, provide `ejc-sql' users expected behaviour." - :group 'ejc-sql - :type 'boolean) - -(defvar ejc-sql-mode-keymap (make-keymap) "ejc-sql-mode keymap.") -(define-key ejc-sql-mode-keymap (kbd "C-c C-c") 'ejc-eval-user-sql-at-point) -(define-key ejc-sql-mode-keymap (kbd "C-h t") 'ejc-describe-table) -(define-key ejc-sql-mode-keymap (kbd "C-h T") 'ejc-describe-entity) -(define-key ejc-sql-mode-keymap (kbd "C-M-S-b") '(lambda() (interactive) (ejc-previous-sql t))) -(define-key ejc-sql-mode-keymap (kbd "C-M-S-f") '(lambda() (interactive) (ejc-next-sql t))) -(define-key ejc-sql-mode-keymap (kbd "C-M-b") 'ejc-previous-sql) -(define-key ejc-sql-mode-keymap (kbd "C-M-f") 'ejc-next-sql) -(define-key ejc-sql-mode-keymap (kbd "C-g") 'ejc-cancel-query) - -(defvar ejc-command-map - (let ((map (make-sparse-keymap))) - (define-key map (kbd "") #'ejc-show-last-result) - (define-key map (kbd "t") #'ejc-show-tables-list) - (define-key map (kbd "T") #'ejc-show-user-types-list) - (define-key map (kbd "s") #'ejc-strinp-sql-at-point) - (define-key map (kbd "S") #'ejc-dress-sql-at-point) - (define-key map (kbd "p") #'ejc-pretty-print-sql-at-point) - map) - "Keymap for ejc-sql commands after `ejc-keymap-prefix'.") -(fset 'ejc-command-map ejc-command-map) - -(define-key ejc-sql-mode-keymap ejc-keymap-prefix 'ejc-command-map) - -(defvar ejc-sql-minor-mode-exit-hook nil - "*Functions to be called when `ejc-sql-mode' is exited.") - -(defvar ejc-sql-minor-mode-hook nil - "*Functions to be called when `ejc-sql-mode' is entered.") - -(defvar ejc-sql-mode nil) - -(defvar ejc-conn-statistics (list) - "Keep connection usage statistics and offer most frequently used first - when `ejc-connect' is called.") - -(defcustom ejc-conn-statistics-file (expand-file-name - "~/.ejc-sql/connection-statistics.el") - "Connection usage statistics data file location." - :group 'ejc-sql - :type 'string) - -(defface ejc-separator-face - '((t :inherit font-lock-function-name-face)) - "Face used to highlight SQL statement separators." - :group 'ejc-sql) - -(defun ejc-refresh-font-lock () - (funcall (if ejc-sql-mode - 'font-lock-add-keywords - 'font-lock-remove-keywords) - nil `((,(ejc-sql-separator-re) . 'ejc-separator-face))) - (if (fboundp 'font-lock-flush) - (font-lock-flush) - (when font-lock-mode - (with-no-warnings (font-lock-fontify-buffer)))) - (run-hooks 'ejc-sql-minor-mode-hook)) - -;;;###autoload -(define-minor-mode ejc-sql-mode - "Toggle ejc-sql mode." - :lighter " ejc" - :keymap ejc-sql-mode-keymap - :group 'ejc - :global nil - ;; :after-hook (ejc-create-menu) - (if ejc-sql-mode - (progn - (ejc-ac-setup) - (ejc-create-menu) - (ejc-refresh-font-lock)) - (progn - ;; (global-unset-key [menu-bar ejc-menu]) - (ejc-refresh-font-lock) - (run-hooks 'ejc-sql-minor-mode-exit-hook)))) - -;;;###autoload -(defun ejc-create-menu () - (define-key-after - ejc-sql-mode-keymap - [menu-bar ejc-menu] - (cons "ejc-sql" (make-sparse-keymap "ejc-sql mode")) - 'tools ) - (define-key - ejc-sql-mode-keymap - [menu-bar ejc-menu ev] - '("Eval SQL" . ejc-eval-user-sql-at-point)) - (define-key - ejc-sql-mode-keymap - [menu-bar ejc-menu fs] - '("Format SQL" . ejc-format-sql-at-point)) - (define-key - ejc-sql-mode-keymap - [menu-bar ejc-menu ms] - '("Mark SQL" . ejc-mark-this-sql)) - (define-key - ejc-sql-mode-keymap - [menu-bar ejc-menu tl] - '("Show tables list" . ejc-show-tables-list)) - (define-key - ejc-sql-mode-keymap - [menu-bar ejc-menu cl] - '("Show constraints list" . ejc-show-constraints-list)) - (define-key - ejc-sql-mode-keymap - [menu-bar ejc-menu pl] - '("Show procedures list" . ejc-show-procedures-list)) - (define-key - ejc-sql-mode-keymap - [menu-bar ejc-menu ss] - '("Strip SQL" . ejc-strinp-sql-at-point)) - (define-key - ejc-sql-mode-keymap - [menu-bar ejc-menu ds] - '("Dress SQL" . ejc-dress-sql-at-point)) - (define-key - ejc-sql-mode-keymap - [menu-bar ejc-menu ol] - '("Open log" . ejc-open-log)) - (define-key - ejc-sql-mode-keymap - [menu-bar ejc-menu sl] - '("Show last result" . ejc-show-last-result)) - (define-key - ejc-sql-mode-keymap - [menu-bar ejc-menu qc] - '("Quit connection" . ejc-quit-connection))) - -(cl-defun ejc-create-connection (connection-name - &key - ;; ---------- - ;; DriverManager (preferred): - dbtype - dbname - host - port - ;; others (may include :user and :password) - ;; ---------- - ;; Raw: - connection-uri - ;; others (may include :user and :password) - ;; ---------- - ;; DriverManager (alternative / legacy style): - subprotocol - subname - ;; ---------- - ;; Others: - user - password - classpath - separator - ;; ---------- - ;; Optional: - classname) - "Add new connection configuration named CONNECTION-NAME. -It adds new connection to `ejc-connections' list or replace existing with the -same CONNECTION-NAME. -For more details about parameters see `get-connection' function in jdbc.clj: -`https://github.com/clojure/java.jdbc/blob/master/src/main/clojure/clojure/java/jdbc.clj'" - (setq ejc-connections - (-remove (lambda (x) (equal (car x) connection-name)) - ejc-connections)) - (setq ejc-connections - (cons (cons - connection-name - (let ((new-connection nil)) - (-map (lambda (arg) - (if (cdr arg) - (setq new-connection - (cons arg new-connection)))) - (list - (cons :dbtype dbtype) - (cons :dbname dbname) - (cons :host host) - (cons :port port) - (cons :connection-uri connection-uri) - (cons :subprotocol subprotocol) - (cons :subname subname) - (cons :user user) - (cons :password password) - (cons :classpath (file-truename classpath)) - (cons :separator separator) - (cons :classname classname))) - new-connection)) - ejc-connections))) - -(defun ejc-find-connection (connection-name) - "Return pair with name CONNECTION-NAME and db connection structure from -`ejc-connections'." - (-find (lambda (x) (equal (car x) connection-name)) - ejc-connections)) - -(defvar ejc-product-assoc - '((sqlserver . ms) - (oracle:sid . oracle))) - -(defun ejc-configure-sql-buffer (product-name) - (unless (or (derived-mode-p 'org-mode) (org-src-edit-buffer-p)) - (sql-mode)) - (sql-set-product (or (cdr (assoc-string product-name ejc-product-assoc)) - (car (assoc-string product-name sql-product-alist)) - "ansi")) - (auto-complete-mode t) - (auto-fill-mode t) - (unless (derived-mode-p 'org-mode) - (ejc-sql-mode t))) - -(defun ejc-load-conn-statistics () - "Load connection usage statistics to `ejc-conn-statistics' var." - (condition-case nil - (let ((dir (file-name-directory ejc-conn-statistics-file))) - (if (not (file-accessible-directory-p dir)) - (make-directory dir)) - (load-file ejc-conn-statistics-file)) - (error - (with-temp-file ejc-conn-statistics-file - (insert "(setq ejc-conn-statistics (list))")) - (load-file ejc-conn-statistics-file))) - ejc-conn-statistics) - -(defun ejc-update-conn-statistics (connection-name) - "Update connection usage statistics, persist it in `ejc-conn-statistics-file'" - (setq ejc-conn-statistics - (lax-plist-put - ejc-conn-statistics - connection-name - (1+ (or (lax-plist-get ejc-conn-statistics connection-name) 0)))) - (with-temp-file ejc-conn-statistics-file - (insert "(setq ejc-conn-statistics '") - (prin1 ejc-conn-statistics (current-buffer)) - (insert ")"))) - -(defun ejc-set-mode-name (connection-name) - "Show CONNECTION-NAME as part of `mode-name' in `mode-line'." - (setq mode-name (format "%s->[%s]" - (car (split-string mode-name "->\\[.+\\]")) - connection-name))) - -(defun ejc-add-connection (product-name connection-name db) - "Add ejc connection information to current buffer. -Prepare buffer to operate as `ejc-sql-mode' buffer." - (ejc-configure-sql-buffer product-name) - (setq-local ejc-connection-name connection-name) - (setq-local ejc-db db) - (ejc-set-mode-name connection-name)) - -(defun ejc-get-result-file-path () - (or ejc-result-file-path - (setq ejc-result-file-path - (ejc--get-result-file-path)))) - -(defun ejc-eval-org-snippet (body params) - "Used to eval SQL code in `org-mode' code snippets." - (let* ((beg (save-excursion - (goto-char (nth 5 (org-babel-get-src-block-info))) - (end-of-line) - (right-char 1) - (point))) - (end (save-excursion - (goto-char beg) - (+ beg (length body) (skip-chars-forward "\t "))))) - (ejc-eval-user-sql-at-point - :beg beg - :end end - :sync ejc-org-mode-show-results - :display-result (not ejc-org-mode-show-results)) - (if ejc-org-mode-show-results - (with-temp-buffer - (insert-file-contents (ejc-get-result-file-path)) - (buffer-string))))) - -(defun ejc-get-product-name (db) - (or (alist-get :subprotocol db) - (alist-get :dbtype db))) - -(defun ejc-org-edit-special (orig-fun &rest args) - (if (and (equal "sql" (car (org-babel-get-src-block-info))) - (boundp 'ejc-db) ejc-db - (boundp 'ejc-connection-name) ejc-connection-name) - (let* ((db ejc-db) - (connection-name ejc-connection-name) - (product-name (ejc-get-product-name db))) - (apply orig-fun args) - (ejc-add-connection product-name connection-name db)) - (apply orig-fun args))) - -;;;###autoload -(defun ejc-connect (connection-name) - "Connect to selected db." - (interactive - (list - (ido-completing-read - "DataBase connection name: " - (let ((conn-list (mapcar 'car ejc-connections)) - (conn-statistics (ejc-load-conn-statistics))) - (-sort (lambda (c1 c2) - (> (or (lax-plist-get conn-statistics c1) 0) - (or (lax-plist-get conn-statistics c2) 0))) - conn-list))))) - (let* ((db (cdr (ejc-find-connection connection-name))) - (product-name (ejc-get-product-name db))) - (ejc-update-conn-statistics connection-name) - (ejc-configure-sql-buffer product-name) - (when (derived-mode-p 'org-mode) - (defalias 'org-babel-execute:sql 'ejc-eval-org-snippet) - (advice-add 'org-edit-special :around #'ejc-org-edit-special)) - (setq-local ejc-connection-name connection-name) - (setq-local ejc-db db) - (message "Connection started...") - (ejc-connect-to-db db) - (when (ejc-validate-connection :db ejc-db - :timeout ejc-connection-validate-timeout) - (ejc-set-mode-name connection-name) - (message "Connected.")))) - -;;;###autoload -(defun ejc-connect-existing-repl () - "Connect to existing ejc-sql nREPL running process. -You can `cd` to your ejc-sql project folder (typically -'~/.emacs.d/elpa/ejc-sql-') and launch nREPL via `lein repl`. -Then run in Emacs `ejc-connect-existing-repl', type HOST and PORT -from your `lein run` console output. Finally, use `ejc-connect' from -any SQL buffer to connect to exact database, as always. " - (interactive) - (let* ((params (cider-select-endpoint)) - (host (car params)) - (port (cdr params)) - (current-repl-b-name (cider-connect (list :host host :port port))) - (ejc-repl-b-name (nrepl-repl-buffer-name - (list - :session-name "ejc-sql" - :repl-type "clj" - :host host - :port port)))) - (with-current-buffer current-repl-b-name - (rename-buffer ejc-repl-b-name)))) - -(defun ejc-get-word-at-point (pos) - "Return SQL word around the point." - (interactive "d") - (let* ((char (char-after pos)) - (str (char-to-string char))) - (save-excursion - (let* ((end (if (member str '(" " ")" "<" ">" "=")) - (point) - (progn - (forward-sexp 1) - (point)))) - (beg (progn - (forward-sexp -1) - (point))) - (sql-word (buffer-substring beg end))) - sql-word)))) - -(defun ejc-get-prompt-symbol-under-point (msg) - (let ((sql-symbol (if mark-active - (buffer-substring (mark) (point)) - (ejc-get-word-at-point (point)))) - (enable-recursive-minibuffers t) - val) - (setq val (completing-read - (if sql-symbol - (format "%s (default %s): " msg sql-symbol) - (format "%s: " msg)) - obarray)) - (list (if (equal val "") - sql-symbol - val)))) - -(defun ejc-check-connection () - (unless (ejc-buffer-connected-p) - (error "Run M-x ejc-connect first!"))) - -(cl-defun ejc-eval-sql-and-log (db - sql - &key - start-time - rows-limit - append - sync - display-result) - (when sql - (spinner-start 'rotating-line) - (setq ejc-current-buffer-query (current-buffer)) - (let* ((prepared-sql (ejc-get-sql-from-string sql))) - (ejc--eval-sql-and-log-print - db - prepared-sql - :start-time start-time - :rows-limit rows-limit - :append append - :sync sync - :display-result display-result)))) - -(defun ejc-message-query-done (start-time result) - (message - "%s SQL query at %s. Exec time %.03f" - (case result - (:done (propertize "Done" 'face 'font-lock-keyword-face)) - (:error (propertize "Error" 'face 'error)) - (:terminated (propertize "Terminated" 'face 'font-lock-keyword-face))) - (format-time-string ejc-date-output-format - (current-time)) - (float-time (time-since start-time)))) - -(defun ejc-spinner-stop () - "Stop spinner indicating current running query." - (with-current-buffer ejc-current-buffer-query - (spinner-stop))) - -(cl-defun ejc-complete-query (result-file-path - &key - start-time - result - display-result) - (if result-file-path - (setq ejc-result-file-path result-file-path)) - (ejc-spinner-stop) - (if display-result - (ejc-show-last-result)) - (if (and start-time result) - (ejc-message-query-done start-time result)) - nil) - -(cl-defun ejc-cancel-query (&key start-time) - "Terminate current (long) running query. Aimed to cancel SELECT queries. -Unsafe for INSERT/UPDATE/CREATE/ALTER queries." - (interactive) - (if (and (clomacs-get-connection "ejc-sql") - (ejc--is-query-running-p)) - (let ((start-time (ejc--cancel-query))) - (ejc-spinner-stop) - (ejc-message-query-done start-time :terminated)) - (keyboard-quit))) - -(defun ejc-describe-table (table-name) - "Describe SQL table TABLE-NAME (default table name - word around the point)." - (interactive (ejc-get-prompt-symbol-under-point "Describe table")) - (ejc-check-connection) - (let* ((owner (car (split-string table-name "\\."))) - (table (cadr (split-string table-name "\\.")))) - (when (not table) - (setq table owner) - (setq owner nil)) - (ejc-get-table-meta ejc-db table-name) - (let ((sql (ejc-select-db-meta-script ejc-db :constraints - :owner owner - :table table))) - (when (ejc-not-nil-str sql) - (ejc-write-result-file (concat "\n" - "Constraints:\n" - "------------\n") - :append t) - (ejc-eval-sql-and-log ejc-db sql :append t))))) - -(defun ejc-describe-entity (entity-name) - "Describe SQL entity ENTITY-NAME - function, procedure, type or view - (default entity name - word around the point)." - (interactive (ejc-get-prompt-symbol-under-point "Describe entity")) - (ejc-check-connection) - (ejc-show-last-result - (let ((entity-result - ;; Try to get entity source code. - (ejc-eval-sql-and-log - ejc-db - (ejc-select-db-meta-script ejc-db :entity - :entity-name entity-name)))) - (if (not (equal entity-result "nil")) - ;; Show entity text. - ;; Assume there is no entity and view with the same names. - entity-result - ;; No entity with such name. - ;; Try to get view source code. - (ejc-eval-sql-and-log - ejc-db - (ejc-select-db-meta-script ejc-db :view - :entity-name entity-name)))))) - -(cl-defun ejc-eval-user-sql (sql &key rows-limit sync display-result) - "Evaluate SQL by user: reload and show query results buffer, update log." - (message "Processing SQL query...") - (ejc-eval-sql-and-log ejc-db - sql - :rows-limit rows-limit - :start-time (current-time) - :sync sync - :display-result display-result)) - -(defun ejc-eval-user-sql-region (beg end) - "Evaluate SQL bounded by the selection area." - (interactive "r") - (ejc-check-connection) - (let ((sql (buffer-substring beg end))) - (ejc-eval-user-sql sql))) - -(cl-defun ejc-eval-user-sql-at-point (&key - sync - beg - end - (display-result t)) - "Evaluate SQL bounded by the `ejc-sql-separator' or/and buffer -boundaries." - (interactive) - (ejc-check-connection) - (ejc-flash-this-sql :beg beg - :end end) - (ejc-eval-user-sql (ejc-get-sql-at-point :beg beg :end end) - :sync sync - :display-result display-result)) - -(defun ejc-show-tables-list () - "Output tables list." - (interactive) - (ejc-check-connection) - (ejc-eval-user-sql - (ejc-select-db-meta-script ejc-db :all-tables) - :rows-limit 0 - :display-result t)) - -(defun ejc-show-user-types-list (&optional owner) - "Output user types list." - (interactive) - (ejc-check-connection) - (ejc-eval-user-sql (ejc-select-db-meta-script ejc-db :types - :owner owner))) - -(defun ejc-show-constraints-list (&optional owner table) - "Output constraints list." - (interactive) - (ejc-check-connection) - (ejc-eval-user-sql (ejc-select-db-meta-script ejc-db :constraints - :owner owner - :table table))) - -(defun ejc-show-procedures-list (&optional owner) - "Output procedures list." - (interactive) - (ejc-eval-user-sql (ejc-select-db-meta-script ejc-db :procedures - :owner owner))) - -;;----------------------------------------------------------------------------- -;; results buffer -;; -(defun ejc-create-output-buffer () - (set-buffer (get-buffer-create ejc-results-buffer-name)) - (setq ejc-results-buffer (current-buffer)) - (ejc-result-mode) - ejc-results-buffer) - -(defun ejc-get-buffer-or-create (buffer-or-name create-buffer-fn) - "Return buffer passed in `buffer-or-name' parameter. -If this buffer is not exists or it was killed - create buffer via -`create-buffer-fn' function (this function must return buffer)." - (let ((buf (if (bufferp buffer-or-name) - buffer-or-name - (get-buffer buffer-or-name)))) - (if (and buf (buffer-live-p buf)) - buf - (apply create-buffer-fn nil)))) - -(defun ejc-get-output-buffer () - (if (and ejc-results-buffer (buffer-live-p ejc-results-buffer)) - ejc-results-buffer - (ejc-create-output-buffer))) - -(cl-defun ejc-show-last-result (&optional result) - "Popup buffer with last SQL execution result output." - (interactive) - (let ((output-buffer (ejc-get-output-buffer)) - (old-split split-width-threshold)) - (set-buffer output-buffer) - (read-only-mode -1) - (erase-buffer) - (if result - (insert result) - (insert-file-contents (ejc-get-result-file-path))) - (read-only-mode 1) - (beginning-of-buffer) - (setq split-width-threshold nil) - (display-buffer output-buffer) - (setq split-width-threshold old-split))) - -(defun ejc-switch-to-sql-editor-buffer () - "Switch to buffer dedicated to ad-hoc edit and SQL scripts. -If the buffer is not exists - create it. -Buffer can be saved to file with `ejc-temp-editor-file' path." - (interactive) - (if (get-buffer ejc-temp-editor-buffer-name) - (switch-to-buffer ejc-temp-editor-buffer-name) - (progn - (unless (file-exists-p - (file-name-directory ejc-temp-editor-file)) - (make-directory (file-name-directory ejc-temp-editor-file) t)) - (find-file ejc-temp-editor-file) - (rename-buffer ejc-temp-editor-buffer-name) - (ejc-configure-sql-buffer "ansi")))) - -(defun ejc-open-log () - (interactive) - (find-file-read-only (ejc-get-log-file-path)) - (end-of-buffer)) - -;;;###autoload -(defun ejc-version () - "Get the ejc-sql version as string." - (interactive) - (if (require 'pkg-info nil t) - (message "ejc-sql %s" (pkg-info-version-info 'ejc-sql)) - (error "Cannot determine version without package pkg-info"))) - -(provide 'ejc-sql) - -;;; ejc-sql.el ends here diff --git a/elpa/ejc-sql-20190121.1043/project.clj b/elpa/ejc-sql-20190121.1043/project.clj deleted file mode 100644 index b2115745..00000000 --- a/elpa/ejc-sql-20190121.1043/project.clj +++ /dev/null @@ -1,14 +0,0 @@ -(defproject ejc-sql "0.0.1-SNAPSHOT" - :description "Interact with database via java/clojure libs to run SQL/JPQL scripts" - :url "https://github.com/kostafey/ejc-sql" - :license {:name "GPL 2.0+" - :url "http://www.gnu.org/licenses/old-licenses/gpl-2.0.html"} - :dependencies [[org.clojure/clojure "1.9.0"] - [org.clojure/clojure-contrib "1.2.0"] - [org.clojars.kostafey/java.jdbc "0.7.9-SNAPSHOT"] - [org.apache.openjpa/openjpa-all "2.2.2"] - [org.hibernate/hibernate-core "5.2.3.Final"] - [com.cemerick/pomegranate "0.3.0"] - [org.apache.commons/commons-lang3 "3.2.1"] - [org.apache.httpcomponents/httpclient "4.5.5"] - [clomacs "0.0.3-SNAPSHOT"]]) diff --git a/elpa/ejc-sql-20190121.1043/snippets/sql-mode/begin.snippet b/elpa/ejc-sql-20190121.1043/snippets/sql-mode/begin.snippet deleted file mode 100644 index 346dff8b..00000000 --- a/elpa/ejc-sql-20190121.1043/snippets/sql-mode/begin.snippet +++ /dev/null @@ -1,7 +0,0 @@ -# -*- mode: snippet -*- -# name: begin -# key: begin -# -- -BEGIN - $0 -END; \ No newline at end of file diff --git a/elpa/ejc-sql-20190121.1043/snippets/sql-mode/delete.yasnippet b/elpa/ejc-sql-20190121.1043/snippets/sql-mode/delete.yasnippet deleted file mode 100644 index 27cc2af9..00000000 --- a/elpa/ejc-sql-20190121.1043/snippets/sql-mode/delete.yasnippet +++ /dev/null @@ -1,5 +0,0 @@ -# -*- mode: snippet -*- -# name: delete -# key: delete -# -- -DELETE FROM ${1:table_name} WHERE ${2:where_stmt} \ No newline at end of file diff --git a/elpa/ejc-sql-20190121.1043/snippets/sql-mode/insert.yasnippet b/elpa/ejc-sql-20190121.1043/snippets/sql-mode/insert.yasnippet deleted file mode 100644 index b38c3ebb..00000000 --- a/elpa/ejc-sql-20190121.1043/snippets/sql-mode/insert.yasnippet +++ /dev/null @@ -1,6 +0,0 @@ -# -*- mode: snippet -*- -# name: insert -# key: insert -# -- -INSERT INTO ${1:table_name} (${2:column1}, ${3:column2}) -VALUES ($0value1, value2) \ No newline at end of file diff --git a/elpa/ejc-sql-20190121.1043/snippets/sql-mode/select.yasnippet b/elpa/ejc-sql-20190121.1043/snippets/sql-mode/select.yasnippet deleted file mode 100644 index 4e5fe935..00000000 --- a/elpa/ejc-sql-20190121.1043/snippets/sql-mode/select.yasnippet +++ /dev/null @@ -1,7 +0,0 @@ -# -*- mode: snippet -*- -# name: select -# key: select -# -- -SELECT `(if (eq sql-product 'sqlserver) "first 20 ")`* -FROM ${1:table_name} -WHERE `(if (eq sql-product 'oracle) "rownum < 20\n AND ")`${2:where_stmt} \ No newline at end of file diff --git a/elpa/ejc-sql-20190121.1043/snippets/sql-mode/update.yasnippet b/elpa/ejc-sql-20190121.1043/snippets/sql-mode/update.yasnippet deleted file mode 100644 index 5f15e73f..00000000 --- a/elpa/ejc-sql-20190121.1043/snippets/sql-mode/update.yasnippet +++ /dev/null @@ -1,7 +0,0 @@ -# -*- mode: snippet -*- -# name: update -# key: update -# -- -UPDATE ${1:table_name} -SET ${2:column1} = ${3:value}, ${4:column2} = ${5:value} -WHERE ${6:some_column} = ${7:some_value} \ No newline at end of file diff --git a/elpa/ejc-sql-20190121.1043/snippets/sql-mode/where.yasnippet b/elpa/ejc-sql-20190121.1043/snippets/sql-mode/where.yasnippet deleted file mode 100644 index 13d87f2f..00000000 --- a/elpa/ejc-sql-20190121.1043/snippets/sql-mode/where.yasnippet +++ /dev/null @@ -1,5 +0,0 @@ -# -*- mode: snippet -*- -# name: where -# key: where -# -- -WHERE `(if (eq sql-product 'oracle) "rownum < 20\n AND ")`${2:where_stmt} \ No newline at end of file diff --git a/elpa/ejc-sql-20190121.1043/src/ejc_sql/connect.clj b/elpa/ejc-sql-20190121.1043/src/ejc_sql/connect.clj deleted file mode 100644 index e8ba755e..00000000 --- a/elpa/ejc-sql-20190121.1043/src/ejc_sql/connect.clj +++ /dev/null @@ -1,285 +0,0 @@ -;;; connect.clj -- Core clojure functions for ejc-sql emacs extension. - -;;; Copyright © 2013-2018 - Kostafey - -;;; This program is free software; you can redistribute it and/or modify -;;; it under the terms of the GNU General Public License as published by -;;; the Free Software Foundation; either version 2, or (at your option) -;;; any later version. -;;; -;;; This program is distributed in the hope that it will be useful, -;;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;;; GNU General Public License for more details. -;;; -;;; You should have received a copy of the GNU General Public License -;;; along with this program; if not, write to the Free Software Foundation, -;;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - -(ns ejc-sql.connect - (:use [clojure.java.io] - [ejc-sql.lib] - [clomacs]) - (:require [clojure.java.jdbc :as j] - [clojure.contrib.java-utils] - [clojure.string :as s] - [ejc-sql.output :as o]) - (:import [java.sql Connection - DriverManager - PreparedStatement - ResultSet - SQLException] - [java.io File])) - -(def db - "DataBase connection properties list from the last transaction. -For debug purpose." - (atom nil)) - -(def current-query - "Current running query data." - (atom {})) - -(defn set-db [ejc-db] - (reset! db ejc-db)) - -(defn clean-sql [sql] - (-> sql - (s/replace #"(--).*\n" "") - (s/replace #"( )|( \t)|\t" " ") - (s/replace "^\n" "") - trim)) - -(def dml-set - #{"SELECT" - "INSERT" - "UPDATE" - "DELETE"}) - -(def ignore-set #{\( \[}) - -(defn determine-dml [sql] - "Determine if current SQL is Data Manipulation Language (DML) case." - (let [sql (clean-sql sql) - pos (loop [pos 0] - (if (ignore-set (get sql pos)) - (recur (inc pos)) - pos))] - (or - (dml-set (.toUpperCase (subs sql pos (+ 6 pos)))) - (#{"SHOW"} (.toUpperCase (subs sql pos (+ 4 pos))))))) - -(defn handle-special-cases [db sql] - (case (:subprotocol db) - "oracle" (case (clojure.string/upper-case sql) - "SHOW ERRORS" (str "SELECT line, position, sequence, text - FROM all_errors - WHERE type = 'FUNCTION' - AND name = 'FILTERDICT' - AND attribute != 'WARNING' - AND owner = '" (:user db) "' - ORDER BY line, position, sequence") - sql) - sql)) - -(defn clob-to-string [clob] - "Turn an Oracle Clob into a String" - (with-open [rdr (java.io.BufferedReader. (.getCharacterStream clob))] - (apply str (line-seq rdr)))) - -(defn is-clob? [x] - (or (instance? java.sql.Clob x) - (and (class-exists? 'oracle.sql.CLOB) - (instance? (Class/forName "oracle.sql.CLOB") x)))) - -(defn clob-to-string-row [row] - "Check all data in row if it's a CLOB and convert CLOB to string." - (loop [acc {} - rest-keys (keys row)] - (if rest-keys - (let [k (first rest-keys) - v (row k)] - (recur (assoc acc k (if (is-clob? v) - (clob-to-string v) - v)) - (next rest-keys))) - acc))) - -(defn is-query-running? [] - (let [stmt (:stmt @current-query)] - (and (not (nil? stmt)) - (not (.isClosed stmt))))) - -(defn cancel-query [] - "Terminate current (long) running query. Aimed to cancel SELECT queries. -Unsafe for INSERT/UPDATE/CREATE/ALTER queries." - (future - (if (is-query-running?) - (let [conn (:conn @current-query) - runner (:runner @current-query)] - (try - (.rollback conn) - (finally - (.close conn))) - (if (and - (not (nil? runner)) - (not (future-done? runner)) - (not (future-cancelled? runner))) - (future-cancel runner))))) - (:start-time @current-query)) - -(defn validate-connection [& {:keys [db timeout] - :or {db @ejc-sql.connect/db - timeout 5}}] - (.isValid (j/get-connection db) timeout)) - -(defn get-separator-re [separator] - "Handle cases where separator is a part of string in SQL query. -E.g. you can use default separator char `/` in this query: -SELECT * FROM urls WHERE path like '%http://localhost%'" - (String/format - "%s(? result rest flatten) - result))) - -(defn query-meta [db sql] - "Get metadata for `sql` result dataset." - (try - {:success true - :result (j/db-query-with-resultset - db - [(str "SELECT nodata.* " - "FROM (" sql ") nodata " - "WHERE 0 = 1")] - (fn [rs] - (let [rs-meta (.getMetaData rs) - col-count (.getColumnCount rs-meta)] - (mapv (fn [i] - {:name (.getColumnLabel rs-meta i) - :type (.getColumnTypeName rs-meta i)}) - (range 1 (+ 1 col-count))))))} - (catch SQLException e - {:success false - :result (str "Error: " (.getMessage e))}))) - -(defn table-meta - [db table-name] - (set-db db) - (query-meta db (str "SELECT * FROM " table-name))) - -(defn get-table-meta - "Describe table." - [db table-name] - (let [result-map (table-meta db table-name) - success (:success result-map) - result-data (:result result-map) - head (str "Table \"" table-name "\" description:\n") - head-length (dec (.length head))] - (complete-query - (o/write-result-file - (if success - (str head - (ejc-sql.lib/simple-join head-length "-") "\n" - (o/print-table result-data)) - result-data)) - :display-result true))) diff --git a/elpa/ejc-sql-20190121.1043/src/ejc_sql/jpa.clj b/elpa/ejc-sql-20190121.1043/src/ejc_sql/jpa.clj deleted file mode 100644 index f7ce3eba..00000000 --- a/elpa/ejc-sql-20190121.1043/src/ejc_sql/jpa.clj +++ /dev/null @@ -1,48 +0,0 @@ -(ns ejc-sql.jpa - (:require [cemerick.pomegranate :as pom]) - (:use [clojure.java.io] - [ejc-sql.lib] - [ejc-sql.output]) - (:import [javax.persistence Persistence - EntityManager - TypedQuery] - [org.apache.commons.lang3.builder - ReflectionToStringBuilder - ToStringStyle])) - -(def em) - -(defn connect [{:keys [connection-name - persistent-xml-url - domain-objects-url - jdbc-driver-url]}] - (pom/add-classpath persistent-xml-url) - (pom/add-classpath domain-objects-url) - (pom/add-classpath jdbc-driver-url) - (def em (-> (Persistence/createEntityManagerFactory connection-name) - (.createEntityManager)))) - -(defn connect-plain [connection-name - persistent-xml-url - domain-objects-url - jdbc-driver-url] - (connect - {:connection-name connection-name - :persistent-xml-url persistent-xml-url - :domain-objects-url domain-objects-url - :jdbc-driver-url jdbc-driver-url})) - -(defn eval-jpql [jpql] - (-> em (.createQuery jpql) (.getResultList) (.toArray))) - -(defn row-to-str [row] - (if (not (array? row)) - (ReflectionToStringBuilder/toString - row ToStringStyle/SHORT_PREFIX_STYLE) - (list (str row)))) - -(defn eval-jpql-print [jpql] - (print - (format-output (map row-to-str (eval-jpql jpql)) - :as-arrays? true, :add-headers? false))) - diff --git a/elpa/ejc-sql-20190121.1043/src/ejc_sql/lib.clj b/elpa/ejc-sql-20190121.1043/src/ejc_sql/lib.clj deleted file mode 100644 index d0cd8dbb..00000000 --- a/elpa/ejc-sql-20190121.1043/src/ejc_sql/lib.clj +++ /dev/null @@ -1,91 +0,0 @@ -;;; lib.clj -- Misc clojure functions for ejc-sql emacs extension. - -;;; Copyright © 2013-2017 - Kostafey - -;;; This program is free software; you can redistribute it and/or modify -;;; it under the terms of the GNU General Public License as published by -;;; the Free Software Foundation; either version 2, or (at your option) -;;; any later version. -;;; -;;; This program is distributed in the hope that it will be useful, -;;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;;; GNU General Public License for more details. -;;; -;;; You should have received a copy of the GNU General Public License -;;; along with this program; if not, write to the Free Software Foundation, -;;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - -(ns ejc-sql.lib - (:import (java.io File)) - (:require [clojure.string :as s] - [clojure.reflect :refer [resolve-class]])) - -(def windows? - "The value is true if it runs under the os Windows." - (>= 0 (.indexOf (System/getProperty "os.name") "Windows"))) - -(defn in? - "true if `seq` contains `elm`. - Search case insensitive wthen `case-sensitive` is false." - [seq elm & {:keys [case-sensitive] :or {case-sensitive true}}] - (if (and elm seq) - (if (not case-sensitive) - (in? (mapv s/lower-case seq) (s/lower-case elm)) - (some #(= elm %) seq)))) - -(defn get->in [obj path & {:keys [case-sensitive] :or {case-sensitive false}}] - "Case insensitive `get-in` for last key in sequence." - (if case-sensitive - (get-in obj path) - (get-in obj - (conj (into [] (butlast path)) - (last path)) - (get-in obj - (conj (into [] (butlast path)) - (s/upper-case (last path))) - (get-in obj - (conj (into [] (butlast path)) - (s/lower-case (last path)))))))) - -(defn array? [x] - (-> x .getClass .isArray)) - -(defn trim [s] - (if (instance? java.lang.String s) - (.trim s) - s)) - -(defn filter-data [rs] - (map #(map trim %) rs)) - -(defn get-rs-data [rs] - (map vals rs)) - -(defn get-rs-headers [rs] - (for [[k _] (first rs)] - (subs (str k) 1))) - -(defn transpose [m] - (apply mapv vector m)) - -(defn find-longest-list - "Returns the list of the longest lengths per column." - [lst] - (map #(apply max %) (transpose lst))) - -(defn simple-join [n s] - (clojure.string/join - (for [x (range 0 n)] s))) - -(defn str-length [s] - (.length (str s))) - -(defn get-rs-lengths [rs] - (map #(map str-length %) rs)) - -(defn get-absolute-file-path [relative-file-path] - (-> (java.io.File. relative-file-path) .getAbsolutePath)) - -(defn class-exists? [c] - (resolve-class (.getContextClassLoader (Thread/currentThread)) c)) diff --git a/elpa/ejc-sql-20190121.1043/src/ejc_sql/output.clj b/elpa/ejc-sql-20190121.1043/src/ejc_sql/output.clj deleted file mode 100644 index 1ade3ae4..00000000 --- a/elpa/ejc-sql-20190121.1043/src/ejc_sql/output.clj +++ /dev/null @@ -1,170 +0,0 @@ -;;; output.clj -- Output & formatting clojure functions for ejc-sql. - -;;; Copyright © 2013, 2016 - Kostafey - -;;; This program is free software; you can redistribute it and/or modify -;;; it under the terms of the GNU General Public License as published by -;;; the Free Software Foundation; either version 2, or (at your option) -;;; any later version. -;;; -;;; This program is distributed in the hope that it will be useful, -;;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;;; GNU General Public License for more details. -;;; -;;; You should have received a copy of the GNU General Public License -;;; along with this program; if not, write to the Free Software Foundation, -;;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - -(ns ejc-sql.output - (:use clojure.java.io - ejc-sql.lib) - (:require clojure.contrib.java-utils - [clojure.string :as s]) - (:import (java.io File) - (java.lang.reflect Method) - (java.util.Date) - (java.text.SimpleDateFormat) - (org.apache.openjpa.lib.jdbc SQLFormatter) - (org.hibernate.engine.jdbc.internal BasicFormatterImpl))) - -(def result-file-name - "SQL evaluation results file name." - "ejc-sql-result.txt") - -(defn get-result-file-path [] - (s/replace - (.getAbsolutePath - (File. - (File. (System/getProperty "java.io.tmpdir")) - result-file-name)) - #"\\" "/")) - -(defn get-log-dir [] - (file (if windows? - (System/getenv "AppData") - "/var/log/") - "ejc-sql")) - -(defn get-log-file [] - (file (get-log-dir) - (str (.format (new java.text.SimpleDateFormat - "yyyy-MM-dd") - (new java.util.Date)) ".log"))) - -(defn print-log-file-path [] - (print (.getAbsolutePath (get-log-file)))) - -(defn log-sql [sql] - (let [log-file (get-log-file) - is-new-file (not (.exists log-file))] - (when is-new-file - (.mkdirs (File. (.getParent log-file))) - (.createNewFile log-file)) - (with-open [wrtr (clojure.java.io/writer log-file :append true)] - (if is-new-file - (.write wrtr (str "-- -*- mode: sql; -*-\n" - "-- Local Variables:\n" - "-- eval: (ejc-sql-mode)\n" - "-- End:\n"))) - (.write wrtr (str (simple-join 50 "-") " " - (.format (new java.text.SimpleDateFormat - "yyyy.MM.dd HH:mm:ss.S") - (new java.util.Date)) - " " (simple-join 2 "-") "\n" sql "\n"))))) - -(def rows-limit - "Limit number of records to output." - (atom 1000)) - -(defn set-rows-limit [val] - "Set limit for number of records to output. When nil no limit." - (reset! rows-limit val)) - -(defn fmap [f m] - (reduce (fn [altered-map [k v]] (assoc altered-map k (f v))) {} m)) - -(defn rotate-table [data] - "Rotate result set to show fields list vertically. -Applied to single-record result set. -E.g. transtofm from: a | b | c into: a | 1 - --+---+-- b | 2 - 1 | 2 | 3 c | 3" - (let [first-row (first data) - keys (map #(if (keyword? %) (name %) (str %)) - (first first-row)) - values (rest first-row)] - (into [] (map - (fn [v] - (into {} - (map #(identity - [%1 (if (keyword? %2) (name %2) %2)]) - keys v))) - values)))) - -(defn print-table - "Prints a collection of maps in a textual table. Prints table headings - ks, and then a line of output for each row, corresponding to the keys - in ks. If ks are not specified, use the keys of the first item in rows." - ([ks rows limit] - (when (seq rows) - (let [row-limit (or limit @rows-limit) - [rows msg] (if (and row-limit - (> row-limit 0) - (> (count rows) row-limit)) - [(take row-limit rows) - (format "Too many rows. Only %s from %s is shown.\n\n" - row-limit (count rows))] - [rows ""]) - [rows ks rotated] (if (and (= (count rows) 1) - (> (count (first rows)) 1)) - (let [r (rotate-table rows)] - [r (keys (first r)) true]) - [rows ks false]) - rows (map (fn [row] - (fmap (fn [v] - (if (string? v) - (clojure.string/replace v "\n" " ") - v)) - row)) - rows) - widths (map - (fn [k] - (apply max (count (name k)) (map #(count (str (get % k))) rows))) - ks) - headers (map name ks) - spacers (map #(apply str (repeat % "-")) widths) - ;; TODO: #(str "%" % "d") for numbers - fmts (map #(str "%-" % "s") widths) - fmt-row (fn [leader divider trailer row] - (str leader - (apply str (interpose divider - (for [[col fmt] (map vector (map #(get row %) ks) fmts)] - (format fmt (str col))))) - trailer)) - result (new StringBuffer "") - ;; TODO: cahnge to #(println %) when async output ready - out #(.append result (str % "\n"))] - (out (fmt-row "" " | " "" (zipmap ks headers))) - (if (not rotated) - (out (fmt-row "" "-+-" "" (zipmap ks spacers)))) - (doseq [row rows] - (out (fmt-row "" " | " "" row))) - (str msg (.toString result))))) - ([rows limit] (print-table (keys (first rows)) rows limit)) - ([rows] (print-table (keys (first rows)) rows @rows-limit))) - -(defn pretty-print [sql formatter] - (if (= formatter :jpa) - (print (.prettyPrint (SQLFormatter.) sql)) - ;; :hibernate - (print (.format (BasicFormatterImpl.) sql)))) - -(defn write-result-file [text & {:keys [append] - :or {append false}}] - (let [result-file-path (get-result-file-path)] - (spit result-file-path text :append append) - result-file-path)) - -(defn clear-result-file [] - (write-result-file "")) diff --git a/elpa/ejc-sql-20190121.1043/src/ejc_sql/structure.clj b/elpa/ejc-sql-20190121.1043/src/ejc_sql/structure.clj deleted file mode 100644 index 79f7c512..00000000 --- a/elpa/ejc-sql-20190121.1043/src/ejc_sql/structure.clj +++ /dev/null @@ -1,556 +0,0 @@ -;;; structure.clj -- Receive database stucture and keep it in cache. - -;;; Copyright © 2016-2019 - Kostafey - -;;; This program is free software; you can redistribute it and/or modify -;;; it under the terms of the GNU General Public License as published by -;;; the Free Software Foundation; either version 2, or (at your option) -;;; any later version. -;;; -;;; This program is distributed in the hope that it will be useful, -;;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;;; GNU General Public License for more details. -;;; -;;; You should have received a copy of the GNU General Public License -;;; along with this program; if not, write to the Free Software Foundation, -;;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - -(ns ejc-sql.structure - (:use [ejc-sql.lib]) - (:require - [clojure.java.jdbc :as j] - [clojure.string :as s] - [ejc-sql.connect :as c])) - -(def cache (atom {})) - -(defn- db->column [db sql] - "Execute `sql`, return first column of result set as result list." - (if sql - (rest - (map first - (j/query db (list sql) {:as-arrays? true}))))) - -(defn- db->>column [db sql] - "Execute `sql`, return last column of result set as result list." - (if sql - (rest - (map last - (j/query db (list sql) {:as-arrays? true}))))) - -(defn- db->value [db sql] - "Execute `sql`, return first value of first column of result set as result." - (first (db->column db sql))) - -(defn get-ms-sql-server-version [db] - (-> - (filter not-empty - (.split - (db->value db "SELECT @@VERSION AS 'SQL Server Version'") - " ")) - (nth 3) - Integer/parseInt)) - -(def default-queries - {:owners (fn [& _] - (str " SELECT schema_owner \n" - " FROM information_schema.schemata \n")) - :schemas (fn [& _] - (str " SELECT schema_name \n" - " FROM information_schema.schemata \n")) - :tables (fn [& {:keys [schema]}] - (str " SELECT table_name \n" - " FROM information_schema.tables \n" - (if schema - (str " WHERE table_schema = '" schema "'") - "") - " ORDER BY table_name \n")) - :all-tables (fn [& _] - (str "SELECT s.schema_owner, s.schema_name, t.table_name \n" - "FROM information_schema.schemata AS s, \n" - " information_schema.tables AS t \n" - "WHERE t.table_schema = s.schema_name \n")) - :columns (fn [& {:keys [table]}] - (str " SELECT column_name \n" - " FROM information_schema.columns \n" - " WHERE table_name = '" table "' \n" - " ORDER BY column_name \n"))}) - -(def queries - { - ;;-------- - :oracle - ;;-------- - {:entity (fn [& {:keys [entity-name]}] - (str " SELECT text \n" - " FROM all_source \n" - " WHERE UPPER(name) = '" - (s/upper-case entity-name) "' \n")) - :view (fn [& {:keys [entity-name]}] - (str "SELECT text \n" - "FROM all_views \n" - "WHERE UPPER(view_name) = '" - (s/upper-case entity-name) "' \n")) - :types (fn [& _] "SELECT * FROM USER_TYPES") - :owners (fn [& _] (str " SELECT DISTINCT(owner) \n" - " FROM ALL_OBJECTS \n" - " ORDER BY owner \n")) - :tables (fn [& {:keys [owner]}] - (str " SELECT table_name, owner \n" - " FROM all_tables \n" - (if owner - (str " WHERE UPPER(owner) = '" - (s/upper-case owner)"'")) - " ORDER BY table_name")) - :all-tables (fn [& _] - (str " SELECT owner, table_name \n" - " FROM all_tables \n" - " WHERE owner NOT IN ('SYS', 'SYSTEM') \n" - " ORDER BY owner")) - :columns (fn [& {:keys [table]}] - (str " SELECT column_name \n" - " FROM ALL_TAB_COLUMNS \n" - " WHERE UPPER(table_name) = '" - (s/upper-case table)"'")) - :constraints (fn [& {:keys [owner table]}] - (cond - (and owner table) - (str " SELECT * FROM all_constraints \n" - " WHERE owner = "owner" \n" - " AND table_name = '"table"' \n") - table - (str " SELECT * FROM all_constraints \n" - " WHERE table_name = '"table"' \n") - :else - "SELECT * FROM user_constraints")) - :procedures (fn [& {:keys [owner]}] - (str " SELECT object_name, procedure_name \n" - " FROM all_procedures \n" - (if owner - (str " WHERE owner = '" owner "'") - ""))) - :objects (fn [& _] - (str "SELECT * FROM all_objects WHERE object_type IN " - "('FUNCTION','PROCEDURE','PACKAGE')"))} - ;;-------- - :informix - ;;-------- - {:owners nil - :tables (fn [& _] - (str " SELECT TRIM(t.tabname) as tablesList \n" - " FROM systables AS t \n" - " WHERE t.tabtype = 'T' \n" - " AND t.tabid >= 100 \n" - " ORDER BY t.tabname; \n")) - :columns (fn [& {:keys [table]}] - (str " SELECT TRIM(c.colname) AS column_name \n" - " FROM systables AS t, syscolumns AS c \n" - " WHERE t.tabid = c.tabid \n" - " AND t.tabtype = 'T' \n" - " AND t.tabid >= 100 \n" - " AND TRIM(t.tabname) = '" table "' \n" - " ORDER BY c.colno; \n"))} - ;;------- - :mysql - ;;------- - {:owners (fn [& _] - (str " SELECT schema_name \n" - " FROM information_schema.schemata \n")) - :tables (default-queries :tables) - :all-tables (fn [& _] - (str "SELECT s.schema_name, t.table_name \n" - "FROM information_schema.schemata AS s, \n" - " information_schema.tables AS t \n" - "WHERE t.table_schema = s.schema_name \n")) - :columns (default-queries :columns)} - ;;-------- - :h2 - ;;-------- - {:tables (fn [& _] ((default-queries :tables) :schema "PUBLIC")) - :all-tables (fn [& _] - (str "SELECT s.schema_owner, s.schema_name, t.table_name \n" - "FROM information_schema.schemata AS s, \n" - " information_schema.tables AS t \n" - "WHERE t.table_schema = s.schema_name \n" - " AND LCASE(s.schema_name) != 'information_schema' \n")) - :columns (default-queries :columns)} - ;;------- - :sqlserver ; ms sql server - ;;------- - {:owners (default-queries :owners) - :schemas (default-queries :schemas) - :tables (default-queries :tables) - :all-tables (default-queries :all-tables) - :columns (default-queries :columns) - :constraints (fn [& {:keys [table]}] - (str "SELECT type_desc AS constraint_type, \n" - " name \n" - "FROM sys.objects \n" - "WHERE type_desc LIKE '%CONSTRAINT' \n" - " AND OBJECT_NAME(parent_object_id)='" table "'")) - :entity (fn [& {:keys [db entity-name]}] - (if (> (get-ms-sql-server-version db) 2000) - (str - "SELECT definition \n" - "FROM sys.objects o \n" - "JOIN sys.sql_modules m ON m.object_id = o.object_id \n" - "WHERE o.object_id = object_id('" entity-name "') \n") - (str - "SELECT c.text \n" - "FROM sysobjects o \n" - "JOIN syscomments c ON c.id = o.id \n" - "WHERE o.name = '" entity-name "' \n")))} - ;;------- - :postgresql - ;;------- - {:owners (default-queries :owners) - :tables (default-queries :tables) - :all-tables (default-queries :all-tables) - :columns (default-queries :columns)}}) - -(defn autocomplete-available-for-db? [db-type] - (queries db-type)) - -(defn get-db-name [db] - (let [{:keys [database subname connection-uri dbname]} db] - (or dbname - database - (if subname - (let [separator (if (= (first (.split subname "/")) subname) - ":" "/") - raw-db-name (last (.split subname separator)) - raw-db-name (first (.split raw-db-name "\\?")) - raw-db-name (first (.split raw-db-name ";"))] - raw-db-name) - ;; No subname - parse connection-uri - (let [props-list (.split connection-uri ";") - db-name-prop (first - (filter - (fn [prop] - (= - "databasename" - (.toLowerCase (first (.split prop "="))))) - props-list))] - (if db-name-prop - ;; "databaseName=my_db_name;" - (second (.split db-name-prop "=")) - ;; "jdbc:jtds:sqlserver://localhost:1433/my_db_name;" - (last (.split (first props-list) "/")))))))) - -(defn get-user [db] - (or - (:user db) - (let [{:keys [user connection-uri]} db] - (or user - (second (.split - (let [props-list (.split connection-uri ";")] - (first - (filter - (fn [prop] - (= - "user" - (.toLowerCase (first (.split prop "="))))) - props-list))) "=")))))) - -(def product-assoc {"oracle:sid" "oracle"}) - -(defn get-db-type [db] - (let [{:keys [subprotocol connection-uri dbtype]} db - result (or dbtype - subprotocol - (let [attrs (.split connection-uri ":")] - (if (= (second attrs) "jtds") - ;; jdbc:jtds:sqlserver://... - (nth attrs 2) - ;; jdbc:sqlserver://localhost\instance:1433; - (second attrs))))] - (keyword (or (product-assoc result) result)))) - -(defn- get? [obj & [force?]] - (if (and obj (or force? (realized? obj))) - @obj)) - -(defn get-this-owner [db & [owner]] - "Return current owner/schema." - (or owner - (get? (get-in @cache [db :this-owner]) false) - (do - (swap! cache assoc-in [db :this-owner] - (future - ((fn [db] - (let [db-type (get-db-type db)] - (case db-type - :sqlserver (if (> (get-ms-sql-server-version db) 2000) - ;; Get default SQL Server schema for session - (db->value db "SELECT SCHEMA_NAME()") - "dbo") - :oracle (db->value - db - "SELECT sys_context('userenv', 'current_schema') FROM dual") - ;; By default - ;; Assume owner == schema (it can be wrong in general). - (get-user db)))) db))) - (get? (get-in @cache [db :this-owner]) true)))) - -(defn select-db-meta-script [db meta-type & - {:keys [owner - table - entity-name]}] - "Return SQL request to obtain some database structure info." - (let [db-type (get-db-type db) - meta-type (if (keyword? meta-type) meta-type (keyword meta-type)) - ;; owner (get-this-owner db owner) - sql-receiver (get-in queries [db-type meta-type]) - sql (if sql-receiver - (sql-receiver :db db - :owner owner - :schema owner - :table table - :entity-name entity-name - :db-name (get-db-name db)))] - sql)) - -(defn get-namespace [db] - "Find tables namespace for current database type. -Possible cases for namespace: -* schema is sutable (or both schema and owner) - for this DB type - use `:schemas` -* only owner is sutable, so use `:owners` -* none of them is sutable - `nil`" - (let [db-type (get-db-type db)] - (cond - (get-in queries [db-type :schemas]) :schemas - (get-in queries [db-type :owners]) :owners - :else nil))) - -(defn get-owners [db & [force?]] - "Return owners list from cache if already received from DB, -check if receiveing process is not running, then start it." - (let [namespace (get-namespace db)] - (if namespace - (do - (if (not (get-in @cache [db namespace])) - (swap! cache assoc-in [db namespace] - (future ((fn [db] - (let [sql (select-db-meta-script - db namespace)] - (sort (db->column db sql)))) db)))) - (get? (get-in @cache [db namespace]) force?)) - (list)))) - -(defn get-tables [db & [owner_ force?]] - "Return tables list for this owner from cache if already received from DB, -check if receiveing process is not running, then start it." - (let [owner (get-this-owner db owner_)] - (if (not (get->in @cache [db :tables owner])) - (swap! cache assoc-in [db :tables owner] - (future ((fn [db owner] - (let [sql (select-db-meta-script db :tables - :owner owner)] - (db->column db sql))) - db owner)))) - (if owner_ - (get? (get->in @cache [db :tables owner]) force?) - (do (if (not (get-in @cache [db :all-tables])) - (swap! cache assoc-in [db :all-tables] - (future ((fn [db] - (let [sql (select-db-meta-script - db :all-tables)] - (sort (db->>column db sql)))) - db)))) - (get? (get-in @cache [db :all-tables]) force?))))) - -(defn get-colomns [db table force?] - "Return colomns list for this table from cache if already received from DB, -check if receiveing process is not running, then start it." - (if (not (get->in @cache [db :colomns table])) - (swap! cache assoc-in [db :colomns table] - (future ((fn [db table] - (let [sql (select-db-meta-script db :columns - :table table)] - (sort (db->column db sql)))) - db table)))) - (get? (get->in @cache [db :colomns table]) - force?)) - -(defn is-owner? [db prefix] - (in? (get-owners db) prefix :case-sensitive false)) - -(defn autocomplete-loading [] - "Not loaded tables yet. Output pending db structure data..." - (list "t")) - -(defn autocomplete-result [result] - "Output autocomplete result." - (cons "nil" result)) - -(defn autocomplete-nothing [] - "Output autocomplete nothing." - (list "nil")) - -(defn get-owners-candidates [db sql prefix-1 & _] - "Return owners candidates autocomplete list from the database structure -cache, async request to fill it, if not yet. -The result list has the following structure: -(pending item1 item2 ...) -If `pending` is t - the async request to get the structure is running -if `pending` is nil - no request is running, return result immediately." - (let [owners (get-owners db)] - (if prefix-1 - ;; Assume schema|table.# is not applicable. - ;; So, return empty list. - (autocomplete-nothing) - (if owners - (autocomplete-result owners) - ;; pending owners... - (autocomplete-loading))))) - -(defn get-tables-candidates [db sql prefix-1 & _] - "Return tables candidates autocomplete list." - (let [tables (if (not prefix-1) - ;; something# - (get-tables db) - (if (is-owner? db prefix-1) - ;; [owner].# - (get-tables db prefix-1) - ;; owners still pending or - ;; unknown?.# case - (list)))] - (if tables - (autocomplete-result tables) - ;; pending tables... - (autocomplete-loading)))) - -(defn match-alias? [sql owner table probable-alias] - "Check if prefix (`probable-alias`) is alias for `table` in this `sql`." - (let [sql (s/lower-case sql) - owner (if owner - (str (s/lower-case owner) "\\.") - "\\s+(\\w+\\.)?") - table (s/lower-case table) - probable-alias (s/lower-case probable-alias) - alias-pattern (re-pattern - (str owner table "(\\s+as)?" - "\\s+" probable-alias))] - (not (nil? (re-find alias-pattern sql))))) - -(defn get-all-tables [db] - "Get all tables for all owners/schemas." - (flatten - (mapv #(get-tables db % true) - (get-owners db true)))) - -(def insert-re - (re-pattern (str "(?i)\\s*INSERT\\s+INTO\\s+(\\S+)\\s+"))) - -(defn insert-sql? [sql] - "If `sql` is INSERT query, return a table name used to insert new records. -Otherwise return nil." - (second (re-find insert-re sql))) - -(def update-re - (re-pattern (str "(?i)\\s*UPDATE\\s(\\S+)\\s+\n*SET.*"))) - -(defn update-sql? [sql] - "If `sql` is UPDATE query, return a table name used to modify the existing -records. Otherwise return nil." - (second (re-find update-re sql))) - -(defn get-colomns-candidates [db sql prefix-1 & [prefix-2]] - "Return colomns candidates autocomplete list." - ;; Possible cases: - ;; 1. [owner|schema.]table.# - ;; 2. SELECT alias.# FROM [owner|schema.]table AS alias - ;; 3. SELECT complex-alias.# FROM (SELECT...) AS complex-alias - ;; 4. INSERT INTO table (field1, .#) values (123, 'text') - ;; 5. UPDATE table SET field1 = 123, .# = 'text' WHERE id = 1 - ;; - ;; In any case, consider `prefix-1` as table or alias - ;; and optional `prefix-2` as owner or schema. - ;; When no any prefix at all, check for 4 (INSERT) or 5 (UPDATE) case. - (let [owner prefix-2 - tables-list (if owner - (get-tables db owner) - ;; In case of queries like - ;; "SELECT u.# FROM custom.Users as u" - ;; when "custom" is not the current - ;; schema, the full DB structure tree - ;; sould be built to obtain overall - ;; tables list for all owners/schemas. - (if (get-namespace db) - ;; Database has namespaces - (if (not (get-owners db)) - ;; Not received owners list yet - - ;; pending... - (do - (future (get-all-tables db)) - nil) - ;; Owners list is already here - - ;; force tables list receiving! - (get-all-tables db)) - ;; Database hasn't namespaces - - ;; no owners needed - (get-tables db)))] - (if (not (and tables-list - (not-empty (filter not-empty tables-list)))) - ;; no tables yet - ;; pending tables... - (autocomplete-loading) - ;; Tables list loaded: - (if (not prefix-1) - (let [insert-or-update-table (or (insert-sql? sql) - (update-sql? sql))] - (cond - (and (not-empty insert-or-update-table) - (in? tables-list insert-or-update-table - :case-sensitive false)) - ;; INSERT INTO table (field1, .#) values (123, 'text') - ;; or - ;; UPDATE table SET field1 = 123, .# = 'text' WHERE id = 1 - (autocomplete-result - (get-colomns db insert-or-update-table true)) - ;; SELECT or other queries types - :else (autocomplete-nothing))) - (if (in? tables-list prefix-1 :case-sensitive false) - ;; table.# - (let [table prefix-1 - ;; force columns-cache obtaining... - columns-list (get-colomns db table true)] - ;; ok - columns - (autocomplete-result columns-list)) - (let [sql (c/clean-sql sql) - table-alias (first - (filter - (fn [table] - (match-alias? sql owner table prefix-1)) - tables-list))] - (if table-alias - ;; table-alias.# - (autocomplete-result (get-colomns db table-alias true)) - ;; Check "SELECT t.# FROM (SELECT ... ) AS t" case. - (let [pattern (re-pattern (str "\\(.+\\)(\\s|\\s(as)\\s)" - prefix-1)) - complex-alias (first (re-find pattern sql)) - complex-alias (if complex-alias - (subs complex-alias 1 - (.lastIndexOf complex-alias ")")))] - (if complex-alias - (let [{:keys [success result]} (c/query-meta db complex-alias)] - (if success - ;; complex-alias.# - (autocomplete-result (mapv :name result)) - ;; Can't execute "blah blah" to get metadata in - ;; "SELECT t.# FROM (blah blah) AS t" case. - (autocomplete-nothing))) - ;; unknown?.# case - ;; nothing to complete - (autocomplete-nothing)))))))))) - -(defn get-cache [] - "Output actual cache." - @cache) - -(defn invalidate-cache [db] - "Clean your current connection cache (database owners and tables list)." - (swap! cache assoc-in [db] nil)) diff --git a/elpa/helm-20191031.839/emacs-helm.sh b/elpa/helm-20191101.641/emacs-helm.sh similarity index 100% rename from elpa/helm-20191031.839/emacs-helm.sh rename to elpa/helm-20191101.641/emacs-helm.sh diff --git a/elpa/helm-20191031.839/helm-adaptive.el b/elpa/helm-20191101.641/helm-adaptive.el similarity index 100% rename from elpa/helm-20191031.839/helm-adaptive.el rename to elpa/helm-20191101.641/helm-adaptive.el diff --git a/elpa/helm-20191031.839/helm-autoloads.el b/elpa/helm-20191101.641/helm-autoloads.el similarity index 81% rename from elpa/helm-20191031.839/helm-autoloads.el rename to elpa/helm-20191101.641/helm-autoloads.el index 490aaec7..200a923b 100644 --- a/elpa/helm-20191031.839/helm-autoloads.el +++ b/elpa/helm-20191101.641/helm-autoloads.el @@ -1,10 +1,12 @@ ;;; helm-autoloads.el --- automatically extracted autoloads ;; ;;; Code: -(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) + +(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path)))) + -;;;### (autoloads nil "helm-adaptive" "helm-adaptive.el" (23995 4638 -;;;;;; 436387 418000)) +;;;### (autoloads nil "helm-adaptive" "helm-adaptive.el" (0 0 0 0)) ;;; Generated autoloads from helm-adaptive.el (defvar helm-adaptive-mode nil "\ @@ -28,10 +30,11 @@ Useful when you have a old or corrupted `helm-adaptive-history-file'. \(fn)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-adaptive" '("helm-adapt"))) + ;;;*** -;;;### (autoloads nil "helm-bookmark" "helm-bookmark.el" (23995 4638 -;;;;;; 434400 192000)) +;;;### (autoloads nil "helm-bookmark" "helm-bookmark.el" (0 0 0 0)) ;;; Generated autoloads from helm-bookmark.el (autoload 'helm-bookmarks "helm-bookmark" "\ @@ -46,10 +49,11 @@ only if external addressbook-bookmark package is installed. \(fn)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-bookmark" '("helm-" "bmkext-jump-" "bookmark"))) + ;;;*** -;;;### (autoloads nil "helm-buffers" "helm-buffers.el" (23995 4638 -;;;;;; 464781 494000)) +;;;### (autoloads nil "helm-buffers" "helm-buffers.el" (0 0 0 0)) ;;; Generated autoloads from helm-buffers.el (autoload 'helm-buffers-list "helm-buffers" "\ @@ -62,10 +66,11 @@ Preconfigured `helm' displaying `helm-mini-default-sources'. \(fn)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-buffers" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-color" "helm-color.el" (23995 4638 472345 -;;;;;; 343000)) +;;;### (autoloads nil "helm-color" "helm-color.el" (0 0 0 0)) ;;; Generated autoloads from helm-color.el (autoload 'helm-colors "helm-color" "\ @@ -73,10 +78,11 @@ Preconfigured `helm' for color. \(fn)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-color" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-comint" "helm-comint.el" (23995 4638 -;;;;;; 440314 914000)) +;;;### (autoloads nil "helm-comint" "helm-comint.el" (0 0 0 0)) ;;; Generated autoloads from helm-comint.el (autoload 'helm-comint-prompts "helm-comint" "\ @@ -94,10 +100,11 @@ Preconfigured `helm' that provide completion of `comint' history. \(fn)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-comint" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-command" "helm-command.el" (23995 4638 -;;;;;; 456078 739000)) +;;;### (autoloads nil "helm-command" "helm-command.el" (0 0 0 0)) ;;; Generated autoloads from helm-command.el (autoload 'helm-M-x "helm-command" "\ @@ -113,10 +120,11 @@ You can get help on each command by persistent action. \(fn ARG &optional COMMAND-NAME)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-command" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-config" "helm-config.el" (23995 4638 -;;;;;; 438309 931000)) +;;;### (autoloads nil "helm-config" "helm-config.el" (0 0 0 0)) ;;; Generated autoloads from helm-config.el (autoload 'helm-configuration "helm-config" "\ @@ -124,10 +132,11 @@ Customize `helm'. \(fn)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-config" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-dabbrev" "helm-dabbrev.el" (23995 4638 -;;;;;; 429022 351000)) +;;;### (autoloads nil "helm-dabbrev" "helm-dabbrev.el" (0 0 0 0)) ;;; Generated autoloads from helm-dabbrev.el (autoload 'helm-dabbrev "helm-dabbrev" "\ @@ -135,10 +144,11 @@ Preconfigured helm for dynamic abbreviations. \(fn)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-dabbrev" '("helm-dabbrev-"))) + ;;;*** -;;;### (autoloads nil "helm-elisp" "helm-elisp.el" (23995 4638 446565 -;;;;;; 209000)) +;;;### (autoloads nil "helm-elisp" "helm-elisp.el" (0 0 0 0)) ;;; Generated autoloads from helm-elisp.el (autoload 'helm-lisp-completion-at-point "helm-elisp" "\ @@ -189,10 +199,12 @@ Preconfigured helm for complex command history. \(fn)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-elisp" '("helm-" "with-helm-show-completion"))) + ;;;*** ;;;### (autoloads nil "helm-elisp-package" "helm-elisp-package.el" -;;;;;; (23995 4638 431566 749000)) +;;;;;; (0 0 0 0)) ;;; Generated autoloads from helm-elisp-package.el (autoload 'helm-list-elisp-packages "helm-elisp-package" "\ @@ -208,10 +220,11 @@ Called with a prefix ARG always fetch packages on remote. \(fn ARG)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-elisp-package" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-eshell" "helm-eshell.el" (23995 4638 -;;;;;; 452554 924000)) +;;;### (autoloads nil "helm-eshell" "helm-eshell.el" (0 0 0 0)) ;;; Generated autoloads from helm-eshell.el (autoload 'helm-esh-pcomplete "helm-eshell" "\ @@ -234,10 +247,11 @@ Pre-configured `helm' to browse the prompts of all Eshell sessions. \(fn)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-eshell" '("helm-e"))) + ;;;*** -;;;### (autoloads nil "helm-eval" "helm-eval.el" (23995 4638 426076 -;;;;;; 258000)) +;;;### (autoloads nil "helm-eval" "helm-eval.el" (0 0 0 0)) ;;; Generated autoloads from helm-eval.el (autoload 'helm-eval-expression "helm-eval" "\ @@ -255,10 +269,11 @@ Preconfigured helm for `helm-source-calculation-result'. \(fn)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-eval" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-external" "helm-external.el" (23995 4638 -;;;;;; 463440 442000)) +;;;### (autoloads nil "helm-external" "helm-external.el" (0 0 0 0)) ;;; Generated autoloads from helm-external.el (autoload 'helm-run-external-command "helm-external" "\ @@ -269,10 +284,11 @@ You can set your own list of commands with \(fn PROGRAM)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-external" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-files" "helm-files.el" (23995 4638 469439 -;;;;;; 798000)) +;;;### (autoloads nil "helm-files" "helm-files.el" (0 0 0 0)) ;;; Generated autoloads from helm-files.el (autoload 'helm-projects-history "helm-files" "\ @@ -317,10 +333,11 @@ It allows additionally to delete more than one connection at once. \(fn)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-files" '("helm-" "eshell-command-aliases-list"))) + ;;;*** -;;;### (autoloads nil "helm-find" "helm-find.el" (23995 4638 460542 -;;;;;; 606000)) +;;;### (autoloads nil "helm-find" "helm-find.el" (0 0 0 0)) ;;; Generated autoloads from helm-find.el (autoload 'helm-find "helm-find" "\ @@ -343,10 +360,11 @@ are passed to \"find\" literally. \(fn ARG)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-find" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-font" "helm-font.el" (23995 4638 439304 -;;;;;; 202000)) +;;;### (autoloads nil "helm-font" "helm-font.el" (0 0 0 0)) ;;; Generated autoloads from helm-font.el (autoload 'helm-select-xfont "helm-font" "\ @@ -361,10 +379,12 @@ Called with a prefix arg force reloading cache. \(fn ARG)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-font" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-for-files" "helm-for-files.el" (23995 -;;;;;; 4638 427050 563000)) +;;;### (autoloads nil "helm-for-files" "helm-for-files.el" (0 0 0 +;;;;;; 0)) ;;; Generated autoloads from helm-for-files.el (autoload 'helm-for-files "helm-for-files" "\ @@ -388,10 +408,11 @@ Preconfigured `helm' for `recentf'. \(fn)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-for-files" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-grep" "helm-grep.el" (23995 4638 437298 -;;;;;; 323000)) +;;;### (autoloads nil "helm-grep" "helm-grep.el" (0 0 0 0)) ;;; Generated autoloads from helm-grep.el (autoload 'helm-goto-precedent-file "helm-grep" "\ @@ -416,10 +437,11 @@ With a prefix arg ARG git-grep the whole repository. \(fn ARG)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-grep" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-help" "helm-help.el" (23995 4638 435455 -;;;;;; 853000)) +;;;### (autoloads nil "helm-help" "helm-help.el" (0 0 0 0)) ;;; Generated autoloads from helm-help.el (autoload 'helm-documentation "helm-help" "\ @@ -437,10 +459,11 @@ String displayed in mode-line in `helm-source-find-files'.") (defvar helm-top-mode-line "\\\\[helm-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend \\[helm-customize-group]:Conf") +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-help" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-id-utils" "helm-id-utils.el" (23995 4638 -;;;;;; 449602 499000)) +;;;### (autoloads nil "helm-id-utils" "helm-id-utils.el" (0 0 0 0)) ;;; Generated autoloads from helm-id-utils.el (autoload 'helm-gid "helm-id-utils" "\ @@ -452,10 +475,11 @@ See . \(fn)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-id-utils" '("helm-gid-"))) + ;;;*** -;;;### (autoloads nil "helm-imenu" "helm-imenu.el" (23995 4638 441204 -;;;;;; 502000)) +;;;### (autoloads nil "helm-imenu" "helm-imenu.el" (0 0 0 0)) ;;; Generated autoloads from helm-imenu.el (autoload 'helm-imenu "helm-imenu" "\ @@ -470,10 +494,11 @@ or it have an association in `helm-imenu-all-buffer-assoc'. \(fn)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-imenu" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-info" "helm-info.el" (23995 4638 454030 -;;;;;; 162000)) +;;;### (autoloads nil "helm-info" "helm-info.el" (0 0 0 0)) ;;; Generated autoloads from helm-info.el (autoload 'helm-info "helm-info" "\ @@ -497,10 +522,11 @@ Preconfigured `helm' for searching info at point. \(fn)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-info" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-locate" "helm-locate.el" (23995 4638 -;;;;;; 468480 454000)) +;;;### (autoloads nil "helm-locate" "helm-locate.el" (0 0 0 0)) ;;; Generated autoloads from helm-locate.el (autoload 'helm-projects-find-files "helm-locate" "\ @@ -525,10 +551,11 @@ Where db_path is a filename matched by \(fn ARG)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-locate" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-man" "helm-man.el" (23995 4638 470648 -;;;;;; 856000)) +;;;### (autoloads nil "helm-man" "helm-man.el" (0 0 0 0)) ;;; Generated autoloads from helm-man.el (autoload 'helm-man-woman "helm-man" "\ @@ -537,10 +564,11 @@ With a prefix arg reinitialize the cache. \(fn ARG)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-man" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-misc" "helm-misc.el" (23995 4638 447993 -;;;;;; 29000)) +;;;### (autoloads nil "helm-misc" "helm-misc.el" (0 0 0 0)) ;;; Generated autoloads from helm-misc.el (autoload 'helm-world-time "helm-misc" "\ @@ -569,10 +597,11 @@ Preconfigured `helm' for `minibuffer-history'. \(fn)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-misc" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-mode" "helm-mode.el" (23995 4638 461864 -;;;;;; 977000)) +;;;### (autoloads nil "helm-mode" "helm-mode.el" (0 0 0 0)) ;;; Generated autoloads from helm-mode.el (autoload 'helm-comp-read "helm-mode" "\ @@ -768,10 +797,11 @@ Note: This mode is incompatible with Emacs23. \(fn &optional ARG)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-mode" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-net" "helm-net.el" (23995 4638 427991 -;;;;;; 953000)) +;;;### (autoloads nil "helm-net" "helm-net.el" (0 0 0 0)) ;;; Generated autoloads from helm-net.el (autoload 'helm-browse-url-firefox "helm-net" "\ @@ -819,10 +849,11 @@ Preconfigured `helm' for google search with google suggest. \(fn)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-net" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-occur" "helm-occur.el" (23995 4638 442119 -;;;;;; 851000)) +;;;### (autoloads nil "helm-occur" "helm-occur.el" (0 0 0 0)) ;;; Generated autoloads from helm-occur.el (autoload 'helm-occur "helm-occur" "\ @@ -871,10 +902,11 @@ To use this bind it to a key in `isearch-mode-map'. \(fn)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-occur" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-regexp" "helm-regexp.el" (23995 4638 -;;;;;; 457542 714000)) +;;;### (autoloads nil "helm-regexp" "helm-regexp.el" (0 0 0 0)) ;;; Generated autoloads from helm-regexp.el (autoload 'helm-regexp "helm-regexp" "\ @@ -883,10 +915,11 @@ Preconfigured helm to build regexps. \(fn)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-regexp" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-ring" "helm-ring.el" (23995 4638 467358 -;;;;;; 867000)) +;;;### (autoloads nil "helm-ring" "helm-ring.el" (0 0 0 0)) ;;; Generated autoloads from helm-ring.el (autoload 'helm-mark-ring "helm-ring" "\ @@ -925,10 +958,11 @@ This command is useful when used with persistent action. \(fn)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-ring" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-semantic" "helm-semantic.el" (23995 4638 -;;;;;; 433498 614000)) +;;;### (autoloads nil "helm-semantic" "helm-semantic.el" (0 0 0 0)) ;;; Generated autoloads from helm-semantic.el (autoload 'helm-semantic "helm-semantic" "\ @@ -948,10 +982,11 @@ Fill in the symbol at point by default. \(fn ARG)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-semantic" '("helm-s"))) + ;;;*** -;;;### (autoloads nil "helm-shell" "helm-shell.el" (23995 4638 429828 -;;;;;; 754000)) +;;;### (autoloads nil "helm-shell" "helm-shell.el" (0 0 0 0)) ;;; Generated autoloads from helm-shell.el (defalias 'helm-shell-prompts 'helm-comint-prompts) @@ -960,8 +995,7 @@ Fill in the symbol at point by default. ;;;*** -;;;### (autoloads nil "helm-sys" "helm-sys.el" (23995 4638 466220 -;;;;;; 502000)) +;;;### (autoloads nil "helm-sys" "helm-sys.el" (0 0 0 0)) ;;; Generated autoloads from helm-sys.el (defvar helm-top-poll-mode nil "\ @@ -994,10 +1028,11 @@ Preconfigured helm for xrandr. \(fn)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-sys" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-tags" "helm-tags.el" (23995 4638 445164 -;;;;;; 259000)) +;;;### (autoloads nil "helm-tags" "helm-tags.el" (0 0 0 0)) ;;; Generated autoloads from helm-tags.el (autoload 'helm-etags-select "helm-tags" "\ @@ -1014,10 +1049,18 @@ This function aggregates three sources of tag files: \(fn REINIT)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-tags" '("helm-"))) + +;;;*** + +;;;### (autoloads nil "helm-types" "helm-types.el" (0 0 0 0)) +;;; Generated autoloads from helm-types.el + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-types" '("helm-"))) + ;;;*** -;;;### (autoloads nil "helm-utils" "helm-utils.el" (23995 4638 432487 -;;;;;; 102000)) +;;;### (autoloads nil "helm-utils" "helm-utils.el" (0 0 0 0)) ;;; Generated autoloads from helm-utils.el (defvar helm-popup-tip-mode nil "\ @@ -1035,10 +1078,19 @@ Show help-echo informations in a popup tip at end of line. \(fn &optional ARG)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-utils" '("helm-" "with-helm-display-marked-candidates"))) + +;;;*** + +;;;### (autoloads nil "helm-x-files" "helm-x-files.el" (0 0 0 0)) +;;; Generated autoloads from helm-x-files.el + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-x-files" '("helm-"))) + ;;;*** -;;;### (autoloads nil nil ("helm-easymenu.el" "helm-pkg.el" "helm-types.el" -;;;;;; "helm-x-files.el") (23995 4638 471463 881000)) +;;;### (autoloads nil nil ("helm-easymenu.el" "helm-pkg.el") (0 0 +;;;;;; 0 0)) ;;;*** @@ -1046,5 +1098,6 @@ Show help-echo informations in a popup tip at end of line. ;; version-control: never ;; no-byte-compile: t ;; no-update-autoloads: t +;; coding: utf-8 ;; End: ;;; helm-autoloads.el ends here diff --git a/elpa/helm-20191031.839/helm-bookmark.el b/elpa/helm-20191101.641/helm-bookmark.el similarity index 100% rename from elpa/helm-20191031.839/helm-bookmark.el rename to elpa/helm-20191101.641/helm-bookmark.el diff --git a/elpa/helm-20191031.839/helm-buffers.el b/elpa/helm-20191101.641/helm-buffers.el similarity index 100% rename from elpa/helm-20191031.839/helm-buffers.el rename to elpa/helm-20191101.641/helm-buffers.el diff --git a/elpa/helm-20191031.839/helm-color.el b/elpa/helm-20191101.641/helm-color.el similarity index 100% rename from elpa/helm-20191031.839/helm-color.el rename to elpa/helm-20191101.641/helm-color.el diff --git a/elpa/helm-20191031.839/helm-comint.el b/elpa/helm-20191101.641/helm-comint.el similarity index 100% rename from elpa/helm-20191031.839/helm-comint.el rename to elpa/helm-20191101.641/helm-comint.el diff --git a/elpa/helm-20191031.839/helm-command.el b/elpa/helm-20191101.641/helm-command.el similarity index 100% rename from elpa/helm-20191031.839/helm-command.el rename to elpa/helm-20191101.641/helm-command.el diff --git a/elpa/helm-20191031.839/helm-config.el b/elpa/helm-20191101.641/helm-config.el similarity index 100% rename from elpa/helm-20191031.839/helm-config.el rename to elpa/helm-20191101.641/helm-config.el diff --git a/elpa/helm-20191031.839/helm-dabbrev.el b/elpa/helm-20191101.641/helm-dabbrev.el similarity index 100% rename from elpa/helm-20191031.839/helm-dabbrev.el rename to elpa/helm-20191101.641/helm-dabbrev.el diff --git a/elpa/helm-20191031.839/helm-easymenu.el b/elpa/helm-20191101.641/helm-easymenu.el similarity index 100% rename from elpa/helm-20191031.839/helm-easymenu.el rename to elpa/helm-20191101.641/helm-easymenu.el diff --git a/elpa/helm-20191031.839/helm-elisp-package.el b/elpa/helm-20191101.641/helm-elisp-package.el similarity index 100% rename from elpa/helm-20191031.839/helm-elisp-package.el rename to elpa/helm-20191101.641/helm-elisp-package.el diff --git a/elpa/helm-20191031.839/helm-elisp.el b/elpa/helm-20191101.641/helm-elisp.el similarity index 100% rename from elpa/helm-20191031.839/helm-elisp.el rename to elpa/helm-20191101.641/helm-elisp.el diff --git a/elpa/helm-20191031.839/helm-eshell.el b/elpa/helm-20191101.641/helm-eshell.el similarity index 100% rename from elpa/helm-20191031.839/helm-eshell.el rename to elpa/helm-20191101.641/helm-eshell.el diff --git a/elpa/helm-20191031.839/helm-eval.el b/elpa/helm-20191101.641/helm-eval.el similarity index 100% rename from elpa/helm-20191031.839/helm-eval.el rename to elpa/helm-20191101.641/helm-eval.el diff --git a/elpa/helm-20191031.839/helm-external.el b/elpa/helm-20191101.641/helm-external.el similarity index 100% rename from elpa/helm-20191031.839/helm-external.el rename to elpa/helm-20191101.641/helm-external.el diff --git a/elpa/helm-20191031.839/helm-files.el b/elpa/helm-20191101.641/helm-files.el similarity index 100% rename from elpa/helm-20191031.839/helm-files.el rename to elpa/helm-20191101.641/helm-files.el diff --git a/elpa/helm-20191031.839/helm-find.el b/elpa/helm-20191101.641/helm-find.el similarity index 100% rename from elpa/helm-20191031.839/helm-find.el rename to elpa/helm-20191101.641/helm-find.el diff --git a/elpa/helm-20191031.839/helm-font.el b/elpa/helm-20191101.641/helm-font.el similarity index 100% rename from elpa/helm-20191031.839/helm-font.el rename to elpa/helm-20191101.641/helm-font.el diff --git a/elpa/helm-20191031.839/helm-for-files.el b/elpa/helm-20191101.641/helm-for-files.el similarity index 100% rename from elpa/helm-20191031.839/helm-for-files.el rename to elpa/helm-20191101.641/helm-for-files.el diff --git a/elpa/helm-20191031.839/helm-grep.el b/elpa/helm-20191101.641/helm-grep.el similarity index 100% rename from elpa/helm-20191031.839/helm-grep.el rename to elpa/helm-20191101.641/helm-grep.el diff --git a/elpa/helm-20191031.839/helm-help.el b/elpa/helm-20191101.641/helm-help.el similarity index 100% rename from elpa/helm-20191031.839/helm-help.el rename to elpa/helm-20191101.641/helm-help.el diff --git a/elpa/helm-20191031.839/helm-id-utils.el b/elpa/helm-20191101.641/helm-id-utils.el similarity index 100% rename from elpa/helm-20191031.839/helm-id-utils.el rename to elpa/helm-20191101.641/helm-id-utils.el diff --git a/elpa/helm-20191031.839/helm-imenu.el b/elpa/helm-20191101.641/helm-imenu.el similarity index 100% rename from elpa/helm-20191031.839/helm-imenu.el rename to elpa/helm-20191101.641/helm-imenu.el diff --git a/elpa/helm-20191031.839/helm-info.el b/elpa/helm-20191101.641/helm-info.el similarity index 100% rename from elpa/helm-20191031.839/helm-info.el rename to elpa/helm-20191101.641/helm-info.el diff --git a/elpa/helm-20191031.839/helm-locate.el b/elpa/helm-20191101.641/helm-locate.el similarity index 100% rename from elpa/helm-20191031.839/helm-locate.el rename to elpa/helm-20191101.641/helm-locate.el diff --git a/elpa/helm-20191031.839/helm-man.el b/elpa/helm-20191101.641/helm-man.el similarity index 100% rename from elpa/helm-20191031.839/helm-man.el rename to elpa/helm-20191101.641/helm-man.el diff --git a/elpa/helm-20191031.839/helm-misc.el b/elpa/helm-20191101.641/helm-misc.el similarity index 100% rename from elpa/helm-20191031.839/helm-misc.el rename to elpa/helm-20191101.641/helm-misc.el diff --git a/elpa/helm-20191031.839/helm-mode.el b/elpa/helm-20191101.641/helm-mode.el similarity index 99% rename from elpa/helm-20191031.839/helm-mode.el rename to elpa/helm-20191101.641/helm-mode.el index 36521a4b..d2f746c6 100644 --- a/elpa/helm-20191031.839/helm-mode.el +++ b/elpa/helm-20191101.641/helm-mode.el @@ -1366,10 +1366,10 @@ Actually do nothing." "The all completions function for `completing-styles-alist'." ;; FIXME: No need to bind all these value. (cl-multiple-value-bind (all _pattern prefix _suffix _carbounds) - (helm-completion--substring-all-completions string table pred point) + (helm-completion--multi-all-completions string table pred point) (when all (nconc all (length prefix))))) -(defun helm-completion--all-completions-multi (string collection &optional predicate) +(defun helm-completion--multi-all-completions-1 (string collection &optional predicate) "Allow `all-completions' multi matching on its candidates." (all-completions "" collection (lambda (x) (if predicate @@ -1377,7 +1377,7 @@ Actually do nothing." (helm-mm-match (helm-stringify x) string)) (helm-mm-match (helm-stringify x) string))))) -(defun helm-completion--substring-all-completions (string table pred point) +(defun helm-completion--multi-all-completions (string table pred point) "Collect completions from TABLE for helm completion style." (let* ((beforepoint (substring string 0 point)) (afterpoint (substring string point)) @@ -1386,7 +1386,7 @@ Actually do nothing." (suffix (substring afterpoint (cdr bounds))) (all (if (or (string-match-p " " string) (string-match-p "\\`!" string)) - (helm-completion--all-completions-multi string table pred) + (helm-completion--multi-all-completions-1 string table pred) (all-completions string table pred)))) (list all string prefix suffix point))) @@ -1509,11 +1509,6 @@ Can be used as value for `completion-in-region-function'." ;; so data looks like this: '(a b c d . 0) and (last data) == (d . 0). base-size (compfn (lambda (str _predicate _action) - ;; Cache data for subsequent calls when emacs - ;; style is in use, with helm style function - ;; is called only once and cache is not - ;; needed but it doesn't harm to set hash, it - ;; will not be used. (let* ((comps (completion-all-completions ;; `helm-comp-read-get-candidates' diff --git a/elpa/helm-20191031.839/helm-net.el b/elpa/helm-20191101.641/helm-net.el similarity index 100% rename from elpa/helm-20191031.839/helm-net.el rename to elpa/helm-20191101.641/helm-net.el diff --git a/elpa/helm-20191031.839/helm-occur.el b/elpa/helm-20191101.641/helm-occur.el similarity index 100% rename from elpa/helm-20191031.839/helm-occur.el rename to elpa/helm-20191101.641/helm-occur.el diff --git a/elpa/helm-20191031.839/helm-pkg.el b/elpa/helm-20191101.641/helm-pkg.el similarity index 76% rename from elpa/helm-20191031.839/helm-pkg.el rename to elpa/helm-20191101.641/helm-pkg.el index e6105a64..d9a664cc 100644 --- a/elpa/helm-20191031.839/helm-pkg.el +++ b/elpa/helm-20191101.641/helm-pkg.el @@ -1,4 +1,4 @@ -(define-package "helm" "20191031.839" "Helm is an Emacs incremental and narrowing framework" +(define-package "helm" "20191101.641" "Helm is an Emacs incremental and narrowing framework" '((emacs "24.4") (async "1.9.3") (popup "0.5.3") diff --git a/elpa/helm-20191031.839/helm-regexp.el b/elpa/helm-20191101.641/helm-regexp.el similarity index 100% rename from elpa/helm-20191031.839/helm-regexp.el rename to elpa/helm-20191101.641/helm-regexp.el diff --git a/elpa/helm-20191031.839/helm-ring.el b/elpa/helm-20191101.641/helm-ring.el similarity index 100% rename from elpa/helm-20191031.839/helm-ring.el rename to elpa/helm-20191101.641/helm-ring.el diff --git a/elpa/helm-20191031.839/helm-semantic.el b/elpa/helm-20191101.641/helm-semantic.el similarity index 100% rename from elpa/helm-20191031.839/helm-semantic.el rename to elpa/helm-20191101.641/helm-semantic.el diff --git a/elpa/helm-20191031.839/helm-shell.el b/elpa/helm-20191101.641/helm-shell.el similarity index 100% rename from elpa/helm-20191031.839/helm-shell.el rename to elpa/helm-20191101.641/helm-shell.el diff --git a/elpa/helm-20191031.839/helm-sys.el b/elpa/helm-20191101.641/helm-sys.el similarity index 100% rename from elpa/helm-20191031.839/helm-sys.el rename to elpa/helm-20191101.641/helm-sys.el diff --git a/elpa/helm-20191031.839/helm-tags.el b/elpa/helm-20191101.641/helm-tags.el similarity index 100% rename from elpa/helm-20191031.839/helm-tags.el rename to elpa/helm-20191101.641/helm-tags.el diff --git a/elpa/helm-20191031.839/helm-types.el b/elpa/helm-20191101.641/helm-types.el similarity index 100% rename from elpa/helm-20191031.839/helm-types.el rename to elpa/helm-20191101.641/helm-types.el diff --git a/elpa/helm-20191031.839/helm-utils.el b/elpa/helm-20191101.641/helm-utils.el similarity index 100% rename from elpa/helm-20191031.839/helm-utils.el rename to elpa/helm-20191101.641/helm-utils.el diff --git a/elpa/helm-20191031.839/helm-x-files.el b/elpa/helm-20191101.641/helm-x-files.el similarity index 100% rename from elpa/helm-20191031.839/helm-x-files.el rename to elpa/helm-20191101.641/helm-x-files.el diff --git a/elpa/helm-core-20191013.626/helm-core-autoloads.el b/elpa/helm-core-20191031.1931/helm-core-autoloads.el similarity index 85% rename from elpa/helm-core-20191013.626/helm-core-autoloads.el rename to elpa/helm-core-20191031.1931/helm-core-autoloads.el index 889e8baf..48f40c77 100644 --- a/elpa/helm-core-20191013.626/helm-core-autoloads.el +++ b/elpa/helm-core-20191031.1931/helm-core-autoloads.el @@ -1,9 +1,12 @@ ;;; helm-core-autoloads.el --- automatically extracted autoloads ;; ;;; Code: -(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) + +(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path)))) + -;;;### (autoloads nil "helm" "helm.el" (23994 46468 951673 745000)) +;;;### (autoloads nil "helm" "helm.el" (0 0 0 0)) ;;; Generated autoloads from helm.el (autoload 'helm-define-multi-key "helm" "\ @@ -220,10 +223,33 @@ Call `helm' only with ANY-SOURCES and ANY-BUFFER as args. \(fn ANY-SOURCES ANY-BUFFER)" nil nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm" '("helm-" "with-helm-"))) + +;;;*** + +;;;### (autoloads nil "helm-lib" "helm-lib.el" (0 0 0 0)) +;;; Generated autoloads from helm-lib.el + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-lib" '("helm-" "with-helm-"))) + +;;;*** + +;;;### (autoloads nil "helm-multi-match" "helm-multi-match.el" (0 +;;;;;; 0 0 0)) +;;; Generated autoloads from helm-multi-match.el + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-multi-match" '("helm-m"))) + +;;;*** + +;;;### (autoloads nil "helm-source" "helm-source.el" (0 0 0 0)) +;;; Generated autoloads from helm-source.el + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-source" '("helm-"))) + ;;;*** -;;;### (autoloads nil nil ("helm-core-pkg.el" "helm-lib.el" "helm-multi-match.el" -;;;;;; "helm-source.el") (23994 46468 953271 677000)) +;;;### (autoloads nil nil ("helm-core-pkg.el") (0 0 0 0)) ;;;*** @@ -231,5 +257,6 @@ Call `helm' only with ANY-SOURCES and ANY-BUFFER as args. ;; version-control: never ;; no-byte-compile: t ;; no-update-autoloads: t +;; coding: utf-8 ;; End: ;;; helm-core-autoloads.el ends here diff --git a/elpa/helm-core-20191013.626/helm-core-pkg.el b/elpa/helm-core-20191031.1931/helm-core-pkg.el similarity index 64% rename from elpa/helm-core-20191013.626/helm-core-pkg.el rename to elpa/helm-core-20191031.1931/helm-core-pkg.el index b787ffa7..9a486e1b 100644 --- a/elpa/helm-core-20191013.626/helm-core-pkg.el +++ b/elpa/helm-core-20191031.1931/helm-core-pkg.el @@ -1,4 +1,4 @@ -(define-package "helm-core" "20191013.626" "Development files for Helm" +(define-package "helm-core" "20191031.1931" "Development files for Helm" '((emacs "24.4") (async "1.9.3")) :url "https://emacs-helm.github.io/helm/") diff --git a/elpa/helm-core-20191013.626/helm-lib.el b/elpa/helm-core-20191031.1931/helm-lib.el similarity index 100% rename from elpa/helm-core-20191013.626/helm-lib.el rename to elpa/helm-core-20191031.1931/helm-lib.el diff --git a/elpa/helm-core-20191013.626/helm-multi-match.el b/elpa/helm-core-20191031.1931/helm-multi-match.el similarity index 100% rename from elpa/helm-core-20191013.626/helm-multi-match.el rename to elpa/helm-core-20191031.1931/helm-multi-match.el diff --git a/elpa/helm-core-20191013.626/helm-source.el b/elpa/helm-core-20191031.1931/helm-source.el similarity index 99% rename from elpa/helm-core-20191013.626/helm-source.el rename to elpa/helm-core-20191031.1931/helm-source.el index bcf434df..05bcb3e5 100644 --- a/elpa/helm-core-20191013.626/helm-source.el +++ b/elpa/helm-core-20191031.1931/helm-source.el @@ -1160,7 +1160,7 @@ Args ARGS are keywords provided by `helm-source-dummy'." Arg FILE is a filename, the contents of this file will be used as candidates in buffer. Args ARGS are keywords provided by `helm-source-in-file'." - (declare (indent 1)) + (declare (indent 2)) `(helm-make-source ,name 'helm-source-in-file :candidates-file ,file ,@args)) diff --git a/elpa/helm-core-20191013.626/helm.el b/elpa/helm-core-20191031.1931/helm.el similarity index 99% rename from elpa/helm-core-20191013.626/helm.el rename to elpa/helm-core-20191031.1931/helm.el index ff5ff2f4..dde4b5a6 100644 --- a/elpa/helm-core-20191013.626/helm.el +++ b/elpa/helm-core-20191031.1931/helm.el @@ -244,7 +244,6 @@ vectors, so don't use strings to define them." ;; Multi keys (define-key map (kbd "C-t") 'helm-toggle-resplit-and-swap-windows) ;; Debugging command - (define-key map (kbd "C-h C-d") 'undefined) (define-key map (kbd "C-h C-d") 'helm-enable-or-switch-to-debug) (define-key map (kbd "C-h c") 'helm-customize-group) ;; Allow to eval keymap without errors. diff --git a/elpa/hydra-readme.txt b/elpa/hydra-readme.txt deleted file mode 100644 index 04ef5ff8..00000000 --- a/elpa/hydra-readme.txt +++ /dev/null @@ -1,51 +0,0 @@ -This package can be used to tie related commands into a family of -short bindings with a common prefix - a Hydra. - -Once you summon the Hydra (through the prefixed binding), all the -heads can be called in succession with only a short extension. -The Hydra is vanquished once Hercules, any binding that isn't the -Hydra's head, arrives. Note that Hercules, besides vanquishing the -Hydra, will still serve his orignal purpose, calling his proper -command. This makes the Hydra very seamless, it's like a minor -mode that disables itself automagically. - -Here's an example Hydra, bound in the global map (you can use any -keymap in place of `global-map'): - - (defhydra hydra-zoom (global-map "") - "zoom" - ("g" text-scale-increase "in") - ("l" text-scale-decrease "out")) - -It allows to start a command chain either like this: -" gg4ll5g", or " lgllg". - -Here's another approach, when you just want a "callable keymap": - - (defhydra hydra-toggle (:color blue) - "toggle" - ("a" abbrev-mode "abbrev") - ("d" toggle-debug-on-error "debug") - ("f" auto-fill-mode "fill") - ("t" toggle-truncate-lines "truncate") - ("w" whitespace-mode "whitespace") - ("q" nil "cancel")) - -This binds nothing so far, but if you follow up with: - - (global-set-key (kbd "C-c C-v") 'hydra-toggle/body) - -you will have bound "C-c C-v a", "C-c C-v d" etc. - -Knowing that `defhydra' defines e.g. `hydra-toggle/body' command, -you can nest Hydras if you wish, with `hydra-toggle/body' possibly -becoming a blue head of another Hydra. - -If you want to learn all intricacies of using `defhydra' without -having to figure it all out from this source code, check out the -wiki: https://github.com/abo-abo/hydra/wiki. There's a wealth of -information there. Everyone is welcome to bring the existing pages -up to date and add new ones. - -Additionally, the file hydra-examples.el serves to demo most of the -functionality. diff --git a/elpa/json-mode-readme.txt b/elpa/json-mode-readme.txt deleted file mode 100644 index 78b3464e..00000000 --- a/elpa/json-mode-readme.txt +++ /dev/null @@ -1 +0,0 @@ -extend the builtin js-mode's syntax highlighting diff --git a/elpa/lv-20191025.1326/lv-autoloads.el b/elpa/lv-20191025.1326/lv-autoloads.el new file mode 100644 index 00000000..61b10796 --- /dev/null +++ b/elpa/lv-20191025.1326/lv-autoloads.el @@ -0,0 +1,22 @@ +;;; lv-autoloads.el --- automatically extracted autoloads +;; +;;; Code: + +(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path)))) + + +;;;### (autoloads nil "lv" "lv.el" (0 0 0 0)) +;;; Generated autoloads from lv.el + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "lv" '("lv-"))) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; coding: utf-8 +;; End: +;;; lv-autoloads.el ends here diff --git a/elpa/lv-20191025.1326/lv-pkg.el b/elpa/lv-20191025.1326/lv-pkg.el new file mode 100644 index 00000000..c971a6d6 --- /dev/null +++ b/elpa/lv-20191025.1326/lv-pkg.el @@ -0,0 +1,2 @@ +;;; -*- no-byte-compile: t -*- +(define-package "lv" "20191025.1326" "Other echo area" 'nil :commit "74b32f3ff004cd2ad7707722ffa7f85e8233a845" :authors '(("Oleh Krehel")) :maintainer '("Oleh Krehel")) diff --git a/elpa/lv-20191025.1326/lv.el b/elpa/lv-20191025.1326/lv.el new file mode 100644 index 00000000..9d9c4c7b --- /dev/null +++ b/elpa/lv-20191025.1326/lv.el @@ -0,0 +1,126 @@ +;;; lv.el --- Other echo area +;; Package-Version: 20191025.1326 + +;; Copyright (C) 2015 Free Software Foundation, Inc. + +;; Author: Oleh Krehel + +;; This file is part of GNU Emacs. + +;; GNU Emacs 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. + +;; GNU Emacs 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. If not, see . + +;;; Commentary: +;; +;; This package provides `lv-message' intended to be used in place of +;; `message' when semi-permanent hints are needed, in order to not +;; interfere with Echo Area. +;; +;; "Я тихо-тихо пiдглядаю, +;; І тiшуся собi, як бачу то, +;; Шо страшить i не пiдпускає, +;; А iншi п’ють тебе, як воду пiсок." +;; -- Андрій Кузьменко, L.V. + +;;; Code: + +(defgroup lv nil + "The other echo area." + :group 'minibuffer + :group 'hydra) + +(defcustom lv-use-separator nil + "Whether to draw a line between the LV window and the Echo Area." + :group 'lv + :type 'boolean) + +(defface lv-separator + '((((class color) (background light)) :background "grey80") + (((class color) (background dark)) :background "grey30")) + "Face used to draw line between the lv window and the echo area. +This is only used if option `lv-use-separator' is non-nil. +Only the background color is significant." + :group 'lv) + +(defvar lv-wnd nil + "Holds the current LV window.") + +(defvar display-line-numbers) +(defvar display-fill-column-indicator) +(defvar tab-line-format) + +(defun lv-window () + "Ensure that LV window is live and return it." + (if (window-live-p lv-wnd) + lv-wnd + (let ((ori (selected-window)) + buf) + (prog1 (setq lv-wnd + (select-window + (let ((ignore-window-parameters t)) + (split-window + (frame-root-window) -1 'below)))) + (if (setq buf (get-buffer " *LV*")) + (switch-to-buffer buf) + (switch-to-buffer " *LV*") + (set-window-hscroll lv-wnd 0) + (setq window-size-fixed t) + (setq mode-line-format nil) + (setq header-line-format nil) + (setq tab-line-format nil) + (setq cursor-type nil) + (setq display-line-numbers nil) + (setq display-fill-column-indicator nil) + (set-window-dedicated-p lv-wnd t) + (set-window-parameter lv-wnd 'no-other-window t)) + (select-window ori))))) + +(defvar golden-ratio-mode) + +(defvar lv-force-update nil + "When non-nil, `lv-message' will refresh even for the same string.") + +(defun lv-message (format-string &rest args) + "Set LV window contents to (`format' FORMAT-STRING ARGS)." + (let* ((str (apply #'format format-string args)) + (n-lines (cl-count ?\n str)) + deactivate-mark + golden-ratio-mode) + (with-selected-window (lv-window) + (unless (and (string= (buffer-string) str) + (null lv-force-update)) + (delete-region (point-min) (point-max)) + (insert str) + (when (and (window-system) lv-use-separator) + (unless (looking-back "\n" nil) + (insert "\n")) + (insert + (propertize "__" 'face 'lv-separator 'display '(space :height (1))) + (propertize "\n" 'face 'lv-separator 'line-height t))) + (set (make-local-variable 'window-min-height) n-lines) + (setq truncate-lines (> n-lines 1)) + (let ((window-resize-pixelwise t) + (window-size-fixed nil)) + (fit-window-to-buffer nil nil 1))) + (goto-char (point-min))))) + +(defun lv-delete-window () + "Delete LV window and kill its buffer." + (when (window-live-p lv-wnd) + (let ((buf (window-buffer lv-wnd))) + (delete-window lv-wnd) + (kill-buffer buf)))) + +(provide 'lv) + +;;; lv.el ends here diff --git a/elpa/lv-readme.txt b/elpa/lv-readme.txt new file mode 100644 index 00000000..05ad5b76 --- /dev/null +++ b/elpa/lv-readme.txt @@ -0,0 +1,9 @@ +This package provides `lv-message' intended to be used in place of +`message' when semi-permanent hints are needed, in order to not +interfere with Echo Area. + + "Я тихо-тихо пiдглядаю, + І тiшуся собi, як бачу то, + Шо страшить i не пiдпускає, + А iншi п’ють тебе, як воду пiсок." + -- Андрій Кузьменко, L.V. diff --git a/elpa/parsebib-readme.txt b/elpa/parsebib-readme.txt new file mode 100644 index 00000000..e69de29b diff --git a/elpa/parseclj-20190531.711/parseclj-ast.el b/elpa/parseclj-20190531.711/parseclj-ast.el new file mode 100644 index 00000000..e7b3cebc --- /dev/null +++ b/elpa/parseclj-20190531.711/parseclj-ast.el @@ -0,0 +1,205 @@ +;;; parseclj-ast.el --- Clojure parser/unparser -*- lexical-binding: t; -*- + +;; Copyright (C) 2017-2018 Arne Brasseur + +;; Author: Arne Brasseur + +;; This file is not part of GNU Emacs. + +;; This file is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Commentary: + +;; Parse Clojure code to an AST, and unparse back to code. + +;;; Code: + +(require 'a) +(require 'seq) +(require 'subr-x) +(require 'parseclj-lex) + +;; AST helper functions + +(defun parseclj-ast-node (type position &rest attributes) + "Create an AST node with given TYPE and POSITION. +Other ATTRIBUTES can be given as a flat list of key-value pairs." + (apply 'a-list :node-type type :position position attributes)) + +(defun parseclj-ast-node-p (node) + "Return t if the given NODE is a Clojure AST node." + (and (consp node) + (consp (car node)) + (eq :node-type (caar node)))) + +(defun parseclj-ast-node-attr (node attr) + "Return NODE's ATTR, or nil." + (a-get node attr)) + +(defun parseclj-ast-node-type (node) + "Return the type of the AST node NODE." + (a-get node :node-type)) + +(defun parseclj-ast-children (node) + "Return children for the AST NODE." + (a-get node :children)) + +(defun parseclj-ast-value (node) + "Return the value of NODE as another AST node." + (a-get node :value)) + +(defun parseclj-ast-leaf-node-p (node) + "Return t if the given ast NODE is a leaf node." + (member (parseclj-ast-node-type node) parseclj-lex--leaf-tokens)) + +(defun parseclj-ast-branch-node-p (node) + "Return t if the given AST NODE is a branch node." + (not (parseclj-ast-leaf-node-p node))) + + +;; Parse/reduce strategy functions + +(defun parseclj-ast--reduce-leaf (stack token &optional _options) + "Put into the STACK an AST leaf node based on TOKEN. +Ignores white spaces and comments. + +OPTIONS is an association list. See `parseclj-parse' for more information +on available options." + (if (member (parseclj-lex-token-type token) '(:whitespace :comment)) + stack + (cons + (parseclj-ast-node (parseclj-lex-token-type token) + (a-get token :pos) + :form (a-get token :form) + :value (parseclj-lex--leaf-token-value token)) + stack))) + +(defun parseclj-ast--reduce-leaf-with-lexical-preservation (stack token options) + "Put into STACK an AST leaf node based on TOKEN. +This function is very similar to `parseclj-ast--reduce-leaf', but unlike +it, takes into account tokens representing white space or comments and +saves them into the STACK. Nodes produced by this function have a +`:lexical-preservation' key set to t. + +OPTIONS is an association list. See `parseclj-parse' for more information +on available options." + (let ((token-type (parseclj-lex-token-type token)) + (top (car stack))) + (if (member token-type '(:whitespace :comment)) + ;; merge consecutive whitespace or comment tokens + (if (eq token-type (a-get top :node-type)) + (cons (a-update top :form #'concat (a-get token :form)) + (cdr stack)) + (cons (parseclj-ast-node (parseclj-lex-token-type token) + (a-get token :pos) + :form (a-get token :form)) + stack)) + (parseclj-ast--reduce-leaf stack token options)))) + +(defun parseclj-ast--reduce-branch (stack opening-token children _options) + "Reduce STACK with an AST branch node representing a collection of elements. +Ignores discard tokens. + +OPENING-TOKEN is a lex token representing an opening paren, bracket or +brace. +CHILDREN is the collection of nodes to be reduced into the AST branch node. +OPTIONS is an association list. See `parseclj-parse' for more information +on available options." + (let* ((pos (a-get opening-token :pos)) + (type (parseclj-lex-token-type opening-token)) + (type (cl-case type + (:lparen :list) + (:lbracket :vector) + (:lbrace :map) + (t type)))) + (cl-case type + (:root (cons (parseclj-ast-node :root pos :children children) stack)) + (:discard stack) + (:tag (cons (parseclj-ast-node :tag + pos + :tag (intern (substring (a-get opening-token :form) 1)) + :children children) + stack)) + (:metadata (cons (parseclj-ast-node :with-meta + pos + :children children) + stack)) + (:map-prefix (cons (a-assoc (car children) + :map-prefix opening-token) + stack)) + (t (cons + (parseclj-ast-node type pos :children children) + stack))))) + +(defun parseclj-ast--reduce-branch-with-lexical-preservation (stack opening-token children options) + "Reduce STACK with an AST branch node representing a collection of elements. +Similar to `parseclj-ast--reduce-branch', but reduces discard tokens as +well. Nodes produced by this function have a `:lexical-preservation' +key set to t. + +OPENING-TOKEN is a lex token representing an opening paren, bracket or +brace. +CHILDREN is the collection of tokens to be reduced into the AST branch +node. +OPTIONS is an association list. See `parseclj-parse' for more information +on available options." + (if (eq :discard (parseclj-lex-token-type opening-token)) + (cons (parseclj-ast-node :discard (a-get opening-token :pos) :children children) stack) + (let* ((stack (funcall #'parseclj-ast--reduce-branch stack opening-token children options)) + (top (car stack))) + (if (parseclj-ast-node-p top) + (cons (cl-list* (car top) ;; make sure :node-type remains the first element in the list + '(:lexical-preservation . t) + (cdr top)) + (cdr stack)) + stack)))) + + + +;; Unparse functions + +(declare-function parseclj-unparse-clojure "parseclj") + +(defun parseclj-ast--unparse-collection (node) + "Insert a string representation of the given AST branch NODE into buffer." + (let* ((token-type (parseclj-ast-node-type node)) + (delimiters (cl-case token-type + (:root (cons "" "")) + (:list (cons "(" ")")) + (:vector (cons "[" "]")) + (:set (cons "#{" "}")) + (:map (cons "{" "}"))))) + (insert (car delimiters)) + (let ((nodes (alist-get ':children node))) + (when-let (node (car nodes)) + (parseclj-unparse-clojure node)) + (seq-doseq (child (cdr nodes)) + (when (not (a-get node :lexical-preservation)) + (insert " ")) + (parseclj-unparse-clojure child))) + (insert (cdr delimiters)))) + +(defun parseclj-ast--unparse-tag (node) + "Insert a string representation of the given AST tag NODE into buffer." + (progn + (insert "#") + (insert (symbol-name (a-get node :tag))) + (insert " ") + (parseclj-unparse-clojure (car (a-get node :children))))) + +(provide 'parseclj-ast) + +;;; parseclj-ast.el ends here diff --git a/elpa/parseclj-20190531.711/parseclj-autoloads.el b/elpa/parseclj-20190531.711/parseclj-autoloads.el new file mode 100644 index 00000000..a3ce9ffc --- /dev/null +++ b/elpa/parseclj-20190531.711/parseclj-autoloads.el @@ -0,0 +1,48 @@ +;;; parseclj-autoloads.el --- automatically extracted autoloads +;; +;;; Code: + +(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path)))) + + +;;;### (autoloads nil "parseclj" "parseclj.el" (0 0 0 0)) +;;; Generated autoloads from parseclj.el + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "parseclj" '("parseclj-"))) + +;;;*** + +;;;### (autoloads nil "parseclj-ast" "parseclj-ast.el" (0 0 0 0)) +;;; Generated autoloads from parseclj-ast.el + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "parseclj-ast" '("parseclj-ast-"))) + +;;;*** + +;;;### (autoloads nil "parseclj-lex" "parseclj-lex.el" (0 0 0 0)) +;;; Generated autoloads from parseclj-lex.el + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "parseclj-lex" '("parseclj-lex-"))) + +;;;*** + +;;;### (autoloads nil "parseclj-parser" "parseclj-parser.el" (0 0 +;;;;;; 0 0)) +;;; Generated autoloads from parseclj-parser.el + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "parseclj-parser" '("parseclj-"))) + +;;;*** + +;;;### (autoloads nil nil ("parseclj-pkg.el") (0 0 0 0)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; coding: utf-8 +;; End: +;;; parseclj-autoloads.el ends here diff --git a/elpa/parseclj-20190531.711/parseclj-lex.el b/elpa/parseclj-20190531.711/parseclj-lex.el new file mode 100644 index 00000000..f3d445f4 --- /dev/null +++ b/elpa/parseclj-20190531.711/parseclj-lex.el @@ -0,0 +1,545 @@ +;;; parseclj-lex.el --- Clojure/EDN Lexer + +;; Copyright (C) 2017-2018 Arne Brasseur + +;; Author: Arne Brasseur + +;; This file is not part of GNU Emacs. + +;; This file is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Commentary: + +;; A reader for EDN data files and parser for Clojure source files. + +;;; Code: + +(defvar parseclj-lex--leaf-tokens '(:whitespace + :comment + :number + :nil + :true + :false + :symbol + :keyword + :string + :regex + :character) + "Types of tokens that represent leaf nodes in the AST.") + +(defvar parseclj-lex--closing-tokens '(:rparen + :rbracket + :rbrace) + "Types of tokens that mark the end of a non-atomic form.") + +(defvar parseclj-lex--prefix-tokens '(:quote + :backquote + :unquote + :unquote-splice + :discard + :tag + :reader-conditional + :reader-conditional-splice + :var + :deref + :map-prefix + :eval) + "Tokens that modify the form that follows.") + +(defvar parseclj-lex--prefix-2-tokens '(:metadata) + "Tokens that modify the two forms that follow.") + +;; Token interface + +(defun parseclj-lex-token (type form pos &rest attributes) + "Create a lexer token with the specified attributes. + +Tokens at a mimimum have these attributes +- TYPE: the type of token, like :whitespace or :lparen +- FORM: the source form, a string +- POS: the position in the input, starts from 1 (like point) + +Other ATTRIBUTES can be given as a flat list of key-value pairs." + (apply 'a-list :token-type type :form form :pos pos attributes)) + +(defun parseclj-lex-error-token (pos &optional error-type) + "Create a lexer error token starting at POS. +ERROR-TYPE is an optional keyword to attach to the created token, +as the means for providing more information on the error." + (apply #'parseclj-lex-token + :lex-error + (buffer-substring-no-properties pos (point)) + pos + (when error-type + (list :error-type error-type)))) + +(defun parseclj-lex-token-p (token) + "Is the given TOKEN a parseclj-lex TOKEN. + +A token is an association list with :token-type as its first key." + (and (consp token) + (consp (car token)) + (eq :token-type (caar token)))) + +(defun parseclj-lex-token-type (token) + "Get the type of TOKEN." + (and (consp token) + (cdr (assq :token-type token)))) + +(defun parseclj-lex-token-form (token) + "Get the form of TOKEN." + (and (consp token) + (cdr (assq :form token)))) + +(defun parseclj-lex-leaf-token-p (token) + "Return t if the given AST TOKEN is a leaf node." + (member (parseclj-lex-token-type token) parseclj-lex--leaf-tokens)) + +(defun parseclj-lex-closing-token-p (token) + "Return t if the given ast TOKEN is a closing token." + (member (parseclj-lex-token-type token) parseclj-lex--closing-tokens)) + +(defun parseclj-lex-error-p (token) + "Return t if the TOKEN represents a lexing error token." + (eq (parseclj-lex-token-type token) :lex-error)) + +;; Elisp values from tokens + +(defun parseclj-lex--string-value (s) + "Parse an EDN string S into a regular string. +S goes through three transformations: +- Escaped characters in S are transformed into Elisp escaped + characters. +- Unicode escaped characters are decoded into its corresponding + unicode character counterpart. +- Octal escaped characters are decoded into its corresponding + character counterpart." + (replace-regexp-in-string + "\\\\o[0-8]\\{3\\}" + (lambda (x) + (make-string 1 (string-to-number (substring x 2) 8))) + (replace-regexp-in-string + "\\\\u[0-9a-fA-F]\\{4\\}" + (lambda (x) + (make-string 1 (string-to-number (substring x 2) 16))) + (replace-regexp-in-string "\\\\[tbnrf'\"\\]" + (lambda (x) + (cl-case (elt x 1) + (?t "\t") + (?f "\f") + (?\" "\"") + (?r "\r") + (?n "\n") + (?\\ "\\\\") + (t (substring x 1)))) + (substring s 1 -1))))) + +(defun parseclj-lex--character-value (c) + "Parse an EDN character C into an Emacs Lisp character." + (let ((first-char (elt c 1))) + (cond + ((equal c "\\newline") ?\n) + ((equal c "\\return") ?\r) + ((equal c "\\space") ?\ ) + ((equal c "\\tab") ?\t) + ((eq first-char ?u) (string-to-number (substring c 2) 16)) + ((eq first-char ?o) (string-to-number (substring c 2) 8)) + (t first-char)))) + +(defun parseclj-lex--leaf-token-value (token) + "Parse the given leaf TOKEN to an Emacs Lisp value." + (cl-case (parseclj-lex-token-type token) + (:number (string-to-number (alist-get :form token))) + (:nil nil) + (:true t) + (:false nil) + (:symbol (intern (alist-get :form token))) + (:keyword (intern (alist-get :form token))) + (:string (parseclj-lex--string-value (alist-get :form token))) + (:character (parseclj-lex--character-value (alist-get :form token))))) + + +;; Stream tokenization + +(defun parseclj-lex-at-whitespace-p () + "Return t if char at point is white space." + (let ((char (char-after (point)))) + (or (equal char ?\ ) + (equal char ?\t) + (equal char ?\n) + (equal char ?\r) + (equal char ?,)))) + +(defun parseclj-lex-at-eof-p () + "Return t if point is at the end of file." + (eq (point) (point-max))) + +(defun parseclj-lex-whitespace () + "Consume all consecutive white space as possible and return an :whitespace token." + (let ((pos (point))) + (while (parseclj-lex-at-whitespace-p) + (right-char)) + (parseclj-lex-token :whitespace + (buffer-substring-no-properties pos (point)) + pos))) + +(defun parseclj-lex-skip-digits () + "Skip all consecutive digits after point." + (while (and (char-after (point)) + (<= ?0 (char-after (point))) + (<= (char-after (point)) ?9)) + (right-char))) + +(defun parseclj-lex-skip-hex () + "Skip all consecutive hex digits after point." + (while (and (char-after (point)) + (or (<= ?0 (char-after (point)) ?9) + (<= ?a (char-after (point)) ?f) + (<= ?A (char-after (point)) ?F))) + (right-char))) + +(defun parseclj-lex-skip-number () + "Skip a number at point." + ;; [\+\-]?\d+\.\d+ + (if (and (eq ?0 (char-after (point))) + (eq ?x (char-after (1+ (point))))) + (progn + (right-char 2) + (parseclj-lex-skip-hex)) + (progn + (when (member (char-after (point)) '(?+ ?-)) + (right-char)) + + (parseclj-lex-skip-digits) + + (when (eq (char-after (point)) ?.) + (right-char)) + + (parseclj-lex-skip-digits)))) + +(defun parseclj-lex-number () + "Consume a number and return a `:number' token representing it." + (let ((pos (point))) + (parseclj-lex-skip-number) + + ;; 10110r2 or 4.3e+22 + (when (member (char-after (point)) '(?E ?e ?r)) + (right-char)) + + (parseclj-lex-skip-number) + + ;; trailing M + (when (eq (char-after (point)) ?M) + (right-char)) + + (let ((char (char-after (point)))) + (if (and char (or (and (<= ?a char) (<= char ?z)) + (and (<= ?A char) (<= char ?Z)) + (and (member char '(?. ?* ?+ ?! ?- ?_ ?? ?$ ?& ?= ?< ?> ?/))))) + (progn + (right-char) + (parseclj-lex-error-token pos :invalid-number-format)) + (parseclj-lex-token :number + (buffer-substring-no-properties pos (point)) + pos))))) + + +(defun parseclj-lex-digit-p (char) + "Return t if CHAR is a digit." + (and char (<= ?0 char) (<= char ?9))) + +(defun parseclj-lex-at-number-p () + "Return t if point is at a number." + (let ((char (char-after (point)))) + (or (parseclj-lex-digit-p char) + (and (member char '(?- ?+ ?.)) + (parseclj-lex-digit-p (char-after (1+ (point)))))))) + +(defun parseclj-lex-symbol-start-p (char &optional alpha-only) + "Return t if CHAR is a valid start for a symbol. + +Symbols begin with a non-numeric character and can contain alphanumeric +characters and . * + ! - _ ? $ % & = < > '. If - + or . are the first +character, the second character (if any) must be non-numeric. + +In some cases, like in tagged elements, symbols are required to start with +alphabetic characters only. ALPHA-ONLY ensures this behavior." + (not (not (and char + (or (and (<= ?a char) (<= char ?z)) + (and (<= ?A char) (<= char ?Z)) + (and (not alpha-only) (member char '(?. ?* ?+ ?! ?- ?_ ?? ?$ ?% ?& ?= ?< ?> ?/ ?')))))))) + +(defun parseclj-lex-symbol-rest-p (char) + "Return t if CHAR is a valid character in a symbol. +For more information on what determines a valid symbol, see +`parseclj-lex-symbol-start-p'" + (or (parseclj-lex-symbol-start-p char) + (parseclj-lex-digit-p char) + (eq ?: char) + (eq ?# char))) + +(defun parseclj-lex-get-symbol-at-point (pos) + "Return the symbol at POS as a string." + (while (parseclj-lex-symbol-rest-p (char-after (point))) + (right-char)) + (buffer-substring-no-properties pos (point))) + +(defun parseclj-lex-symbol () + "Return a lex token representing a symbol. +Because of their special meaning, symbols \"nil\", \"true\", and \"false\" +are returned as their own lex tokens." + (let ((pos (point))) + (right-char) + (let ((sym (parseclj-lex-get-symbol-at-point pos))) + (cond + ((equal sym "nil") (parseclj-lex-token :nil "nil" pos)) + ((equal sym "true") (parseclj-lex-token :true "true" pos)) + ((equal sym "false") (parseclj-lex-token :false "false" pos)) + (t (parseclj-lex-token :symbol sym pos)))))) + +(defun parseclj-lex-string* () + "Helper for string/regex lexing. +Returns either the string, or an error token" + (let ((pos (point))) + (right-char) + (while (not (or (equal (char-after (point)) ?\") (parseclj-lex-at-eof-p))) + (if (equal (char-after (point)) ?\\) + (right-char 2) + (right-char))) + (when (equal (char-after (point)) ?\") + (right-char) + (buffer-substring-no-properties pos (point))))) + +(defun parseclj-lex-string () + "Return a lex token representing a string. +If EOF is reached without finding a closing double quote, a :lex-error +token is returned." + (let ((pos (point)) + (str (parseclj-lex-string*))) + (if str + (parseclj-lex-token :string str pos) + (parseclj-lex-error-token pos :invalid-string)))) + +(defun parseclj-lex-regex () + "Return a lex token representing a regular expression. +If EOF is reached without finding a closing double quote, a :lex-error +token is returned." + (let ((pos (1- (point))) + (str (parseclj-lex-string*))) + (if str + (parseclj-lex-token :regex (concat "#" str) pos) + (parseclj-lex-error-token pos :invalid-regex)))) + +(defun parseclj-lex-lookahead (n) + "Return a lookahead string of N characters after point." + (buffer-substring-no-properties (point) (min (+ (point) n) (point-max)))) + +(defun parseclj-lex-character () + "Return a lex token representing a character." + (let ((pos (point))) + (right-char) + (cond + ((equal (parseclj-lex-lookahead 3) "tab") + (right-char 3) + (parseclj-lex-token :character (buffer-substring-no-properties pos (point)) pos)) + + ((equal (parseclj-lex-lookahead 5) "space") + (right-char 5) + (parseclj-lex-token :character (buffer-substring-no-properties pos (point)) pos)) + + ((equal (parseclj-lex-lookahead 6) "return") + (right-char 6) + (parseclj-lex-token :character (buffer-substring-no-properties pos (point)) pos)) + + ((equal (parseclj-lex-lookahead 7) "newline") + (right-char 7) + (parseclj-lex-token :character (buffer-substring-no-properties pos (point)) pos)) + + ((string-match-p "^u[0-9a-fA-F]\\{4\\}" (parseclj-lex-lookahead 5)) + (right-char 5) + (parseclj-lex-token :character (buffer-substring-no-properties pos (point)) pos)) + + ((string-match-p "^o[0-8]\\{3\\}" (parseclj-lex-lookahead 4)) + (right-char 4) + (parseclj-lex-token :character (buffer-substring-no-properties pos (point)) pos)) + + (t + (right-char) + (parseclj-lex-token :character (buffer-substring-no-properties pos (point)) pos))))) + +(defun parseclj-lex-keyword () + "Return a lex token representing a keyword. +Keywords follow the same rules as symbols, except they start with one or +two colon characters. + +See `parseclj-lex-symbol', `parseclj-lex-symbol-start-p'." + (let ((pos (point))) + (right-char) + (when (equal (char-after (point)) ?:) ;; same-namespace keyword + (right-char)) + (if (equal (char-after (point)) ?:) ;; three colons in a row => lex-error + (progn + (right-char) + (parseclj-lex-error-token pos :invalid-keyword)) + (progn + (while (or (parseclj-lex-symbol-rest-p (char-after (point))) + (equal (char-after (point)) ?#)) + (right-char)) + (parseclj-lex-token :keyword (buffer-substring-no-properties pos (point)) pos))))) + +(defun parseclj-lex-comment () + "Return a lex token representing a comment." + (let ((pos (point))) + (goto-char (line-end-position)) + (when (equal (char-after (point)) ?\n) + (right-char)) + (parseclj-lex-token :comment (buffer-substring-no-properties pos (point)) pos))) + +(defun parseclj-lex-map-prefix () + "Return a lex token representing a map prefix." + (let ((pos (1- (point)))) + (right-char) + (when (equal (char-after (point)) ?:) + (right-char)) + (while (parseclj-lex-symbol-rest-p (char-after (point))) + (right-char)) + (parseclj-lex-token :map-prefix (buffer-substring-no-properties pos (point)) pos))) + +(defun parseclj-lex-next () + "Consume characters at point and return the next lexical token. + +See `parseclj-lex-token'." + (if (parseclj-lex-at-eof-p) + (parseclj-lex-token :eof nil (point)) + (let ((char (char-after (point))) + (pos (point))) + (cond + ((parseclj-lex-at-whitespace-p) + (parseclj-lex-whitespace)) + + ((equal char ?\() + (right-char) + (parseclj-lex-token :lparen "(" pos)) + + ((equal char ?\)) + (right-char) + (parseclj-lex-token :rparen ")" pos)) + + ((equal char ?\[) + (right-char) + (parseclj-lex-token :lbracket "[" pos)) + + ((equal char ?\]) + (right-char) + (parseclj-lex-token :rbracket "]" pos)) + + ((equal char ?{) + (right-char) + (parseclj-lex-token :lbrace "{" pos)) + + ((equal char ?}) + (right-char) + (parseclj-lex-token :rbrace "}" pos)) + + ((equal char ?') + (right-char) + (parseclj-lex-token :quote "'" pos)) + + ((equal char ?`) + (right-char) + (parseclj-lex-token :backquote "`" pos)) + + ((equal char ?~) + (right-char) + (if (eq ?@ (char-after (point))) + (progn + (right-char) + (parseclj-lex-token :unquote-splice "~@" pos)) + (parseclj-lex-token :unquote "~" pos))) + + ((parseclj-lex-at-number-p) + (parseclj-lex-number)) + + ((parseclj-lex-symbol-start-p char) + (parseclj-lex-symbol)) + + ((equal char ?\") + (parseclj-lex-string)) + + ((equal char ?\\) + (parseclj-lex-character)) + + ((equal char ?:) + (parseclj-lex-keyword)) + + ((equal char ?\;) + (parseclj-lex-comment)) + + ((equal char ?^) + (right-char) + (parseclj-lex-token :metadata "^" pos)) + + ((equal char ?@) + (right-char) + (parseclj-lex-token :deref "@" pos)) + + ((equal char ?#) + (right-char) + (let ((char (char-after (point)))) + (cond + ((equal char ?{) + (right-char) + (parseclj-lex-token :set "#{" pos)) + ((equal char ?_) + (right-char) + (parseclj-lex-token :discard "#_" pos)) + ((equal char ?\() + (right-char) + (parseclj-lex-token :lambda "#(" pos)) + ((equal char ?') + (right-char) + (parseclj-lex-token :var "#'" pos)) + ((equal char ?=) + (right-char) + (parseclj-lex-token :eval "#=" pos)) + ((equal char ?\") + (parseclj-lex-regex)) + ((equal char ?:) + (parseclj-lex-map-prefix)) + ((equal char ?\?) + (right-char) + (if (eq ?@ (char-after (point))) + (progn + (right-char) + (parseclj-lex-token :reader-conditional-splice "#?@" pos)) + (parseclj-lex-token :reader-conditional "#?" pos))) + ((parseclj-lex-symbol-start-p char t) + (right-char) + (parseclj-lex-token :tag (concat "#" (parseclj-lex-get-symbol-at-point (1+ pos))) pos)) + (t + (while (not (or (parseclj-lex-at-whitespace-p) + (parseclj-lex-at-eof-p))) + (right-char)) + (parseclj-lex-error-token pos :invalid-hashtag-dispatcher))))) + + (t + (progn + (right-char) + (parseclj-lex-error-token pos))))))) + +(provide 'parseclj-lex) + +;;; parseclj-lex.el ends here diff --git a/elpa/parseclj-20190531.711/parseclj-parser.el b/elpa/parseclj-20190531.711/parseclj-parser.el new file mode 100644 index 00000000..d0e5d24a --- /dev/null +++ b/elpa/parseclj-20190531.711/parseclj-parser.el @@ -0,0 +1,278 @@ +;;; parseclj-parser.el --- Clojure/EDN parser -*- lexical-binding: t; -*- + +;; Copyright (C) 2017-2018 Arne Brasseur + +;; Author: Arne Brasseur +;; Keywords: lisp +;; Package-Requires: ((emacs "25") (a "0.1.0alpha4")) +;; Version: 0.1.0 + +;; This file is not part of GNU Emacs. + +;; This file is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Commentary: + +;; A shift/reduce parser for Clojure source. + +;;; Code: + +(require 'cl-lib) +(require 'subr-x) +(require 'a) +(require 'parseclj-lex) + +(define-error 'parseclj-parser-error "parseclj: Syntax error") + +(defun parseclj--error (format &rest args) + "Signal a parse error. +Takes a FORMAT string and optional ARGS to be passed to +`format-message'. Signals a 'parseclj-parser-error signal, which +can be handled with `condition-case'." + (signal 'parseclj-parser-error (list (apply #'format-message format args)))) + +(defun parseclj--find-opening-token (stack closing-token) + "Scan STACK for an opening-token matching CLOSING-TOKEN." + (cl-case (parseclj-lex-token-type closing-token) + (:rparen (parseclj-lex-token-type + (seq-find (lambda (token) + (member (parseclj-lex-token-type token) + '(:lparen :lambda))) + stack))) + (:rbracket :lbracket) + (:rbrace (parseclj-lex-token-type + (seq-find (lambda (token) + (member (parseclj-lex-token-type token) + '(:lbrace :set))) + stack))))) + +(defun parseclj--reduce-coll (stack closing-token reduce-branch options) + "Reduce collection based on the top of the STACK and a CLOSING-TOKEN. + +REDUCE-BRANCH is a function to be applied to the collection of tokens found +from the top of the stack until an opening token that matches +CLOSING-TOKEN. This function should return an AST token representing such +collection. + +OPTIONS is an association list. This list is also passed down to the +REDUCE-BRANCH function. See `parseclj-parser' for more information on +available options." + (let ((opening-token-type (parseclj--find-opening-token stack closing-token)) + (fail-fast (a-get options :fail-fast t)) + (collection nil)) + + ;; unwind the stack until opening-token-type is found, adding to collection + (while (and stack (not (eq (parseclj-lex-token-type (car stack)) opening-token-type))) + (push (pop stack) collection)) + + ;; did we find the right token? + (if (eq (parseclj-lex-token-type (car stack)) opening-token-type) + (progn + (when fail-fast + ;; any unreduced tokens left: bail early + (when-let ((token (seq-find #'parseclj-lex-token-p collection))) + (parseclj--error "At position %s, unmatched %S" + (a-get token :pos) + (parseclj-lex-token-type token)))) + + ;; all good, call the reducer so it can return an updated stack with a + ;; new node at the top. + (let ((opening-token (pop stack))) + (funcall reduce-branch stack opening-token collection options))) + + ;; Unwound the stack without finding a matching paren: either bail early + ;; or return the original stack and continue parsing + (if fail-fast + (parseclj--error "At position %s, unmatched %S" + (a-get closing-token :pos) + (parseclj-lex-token-type closing-token)) + + (reverse collection))))) + +(defun parseclj--take-value (stack value-p) + "Scan STACK until a value is found. +Return everything up to the value in reversed order (meaning the value +comes first in the result). + +STACK is the current parse stack to scan. + +VALUE-P a predicate to distinguish reduced values from non-values (tokens +and whitespace)." + (let ((result nil)) + (cl-block nil + (while stack + (cond + ((parseclj-lex-token-p (car stack)) + (cl-return nil)) + + ((funcall value-p (car stack)) + (cl-return (cons (car stack) result))) + + (t + (push (pop stack) result))))))) + +(defun parseclj--take-token (stack value-p token-types) + "Scan STACK until a token of a certain type is found. +Returns nil if a value is encountered before a matching token is found. +Return everything up to the token in reversed order (meaning the token +comes first in the result). + +STACK is the current parse stack to scan. + +VALUE-P a predicate to distinguish reduced values from non-values (tokens +and whitespace). + +TOKEN-TYPES are the token types to look for." + (let ((result nil)) + (cl-block nil + (while stack + (cond + ((member (parseclj-lex-token-type (car stack)) token-types) + (cl-return (cons (car stack) result))) + ((funcall value-p (car stack)) + (cl-return nil)) + ((parseclj-lex-token-p (car stack)) + (cl-return nil)) + (t + (push (pop stack) result))))))) + +(defun parseclj-single-value-p (stack value-p) + "Return t if STACK only has a single node for which VALUE-P is true. + +This checks if the stack contains a single, fully reduced value, and no +dangling unmatched tokens. When parsing with `:read-one' this indicates a +form can be returned." + (and (not (cl-reduce (lambda (bool node) + (or bool (parseclj-lex-token-p node))) + stack + :initial-value nil)) + (parseclj--take-value stack value-p))) + +(defun parseclj-parser (reduce-leaf reduce-branch &optional options) + "Clojure/EDN stack-based shift-reduce parser. + +REDUCE-LEAF does reductions for leaf nodes. It is a function that takes +the current value of the stack and a token, and either returns an updated +stack, with a new leaf node at the top (front), or returns the stack +unmodified. + +REDUCE-BRANCH does reductions for branch nodes. It is a function that +takes the current value of the stack, the type of branch node to create, +and a list of child nodes, and returns an updated stack, with the new node +at the top (front). + +What \"node\" means in this case is up to the reducing functions, it could +be AST nodes (as in the case of `parseclj-parser-clojure'), or plain +values/sexps (as in the case of `parseedn-read'), or something else. The +only requirement is that they should not put raw tokens back on the stack, +as the parser relies on the presence or absence of these to detect parse +errors. + +OPTIONS is an association list which is passed on to the reducing +functions. Additionally the following options are recognized + +- `:fail-fast' + Raise an error when a parse error is encountered, rather than continuing + with a partial result. +- `:value-p' + A predicate function to differentiate values from tokens and + whitespace. This is needed when scanning the stack to see if any + reductions can be performed. By default anything that isn't a token is + considered a value. This can be problematic when parsing with + `:lexical-preservation', and which case you should provide an + implementation that also returns falsy for :whitespace, :comment, and + :discard AST nodes. +- `:tag-readers' + An association list that describes tag handler functions for any possible + tag. This options in only available in `parseedn-read', for more + information, please refer to its documentation. +- `:read-one' + Return as soon as a single complete value has been read." + (let ((fail-fast (a-get options :fail-fast t)) + (read-one (a-get options :read-one)) + (value-p (a-get options :value-p (lambda (e) (not (parseclj-lex-token-p e))))) + (stack nil) + (token (parseclj-lex-next))) + + (while (not (or (and read-one (parseclj-single-value-p stack value-p)) + (eq (parseclj-lex-token-type token) :eof))) + ;; (message "STACK: %S" stack) + ;; (message "TOKEN: %S\n" token) + + (when (and fail-fast (parseclj-lex-error-p token)) + (parseclj--error "Invalid token at %s: %S" + (a-get token :pos) + (parseclj-lex-token-form token))) + + ;; Reduce based on the top item on the stack (collections) + (cond + ((parseclj-lex-leaf-token-p token) + (setf stack (funcall reduce-leaf stack token options))) + + ((parseclj-lex-closing-token-p token) + (setf stack (parseclj--reduce-coll stack token reduce-branch options))) + + (t (push token stack))) + + ;; Reduce based on top two items on the stack (special prefixed elements) + (let* ((top-value (parseclj--take-value stack value-p)) + (opening-token (parseclj--take-token (nthcdr (length top-value) stack) value-p parseclj-lex--prefix-tokens)) + new-stack) + (while (and top-value opening-token) + ;; (message "Reducing...") + ;; (message " - STACK %S" stack) + ;; (message " - OPENING-TOKEN %S" opening-token) + ;; (message " - TOP-VALUE %S" top-value) + (setq new-stack (nthcdr (+ (length top-value) (length opening-token)) stack)) + (setq stack (funcall reduce-branch new-stack (car opening-token) (append (cdr opening-token) top-value) options)) + + ;; recur + (setq top-value (parseclj--take-value stack value-p)) + (setq opening-token (parseclj--take-token (nthcdr (length top-value) stack) value-p parseclj-lex--prefix-tokens)))) + + ;; Reduce based on top three items on the stack (metadata, namespaced maps) + (let* ((top-value-1 (parseclj--take-value stack value-p)) + (top-value-2 (parseclj--take-value (nthcdr (length top-value-1) stack) value-p)) + (opening-token (parseclj--take-token (nthcdr (+ (length top-value-1) + (length top-value-2)) stack) value-p parseclj-lex--prefix-2-tokens)) + new-stack) + (while (and top-value-1 top-value-2 opening-token) + (setq new-stack (nthcdr (apply #'+ (mapcar #'length (list top-value-1 top-value-2 opening-token))) stack)) + (setq stack (funcall reduce-branch new-stack (car opening-token) (append (cdr opening-token) top-value-2 top-value-1) options)) + + ;; recur + (setq top-value-1 (parseclj--take-value stack value-p)) + (setq top-value-2 (parseclj--take-value (nthcdr (length top-value-1) stack) value-p)) + (setq opening-token (parseclj--take-token (nthcdr (+ (length top-value-1) + (length top-value-2)) stack) value-p parseclj-lex--prefix-2-tokens)))) + + (setq token (parseclj-lex-next))) + + ;; reduce root + (when fail-fast + (when-let ((token (seq-find #'parseclj-lex-token-p stack))) + (parseclj--error "At position %s, unmatched %S" + (a-get token :pos) + (parseclj-lex-token-type token)))) + + (if read-one + (car (parseclj--take-value stack value-p)) + (car (funcall reduce-branch nil (parseclj-lex-token :root "" 1) + (reverse stack) + options))))) + +(provide 'parseclj-parser) +;;; parseclj-parser.el ends here diff --git a/elpa/parseclj-20190531.711/parseclj-pkg.el b/elpa/parseclj-20190531.711/parseclj-pkg.el new file mode 100644 index 00000000..d3117745 --- /dev/null +++ b/elpa/parseclj-20190531.711/parseclj-pkg.el @@ -0,0 +1,12 @@ +(define-package "parseclj" "20190531.711" "Clojure/EDN parser" + '((emacs "25") + (a "0.1.0alpha4")) + :keywords + '("lisp" "clojure" "edn" "parser") + :authors + '(("Arne Brasseur" . "arne@arnebrasseur.net")) + :maintainer + '("Arne Brasseur" . "arne@arnebrasseur.net")) +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/elpa/parseclj-20190531.711/parseclj.el b/elpa/parseclj-20190531.711/parseclj.el new file mode 100644 index 00000000..7515d5e0 --- /dev/null +++ b/elpa/parseclj-20190531.711/parseclj.el @@ -0,0 +1,93 @@ +;;; parseclj.el --- Clojure/EDN parser -*- lexical-binding: t; -*- + +;; Copyright (C) 2017-2018 Arne Brasseur + +;; Author: Arne Brasseur +;; Keywords: lisp clojure edn parser +;; Package-Requires: ((emacs "25") (a "0.1.0alpha4")) +;; Version: 0.1.0 + +;; This file is not part of GNU Emacs. + +;; This file is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Commentary: + +;; Top level API for the Clojure parser. + +;;; Code: + +(require 'parseclj-parser) +(require 'parseclj-ast) + +(defun parseclj-parse-clojure (&rest string-and-options) + "Parse Clojure source to AST. + +Reads either from the current buffer, starting from point, until +`point-max', or reads from the optional string argument. + +STRING-AND-OPTIONS can be an optional string, followed by +key-value pairs to specify parsing options. + +- `:lexical-preservation' Retain whitespace, comments, and + discards. Defaults to nil. +- `:fail-fast' Raise an error when encountering invalid syntax. + Defaults to t. +- `:read-one' + Read a single form. Defaults to false: parse the complete input." + (if (stringp (car string-and-options)) + (with-temp-buffer + (insert (car string-and-options)) + (goto-char 1) + (apply 'parseclj-parse-clojure (cdr string-and-options))) + (let* ((value-p (lambda (e) + (and (parseclj-ast-node-p e) + (not (member (parseclj-ast-node-type e) '(:whitespace :comment :discard)))))) + (options (apply 'a-list :value-p value-p string-and-options)) + (lexical? (a-get options :lexical-preservation))) + (parseclj-parser (if lexical? + #'parseclj-ast--reduce-leaf-with-lexical-preservation + #'parseclj-ast--reduce-leaf) + (if lexical? + #'parseclj-ast--reduce-branch-with-lexical-preservation + #'parseclj-ast--reduce-branch) + options)))) + +(defun parseclj-unparse-clojure (ast) + "Parse Clojure AST to source code. + +Given an abstract syntax tree AST (as returned by +`parseclj-parse-clojure'), turn it back into source code, and +insert it into the current buffer." + (if (parseclj-ast-leaf-node-p ast) + (insert (a-get ast :form)) + (if (eql (parseclj-ast-node-type ast) :tag) + (parseclj-ast--unparse-tag ast) + (parseclj-ast--unparse-collection ast)))) + +(defun parseclj-unparse-clojure-to-string (ast) + "Parse Clojure AST to a source code string. + +Given an abstract syntax tree AST (as returned by +`parseclj-parse-clojure'), turn it back into source code, and +return it as a string" + (with-temp-buffer + (parseclj-unparse-clojure ast) + (buffer-substring-no-properties (point-min) (point-max)))) + +(provide 'parseclj) + +;;; parseclj.el ends here diff --git a/elpa/parseedn-20190331.1058/parseedn-autoloads.el b/elpa/parseedn-20190331.1058/parseedn-autoloads.el new file mode 100644 index 00000000..9bdb12c3 --- /dev/null +++ b/elpa/parseedn-20190331.1058/parseedn-autoloads.el @@ -0,0 +1,22 @@ +;;; parseedn-autoloads.el --- automatically extracted autoloads +;; +;;; Code: + +(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path)))) + + +;;;### (autoloads nil "parseedn" "parseedn.el" (0 0 0 0)) +;;; Generated autoloads from parseedn.el + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "parseedn" '("parseedn-"))) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; coding: utf-8 +;; End: +;;; parseedn-autoloads.el ends here diff --git a/elpa/parseedn-20190331.1058/parseedn-pkg.el b/elpa/parseedn-20190331.1058/parseedn-pkg.el new file mode 100644 index 00000000..2f7d44f8 --- /dev/null +++ b/elpa/parseedn-20190331.1058/parseedn-pkg.el @@ -0,0 +1,2 @@ +;;; -*- no-byte-compile: t -*- +(define-package "parseedn" "20190331.1058" "Clojure/EDN parser" '((emacs "25") (a "0.1.0alpha4") (parseclj "0.1.0")) :commit "ddf824bc1df1585867cb7f27f2dd8ca8df760569" :keywords '("lisp" "clojure" "edn" "parser") :authors '(("Arne Brasseur" . "arne@arnebrasseur.net")) :maintainer '("Arne Brasseur" . "arne@arnebrasseur.net")) diff --git a/elpa/parseedn-20190331.1058/parseedn.el b/elpa/parseedn-20190331.1058/parseedn.el new file mode 100644 index 00000000..45fd4f9e --- /dev/null +++ b/elpa/parseedn-20190331.1058/parseedn.el @@ -0,0 +1,202 @@ +;;; parseedn.el --- Clojure/EDN parser -*- lexical-binding: t; -*- + +;; Copyright (C) 2017-2018 Arne Brasseur + +;; Author: Arne Brasseur +;; Keywords: lisp clojure edn parser +;; Package-Version: 20190331.1058 +;; Package-Requires: ((emacs "25") (a "0.1.0alpha4") (parseclj "0.1.0")) +;; Version: 0.1.0 + +;; This file is not part of GNU Emacs. + +;; This file is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Commentary: + +;; parseedn is an Emacs Lisp library for parsing EDN (Clojure) data. +;; It uses parseclj's shift-reduce parser internally. + +;; EDN and Emacs Lisp have some important differences that make +;; translation from one to the other not transparent (think +;; representing an EDN map into Elisp, or being able to differentiate +;; between false and nil in Elisp). Because of this, parseedn takes +;; certain decisions when parsing and transforming EDN data into Elisp +;; data types. For more information please refer to parseclj's design +;; documentation. + +;;; Code: + +;; The EDN spec is not clear about whether \u0123 and \o012 are supported in +;; strings. They are described as character literals, but not as string escape +;; codes. In practice all implementations support them (mostly with broken +;; surrogate pair support), so we do the same. Sorry, emoji 🙁. +;; +;; Note that this is kind of broken, we don't correctly detect if \u or \o forms +;; don't have the right forms. + +(require 'a) +(require 'cl-lib) +(require 'parseclj-parser) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Reader + +(defvar parseedn-default-tag-readers + (a-list 'inst (lambda (s) + (cl-list* 'edn-inst (date-to-time s))) + 'uuid (lambda (s) + (list 'edn-uuid s))) + "Default reader functions for handling tagged literals in EDN. +These are the ones defined in the EDN spec, #inst and #uuid. It +is not recommended you change this variable, as this globally +changes the behavior of the EDN reader. Instead pass your own +handlers as an optional argument to the reader functions.") + +(defun parseedn-reduce-leaf (stack token _options) + "Put in the STACK an elisp value representing TOKEN. + +OPTIONS is an association list. See `parseclj-parse' for more information +on available options." + (if (member (parseclj-lex-token-type token) (list :whitespace :comment)) + stack + (cons (parseclj-lex--leaf-token-value token) stack))) + +(defun parseedn-reduce-branch (stack opening-token children options) + "Reduce STACK with an sequence containing a collection of other elisp values. +Ignores discard tokens. + +OPENING-TOKEN is a lex token representing an opening paren, bracket or +brace. +CHILDREN is a collection elisp values to be reduced into an elisp +sequence. +OPTIONS is an association list. See `parseclj-parse' for more information +on available options." + (let ((tag-readers (a-merge parseedn-default-tag-readers (a-get options :tag-readers))) + (token-type (parseclj-lex-token-type opening-token))) + (if (eq token-type :discard) + stack + (cons + (cl-case token-type + (:root children) + (:lparen children) + (:lbracket (apply #'vector children)) + (:set (list 'edn-set children)) + (:lbrace (let* ((kvs (seq-partition children 2)) + (hash-map (make-hash-table :test 'equal :size (length kvs)))) + (seq-do (lambda (pair) + (puthash (car pair) (cadr pair) hash-map)) + kvs) + hash-map)) + (:tag (let* ((tag (intern (substring (a-get opening-token :form) 1))) + (reader (a-get tag-readers tag :missing))) + (when (eq :missing reader) + (user-error "No reader for tag #%S in %S" tag (a-keys tag-readers))) + (funcall reader (car children))))) + stack)))) + +(defun parseedn-read (&optional tag-readers) + "Read content from current buffer and parse it as EDN source. +Returns an Emacs Lisp value. + +TAG-READERS is an optional association list where keys are symbols +identifying *tags*, and values are tag handler functions that receive one +argument: *the tagged element*, and specify how to interpret it." + (parseclj-parser #'parseedn-reduce-leaf + #'parseedn-reduce-branch + (a-list :tag-readers tag-readers))) + +(defun parseedn-read-str (s &optional tag-readers) + "Parse string S as EDN. +Returns an Emacs Lisp value. + +TAG-READERS is an optional association list. For more information, see +`parseedn-read'." + (with-temp-buffer + (insert s) + (goto-char 1) + (car (parseedn-read tag-readers)))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Printer + +(defun parseedn-print-seq (coll) + "Insert sequence COLL as EDN into the current buffer." + (parseedn-print (elt coll 0)) + (let ((next (seq-drop coll 1))) + (when (not (seq-empty-p next)) + (insert " ") + (parseedn-print-seq next)))) + +(defun parseedn-print-kvs (map) + "Insert hash table MAP as an EDN map into the current buffer." + (let ((keys (a-keys map))) + (parseedn-print (car keys)) + (insert " ") + (parseedn-print (a-get map (car keys))) + (let ((next (cdr keys))) + (when (not (seq-empty-p next)) + (insert ", ") + (parseedn-print-kvs next))))) + +(defun parseedn-print (datum) + "Insert DATUM as EDN into the current buffer. +DATUM can be any Emacs Lisp value." + (cond + ((or (null datum) (numberp datum)) + (prin1 datum (current-buffer))) + + ((stringp datum) + (insert "\"") + (seq-doseq (char datum) + (insert (cl-case char + (?\t "\\t") + (?\f "\\f") + (?\" "\\\"") + (?\r "\\r") + (?\n"foo\t" "\\n") + (?\\ "\\\\") + (t (char-to-string char))))) + (insert "\"")) + + ((eq t datum) + (insert "true")) + + ((symbolp datum) + (insert (symbol-name datum))) + + ((vectorp datum) (insert "[") (parseedn-print-seq datum) (insert "]")) + + ((consp datum) + (cond + ((eq 'edn-set (car datum)) + (insert "#{") (parseedn-print-seq (cadr datum)) (insert "}")) + (t (insert "(") (parseedn-print-seq datum) (insert ")")))) + + ((hash-table-p datum) + (insert "{") (parseedn-print-kvs datum) (insert "}")))) + +(defun parseedn-print-str (datum) + "Return a string containing DATUM as EDN. +DATUM can be any Emacs Lisp value." + (with-temp-buffer + (parseedn-print datum) + (buffer-substring-no-properties (point-min) (point-max)))) + +(provide 'parseedn) + +;;; parseedn.el ends here diff --git a/elpa/parseedn-readme.txt b/elpa/parseedn-readme.txt new file mode 100644 index 00000000..48bb53e4 --- /dev/null +++ b/elpa/parseedn-readme.txt @@ -0,0 +1,10 @@ +parseedn is an Emacs Lisp library for parsing EDN (Clojure) data. +It uses parseclj's shift-reduce parser internally. + +EDN and Emacs Lisp have some important differences that make +translation from one to the other not transparent (think +representing an EDN map into Elisp, or being able to differentiate +between false and nil in Elisp). Because of this, parseedn takes +certain decisions when parsing and transforming EDN data into Elisp +data types. For more information please refer to parseclj's design +documentation. -- 2.47.3